--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ Necessary TODO: Put your copyright here.\r
+\r
+ This program and the accompanying materials are made available under the\r
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ and is available at http://www.eclipse.org/legal/epl-v10.html\r
+--><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">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>commons.opendaylight</artifactId>\r
+ <version>1.4.2-SNAPSHOT</version>\r
+ <relativePath>../../opendaylight/commons/opendaylight</relativePath>\r
+ </parent>\r
+ <artifactId>features-adsal-compatibility</artifactId>\r
+ <packaging>jar</packaging>\r
+ <properties>\r
+ <features.file>features.xml</features.file>\r
+ <feature.test.version>0.6.2-SNAPSHOT</feature.test.version>\r
+ </properties>\r
+ <dependencies>\r
+ <!--\r
+ Necessary TODO: Put dependencies on any feature repos\r
+ you use in your features.xml file.\r
+\r
+ Note: they will need to be <type>xml</xml>\r
+ and <classifier>features</classifier>.\r
+ One other thing to watch for is to make sure they are\r
+ <scope>compile</compile>, which they should be by default,\r
+ but be cautious lest they be at a different scope in a parent pom.\r
+\r
+ Examples:\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>features-yangtools</artifactId>\r
+ <version>0.6.2-SNAPSHOT</version>\r
+ <classifier>features</classifier>\r
+ <type>xml</type>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>features-mdsal</artifactId>\r
+ <version>1.1-SNAPSHOT</version>\r
+ <classifier>features</classifier>\r
+ <type>xml</type>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.openflowplugin</groupId>\r
+ <artifactId>features-openflowplugin</artifactId>\r
+ <version>0.0.3-SNAPSHOT</version>\r
+ <classifier>features</classifier>\r
+ <type>xml</type>\r
+ </dependency>\r
+ -->\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>features-mdsal</artifactId>\r
+ <version>${mdsal.version}</version>\r
+ <classifier>features</classifier>\r
+ <type>xml</type>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>features-flow</artifactId>\r
+ <version>${mdsal.version}</version>\r
+ <classifier>features</classifier>\r
+ <type>xml</type>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>features-adsal</artifactId>\r
+ <version>${sal.version}</version>\r
+ <classifier>features</classifier>\r
+ <type>xml</type>\r
+ </dependency>\r
+\r
+ <!--\r
+ Necessary TODO: Put dependencies for bundles directly referenced\r
+ in your features.xml file. For every <bundle> reference in your\r
+ features.xml file, you need a corresponding dependency here.\r
+\r
+ Examples:\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>controller-provider</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>controller-model</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ -->\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal-compatibility</artifactId>\r
+ <version>${mdsal.version}</version>\r
+ </dependency>\r
+\r
+ <!--\r
+ Necessary TODO: Put dependencies for configfiles directly referenced\r
+ in your features.xml file. For every <configfile> reference in your\r
+ features.xml file, you need a corresponding dependency here.\r
+\r
+ Example (presuming here version is coming from the parent pom):\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>controller-config</artifactId>\r
+ <version>${project.version}</version>\r
+ <type>xml</type>\r
+ <classifier>config</classifier>\r
+ </dependency>\r
+ -->\r
+\r
+ <!--\r
+ Optional TODO: Remove TODO comments.\r
+ -->\r
+ <!-- test to validate features.xml -->\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>features-test</artifactId>\r
+ <version>${feature.test.version}</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>opendaylight-karaf-empty</artifactId>\r
+ <version>${commons.opendaylight.version}</version>\r
+ <type>zip</type>\r
+ </dependency>\r
+ <!-- Uncomment this if you get an error : java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-simple</artifactId>\r
+ <version>1.7.2</version>\r
+ </dependency>\r
+ -->\r
+\r
+ </dependencies>\r
+ <build>\r
+ <resources>\r
+ <resource>\r
+ <directory>src/main/resources</directory>\r
+ <filtering>true</filtering>\r
+ </resource>\r
+ </resources>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-resources-plugin</artifactId>\r
+ <executions>\r
+ <execution>\r
+ <id>filter</id>\r
+ <phase>generate-resources</phase>\r
+ <goals>\r
+ <goal>resources</goal>\r
+ </goals>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>build-helper-maven-plugin</artifactId>\r
+ <executions>\r
+ <execution>\r
+ <id>attach-artifacts</id>\r
+ <phase>package</phase>\r
+ <goals>\r
+ <goal>attach-artifact</goal>\r
+ </goals>\r
+ <configuration>\r
+ <artifacts>\r
+ <artifact>\r
+ <file>${project.build.directory}/classes/${features.file}</file>\r
+ <type>xml</type>\r
+ <classifier>features</classifier>\r
+ </artifact>\r
+ </artifacts>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-surefire-plugin</artifactId>\r
+ <version>${surefire.version}</version>\r
+ <configuration>\r
+ <systemPropertyVariables>\r
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>\r
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>\r
+ <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>\r
+ </systemPropertyVariables>\r
+ <dependenciesToScan>\r
+ <dependency>org.opendaylight.yangtools:features-test</dependency>\r
+ </dependenciesToScan>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <scm>\r
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>\r
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>\r
+ <tag>HEAD</tag>\r
+ <url>https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=summary</url>\r
+ </scm>\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Necessary TODO: Put your copyright statement here
+
+ 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
+-->
+<features name="odl-adsal-compatibility-${sal.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-adsal/${sal.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-flow/${mdsal.version}/xml/features</repository>
+ <feature name='odl-adsal-compatibility-all' version='${project.version}' description='OpenDaylight :: controller :: All'>
+ <feature version='${sal.version}'>odl-adsal-compatibility</feature>
+ </feature>
+ <feature name='odl-adsal-compatibility' description="OpenDaylight :: AD-SAL :: Compatibility" version="${sal.version}">
+ <feature version="${mdsal.version}">odl-mdsal-broker</feature>
+ <feature version="${mdsal.version}">odl-flow-model</feature>
+ <feature version="${sal.version}">odl-adsal-all</feature>
+ <bundle>mvn:org.opendaylight.controller/sal-compatibility/${mdsal.version}</bundle>
+ </feature>
+</features>
</parent>
<artifactId>features-adsal</artifactId>
<version>${sal.version}</version>
- <packaging>pom</packaging>
+ <packaging>jar</packaging>
<name>Features :: AD-SAL Features</name>
<description>AD-SAL Features POM</description>
<properties>
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>base-features</artifactId>
- <version>${project.parent.version}</version>
+ <artifactId>features-base</artifactId>
<classifier>features</classifier>
<type>xml</type>
- <scope>runtime</scope>
+ </dependency>
+ <!-- test to validate features.xml -->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ </dependency>
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <version>1.4.2-SNAPSHOT</version>
+ <type>zip</type>
+ </dependency>
+ <!-- Bundle dependencies -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>dummy-console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.connection</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.connection.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.networkconfiguration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.networkconfiguration.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services-implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.stub</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>logging.bridge</artifactId>
</dependency>
</dependencies>
<build>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+ <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>
+ </systemPropertyVariables>
+ <dependenciesToScan>
+ <dependency>org.opendaylight.yangtools:features-test</dependency>
+ </dependenciesToScan>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features name="adsal-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <repository>mvn:org.opendaylight.controller/features-base/${commons.opendaylight.version}/xml/features</repository>
<feature name="odl-adsal-all" description="OpenDaylight AD-SAL All Features" version="${sal.version}">
<feature version="${sal.version}">odl-adsal-core</feature>
<feature version="${sal.networkconfiguration.version}">odl-adsal-networkconfiguration</feature>
<feature version="${configuration.version}">odl-adsal-configuration</feature>
</feature>
<feature name="odl-adsal-core" description="OpenDaylight :: AD-SAL :: Core" version="${sal.version}">
- <feature>base-felix-dm</feature>
- <feature>base-dummy-console</feature>
+ <feature>odl-base-felix-dm</feature>
+ <feature>odl-base-dummy-console</feature>
<feature version="${project.version}">odl-adsal-thirdparty</feature>
- <bundle start="true" start-level="35">mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+ <bundle start="true">mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
<!-- <bundle>mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version}</bundle> -->
<bundle>mvn:org.opendaylight.controller/sal/${sal.version}</bundle>
<bundle>mvn:org.opendaylight.controller/sal.implementation/${sal.implementation.version}</bundle>
</feature>
<feature name="odl-adsal-networkconfiguration" description="OpenDaylight :: AD-SAL :: Network Configuration" version="${sal.networkconfiguration.version}">
+ <feature>odl-adsal-core</feature>
<bundle>mvn:org.opendaylight.controller/sal.networkconfiguration/${sal.networkconfiguration.version}</bundle>
<bundle>mvn:org.opendaylight.controller/sal.networkconfiguration.implementation/${sal.networkconfiguration.version}</bundle>
</feature>
</feature>
<feature name="odl-adsal-clustering" description="OpenDaylight :: AD-SAL :: Clustering" version="${clustering.services.version}">
<feature>transaction</feature>
- <feature>base-felix-dm</feature>
- <feature>base-eclipselink-persistence</feature>
+ <feature>odl-base-felix-dm</feature>
+ <feature>odl-base-eclipselink-persistence</feature>
<feature version="${sal.version}">odl-adsal-core</feature>
<bundle>mvn:org.opendaylight.controller/clustering.services/${clustering.services.version}</bundle>
<bundle>mvn:org.opendaylight.controller/clustering.services-implementation/${clustering.services_implementation.version}</bundle>
<version>1.4.2-SNAPSHOT</version>
<relativePath>../../opendaylight/commons/opendaylight</relativePath>
</parent>
- <artifactId>base-features</artifactId>
- <packaging>pom</packaging>
+ <artifactId>features-base</artifactId>
+ <packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>Base Features POM</description>
<properties>
<features.file>features.xml</features.file>
</properties>
+ <dependencies>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>dummy-console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>karaf-tomcat-security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.thirdparty</groupId>
+ <artifactId>ganymed</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-json-org</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-base</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-jaxb-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <!-- Jersey for JAXRS -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>eclipselink</groupId>
+ <artifactId>javax.persistence</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>eclipselink</groupId>
+ <artifactId>javax.resource</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>javax.servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>javax.servlet.jsp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.apache.felix.gogo.command</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.apache.felix.gogo.shell</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.cm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.ds</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.launcher</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi.services</artifactId>
+ </dependency>
+ <!-- Gemini Web -->
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.gemini.web.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.gemini.web.extender</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.gemini.web.tomcat</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.kernel.equinox.extensions</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.util.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.util.io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.util.math</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.util.osgi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.util.osgi.manifest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geminiweb</groupId>
+ <artifactId>org.eclipse.virgo.util.parser.manifest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-codec-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-common</artifactId>
+ </dependency>
+
+ <!--Netty-->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.activation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.annotation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.ejb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.el</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.mail.glassfish</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.servlet.jsp.jstl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.servlet.jsp.jstl.impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>javax.xml.rpc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.catalina</artifactId>
+ <version>7.0.53.v201406061610</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.catalina.ha</artifactId>
+ <version>7.0.53.v201406070630</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.catalina.tribes</artifactId>
+ <version>7.0.53.v201406070630</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.coyote</artifactId>
+ <version>7.0.53.v201406070630</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.el</artifactId>
+ <version>7.0.53.v201406060720</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.jasper</artifactId>
+ <version>7.0.53.v201406070630</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.juli.extras</artifactId>
+ <version>7.0.53.v201406060720</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.tomcat.api</artifactId>
+ <version>7.0.53.v201406060720</version>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.tomcat.util</artifactId>
+ <version>7.0.53.v201406070630</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aopalliance</groupId>
+ <artifactId>com.springsource.org.aopalliance</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.dependencymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.dependencymanager.shell</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.fileinstall</artifactId>
+ </dependency>
+ <!-- felix webconsole -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.webconsole</artifactId>
+ <classifier>all</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox.http</groupId>
+ <artifactId>servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.antlr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.moxy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.transaction</groupId>
+ <artifactId>jboss-transaction-api_1.1_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jolokia</groupId>
+ <artifactId>jolokia-osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-all</artifactId>
+ </dependency>
+ <!-- Visual VM hook -->
+ <dependency>
+ <groupId>org.ow2.chameleon.management</groupId>
+ <artifactId>chameleon-mbeans</artifactId>
+ </dependency>
+
+ <!-- Third party depedencies -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.aop</artifactId>
+ </dependency>
+ <!-- Add Pax Exam -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.asm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.context.support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.expression</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.transaction</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>org.springframework.web.servlet</artifactId>
+ </dependency>
+ <!-- Spring security -->
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-config</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-taglibs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>virgomirror</groupId>
+ <artifactId>org.eclipse.jdt.core.compiler.batch</artifactId>
+ </dependency>
+
+ <!-- test to validate features.xml -->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ </dependency>
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <version>1.4.2-SNAPSHOT</version>
+ <type>zip</type>
+ </dependency>
+ </dependencies>
<build>
<resources>
<resource>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+ <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>
+ </systemPropertyVariables>
+ <dependenciesToScan>
+ <dependency>org.opendaylight.yangtools:features-test</dependency>
+ </dependenciesToScan>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<features name="base-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+<features name="odl-base-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <feature name="base-all" description="OpenDaylight Controller" version="${project.version}">
+ <feature name="odl-base-all" description="OpenDaylight Controller" version="${project.version}">
<feature>http</feature>
<feature>transaction</feature>
- <feature>base-felix-dm</feature>
- <feature>base-aries-spi-fly</feature>
- <feature>base-dummy-console</feature>
- <feature>base-apache-commons</feature>
- <feature>base-eclipselink-persistence</feature>
- <feature>base-gemini-web</feature>
- <feature>base-tomcat</feature>
- <feature>base-netty</feature>
- <feature>base-jersey</feature>
- <feature>base-spring-security</feature>
+ <feature>odl-base-felix-dm</feature>
+ <feature>odl-base-aries-spi-fly</feature>
+ <feature>odl-base-dummy-console</feature>
+ <feature>odl-base-apache-commons</feature>
+ <feature>odl-base-eclipselink-persistence</feature>
+ <feature>odl-base-gemini-web</feature>
+ <feature>odl-base-tomcat</feature>
+ <feature>odl-base-netty</feature>
+ <feature>odl-base-jersey</feature>
+ <feature>odl-base-jackson</feature>
+ <feature>odl-base-spring-security</feature>
</feature>
- <feature name="base-dummy-console" description="Temporary Dummy Console" version="1.1.0-SNAPSHOT">
+ <feature name="odl-base-dummy-console" description="Temporary Dummy Console" version="1.1.0-SNAPSHOT">
<bundle>mvn:org.opendaylight.controller/dummy-console/1.1.0-SNAPSHOT</bundle>
</feature>
- <feature name="base-felix-dm" description="Felix Dependency Manager" version="${felix.dependencymanager.version}">
- <bundle start-level="35">mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version}</bundle>
- <bundle start-level="35">mvn:org.apache.felix/org.apache.felix.dependencymanager/${felix.dependencymanager.version}</bundle>
- <bundle start-level="35">mvn:org.apache.felix/org.apache.felix.dependencymanager.shell/${felix.dependencymanager.shell.version}</bundle>
+ <feature name="odl-base-felix-dm" description="Felix Dependency Manager" version="${felix.dependencymanager.version}">
+ <bundle>mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version}</bundle>
+ <bundle>mvn:org.apache.felix/org.apache.felix.dependencymanager/${felix.dependencymanager.version}</bundle>
+ <bundle>mvn:org.apache.felix/org.apache.felix.dependencymanager.shell/${felix.dependencymanager.shell.version}</bundle>
</feature>
- <feature name="base-aries-spi-fly" description="Aries SPI Fly" version="${spifly.version}">
- <bundle start-level="35">mvn:org.apache.aries/org.apache.aries.util/1.1.0</bundle>
- <bundle start-level="35">mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/${spifly.version}</bundle>
- <bundle start-level="35">mvn:org.ow2.asm/asm-all/4.0</bundle>
+ <feature name="odl-base-aries-spi-fly" description="Aries SPI Fly" version="${spifly.version}">
+ <bundle>mvn:org.apache.aries/org.apache.aries.util/1.1.0</bundle>
+ <bundle>mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/${spifly.version}</bundle>
+ <bundle>mvn:org.ow2.asm/asm-all/4.0</bundle>
</feature>
- <feature name='base-netty' version='${netty.version}'>
+ <feature name='odl-base-netty' version='${netty.version}'>
<bundle>wrap:mvn:io.netty/netty-buffer/${netty.version}</bundle>
<bundle>wrap:mvn:io.netty/netty-codec/${netty.version}</bundle>
<bundle>wrap:mvn:io.netty/netty-transport/${netty.version}</bundle>
<bundle>wrap:mvn:io.netty/netty-codec-http/${netty.version}</bundle>
<bundle>mvn:org.opendaylight.controller.thirdparty/ganymed/1.1-SNAPSHOT</bundle>
</feature>
- <feature name="base-jersey" description="Jersey" version="${jersey.version}">
- <feature>base-gemini-web</feature>
- <bundle>mvn:org.opendaylight.controller.thirdparty/com.sun.jersey.jersey-servlet/${jersey.version}</bundle>
+ <feature name="odl-base-jersey" description="Jersey" version="${jersey.version}">
+ <feature>odl-base-gemini-web</feature>
<bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
<bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
<bundle>mvn:com.sun.jersey/jersey-client/${jersey.version}</bundle>
<bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
- <bundle start="true" start-level="35">mvn:javax.ws.rs/javax.ws.rs-api/2.0</bundle>
</feature>
- <feature name="base-jersey2-osgi" description="OSGi friendly Jersey" version="${jersey2.publisher.version}">
+ <feature name="odl-base-jersey2-osgi" description="OSGi friendly Jersey" version="${jersey2.publisher.version}">
<feature>http</feature>
<bundle>mvn:com.eclipsesource.jaxrs/jersey-all/${jersey2.version}</bundle>
<bundle>mvn:com.eclipsesource.jaxrs/publisher/${jersey2.publisher.version}</bundle>
- <bundle start="true" start-level="35">mvn:javax.ws.rs/javax.ws.rs-api/${jsr311.v2.api.version}</bundle>
+ <bundle start="true">mvn:javax.ws.rs/javax.ws.rs-api/${jsr311.v2.api.version}</bundle>
<bundle>mvn:javax.annotation/javax.annotation-api/${javax.annotation.version}</bundle>
</feature>
- <feature name="base-jackson" description="Jackson JAX-RS" version="${jackson.version}">
- <bundle start="true" start-level="35">mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
- <bundle start="true" start-level="35">mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
- <bundle start="true" start-level="35">mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
- <bundle start="true" start-level="35">mvn:org.codehaus.jettison/jettison/${jettison.version}</bundle>
- <bundle start="true" start-level="35">mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
- <bundle start="true" start-level="35">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version}</bundle>
- <bundle start="true" start-level="35">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version}</bundle>
+ <feature name="odl-base-jackson" description="Jackson JAX-RS" version="${jackson.version}">
+ <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-client/${jersey.version}</bundle>
+ <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+ <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+ <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+ <bundle start="true">mvn:org.codehaus.jettison/jettison/${jettison.version}</bundle>
+ <bundle start="true">mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
+ <bundle start="true">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version}</bundle>
+ <bundle start="true">mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version}</bundle>
</feature>
- <feature name="base-slf4j" description="SLF4J Logging" version="${slf4j.version}">
- <bundle start-level="35">mvn:org.slf4j/slf4j-jdk14/1.7.2</bundle>
- <bundle start-level="35">mvn:org.slf4j/slf4j-nop/1.7.2</bundle>
- <bundle start-level="35">mvn:org.slf4j/slf4j-simple/1.7.2</bundle>
- <bundle start="true" start-level="35">mvn:org.slf4j/slf4j-api/1.7.2</bundle>
+ <feature name="odl-base-slf4j" description="SLF4J Logging" version="${slf4j.version}">
+ <bundle>mvn:org.slf4j/slf4j-jdk14/1.7.2</bundle>
+ <bundle>mvn:org.slf4j/slf4j-nop/1.7.2</bundle>
+ <bundle>mvn:org.slf4j/slf4j-simple/1.7.2</bundle>
+ <bundle start="true">mvn:org.slf4j/slf4j-api/1.7.2</bundle>
</feature>
- <feature name="base-apache-commons" description="Apache Commons Libraries" version="${project.version}">
- <bundle start="true" start-level="35">mvn:com.google.guava/guava/${guava.version}</bundle>
- <bundle start="true" start-level="35">mvn:org.javassist/javassist/${javassist.version}</bundle>
- <bundle start="true" start-level="35">mvn:commons-io/commons-io/${commons.io.version}</bundle>
- <bundle start="true" start-level="35">mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
- <bundle start="true" start-level="35">mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
- <bundle start="true" start-level="35">mvn:commons-net/commons-net/${commons.net.version}</bundle>
+ <feature name="odl-base-apache-commons" description="Apache Commons Libraries" version="${project.version}">
+ <bundle start="true">mvn:com.google.guava/guava/${guava.version}</bundle>
+ <bundle start="true">mvn:org.javassist/javassist/${javassist.version}</bundle>
+ <bundle start="true">mvn:commons-io/commons-io/${commons.io.version}</bundle>
+ <bundle start="true">mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
+ <bundle start="true">mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+ <bundle start="true">mvn:commons-net/commons-net/${commons.net.version}</bundle>
</feature>
- <feature name="base-eclipselink-persistence" description="EclipseLink Persistence API" version="2.0.4.v201112161009">
- <bundle start="true" start-level="35">mvn:eclipselink/javax.persistence/2.0.4.v201112161009</bundle>
- <bundle start="true" start-level="35">mvn:eclipselink/javax.resource/1.5.0.v200906010428</bundle>
- <bundle start="true" start-level="35">mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/2.5.0</bundle>
- <bundle start="true" start-level="35">mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0</bundle>
+ <feature name="odl-base-eclipselink-persistence" description="EclipseLink Persistence API" version="2.0.4.v201112161009">
+ <bundle start="true">mvn:eclipselink/javax.persistence/2.0.4.v201112161009</bundle>
+ <bundle start="true">mvn:eclipselink/javax.resource/1.5.0.v200906010428</bundle>
+ <bundle start="true">mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/2.5.0</bundle>
+ <bundle start="true">mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0</bundle>
</feature>
- <feature name="base-gemini-web" description="Gemini Web" version="${geminiweb.version}">
+ <feature name="odl-base-gemini-web" description="Gemini Web" version="${geminiweb.version}">
<feature>http</feature>
<feature>transaction</feature>
- <feature>base-slf4j</feature>
- <feature>base-felix-dm</feature>
- <feature>base-jackson</feature>
- <feature>base-apache-commons</feature>
- <bundle start="true" start-level="35">mvn:com.google.code.gson/gson/${gson.version}</bundle>
- <bundle start="true" start-level="35">mvn:commons-fileupload/commons-fileupload/${commons.fileupload.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.gemini.web.core/${geminiweb.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.gemini.web.extender/${geminiweb.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.virgo.util.common/${virgo.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.virgo.util.io/${virgo.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.virgo.util.math/${virgo.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.virgo.util.osgi/${virgo.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.virgo.util.osgi.manifest/${virgo.version}</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.virgo.util.parser.manifest/${virgo.version}</bundle>
- <bundle start="true" start-level="35">mvn:org.apache.felix/org.apache.felix.fileinstall/3.1.6</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.activation/1.1.0.v201211130549</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.annotation/1.1.0.v201209060031</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.ejb/3.1.1.v201204261316</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.el/2.2.0.v201108011116</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.mail.glassfish/1.4.1.v201108011116</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.xml.rpc/1.1.0.v201005080400</bundle>
- <bundle start="true" start-level="35">mvn:org.eclipse.jetty.orbit/javax.servlet.jsp/2.2.0.v201112011158</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.servlet.jsp.jstl/1.2.0.v201105211821</bundle>
- <bundle start="true" start-level="35">mvn:orbit/javax.servlet.jsp.jstl.impl/1.2.0.v201210211230</bundle>
+ <feature>odl-base-slf4j</feature>
+ <feature>odl-base-felix-dm</feature>
+ <feature>odl-base-jackson</feature>
+ <feature>odl-base-apache-commons</feature>
+ <bundle start="true">mvn:com.google.code.gson/gson/${gson.version}</bundle>
+ <bundle start="true">mvn:commons-fileupload/commons-fileupload/${commons.fileupload.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.gemini.web.core/${geminiweb.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.gemini.web.extender/${geminiweb.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.virgo.util.common/${virgo.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.virgo.util.io/${virgo.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.virgo.util.math/${virgo.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.virgo.util.osgi/${virgo.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.virgo.util.osgi.manifest/${virgo.version}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.virgo.util.parser.manifest/${virgo.version}</bundle>
+ <bundle start="true">mvn:org.apache.felix/org.apache.felix.fileinstall/3.1.6</bundle>
+ <bundle start="true">mvn:orbit/javax.activation/1.1.0.v201211130549</bundle>
+ <bundle start="true">mvn:orbit/javax.annotation/1.1.0.v201209060031</bundle>
+ <bundle start="true">mvn:orbit/javax.ejb/3.1.1.v201204261316</bundle>
+ <bundle start="true">mvn:orbit/javax.el/2.2.0.v201108011116</bundle>
+ <bundle start="true">mvn:orbit/javax.mail.glassfish/1.4.1.v201108011116</bundle>
+ <bundle start="true">mvn:orbit/javax.xml.rpc/1.1.0.v201005080400</bundle>
+ <bundle start="true">mvn:org.eclipse.jetty.orbit/javax.servlet.jsp/2.2.0.v201112011158</bundle>
+ <bundle start="true">mvn:orbit/javax.servlet.jsp.jstl/1.2.0.v201105211821</bundle>
+ <bundle start="true">mvn:orbit/javax.servlet.jsp.jstl.impl/1.2.0.v201210211230</bundle>
</feature>
- <feature name="base-tomcat" description="OpenDaylight Tomcat" version="7.0.32">
- <feature>base-gemini-web</feature>
- <feature>base-eclipselink-persistence</feature>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.catalina/7.0.32.v201211201336</bundle>
- <bundle start="true" start-level="35">mvn:geminiweb/org.eclipse.gemini.web.tomcat/${geminiweb.version}</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.catalina.ha/7.0.32.v201211201952</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.catalina.tribes/7.0.32.v201211201952</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.coyote/7.0.32.v201211201952</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.el/7.0.32.v201211081135</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.jasper/7.0.32.v201211201952</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.juli.extras/7.0.32.v201211081135</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.tomcat.api/7.0.32.v201211081135</bundle>
- <bundle start="true" start-level="35">mvn:orbit/org.apache.tomcat.util/7.0.32.v201211201952</bundle>
- <bundle start="true" start-level="35">wrap:mvn:virgomirror/org.eclipse.jdt.core.compiler.batch/3.8.0.I20120518-2145</bundle>
+ <feature name="odl-base-tomcat" description="OpenDaylight Tomcat" version="7.0.53">
+ <feature>odl-base-gemini-web</feature>
+ <feature>odl-base-eclipselink-persistence</feature>
+ <bundle start="true">mvn:orbit/org.apache.catalina/${commons.karaf.catalina}</bundle>
+ <bundle start="true">mvn:geminiweb/org.eclipse.gemini.web.tomcat/${geminiweb.version}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.catalina.ha/${commons.karaf.catalina.ha}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.catalina.tribes/${commons.karaf.catalina.tribes}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.coyote/${commons.karaf.coyote}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.el/${commons.karaf.el}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.jasper/${commons.karaf.jasper}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.juli.extras/${commons.karaf.juli.version}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.tomcat.api/${commons.karaf.tomcat.api}</bundle>
+ <bundle start="true">mvn:orbit/org.apache.tomcat.util/${commons.karaf.tomcat.util}</bundle>
+ <bundle start="true" >mvn:org.opendaylight.controller/karaf-tomcat-security/${karaf.security.version}</bundle>
+ <bundle start="true">wrap:mvn:virgomirror/org.eclipse.jdt.core.compiler.batch/${eclipse.jdt.core.compiler.batch.version}</bundle>
</feature>
- <feature name="base-spring" description="Opendaylight Spring Support" version="${spring.version}">
+ <feature name="odl-base-spring" description="Opendaylight Spring Support" version="${spring.version}">
<bundle>mvn:org.ow2.asm/asm-all/${asm.version}</bundle>
<bundle>mvn:org.aopalliance/com.springsource.org.aopalliance/${aopalliance.version}</bundle>
<bundle>mvn:org.springframework/org.springframework.aop/${spring.version}</bundle>
<bundle>mvn:org.springframework/org.springframework.expression/${spring.version}</bundle>
<bundle>mvn:org.springframework/org.springframework.transaction/${spring.version}</bundle>
</feature>
- <feature name="base-spring-web" description="OpenDaylight Spring Web" version="${spring.version}">
- <feature>base-spring</feature>
- <feature>base-gemini-web</feature>
+ <feature name="odl-base-spring-web" description="OpenDaylight Spring Web" version="${spring.version}">
+ <feature>odl-base-spring</feature>
+ <feature>odl-base-gemini-web</feature>
<bundle>mvn:org.springframework/org.springframework.web/${spring.version}</bundle>
<bundle>mvn:org.springframework/org.springframework.web.servlet/${spring.version}</bundle>
</feature>
- <feature name="base-spring-security" description="OpenDaylight Spring Security" version="${spring-security.version}">
- <feature>base-spring-web</feature>
+ <feature name="odl-base-spring-security" description="OpenDaylight Spring Security" version="${spring-security.version}">
+ <feature>odl-base-spring-web</feature>
<bundle>mvn:org.springframework.security/spring-security-config/${spring-security.version}</bundle>
<bundle>mvn:org.springframework.security/spring-security-core/${spring-security.version}</bundle>
<bundle>mvn:org.springframework.security/spring-security-taglibs/${spring-security.version}</bundle>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.controller/features-config-persister/${config.version}/xml/features</repository>
- <feature name='odl-config-netty' version='${project.version}'>
+ <feature name='odl-config-netty' version='${project.version}' description="OpenDaylight :: Config-Netty">
<feature version='${project.version}'>odl-config-netty-config-api</feature>
<bundle>mvn:org.opendaylight.controller/netty-event-executor-config/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/netty-threadgroup-config/${project.version}</bundle>
<repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-netconf/${netconf.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config/${config.version}/xml/features</repository>
- <feature name='odl-config-all' version='${project.version}'>
+ <feature name='odl-config-persister-all' version='${project.version}' description="OpenDaylight :: Config Persister:: All">
<feature version='${project.version}'>odl-config-persister</feature>
<feature version='${project.version}'>odl-config-startup</feature>
</feature>
- <feature name='odl-config-persister' version='${project.version}'>
+ <feature name='odl-config-persister' version='${project.version}' description="OpenDaylight :: Config Persister ">
<feature version='${netconf.version}'>odl-netconf-api</feature>
<feature version='${project.version}'>odl-config-api</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding-generator</feature>
<bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version}</bundle>
<bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version}</bundle>
</feature>
- <feature name='odl-config-startup' version='${project.version}'>
+ <feature name='odl-config-startup' version='${project.version}' description="OpenDaylight :: Config Persister:: Config Startup">
<feature version='${project.version}'>odl-config-netconf-connector</feature>
<feature version='${project.version}'>odl-config-persister</feature>
<feature version='${project.version}'>odl-netconf-impl</feature>
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
- <feature name='odl-config-all' version='${project.version}'>
+ <feature name='odl-config-all' version='${project.version}' description="OpenDaylight :: Config :: All">
<feature version='${mdsal.version}'>odl-mdsal-common</feature>
<feature version='${project.version}'>odl-config-api</feature>
<feature version='${project.version}'>odl-config-netty-config-api</feature>
<feature version='${project.version}'>odl-config-manager</feature>
</feature>
- <feature name='odl-mdsal-common' version='${mdsal.version}'>
+ <feature name='odl-mdsal-common' version='${mdsal.version}' description="OpenDaylight :: Config :: All">
<feature version='${yangtools.version}'>odl-yangtools-data-binding</feature>
<bundle>mvn:org.opendaylight.controller/sal-common/${mdsal.version}</bundle>
<bundle>mvn:org.opendaylight.controller/sal-common-api/${mdsal.version}</bundle>
<bundle>mvn:org.opendaylight.controller/sal-common-util/${mdsal.version}</bundle>
</feature>
- <feature name='odl-config-api' version='${project.version}'>
+ <feature name='odl-config-api' version='${project.version}' description="OpenDaylight :: Config :: API">
<bundle>mvn:org.opendaylight.controller/config-api/${project.version}</bundle>
<feature version='${yangtools.version}'>odl-yangtools-common</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding</feature>
</feature>
- <feature name='odl-config-netty-config-api' version='${project.version}'>
+ <feature name='odl-config-netty-config-api' version='${project.version}' description="OpenDaylight :: Config :: Netty Config API">
<feature version='${project.version}'>odl-config-api</feature>
<bundle>mvn:org.opendaylight.controller/netty-config-api/${project.version}</bundle>
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
</feature>
- <feature name='odl-config-core' version='${project.version}'>
+ <feature name='odl-config-core' version='${project.version}' description="OpenDaylight :: Config :: Core">
<feature version='${yangtools.version}'>odl-yangtools-common</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding-generator</feature>
<bundle>mvn:com.google.guava/guava/${guava.version}</bundle>
<bundle>mvn:org.javassist/javassist/${javassist.version}</bundle>
</feature>
- <feature name='odl-config-manager' version='${project.version}'>
+ <feature name='odl-config-manager' version='${project.version}' description="OpenDaylight :: Config :: Manager">
<feature version='${project.version}'>odl-config-core</feature>
<bundle>mvn:org.opendaylight.controller/config-manager/${project.version}</bundle>
</feature>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
- <feature name='odl-flow-model' version='${project.version}'>
+ <feature name='odl-flow-model' version='${project.version}' description="OpenDaylight :: Flow :: Model">
<feature version='${yangtools.version}'>odl-yangtools-models</feature>
<bundle>mvn:org.opendaylight.controller.model/model-flow-base/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller.model/model-flow-service/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller.model/model-inventory/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller.model/model-topology/${project.version}</bundle>
</feature>
- <feature name='odl-flow-services' version='${project.version}'>
+ <feature name='odl-flow-services' version='${project.version}' description="OpenDaylight :: Flow :: Services">
<feature version='${project.version}'>odl-mdsal-broker</feature>
<feature version='${project.version}'>odl-flow-model</feature>
<bundle>mvn:org.opendaylight.controller.md/topology-manager/${project.version}</bundle>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-broker-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-dom-xsql</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-dom-xsql-config</artifactId>
+ <classifier>config</classifier>
+ <type>xml</type>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
<artifactId>jersey-server</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller.thirdparty</groupId>
- <artifactId>com.sun.jersey.jersey-servlet</artifactId>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<type>xml</type>
<classifier>config</classifier>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-docgen</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-json-org</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-jaxb-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-base</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
<!-- test to validate features.xml -->
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<repository>mvn:org.opendaylight.controller/features-config/${config.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config-persister/${config.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config-netty/${config.version}/xml/features</repository>
- <feature name='odl-mdsal-all' version='${project.version}'>
+ <feature name='odl-mdsal-all' version='${project.version}' description="OpenDaylight :: MDSAL :: All">
<feature version='${project.version}'>odl-mdsal-broker</feature>
<feature version='${project.version}'>odl-mdsal-netconf-connector</feature>
<feature version='${project.version}'>odl-restconf</feature>
+ <feature version='${project.version}'>odl-mdsal-xsql</feature>
<feature version='${project.version}'>odl-toaster</feature>
</feature>
- <feature name='odl-mdsal-broker' version='${project.version}'>
+ <feature name='odl-mdsal-broker' version='${project.version}' description="OpenDaylight :: MDSAL :: Broker">
<feature version='${yangtools.version}'>odl-yangtools-common</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding</feature>
<feature version='${mdsal.version}'>odl-mdsal-common</feature>
<bundle>mvn:org.opendaylight.controller/sal-inmemory-datastore/${project.version}</bundle>
<configfile finalname="${config.configfile.directory}/${config.mdsal.configfile}">mvn:org.opendaylight.controller/md-sal-config/${mdsal.version}/xml/config</configfile>
</feature>
- <feature name='odl-mdsal-netconf-connector' version='${project.version}'>
+ <feature name='odl-mdsal-netconf-connector' version='${project.version}' description="OpenDaylight :: MDSAL :: Netconf Connector">
<feature version='${project.version}'>odl-mdsal-broker</feature>
<feature version='${netconf.version}'>odl-netconf-client</feature>
<feature version='${yangtools.version}'>odl-yangtools-models</feature>
<bundle>mvn:org.opendaylight.controller/netconf-config-dispatcher/${config.version}</bundle>
<configfile finalname="${config.configfile.directory}/${config.netconf.connector.configfile}">mvn:org.opendaylight.controller/netconf-connector-config/${netconf.version}/xml/config</configfile>
</feature>
- <feature name='odl-restconf' version='${project.version}'>
+ <feature name='odl-restconf' version='${project.version}' description="OpenDaylight :: Restconf">
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature>war</feature>
<bundle>mvn:org.opendaylight.controller/sal-rest-connector/${project.version}</bundle>
<bundle>mvn:com.google.code.gson/gson/${gson.version}</bundle>
+ <bundle>mvn:org.opendaylight.yangtools/yang-data-codec-gson/${yangtools.version}</bundle>
<bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
<bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
- <bundle>mvn:org.opendaylight.controller.thirdparty/com.sun.jersey.jersey-servlet/${jersey.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
<bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-codec/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-codec-http/${netty.version}</bundle>
<bundle>mvn:org.opendaylight.controller/sal-remote/${project.version}</bundle>
<configfile finalname="${config.configfile.directory}/${config.restconf.configfile}">mvn:org.opendaylight.controller/sal-rest-connector-config/${mdsal.version}/xml/config</configfile>
</feature>
- <feature name='odl-toaster' version='${project.version}'>
+ <feature name='odl-toaster' version='${project.version}' description="OpenDaylight :: Toaster">
<feature version='${yangtools.version}'>odl-yangtools-common</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding</feature>
<feature version='${project.version}'>odl-mdsal-broker</feature>
<bundle>mvn:org.opendaylight.controller.samples/sample-toaster-provider/${project.version}</bundle>
<configfile finalname="${config.configfile.directory}/${config.toaster.configfile}">mvn:org.opendaylight.controller.samples/toaster-config/${project.version}/xml/config</configfile>
</feature>
+ <feature name ='odl-mdsal-xsql' version='${project.version}'>
+ <feature version='${project.version}'>odl-mdsal-broker</feature>
+ <bundle>mvn:org.opendaylight.controller/sal-dom-xsql/${project.version}</bundle>
+ <configfile finalname="${config.configfile.directory}/${config.xsql.configfile}">mvn:org.opendaylight.controller/sal-dom-xsql-config/${project.version}/xml/config</configfile>
+ </feature>
+ <feature name ='odl-mdsal-apidocs' version='${project.version}'>
+ <feature version='${project.version}'>odl-restconf</feature>
+ <bundle>mvn:org.opendaylight.controller/sal-rest-docgen/${project.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.datatype/jackson-datatype-json-org/${jackson.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version}</bundle>
+ <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
+ <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
+ <bundle>wrap:mvn:org.json/json/${org.json.version}</bundle>
+ </feature>
</features>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-auth</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>ietf-netconf-monitoring</artifactId>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>ganymed</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.openexi</groupId>
<artifactId>nagasena</artifactId>
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.controller/features-protocol-framework/${protocol-framework.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config/${config.version}/xml/features</repository>
- <feature name='odl-netconf-all' version='${project.version}'>
+ <feature name='odl-netconf-all' version='${project.version}' description="OpenDaylight :: Netconf :: All">
<feature version='${project.version}'>odl-netconf-api</feature>
<feature version='${project.version}'>odl-netconf-mapping-api</feature>
<feature version='${project.version}'>odl-netconf-util</feature>
<feature version='${project.version}'>odl-netconf-monitoring</feature>
</feature>
- <feature name='odl-netconf-api' version='${project.version}'>
+ <feature name='odl-netconf-api' version='${project.version}' description="OpenDaylight :: Netconf :: API">
<feature version='${protocol-framework.version}'>odl-protocol-framework</feature>
<bundle>mvn:org.opendaylight.controller/netconf-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/netconf-auth/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/ietf-netconf-monitoring/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/ietf-netconf-monitoring-extension/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools.model/ietf-inet-types/${ietf-inet-types.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools.model/ietf-yang-types/${ietf-yang-types.version}</bundle>
</feature>
- <feature name='odl-netconf-mapping-api' version='${project.version}'>
+ <feature name='odl-netconf-mapping-api' version='${project.version}' description="OpenDaylight :: Netconf :: Mapping API">
<feature version='${project.version}'>odl-netconf-api</feature>
<bundle>mvn:org.opendaylight.controller/netconf-mapping-api/${project.version}</bundle>
</feature>
<feature version='${project.version}'>odl-netconf-mapping-api</feature>
<bundle>mvn:org.opendaylight.controller/netconf-util/${project.version}</bundle>
</feature>
- <feature name='odl-netconf-impl' version='${project.version}'>
+ <feature name='odl-netconf-impl' version='${project.version}' description="OpenDaylight :: Netconf :: Impl">
<feature version='${project.version}'>odl-netconf-api</feature>
<feature version='${project.version}'>odl-netconf-mapping-api</feature>
<feature version='${project.version}'>odl-netconf-util</feature>
<feature version='${project.version}'>odl-netconf-netty-util</feature>
<bundle>mvn:org.opendaylight.controller/netconf-impl/${project.version}</bundle>
</feature>
- <feature name='odl-config-netconf-connector' version='${project.version}'>
+ <feature name='odl-config-netconf-connector' version='${project.version}' description="OpenDaylight :: Netconf :: Connector">
<feature version='${config.version}'>odl-config-manager</feature>
<feature version='${project.version}'>odl-netconf-api</feature>
<feature version='${project.version}'>odl-netconf-mapping-api</feature>
<feature version='${project.version}'>odl-netconf-util</feature>
<bundle>mvn:org.opendaylight.controller/config-netconf-connector/${project.version}</bundle>
</feature>
- <feature name='odl-netconf-netty-util' version='${project.version}'>
+ <feature name='odl-netconf-netty-util' version='${project.version}' description="OpenDaylight :: Netconf :: Netty Util">
<feature version='${project.version}'>odl-netconf-api</feature>
<feature version='${project.version}'>odl-netconf-mapping-api</feature>
<feature version='${project.version}'>odl-netconf-util</feature>
<bundle>mvn:org.opendaylight.controller/netconf-netty-util/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller.thirdparty/ganymed/${ganymed.version}</bundle>
+ <bundle>mvn:org.apache.sshd/sshd-core/${sshd-core.version}</bundle>
<bundle>mvn:org.openexi/nagasena/${exi.nagasena.version}</bundle>
<bundle>mvn:io.netty/netty-codec/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
</feature>
- <feature name='odl-netconf-client' version="${project.version}">
+ <feature name='odl-netconf-client' version='${project.version}' description="OpenDaylight :: Netconf :: Client">
<feature version='${project.version}'>odl-netconf-netty-util</feature>
<bundle>mvn:org.opendaylight.controller/netconf-client/${project.version}</bundle>
- <configfile finalname="${config.configfile.directory}/${config.netconf.client.configfile}">mvn:org.opendaylight.controller/netconf-config/${netconf.version}/xml/config</configfile>
+ <configfile finalname='${config.configfile.directory}/${config.netconf.client.configfile}'>mvn:org.opendaylight.controller/netconf-config/${netconf.version}/xml/config</configfile>
</feature>
- <feature name='odl-netconf-monitoring' version='${project.version}'>
+ <feature name='odl-netconf-monitoring' version='${project.version}' description="OpenDaylight :: Netconf :: Monitoring">
<feature version='${project.version}'>odl-netconf-util</feature>
<bundle>mvn:org.opendaylight.controller/netconf-monitoring/${project.version}</bundle>
</feature>
-</features>
\ No newline at end of file
+</features>
<relativePath>../../opendaylight/commons/opendaylight</relativePath>
</parent>
<artifactId>features-nsf</artifactId>
- <packaging>pom</packaging>
+ <version>${nsf.version}</version>
+ <packaging>jar</packaging>
<name>OpenDaylight :: Features :: Network Service Functions</name>
<description>Feature for Network Service Functions</description>
<properties>
<features.file>features.xml</features.file>
</properties>
+ <dependencies>
+ <!-- test to validate features.xml -->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ </dependency>
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <version>1.4.2-SNAPSHOT</version>
+ <type>zip</type>
+ </dependency>
+ <!-- Feature Dependencies -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-adsal</artifactId>
+ <version>${sal.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-base</artifactId>
+ <classifier>features</classifier>
+ <version>${commons.opendaylight.version}</version>
+ <type>xml</type>
+ </dependency>
+ <!-- Bundle Dependencies -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>appauth</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>arphandler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>bundlescanner</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>bundlescanner.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>connectionmanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>connectionmanager.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>connectionmanager.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager.shell</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>controllermanager.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>devices.web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>flowprogrammer.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>flows.web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>routing.dijkstra_implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwarding.staticrouting</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwarding.staticrouting.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwardingrulesmanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwardingrulesmanager.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker.shell</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>httpservice-bridge</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>jolokia-bridge</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>logging.bridge</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.bridgedomain.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>osgi-brandfragment.web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>samples.loadbalancer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>samples.loadbalancer.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>samples.simpleforwarding</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>statistics.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>statisticsmanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>statisticsmanager.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>subnets.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topology.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topology.web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager.shell</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>troubleshoot.web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>usermanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>usermanager.implementation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>usermanager.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.thirdparty</groupId>
+ <artifactId>net.sf.jung2</artifactId>
+ </dependency>
+ </dependencies>
<build>
<resources>
<resource>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+ <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>
+ </systemPropertyVariables>
+ <dependenciesToScan>
+ <dependency>org.opendaylight.yangtools:features-test</dependency>
+ </dependenciesToScan>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features name="nsf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <repository>mvn:org.opendaylight.controller/features-base/${commons.opendaylight.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-adsal/${sal.version}/xml/features</repository>
<feature name="odl-nsf-all" description="OpenDaylight :: NSF :: All Network Service Functions" version="${project.version}">
<feature version="${sal.version}">odl-adsal-all</feature>
<feature version="${project.version}">odl-nsf-managers</feature>
</feature>
<feature name="odl-nsf-managers" description="OpenDaylight :: AD-SAL :: Network Service Functions" version="${project.version}">
- <feature version="${project.version}">base-all</feature>
+ <feature version="${commons.opendaylight.version}">odl-base-all</feature>
<feature version="${sal.version}">odl-adsal-all</feature>
<bundle>mvn:org.opendaylight.controller/usermanager/${usermanager.version}</bundle>
<bundle>mvn:org.opendaylight.controller/usermanager.implementation/${usermanager.version}</bundle>
<bundle>mvn:org.opendaylight.controller/hosttracker.implementation/${hosttracker.implementation.version}</bundle>
<bundle>mvn:org.opendaylight.controller/hosttracker.shell/${hosttracker.shell.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/forwarding.staticrouting</bundle>
+ <bundle>mvn:org.opendaylight.controller/forwarding.staticrouting/${forwarding.staticrouting}</bundle>
<bundle>mvn:org.opendaylight.controller.thirdparty/net.sf.jung2/2.0.1</bundle>
- <bundle>mvn:org.opendaylight.controller/routing.dijkstra_implementation</bundle>
+ <bundle>mvn:org.opendaylight.controller/routing.dijkstra_implementation/${routing.dijkstra_implementation.version}</bundle>
</feature>
<feature name="odl-adsal-northbound" description="OpenDaylight :: AD-SAL :: Northbound APIs" version="${project.version}">
- <feature version="${project.version}">base-all</feature>
+ <feature version="${commons.opendaylight.version}">odl-base-all</feature>
<feature version="${project.version}">odl-nsf-managers</feature>
- <bundle start-level="35">mvn:org.ow2.asm/asm-all/${asm.version}</bundle>
+ <bundle>mvn:org.ow2.asm/asm-all/${asm.version}</bundle>
<!--
TODO : Resolve these in a follow-up commit
<bundle>mvn:org.opendaylight.controller/httpservice-bridge/${httpservice-bridge.northbound.version}</bundle>
<bundle>mvn:org.opendaylight.controller/bundlescanner/${bundlescanner.api.version}</bundle>
<bundle>mvn:org.opendaylight.controller/bundlescanner.implementation/${bundlescanner.implementation.version}</bundle>
<bundle>mvn:org.opendaylight.controller/commons.northbound/${northbound.commons.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/connectionmanager.northbound/${connectionmanager.version}</bundle>
<bundle>mvn:org.opendaylight.controller/flowprogrammer.northbound/${flowprogrammer.northbound.version}</bundle>
<bundle>mvn:org.opendaylight.controller/hosttracker.northbound/${hosttracker.northbound.version}</bundle>
<bundle>mvn:org.opendaylight.controller/networkconfig.bridgedomain.northbound/${networkconfig.bridgedomain.northbound.version}</bundle>
<module>flow</module>
<module>netconf</module>
<module>protocol-framework</module>
+ <module>adsal-compatibility</module>
</modules>
-</project>
+</project>
\ No newline at end of file
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.controller/features-config/${config.version}/xml/features</repository>
- <feature name='odl-protocol-framework' version='${project.version}'>
+ <feature name='odl-protocol-framework' version='${project.version}' description="OpenDaylight :: Protocol Framework">
<feature version='${config.version}'>odl-config-api</feature>
<feature version='${config.version}'>odl-config-netty-config-api</feature>
<bundle>mvn:org.opendaylight.controller/protocol-framework/${protocol-framework.version}</bundle>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-configfile-archetype</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.2</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <description>Configuration files for md-sal</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git/md-sal-config</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git/md-sal-config</developerConnection>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL/md-sal-config</url>
+ </scm>
+
+ <distributionManagement>
+ <repository>
+ <id>opendaylight-release</id>
+ <url>http://nexus.opendaylight.org/content/repositories/opendaylight.release/</url>
+ </repository>
+ <snapshotRepository>
+ <id>opendaylight-snapshot</id>
+ <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
+ </snapshotRepository>
+ <site>
+ <id>website</id>
+ <url>dav:http://nexus.opendaylight.org/content/sites/site/sal-parent</url>
+ </site>
+ </distributionManagement>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="md-sal-config"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <requiredProperties>
+ <requiredProperty key="repoName"/>
+ </requiredProperties>
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2014 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
+--><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>
+ <!--
+ Necessary TODO: Hookup your parent pom here, else you will not get necessary versions,
+ maven repos etc. If you run this archetype in a subdirectory of your project, it
+ will pick the pom.xml from the parent directory as the parent pom, which may or may
+ not be correct.
+ -->
+ <!--
+ Necessary TODO: Replace the contents of src/main/resources/80-${repoName}.xml with
+ the proper config subsystem contents for your module
+ -->
+ <artifactId>${artifactId}</artifactId>
+ <groupId>${groupId}</groupId>
+ <description>Configuration files for md-sal</description>
+ <!-- Optional TODO: Uncomment version if you are not using a parent pom.xml
+ <version>${version}</version>
+ -->
+ <packaging>jar</packaging>
+ <properties>
+ <!-- Optional TODO: Rename your configfile to taste -->
+ <configfile>80-${repoName}.xml</configfile>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${configfile}</file>
+ <type>xml</type>
+ <classifier>config</classifier>
+ </artifact>
+ <!--
+ Optional TODO: Add additional config files
+ You may need to add more than one config file
+ if so, you just need to add additional <artifact> entries
+ here WITH DIFFERENT CLASSIFIERS
+ Example:
+ <artifact>
+ <file>${project.build.directory}/classes/<another-configfile></file>
+ <type>xml</type>
+ <classifier>config-<meaningful suffix to describe your other configfile></classifier>
+ </artifact>
+ -->
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/${repoName}.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/${repoName}.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://git.opendaylight.org/gerrit/gitweb?p=${repoName}.git;a=summary</url>
+ </scm>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+-->
+<snapshot>
+ <required-capabilities>
+ <!-- Necessary TODO put your required capabilities here
+
+ Examples:
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:netty?module=netty&revision=2013-11-19</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup?module=threadgroup&revision=2013-11-07</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:netty:timer?module=netty-timer&revision=2013-11-19</capability>
+ -->
+ </required-capabilities>
+ <configuration>
+
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <!-- Optional TODO: Add your modules definitions here
+ Examples:
+ <module>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">netty:netty-threadgroup-fixed</type>
+ <name>global-boss-group</name>
+ </module>
+ <module>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">netty:netty-threadgroup-fixed</type>
+ <name>global-worker-group</name>
+ </module>
+ <module>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:timer">netty:netty-hashed-wheel-timer</type>
+ <name>global-timer</name>
+ </module>
+ <module>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor">netty:netty-global-event-executor</type>
+ <name>singleton</name>
+ </module>
+ -->
+ </modules>
+
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <!-- Optional TODO: Put your service instance definitions here
+ Examples:
+ <service>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
+ <instance>
+ <name>global-boss-group</name>
+ <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-boss-group']</provider>
+ </instance>
+ <instance>
+ <name>global-worker-group</name>
+ <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-worker-group']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-event-executor</type>
+ <instance>
+ <name>global-event-executor</name>
+ <provider>/modules/module[type='netty-global-event-executor'][name='singleton']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-timer</type>
+ <instance>
+ <name>global-timer</name>
+ <provider>/modules/module[type='netty-hashed-wheel-timer'][name='global-timer']</provider>
+ </instance>
+ </service>
+ -->
+ </services>
+ </data>
+
+ </configuration>
+</snapshot>
--- /dev/null
+#Mon Aug 25 05:45:18 CDT 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
+repoName=foo
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-distro-archetype</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>distribution-karaf-archetype</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.2</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <url>https://wiki.opendaylight.org/view/CrossProject:Integration_Group/distribution-karaf</url>
+
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
+ </scm>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <requiredProperties>
+ <requiredProperty key="repoName"/>
+ </requiredProperties>
+</archetype-descriptor>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <!--
+ Necessary TODO: Hookup your parent pom here, else you will not get necessary versions,
+ maven repos etc. If you run this archetype in a subdirectory of your project, it
+ will pick the pom.xml from the parent directory as the parent pom, which may or may
+ not be correct.
+ -->
+ <artifactId>${artifactId}</artifactId>
+ <groupId>${groupId}</groupId>
+ <!-- Optional TODO: Uncomment version if you are not using a parent pom.xml
+ <version>${version}</version>
+ -->
+ <packaging>pom</packaging>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+ <properties>
+ <!-- Optional TODO: Move these properties to your parent pom and possibly
+ DependencyManagement section of your parent pom -->
+ <branding.version>1.0.0-SNAPSHOT</branding.version>
+ <karaf.resources.version>1.4.2-SNAPSHOT</karaf.resources.version>
+ <karaf.version>3.0.1</karaf.version>
+ </properties>
+
+ <dependencies>
+ <!-- Basic Karaf dependencies -->
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>framework</artifactId>
+ <version>${karaf.version}</version>
+ <type>kar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>standard</artifactId>
+ <version>${karaf.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- ODL Branding -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>karaf.branding</artifactId>
+ <version>${branding.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- ODL Resources needed for karaf -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-resources</artifactId>
+ <version>${karaf.resources.version}</version>
+ </dependency>
+
+ <!-- Project local feautures -->
+ <!--
+ Necessary TODO put your features here.
+
+ Note: they will need to be <type>xml</xml>
+ and <classifier>features</classifier>.
+
+ Note: they must be <scope>runtime</scope>
+
+ Note: usually you would only need to depend
+ on your own feature file here for your local distro,
+ and possible the features-mdsal for odl-restconf
+ (although, strange situations do exist :) )
+
+ Example:
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowplugin</groupId>
+ <artifactId>features-openflowplugin</artifactId>
+ <version>0.0.3-SNAPSHOT</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ -->
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <versionRange>[0,)</versionRange>
+ <goals>
+ <goal>cleanVersions</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <versionRange>[0,)</versionRange>
+ <goals>
+ <goal>copy</goal>
+ <goal>unpack</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <versionRange>[0,)</versionRange>
+ <goals>
+ <goal>commands-generate-help</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.fusesource.scalate</groupId>
+ <artifactId>maven-scalate-plugin</artifactId>
+ <versionRange>[0,)</versionRange>
+ <goals>
+ <goal>sitegen</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <versionRange>[0,)</versionRange>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <version>${karaf.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <bootFeatures>
+ <feature>standard</feature>
+ <!--
+ Optional TODO: Add entries here for the features you want in your local distro
+ Note: odl-restconf is a separate feature from odl-mdsal-broker. If you want
+ restconf, you need to list it here explicitely.
+ Examples:
+ <feature>odl-openflowplugin-flow-services</feature>
+ <feature>odl-restconf</feature>
+ -->
+ <!-- Final TODO: Remove TODO Comments ;) -->
+ </bootFeatures>
+ </configuration>
+ <executions>
+ <execution>
+ <id>process-resources</id>
+ <goals>
+ <goal>install-kars</goal>
+ </goals>
+ <phase>process-resources</phase>
+ </execution>
+ <execution>
+ <id>package</id>
+ <goals>
+ <goal>instance-create-archive</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>karaf.branding</artifactId>
+ <version>${karaf.branding.version}</version>
+ <outputDirectory>target/assembly/lib</outputDirectory>
+ <destFileName>karaf.branding-${branding.version}.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ <execution>
+ <id>unpack-karaf-resources</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/assembly</outputDirectory>
+ <groupId>org.opendaylight.controller</groupId>
+ <includeArtifactIds>opendaylight-karaf-resources</includeArtifactIds>
+ <excludes>META-INF\/**</excludes>
+ <excludeTransitive>true</excludeTransitive>
+ <ignorePermissions>false</ignorePermissions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <chmod perm="755">
+ <fileset dir="${project.build.directory}/assembly/bin">
+ <include name="karaf" />
+ <include name="instance" />
+ <include name="start"/>
+ <include name="stop"/>
+ <include name="status"/>
+ <include name="client"/>
+ <include name="shell"/>
+ </fileset>
+ </chmod>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/${repoName}.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/${repoName}.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://git.opendaylight.org/gerrit/gitweb?p=${repoName}.git;a=summary</url>
+ </scm>
+</project>
--- /dev/null
+#Thu Aug 21 14:44:29 CDT 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
+repoName=foo
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-features-archetype</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>opendaylight-karaf-features-archetype</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.2</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git/</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git/</developerConnection>
+ <url>https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=summary</url>
+ </scm>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="features-integration"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <requiredProperties>
+ <requiredProperty key="repoName"/>
+ </requiredProperties>
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <include>**/*.xml</include>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Necessary TODO: Put your copyright here.
+
+ 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
+-->
+<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>
+ <!--
+ Necessary TODO: Hookup your parent pom here, else you will not get necessary versions,
+ maven repos etc. If you run this archetype in a subdirectory of your project, it
+ will pick the pom.xml from the parent directory as the parent pom, which may or may
+ not be correct.
+ -->
+ <artifactId>features-${repoName}</artifactId>
+ <groupId>${groupId}</groupId>
+ <!-- Optional TODO: Uncomment version if you are not using a parent pom.xml
+ <version>${version}</version>
+ -->
+ <packaging>jar</packaging>
+ <properties>
+ <features.file>features.xml</features.file>
+ <!-- Optional TODO: Move these properties to your parent pom and possibly
+ DependencyManagement section of your parent pom -->
+ <branding.version>1.0.0-SNAPSHOT</branding.version>
+ <karaf.resources.version>1.4.2-SNAPSHOT</karaf.resources.version>
+ <karaf.version>3.0.1</karaf.version>
+ <feature.test.version>0.6.2-SNAPSHOT</feature.test.version>
+ <karaf.empty.version>1.4.2-SNAPSHOT</karaf.empty.version>
+ <surefire.version>2.16</surefire.version>
+ </properties>
+ <dependencies>
+ <!--
+ Necessary TODO: Put dependencies on any feature repos
+ you use in your features.xml file.
+
+ Note: they will need to be <type>xml</xml>
+ and <classifier>features</classifier>.
+ One other thing to watch for is to make sure they are
+ <scope>compile</compile>, which they should be by default,
+ but be cautious lest they be at a different scope in a parent pom.
+
+ Examples:
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <version>0.6.2-SNAPSHOT</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowplugin</groupId>
+ <artifactId>features-openflowplugin</artifactId>
+ <version>0.0.3-SNAPSHOT</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ -->
+
+ <!--
+ Necessary TODO: Put dependencies for bundles directly referenced
+ in your features.xml file. For every <bundle> reference in your
+ features.xml file, you need a corresponding dependency here.
+
+ Examples:
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>${repoName}-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>${repoName}-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ -->
+
+ <!--
+ Necessary TODO: Put dependencies for configfiles directly referenced
+ in your features.xml file. For every <configfile> reference in your
+ features.xml file, you need a corresponding dependency here.
+
+ Example (presuming here version is coming from the parent pom):
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>${repoName}-config</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>config</classifier>
+ </dependency>
+ -->
+
+ <!--
+ Optional TODO: Remove TODO comments.
+ -->
+ <!-- test to validate features.xml -->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ <version>${feature.test.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <version>${karaf.empty.version}</version>
+ <type>zip</type>
+ </dependency>
+ <!-- Uncomment this if you get an error : java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ -->
+
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <systemPropertyVariables>
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+ <karaf.distro.version>${karaf.empty.version}</karaf.distro.version>
+ </systemPropertyVariables>
+ <dependenciesToScan>
+ <dependency>org.opendaylight.yangtools:features-test</dependency>
+ </dependenciesToScan>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/${repoName}.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/${repoName}.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://git.opendaylight.org/gerrit/gitweb?p=${repoName}.git;a=summary</url>
+ </scm>
+</project>
--- /dev/null
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Necessary TODO: Put your copyright statement here
+
+ 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
+-->
+<features name="odl-${repoName}-${symbol_dollar}{project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <!--
+ Necessary TODO: Please read the features guidelines:
+ https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Feature_Best_Practices
+ -->
+ <!--
+ Necessary TODO: Add repo entries for the repositories of features you refer to
+ in this feature file but do not define here.
+ Examples:
+ <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.6.2-SNAPSHOT/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/features-mdsal/1.1-SNAPSHOT/xml/features</repository>
+ <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.0.3-SNAPSHOT/xml/features</repository>
+ -->
+ <feature name='odl-${repoName}-all' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: All'>
+ <!--
+ Necessary TODO:
+ List all of the user consumable features you define in this feature file here.
+ Generally you would *not* list individual bundles here, but only features defined in *this* file.
+ It is useful to list them in the same order they occur in the file.
+
+ Examples:
+ <feature version='${symbol_dollar}{project.version}'>odl-${repoName}-provider</feature>
+ <feature version='${symbol_dollar}{project.version}'>odl-${repoName}-model</feature>
+ -->
+ </feature>
+ <!--
+ Necessary TODO: Define your features. It is useful to list then in order of dependency. So if A depends on B, list A first.
+ When naming your features please be mindful of the guidelines:
+ https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines
+ Particularly:
+ a) Prefixing names with 'odl-': https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Feature_Naming
+ b) Descriptions: https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Description
+ c) Avoid start-levels: https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Avoid_start-levels
+
+ It's also nice to list inside a feature, first the features it needs, then the bundles it needs, then the configfiles.
+ Examples:
+
+ * Basic MD-SAL Provider
+ <feature name='odl-${repoName}-provider' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Provider '>
+ <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+ <feature version='${symbol_dollar}{project.version}'>odl-${repoName}-model</feature>
+ <bundle>mvn:${groupId}/${repoName}-provider/${symbol_dollar}{project.version}</bundle>
+ ... whatever other bundles you need
+ </feature>
+
+ * Basic MD-SAL Model feature
+ <feature name='odl-${repoName}-model' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Model'>
+ <feature version='0.6.2-SNAPSHOT'>odl-yangtools-binding</feature>
+ <feature version='0.6.2-SNAPSHOT'>odl-yangtools-models</feature>
+ <bundle>mvn:${groupId}/${repoName}-model/${symbol_dollar}{project.version}</bundle>
+ ... whatever other bundles you need
+ </feature>
+
+ * Config Subsystem example - the config file is your config subsystem configuration
+ <feature name='odl-${repoName}-provider' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Provider'>
+ <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+ <bundle>mvn:${groupId}/${repoName}-provider/${symbol_dollar}{project.version}</bundle>
+ <configfile finalname="etc/opendaylight/karaf/80-${repoName}.xml">mvn:${groupId}/${repoName}-config/${symbol_dollar}{project.version}/xml/config</configfile>
+ ... whatever other bundles you need
+ </feature>
+
+ * Basic MD-SAL Provider that uses openflowplugin-flow-services (which brings along odl-mdsal-broker)
+ <feature name='odl-${repoName}-provider' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Provider'>
+ <feature version='0.0.3-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
+ <bundle>mvn:${groupId}/${repoName}-provider/${symbol_dollar}{project.version}</bundle>
+ ... whatever other bundles you need
+ </feature>
+
+ -->
+ <!-- Optional TODO: Remove TODO Comments -->
+
+</features>
--- /dev/null
+#Thu Aug 21 23:46:25 CDT 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
+repoName=foo
</prerequisites>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../commons/parent</relativePath>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.2-SNAPSHOT</version>
+ <relativePath>../commons/opendaylight</relativePath>
</parent>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
</distributionManagement>
<modules>
<module>odl-model-project</module>
+ <module>opendaylight-configfile-archetype</module>
+ <module>opendaylight-karaf-distro-archetype</module>
+ <module>opendaylight-karaf-features</module>
</modules>
</project>
<clustering.test.version>0.4.2-SNAPSHOT</clustering.test.version>
<commmons.northbound.version>0.4.2-SNAPSHOT</commmons.northbound.version>
<!-- Third Party Versions -->
+ <codahale.metrics.version>3.0.1</codahale.metrics.version>
<commons.catalina>7.0.32.v201211201336</commons.catalina>
<commons.catalina.ha>7.0.32.v201211201952</commons.catalina.ha>
<commons.catalina.tribes>7.0.32.v201211201952</commons.catalina.tribes>
- <commons.checkstyle.version>0.0.3-SNAPSHOT</commons.checkstyle.version>
<commons.coyote>7.0.32.v201211201952</commons.coyote>
<commons.el>7.0.32.v201211081135</commons.el>
+ <commons.jasper>7.0.32.v201211201952</commons.jasper>
+ <commons.juli.version>7.0.32.v201211081135</commons.juli.version>
+ <commons.tomcat.api>7.0.32.v201211081135</commons.tomcat.api>
+ <commons.tomcat.util>7.0.32.v201211201952</commons.tomcat.util>
+
+ <commons.karaf.catalina>7.0.53.v201406061610</commons.karaf.catalina>
+ <commons.karaf.catalina.ha>7.0.53.v201406070630</commons.karaf.catalina.ha>
+ <commons.karaf.catalina.tribes>7.0.53.v201406070630</commons.karaf.catalina.tribes>
+ <commons.karaf.coyote>7.0.53.v201406070630</commons.karaf.coyote>
+ <commons.karaf.el>7.0.53.v201406060720</commons.karaf.el>
+ <commons.karaf.jasper>7.0.53.v201406070630</commons.karaf.jasper>
+ <commons.karaf.juli.version>7.0.53.v201406060720</commons.karaf.juli.version>
+ <commons.karaf.tomcat.api>7.0.53.v201406060720</commons.karaf.tomcat.api>
+ <commons.karaf.tomcat.util>7.0.53.v201406070630</commons.karaf.tomcat.util>
+
+ <commons.checkstyle.version>0.0.3-SNAPSHOT</commons.checkstyle.version>
<commons.fileupload.version>1.2.2</commons.fileupload.version>
<commons.httpclient.version>0.1.2-SNAPSHOT</commons.httpclient.version>
<commons.io.version>2.4</commons.io.version>
- <commons.jasper>7.0.32.v201211201952</commons.jasper>
- <commons.juli.version>7.0.32.v201211081135</commons.juli.version>
<commons.lang3.version>3.1</commons.lang3.version>
<commons.logback_settings.version>0.0.2-SNAPSHOT</commons.logback_settings.version>
<commons.net.version>3.0.1</commons.net.version>
<commons.opendaylight.concepts.version>0.5.2-SNAPSHOT</commons.opendaylight.concepts.version>
<commons.opendaylight.version>1.4.2-SNAPSHOT</commons.opendaylight.version>
<commons.parent.version>1.0.2-SNAPSHOT</commons.parent.version>
- <commons.tomcat.api>7.0.32.v201211081135</commons.tomcat.api>
- <commons.tomcat.util>7.0.32.v201211201952</commons.tomcat.util>
<compiler.version>2.3.2</compiler.version>
<commons.httpclient.version>0.1.2-SNAPSHOT</commons.httpclient.version>
<concepts.version>0.5.2-SNAPSHOT</concepts.version>
<config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
<config.netty.configfile>00-netty.xml</config.netty.configfile>
<config.mdsal.configfile>01-mdsal.xml</config.mdsal.configfile>
+ <config.xsql.configfile>04-xsql.xml</config.xsql.configfile>
<config.netconf.client.configfile>01-netconf.xml</config.netconf.client.configfile>
<config.toaster.configfile>03-toaster-sample.xml</config.toaster.configfile>
<config.restconf.configfile>10-rest-connector.xml</config.restconf.configfile>
<devices.web.version>0.4.2-SNAPSHOT</devices.web.version>
<dummy-console.version>1.1.0-SNAPSHOT</dummy-console.version>
<eclipse.persistence.version>2.5.0</eclipse.persistence.version>
+ <eclipse.jdt.core.compiler.batch.version>3.8.0.I20120518-2145</eclipse.jdt.core.compiler.batch.version>
<!-- enforcer version -->
<enforcer.version>1.3.1</enforcer.version>
<enunciate.version>1.28</enunciate.version>
<scala.version>2.10</scala.version>
<scala.micro.version>4</scala.micro.version>
<security.version>0.4.2-SNAPSHOT</security.version>
+ <karaf.security.version>0.4.2-SNAPSHOT</karaf.security.version>
<shapeless.version>1.2.4</shapeless.version>
<sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>
<sonar.branch>${user.name}-private-view</sonar.branch>
<usermanager.implementation.version>0.4.2-SNAPSHOT</usermanager.implementation.version>
<usermanager.northbound.version>0.0.2-SNAPSHOT</usermanager.northbound.version>
<usermanager.version>0.4.2-SNAPSHOT</usermanager.version>
+ <nsf.version>0.4.2-SNAPSHOT</nsf.version>
<web.version>0.4.2-SNAPSHOT</web.version>
<xtend.dstdir>src/main/xtend-gen</xtend.dstdir>
<yang-ext.version>2013.09.07.4-SNAPSHOT</yang-ext.version>
<yang-jmx-generator.version>1.0.0-SNAPSHOT</yang-jmx-generator.version>
<yangtools.version>0.6.2-SNAPSHOT</yangtools.version>
+ <sshd-core.version>0.12.0</sshd-core.version>
</properties>
<dependencyManagement>
<artifactId>netconf-netty-util</artifactId>
<version>${netconf.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>${sshd-core.version}</version>
+ </dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-core</artifactId>
+ <version>${codahale.metrics.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-graphite</artifactId>
+ <version>${codahale.metrics.version}</version>
+ </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
-
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ <version>${jersey-servlet.version}</version>
+ </dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>hosttracker.northbound</artifactId>
<version>${hosttracker.northbound.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker.shell</artifactId>
+ <version>${hosttracker.shell.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>hosttracker_new</artifactId>
<artifactId>logging.bridge</artifactId>
<version>${logging.bridge.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>dummy-console</artifactId>
+ <version>${dummy-console.version}</version>
+ </dependency>
<!-- Netconf -->
<dependency>
<version>${netconf.version}</version>
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-auth</artifactId>
+ <version>${netconf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-usermanager</artifactId>
+ <version>${netconf.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-ssh</artifactId>
<artifactId>sal-connector-api</artifactId>
<version>${mdsal.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-dom-xsql</artifactId>
+ <version>${mdsal.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-dom-xsql-config</artifactId>
+ <version>${mdsal.version}</version>
+ <classifier>config</classifier>
+ <type>xml</type>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-core-api</artifactId>
<artifactId>security</artifactId>
<version>${security.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>karaf-tomcat-security</artifactId>
+ <version>${karaf.security.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>topologymanager</artifactId>
<version>${topologymanager.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager.shell</artifactId>
+ <version>${topologymanager.shell.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>troubleshoot.web</artifactId>
<artifactId>yang-data-composite-node</artifactId>
<version>${yangtools.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-codec-gson</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
<!-- yangtools dependencies -->
<dependency>
<type>xml</type>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-base</artifactId>
+ <version>${commons.opendaylight.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-adsal</artifactId>
<type>xml</type>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-nsf</artifactId>
+ <version>${nsf.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-mdsal</artifactId>
pending = this.dispatcher.createClient(this.address, cs, b, new AbstractDispatcher.PipelineInitializer<S>() {
@Override
public void initializeChannel(final SocketChannel channel, final Promise<S> promise) {
- initializer.initializeChannel(channel, promise);
-
// add closed channel handler
+ // This handler has to be added before initializer.initializeChannel is called
+ // Initializer might add some handlers using addFirst e.g. AsyncSshHandler and in that case
+ // closed channel handler is before the handler that invokes channel inactive event
channel.pipeline().addFirst(new ClosedChannelHandler(ReconnectPromise.this));
+
+ initializer.initializeChannel(channel, promise);
}
});
}
@Override
public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
+ // Pass info about disconnect further and then reconnect
+ super.channelInactive(ctx);
+
if (promise.isCancelled()) {
return;
}
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ </dependency>
</dependencies>
<build>
JmxAttribute that = (JmxAttribute) o;
- if (attributeName != null ? !attributeName.equals(that.attributeName)
- : that.attributeName != null) {
+ if (!attributeName.equals(that.attributeName)) {
return false;
}
@Override
public int hashCode() {
- return attributeName != null ? attributeName.hashCode() : 0;
+ return attributeName.hashCode();
}
@Override
--- /dev/null
+package org.opendaylight.controller.config.api;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+
+import javax.management.*;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+public class IdentityAttributeRefTest {
+
+ IdentityAttributeRef attr = new IdentityAttributeRef("attr");
+
+ @Test
+ public void testConstructor() throws Exception {
+ String param = new String("attr");
+ Assert.assertEquals(attr.getqNameOfIdentity(), param);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testConstructor2() throws Exception {
+ IdentityAttributeRef attr = new IdentityAttributeRef(null);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ Assert.assertEquals(attr.hashCode(), new String("attr").hashCode());
+ }
+
+ @Test
+ public void testEqual() throws Exception {
+ Assert.assertEquals(attr, attr);
+ }
+
+ @Test
+ public void testEqual2() throws Exception {
+ Assert.assertEquals(attr, new IdentityAttributeRef("attr"));
+ }
+
+ @Test
+ public void testNotEqual() throws Exception {
+ Assert.assertNotEquals(attr, new IdentityAttributeRef("different"));
+ }
+
+ @Test
+ public void testResolveIdentity() throws Exception {
+ DependencyResolver res = mock(DependencyResolver.class);
+ IdentityAttributeRef a = new IdentityAttributeRef("abcd");
+ doReturn(SubIdentity.class).when(res).resolveIdentity(a, Identity.class);
+ a.resolveIdentity(res, Identity.class);
+ verify(res).resolveIdentity(a, Identity.class);
+ }
+
+ @Test
+ public void testValidateIdentity() throws Exception {
+ DependencyResolver res = mock(DependencyResolver.class);
+ JmxAttribute jmxAttr = new JmxAttribute("abc");
+ doNothing().when(res).validateIdentity(attr, Identity.class, jmxAttr);
+ attr.validateIdentity(res, Identity.class, jmxAttr);
+ verify(res).validateIdentity(attr, Identity.class, jmxAttr);
+ }
+
+ static class Identity extends BaseIdentity {}
+
+ static class SubIdentity extends Identity {}
+}
--- /dev/null
+package org.opendaylight.controller.config.api;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class JmxAttributeTest {
+
+ @Test
+ public void testJmxAttribute() throws Exception {
+ JmxAttribute attr = new JmxAttribute("test");
+ assertEquals("test", attr.getAttributeName());
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ JmxAttribute attr = new JmxAttribute("test");
+ assertEquals(attr.toString(), new JmxAttribute("test").toString());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testJmxAttributeInvalid() throws Exception {
+ JmxAttribute attr = new JmxAttribute(null);
+ }
+
+ @Test
+ public void testJmxAttributeEqual() throws Exception {
+ JmxAttribute a1 = new JmxAttribute("test_string");
+ JmxAttribute a2 = new JmxAttribute("test_string");
+ assertEquals(a1, a2);
+ }
+
+ @Test
+ public void testJmxAttributeNotEqual() throws Exception {
+ JmxAttribute a1 = new JmxAttribute("test_string");
+ JmxAttribute a2 = new JmxAttribute("different");
+ assertNotEquals(a1, a2);
+ }
+
+ @Test
+ public void testJmxAttributeEqual2() throws Exception {
+ JmxAttribute a1 = new JmxAttribute("test_string");
+ assertNotNull(a1);
+ }
+
+ @Test
+ public void testJmxAttributeHashCode() throws Exception {
+ JmxAttribute a1 = new JmxAttribute("test_string");
+ assertEquals(a1.hashCode(), new String("test_string").hashCode());
+ }
+}
package org.opendaylight.controller.config.api;
-import static org.junit.Assert.assertEquals;
+import java.nio.file.AccessDeniedException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import com.google.common.collect.Lists;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import javax.management.Query;
+
+import static org.junit.Assert.*;
+
public class JmxAttributeValidationExceptionTest {
private JmxAttribute jmxAttribute = new JmxAttribute("attr1");
- private JmxAttribute jmxAttribute2 = new JmxAttribute("attr2");
- @Before
- public void setUp() throws Exception {
+ @Test
+ public void testJmxAttributeValidationExceptionElement() throws Exception {
+ JmxAttribute attributeName = new JmxAttribute("attr_name");
+ JmxAttributeValidationException e = new JmxAttributeValidationException(attributeName);
+ assertThat(e.getAttributeNames(), CoreMatchers.hasItem(attributeName));
+ }
+ @Test
+ public void testJmxAttributeValidationExceptionList() throws Exception {
+ List attributeNames = new ArrayList<JmxAttribute>();
+ attributeNames.add(new JmxAttribute("att1"));
+ attributeNames.add(new JmxAttribute("att2"));
+ attributeNames.add(new JmxAttribute("att3"));
+ JmxAttributeValidationException e = new JmxAttributeValidationException(attributeNames);
+ assertEquals(e.getAttributeNames(), attributeNames);
}
@Test
- public void testGetAttributeNames() throws Exception {
+ public void testJmxAttributeValidationExceptionList2() throws Exception {
+ List attributeNames = new ArrayList<JmxAttribute>();
+ attributeNames.add(new JmxAttribute("att1"));
+ attributeNames.add(new JmxAttribute("att2"));
+ attributeNames.add(new JmxAttribute("att3"));
+ JmxAttributeValidationException e = new JmxAttributeValidationException("exception str",
+ new AccessDeniedException(""), attributeNames);
+ assertEquals(e.getAttributeNames(), attributeNames);
+ }
+ @Test
+ public void testJmxAttributeValidationExceptionJmxElement() throws Exception {
+ JmxAttribute attributeName = new JmxAttribute("attr_name");
+ JmxAttributeValidationException e = new JmxAttributeValidationException("exception str",
+ new AccessDeniedException(""), attributeName);
+ assertEquals(e.getAttributeNames(), Arrays.asList(attributeName));
}
@Test
public void testCheckNotNull() throws Exception {
try {
- JmxAttributeValidationException.checkNotNull(false, "message", jmxAttribute);
+ JmxAttributeValidationException.checkNotNull(false, jmxAttribute);
} catch (JmxAttributeValidationException e) {
assertJmxEx(e, jmxAttribute.getAttributeName() + " " + "message", jmxAttribute);
}
}
@Test
- public void testWrap() throws Exception {
+ public void testCheckCondition() throws Exception {
+ JmxAttributeValidationException.checkCondition(true, "message", jmxAttribute);
+ }
+ @Test(expected = JmxAttributeValidationException.class)
+ public void testJmxAttributeValidationException() throws Exception {
+ JmxAttributeValidationException.wrap(new Exception("tmp"), jmxAttribute);
}
- @Test
- public void testCheckCondition() throws Exception {
- try {
- JmxAttributeValidationException.checkCondition(false, "message", jmxAttribute);
- } catch (JmxAttributeValidationException e) {
- assertJmxEx(e, jmxAttribute.getAttributeName() + " " + "message", jmxAttribute);
- }
+ @Test(expected = JmxAttributeValidationException.class)
+ public void testJmxAttributeValidationException2() throws Exception {
+ JmxAttributeValidationException.wrap(new Exception("tmp"), "message", jmxAttribute);
+ }
+
+ @Test(expected = JmxAttributeValidationException.class)
+ public void testCheckConditionFalse() throws Exception {
+ JmxAttributeValidationException.checkCondition(false, "message", jmxAttribute);
}
private void assertJmxEx(JmxAttributeValidationException e, String message, JmxAttribute... attrNames) {
--- /dev/null
+package org.opendaylight.controller.config.api;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+
+public class ModuleIdentifierTest {
+ String fact = new String("factory");
+ String inst = new String("instance");
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testConstructor() throws Exception {
+ ModuleIdentifier m = new ModuleIdentifier(null, "instance");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testConstructor2() throws Exception {
+ ModuleIdentifier m = new ModuleIdentifier("name", null);
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+
+ ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
+ assertEquals(m1, new ModuleIdentifier(fact, inst));
+ }
+
+ @Test
+ public void testEquals2() throws Exception {
+ assertNotEquals(new ModuleIdentifier(fact, inst), null);
+ }
+
+ @Test
+ public void testEquals3() throws Exception {
+ assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier(fact, "i"));
+ }
+
+ @Test
+ public void testEquals4() throws Exception {
+ assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier("f", inst));
+ }
+
+ @Test
+ public void testEquals5() throws Exception {
+ ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
+ assertEquals(m1, m1);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ int hash = new ModuleIdentifier(fact, inst).hashCode();
+ assertEquals(hash, new ModuleIdentifier("factory", "instance").hashCode());
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ assertEquals( new ModuleIdentifier("factory", "instance").toString(),
+ new ModuleIdentifier("factory", "instance").toString());
+ }
+}
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import com.google.common.collect.Lists;
import java.util.Map;
+
+import org.junit.Assert;
import org.junit.Test;
public class ValidationExceptionTest {
}
fail("Duplicate exception should have failed");
}
+
+ @Test
+ public void testGetTrace() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace();
+ exp.setTrace("trace");
+ Assert.assertEquals(exp.getTrace(), "trace");
+ }
+
+ @Test
+ public void testSetMessage() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace();
+ exp.setMessage("message");
+ Assert.assertEquals(exp.getMessage(), "message");
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace();
+ Assert.assertEquals(exp.hashCode(), new ValidationException.ExceptionMessageWithStackTrace().hashCode());
+ }
+
+ @Test
+ public void testExceptionMessageWithStackTraceConstructor() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ Assert.assertEquals(exp, exp);
+ }
+
+ @Test
+ public void testExceptionMessageWithStackTraceConstructor2() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ Assert.assertNotEquals(exp, null);
+ }
+
+ @Test
+ public void testExceptionMessageWithStackTraceConstructor3() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ Assert.assertNotEquals(exp, new Exception());
+ }
+
+ @Test
+ public void testExceptionMessageWithStackTraceConstructor4() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ Assert.assertEquals(exp, new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"));
+ }
+
+ @Test
+ public void testEqual() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ ValidationException.ExceptionMessageWithStackTrace exp2 =
+ new ValidationException.ExceptionMessageWithStackTrace(null, "string2");
+ Assert.assertNotEquals(exp, exp2);
+ }
+
+ @Test
+ public void testEqual2() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ ValidationException.ExceptionMessageWithStackTrace exp2 =
+ new ValidationException.ExceptionMessageWithStackTrace("different", "string2");
+ Assert.assertNotEquals(exp, exp2);
+ }
+
+
+ @Test
+ public void testEqual3() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ ValidationException.ExceptionMessageWithStackTrace exp2 =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", null);
+ Assert.assertNotEquals(exp, exp2);
+ }
+
+ @Test
+ public void testEqual4() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ ValidationException.ExceptionMessageWithStackTrace exp2 =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "different");
+ Assert.assertNotEquals(exp, exp2);
+ }
+
+ @Test
+ public void testEqual5() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace(null, "string2");
+ ValidationException.ExceptionMessageWithStackTrace exp2 =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ Assert.assertNotEquals(exp, exp2);
+ }
+
+ @Test
+ public void testEqual6() throws Exception {
+ ValidationException.ExceptionMessageWithStackTrace exp =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", null);
+ ValidationException.ExceptionMessageWithStackTrace exp2 =
+ new ValidationException.ExceptionMessageWithStackTrace("string1", "string2");
+ Assert.assertNotEquals(exp, exp2);
+ }
}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.controller.config.api.jmx;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommitStatusTest {
+ List newInst = new ArrayList<ObjectName>();
+ List reusedInst = new ArrayList<ObjectName>();
+ List recreatedInst = new ArrayList<ObjectName>();
+
+ @Before
+ public void setUp() throws Exception {
+ newInst.add(new ObjectName("domain: key1 = value1 , key2 = value2"));
+ reusedInst.add(new ObjectName("o2: key = val"));
+ recreatedInst.add(new ObjectName("o3: key = k"));
+ }
+ @Test
+ public void testCommitStatus() throws Exception {
+ CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
+ Assert.assertEquals(status.getNewInstances(), newInst);
+ Assert.assertEquals(status.getRecreatedInstances(), recreatedInst);
+ Assert.assertEquals(status.getReusedInstances(), reusedInst);
+ }
+
+ @Test
+ public void testEqual() throws Exception {
+ CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
+ Assert.assertEquals(status, new CommitStatus(newInst, reusedInst, recreatedInst));
+ Assert.assertEquals(status.toString(), new CommitStatus(newInst, reusedInst, recreatedInst).toString());
+ Assert.assertEquals(status, status);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
+ Assert.assertEquals(status.hashCode(), new CommitStatus(newInst, reusedInst, recreatedInst).hashCode());
+ }
+
+ @Test
+ public void testNotEqual() throws Exception {
+ List newInst2 = new ArrayList<ObjectName>();
+ List reusedInst2 = new ArrayList<ObjectName>();
+ List recreatedInst2 = new ArrayList<ObjectName>();
+
+ newInst2.add(new ObjectName("first: key1 = value1"));
+ reusedInst2.add(new ObjectName("second: key = val"));
+ recreatedInst2.add(new ObjectName("third: key = k"));
+
+ CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
+ Assert.assertNotEquals(status, null);
+ Assert.assertNotEquals(status, new Object());
+ Assert.assertNotEquals(status, new CommitStatus(newInst2, reusedInst, recreatedInst));
+ Assert.assertNotEquals(status, new CommitStatus(newInst, reusedInst2, recreatedInst));
+ Assert.assertNotEquals(status, new CommitStatus(newInst, reusedInst, recreatedInst2));
+
+ CommitStatus status2 = new CommitStatus(newInst, reusedInst, recreatedInst);
+ }
+}
--- /dev/null
+package org.opendaylight.controller.config.api.jmx;
+
+
+import org.junit.Test;
+import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
+
+public class ConfigRegistryConstantsTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateON() throws Exception {
+ ConfigRegistryConstants.createON("test.<:", "asd", "asd");
+ }
+}
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
+
+import java.util.HashMap;
import java.util.Map;
import javax.management.ObjectName;
import junit.framework.Assert;
fail(test + " should have failed on " + ex);
}
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateON() throws Exception {
+ ObjectNameUtil.createON(">}+!#");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateON2() throws Exception {
+ Map<String, String> map = new HashMap<>();
+ ObjectNameUtil.createON(">}+!#", map);
+ }
}
--- /dev/null
+package org.opendaylight.controller.config.manager.impl.osgi;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.sal.binding.generator.api.ModuleInfoRegistry;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.*;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class RefreshingSCPModuleInfoRegistryTest {
+ @Test
+ public void testConstructor() throws Exception {
+ ModuleInfoRegistry reg = mock(ModuleInfoRegistry.class);
+ SchemaContextProvider prov = mock(SchemaContextProvider.class);
+ doReturn("string").when(prov).toString();
+
+ BundleContext ctxt = mock(BundleContext.class);
+ Dictionary dict = new Hashtable();
+ ServiceRegistration servReg = mock(ServiceRegistration.class);
+ doReturn(servReg).when(ctxt).registerService(Mockito.any(Class.class), Mockito.any(SchemaContextProvider.class), Mockito.any(Dictionary.class));
+ doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), Mockito.any(Object.class), Mockito.any(Dictionary.class));
+ RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, ctxt);
+
+ YangModuleInfo modInfo = mock(YangModuleInfo.class);
+ doNothing().when(servReg).setProperties(null);
+ doNothing().when(servReg).unregister();
+ doReturn("").when(modInfo).toString();
+ ObjectRegistration<YangModuleInfo> ymi = mock(ObjectRegistration.class);
+ doReturn(ymi).when(reg).registerModuleInfo(modInfo);
+
+ scpreg.registerModuleInfo(modInfo);
+ scpreg.close();
+
+ Mockito.verify(servReg, Mockito.times(1)).setProperties(null);
+ Mockito.verify(servReg, Mockito.times(1)).unregister();
+ }
+}
*
*/
-public class ConfigurationService implements IConfigurationService, ICacheUpdateAware<ConfigurationEvent, String> {
+public class ConfigurationService implements IConfigurationService, ICacheUpdateAware<String, String> {
private static final Logger logger = LoggerFactory
.getLogger(ConfigurationService.class);
public static final String SAVE_EVENT_CACHE = "config.event.save";
private static final String ROOT = GlobalConstants.STARTUPHOME.toString();
private IClusterGlobalServices clusterServices;
- private ConcurrentMap <ConfigurationEvent, String> configEvent;
+ private ConcurrentMap<String, String> configEvent;
private Set<IConfigurationAware> configurationAwareList = Collections
.synchronizedSet(new HashSet<IConfigurationAware>());
private ObjectReader objReader;
@Override
public Status saveConfigurations() {
if (configEvent != null) {
- configEvent.put(ConfigurationEvent.SAVE, "");
+ configEvent.put(ConfigurationEvent.SAVE.toString(), "");
}
return saveConfigurationsInternal();
}
}
@Override
- public void entryCreated(ConfigurationEvent key, String cacheName,
+ public void entryCreated(String key, String cacheName,
boolean originLocal) {
if (originLocal) {
return;
}
@Override
- public void entryUpdated(ConfigurationEvent key, String new_value,
+ public void entryUpdated(String key, String new_value,
String cacheName, boolean originLocal) {
if (originLocal) {
return;
}
- if (key == ConfigurationEvent.SAVE) {
+ if (key.equals(ConfigurationEvent.SAVE.toString())) {
saveConfigurationsInternal();
}
}
@Override
- public void entryDeleted(ConfigurationEvent key, String cacheName,
+ public void entryDeleted(String key, String cacheName,
boolean originLocal) {
if (originLocal) {
return;
logger.error("uninitialized clusterServices, can't retrieve cache");
return;
}
- configEvent = (ConcurrentMap<ConfigurationEvent, String>) this.clusterServices.getCache(SAVE_EVENT_CACHE);
+ configEvent = (ConcurrentMap<String, String>) this.clusterServices.getCache(SAVE_EVENT_CACHE);
if (configEvent == null) {
logger.error("Failed to retrieve configuration Cache");
}
*/
public class ContainerConfigurationService implements IConfigurationContainerService,
- IConfigurationAware, ICacheUpdateAware<ConfigurationEvent, String> {
+ IConfigurationAware,
+ ICacheUpdateAware<String, String> {
public static final String CONTAINER_SAVE_EVENT_CACHE = "config.container.event.save";
private static final Logger logger = LoggerFactory.getLogger(ContainerConfigurationService.class);
private IClusterContainerServices clusterServices;
- private ConcurrentMap <ConfigurationEvent, String> containerConfigEvent;
+ private ConcurrentMap<String, String> containerConfigEvent;
// Directory which contains the startup files for this container
private String root;
private Set<IConfigurationContainerAware> configurationAwareList = Collections
@Override
public Status saveConfigurations() {
- containerConfigEvent.put(ConfigurationEvent.SAVE, "");
+ containerConfigEvent.put(ConfigurationEvent.SAVE.toString(), "");
return saveConfiguration();
}
@Override
- public void entryCreated(ConfigurationEvent key, String cacheName,
+ public void entryCreated(String key, String cacheName,
boolean originLocal) {
if (originLocal) {
return;
}
@Override
- public void entryUpdated(ConfigurationEvent key, String new_value,
+ public void entryUpdated(String key, String new_value,
String cacheName, boolean originLocal) {
if (originLocal) {
return;
}
logger.debug("Processing {} event", key);
- if (key == ConfigurationEvent.SAVE) {
+ if (key.equals(ConfigurationEvent.SAVE.toString())) {
saveConfiguration();
}
}
@Override
- public void entryDeleted(ConfigurationEvent key, String cacheName,
+ public void entryDeleted(String key, String cacheName,
boolean originLocal) {
if (originLocal) {
return;
logger.error("uninitialized clusterServices, can't retrieve cache");
return;
}
- containerConfigEvent = (ConcurrentMap<ConfigurationEvent, String>) this.clusterServices.getCache(CONTAINER_SAVE_EVENT_CACHE);
+ containerConfigEvent =
+ (ConcurrentMap<String, String>) this.clusterServices.getCache(CONTAINER_SAVE_EVENT_CACHE);
if (containerConfigEvent == null) {
logger.error("Failed to retrieve configuration Cache");
}
<Host name="localhost" appBase=""
unpackWARs="false" autoDeploy="false"
deployOnStartup="false" createDirs="false">
-<!-- <Realm className="org.opendaylight.controller.security.ControllerCustomRealm" />
+ <Realm className="org.opendaylight.controller.karafsecurity.ControllerCustomRealm" />
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
- -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="web_access_log_" suffix=".txt" resolveHosts="false"
rotatable="true" fileDateFormat="yyyy-MM"
# Extra packages to import from the boot class loader
org.osgi.framework.system.packages.extra=org.apache.karaf.branding,sun.reflect,sun.reflect.misc,sun.misc,sun.nio.ch
+# Override the config.properties to remove
+# ${services-${karaf.framework}}
+# This is to work around:
+# https://issues.apache.org/jira/browse/KARAF-3092
+# Which should be fixed in karaf 3.0.2
+# Which is not as of today (2014-08-24) released.
+# Since it is biting folks, we need to fix it here
+# Please remove this when we shift to karaf 3.0.2
+org.osgi.framework.system.capabilities= \
+ ${eecap-${java.specification.version}}, \
+ service-reference;effective:=active;objectClass=org.osgi.service.packageadmin.PackageAdmin, \
+ service-reference;effective:=active;objectClass=org.osgi.service.startlevel.StartLevel, \
+ service-reference;effective:=active;objectClass=org.osgi.service.url.URLHandlers
+
# https://bugs.eclipse.org/bugs/show_bug.cgi?id=325578
# Extend the framework to avoid the resources to be presented with
# a URL of type bundleresource: but to be presented as file:
#Hosttracker hostsdb key scheme setting
hosttracker.keyscheme=IP
+
down with testing... ie, no broken feature repos
-->
+ <!-- AD-SAL Related Features -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-base</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-adsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-nsf</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
<!-- MD-SAL Related Features -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
<fileset dir="${project.build.directory}/assembly/bin">
<include name="karaf"/>
<include name="instance"/>
+ <include name="start"/>
+ <include name="stop"/>
+ <include name="status"/>
+ <include name="client"/>
+ <include name="shell"/>
</fileset>
</chmod>
</tasks>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-ssh</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-auth</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-usermanager</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-tcp</artifactId>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>ganymed</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator-api</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-codec-gson</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-composite-node</artifactId>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.2-SNAPSHOT</version>
+ <relativePath>../commons/opendaylight</relativePath>
+ </parent>
+
+ <artifactId>karaf-tomcat-security</artifactId>
+ <version>0.4.2-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.catalina</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Fragment-Host>org.apache.catalina</Fragment-Host>
+ <Import-Package>org.slf4j,
+ javax.servlet,
+ org.apache.catalina,
+ org.apache.catalina.connector,
+ org.apache.catalina.valves,
+ org.apache.catalina.realm
+ </Import-Package>
+ <Export-Package>org.opendaylight.controller.karafsecurity</Export-Package>
+ </instructions>
+ <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
+ </scm>
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2014 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.karafsecurity;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.catalina.realm.GenericPrincipal;
+import org.apache.catalina.realm.RealmBase;
+
+public class ControllerCustomRealm extends RealmBase {
+
+ private static final String name = "ControllerCustomRealm";
+
+ @Override
+ protected String getName() {
+ return name;
+ }
+
+ @Override
+ protected String getPassword(String username) {
+ return "admin";
+ }
+
+ @Override
+ protected Principal getPrincipal(String username) {
+ List<String> controllerRoles = new ArrayList<String>();
+ controllerRoles.add("System-Admin");
+ return new GenericPrincipal(username, "", controllerRoles);
+ }
+
+ @Override
+ public Principal authenticate(String username, String credentials) {
+ return this.getPrincipal(username);
+ }
+}
import java.util.Date;
import java.util.HashSet;
import java.util.List;
+import java.util.regex.Pattern;
import org.opendaylight.controller.sal.common.util.Arguments;
import org.opendaylight.controller.sal.core.AdvertisedBandwidth;
import org.opendaylight.controller.sal.core.Bandwidth;
private final static Class<NodeConnector> NODECONNECTOR_CLASS = NodeConnector.class;
+ private final static Pattern COLON_NUMBERS_EOL = Pattern.compile(":[0-9]+$");
+
+ private final static Pattern NUMBERS_ONLY = Pattern.compile("[0-9]+");
+
+ private final static Pattern ALL_CHARS_TO_COLON = Pattern.compile("^.*:");
+
private NodeMapping() {
throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
}
return org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID;
}
- String nodeConnectorIdStripped = nodeConnectorId.getValue().replaceFirst("^.*:", "");
- if (nodeConnectorIdStripped.matches("[0-9]+")) {
+ String nodeConnectorIdStripped = ALL_CHARS_TO_COLON.matcher(nodeConnectorId.getValue()).replaceFirst("");
+
+ if (NUMBERS_ONLY.matcher(nodeConnectorIdStripped).matches()) {
Short nodeConnectorIdVal = null;
try {
nodeConnectorIdVal = Short.valueOf(nodeConnectorIdStripped);
+ return nodeConnectorIdVal;
} catch (NumberFormatException e) {
- LOG.warn("nodeConnectorId not supported (short): {}", nodeConnectorIdStripped, e);
+ LOG.warn("nodeConnectorId not supported (long): {}", nodeConnectorIdStripped, e);
}
- return nodeConnectorIdVal;
}
return nodeConnectorIdStripped;
}
public static NodeId toAdNodeId(final NodeConnectorId nodeConnectorId) {
NodeId nodeId = null;
if (nodeConnectorId != null) {
- nodeId = new NodeId(nodeConnectorId.getValue().replaceFirst(":[0-9]+$", ""));
+ nodeId = new NodeId(COLON_NUMBERS_EOL.matcher(nodeConnectorId.getValue()).replaceFirst(""));
}
return nodeId;
}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * AbstractChangeListner implemented basic {@link AsyncDataChangeEvent} processing for
- * flow node subDataObject (flows, groups and meters).
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public abstract class AbstractChangeListener implements DataChangeListener {
-
- private final static Logger LOG = LoggerFactory.getLogger(AbstractChangeListener.class);
-
- private final AtomicLong txNum = new AtomicLong();
- private String transactionId;
-
- @Override
- public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
- this.transactionId = this.newTransactionIdentifier().toString();
- /* All DataObjects for create */
- final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries =
- changeEvent.getCreatedData().entrySet();
- /* All DataObjects for updates - init HashSet */
- final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updatedEntries = new HashSet<>();
- /* Filtered DataObject for update processing only */
- Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updateConfigEntrySet =
- changeEvent.getUpdatedData().entrySet();
- updatedEntries.addAll(updateConfigEntrySet);
- updatedEntries.removeAll(createdEntries);
- /* All DataObjects for remove */
- final Set<InstanceIdentifier<? extends DataObject>> removeEntriesInstanceIdentifiers =
- changeEvent.getRemovedPaths();
- /* Create DataObject processing (send to device) */
- for (final Entry<InstanceIdentifier<? extends DataObject>, DataObject> createdEntry : createdEntries) {
- InstanceIdentifier<? extends DataObject> entryKey = createdEntry.getKey();
- DataObject entryValue = createdEntry.getValue();
- if (preconditionForChange(entryKey, entryValue, null)) {
- this.add(entryKey, entryValue);
- }
- }
-
- for (final Entry<InstanceIdentifier<?>, DataObject> updatedEntrie : updatedEntries) {
- Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
- changeEvent.getOriginalData();
-
- InstanceIdentifier<? extends Object> entryKey = updatedEntrie.getKey();
- final DataObject original = origConfigData.get(entryKey);
- final DataObject updated = updatedEntrie.getValue();
- if (preconditionForChange(entryKey, original, updated)) {
- this.update(entryKey, original, updated);
- }
- }
-
- for (final InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers) {
- Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
- changeEvent.getOriginalData();
-
- final DataObject removeValue = origConfigData.get(instanceId);
- if (preconditionForChange(instanceId, removeValue, null)) {
- this.remove(instanceId, removeValue);
- }
- }
- }
-
- /**
- * Method returns generated transaction ID, which is unique for
- * every transaction. ID is composite from prefix ("DOM") and unique number.
- *
- * @return String transactionID
- */
- public String getTransactionId() {
- return this.transactionId;
- }
-
- private Object newTransactionIdentifier() {
- return "DOM-" + txNum.getAndIncrement();
- }
-
- /**
- * Method check all local preconditions for apply relevant changes.
- *
- * @param InstanceIdentifier identifier - the whole path to DataObject
- * @param DataObject original - original DataObject (for update)
- * or relevant DataObject (add/delete operations)
- * @param DataObject update - changed DataObject (contain updates)
- * or should be null for (add/delete operations)
- *
- * @return boolean - applicable
- */
- protected abstract boolean preconditionForChange(
- final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject original, final DataObject update);
-
- /**
- * Method checks the node data path in DataStore/OPERATIONAL because
- * without the Node Identifier in DataStore/OPERATIONAL, device
- * is not connected and device pre-configuration is allowed only.
- *
- * @param InstanceIdentifier identifier - could be whole path to DataObject,
- * but parent Node.class InstanceIdentifier is used for a check only
- *
- * @return boolean - is the Node available in DataStore/OPERATIONAL (is connected)
- */
- protected boolean isNodeAvailable(final InstanceIdentifier<? extends DataObject> identifier,
- final ReadOnlyTransaction readTrans) {
- final InstanceIdentifier<Node> nodeInstanceId = identifier.firstIdentifierOf(Node.class);
- try {
- return readTrans.read(LogicalDatastoreType.OPERATIONAL, nodeInstanceId).get().isPresent();
- }
- catch (InterruptedException | ExecutionException e) {
- LOG.error("Unexpected exception by reading Node ".concat(nodeInstanceId.toString()), e);
- return false;
- }
- finally {
- readTrans.close();
- }
- }
-
- /**
- * Method removes DataObject which is identified by InstanceIdentifier
- * from device.
- *
- * @param InstanceIdentifier identifier - the whole path to DataObject
- * @param DataObject remove - DataObject for removing
- */
- protected abstract void remove(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject remove);
-
- /**
- * Method updates the original DataObject to the update DataObject
- * in device. Both are identified by same InstanceIdentifier
- *
- * @param InstanceIdentifier identifier - the whole path to DataObject
- * @param DataObject original - original DataObject (for update)
- * @param DataObject update - changed DataObject (contain updates)
- */
- protected abstract void update(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject original, final DataObject update);
-
- /**
- * Method adds the DataObject which is identified by InstanceIdentifier
- * to device.
- *
- * @param InstanceIdentifier identifier - the whole path to new DataObject
- * @param DataObject add - new DataObject
- */
- protected abstract void add(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject add);
-}
*/
package org.opendaylight.controller.frm;
-import org.opendaylight.controller.frm.flow.FlowProvider;
-import org.opendaylight.controller.frm.group.GroupProvider;
-import org.opendaylight.controller.frm.meter.MeterProvider;
-import org.opendaylight.controller.frm.reconil.FlowNodeReconcilProvider;
+import org.opendaylight.controller.frm.impl.ForwardingRulesManagerImpl;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
/**
* Forwarding Rules Manager Activator
*
- * Activator manages all Providers ({@link FlowProvider}, {@link GroupProvider},
- * {@link MeterProvider} and the {@link FlowNodeReconcilProvider}).
+ * Activator {@link ForwardingRulesManager}.
* It registers all listeners (DataChangeEvent, ReconcilNotification)
* in the Session Initialization phase.
*
private final static Logger LOG = LoggerFactory.getLogger(FRMActivator.class);
- private final FlowProvider flowProvider;
- private final GroupProvider groupProvider;
- private final MeterProvider meterProvider;
- private final FlowNodeReconcilProvider flowNodeReconcilProvider;
-
- public FRMActivator() {
- this.flowProvider = new FlowProvider();
- this.groupProvider = new GroupProvider();
- this.meterProvider = new MeterProvider();
- this.flowNodeReconcilProvider = new FlowNodeReconcilProvider();
- }
+ private ForwardingRulesManager manager;
@Override
- public void onSessionInitiated(final ProviderContext session) {
+ public void onSessionInitiated(ProviderContext session) {
LOG.info("FRMActivator initialization.");
- /* Flow */
try {
- final DataBroker flowSalService = session.getSALService(DataBroker.class);
- this.flowProvider.init(flowSalService);
- this.flowProvider.start(session);
- /* Group */
- final DataBroker groupSalService = session.getSALService(DataBroker.class);
- this.groupProvider.init(groupSalService);
- this.groupProvider.start(session);
- /* Meter */
- final DataBroker meterSalService = session.getSALService(DataBroker.class);
- this.meterProvider.init(meterSalService);
- this.meterProvider.start(session);
- /* FlowNode Reconciliation */
- final DataBroker dbs = session.getSALService(DataBroker.class);
- this.flowNodeReconcilProvider.init(dbs);
- this.flowNodeReconcilProvider.start(session);
-
- LOG.info("FRMActivator started successfully");
- } catch (Exception e) {
- String errMsg = "Unexpected error by starting FRMActivator";
- LOG.error(errMsg, e);
- throw new IllegalStateException(errMsg, e);
+ final DataBroker dataBroker = session.getSALService(DataBroker.class);
+ this.manager = new ForwardingRulesManagerImpl(dataBroker, session);
+ this.manager.start();
+ LOG.info("FRMActivator initialization successfull.");
+ }
+ catch (Exception e) {
+ LOG.error("Unexpected error by FRM initialization!", e);
+ this.stopImpl(null);
}
}
@Override
protected void stopImpl(final BundleContext context) {
- try {
- this.flowProvider.close();
- this.groupProvider.close();
- this.meterProvider.close();
- this.flowNodeReconcilProvider.close();
- } catch (Exception e) {
- LOG.error("Unexpected error by stopping FRMActivator", e);
+ if (manager != null) {
+ try {
+ manager.close();
+ } catch (Exception e) {
+ LOG.error("Unexpected error by stopping FRMActivator", e);
+ }
+ manager = null;
+ LOG.info("FRMActivator stopped.");
}
}
}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm;
-
-import java.math.BigInteger;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.AtomicLongMap;
-
-/**
- * forwardingrules-manager
- * org.opendaylight.controller.frm
- *
- * Singleton FlowCookieProducer contains a FlowCookie generator which is generated unique
- * flowCookie identifier for every flow in same Table. That could help with quick
- * identification of flow statistic because DataStore/CONFIGURATION could contains
- * a lot of flows with same flowCookie. So we are replacing original flowCookie
- * with unique and we are building final FlowCookieMap in DataStore/OPERATIONAL
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Jun 13, 2014
- */
-public enum FlowCookieProducer {
-
- INSTANCE;
-
- /* Flow_Cookie_Key and Flow_Ids MapHolder */
- private static final AtomicLongMap<InstanceIdentifier<Table>> cookieKeys = AtomicLongMap.create();
-
- /**
- * Method returns the unique cookie for a node table.
- * Flow Cookie Key signs List<FlowId> for a right flow statistic identification
- * in the DataStore/operational.
- * We need a List<FlowId> because system doesn't guarantee unique mapping
- * from flow_cookie to flow_id. REST Operations doesn't used FRM yet, so
- * cookie from user input could have a user input flow ID and an alien system ID
- * which is generated by system.
- *
- * @param InstanceIdentifier<Table> tableIdentifier
- * @return unique BigInteger flowCookie for a node table
- */
- public BigInteger getNewCookie(final InstanceIdentifier<Table> tableIdentifier) {
- FlowCookieProducer.validationTableIdentifier(tableIdentifier);
- if ( cookieKeys.containsKey(tableIdentifier)) {
- /* new identifier always starts from ONE because
- * ZERO is reserved for the NO_COOKIES flows */
- return BigInteger.valueOf(cookieKeys.addAndGet(tableIdentifier, 1L));
- } else {
- return BigInteger.valueOf(cookieKeys.incrementAndGet(tableIdentifier));
- }
- }
-
- /**
- * Method cleans the node table flow_cookie_key for the disconnected Node.
- *
- * @param InstanceIdentifier<Table> tableIdentifier
- */
- public void clean(final InstanceIdentifier<Table> tableIdentifier) {
- FlowCookieProducer.validationTableIdentifier(tableIdentifier);
- cookieKeys.remove(tableIdentifier);
- }
-
- /*
- * Help the TableIdentifer input validation method
- */
- private static void validationTableIdentifier(final InstanceIdentifier<Table> tableIdent) {
- Preconditions.checkArgument(tableIdent != null, "Input validation exception: TableIdentifier can not be null !");
- }
-}
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * forwardingrules-manager
+ * org.opendaylight.controller.frm
+ *
+ * FlowNodeReconciliation
+ * It represent Reconciliation functionality for every new device.
+ * So we have to read all possible pre-configured Flows, Meters and Groups from
+ * Config/DS and add all to new device.
+ * New device is represented by new {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}
+ * in Operational/DS. So we have to add listener for Wildcarded path in base data change scope.
+ *
+ * WildCarded InstanceIdentifier:
+ * {@code
+ *
+ * InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+ *
+ * }
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 26, 2014
+ */
+public interface FlowNodeReconciliation extends DataChangeListener, AutoCloseable {
+
+ /**
+ * Method contains Node registration to {@link ForwardingRulesManager} functionality
+ * as a prevention to use a validation check to the Operational/DS for identify
+ * pre-configure transaction and serious device commit in every transaction.
+ *
+ * Second part of functionality is own reconciliation pre-configure
+ * Flows, Meters and Groups.
+ *
+ * @param connectedNode - {@link org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier} to new Node
+ */
+ void flowNodeConnected(InstanceIdentifier<FlowCapableNode> connectedNode);
+
+ /**
+ * Method contains functionality for registered Node {@FlowCapableNode} removing
+ * from {@Link ForwardingRulesManager}
+ *
+ * @param disconnectedNode - {@link org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier} to removed Node
+ */
+ void flowNodeDisconnected(InstanceIdentifier<FlowCapableNode> disconnectedNode);
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * forwardingrules-manager
+ * org.opendaylight.controller.frm
+ *
+ * ForwardingRulesCommiter
+ * It represent a contract between DataStore DataChangeEvent and relevant
+ * SalRpcService for device. Every implementation has to be registered for
+ * Configurational/DS tree path.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 25, 2014
+ */
+public interface ForwardingRulesCommiter <D extends DataObject> extends AutoCloseable, DataChangeListener {
+
+ /**
+ * Method removes DataObject which is identified by InstanceIdentifier
+ * from device.
+ *
+ * @param InstanceIdentifier identifier - the whole path to DataObject
+ * @param DataObject remove - DataObject for removing
+ * @param InstanceIdentifier<FlowCapableNode> parent Node InstanceIdentifier
+ */
+ void remove(InstanceIdentifier<D> identifier, D del,
+ InstanceIdentifier<FlowCapableNode> nodeIdent);
+
+ /**
+ * Method updates the original DataObject to the update DataObject
+ * in device. Both are identified by same InstanceIdentifier
+ *
+ * @param InstanceIdentifier identifier - the whole path to DataObject
+ * @param DataObject original - original DataObject (for update)
+ * @param DataObject update - changed DataObject (contain updates)
+ */
+ void update(InstanceIdentifier<D> identifier, D original, D update,
+ InstanceIdentifier<FlowCapableNode> nodeIdent);
+
+ /**
+ * Method adds the DataObject which is identified by InstanceIdentifier
+ * to device.
+ *
+ * @param InstanceIdentifier identifier - the whole path to new DataObject
+ * @param DataObject add - new DataObject
+ */
+ void add(InstanceIdentifier<D> identifier, D add,
+ InstanceIdentifier<FlowCapableNode> nodeIdent);
+
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * forwardingrules-manager
+ * org.opendaylight.controller.frm
+ *
+ * ForwardingRulesManager
+ * It represent a central point for whole modul. Implementation
+ * Flow Provider registers the link FlowChangeListener} and it holds all needed
+ * services for link FlowChangeListener}.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 25, 2014
+ */
+public interface ForwardingRulesManager extends AutoCloseable {
+
+ public void start();
+
+ /**
+ * Method returns information :
+ * "is Node with send InstanceIdentifier connected"?
+ *
+ * @param InstanceIdentifier<FlowCapableNode> ident - the key of the node
+ * @return boolean - is device connected
+ */
+ public boolean isNodeActive(InstanceIdentifier<FlowCapableNode> ident);
+
+ /**
+ * Method add new {@link FlowCapableNode} to active Node Holder.
+ * ActiveNodeHolder prevent unnecessary Operational/DS read for identify
+ * pre-configure and serious Configure/DS transactions.
+ *
+ * @param InstanceIdentifier<FlowCapableNode> ident - the key of the node
+ */
+ public void registrateNewNode(InstanceIdentifier<FlowCapableNode> ident);
+
+ /**
+ * Method remove disconnected {@link FlowCapableNode} from active Node
+ * Holder. And all next flows or groups or meters will stay in Config/DS
+ * only.
+ *
+ * @param InstanceIdentifier<FlowCapableNode> ident - the key of the node
+ */
+ public void unregistrateNode(InstanceIdentifier<FlowCapableNode> ident);
+
+ /**
+ * Method returns generated transaction ID, which is unique for
+ * every transaction. ID is composite from prefix ("DOM") and unique number.
+ *
+ * @return String transactionID for RPC transaction identification
+ */
+ public String getNewTransactionId();
+
+ /**
+ * Method returns Read Transacion. It is need for Node reconciliation only.
+ *
+ * @return ReadOnlyTransaction
+ */
+ public ReadOnlyTransaction getReadTranaction();
+
+ /**
+ * Flow RPC service
+ *
+ * @return
+ */
+ public SalFlowService getSalFlowService();
+
+ /**
+ * Group RPC service
+ *
+ * @return
+ */
+ public SalGroupService getSalGroupService();
+
+ /**
+ * Meter RPC service
+ *
+ * @return
+ */
+ public SalMeterService getSalMeterService();
+
+ /**
+ * Content definition method and prevent code duplicity in Reconcil
+ * @return ForwardingRulesCommiter<Flow>
+ */
+ public ForwardingRulesCommiter<Flow> getFlowCommiter();
+
+ /**
+ * Content definition method and prevent code duplicity in Reconcil
+ * @return ForwardingRulesCommiter<Group>
+ */
+ public ForwardingRulesCommiter<Group> getGroupCommiter();
+
+ /**
+ * Content definition method and prevent code duplicity
+ * @return ForwardingRulesCommiter<Meter>
+ */
+ public ForwardingRulesCommiter<Meter> getMeterCommiter();
+
+ /**
+ * Content definition method
+ * @return FlowNodeReconciliation
+ */
+ public FlowNodeReconciliation getFlowNodeReconciliation();
+}
+
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.flow;
-
-import java.math.BigInteger;
-
-import org.opendaylight.controller.frm.AbstractChangeListener;
-import org.opendaylight.controller.frm.FlowCookieProducer;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Flow Change Listener
- * add, update and remove {@link Flow} processing from {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent}.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public class FlowChangeListener extends AbstractChangeListener {
-
- private static final Logger LOG = LoggerFactory.getLogger(FlowChangeListener.class);
-
- private final FlowProvider provider;
-
- public FlowChangeListener (final FlowProvider provider) {
- this.provider = Preconditions.checkNotNull(provider, "FlowProvider can not be null !");
- }
-
- @Override
- protected void remove(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject removeDataObj) {
-
- final Flow flow = ((Flow) removeDataObj);
- final InstanceIdentifier<Table> tableIdent = identifier.firstIdentifierOf(Table.class);
- final InstanceIdentifier<Node> nodeIdent = identifier.firstIdentifierOf(Node.class);
- final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow);
-
- // use empty cookie mask in order to delete flow even with generated cookie
- builder.setCookieMask(new FlowCookie(BigInteger.ZERO));
-
- builder.setFlowRef(new FlowRef(identifier));
- builder.setNode(new NodeRef(nodeIdent));
- builder.setFlowTable(new FlowTableRef(tableIdent));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
- this.provider.getSalFlowService().removeFlow(builder.build());
- LOG.debug("Transaction {} - Removed Flow has removed flow: {}", new Object[]{uri, removeDataObj});
- }
-
- @Override
- protected void update(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject original, final DataObject update) {
-
- final Flow originalFlow = ((Flow) original);
- final Flow updatedFlow = ((Flow) update);
- final InstanceIdentifier<Node> nodeIdent = identifier.firstIdentifierOf(Node.class);
- final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
-
- builder.setNode(new NodeRef(nodeIdent));
- builder.setFlowRef(new FlowRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
-
- builder.setUpdatedFlow((new UpdatedFlowBuilder(updatedFlow)).build());
- builder.setOriginalFlow((new OriginalFlowBuilder(originalFlow)).build());
-
- this.provider.getSalFlowService().updateFlow(builder.build());
- LOG.debug("Transaction {} - Update Flow has updated flow {} with {}", new Object[]{uri, original, update});
- }
-
- @Override
- protected void add(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject addDataObj) {
-
- final Flow flow = ((Flow) addDataObj);
- final InstanceIdentifier<Table> tableIdent = identifier.firstIdentifierOf(Table.class);
- final NodeRef nodeRef = new NodeRef(identifier.firstIdentifierOf(Node.class));
- final FlowCookie flowCookie = new FlowCookie(FlowCookieProducer.INSTANCE.getNewCookie(tableIdent));
- final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow);
-
- builder.setNode(nodeRef);
- builder.setFlowRef(new FlowRef(identifier));
- builder.setFlowTable(new FlowTableRef(tableIdent));
- builder.setCookie( flowCookie );
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
- this.provider.getSalFlowService().addFlow(builder.build());
- LOG.debug("Transaction {} - Add Flow has added flow: {}", new Object[]{uri, addDataObj});
- }
-
- @Override
- protected boolean preconditionForChange(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject dataObj, final DataObject update) {
-
- final ReadOnlyTransaction trans = this.provider.getDataService().newReadOnlyTransaction();
- return update != null
- ? (dataObj instanceof Flow && update instanceof Flow && isNodeAvailable(identifier, trans))
- : (dataObj instanceof Flow && isNodeAvailable(identifier, trans));
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.flow;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Flow Provider registers the {@link FlowChangeListener} and it holds all needed
- * services for {@link FlowChangeListener}.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public class FlowProvider implements AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(FlowProvider.class);
-
- private SalFlowService salFlowService;
- private DataBroker dataService;
-
- /* DataChangeListener */
- private DataChangeListener flowDataChangeListener;
- private ListenerRegistration<DataChangeListener> flowDataChangeListenerRegistration;
-
- /**
- * Provider Initialization Phase.
- *
- * @param DataProviderService dataService
- */
- public void init (final DataBroker dataService) {
- LOG.info("FRM Flow Config Provider initialization.");
- this.dataService = Preconditions.checkNotNull(dataService, "DataProviderService can not be null !");
- }
-
- /**
- * Listener Registration Phase
- *
- * @param RpcConsumerRegistry rpcRegistry
- */
- public void start(final RpcConsumerRegistry rpcRegistry) {
- Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
-
- this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
- "RPC SalFlowService not found.");
-
- /* Build Path */
- InstanceIdentifier<Flow> flowIdentifier = InstanceIdentifier.create(Nodes.class)
- .child(Node.class).augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
-
- /* DataChangeListener registration */
- this.flowDataChangeListener = new FlowChangeListener(FlowProvider.this);
- this.flowDataChangeListenerRegistration =
- this.dataService.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
- flowIdentifier, flowDataChangeListener, DataChangeScope.SUBTREE);
-
- LOG.info("FRM Flow Config Provider started.");
- }
-
- @Override
- public void close() {
- LOG.info("FRM Flow Config Provider stopped.");
- if (flowDataChangeListenerRegistration != null) {
- try {
- flowDataChangeListenerRegistration.close();
- } catch (Exception e) {
- String errMsg = "Error by stop FRM Flow Config Provider.";
- LOG.error(errMsg, e);
- throw new IllegalStateException(errMsg, e);
- } finally {
- flowDataChangeListenerRegistration = null;
- }
- }
- }
-
- public DataChangeListener getFlowDataChangeListener() {
- return flowDataChangeListener;
- }
-
- public SalFlowService getSalFlowService() {
- return salFlowService;
- }
-
- public DataBroker getDataService() {
- return dataService;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.group;
-
-import org.opendaylight.controller.frm.AbstractChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
-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.OriginalGroupBuilder;
-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.GroupRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Group Change Listener
- * add, update and remove {@link Group} processing from {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent}.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public class GroupChangeListener extends AbstractChangeListener {
-
- private static final Logger LOG = LoggerFactory.getLogger(GroupChangeListener.class);
-
- private final GroupProvider provider;
-
- public GroupChangeListener(final GroupProvider provider) {
- this.provider = Preconditions.checkNotNull(provider, "GroupProvider can not be null !");
- }
-
- @Override
- protected void remove(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject removeDataObj) {
-
- final Group group = ((Group) removeDataObj);
- final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
- final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
-
- builder.setNode(new NodeRef(nodeInstanceId));
- builder.setGroupRef(new GroupRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
- this.provider.getSalGroupService().removeGroup(builder.build());
- LOG.debug("Transaction {} - Remove Group has removed group: {}", new Object[]{uri, removeDataObj});
- }
-
- @Override
- protected void update(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject original, final DataObject update) {
-
- final Group originalGroup = ((Group) original);
- final Group updatedGroup = ((Group) update);
- final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
- final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
-
- builder.setNode(new NodeRef(nodeInstanceId));
- builder.setGroupRef(new GroupRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
-
- builder.setUpdatedGroup((new UpdatedGroupBuilder(updatedGroup)).build());
- builder.setOriginalGroup((new OriginalGroupBuilder(originalGroup)).build());
-
- this.provider.getSalGroupService().updateGroup(builder.build());
- LOG.debug("Transaction {} - Update Group has updated group {} with group {}", new Object[]{uri, original, update});
- }
-
- @Override
- protected void add(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject addDataObj) {
-
- final Group group = ((Group) addDataObj);
- final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
- final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
-
- builder.setNode(new NodeRef(nodeInstanceId));
- builder.setGroupRef(new GroupRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
- this.provider.getSalGroupService().addGroup(builder.build());
- LOG.debug("Transaction {} - Add Group has added group: {}", new Object[]{uri, addDataObj});
- }
-
- @Override
- protected boolean preconditionForChange(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject dataObj, final DataObject update) {
-
- final ReadOnlyTransaction trans = this.provider.getDataService().newReadOnlyTransaction();
- return update != null
- ? (dataObj instanceof Group && update instanceof Group && isNodeAvailable(identifier, trans))
- : (dataObj instanceof Group && isNodeAvailable(identifier, trans));
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.group;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Group Provider registers the {@link GroupChangeListener} and it holds all needed
- * services for {@link GroupChangeListener}.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public class GroupProvider implements AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(GroupProvider.class);
-
- private SalGroupService salGroupService;
- private DataBroker dataService;
-
- /* DataChangeListener */
- private DataChangeListener groupDataChangeListener;
- private ListenerRegistration<DataChangeListener> groupDataChangeListenerRegistration;
-
- /**
- * Provider Initialization Phase.
- *
- * @param DataProviderService dataService
- */
- public void init (final DataBroker dataService) {
- LOG.info("FRM Group Config Provider initialization.");
- this.dataService = Preconditions.checkNotNull(dataService, "DataService can not be null !");
- }
-
- /**
- * Listener Registration Phase
- *
- * @param RpcConsumerRegistry rpcRegistry
- */
- public void start(final RpcConsumerRegistry rpcRegistry) {
- Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
-
- this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
- "RPC SalGroupService not found.");
-
- /* Build Path */
- InstanceIdentifier<Group> groupIdentifier = InstanceIdentifier.create(Nodes.class)
- .child(Node.class).augmentation(FlowCapableNode.class).child(Group.class);
-
- /* DataChangeListener registration */
- this.groupDataChangeListener = new GroupChangeListener(GroupProvider.this);
- this.groupDataChangeListenerRegistration = this.dataService.registerDataChangeListener(
- LogicalDatastoreType.CONFIGURATION, groupIdentifier, groupDataChangeListener, DataChangeScope.SUBTREE);
-
- LOG.info("FRM Group Config Provider started.");
- }
-
- @Override
- public void close() {
- LOG.info("FRM Group Config Provider stopped.");
- if (groupDataChangeListenerRegistration != null) {
- try {
- groupDataChangeListenerRegistration.close();
- } catch (Exception e) {
- String errMsg = "Error by stop FRM Group Config Provider.";
- LOG.error(errMsg, e);
- throw new IllegalStateException(errMsg, e);
- } finally {
- groupDataChangeListenerRegistration = null;
- }
- }
- }
-
- public DataChangeListener getGroupDataChangeListener() {
- return groupDataChangeListener;
- }
-
- public SalGroupService getSalGroupService() {
- return salGroupService;
- }
-
- public DataBroker getDataService() {
- return dataService;
- }
-}
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.frm.ForwardingRulesCommiter;
+import org.opendaylight.controller.frm.ForwardingRulesManager;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * AbstractChangeListner implemented basic {@link AsyncDataChangeEvent} processing for
+ * flow node subDataObject (flows, groups and meters).
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public abstract class AbstractListeningCommiter <T extends DataObject> implements ForwardingRulesCommiter<T> {
+
+ protected ForwardingRulesManager provider;
+
+ protected final Class<T> clazz;
+
+ public AbstractListeningCommiter (ForwardingRulesManager provider, Class<T> clazz) {
+ this.provider = Preconditions.checkNotNull(provider, "ForwardingRulesManager can not be null!");
+ this.clazz = Preconditions.checkNotNull(clazz, "Class can not be null!");
+ }
+
+ @Override
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+ Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
+
+ /* All DataObjects for create */
+ final Map<InstanceIdentifier<?>, DataObject> createdData = changeEvent.getCreatedData() != null
+ ? changeEvent.getCreatedData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+ /* All DataObjects for remove */
+ final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
+ ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>> emptySet();
+ /* All DataObjects for updates */
+ final Map<InstanceIdentifier<?>, DataObject> updateData = changeEvent.getUpdatedData() != null
+ ? changeEvent.getUpdatedData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+ /* All Original DataObjects */
+ final Map<InstanceIdentifier<?>, DataObject> originalData = changeEvent.getOriginalData() != null
+ ? changeEvent.getOriginalData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+
+ this.createData(createdData);
+ this.updateData(updateData, originalData);
+ this.removeData(removeData, originalData);
+ }
+
+ /**
+ * Method return wildCardPath for Listener registration
+ * and for identify the correct KeyInstanceIdentifier from data;
+ */
+ protected abstract InstanceIdentifier<T> getWildCardPath();
+
+
+
+ @SuppressWarnings("unchecked")
+ private void createData(final Map<InstanceIdentifier<?>, DataObject> createdData) {
+ final Set<InstanceIdentifier<?>> keys = createdData.keySet() != null
+ ? createdData.keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+ for (InstanceIdentifier<?> key : keys) {
+ if (clazz.equals(key.getTargetType())) {
+ final InstanceIdentifier<FlowCapableNode> nodeIdent =
+ key.firstIdentifierOf(FlowCapableNode.class);
+ if (preConfigurationCheck(nodeIdent)) {
+ InstanceIdentifier<T> createKeyIdent = key.firstIdentifierOf(clazz);
+ final Optional<DataObject> value = Optional.of(createdData.get(key));
+ if (value.isPresent()) {
+ this.add(createKeyIdent, (T)value.get(), nodeIdent);
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void updateData(final Map<InstanceIdentifier<?>, DataObject> updateData,
+ final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+ final Set<InstanceIdentifier<?>> keys = updateData.keySet() != null
+ ? updateData.keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+ for (InstanceIdentifier<?> key : keys) {
+ if (clazz.equals(key.getTargetType())) {
+ final InstanceIdentifier<FlowCapableNode> nodeIdent =
+ key.firstIdentifierOf(FlowCapableNode.class);
+ if (preConfigurationCheck(nodeIdent)) {
+ InstanceIdentifier<T> updateKeyIdent = key.firstIdentifierOf(clazz);
+ final Optional<DataObject> value = Optional.of(updateData.get(key));
+ final Optional<DataObject> original = Optional.of(originalData.get(key));
+ if (value.isPresent() && original.isPresent()) {
+ this.update(updateKeyIdent, (T)original.get(), (T)value.get(), nodeIdent);
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeData(final Set<InstanceIdentifier<?>> removeData,
+ final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+ for (InstanceIdentifier<?> key : removeData) {
+ if (clazz.equals(key.getTargetType())) {
+ final InstanceIdentifier<FlowCapableNode> nodeIdent =
+ key.firstIdentifierOf(FlowCapableNode.class);
+ if (preConfigurationCheck(nodeIdent)) {
+ final InstanceIdentifier<T> ident = key.firstIdentifierOf(clazz);
+ final DataObject removeValue = originalData.get(key);
+ this.remove(ident, (T)removeValue, nodeIdent);
+ }
+ }
+ }
+ }
+
+ private boolean preConfigurationCheck(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+ Preconditions.checkNotNull(nodeIdent, "FlowCapableNode ident can not be null!");
+ return provider.isNodeActive(nodeIdent);
+ }
+}
+
--- /dev/null
+/**ab
+ * Copyright (c) 2014 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.frm.impl;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.frm.ForwardingRulesManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * GroupForwarder
+ * It implements {@link org.opendaylight.controller.md.sal.binding.api.DataChangeListener}}
+ * for WildCardedPath to {@link Flow} and ForwardingRulesCommiter interface for methods:
+ * add, update and remove {@link Flow} processing for
+ * {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent}.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class FlowForwarder extends AbstractListeningCommiter<Flow> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FlowForwarder.class);
+
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+
+ public FlowForwarder (final ForwardingRulesManager manager, final DataBroker db) {
+ super(manager, Flow.class);
+ Preconditions.checkNotNull(db, "DataBroker can not be null!");
+ this.listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ getWildCardPath(), FlowForwarder.this, DataChangeScope.BASE);
+ }
+
+ @Override
+ public void close() {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (Exception e) {
+ LOG.error("Error by stop FRM FlowChangeListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ }
+
+ @Override
+ public void remove(final InstanceIdentifier<Flow> identifier,
+ final Flow removeDataObj,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
+ if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
+ final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
+ builder.setFlowRef(new FlowRef(identifier));
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ this.provider.getSalFlowService().removeFlow(builder.build());
+ }
+ }
+
+ @Override
+ public void update(final InstanceIdentifier<Flow> identifier,
+ final Flow original, final Flow update,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
+ if (tableIdValidationPrecondition(tableKey, update)) {
+ final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setFlowRef(new FlowRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ builder.setUpdatedFlow((new UpdatedFlowBuilder(update)).build());
+ builder.setOriginalFlow((new OriginalFlowBuilder(original)).build());
+
+ this.provider.getSalFlowService().updateFlow(builder.build());
+ }
+ }
+
+ @Override
+ public void add(final InstanceIdentifier<Flow> identifier,
+ final Flow addDataObj,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
+ if (tableIdValidationPrecondition(tableKey, addDataObj)) {
+ final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setFlowRef(new FlowRef(identifier));
+ builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ this.provider.getSalFlowService().addFlow(builder.build());
+ }
+ }
+
+ @Override
+ protected InstanceIdentifier<Flow> getWildCardPath() {
+ return InstanceIdentifier.create(Nodes.class).child(Node.class)
+ .augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
+ }
+
+ private boolean tableIdValidationPrecondition (final TableKey tableKey, final Flow flow) {
+ Preconditions.checkNotNull(tableKey, "TableKey can not be null or empty!");
+ Preconditions.checkNotNull(flow, "Flow can not be null or empty!");
+ if (flow.getTableId() != tableKey.getId()) {
+ LOG.error("TableID in URI tableId={} and in palyload tableId={} is not same.",
+ flow.getTableId(), tableKey.getId());
+ return false;
+ }
+ return true;
+ }
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm.impl;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.frm.FlowNodeReconciliation;
+import org.opendaylight.controller.frm.ForwardingRulesManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+/**
+ * forwardingrules-manager
+ * org.opendaylight.controller.frm
+ *
+ * FlowNode Reconciliation Listener
+ * Reconciliation for a new FlowNode
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Jun 13, 2014
+ */
+public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FlowNodeReconciliationImpl.class);
+
+ private final ForwardingRulesManager provider;
+
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+
+ public FlowNodeReconciliationImpl (final ForwardingRulesManager manager, final DataBroker db) {
+ this.provider = Preconditions.checkNotNull(manager, "ForwardingRulesManager can not be null!");
+ Preconditions.checkNotNull(db, "DataBroker can not be null!");
+ /* Build Path */
+ InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class)
+ .child(Node.class).augmentation(FlowCapableNode.class);
+ this.listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ flowNodeWildCardIdentifier, FlowNodeReconciliationImpl.this, DataChangeScope.BASE);
+ }
+
+ @Override
+ public void close() {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (Exception e) {
+ LOG.error("Error by stop FRM FlowNodeReconilListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ }
+
+ @Override
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+ Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
+ /* All DataObjects for create */
+ final Set<InstanceIdentifier<?>> createdData = changeEvent.getCreatedData() != null
+ ? changeEvent.getCreatedData().keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+ /* All DataObjects for remove */
+ final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
+ ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>> emptySet();
+
+ for (InstanceIdentifier<?> entryKey : removeData) {
+ final InstanceIdentifier<FlowCapableNode> nodeIdent = entryKey
+ .firstIdentifierOf(FlowCapableNode.class);
+ if ( ! nodeIdent.isWildcarded()) {
+ flowNodeDisconnected(nodeIdent);
+ }
+ }
+ for (InstanceIdentifier<?> entryKey : createdData) {
+ final InstanceIdentifier<FlowCapableNode> nodeIdent = entryKey
+ .firstIdentifierOf(FlowCapableNode.class);
+ if ( ! nodeIdent.isWildcarded()) {
+ flowNodeConnected(nodeIdent);
+ }
+ }
+ }
+
+ @Override
+ public void flowNodeDisconnected(InstanceIdentifier<FlowCapableNode> disconnectedNode) {
+ provider.unregistrateNode(disconnectedNode);
+ }
+
+ @Override
+ public void flowNodeConnected(InstanceIdentifier<FlowCapableNode> connectedNode) {
+ if ( ! provider.isNodeActive(connectedNode)) {
+ provider.registrateNewNode(connectedNode);
+ reconciliation(connectedNode);
+ }
+ }
+
+ private void reconciliation(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ ReadOnlyTransaction trans = provider.getReadTranaction();
+ Optional<FlowCapableNode> flowNode = Optional.absent();
+
+ try {
+ flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdent).get();
+ }
+ catch (Exception e) {
+ LOG.error("Fail with read Config/DS for Node {} !", nodeIdent, e);
+ }
+
+ if (flowNode.isPresent()) {
+ /* Groups - have to be first */
+ List<Group> groups = flowNode.get().getGroup() != null
+ ? flowNode.get().getGroup() : Collections.<Group> emptyList();
+ for (Group group : groups) {
+ final KeyedInstanceIdentifier<Group, GroupKey> groupIdent =
+ nodeIdent.child(Group.class, group.getKey());
+ this.provider.getGroupCommiter().add(groupIdent, group, nodeIdent);
+ }
+ /* Meters */
+ List<Meter> meters = flowNode.get().getMeter() != null
+ ? flowNode.get().getMeter() : Collections.<Meter> emptyList();
+ for (Meter meter : meters) {
+ final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent =
+ nodeIdent.child(Meter.class, meter.getKey());
+ this.provider.getMeterCommiter().add(meterIdent, meter, nodeIdent);
+ }
+ /* Flows */
+ List<Table> tables = flowNode.get().getTable() != null
+ ? flowNode.get().getTable() : Collections.<Table> emptyList();
+ for (Table table : tables) {
+ final KeyedInstanceIdentifier<Table, TableKey> tableIdent =
+ nodeIdent.child(Table.class, table.getKey());
+ List<Flow> flows = table.getFlow() != null ? table.getFlow() : Collections.<Flow> emptyList();
+ for (Flow flow : flows) {
+ final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent =
+ tableIdent.child(Flow.class, flow.getKey());
+ this.provider.getFlowCommiter().add(flowIdent, flow, nodeIdent);
+ }
+ }
+ }
+ /* clean transaction */
+ trans.close();
+ }
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm.impl;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.opendaylight.controller.frm.FlowNodeReconciliation;
+import org.opendaylight.controller.frm.ForwardingRulesCommiter;
+import org.opendaylight.controller.frm.ForwardingRulesManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+
+/**
+ * forwardingrules-manager
+ * org.opendaylight.controller.frm.impl
+ *
+ * Manager and middle point for whole module.
+ * It contains ActiveNodeHolder and provide all RPC services.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 25, 2014
+ */
+public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class);
+
+ private final AtomicLong txNum = new AtomicLong();
+ private final Object lockObj = new Object();
+ private Set<InstanceIdentifier<FlowCapableNode>> activeNodes = Collections.emptySet();
+
+ private final DataBroker dataService;
+ private final SalFlowService salFlowService;
+ private final SalGroupService salGroupService;
+ private final SalMeterService salMeterService;
+
+ private ForwardingRulesCommiter<Flow> flowListener;
+ private ForwardingRulesCommiter<Group> groupListener;
+ private ForwardingRulesCommiter<Meter> meterListener;
+ private FlowNodeReconciliation nodeListener;
+
+ public ForwardingRulesManagerImpl(final DataBroker dataBroker,
+ final RpcConsumerRegistry rpcRegistry) {
+ this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
+
+ Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
+
+ this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
+ "RPC SalFlowService not found.");
+ this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
+ "RPC SalGroupService not found.");
+ this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
+ "RPC SalMeterService not found.");
+ }
+
+ @Override
+ public void start() {
+ this.flowListener = new FlowForwarder(this, dataService);
+ this.groupListener = new GroupForwarder(this, dataService);
+ this.meterListener = new MeterForwarder(this, dataService);
+ this.nodeListener = new FlowNodeReconciliationImpl(this, dataService);
+ LOG.info("ForwardingRulesManager has started successfull.");
+ }
+
+ @Override
+ public void close() throws Exception {
+ if(this.flowListener != null) {
+ this.flowListener.close();
+ this.flowListener = null;
+ }
+ if (this.groupListener != null) {
+ this.groupListener.close();
+ this.groupListener = null;
+ }
+ if (this.meterListener != null) {
+ this.meterListener.close();
+ this.meterListener = null;
+ }
+ if (this.nodeListener != null) {
+ this.nodeListener.close();
+ this.nodeListener = null;
+ }
+ }
+
+ @Override
+ public ReadOnlyTransaction getReadTranaction() {
+ return dataService.newReadOnlyTransaction();
+ }
+
+ @Override
+ public String getNewTransactionId() {
+ return "DOM-" + txNum.getAndIncrement();
+ }
+
+ @Override
+ public boolean isNodeActive(InstanceIdentifier<FlowCapableNode> ident) {
+ return activeNodes.contains(ident);
+ }
+
+ @Override
+ public void registrateNewNode(InstanceIdentifier<FlowCapableNode> ident) {
+ if ( ! activeNodes.contains(ident)) {
+ synchronized (lockObj) {
+ if ( ! activeNodes.contains(ident)) {
+ Set<InstanceIdentifier<FlowCapableNode>> set =
+ Sets.newHashSet(activeNodes);
+ set.add(ident);
+ activeNodes = Collections.unmodifiableSet(set);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void unregistrateNode(InstanceIdentifier<FlowCapableNode> ident) {
+ if (activeNodes.contains(ident)) {
+ synchronized (lockObj) {
+ if (activeNodes.contains(ident)) {
+ Set<InstanceIdentifier<FlowCapableNode>> set =
+ Sets.newHashSet(activeNodes);
+ set.remove(ident);
+ activeNodes = Collections.unmodifiableSet(set);
+ }
+ }
+ }
+ }
+
+ @Override
+ public SalFlowService getSalFlowService() {
+ return salFlowService;
+ }
+
+ @Override
+ public SalGroupService getSalGroupService() {
+ return salGroupService;
+ }
+
+ @Override
+ public SalMeterService getSalMeterService() {
+ return salMeterService;
+ }
+
+ @Override
+ public ForwardingRulesCommiter<Flow> getFlowCommiter() {
+ return flowListener;
+ }
+
+ @Override
+ public ForwardingRulesCommiter<Group> getGroupCommiter() {
+ return groupListener;
+ }
+
+ @Override
+ public ForwardingRulesCommiter<Meter> getMeterCommiter() {
+ return meterListener;
+ }
+
+ @Override
+ public FlowNodeReconciliation getFlowNodeReconciliation() {
+ return nodeListener;
+ }
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm.impl;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.frm.ForwardingRulesManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
+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.OriginalGroupBuilder;
+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.GroupRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * GroupForwarder
+ * It implements {@link org.opendaylight.controller.md.sal.binding.api.DataChangeListener}}
+ * for WildCardedPath to {@link Group} and ForwardingRulesCommiter interface for methods:
+ * add, update and remove {@link Group} processing for
+ * {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent}.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class GroupForwarder extends AbstractListeningCommiter<Group> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GroupForwarder.class);
+
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+
+ public GroupForwarder (final ForwardingRulesManager manager, final DataBroker db) {
+ super(manager, Group.class);
+ Preconditions.checkNotNull(db, "DataBroker can not be null!");
+ this.listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ getWildCardPath(), GroupForwarder.this, DataChangeScope.BASE);
+ }
+
+ @Override
+ public void close() {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (Exception e) {
+ LOG.error("Error by stop FRM GroupChangeListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ }
+
+ @Override
+ protected InstanceIdentifier<Group> getWildCardPath() {
+ return InstanceIdentifier.create(Nodes.class).child(Node.class)
+ .augmentation(FlowCapableNode.class).child(Group.class);
+ }
+
+ @Override
+ public void remove(final InstanceIdentifier<Group> identifier, final Group removeDataObj,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final Group group = (removeDataObj);
+ final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setGroupRef(new GroupRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ this.provider.getSalGroupService().removeGroup(builder.build());
+ }
+
+ @Override
+ public void update(final InstanceIdentifier<Group> identifier,
+ final Group original, final Group update,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final Group originalGroup = (original);
+ final Group updatedGroup = (update);
+ final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setGroupRef(new GroupRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ builder.setUpdatedGroup((new UpdatedGroupBuilder(updatedGroup)).build());
+ builder.setOriginalGroup((new OriginalGroupBuilder(originalGroup)).build());
+
+ this.provider.getSalGroupService().updateGroup(builder.build());
+ }
+
+ @Override
+ public void add(final InstanceIdentifier<Group> identifier, final Group addDataObj,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final Group group = (addDataObj);
+ final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setGroupRef(new GroupRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ this.provider.getSalGroupService().addGroup(builder.build());
+ }
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2014 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.frm.impl;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.frm.ForwardingRulesManager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MeterForwarder
+ * It implements {@link org.opendaylight.controller.md.sal.binding.api.DataChangeListener}}
+ * for WildCardedPath to {@link Meter} and ForwardingRulesCommiter interface for methods:
+ * add, update and remove {@link Meter} processing for
+ * {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent}.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class MeterForwarder extends AbstractListeningCommiter<Meter> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MeterForwarder.class);
+
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+
+ public MeterForwarder (final ForwardingRulesManager manager, final DataBroker db) {
+ super(manager, Meter.class);
+ Preconditions.checkNotNull(db, "DataBroker can not be null!");
+ this.listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ getWildCardPath(), MeterForwarder.this, DataChangeScope.BASE);
+ }
+
+ @Override
+ public void close() {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (Exception e) {
+ LOG.error("Error by stop FRM MeterChangeListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ }
+
+ @Override
+ protected InstanceIdentifier<Meter> getWildCardPath() {
+ return InstanceIdentifier.create(Nodes.class).child(Node.class)
+ .augmentation(FlowCapableNode.class).child(Meter.class);
+ }
+
+ @Override
+ public void remove(final InstanceIdentifier<Meter> identifier, final Meter removeDataObj,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(removeDataObj);
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setMeterRef(new MeterRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ this.provider.getSalMeterService().removeMeter(builder.build());
+ }
+
+ @Override
+ public void update(final InstanceIdentifier<Meter> identifier,
+ final Meter original, final Meter update,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder();
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setMeterRef(new MeterRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ builder.setUpdatedMeter((new UpdatedMeterBuilder(update)).build());
+ builder.setOriginalMeter((new OriginalMeterBuilder(original)).build());
+
+ this.provider.getSalMeterService().updateMeter(builder.build());
+ }
+
+ @Override
+ public void add(final InstanceIdentifier<Meter> identifier, final Meter addDataObj,
+ final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+
+ final AddMeterInputBuilder builder = new AddMeterInputBuilder(addDataObj);
+
+ builder.setNode(new NodeRef(nodeIdent));
+ builder.setMeterRef(new MeterRef(identifier));
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ this.provider.getSalMeterService().addMeter(builder.build());
+ }
+}
+
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.meter;
-
-import org.opendaylight.controller.frm.AbstractChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Meter Change Listener
- * add, update and remove {@link Meter} processing from {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent}.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public class MeterChangeListener extends AbstractChangeListener {
-
- private static final Logger LOG = LoggerFactory.getLogger(MeterChangeListener.class);
-
- private final MeterProvider provider;
-
- public MeterChangeListener (final MeterProvider provider) {
- this.provider = Preconditions.checkNotNull(provider, "MeterProvider can not be null !");
- }
-
- @Override
- protected void remove(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject removeDataObj) {
-
- final Meter meter = ((Meter) removeDataObj);
- final InstanceIdentifier<Node> nodeIdent = identifier.firstIdentifierOf(Node.class);
- final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(meter);
-
- builder.setNode(new NodeRef(nodeIdent));
- builder.setMeterRef(new MeterRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
- this.provider.getSalMeterService().removeMeter(builder.build());
- LOG.debug("Transaction {} - Remove Meter has removed meter: {}", new Object[]{uri, removeDataObj});
- }
-
- @Override
- protected void update(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject original, final DataObject update) {
-
- final Meter originalMeter = ((Meter) original);
- final Meter updatedMeter = ((Meter) update);
- final InstanceIdentifier<Node> nodeInstanceId = identifier.firstIdentifierOf(Node.class);
- final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder();
-
- builder.setNode(new NodeRef(nodeInstanceId));
- builder.setMeterRef(new MeterRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
-
- builder.setUpdatedMeter((new UpdatedMeterBuilder(updatedMeter)).build());
- builder.setOriginalMeter((new OriginalMeterBuilder(originalMeter)).build());
-
- this.provider.getSalMeterService().updateMeter(builder.build());
- LOG.debug("Transaction {} - Update Meter has updated meter {} with {}", new Object[]{uri, original, update});
-
- }
-
- @Override
- protected void add(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject addDataObj) {
-
- final Meter meter = ((Meter) addDataObj);
- final InstanceIdentifier<Node> nodeInstanceId = identifier.firstIdentifierOf(Node.class);
- final AddMeterInputBuilder builder = new AddMeterInputBuilder(meter);
-
- builder.setNode(new NodeRef(nodeInstanceId));
- builder.setMeterRef(new MeterRef(identifier));
-
- Uri uri = new Uri(this.getTransactionId());
- builder.setTransactionUri(uri);
- this.provider.getSalMeterService().addMeter(builder.build());
- LOG.debug("Transaction {} - Add Meter has added meter: {}", new Object[]{uri, addDataObj});
- }
-
- @Override
- protected boolean preconditionForChange(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject dataObj, final DataObject update) {
-
- final ReadOnlyTransaction trans = this.provider.getDataService().newReadOnlyTransaction();
- return update != null
- ? (dataObj instanceof Meter && update instanceof Meter && isNodeAvailable(identifier, trans))
- : (dataObj instanceof Meter && isNodeAvailable(identifier, trans));
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.meter;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Meter Provider registers the {@link MeterChangeListener} and it holds all needed
- * services for {@link MeterChangeListener}.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- */
-public class MeterProvider implements AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(MeterProvider.class);
-
- private SalMeterService salMeterService;
- private DataBroker dataService;
-
- /* DataChangeListener */
- private DataChangeListener meterDataChangeListener;
- private ListenerRegistration<DataChangeListener> meterDataChangeListenerRegistration;
-
- /**
- * Provider Initialization Phase.
- *
- * @param DataProviderService dataService
- */
- public void init(final DataBroker dataService) {
- LOG.info("FRM Meter Config Provider initialization.");
- this.dataService = Preconditions.checkNotNull(dataService, "DataProviderService can not be null !");
- }
-
- /**
- * Listener Registration Phase
- *
- * @param RpcConsumerRegistry rpcRegistry
- */
- public void start(final RpcConsumerRegistry rpcRegistry) {
- Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
- this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
- "RPC SalMeterService not found.");
-
- /* Build Path */
- InstanceIdentifier<Meter> meterIdentifier = InstanceIdentifier.create(Nodes.class)
- .child(Node.class).augmentation(FlowCapableNode.class).child(Meter.class);
-
- /* DataChangeListener registration */
- this.meterDataChangeListener = new MeterChangeListener(MeterProvider.this);
- this.meterDataChangeListenerRegistration =
- this.dataService.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
- meterIdentifier, meterDataChangeListener, DataChangeScope.SUBTREE);
-
- LOG.info("FRM Meter Config Provider started.");
- }
-
- @Override
- public void close() {
- LOG.info("FRM Meter Config Provider stopped.");
- if (meterDataChangeListenerRegistration != null) {
- try {
- meterDataChangeListenerRegistration.close();
- } catch (Exception e) {
- String errMsg = "Error by stop FRM Meter Config Provider.";
- LOG.error(errMsg, e);
- throw new IllegalStateException(errMsg, e);
- } finally {
- meterDataChangeListenerRegistration = null;
- }
- }
- }
-
- public DataChangeListener getMeterDataChangeListener() {
- return meterDataChangeListener;
- }
-
- public DataBroker getDataService() {
- return dataService;
- }
-
- public SalMeterService getSalMeterService() {
- return salMeterService;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.reconil;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.frm.AbstractChangeListener;
-import org.opendaylight.controller.frm.FlowCookieProducer;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * forwardingrules-manager
- * org.opendaylight.controller.frm
- *
- * FlowNode Reconciliation Listener
- * Reconciliation for a new FlowNode
- * Remove CookieMapKey for removed FlowNode
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Jun 13, 2014
- */
-public class FlowNodeReconcilListener extends AbstractChangeListener {
-
- private static final Logger LOG = LoggerFactory.getLogger(FlowNodeReconcilListener.class);
-
- private final FlowNodeReconcilProvider provider;
-
- public FlowNodeReconcilListener(final FlowNodeReconcilProvider provider) {
- this.provider = Preconditions.checkNotNull(provider, "Flow Node Reconcil Provider can not be null!");
- }
-
- @Override
- public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
- /* FlowCapableNode DataObjects for reconciliation */
- final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries =
- changeEvent.getCreatedData().entrySet();
- /* FlowCapableNode DataObjects for clean FlowCookieHolder */
- final Set<InstanceIdentifier<? extends DataObject>> removeEntriesInstanceIdentifiers =
- changeEvent.getRemovedPaths();
- for (final Entry<InstanceIdentifier<? extends DataObject>, DataObject> createdEntry : createdEntries) {
- InstanceIdentifier<? extends DataObject> entryKey = createdEntry.getKey();
- DataObject entryValue = createdEntry.getValue();
- if (preconditionForChange(entryKey, entryValue, null)) {
- this.add(entryKey, entryValue);
- }
- }
- for (final InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers) {
- Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
- changeEvent.getOriginalData();
- final DataObject removeValue = origConfigData.get(instanceId);
- if (preconditionForChange(instanceId, removeValue, null)) {
- this.remove(instanceId, removeValue);
- }
- }
- }
-
- @Override
- /* Cleaning FlowCookieManager holder for all node tables */
- protected void remove(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject removeDataObj) {
-
- final InstanceIdentifier<FlowCapableNode> flowNodeIdent =
- identifier.firstIdentifierOf(FlowCapableNode.class);
- final FlowCapableNode flowNode = ((FlowCapableNode) removeDataObj);
-
- for (Table flowTable : flowNode.getTable()) {
- final InstanceIdentifier<Table> tableIdent =
- flowNodeIdent.child(Table.class, flowTable.getKey());
- FlowCookieProducer.INSTANCE.clean(tableIdent);
- }
- }
-
- @Override
- /* Reconciliation by connect new FlowCapableNode */
- protected void add(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject addDataObj) {
-
- final InstanceIdentifier<FlowCapableNode> flowNodeIdent =
- identifier.firstIdentifierOf(FlowCapableNode.class);
- final Optional<FlowCapableNode> flowCapNode = this.readFlowCapableNode(flowNodeIdent);
-
- if (flowCapNode.isPresent()) {
- final InstanceIdentifier<Node> nodeIdent = identifier.firstIdentifierOf(Node.class);
- final NodeRef nodeRef = new NodeRef(nodeIdent);
- /* Groups - have to be first */
- List<Group> groups = flowCapNode.get().getGroup();
- if(groups != null) {
- for (Group group : groups) {
- final GroupRef groupRef = new GroupRef(flowNodeIdent.child(Group.class, group.getKey()));
- final AddGroupInputBuilder groupBuilder = new AddGroupInputBuilder(group);
- groupBuilder.setGroupRef(groupRef);
- groupBuilder.setNode(nodeRef);
- this.provider.getSalGroupService().addGroup(groupBuilder.build());
- }
- }
- /* Meters */
- List<Meter> meters = flowCapNode.get().getMeter();
- if(meters != null) {
- for (Meter meter : meters) {
- final MeterRef meterRef = new MeterRef(flowNodeIdent.child(Meter.class, meter.getKey()));
- final AddMeterInputBuilder meterBuilder = new AddMeterInputBuilder(meter);
- meterBuilder.setMeterRef(meterRef);
- meterBuilder.setNode(nodeRef);
- this.provider.getSalMeterService().addMeter(meterBuilder.build());
- }
- }
- /* Flows */
- List<Table> tables = flowCapNode.get().getTable();
- if(tables != null) {
- for (Table flowTable : tables) {
- final InstanceIdentifier<Table> tableIdent = flowNodeIdent.child(Table.class, flowTable.getKey());
- List<Flow> flows = flowTable.getFlow();
- if(flows != null) {
- for (Flow flow : flows) {
- final FlowCookie flowCookie = new FlowCookie(FlowCookieProducer.INSTANCE.getNewCookie(tableIdent));
- final FlowRef flowRef = new FlowRef(tableIdent.child(Flow.class, flow.getKey()));
- final FlowTableRef flowTableRef = new FlowTableRef(tableIdent);
- final AddFlowInputBuilder flowBuilder = new AddFlowInputBuilder(flow);
- flowBuilder.setCookie(flowCookie);
- flowBuilder.setNode(nodeRef);
- flowBuilder.setFlowTable(flowTableRef);
- flowBuilder.setFlowRef(flowRef);
- this.provider.getSalFlowService().addFlow(flowBuilder.build());
- }
- }
- }
- }
- }
- }
-
- @Override
- protected void update(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject original, final DataObject update) {
- // NOOP - Listener is registered for DataChangeScope.BASE only
- }
-
- @Override
- protected boolean preconditionForChange(final InstanceIdentifier<? extends DataObject> identifier,
- final DataObject dataObj, final DataObject update) {
- return (dataObj instanceof FlowCapableNode);
- }
-
- private Optional<FlowCapableNode> readFlowCapableNode(final InstanceIdentifier<FlowCapableNode> flowNodeIdent) {
- ReadOnlyTransaction readTrans = this.provider.getDataService().newReadOnlyTransaction();
- try {
- ListenableFuture<Optional<FlowCapableNode>> confFlowNode =
- readTrans.read(LogicalDatastoreType.CONFIGURATION, flowNodeIdent);
- if (confFlowNode.get().isPresent()) {
- return Optional.<FlowCapableNode> of(confFlowNode.get().get());
- } else {
- return Optional.absent();
- }
- }
- catch (InterruptedException | ExecutionException e) {
- LOG.error("Unexpected exception by reading flow ".concat(flowNodeIdent.toString()), e);
- return Optional.absent();
- }
- finally {
- readTrans.close();
- }
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2014 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.frm.reconil;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * forwardingrules-manager
- * org.opendaylight.controller.frm
- *
- * FlowNode Reconciliation Provider registers the FlowNodeReconilListener
- * and it holds all needed services for FlowNodeReconcilListener.
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Jun 13, 2014
- */
-public class FlowNodeReconcilProvider implements AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(FlowNodeReconcilProvider.class);
-
- private SalFlowService salFlowService;
- private SalMeterService salMeterService;
- private SalGroupService salGroupService;
- private DataBroker dataService;
-
- /* DataChangeListener */
- private DataChangeListener flowNodeReconcilListener;
- private ListenerRegistration<DataChangeListener> flowNodeReconcilListenerRegistration;
-
- public void init (final DataBroker dataService) {
- LOG.info("FRM Flow Node Config Reconcil Provider initialization.");
-
- this.dataService = Preconditions.checkNotNull(dataService, "DataProviderService can not be null !");
- }
-
- public void start( final RpcConsumerRegistry rpcRegistry ) {
- Preconditions.checkArgument(rpcRegistry != null, "RpcConcumerRegistry can not be null !");
-
- this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
- "RPC SalFlowService not found.");
- this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
- "RPC SalMeterService not found.");
- this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
- "RPC SalGroupService not found.");
-
- /* Build Path */
- InstanceIdentifier<FlowCapableNode> flowCapableNodeIdent =
- InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-
- /* ReconcilNotificationListener registration */
- this.flowNodeReconcilListener = new FlowNodeReconcilListener(FlowNodeReconcilProvider.this);
- this.flowNodeReconcilListenerRegistration = this.dataService.registerDataChangeListener(
- LogicalDatastoreType.OPERATIONAL, flowCapableNodeIdent, flowNodeReconcilListener, DataChangeScope.BASE);
- LOG.info("FRM Flow Node Config Reconcil Provider started.");
- }
-
- @Override
- public void close() {
- LOG.info("FRM Flow Node Config Reconcil Provider stopped.");
- if (flowNodeReconcilListenerRegistration != null) {
- try {
- flowNodeReconcilListenerRegistration.close();
- } catch (Exception e) {
- String errMsg = "Error by stop FRM Flow Node Config Reconcil Provider.";
- LOG.error(errMsg, e);
- throw new IllegalStateException(errMsg, e);
- } finally {
- flowNodeReconcilListenerRegistration = null;
- }
- }
- }
-
- public DataChangeListener getFlowNodeReconcilListener() {
- return flowNodeReconcilListener;
- }
-
- public DataBroker getDataService() {
- return dataService;
- }
-
- public SalFlowService getSalFlowService() {
- return salFlowService;
- }
-
- public SalMeterService getSalMeterService() {
- return salMeterService;
- }
-
- public SalGroupService getSalGroupService() {
- return salGroupService;
- }
-}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 test.mock;
+
+import org.junit.Test;
+import org.opendaylight.controller.frm.impl.ForwardingRulesManagerImpl;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.FRMTest;
+import test.mock.util.RpcProviderRegistryMock;
+import test.mock.util.SalFlowServiceMock;
+
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class FlowListenerTest extends FRMTest {
+ RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
+ NodeKey s1Key = new NodeKey(new NodeId("S1"));
+ TableKey tableKey = new TableKey((short) 2);
+
+ @Test
+ public void addTwoFlowsTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
+ InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
+ Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
+ assertEquals(1, addFlowCalls.size());
+ assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
+
+ flowKey = new FlowKey(new FlowId("test_Flow2"));
+ flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ addFlowCalls = salFlowService.getAddFlowCalls();
+ assertEquals(2, addFlowCalls.size());
+ assertEquals("DOM-1", addFlowCalls.get(1).getTransactionUri().getValue());
+ assertEquals(2, addFlowCalls.get(1).getTableId().intValue());
+ assertEquals(flowII, addFlowCalls.get(1).getFlowRef().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void updateFlowTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
+ InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
+ Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
+ assertEquals(1, addFlowCalls.size());
+ assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
+
+ flowKey = new FlowKey(new FlowId("test_Flow"));
+ flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).setOutGroup((long) 5).build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<UpdateFlowInput> updateFlowCalls = salFlowService.getUpdateFlowCalls();
+ assertEquals(1, updateFlowCalls.size());
+ assertEquals("DOM-1", updateFlowCalls.get(0).getTransactionUri().getValue());
+ assertEquals(flowII, updateFlowCalls.get(0).getFlowRef().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void updateFlowScopeTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
+ InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
+ IpMatch ipMatch = new IpMatchBuilder().setIpDscp(new Dscp((short)4)).build();
+ Match match = new MatchBuilder().setIpMatch(ipMatch).build();
+ Flow flow = new FlowBuilder().setMatch(match).setKey(flowKey).setTableId((short) 2).build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
+ assertEquals(1, addFlowCalls.size());
+ assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
+
+ flowKey = new FlowKey(new FlowId("test_Flow"));
+ flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ ipMatch = new IpMatchBuilder().setIpDscp(new Dscp((short)5)).build();
+ match = new MatchBuilder().setIpMatch(ipMatch).build();
+ flow = new FlowBuilder().setMatch(match).setKey(flowKey).setTableId((short) 2).build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<UpdateFlowInput> updateFlowCalls = salFlowService.getUpdateFlowCalls();
+ assertEquals(1, updateFlowCalls.size());
+ assertEquals("DOM-1", updateFlowCalls.get(0).getTransactionUri().getValue());
+ assertEquals(flowII, updateFlowCalls.get(0).getFlowRef().getValue());
+ assertEquals(ipMatch, updateFlowCalls.get(0).getUpdatedFlow().getMatch().getIpMatch());
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void deleteFlowTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
+ InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
+ Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+ assertCommit(writeTx.submit());
+ SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
+ assertEquals(1, addFlowCalls.size());
+ assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
+
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, flowII);
+ assertCommit(writeTx.submit());
+ salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
+ List<RemoveFlowInput> removeFlowCalls = salFlowService.getRemoveFlowCalls();
+ assertEquals(1, removeFlowCalls.size());
+ assertEquals("DOM-1", removeFlowCalls.get(0).getTransactionUri().getValue());
+ assertEquals(flowII, removeFlowCalls.get(0).getFlowRef().getValue());
+
+ forwardingRulesManager.close();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 test.mock;
+
+import org.junit.Test;
+import org.opendaylight.controller.frm.impl.ForwardingRulesManagerImpl;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.FRMTest;
+import test.mock.util.RpcProviderRegistryMock;
+import test.mock.util.SalGroupServiceMock;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class GroupListenerTest extends FRMTest {
+ RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
+ NodeKey s1Key = new NodeKey(new NodeId("S1"));
+
+ @Test
+ public void addTwoGroupsTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ GroupKey groupKey = new GroupKey(new GroupId((long) 255));
+ InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+ Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+ assertCommit(writeTx.submit());
+ SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
+ List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
+ assertEquals(1, addGroupCalls.size());
+ assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
+
+ groupKey = new GroupKey(new GroupId((long) 256));
+ groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+ group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+ assertCommit(writeTx.submit());
+ salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
+ addGroupCalls = salGroupService.getAddGroupCalls();
+ assertEquals(2, addGroupCalls.size());
+ assertEquals("DOM-1", addGroupCalls.get(1).getTransactionUri().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void updateGroupTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ GroupKey groupKey = new GroupKey(new GroupId((long) 255));
+ InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+ Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+ assertCommit(writeTx.submit());
+ SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
+ List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
+ assertEquals(1, addGroupCalls.size());
+ assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
+
+ group = new GroupBuilder().setKey(groupKey).setGroupName("Group2").build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+ assertCommit(writeTx.submit());
+ salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
+ List<UpdateGroupInput> updateGroupCalls = salGroupService.getUpdateGroupCalls();
+ assertEquals(1, updateGroupCalls.size());
+ assertEquals("DOM-1", updateGroupCalls.get(0).getTransactionUri().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void removeGroupTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ GroupKey groupKey = new GroupKey(new GroupId((long) 255));
+ InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+ Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+ assertCommit(writeTx.submit());
+ SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
+ List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
+ assertEquals(1, addGroupCalls.size());
+ assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
+
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, groupII);
+ assertCommit(writeTx.submit());
+ salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
+ List<RemoveGroupInput> removeGroupCalls = salGroupService.getRemoveGroupCalls();
+ assertEquals(1, removeGroupCalls.size());
+ assertEquals("DOM-1", removeGroupCalls.get(0).getTransactionUri().getValue());
+
+ forwardingRulesManager.close();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 test.mock;
+
+import org.junit.Test;
+import org.opendaylight.controller.frm.impl.ForwardingRulesManagerImpl;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.FRMTest;
+import test.mock.util.RpcProviderRegistryMock;
+import test.mock.util.SalMeterServiceMock;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class MeterListenerTest extends FRMTest {
+ RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
+ NodeKey s1Key = new NodeKey(new NodeId("S1"));
+
+ @Test
+ public void addTwoMetersTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
+ InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+ Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+ assertCommit(writeTx.submit());
+ SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
+ List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
+ assertEquals(1, addMeterCalls.size());
+ assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
+
+ meterKey = new MeterKey(new MeterId((long) 2001));
+ meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+ meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+ assertCommit(writeTx.submit());
+ salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
+ addMeterCalls = salMeterService.getAddMeterCalls();
+ assertEquals(2, addMeterCalls.size());
+ assertEquals("DOM-1", addMeterCalls.get(1).getTransactionUri().getValue());
+ assertEquals(meterII, addMeterCalls.get(1).getMeterRef().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void updateMeterTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
+ InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+ Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").setBarrier(false).build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+ assertCommit(writeTx.submit());
+ SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
+ List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
+ assertEquals(1, addMeterCalls.size());
+ assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
+
+ meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+ assertCommit(writeTx.submit());
+ salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
+ List<UpdateMeterInput> updateMeterCalls = salMeterService.getUpdateMeterCalls();
+ assertEquals(1, updateMeterCalls.size());
+ assertEquals("DOM-1", updateMeterCalls.get(0).getTransactionUri().getValue());
+ assertEquals(meterII, updateMeterCalls.get(0).getMeterRef().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+ @Test
+ public void removeMeterTest() throws Exception {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
+ InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+ Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").build();
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+ assertCommit(writeTx.submit());
+ SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
+ List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
+ assertEquals(1, addMeterCalls.size());
+ assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
+
+ writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, meterII);
+ assertCommit(writeTx.submit());
+ salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
+ List<RemoveMeterInput> removeMeterCalls = salMeterService.getRemoveMeterCalls();
+ assertEquals(1, removeMeterCalls.size());
+ assertEquals("DOM-1", removeMeterCalls.get(0).getTransactionUri().getValue());
+ assertEquals(meterII, removeMeterCalls.get(0).getMeterRef().getValue());
+
+ forwardingRulesManager.close();
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 test.mock;
+
+import org.junit.Test;
+import org.opendaylight.controller.frm.impl.ForwardingRulesManagerImpl;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.FRMTest;
+import test.mock.util.RpcProviderRegistryMock;
+
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class NodeListenerTest extends FRMTest {
+
+ RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
+ NodeKey s1Key = new NodeKey(new NodeId("S1"));
+
+ @Test
+ public void addRemoveNodeTest() throws ExecutionException, InterruptedException {
+ ForwardingRulesManagerImpl forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock);
+ forwardingRulesManager.start();
+
+ addFlowCapableNode(s1Key);
+
+ InstanceIdentifier<FlowCapableNode> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+ .augmentation(FlowCapableNode.class);
+
+ boolean nodeActive = forwardingRulesManager.isNodeActive(nodeII);
+ assertTrue(nodeActive);
+
+ removeNode(s1Key);
+
+ nodeActive = forwardingRulesManager.isNodeActive(nodeII);
+ assertFalse(nodeActive);
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 test.mock.util;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
+
+ private DataBrokerTestCustomizer testCustomizer;
+ private DataBroker dataBroker;
+ private DOMDataBroker domBroker;
+
+
+ @Override
+ protected void setupWithSchema(final SchemaContext context) {
+ testCustomizer = createDataBrokerTestCustomizer();
+ dataBroker = testCustomizer.createDataBroker();
+ domBroker = testCustomizer.createDOMDataBroker();
+ testCustomizer.updateSchema(context);
+ setupWithDataBroker(dataBroker);
+ }
+
+ protected void setupWithDataBroker(final DataBroker dataBroker) {
+ // Intentionally left No-op, subclasses may customize it
+ }
+
+ protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ return new DataBrokerTestCustomizer();
+ }
+
+ public DataBroker getDataBroker() {
+ return dataBroker;
+ }
+
+ public DOMDataBroker getDomBroker() {
+ return domBroker;
+ }
+
+ protected static final void assertCommit(final ListenableFuture<Void> commit) {
+ try {
+ commit.get(500, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 test.mock.util;
+
+import org.junit.Before;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public abstract class AbstractSchemaAwareTest {
+
+ private Iterable<YangModuleInfo> moduleInfos;
+ private SchemaContext schemaContext;
+
+
+ protected Iterable<YangModuleInfo> getModuleInfos() {
+ return BindingReflections.loadModuleInfos();
+ }
+
+
+ @Before
+ public final void setup() {
+ moduleInfos = getModuleInfos();
+ ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
+ moduleContext.addModuleInfos(moduleInfos);
+ schemaContext = moduleContext.tryToCreateSchemaContext().get();
+ setupWithSchema(schemaContext);
+ }
+
+ /**
+ * Setups test with Schema context.
+ * This method is called before {@link #setupWithSchemaService(SchemaService)}
+ *
+ * @param context
+ */
+ protected abstract void setupWithSchema(SchemaContext context);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 test.mock.util;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import javassist.ClassPool;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
+import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class DataBrokerTestCustomizer {
+
+ private DOMDataBroker domDataBroker;
+ private final RuntimeGeneratedMappingServiceImpl mappingService;
+ private final MockSchemaService schemaService;
+ private ImmutableMap<LogicalDatastoreType, DOMStore> datastores;
+ private final BindingToNormalizedNodeCodec bindingToNormalized ;
+
+ public ImmutableMap<LogicalDatastoreType, DOMStore> createDatastores() {
+ return ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
+ .put(LogicalDatastoreType.OPERATIONAL, createOperationalDatastore())
+ .put(LogicalDatastoreType.CONFIGURATION,createConfigurationDatastore())
+ .build();
+ }
+
+ public DataBrokerTestCustomizer() {
+ schemaService = new MockSchemaService();
+ ClassPool pool = ClassPool.getDefault();
+ mappingService = new RuntimeGeneratedMappingServiceImpl(pool);
+ DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(pool));
+ BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
+ GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
+ bindingToNormalized = new BindingToNormalizedNodeCodec(loading, mappingService, codecRegistry);
+ schemaService.registerSchemaContextListener(bindingToNormalized);
+ }
+
+ public DOMStore createConfigurationDatastore() {
+ InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG",
+ MoreExecutors.sameThreadExecutor(), MoreExecutors.sameThreadExecutor());
+ schemaService.registerSchemaContextListener(store);
+ return store;
+ }
+
+ public DOMStore createOperationalDatastore() {
+ InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER",
+ MoreExecutors.sameThreadExecutor(), MoreExecutors.sameThreadExecutor());
+ schemaService.registerSchemaContextListener(store);
+ return store;
+ }
+
+ public DOMDataBroker createDOMDataBroker() {
+ return new DOMDataBrokerImpl(getDatastores(), getCommitCoordinatorExecutor());
+ }
+
+ public ListeningExecutorService getCommitCoordinatorExecutor() {
+ return MoreExecutors.sameThreadExecutor();
+ }
+
+ public DataBroker createDataBroker() {
+ return new ForwardedBindingDataBroker(getDOMDataBroker(), bindingToNormalized, schemaService );
+ }
+
+ public ForwardedBackwardsCompatibleDataBroker createBackwardsCompatibleDataBroker() {
+ return new ForwardedBackwardsCompatibleDataBroker(getDOMDataBroker(), bindingToNormalized, getSchemaService(), MoreExecutors.sameThreadExecutor());
+ }
+
+ private SchemaService getSchemaService() {
+ return schemaService;
+ }
+
+ private DOMDataBroker getDOMDataBroker() {
+ if(domDataBroker == null) {
+ domDataBroker = createDOMDataBroker();
+ }
+ return domDataBroker;
+ }
+
+ private synchronized ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() {
+ if (datastores == null) {
+ datastores = createDatastores();
+ }
+ return datastores;
+ }
+
+ public void updateSchema(final SchemaContext ctx) {
+ schemaService.changeSchema(ctx);
+ mappingService.onGlobalContextUpdated(ctx);
+ }
+
+}
--- /dev/null
+package test.mock.util;
+
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import java.util.Collections;
+import java.util.concurrent.ExecutionException;
+
+public abstract class FRMTest extends AbstractDataBrokerTest{
+
+ public void addFlowCapableNode(NodeKey nodeKey) throws ExecutionException, InterruptedException {
+ Nodes nodes = new NodesBuilder().setNode(Collections.<Node>emptyList()).build();
+ InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class)
+ .child(Node.class, nodeKey);
+
+ FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
+ NodeBuilder nodeBuilder = new NodeBuilder();
+ nodeBuilder.setKey(nodeKey);
+ nodeBuilder.addAugmentation(FlowCapableNode.class, fcnBuilder.build());
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build());
+ assertCommit(writeTx.submit());
+ }
+
+ public void removeNode(NodeKey nodeKey) throws ExecutionException, InterruptedException {
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey));
+ writeTx.submit().get();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 test.mock.util;
+
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.ListenerRegistry;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+
+@SuppressWarnings("deprecation")
+public final class MockSchemaService implements SchemaService, SchemaContextProvider {
+
+ private SchemaContext schemaContext;
+
+ ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
+
+ @Override
+ public void addModule(final Module module) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public synchronized SchemaContext getGlobalContext() {
+ return schemaContext;
+ }
+
+ @Override
+ public synchronized SchemaContext getSessionContext() {
+ return schemaContext;
+ }
+
+ @Override
+ public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
+ final SchemaContextListener listener) {
+ return listeners.register(listener);
+ }
+
+ @Override
+ public void removeModule(final Module module) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public synchronized SchemaContext getSchemaContext() {
+ return schemaContext;
+ }
+
+ public synchronized void changeSchema(final SchemaContext newContext) {
+ schemaContext = newContext;
+ for (ListenerRegistration<SchemaContextListener> listener : listeners) {
+ listener.getInstance().onGlobalContextUpdated(schemaContext);
+ }
+ }
+}
--- /dev/null
+package test.mock.util;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class RpcProviderRegistryMock implements RpcProviderRegistry {
+ @Override
+ public <T extends RpcService> BindingAwareBroker.RpcRegistration<T> addRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public <T extends RpcService> BindingAwareBroker.RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
+ return null;
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
+ if (serviceInterface.equals(SalFlowService.class)) {
+ return (T) new SalFlowServiceMock();
+ } else if (serviceInterface.equals(SalGroupService.class)) {
+ return (T) new SalGroupServiceMock();
+ } else if (serviceInterface.equals(SalMeterService.class)) {
+ return (T) new SalMeterServiceMock();
+ } else {
+ return null;
+ }
+ }
+}
--- /dev/null
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+
+public class SalFlowServiceMock implements SalFlowService{
+ private List<AddFlowInput> addFlowCalls = new ArrayList<>();
+ private List<RemoveFlowInput> removeFlowCalls = new ArrayList<>();
+ private List<UpdateFlowInput> updateFlowCalls = new ArrayList<>();
+
+ @Override
+ public Future<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
+ addFlowCalls.add(input);
+ return null;
+ }
+
+
+ @Override
+ public Future<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
+ removeFlowCalls.add(input);
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
+ updateFlowCalls.add(input);
+ return null;
+ }
+
+ public List<AddFlowInput> getAddFlowCalls() {
+ return addFlowCalls;
+ }
+
+ public List<RemoveFlowInput> getRemoveFlowCalls() {
+ return removeFlowCalls;
+ }
+
+ public List<UpdateFlowInput> getUpdateFlowCalls() {
+ return updateFlowCalls;
+ }
+}
--- /dev/null
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+
+public class SalGroupServiceMock implements SalGroupService {
+ private List<AddGroupInput> addGroupCalls = new ArrayList<>();
+ private List<RemoveGroupInput> removeGroupCalls = new ArrayList<>();
+ private List<UpdateGroupInput> updateGroupCalls = new ArrayList<>();
+
+ @Override
+ public Future<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
+ addGroupCalls.add(input);
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<RemoveGroupOutput>> removeGroup(RemoveGroupInput input) {
+ removeGroupCalls.add(input);
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<UpdateGroupOutput>> updateGroup(UpdateGroupInput input) {
+ updateGroupCalls.add(input);
+ return null;
+ }
+
+ public List<AddGroupInput> getAddGroupCalls() {
+ return addGroupCalls;
+ }
+
+ public List<RemoveGroupInput> getRemoveGroupCalls() {
+ return removeGroupCalls;
+ }
+
+ public List<UpdateGroupInput> getUpdateGroupCalls() {
+ return updateGroupCalls;
+ }
+}
--- /dev/null
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+
+public class SalMeterServiceMock implements SalMeterService {
+ private List<AddMeterInput> addMeterCalls = new ArrayList<>();
+ private List<RemoveMeterInput> removeMeterCalls = new ArrayList<>();
+ private List<UpdateMeterInput> updateMeterCalls = new ArrayList<>();
+
+ @Override
+ public Future<RpcResult<AddMeterOutput>> addMeter(AddMeterInput input) {
+ addMeterCalls.add(input);
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<RemoveMeterOutput>> removeMeter(RemoveMeterInput input) {
+ removeMeterCalls.add(input);
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<UpdateMeterOutput>> updateMeter(UpdateMeterInput input) {
+ updateMeterCalls.add(input);
+ return null;
+ }
+
+ public List<AddMeterInput> getAddMeterCalls() {
+ return addMeterCalls;
+ }
+
+ public List<RemoveMeterInput> getRemoveMeterCalls() {
+ return removeMeterCalls;
+ }
+
+ public List<UpdateMeterInput> getUpdateMeterCalls() {
+ return updateMeterCalls;
+ }
+}
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-config-datastore-provider</type>
<name>config-store-service</name>
- <schema-service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
- <name>yang-schema-service</name>
- </schema-service>
+ <inmemory-config-datastore-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">
+ <schema-service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+ <name>yang-schema-service</name>
+ </schema-service>
+ </inmemory-config-datastore-provider>
</module>
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-operational-datastore-provider</type>
<name>operational-store-service</name>
- <operational-schema-service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
- <name>yang-schema-service</name>
- </operational-schema-service>
+ <inmemory-operational-datastore-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">
+ <schema-service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+ <name>yang-schema-service</name>
+ </schema-service>
+ </inmemory-operational-datastore-provider>
</module>
<!--
Tree-based in-memory data store. This is the data store which is currently
uses meter:meter;
}
}
-
-
- grouping flow-node {
+ grouping ip-address-grouping {
+ leaf ip-address {
+ description "IP address of a flow capable node.";
+ type inet:ip-address;
+ }
+ }
+
+ grouping flow-node {
leaf manufacturer {
type string;
}
uses tables;
uses group:groups;
uses meters;
+ uses ip-address-grouping;
// TODO: ports
container supported-match-types {
}
}
-
+
grouping flow-node-connector {
uses port:flow-capable-port;
<!-- XSQL -->
<module>sal-dom-xsql</module>
+ <module>sal-dom-xsql-config</module>
<!-- Yang Test Models for MD-SAL -->
<module>sal-test-model</module>
</goals>
</pluginExecutionFilter>
<action>
- <ignore></ignore>
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
</goals>
</pluginExecutionFilter>
<action>
- <ignore></ignore>
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</modules>
</profile>
</profiles>
-</project>
+</project>
\ No newline at end of file
<dependencies>
<dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>2.5.0</version>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-clustering-commons</artifactId>
+ <version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>scala-library</artifactId>
</dependency>
- <!-- Test Dependencies -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-slf4j_${scala.version}</artifactId>
+ </dependency>
+
+
+ <!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<includes>
- <include>org.opendaylight.controller.*</include>
+ <include>org/opendaylight/controller/cluster/**/*</include>
</includes>
+ <excludes>
+ <exclude>org/opendaylight/controller/cluster/raft/protobuff/**/*</exclude>
+ <exclude>org/opendaylight/controller/cluster/example/**/*</exclude>
+ </excludes>
<check>false</check>
</configuration>
<executions>
package org.opendaylight.controller.cluster.example.messages;
import com.google.protobuf.GeneratedMessage;
-import org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.example.KeyValueMessages;
import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
import java.io.Serializable;
import java.util.HashMap;
} else if (message instanceof FindLeader) {
getSender().tell(
- new FindLeaderReply(
- context.getPeerAddress(currentBehavior.getLeaderId())),
+ new FindLeaderReply(getLeaderAddress()),
getSelf()
);
// TODO: Handle failure in saving the snapshot
- } else if (message instanceof FindLeader){
-
- getSender().tell(new FindLeaderReply(
- context.getPeerAddress(currentBehavior.getLeaderId())),
- getSelf());
-
} else if (message instanceof AddRaftPeer){
// FIXME : Do not add raft peers like this.
* @return A reference to the leader if known, null otherwise
*/
protected ActorSelection getLeader(){
- String leaderId = currentBehavior.getLeaderId();
- if (leaderId == null) {
- return null;
- }
- String peerAddress = context.getPeerAddress(leaderId);
- LOG.debug("getLeader leaderId = " + leaderId + " peerAddress = "
- + peerAddress);
+ String leaderAddress = getLeaderAddress();
- if(peerAddress == null){
- return null;
- }
- return context.actorSelection(peerAddress);
+ return context.actorSelection(leaderAddress);
}
/**
deleteMessages(sequenceNumber);
}
+ private String getLeaderAddress(){
+ if(isLeader()){
+ return getSelf().path().toString();
+ }
+ String leaderId = currentBehavior.getLeaderId();
+ if (leaderId == null) {
+ return null;
+ }
+ String peerAddress = context.getPeerAddress(leaderId);
+ LOG.debug("getLeaderAddress leaderId = " + leaderId + " peerAddress = "
+ + peerAddress);
+
+ return peerAddress;
+ }
+
private class ReplicatedLogImpl extends AbstractReplicatedLogImpl {
package org.opendaylight.controller.cluster.raft.client.messages;
-public class FindLeader {
+import java.io.Serializable;
+
+public class FindLeader implements Serializable{
}
package org.opendaylight.controller.cluster.raft.client.messages;
-public class FindLeaderReply {
+import java.io.Serializable;
+
+public class FindLeaderReply implements Serializable {
private final String leaderActor;
public FindLeaderReply(String leaderActor) {
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
import java.util.ArrayList;
import java.util.Iterator;
import com.google.protobuf.GeneratedMessage;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
import java.util.Map;
+++ /dev/null
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: VotingMessages.proto
-
-package org.opendaylight.controller.cluster.raft.protobuff.messages;
-
-public final class VotingMessages {
- private VotingMessages() {}
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistry registry) {
- }
- public interface RequestVoteOrBuilder
- extends com.google.protobuf.MessageOrBuilder {
-
- // optional int64 term = 1;
- /**
- * <code>optional int64 term = 1;</code>
- */
- boolean hasTerm();
- /**
- * <code>optional int64 term = 1;</code>
- */
- long getTerm();
-
- // optional string candidateId = 2;
- /**
- * <code>optional string candidateId = 2;</code>
- */
- boolean hasCandidateId();
- /**
- * <code>optional string candidateId = 2;</code>
- */
- java.lang.String getCandidateId();
- /**
- * <code>optional string candidateId = 2;</code>
- */
- com.google.protobuf.ByteString
- getCandidateIdBytes();
-
- // optional int64 lastLongIndex = 3;
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- boolean hasLastLongIndex();
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- long getLastLongIndex();
-
- // optional int64 lastLongTerm = 4;
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- boolean hasLastLongTerm();
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- long getLastLongTerm();
- }
- /**
- * Protobuf type {@code org.opendaylight.controller.cluster.raft.RequestVote}
- */
- public static final class RequestVote extends
- com.google.protobuf.GeneratedMessage
- implements RequestVoteOrBuilder {
- // Use RequestVote.newBuilder() to construct.
- private RequestVote(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
- super(builder);
- this.unknownFields = builder.getUnknownFields();
- }
- private RequestVote(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
- private static final RequestVote defaultInstance;
- public static RequestVote getDefaultInstance() {
- return defaultInstance;
- }
-
- public RequestVote getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- private final com.google.protobuf.UnknownFieldSet unknownFields;
- @java.lang.Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
- private RequestVote(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- initFields();
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- case 8: {
- bitField0_ |= 0x00000001;
- term_ = input.readInt64();
- break;
- }
- case 18: {
- bitField0_ |= 0x00000002;
- candidateId_ = input.readBytes();
- break;
- }
- case 24: {
- bitField0_ |= 0x00000004;
- lastLongIndex_ = input.readInt64();
- break;
- }
- case 32: {
- bitField0_ |= 0x00000008;
- lastLongTerm_ = input.readInt64();
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e.getMessage()).setUnfinishedMessage(this);
- } finally {
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.class, org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.Builder.class);
- }
-
- public static com.google.protobuf.Parser<RequestVote> PARSER =
- new com.google.protobuf.AbstractParser<RequestVote>() {
- public RequestVote parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new RequestVote(input, extensionRegistry);
- }
- };
-
- @java.lang.Override
- public com.google.protobuf.Parser<RequestVote> getParserForType() {
- return PARSER;
- }
-
- private int bitField0_;
- // optional int64 term = 1;
- public static final int TERM_FIELD_NUMBER = 1;
- private long term_;
- /**
- * <code>optional int64 term = 1;</code>
- */
- public boolean hasTerm() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int64 term = 1;</code>
- */
- public long getTerm() {
- return term_;
- }
-
- // optional string candidateId = 2;
- public static final int CANDIDATEID_FIELD_NUMBER = 2;
- private java.lang.Object candidateId_;
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public boolean hasCandidateId() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public java.lang.String getCandidateId() {
- java.lang.Object ref = candidateId_;
- if (ref instanceof java.lang.String) {
- return (java.lang.String) ref;
- } else {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- if (bs.isValidUtf8()) {
- candidateId_ = s;
- }
- return s;
- }
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public com.google.protobuf.ByteString
- getCandidateIdBytes() {
- java.lang.Object ref = candidateId_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- candidateId_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- // optional int64 lastLongIndex = 3;
- public static final int LASTLONGINDEX_FIELD_NUMBER = 3;
- private long lastLongIndex_;
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- public boolean hasLastLongIndex() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
- }
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- public long getLastLongIndex() {
- return lastLongIndex_;
- }
-
- // optional int64 lastLongTerm = 4;
- public static final int LASTLONGTERM_FIELD_NUMBER = 4;
- private long lastLongTerm_;
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- public boolean hasLastLongTerm() {
- return ((bitField0_ & 0x00000008) == 0x00000008);
- }
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- public long getLastLongTerm() {
- return lastLongTerm_;
- }
-
- private void initFields() {
- term_ = 0L;
- candidateId_ = "";
- lastLongIndex_ = 0L;
- lastLongTerm_ = 0L;
- }
- private byte memoizedIsInitialized = -1;
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized != -1) return isInitialized == 1;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- output.writeInt64(1, term_);
- }
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- output.writeBytes(2, getCandidateIdBytes());
- }
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
- output.writeInt64(3, lastLongIndex_);
- }
- if (((bitField0_ & 0x00000008) == 0x00000008)) {
- output.writeInt64(4, lastLongTerm_);
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (((bitField0_ & 0x00000001) == 0x00000001)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(1, term_);
- }
- if (((bitField0_ & 0x00000002) == 0x00000002)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(2, getCandidateIdBytes());
- }
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(3, lastLongIndex_);
- }
- if (((bitField0_ & 0x00000008) == 0x00000008)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(4, lastLongTerm_);
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- private static final long serialVersionUID = 0L;
- @java.lang.Override
- protected java.lang.Object writeReplace()
- throws java.io.ObjectStreamException {
- return super.writeReplace();
- }
-
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseDelimitedFrom(input, extensionRegistry);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return PARSER.parseFrom(input);
- }
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return PARSER.parseFrom(input, extensionRegistry);
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code org.opendaylight.controller.cluster.raft.RequestVote}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder>
- implements org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVoteOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.class, org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.Builder.class);
- }
-
- // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessage.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
- }
- }
- private static Builder create() {
- return new Builder();
- }
-
- public Builder clear() {
- super.clear();
- term_ = 0L;
- bitField0_ = (bitField0_ & ~0x00000001);
- candidateId_ = "";
- bitField0_ = (bitField0_ & ~0x00000002);
- lastLongIndex_ = 0L;
- bitField0_ = (bitField0_ & ~0x00000004);
- lastLongTerm_ = 0L;
- bitField0_ = (bitField0_ & ~0x00000008);
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(buildPartial());
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor;
- }
-
- public org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote getDefaultInstanceForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.getDefaultInstance();
- }
-
- public org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote build() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- public org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote buildPartial() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote result = new org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote(this);
- int from_bitField0_ = bitField0_;
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
- to_bitField0_ |= 0x00000001;
- }
- result.term_ = term_;
- if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
- to_bitField0_ |= 0x00000002;
- }
- result.candidateId_ = candidateId_;
- if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
- to_bitField0_ |= 0x00000004;
- }
- result.lastLongIndex_ = lastLongIndex_;
- if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
- to_bitField0_ |= 0x00000008;
- }
- result.lastLongTerm_ = lastLongTerm_;
- result.bitField0_ = to_bitField0_;
- onBuilt();
- return result;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote) {
- return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote other) {
- if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote.getDefaultInstance()) return this;
- if (other.hasTerm()) {
- setTerm(other.getTerm());
- }
- if (other.hasCandidateId()) {
- bitField0_ |= 0x00000002;
- candidateId_ = other.candidateId_;
- onChanged();
- }
- if (other.hasLastLongIndex()) {
- setLastLongIndex(other.getLastLongIndex());
- }
- if (other.hasLastLongTerm()) {
- setLastLongTerm(other.getLastLongTerm());
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public final boolean isInitialized() {
- return true;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.VotingMessages.RequestVote) e.getUnfinishedMessage();
- throw e;
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
- private int bitField0_;
-
- // optional int64 term = 1;
- private long term_ ;
- /**
- * <code>optional int64 term = 1;</code>
- */
- public boolean hasTerm() {
- return ((bitField0_ & 0x00000001) == 0x00000001);
- }
- /**
- * <code>optional int64 term = 1;</code>
- */
- public long getTerm() {
- return term_;
- }
- /**
- * <code>optional int64 term = 1;</code>
- */
- public Builder setTerm(long value) {
- bitField0_ |= 0x00000001;
- term_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional int64 term = 1;</code>
- */
- public Builder clearTerm() {
- bitField0_ = (bitField0_ & ~0x00000001);
- term_ = 0L;
- onChanged();
- return this;
- }
-
- // optional string candidateId = 2;
- private java.lang.Object candidateId_ = "";
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public boolean hasCandidateId() {
- return ((bitField0_ & 0x00000002) == 0x00000002);
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public java.lang.String getCandidateId() {
- java.lang.Object ref = candidateId_;
- if (!(ref instanceof java.lang.String)) {
- java.lang.String s = ((com.google.protobuf.ByteString) ref)
- .toStringUtf8();
- candidateId_ = s;
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public com.google.protobuf.ByteString
- getCandidateIdBytes() {
- java.lang.Object ref = candidateId_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- candidateId_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public Builder setCandidateId(
- java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000002;
- candidateId_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public Builder clearCandidateId() {
- bitField0_ = (bitField0_ & ~0x00000002);
- candidateId_ = getDefaultInstance().getCandidateId();
- onChanged();
- return this;
- }
- /**
- * <code>optional string candidateId = 2;</code>
- */
- public Builder setCandidateIdBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000002;
- candidateId_ = value;
- onChanged();
- return this;
- }
-
- // optional int64 lastLongIndex = 3;
- private long lastLongIndex_ ;
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- public boolean hasLastLongIndex() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
- }
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- public long getLastLongIndex() {
- return lastLongIndex_;
- }
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- public Builder setLastLongIndex(long value) {
- bitField0_ |= 0x00000004;
- lastLongIndex_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional int64 lastLongIndex = 3;</code>
- */
- public Builder clearLastLongIndex() {
- bitField0_ = (bitField0_ & ~0x00000004);
- lastLongIndex_ = 0L;
- onChanged();
- return this;
- }
-
- // optional int64 lastLongTerm = 4;
- private long lastLongTerm_ ;
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- public boolean hasLastLongTerm() {
- return ((bitField0_ & 0x00000008) == 0x00000008);
- }
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- public long getLastLongTerm() {
- return lastLongTerm_;
- }
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- public Builder setLastLongTerm(long value) {
- bitField0_ |= 0x00000008;
- lastLongTerm_ = value;
- onChanged();
- return this;
- }
- /**
- * <code>optional int64 lastLongTerm = 4;</code>
- */
- public Builder clearLastLongTerm() {
- bitField0_ = (bitField0_ & ~0x00000008);
- lastLongTerm_ = 0L;
- onChanged();
- return this;
- }
-
- // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.cluster.raft.RequestVote)
- }
-
- static {
- defaultInstance = new RequestVote(true);
- defaultInstance.initFields();
- }
-
- // @@protoc_insertion_point(class_scope:org.opendaylight.controller.cluster.raft.RequestVote)
- }
-
- private static com.google.protobuf.Descriptors.Descriptor
- internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable;
-
- public static com.google.protobuf.Descriptors.FileDescriptor
- getDescriptor() {
- return descriptor;
- }
- private static com.google.protobuf.Descriptors.FileDescriptor
- descriptor;
- static {
- java.lang.String[] descriptorData = {
- "\n\024VotingMessages.proto\022(org.opendaylight" +
- ".controller.cluster.raft\"]\n\013RequestVote\022" +
- "\014\n\004term\030\001 \001(\003\022\023\n\013candidateId\030\002 \001(\t\022\025\n\rla" +
- "stLongIndex\030\003 \001(\003\022\024\n\014lastLongTerm\030\004 \001(\003B" +
- "O\n;org.opendaylight.controller.cluster.r" +
- "aft.protobuff.messagesB\016VotingMessagesH\001"
- };
- com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
- new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
- public com.google.protobuf.ExtensionRegistry assignDescriptors(
- com.google.protobuf.Descriptors.FileDescriptor root) {
- descriptor = root;
- internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor =
- getDescriptor().getMessageTypes().get(0);
- internal_static_org_opendaylight_controller_cluster_raft_RequestVote_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_org_opendaylight_controller_cluster_raft_RequestVote_descriptor,
- new java.lang.String[] { "Term", "CandidateId", "LastLongIndex", "LastLongTerm", });
- return null;
- }
- };
- com.google.protobuf.Descriptors.FileDescriptor
- .internalBuildGeneratedFileFrom(descriptorData,
- new com.google.protobuf.Descriptors.FileDescriptor[] {
- }, assigner);
- }
-
- // @@protoc_insertion_point(outer_class_scope)
-}
+++ /dev/null
-package org.opendaylight.controller.cluster.raft;
-
-option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
-option java_outer_classname = "VotingMessages";
-option optimize_for = SPEED;
-
-message RequestVote {
- optional int64 term = 1;
- optional string candidateId = 2;
- optional int64 lastLongIndex = 3;
- optional int64 lastLongTerm = 4;
-
-}
import akka.actor.ActorSystem;
import akka.testkit.JavaTestKit;
+import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.IOException;
+
public abstract class AbstractActorTest {
private static ActorSystem system;
@BeforeClass
- public static void setUpClass() {
+ public static void setUpClass() throws Exception{
+ deleteJournal();
System.setProperty("shard.persistent", "false");
system = ActorSystem.create("test");
}
@AfterClass
- public static void tearDownClass() {
+ public static void tearDownClass() throws Exception{
+ deleteJournal();
JavaTestKit.shutdownActorSystem(system);
system = null;
}
return system;
}
+ protected static void deleteJournal() throws IOException {
+ File journal = new File("journal");
+
+ if(journal.exists()) {
+ FileUtils.deleteDirectory(journal);
+ }
+ }
+
}
import akka.event.LoggingAdapter;
import com.google.protobuf.GeneratedMessage;
import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.MockPayloadMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.test.MockPayloadMessages;
import com.google.common.base.Preconditions;
import java.io.Serializable;
--- /dev/null
+package org.opendaylight.controller.cluster.raft;
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.actor.Props;
+import akka.event.Logging;
+import akka.japi.Creator;
+import akka.testkit.JavaTestKit;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
+import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class RaftActorTest extends AbstractActorTest {
+
+
+ public static class MockRaftActor extends RaftActor {
+
+ public MockRaftActor(String id,
+ Map<String, String> peerAddresses) {
+ super(id, peerAddresses);
+ }
+
+ public static Props props(final String id, final Map<String, String> peerAddresses){
+ return Props.create(new Creator<MockRaftActor>(){
+
+ @Override public MockRaftActor create() throws Exception {
+ return new MockRaftActor(id, peerAddresses);
+ }
+ });
+ }
+
+ @Override protected void applyState(ActorRef clientActor,
+ String identifier,
+ Object data) {
+ }
+
+ @Override protected Object createSnapshot() {
+ throw new UnsupportedOperationException("createSnapshot");
+ }
+
+ @Override protected void applySnapshot(Object snapshot) {
+ throw new UnsupportedOperationException("applySnapshot");
+ }
+
+ @Override protected void onStateChanged() {
+ }
+
+ @Override public String persistenceId() {
+ return this.getId();
+ }
+
+ }
+
+
+ private static class RaftActorTestKit extends JavaTestKit {
+ private final ActorRef raftActor;
+
+ public RaftActorTestKit(ActorSystem actorSystem, String actorName) {
+ super(actorSystem);
+
+ raftActor = this.getSystem()
+ .actorOf(MockRaftActor.props(actorName,
+ Collections.EMPTY_MAP), actorName);
+
+ }
+
+
+ public boolean waitForStartup(){
+ // Wait for a specific log message to show up
+ return
+ new JavaTestKit.EventFilter<Boolean>(Logging.Info.class
+ ) {
+ protected Boolean run() {
+ return true;
+ }
+ }.from(raftActor.path().toString())
+ .message("Switching from state Candidate to Leader")
+ .occurrences(1).exec();
+
+
+ }
+
+ public void findLeader(final String expectedLeader){
+
+
+ new Within(duration("1 seconds")) {
+ protected void run() {
+
+ raftActor.tell(new FindLeader(), getRef());
+
+ String s = new ExpectMsg<String>(duration("1 seconds"),
+ "findLeader") {
+ // do not put code outside this method, will run afterwards
+ protected String match(Object in) {
+ if (in instanceof FindLeaderReply) {
+ return ((FindLeaderReply) in).getLeaderActor();
+ } else {
+ throw noMatch();
+ }
+ }
+ }.get();// this extracts the received message
+
+ assertEquals(expectedLeader, s);
+
+ }
+
+
+ };
+ }
+
+ public ActorRef getRaftActor() {
+ return raftActor;
+ }
+
+ }
+
+
+ @Test
+ public void testConstruction() {
+ boolean started = new RaftActorTestKit(getSystem(), "testConstruction").waitForStartup();
+ assertEquals(true, started);
+ }
+
+ @Test
+ public void testFindLeaderWhenLeaderIsSelf(){
+ RaftActorTestKit kit = new RaftActorTestKit(getSystem(), "testFindLeader");
+ kit.waitForStartup();
+ kit.findLeader(kit.getRaftActor().path().toString());
+ }
+
+
+}
akka {
-
loglevel = "DEBUG"
+ loggers = ["akka.testkit.TestEventListener", "akka.event.slf4j.Slf4jLogger"]
actor {
# enable to test serialization only.
}
serialization-bindings {
+ "org.opendaylight.controller.cluster.raft.client.messages.FindLeader" = java
"org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry" = java
"com.google.protobuf.Message" = proto
"com.google.protobuf.GeneratedMessage" = proto
+/*
+ * Copyright (c) 2014 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.md.sal.binding.api;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+/**
+ * A chain of transactions.
+ * <p>
+ * For more information about transaction chaining and transaction chains
+ * see {@link TransactionChain}.
+ *
+ * @see TransactionChain
+ *
+ */
public interface BindingTransactionChain extends TransactionFactory, TransactionChain<InstanceIdentifier<?>, DataObject> {
-
+ /**
+ * {@inheritDoc}
+ */
@Override
ReadOnlyTransaction newReadOnlyTransaction();
+ /**
+ * {@inheritDoc}
+ */
@Override
ReadWriteTransaction newReadWriteTransaction();
+ /**
+ * {@inheritDoc}
+ */
@Override
WriteTransaction newWriteOnlyTransaction();
-
}
* subscribe for changes to data under a given branch of the tree.
* <p>
* For more information on usage, please see the documentation in {@link AsyncDataBroker}.
+ *
+ * @see AsyncDataBroker
+ * @see TransactionChainFactory
*/
public interface DataBroker extends TransactionFactory, AsyncDataBroker<InstanceIdentifier<?>, DataObject, DataChangeListener>, BindingService, TransactionChainFactory<InstanceIdentifier<?>, DataObject> {
-
+ /**
+ * {@inheritDoc}
+ */
@Override
ReadOnlyTransaction newReadOnlyTransaction();
+ /**
+ * {@inheritDoc}
+ */
@Override
ReadWriteTransaction newReadWriteTransaction();
+ /**
+ * {@inheritDoc}
+ */
@Override
WriteTransaction newWriteOnlyTransaction();
+ /**
+ * {@inheritDoc}
+ */
@Override
ListenerRegistration<DataChangeListener> registerDataChangeListener(LogicalDatastoreType store,
InstanceIdentifier<?> path, DataChangeListener listener, DataChangeScope triggeringScope);
+ /**
+ * {@inheritDoc}
+ */
@Override
BindingTransactionChain createTransactionChain(TransactionChainListener listener);
}
import com.google.common.base.Objects;
import com.google.common.base.Optional;
-import java.util.ArrayList;
+
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
final Map<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized) {
Map<InstanceIdentifier<?>, DataObject> newMap = new HashMap<>();
- for (Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : sortedEntries(normalized)) {
+ for (Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized.entrySet()) {
try {
Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential = getCodec().toBinding(entry);
if (potential.isPresent()) {
return newMap;
}
- private static final Comparator<Entry<YangInstanceIdentifier, ?>> MAP_ENTRY_COMPARATOR = new Comparator<Entry<YangInstanceIdentifier, ?>>() {
- @Override
- public int compare(final Entry<YangInstanceIdentifier, ?> left, final Entry<YangInstanceIdentifier, ?> right) {
- final Iterator<?> li = left.getKey().getPathArguments().iterator();
- final Iterator<?> ri = right.getKey().getPathArguments().iterator();
-
- // Iterate until left is exhausted...
- while (li.hasNext()) {
- if (!ri.hasNext()) {
- // Left is deeper
- return 1;
- }
-
- li.next();
- ri.next();
- }
-
- // Check if right is exhausted
- return ri.hasNext() ? -1 : 0;
- }
- };
-
- private static <T> Iterable<Entry<YangInstanceIdentifier, T>> sortedEntries(final Map<YangInstanceIdentifier, T> map) {
- if (!map.isEmpty()) {
- ArrayList<Entry<YangInstanceIdentifier, T>> entries = new ArrayList<>(map.entrySet());
- Collections.sort(entries, MAP_ENTRY_COMPARATOR);
- return entries;
- } else {
- return Collections.emptySet();
- }
- }
-
protected Set<InstanceIdentifier<?>> toBinding(final InstanceIdentifier<?> path,
final Set<YangInstanceIdentifier> normalized) {
Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
public void onDataChanged(final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
bindingDataChangeListener.onDataChanged(new TranslatedDataChangeEvent(change, path));
}
+
+ @Override
+ public String toString() {
+ return bindingDataChangeListener.getClass().getName();
+ }
}
private class TranslatedDataChangeEvent implements AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> {
import java.util.Iterator;
import java.util.Map.Entry;
+import javax.annotation.Nonnull;
+
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
}
- public org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier toNormalized(
- final InstanceIdentifier<? extends DataObject> binding) {
+ public YangInstanceIdentifier toNormalized(final InstanceIdentifier<? extends DataObject> binding) {
return codecRegistry.toYangInstanceIdentifier(binding);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- public Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
+ public Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
final InstanceIdentifier<? extends DataObject> bindingPath, final DataObject bindingObject) {
return codecRegistry.toNormalizedNode((InstanceIdentifier) bindingPath, bindingObject);
}
- public Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
- final Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> binding) {
+ public Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
+ final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding) {
return toNormalizedNode(binding.getKey(),binding.getValue());
}
* augmentation.
*
*/
- public Optional<InstanceIdentifier<? extends DataObject>> toBinding(
- final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalized)
+ public Optional<InstanceIdentifier<? extends DataObject>> toBinding(final YangInstanceIdentifier normalized)
throws DeserializationException {
try {
- return Optional.<InstanceIdentifier<? extends DataObject>>of(codecRegistry.fromYangInstanceIdentifier(normalized));
+ return Optional.<InstanceIdentifier<? extends DataObject>>fromNullable(codecRegistry.fromYangInstanceIdentifier(normalized));
} catch (IllegalArgumentException e) {
return Optional.absent();
}
return legacyToNormalized;
}
- @SuppressWarnings("unchecked")
- public Optional<Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject>> toBinding(
- final Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized)
+ public Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> toBinding(
+ final @Nonnull Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized)
throws DeserializationException {
try {
- @SuppressWarnings("rawtypes")
- Entry binding = codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue());
- return Optional.<Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject>>fromNullable(binding);
+ /*
+ * This cast is required, due to generics behaviour in openjdk / oracle javac
+ *
+ * InstanceIdentifier has definition InstanceIdentifier<T extends DataObject>,
+ * this means '?' is always  <? extends DataObject>. Eclipse compiler
+ * is able to determine this relationship and treats
+ * Entry<InstanceIdentifier<?>,DataObject> and Entry<InstanceIdentifier<? extends DataObject,DataObject>
+ * as assignable. However openjdk / oracle javac treats this two types
+ * as incompatible and issues a compile error.
+ *
+ * It is safe to loose generic information and cast it to other generic signature.
+ *
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = (Entry) codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue());
+ return Optional.fromNullable(binding);
} catch (IllegalArgumentException e) {
return Optional.absent();
}
* @param path DOM Path
* @return Node with defaults set on.
*/
- public NormalizedNode<?, ?> getDefaultNodeFor(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path) {
+ public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
Iterator<PathArgument> iterator = path.getPathArguments().iterator();
DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation();
while (iterator.hasNext()) {
}
@Override
- public void close() throws Exception {
+ public void close() {
// NOOP Intentionally
}
}
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
+import com.google.common.base.Function;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.util.ClassLoaderUtils;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
class DomToBindingRpcForwarder implements RpcImplementation, InvocationHandler {
private final Logger LOG = LoggerFactory.getLogger(DomToBindingRpcForwarder.class);
static {
try {
EQUALS_METHOD = Object.class.getMethod("equals", Object.class);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (NoSuchMethodException | SecurityException e) {
+ throw new ExceptionInInitializerError(e);
}
}
}
/**
- * Constructor for Routed RPC Forwareder.
+ * Constructor for Routed RPC Forwarder.
*
* @param service
* @param context
package org.opendaylight.controller.md.sal.binding.impl.test;
+import com.google.common.util.concurrent.MoreExecutors;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
testCustomizer = createDataBrokerTestCustomizer();
domBroker = testCustomizer.createDOMDataBroker();
- dataBroker = testCustomizer.createBackwardsCompatibleDataBroker();
+ dataBroker = createBackwardsCompatibleDataBroker();
testCustomizer.updateSchema(context);
}
+ public ForwardedBackwardsCompatibleDataBroker createBackwardsCompatibleDataBroker() {
+ return new ForwardedBackwardsCompatibleDataBroker(domBroker, testCustomizer.getBindingToNormalized(), testCustomizer.getSchemaService(), MoreExecutors
+ .sameThreadExecutor());
+ }
+
+
+
/**
* The purpose of this test is to exercise the backwards compatible broker
* @see org.opendaylight.controller.md.sal.binding.impl.AbstractReadWriteTransaction#ensureParentsByMerge(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.binding.InstanceIdentifier)
*/
@Test
- public void test() throws InterruptedException, ExecutionException {
+ public void testEnsureParentsByMerge() throws InterruptedException, ExecutionException {
DataModificationTransaction writeTx =
dataBroker.beginTransaction();
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-
import javassist.ClassPool;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class DataBrokerTestCustomizer {
return new ForwardedBindingDataBroker(getDOMDataBroker(), bindingToNormalized, schemaService );
}
- public ForwardedBackwardsCompatibleDataBroker createBackwardsCompatibleDataBroker() {
- return new ForwardedBackwardsCompatibleDataBroker(getDOMDataBroker(), bindingToNormalized, getSchemaService(), MoreExecutors.sameThreadExecutor());
+ public BindingToNormalizedNodeCodec getBindingToNormalized() {
+ return bindingToNormalized;
}
- private SchemaService getSchemaService() {
+ public SchemaService getSchemaService() {
return schemaService;
}
- private BindingIndependentMappingService getMappingService() {
- return mappingService;
- }
-
private DOMDataBroker getDOMDataBroker() {
if(domDataBroker == null) {
domDataBroker = createDOMDataBroker();
return domDataBroker;
}
- private ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() {
- if(datastores == null) {
+ private synchronized ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() {
+ if (datastores == null) {
datastores = createDatastores();
}
return datastores;
mavenBundle(CONTROLLER, "netconf-client").versionAsInProject(), //
mavenBundle(CONTROLLER, "netconf-util").versionAsInProject(), //
mavenBundle(CONTROLLER, "netconf-netty-util").versionAsInProject(), //
+ mavenBundle("org.apache.sshd", "sshd-core").versionAsInProject(), //
mavenBundle("org.openexi", "nagasena").versionAsInProject(), //
mavenBundle("org.openexi", "nagasena-rta").versionAsInProject(), //
mavenBundle(CONTROLLER + ".thirdparty", "ganymed").versionAsInProject(), //
mavenBundle("org.javassist", "javassist").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(), // //
+ mavenBundle(YANGTOOLS, "yang-data-util").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-model-util").versionAsInProject(), // //
<packaging>bundle</packaging>
- <dependencies>
+ <dependencies>
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-actor_${scala.version}</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-cluster_${scala.version}</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-persistence-experimental_${scala.version}</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-remote_${scala.version}</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-testkit_${scala.version}</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-slf4j_${scala.version}</artifactId>
+ </dependency>
+
+
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<artifactId>yang-binding</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-akka-raft</artifactId>
- <version>1.1-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
</dependency>
-
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
- <version>3.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-graphite</artifactId>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>org.opendaylight.controller.*</include>
+ </includes>
+ <excludes>
+ <exclude>org.opendaylight.controller.protobuff.*</exclude>
+ </excludes>
+ <check>false</check>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>post-test</id>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <phase>test</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
package org.opendaylight.controller.cluster.datastore.node;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
import org.opendaylight.controller.cluster.datastore.node.utils.PathUtils;
-import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
}
public NormalizedNodeMessages.Container encode(YangInstanceIdentifier id, NormalizedNode node){
+
+ NormalizedNodeMessages.Container.Builder builder = NormalizedNodeMessages.Container.newBuilder();
String parentPath = "";
if(id != null){
- parentPath = PathUtils.getParentPath(id.toString());
+ parentPath = PathUtils.getParentPath(PathUtils.toString(id));
}
+ builder.setParentPath(parentPath);
+ if(node != null) {
+ builder.setNormalizedNode(NormalizedNodeSerializer.serialize(node));
+ }
- NormalizedNodeToProtocolBufferNode encoder = new NormalizedNodeToProtocolBufferNode();
- encoder.encode(parentPath, node);
-
- return encoder.getContainer();
-
-
+ return builder.build();
}
public NormalizedNode<?,?> decode(YangInstanceIdentifier id, NormalizedNodeMessages.Node node){
- NodeToNormalizedNodeBuilder currentOp = NodeToNormalizedNodeBuilder.from(ctx);
-
- for(YangInstanceIdentifier.PathArgument pathArgument : id.getPathArguments()){
- currentOp = currentOp.getChild(pathArgument);
- }
-
- QName nodeType = null;
-
- if(id.getPath().size() < 1){
- nodeType = null;
- } else {
- final YangInstanceIdentifier.PathArgument pathArgument = id.getPath().get(id.getPath().size() - 1);
- if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){
- nodeType = null;
- } else {
- nodeType = pathArgument.getNodeType();
- }
- }
- if((node != null)&& (!node.getType().isEmpty())){
- return currentOp.normalize(nodeType, node);
- } else{
- return null;
- }
+ if(node.getIntType() < 0 || node.getSerializedSize() == 0){
+ return null;
+ }
+ return NormalizedNodeSerializer.deSerialize(node);
}
@Override
public void visitNode(int level, String parentPath, NormalizedNode normalizedNode) {
- String nodePath = parentPath + "/"+ normalizedNode.getIdentifier().toString();
+ String nodePath = parentPath + "/"+ PathUtils.toString(normalizedNode.getIdentifier());
if(nodePath.toString().equals(path)){
output = normalizedNode;
package org.opendaylight.controller.cluster.datastore.node.utils;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
public class PathUtils {
+
public static String getParentPath(String currentElementPath){
StringBuilder parentPath = new StringBuilder();
}
return parentPath.toString();
}
+
+ /**
+ * Given a YangInstanceIdentifier return a serialized version of the same
+ * as a String
+ *
+ * @param path
+ * @return
+ */
+ public static String toString(YangInstanceIdentifier path){
+ StringBuilder sb = new StringBuilder();
+ Iterator<YangInstanceIdentifier.PathArgument> iterator =
+ path.getPathArguments().iterator();
+
+ while(iterator.hasNext()){
+ sb.append(toString(iterator.next()));
+ if(iterator.hasNext()){
+ sb.append("/");
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Given a YangInstanceIdentifier.PathArgument return a serialized version
+ * of the same as a String
+ *
+ * @param pathArgument
+ * @return
+ */
+ public static String toString(YangInstanceIdentifier.PathArgument pathArgument){
+ if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifier){
+ return toString((YangInstanceIdentifier.NodeIdentifier) pathArgument);
+ } else if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){
+ return toString((YangInstanceIdentifier.AugmentationIdentifier) pathArgument);
+ } else if(pathArgument instanceof YangInstanceIdentifier.NodeWithValue){
+ return toString((YangInstanceIdentifier.NodeWithValue) pathArgument);
+ } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates){
+ return toString((YangInstanceIdentifier.NodeIdentifierWithPredicates) pathArgument);
+ }
+
+ return pathArgument.toString();
+ }
+
+ /**
+ * Given a serialized string version of a YangInstanceIdentifier convert
+ * to a YangInstanceIdentifier
+ *
+ * @param path
+ * @return
+ */
+ public static YangInstanceIdentifier toYangInstanceIdentifier(String path){
+ String[] segments = path.split("/");
+
+ List<YangInstanceIdentifier.PathArgument> pathArguments = new ArrayList<>();
+ for (String segment : segments) {
+ if (!"".equals(segment)) {
+ pathArguments.add(NodeIdentifierFactory.getArgument(segment));
+ }
+ }
+ return YangInstanceIdentifier.create(pathArguments);
+ }
+
+ private static String toString(YangInstanceIdentifier.NodeIdentifier pathArgument){
+ return pathArgument.getNodeType().toString();
+ }
+
+ private static String toString(YangInstanceIdentifier.AugmentationIdentifier pathArgument){
+ Set<QName> childNames = pathArgument.getPossibleChildNames();
+ final StringBuilder sb = new StringBuilder("AugmentationIdentifier{");
+ sb.append("childNames=").append(childNames).append('}');
+ return sb.toString();
+
+ }
+
+ private static String toString(YangInstanceIdentifier.NodeWithValue pathArgument){
+ return pathArgument.getNodeType().toString() + "[" + pathArgument.getValue() + "]";
+ }
+
+ private static String toString(YangInstanceIdentifier.NodeIdentifierWithPredicates pathArgument){
+ return pathArgument.getNodeType().toString() + '[' + pathArgument.getKeyValues() + ']';
+ }
+
}
package org.opendaylight.controller.cluster.datastore.node.utils;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
import org.opendaylight.yangtools.yang.common.QName;
-import java.util.HashMap;
-import java.util.Map;
-
public class QNameFactory {
- private static final Map<String, QName> cache = new HashMap<>();
- public static QName create(String name){
- QName value = cache.get(name);
- if(value == null){
- synchronized (cache){
- value = cache.get(name);
- if(value == null) {
- value = QName.create(name);
- cache.put(name, value);
+ private static final int MAX_QNAME_CACHE_SIZE = 10000;
+
+ private static LoadingCache<String, QName> cache = CacheBuilder.newBuilder()
+ .maximumSize(MAX_QNAME_CACHE_SIZE)
+ .softValues()
+ .build(
+ new CacheLoader<String, QName>() {
+ public QName load(String key) {
+ return QName.create(key);
}
}
- }
- return value;
+ );
+
+
+ public static QName create(String name){
+ return cache.getUnchecked(name);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+/**
+ * NormalizedNodeDeSerializationContext provides methods which help in decoding
+ * certain components of a NormalizedNode properly
+ */
+
+public interface NormalizedNodeDeSerializationContext {
+ String getNamespace(int namespace);
+ String getRevision(int revision);
+ String getLocalName(int localName);
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import java.net.URI;
+import java.util.Date;
+
+/**
+ * NormalizedNodeSerializationContext provides methods which help in encoding
+ * certain components of a NormalizedNode properly
+ */
+public interface NormalizedNodeSerializationContext {
+ int addNamespace(URI namespace);
+ int addRevision(Date revision);
+ int addLocalName(String localName);
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.ANY_XML_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.AUGMENTATION_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.CHOICE_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.CONTAINER_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.LEAF_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.LEAF_SET_ENTRY_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.LEAF_SET_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.MAP_ENTRY_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.MAP_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.ORDERED_LEAF_SET_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.ORDERED_MAP_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.UNKEYED_LIST_ENTRY_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.UNKEYED_LIST_NODE_TYPE;
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.getSerializableNodeType;
+
+/**
+ * NormalizedNodeSerializer can be used to convert a Normalized node to and and
+ * from a protocol buffer message.
+ *
+ *
+ */
+public class NormalizedNodeSerializer {
+
+ /**
+ * Serialize a NormalizedNode into a protocol buffer message
+ * <p>
+ * The significant things to be aware of the Serialization process are
+ * <ul>
+ * <li>Repeated strings like namespaces, revisions and localNames are
+ * compressed to codes and stored in the top level of the normalized
+ * node protocol buffer message
+ * </li>
+ * <li>All value types are encoded for each leaf value. This is so that
+ * the deSerialization process does not need to use the schema context to
+ * figure out how to decode values
+ * </li>
+ * </ul>
+ *
+ * One question which may arise is why not use something like gzip to
+ * compress the protocol buffer message instead of rolling our own
+ * encoding scheme. This has to be explored further as it is a more
+ * general solution.
+ *
+ * @param node
+ * @return
+ */
+ public static NormalizedNodeMessages.Node serialize(NormalizedNode node){
+ Preconditions.checkNotNull(node, "node should not be null");
+ return new Serializer(node).serialize();
+ }
+
+
+ /**
+ * DeSerialize a protocol buffer message back into a NormalizedNode
+ *
+ * @param node
+ * @return
+ */
+ public static NormalizedNode deSerialize(NormalizedNodeMessages.Node node){
+ return new DeSerializer(node).deSerialize();
+ }
+
+ /**
+ * DeSerialize a PathArgument which is in the protocol buffer format into
+ * a yang PathArgument. The protocol buffer path argument is specially
+ * encoded and can only be interpreted in the context of a top level
+ * serialized NormalizedNode protocol buffer message. The reason for this
+ * is that during the NormalizedNode serialization process certain repeated
+ * strings are encoded into a "codes" list and the actual strings are
+ * replaced by an integer which is an index into that list.
+ *
+ * @param node
+ * @param pathArgument
+ * @return
+ */
+ public static YangInstanceIdentifier.PathArgument deSerialize(NormalizedNodeMessages.Node node, NormalizedNodeMessages.PathArgument pathArgument){
+ Preconditions.checkNotNull(node, "node should not be null");
+ Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
+ return new DeSerializer(node).deSerialize(pathArgument);
+ }
+
+ private static class Serializer implements NormalizedNodeSerializationContext {
+
+ private final NormalizedNode node;
+
+ private final Map<Object, Integer> codeMap = new HashMap<>();
+ private final List<String> codes = new ArrayList<>();
+
+ private Serializer(NormalizedNode node) {
+ this.node = node;
+ }
+
+ private NormalizedNodeMessages.Node serialize() {
+ return this.serialize(node).addAllCode(codes).build();
+ }
+
+ private NormalizedNodeMessages.Node.Builder serialize(
+ NormalizedNode node) {
+ NormalizedNodeMessages.Node.Builder builder =
+ NormalizedNodeMessages.Node.newBuilder();
+
+ builder.setPathArgument(PathArgumentSerializer.serialize(this, node.getIdentifier()));
+ Integer nodeType = getSerializableNodeType(node).ordinal();
+ builder.setIntType(nodeType);
+ Object value = node.getValue();
+
+ // We need to do a specific check of the type of the node here
+ // because if we looked at the value type alone we will not be
+ // able to distinguish if the value was supposed to be added
+ // as a child or whether the value should be added as a value of the
+ // node.
+ // One use case where this check is necessary when you have a node
+ // with a bits value. In that case the value of the node is a Set
+ // which is also a Collection. Without the following check being
+ // done first the code would flow into the Collection if condition
+ // and the Set would be added as child nodes
+ if(nodeType == NormalizedNodeType.LEAF_NODE_TYPE.ordinal() ||
+ nodeType == NormalizedNodeType.LEAF_SET_ENTRY_NODE_TYPE.ordinal()){
+
+ ValueSerializer.serialize(builder, this, value);
+
+ } else if (value instanceof Iterable) {
+ Iterable iterable = (Iterable) value;
+
+ for (Object o : iterable) {
+ if (o instanceof NormalizedNode) {
+ builder.addChild(serialize((NormalizedNode) o));
+ }
+ }
+
+ } else if (value instanceof NormalizedNode) {
+
+ builder.addChild(serialize((NormalizedNode) value));
+
+ } else {
+
+ ValueSerializer.serialize(builder, this, value);
+ }
+
+ return builder;
+ }
+
+
+ @Override public int addNamespace(URI namespace) {
+ int namespaceInt = getCode(namespace);
+
+ if(namespaceInt == -1) {
+ namespaceInt = addCode(namespace, namespace.toString());
+ }
+ return namespaceInt;
+ }
+
+ @Override public int addRevision(Date revision) {
+ if(revision == null){
+ return -1;
+ }
+
+ int revisionInt = getCode(revision);
+ if(revisionInt == -1) {
+ String formattedRevision =
+ SimpleDateFormatUtil.getRevisionFormat().format(revision);
+ revisionInt = addCode(revision, formattedRevision);
+ }
+ return revisionInt;
+ }
+
+ @Override public int addLocalName(String localName) {
+ int localNameInt = getCode(localName);
+ if(localNameInt == -1) {
+ localNameInt = addCode(localName, localName.toString());
+ }
+ return localNameInt;
+
+ }
+
+ public int addCode(Object code, String codeStr){
+ int count = codes.size();
+ codes.add(codeStr);
+ codeMap.put(code, Integer.valueOf(count));
+ return count;
+ }
+
+ public int getCode(Object code){
+ if(codeMap.containsKey(code)){
+ return codeMap.get(code);
+ }
+ return -1;
+ }
+ }
+
+ private static class DeSerializer implements NormalizedNodeDeSerializationContext {
+ private static Map<NormalizedNodeType, DeSerializationFunction>
+ deSerializationFunctions = new HashMap<>();
+
+ static {
+ deSerializationFunctions.put(CONTAINER_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode>
+ builder = Builders.containerBuilder();
+
+ builder
+ .withNodeIdentifier(deSerializer.toNodeIdentifier(
+ node.getPathArgument()));
+
+ return deSerializer.buildDataContainer(builder, node);
+
+ }
+
+ });
+
+ deSerializationFunctions.put(LEAF_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
+ builder = Builders.leafBuilder();
+
+ builder
+ .withNodeIdentifier(deSerializer.toNodeIdentifier(
+ node.getPathArgument()));
+
+ return deSerializer.buildNormalizedNode(builder, node);
+
+ }
+ });
+
+ deSerializationFunctions.put(MAP_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ CollectionNodeBuilder<MapEntryNode, MapNode>
+ builder = Builders.mapBuilder();
+
+ return deSerializer.buildCollectionNode(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(MAP_ENTRY_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+ builder = Builders.mapEntryBuilder();
+
+ builder.withNodeIdentifier(deSerializer.toNodeIdentifierWithPredicates(
+ node.getPathArgument()));
+
+ return deSerializer.buildDataContainer(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(AUGMENTATION_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ DataContainerNodeBuilder<YangInstanceIdentifier.AugmentationIdentifier, AugmentationNode>
+ builder = Builders.augmentationBuilder();
+
+ builder.withNodeIdentifier(
+ deSerializer.toAugmentationIdentifier(
+ node.getPathArgument()));
+
+ return deSerializer.buildDataContainer(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(LEAF_SET_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ ListNodeBuilder<Object, LeafSetEntryNode<Object>>
+ builder = Builders.leafSetBuilder();
+
+ return deSerializer.buildListNode(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(LEAF_SET_ENTRY_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeWithValue, Object, LeafSetEntryNode<Object>>
+ builder = Builders.leafSetEntryBuilder();
+
+ builder.withNodeIdentifier(deSerializer.toNodeWithValue(
+ node.getPathArgument()));
+
+ return deSerializer.buildNormalizedNode(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(CHOICE_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode>
+ builder =
+ Builders.choiceBuilder();
+
+ builder
+ .withNodeIdentifier(deSerializer.toNodeIdentifier(
+ node.getPathArgument()));
+
+ return deSerializer.buildDataContainer(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(ORDERED_LEAF_SET_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ ListNodeBuilder<Object, LeafSetEntryNode<Object>>
+ builder =
+ Builders.orderedLeafSetBuilder();
+
+ return deSerializer.buildListNode(builder, node);
+
+
+ }
+ });
+
+ deSerializationFunctions.put(ORDERED_MAP_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ CollectionNodeBuilder<MapEntryNode, OrderedMapNode>
+ builder =
+ Builders.orderedMapBuilder();
+
+ return deSerializer.buildCollectionNode(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(UNKEYED_LIST_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode>
+ builder =
+ Builders.unkeyedListBuilder();
+
+ return deSerializer.buildCollectionNode(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(UNKEYED_LIST_ENTRY_NODE_TYPE,
+ new DeSerializationFunction() {
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode>
+ builder =
+ Builders.unkeyedListEntryBuilder();
+
+ builder
+ .withNodeIdentifier(deSerializer.toNodeIdentifier(
+ node.getPathArgument()));
+
+ return deSerializer.buildDataContainer(builder, node);
+ }
+ });
+
+ deSerializationFunctions.put(ANY_XML_NODE_TYPE,
+ new DeSerializationFunction() {
+
+ @Override public NormalizedNode apply(
+ DeSerializer deSerializer,
+ NormalizedNodeMessages.Node node) {
+ NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode>
+ builder =
+ Builders.anyXmlBuilder();
+
+ builder
+ .withNodeIdentifier(deSerializer.toNodeIdentifier(
+ node.getPathArgument()));
+
+ return deSerializer.buildNormalizedNode(builder, node);
+ }
+ });
+
+ }
+
+ private final NormalizedNodeMessages.Node node;
+
+ public DeSerializer(NormalizedNodeMessages.Node node){
+ this.node = node;
+ }
+
+ public NormalizedNode deSerialize(){
+ return deSerialize(node);
+ }
+
+ private NormalizedNode deSerialize(NormalizedNodeMessages.Node node){
+ Preconditions.checkNotNull(node, "node should not be null");
+ DeSerializationFunction deSerializationFunction =
+ Preconditions.checkNotNull(deSerializationFunctions.get(NormalizedNodeType.values()[node.getIntType()]), "Unknown type " + node);
+
+ return deSerializationFunction.apply(this, node);
+ }
+
+
+ private NormalizedNode buildCollectionNode(
+ CollectionNodeBuilder builder,
+ NormalizedNodeMessages.Node node) {
+
+ builder.withNodeIdentifier(toNodeIdentifier(node.getPathArgument()));
+
+ for(NormalizedNodeMessages.Node child : node.getChildList()){
+ builder.withChild(deSerialize(child));
+ }
+
+ return builder.build();
+ }
+
+
+ private NormalizedNode buildListNode(
+ ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder,
+ NormalizedNodeMessages.Node node) {
+ builder.withNodeIdentifier(toNodeIdentifier(node.getPathArgument()));
+
+ for(NormalizedNodeMessages.Node child : node.getChildList()){
+ builder.withChild((LeafSetEntryNode<Object>) deSerialize(child));
+ }
+
+ return builder.build();
+ }
+
+ private NormalizedNode buildDataContainer(DataContainerNodeBuilder builder, NormalizedNodeMessages.Node node){
+
+ for(NormalizedNodeMessages.Node child : node.getChildList()){
+ builder.withChild((DataContainerChild<?, ?>) deSerialize(child));
+ }
+
+ //TODO : Also handle attributes
+
+ return builder.build();
+ }
+
+ private NormalizedNode buildNormalizedNode(NormalizedNodeAttrBuilder builder, NormalizedNodeMessages.Node node){
+
+ builder.withValue(ValueSerializer.deSerialize(this, node));
+
+ //TODO : Also handle attributes
+
+ return builder.build();
+
+ }
+
+
+ private YangInstanceIdentifier.NodeIdentifierWithPredicates toNodeIdentifierWithPredicates(
+ NormalizedNodeMessages.PathArgument path) {
+ return (YangInstanceIdentifier.NodeIdentifierWithPredicates) PathArgumentSerializer.deSerialize(this, path);
+ }
+
+ private YangInstanceIdentifier.AugmentationIdentifier toAugmentationIdentifier(
+ NormalizedNodeMessages.PathArgument path) {
+ return (YangInstanceIdentifier.AugmentationIdentifier) PathArgumentSerializer.deSerialize(this, path);
+ }
+
+ private YangInstanceIdentifier.NodeWithValue toNodeWithValue(
+ NormalizedNodeMessages.PathArgument path) {
+ return (YangInstanceIdentifier.NodeWithValue) PathArgumentSerializer.deSerialize(
+ this, path);
+ }
+
+ private YangInstanceIdentifier.NodeIdentifier toNodeIdentifier(NormalizedNodeMessages.PathArgument path){
+ return (YangInstanceIdentifier.NodeIdentifier) PathArgumentSerializer.deSerialize(
+ this, path);
+ }
+
+ @Override public String getNamespace(int namespace) {
+ return node.getCode(namespace);
+ }
+
+ @Override public String getRevision(int revision) {
+ return node.getCode(revision);
+ }
+
+ @Override public String getLocalName(int localName) {
+ return node.getCode(localName);
+ }
+
+ public YangInstanceIdentifier.PathArgument deSerialize(
+ NormalizedNodeMessages.PathArgument pathArgument) {
+ return PathArgumentSerializer.deSerialize(this, pathArgument);
+ }
+
+ private static interface DeSerializationFunction {
+ NormalizedNode apply(DeSerializer deserializer, NormalizedNodeMessages.Node node);
+ }
+ }
+
+
+
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+
+public enum NormalizedNodeType {
+ CONTAINER_NODE_TYPE,
+ LEAF_NODE_TYPE,
+ MAP_NODE_TYPE,
+ MAP_ENTRY_NODE_TYPE,
+ AUGMENTATION_NODE_TYPE,
+ LEAF_SET_NODE_TYPE,
+ LEAF_SET_ENTRY_NODE_TYPE,
+ CHOICE_NODE_TYPE,
+ ORDERED_LEAF_SET_NODE_TYPE,
+ ORDERED_MAP_NODE_TYPE,
+ UNKEYED_LIST_NODE_TYPE,
+ UNKEYED_LIST_ENTRY_NODE_TYPE,
+ ANY_XML_NODE_TYPE;
+
+ public static NormalizedNodeType getSerializableNodeType(NormalizedNode node){
+ Preconditions.checkNotNull(node, "node should not be null");
+
+ if(node instanceof ContainerNode){
+ return CONTAINER_NODE_TYPE;
+ } else if(node instanceof LeafNode){
+ return LEAF_NODE_TYPE;
+ } else if(node instanceof MapNode){
+ return MAP_NODE_TYPE;
+ } else if(node instanceof MapEntryNode){
+ return MAP_ENTRY_NODE_TYPE;
+ } else if(node instanceof AugmentationNode){
+ return AUGMENTATION_NODE_TYPE;
+ } else if(node instanceof LeafSetNode){
+ return LEAF_SET_NODE_TYPE;
+ } else if(node instanceof LeafSetEntryNode){
+ return LEAF_SET_ENTRY_NODE_TYPE;
+ } else if(node instanceof ChoiceNode){
+ return CHOICE_NODE_TYPE;
+ } else if(node instanceof OrderedLeafSetNode){
+ return ORDERED_LEAF_SET_NODE_TYPE;
+ } else if(node instanceof OrderedMapNode){
+ return ORDERED_MAP_NODE_TYPE;
+ } else if(node instanceof UnkeyedListNode){
+ return UNKEYED_LIST_NODE_TYPE;
+ } else if(node instanceof UnkeyedListEntryNode){
+ return UNKEYED_LIST_ENTRY_NODE_TYPE;
+ } else if(node instanceof AnyXmlNode){
+ return ANY_XML_NODE_TYPE;
+ }
+ throw new IllegalArgumentException("Node type unknown : " + node.getClass().getSimpleName());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
+import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.PathArgumentType.getSerializablePathArgumentType;
+
+public class PathArgumentSerializer {
+ private static final Map<Class, PathArgumentAttributesGetter> pathArgumentAttributesGetters = new HashMap<>();
+
+ public static NormalizedNodeMessages.PathArgument serialize(NormalizedNodeSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument){
+ Preconditions.checkNotNull(context, "context should not be null");
+ Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
+
+ QName nodeType = null;
+ if (!(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier)) {
+ nodeType = pathArgument.getNodeType();
+ }
+
+ NormalizedNodeMessages.PathArgument.Builder builder =
+ NormalizedNodeMessages.PathArgument.newBuilder();
+
+ NormalizedNodeMessages.PathArgument serializablePathArgument =
+ builder
+ .setIntType(getSerializablePathArgumentType(pathArgument))
+ .setNodeType(encodeQName(context, nodeType))
+ .addAllAttribute(getPathArgumentAttributes(context, pathArgument))
+ .build();
+
+ return serializablePathArgument;
+ }
+
+
+ public static YangInstanceIdentifier.PathArgument deSerialize(NormalizedNodeDeSerializationContext context, NormalizedNodeMessages.PathArgument pathArgument){
+ Preconditions.checkNotNull(context, "context should not be null");
+ Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
+
+ return parsePathArgument(context, pathArgument);
+ }
+
+
+ private static interface PathArgumentAttributesGetter {
+ Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(NormalizedNodeSerializationContext context,
+ YangInstanceIdentifier.PathArgument pathArgument);
+ }
+
+ static {
+ pathArgumentAttributesGetters.put(YangInstanceIdentifier.NodeWithValue.class, new PathArgumentAttributesGetter() {
+ @Override
+ public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
+ NormalizedNodeSerializationContext context,
+ YangInstanceIdentifier.PathArgument pathArgument) {
+ List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
+ new ArrayList<>();
+
+ YangInstanceIdentifier.NodeWithValue identifier
+ = (YangInstanceIdentifier.NodeWithValue) pathArgument;
+
+ NormalizedNodeMessages.PathArgumentAttribute attribute =
+ buildAttribute(context, null, identifier.getValue());
+
+ attributes.add(attribute);
+
+ return attributes;
+
+ }
+ });
+
+ pathArgumentAttributesGetters.put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, new PathArgumentAttributesGetter() {
+ @Override
+ public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
+ NormalizedNodeSerializationContext context,
+ YangInstanceIdentifier.PathArgument pathArgument) {
+
+ List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
+ new ArrayList<>();
+
+ YangInstanceIdentifier.NodeIdentifierWithPredicates identifier
+ = (YangInstanceIdentifier.NodeIdentifierWithPredicates) pathArgument;
+
+ for (QName key : identifier.getKeyValues().keySet()) {
+ Object value = identifier.getKeyValues().get(key);
+ NormalizedNodeMessages.PathArgumentAttribute attribute =
+ buildAttribute(context, key, value);
+
+ attributes.add(attribute);
+
+ }
+
+ return attributes;
+
+ }
+ });
+
+ pathArgumentAttributesGetters.put(YangInstanceIdentifier.AugmentationIdentifier.class, new PathArgumentAttributesGetter() {
+ @Override
+ public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
+ NormalizedNodeSerializationContext context,
+ YangInstanceIdentifier.PathArgument pathArgument) {
+
+ List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
+ new ArrayList<>();
+
+ YangInstanceIdentifier.AugmentationIdentifier identifier
+ = (YangInstanceIdentifier.AugmentationIdentifier) pathArgument;
+
+ for (QName key : identifier.getPossibleChildNames()) {
+ Object value = key;
+ NormalizedNodeMessages.PathArgumentAttribute attribute =
+ buildAttribute(context, key, value);
+
+ attributes.add(attribute);
+
+ }
+
+ return attributes;
+
+ }
+ });
+
+
+ pathArgumentAttributesGetters.put(YangInstanceIdentifier.NodeIdentifier.class, new PathArgumentAttributesGetter() {
+ @Override
+ public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
+ NormalizedNodeSerializationContext context,
+ YangInstanceIdentifier.PathArgument pathArgument) {
+ return Collections.emptyList();
+ }
+ });
+ }
+
+ private static NormalizedNodeMessages.PathArgumentAttribute buildAttribute(NormalizedNodeSerializationContext context,QName name, Object value){
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder =
+ NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ builder.setName(encodeQName(context, name));
+ ValueSerializer.serialize(builder, context, value);
+
+ return builder.build();
+
+ }
+
+ private static NormalizedNodeMessages.QName.Builder encodeQName(NormalizedNodeSerializationContext context, QName qName){
+ if(qName == null){
+ return NormalizedNodeMessages.QName.getDefaultInstance().toBuilder();
+ }
+ NormalizedNodeMessages.QName.Builder qNameBuilder =
+ NormalizedNodeMessages.QName.newBuilder();
+
+ qNameBuilder.setNamespace(context.addNamespace(qName.getNamespace()));
+
+ qNameBuilder.setRevision(context.addRevision(qName.getRevision()));
+
+ qNameBuilder.setLocalName(context.addLocalName(qName.getLocalName()));
+
+ return qNameBuilder;
+ }
+
+ private static Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> getPathArgumentAttributes(
+ NormalizedNodeSerializationContext context,
+ YangInstanceIdentifier.PathArgument pathArgument) {
+
+ return pathArgumentAttributesGetters.get(pathArgument.getClass()).get(context, pathArgument);
+
+ }
+
+
+ private static String qNameToString(NormalizedNodeDeSerializationContext context,
+ NormalizedNodeMessages.QName qName){
+ // If this serializer is used qName cannot be null (see encodeQName)
+ // adding null check only in case someone tried to deSerialize a protocol buffer node
+ // that was not serialized using the PathArgumentSerializer
+ Preconditions.checkNotNull(qName, "qName should not be null");
+ Preconditions.checkArgument(!"".equals(qName.getLocalName()),
+ "qName.localName cannot be empty qName = " + qName.toString());
+ Preconditions.checkArgument(qName.getNamespace() != -1, "qName.namespace should be valid");
+
+ StringBuilder sb = new StringBuilder();
+ String namespace = context.getNamespace(qName.getNamespace());
+ String revision = "";
+ String localName = context.getLocalName(qName.getLocalName());
+ if(qName.getRevision() != -1){
+ revision = context.getRevision(qName.getRevision());
+ sb.append("(").append(namespace).append("?revision=").append(
+ revision).append(")").append(
+ localName);
+ } else {
+ sb.append("(").append(namespace).append(")").append(
+ localName);
+ }
+
+ return sb.toString();
+
+ }
+
+ /**
+ * Parse a protocol buffer PathArgument and return an MD-SAL PathArgument
+ *
+ * @param pathArgument protocol buffer PathArgument
+ * @return MD-SAL PathArgument
+ */
+ private static YangInstanceIdentifier.PathArgument parsePathArgument(
+ NormalizedNodeDeSerializationContext context,
+ NormalizedNodeMessages.PathArgument pathArgument) {
+
+ Preconditions.checkArgument(pathArgument.getIntType() >= 0
+ && pathArgument.getIntType() < PathArgumentType.values().length,
+ "Illegal PathArgumentType " + pathArgument.getIntType());
+
+ switch(PathArgumentType.values()[pathArgument.getIntType()]){
+ case NODE_IDENTIFIER_WITH_VALUE : {
+
+ YangInstanceIdentifier.NodeWithValue nodeWithValue =
+ new YangInstanceIdentifier.NodeWithValue(
+ QNameFactory.create(qNameToString(context, pathArgument.getNodeType())),
+ parseAttribute(context, pathArgument.getAttribute(0)));
+
+ return nodeWithValue;
+ }
+
+ case NODE_IDENTIFIER_WITH_PREDICATES : {
+
+ YangInstanceIdentifier.NodeIdentifierWithPredicates
+ nodeIdentifierWithPredicates =
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ QNameFactory.create(qNameToString(context, pathArgument.getNodeType())),
+ toAttributesMap(context, pathArgument.getAttributeList()));
+
+ return nodeIdentifierWithPredicates;
+ }
+
+ case AUGMENTATION_IDENTIFIER: {
+
+ Set<QName> qNameSet = new HashSet<>();
+
+ for(NormalizedNodeMessages.PathArgumentAttribute attribute : pathArgument.getAttributeList()){
+ qNameSet.add(QNameFactory.create(qNameToString(context, attribute.getName())));
+ }
+
+ return new YangInstanceIdentifier.AugmentationIdentifier(qNameSet);
+
+ }
+ default: {
+ return NodeIdentifierFactory.getArgument(qNameToString(context,
+ pathArgument.getNodeType()));
+ }
+
+ }
+ }
+
+ private static Map<QName, Object> toAttributesMap(
+ NormalizedNodeDeSerializationContext context,
+ List<NormalizedNodeMessages.PathArgumentAttribute> attributesList) {
+
+ Map<QName, Object> map = new HashMap<>();
+
+ for(NormalizedNodeMessages.PathArgumentAttribute attribute : attributesList){
+ NormalizedNodeMessages.QName name = attribute.getName();
+ Object value = parseAttribute(context, attribute);
+
+ map.put(QNameFactory.create(qNameToString(context, name)), value);
+ }
+
+ return map;
+ }
+
+ private static Object parseAttribute(NormalizedNodeDeSerializationContext context, NormalizedNodeMessages.PathArgumentAttribute attribute){
+ return ValueSerializer.deSerialize(context, attribute);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public enum PathArgumentType {
+ AUGMENTATION_IDENTIFIER,
+ NODE_IDENTIFIER,
+ NODE_IDENTIFIER_WITH_VALUE,
+ NODE_IDENTIFIER_WITH_PREDICATES;
+
+ public static int getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){
+ Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
+
+ if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){
+ return AUGMENTATION_IDENTIFIER.ordinal();
+ } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifier){
+ return NODE_IDENTIFIER.ordinal();
+ } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates){
+ return NODE_IDENTIFIER_WITH_PREDICATES.ordinal();
+ } else if(pathArgument instanceof YangInstanceIdentifier.NodeWithValue){
+ return NODE_IDENTIFIER_WITH_VALUE.ordinal();
+ }
+ throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument.toString());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ValueSerializer {
+ public static void serialize(NormalizedNodeMessages.Node.Builder builder,
+ NormalizedNodeSerializationContext context, Object value){
+ builder.setIntValueType(ValueType.getSerializableType(value).ordinal());
+
+ if(value instanceof YangInstanceIdentifier) {
+ builder.setInstanceIdentifierValue(
+ InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value));
+ } else if(value instanceof Set) {
+ Set set = (Set) value;
+ if(!set.isEmpty()){
+ for(Object o : set){
+ if(o instanceof String){
+ builder.addBitsValue(o.toString());
+ } else {
+ throw new IllegalArgumentException("Expected value type to be Bits but was : " +
+ value.toString());
+ }
+ }
+ }
+ } else {
+ builder.setValue(value.toString());
+ }
+ }
+
+ public static void serialize(NormalizedNodeMessages.PathArgumentAttribute.Builder builder,
+ NormalizedNodeSerializationContext context, Object value){
+
+ builder.setType(ValueType.getSerializableType(value).ordinal());
+ builder.setValue(value.toString());
+ }
+
+ public static Object deSerialize(
+ NormalizedNodeDeSerializationContext context, NormalizedNodeMessages.Node node) {
+ if(node.getIntValueType() == ValueType.YANG_IDENTIFIER_TYPE.ordinal()){
+ return InstanceIdentifierUtils.fromSerializable(
+ node.getInstanceIdentifierValue());
+ } else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
+ return new HashSet(node.getBitsValueList());
+ }
+ return deSerializeBasicTypes(node.getIntValueType(), node.getValue());
+ }
+
+ public static Object deSerialize(
+ NormalizedNodeDeSerializationContext context,
+ NormalizedNodeMessages.PathArgumentAttribute attribute) {
+ return deSerializeBasicTypes(attribute.getType(), attribute.getValue());
+ }
+
+
+ private static Object deSerializeBasicTypes(int valueType, String value) {
+ Preconditions.checkArgument(valueType >= 0 && valueType < ValueType.values().length,
+ "Illegal value type " + valueType );
+
+ switch(ValueType.values()[valueType]){
+ case SHORT_TYPE: {
+ return Short.valueOf(value);
+ }
+ case BOOL_TYPE: {
+ return Boolean.valueOf(value);
+ }
+ case BYTE_TYPE: {
+ return Byte.valueOf(value);
+ }
+ case INT_TYPE : {
+ return Integer.valueOf(value);
+ }
+ case LONG_TYPE: {
+ return Long.valueOf(value);
+ }
+ case QNAME_TYPE: {
+ return QNameFactory.create(value);
+ }
+ case BIG_INTEGER_TYPE: {
+ return new BigInteger(value);
+ }
+ case BIG_DECIMAL_TYPE: {
+ return new BigDecimal(value);
+ }
+ default: {
+ return value;
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.cluster.datastore.node.utils.serialization;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public enum ValueType {
+ SHORT_TYPE,
+ BYTE_TYPE,
+ INT_TYPE,
+ LONG_TYPE,
+ BOOL_TYPE,
+ QNAME_TYPE,
+ BITS_TYPE,
+ YANG_IDENTIFIER_TYPE,
+ STRING_TYPE,
+ BIG_INTEGER_TYPE,
+ BIG_DECIMAL_TYPE;
+
+ private static Map<Class, ValueType> types = new HashMap<>();
+
+ static {
+ types.put(String.class, STRING_TYPE);
+ types.put(Byte.class, BYTE_TYPE);
+ types.put(Integer.class, INT_TYPE);
+ types.put(Long.class, LONG_TYPE);
+ types.put(Boolean.class, BOOL_TYPE);
+ types.put(QName.class, QNAME_TYPE);
+ types.put(Set.class, BITS_TYPE);
+ types.put(YangInstanceIdentifier.class, YANG_IDENTIFIER_TYPE);
+ types.put(Short.class,SHORT_TYPE);
+ types.put(BigInteger.class, BIG_INTEGER_TYPE);
+ types.put(BigDecimal.class, BIG_DECIMAL_TYPE);
+ }
+
+ public static final ValueType getSerializableType(Object node){
+ Preconditions.checkNotNull(node, "node should not be null");
+
+ if(types.containsKey(node.getClass())) {
+ return types.get(node.getClass());
+ } else if(node instanceof Set){
+ return BITS_TYPE;
+ }
+
+ throw new IllegalArgumentException("Unknown value type " + node.getClass().getSimpleName());
+ }
+}
package org.opendaylight.controller.cluster.datastore.util;
import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
+import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
YangInstanceIdentifier.NodeWithValue nodeWithValue =
new YangInstanceIdentifier.NodeWithValue(
- QName.create(pathArgument.getNodeType().getValue()),
+ QNameFactory.create(pathArgument.getNodeType().getValue()),
parseAttribute(pathArgument.getAttributes(0)));
return nodeWithValue;
YangInstanceIdentifier.NodeIdentifierWithPredicates
nodeIdentifierWithPredicates =
new YangInstanceIdentifier.NodeIdentifierWithPredicates(
- QName.create(pathArgument.getNodeType().getValue()), toAttributesMap(pathArgument.getAttributesList()));
+ QNameFactory.create(pathArgument.getNodeType().getValue()), toAttributesMap(pathArgument.getAttributesList()));
return nodeIdentifierWithPredicates;
Set<QName> qNameSet = new HashSet<>();
for(NormalizedNodeMessages.Attribute attribute : pathArgument.getAttributesList()){
- qNameSet.add(QName.create(attribute.getValue()));
+ qNameSet.add(QNameFactory.create(attribute.getValue()));
}
return new YangInstanceIdentifier.AugmentationIdentifier(qNameSet);
String name = attribute.getName();
Object value = parseAttribute(attribute);
- map.put(QName.create(name), value);
+ map.put(QNameFactory.create(name), value);
}
return map;
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
-import akka.dispatch.BoundedMailbox;
+import akka.dispatch.BoundedDequeBasedMailbox;
import akka.dispatch.MailboxType;
-import akka.dispatch.MessageQueue;
import akka.dispatch.ProducesMessageQueue;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
import java.util.concurrent.TimeUnit;
-public class MeteredBoundedMailbox implements MailboxType, ProducesMessageQueue<BoundedMailbox.MessageQueue> {
+public class MeteredBoundedMailbox implements MailboxType, ProducesMessageQueue<MeteredBoundedMailbox.MeteredMessageQueue> {
private MeteredMessageQueue queue;
private Integer capacity;
private MetricsReporter reporter;
private final String QUEUE_SIZE = "queue-size";
+ private final String CAPACITY = "mailbox-capacity";
+ private final String TIMEOUT = "mailbox-push-timeout-time";
private final Long DEFAULT_TIMEOUT = 10L;
public MeteredBoundedMailbox(ActorSystem.Settings settings, Config config) {
Preconditions.checkArgument( config.hasPath("mailbox-capacity"), "Missing configuration [mailbox-capacity]" );
- this.capacity = config.getInt("mailbox-capacity");
+ this.capacity = config.getInt(CAPACITY);
Preconditions.checkArgument( this.capacity > 0, "mailbox-capacity must be > 0");
Long timeout = -1L;
- if ( config.hasPath("mailbox-push-timeout-time") ){
- timeout = config.getDuration("mailbox-push-timeout-time", TimeUnit.NANOSECONDS);
+ if ( config.hasPath(TIMEOUT) ){
+ timeout = config.getDuration(TIMEOUT, TimeUnit.NANOSECONDS);
} else {
timeout = DEFAULT_TIMEOUT;
}
@Override
- public MessageQueue create(final scala.Option<ActorRef> owner, scala.Option<ActorSystem> system) {
+ public MeteredMessageQueue create(final scala.Option<ActorRef> owner, scala.Option<ActorSystem> system) {
this.queue = new MeteredMessageQueue(this.capacity, this.pushTimeOut);
monitorQueueSize(owner, this.queue);
return this.queue;
return; //there's no actor to monitor
}
actorPath = owner.get().path();
- MetricRegistry registry = reporter.getMetricsRegistry();
+ String actorInstanceId = Integer.toString(owner.get().hashCode());
- String actorName = registry.name(actorPath.toString(), QUEUE_SIZE);
+ MetricRegistry registry = reporter.getMetricsRegistry();
+ String actorName = registry.name(actorPath.toString(), actorInstanceId, QUEUE_SIZE);
if (registry.getMetrics().containsKey(actorName))
return; //already registered
- reporter.getMetricsRegistry().register(actorName,
+ registry.register(actorName,
new Gauge<Integer>() {
@Override
public Integer getValue() {
}
- public static class MeteredMessageQueue extends BoundedMailbox.MessageQueue {
+ public static class MeteredMessageQueue extends BoundedDequeBasedMailbox.MessageQueue {
public MeteredMessageQueue(int capacity, FiniteDuration pushTimeOut) {
super(capacity, pushTimeOut);
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: KeyValueMessages.proto
-package org.opendaylight.controller.cluster.example.protobuff.messages;
+package org.opendaylight.controller.protobuff.messages.cluster.example;
public final class KeyValueMessages {
private KeyValueMessages() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
- registry.add(org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.key);
- registry.add(org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.value);
+ registry.add(org.opendaylight.controller.protobuff.messages.cluster.example.KeyValueMessages.key);
+ registry.add(org.opendaylight.controller.protobuff.messages.cluster.example.KeyValueMessages.value);
}
public static final int KEY_FIELD_NUMBER = 2;
/**
*/
public static final
com.google.protobuf.GeneratedMessage.GeneratedExtension<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
java.lang.String> key = com.google.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
java.lang.String.class,
*/
public static final
com.google.protobuf.GeneratedMessage.GeneratedExtension<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
java.lang.String> value = com.google.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
java.lang.String.class,
"e\022R.org.opendaylight.controller.cluster." +
"raft.AppendEntries.ReplicatedLogEntry.Pa" +
"yload\030\003 \001(\tBT\n>org.opendaylight.controll" +
- "er.cluster.example.protobuff.messagesB\020K" +
+ "er.protobuff.messages.cluster.exampleB\020K" +
"eyValueMessagesH\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(),
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.getDescriptor(),
}, assigner);
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: AppendEntriesMessages.proto
-package org.opendaylight.controller.cluster.raft.protobuff.messages;
+package org.opendaylight.controller.protobuff.messages.cluster.raft;
public final class AppendEntriesMessages {
private AppendEntriesMessages() {}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- java.util.List<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry>
+ java.util.List<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry>
getLogEntriesList();
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index);
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- java.util.List<? extends org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
+ java.util.List<? extends org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
getLogEntriesOrBuilderList();
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder(
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder(
int index);
// optional int64 leaderCommit = 6;
}
case 42: {
if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
- logEntries_ = new java.util.ArrayList<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry>();
+ logEntries_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry>();
mutable_bitField0_ |= 0x00000010;
}
- logEntries_.add(input.readMessage(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PARSER, extensionRegistry));
+ logEntries_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PARSER, extensionRegistry));
break;
}
case 48: {
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.Builder.class);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.class, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.Builder.class);
}
public static com.google.protobuf.Parser<AppendEntries> PARSER =
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData();
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData();
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder();
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder();
}
/**
* Protobuf type {@code org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry}
break;
}
case 26: {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder subBuilder = null;
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder subBuilder = null;
if (((bitField0_ & 0x00000004) == 0x00000004)) {
subBuilder = data_.toBuilder();
}
- data_ = input.readMessage(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.PARSER, extensionRegistry);
+ data_ = input.readMessage(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.PARSER, extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(data_);
data_ = subBuilder.buildPartial();
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder.class);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.class, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder.class);
}
public static com.google.protobuf.Parser<ReplicatedLogEntry> PARSER =
com.google.protobuf.GeneratedMessage.ExtendableMessage<
Payload> implements PayloadOrBuilder {
// Use Payload.newBuilder() to construct.
- private Payload(com.google.protobuf.GeneratedMessage.ExtendableBuilder<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, ?> builder) {
+ private Payload(com.google.protobuf.GeneratedMessage.ExtendableBuilder<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, ?> builder) {
super(builder);
this.unknownFields = builder.getUnknownFields();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder.class);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.class, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder.class);
}
public static com.google.protobuf.Parser<Payload> PARSER =
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
- com.google.protobuf.ByteString bs =
+ com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
getClientPayloadClassNameBytes() {
java.lang.Object ref = clientPayloadClassName_;
if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
clientPayloadClassName_ = b;
throws java.io.IOException {
getSerializedSize();
com.google.protobuf.GeneratedMessage
- .ExtendableMessage<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload>.ExtensionWriter extensionWriter =
+ .ExtendableMessage<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload>.ExtensionWriter extensionWriter =
newExtensionWriter();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeBytes(1, getClientPayloadClassNameBytes());
return super.writeReplace();
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(byte[] data)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(java.io.InputStream input)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseDelimitedFrom(java.io.InputStream input)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseDelimitedFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload prototype) {
+ public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.ExtendableBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, Builder> implements org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, Builder> implements org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder.class);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.class, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder.class);
}
- // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder()
+ // Construct using org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_Payload_descriptor;
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getDefaultInstanceForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getDefaultInstanceForType() {
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload build() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload result = buildPartial();
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload build() {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload buildPartial() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload result = new org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload(this);
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload buildPartial() {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload result = new org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
}
public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload) {
- return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload)other);
+ if (other instanceof org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload) {
+ return mergeFrom((org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload)other);
} else {
super.mergeFrom(other);
return this;
}
}
- public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload other) {
- if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance()) return this;
+ public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload other) {
+ if (other == org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance()) return this;
if (other.hasClientPayloadClassName()) {
bitField0_ |= 0x00000001;
clientPayloadClassName_ = other.clientPayloadClassName_;
public final boolean isInitialized() {
if (!extensionsAreInitialized()) {
-
+
return false;
}
return true;
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parsedMessage = null;
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload) e.getUnfinishedMessage();
+ parsedMessage = (org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
getClientPayloadClassNameBytes() {
java.lang.Object ref = clientPayloadClassName_;
if (ref instanceof String) {
- com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
clientPayloadClassName_ = b;
// optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;
public static final int DATA_FIELD_NUMBER = 3;
- private org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload data_;
+ private org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload data_;
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData() {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData() {
return data_;
}
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder() {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder() {
return data_;
}
private void initFields() {
term_ = 0L;
index_ = 0L;
- data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
+ data_ = org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
return super.writeReplace();
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(byte[] data)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(java.io.InputStream input)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseDelimitedFrom(java.io.InputStream input)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseDelimitedFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry prototype) {
+ public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder>
- implements org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder {
+ implements org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder.class);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.class, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder.class);
}
- // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.newBuilder()
+ // Construct using org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
index_ = 0L;
bitField0_ = (bitField0_ & ~0x00000002);
if (dataBuilder_ == null) {
- data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
+ data_ = org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
} else {
dataBuilder_.clear();
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_ReplicatedLogEntry_descriptor;
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getDefaultInstanceForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance();
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getDefaultInstanceForType() {
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance();
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry build() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry result = buildPartial();
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry build() {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry buildPartial() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry result = new org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry(this);
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry buildPartial() {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry result = new org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
}
public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry) {
- return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry)other);
+ if (other instanceof org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry) {
+ return mergeFrom((org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry)other);
} else {
super.mergeFrom(other);
return this;
}
}
- public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry other) {
- if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance()) return this;
+ public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry other) {
+ if (other == org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance()) return this;
if (other.hasTerm()) {
setTerm(other.getTerm());
}
public final boolean isInitialized() {
if (hasData()) {
if (!getData().isInitialized()) {
-
+
return false;
}
}
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parsedMessage = null;
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry) e.getUnfinishedMessage();
+ parsedMessage = (org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
}
// optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;
- private org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
+ private org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload data_ = org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
private com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder> dataBuilder_;
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder> dataBuilder_;
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData() {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload getData() {
if (dataBuilder_ == null) {
return data_;
} else {
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public Builder setData(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload value) {
+ public Builder setData(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload value) {
if (dataBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
public Builder setData(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder builderForValue) {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder builderForValue) {
if (dataBuilder_ == null) {
data_ = builderForValue.build();
onChanged();
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public Builder mergeData(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload value) {
+ public Builder mergeData(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload value) {
if (dataBuilder_ == null) {
if (((bitField0_ & 0x00000004) == 0x00000004) &&
- data_ != org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance()) {
+ data_ != org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance()) {
data_ =
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder(data_).mergeFrom(value).buildPartial();
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.newBuilder(data_).mergeFrom(value).buildPartial();
} else {
data_ = value;
}
*/
public Builder clearData() {
if (dataBuilder_ == null) {
- data_ = org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
+ data_ = org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.getDefaultInstance();
onChanged();
} else {
dataBuilder_.clear();
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder getDataBuilder() {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder getDataBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getDataFieldBuilder().getBuilder();
/**
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder() {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder getDataOrBuilder() {
if (dataBuilder_ != null) {
return dataBuilder_.getMessageOrBuilder();
} else {
* <code>optional .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload data = 3;</code>
*/
private com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder>
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder>
getDataFieldBuilder() {
if (dataBuilder_ == null) {
dataBuilder_ = new com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder>(
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload.Builder, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.PayloadOrBuilder>(
data_,
getParentForChildren(),
isClean());
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
- com.google.protobuf.ByteString bs =
+ com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
getLeaderIdBytes() {
java.lang.Object ref = leaderId_;
if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
leaderId_ = b;
// repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;
public static final int LOGENTRIES_FIELD_NUMBER = 5;
- private java.util.List<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> logEntries_;
+ private java.util.List<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> logEntries_;
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public java.util.List<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> getLogEntriesList() {
+ public java.util.List<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> getLogEntriesList() {
return logEntries_;
}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public java.util.List<? extends org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
+ public java.util.List<? extends org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
getLogEntriesOrBuilderList() {
return logEntries_;
}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index) {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index) {
return logEntries_.get(index);
}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder(
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder(
int index) {
return logEntries_.get(index);
}
return super.writeReplace();
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(byte[] data)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(java.io.InputStream input)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseDelimitedFrom(java.io.InputStream input)
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseDelimitedFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parseFrom(
+ public static org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries prototype) {
+ public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder>
- implements org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntriesOrBuilder {
+ implements org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntriesOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.class, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.Builder.class);
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.class, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.Builder.class);
}
- // Construct using org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.newBuilder()
+ // Construct using org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor;
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.internal_static_org_opendaylight_controller_cluster_raft_AppendEntries_descriptor;
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries getDefaultInstanceForType() {
- return org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.getDefaultInstance();
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries getDefaultInstanceForType() {
+ return org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.getDefaultInstance();
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries build() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries result = buildPartial();
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries build() {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries buildPartial() {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries result = new org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries(this);
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries buildPartial() {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries result = new org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
}
public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries) {
- return mergeFrom((org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries)other);
+ if (other instanceof org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries) {
+ return mergeFrom((org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries)other);
} else {
super.mergeFrom(other);
return this;
}
}
- public Builder mergeFrom(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries other) {
- if (other == org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.getDefaultInstance()) return this;
+ public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries other) {
+ if (other == org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.getDefaultInstance()) return this;
if (other.hasTerm()) {
setTerm(other.getTerm());
}
logEntriesBuilder_ = null;
logEntries_ = other.logEntries_;
bitField0_ = (bitField0_ & ~0x00000010);
- logEntriesBuilder_ =
+ logEntriesBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getLogEntriesFieldBuilder() : null;
} else {
public final boolean isInitialized() {
for (int i = 0; i < getLogEntriesCount(); i++) {
if (!getLogEntries(i).isInitialized()) {
-
+
return false;
}
}
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries parsedMessage = null;
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries) e.getUnfinishedMessage();
+ parsedMessage = (org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
getLeaderIdBytes() {
java.lang.Object ref = leaderId_;
if (ref instanceof String) {
- com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
leaderId_ = b;
}
// repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;
- private java.util.List<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> logEntries_ =
+ private java.util.List<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> logEntries_ =
java.util.Collections.emptyList();
private void ensureLogEntriesIsMutable() {
if (!((bitField0_ & 0x00000010) == 0x00000010)) {
- logEntries_ = new java.util.ArrayList<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry>(logEntries_);
+ logEntries_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry>(logEntries_);
bitField0_ |= 0x00000010;
}
}
private com.google.protobuf.RepeatedFieldBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder> logEntriesBuilder_;
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder> logEntriesBuilder_;
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public java.util.List<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> getLogEntriesList() {
+ public java.util.List<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> getLogEntriesList() {
if (logEntriesBuilder_ == null) {
return java.util.Collections.unmodifiableList(logEntries_);
} else {
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index) {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry getLogEntries(int index) {
if (logEntriesBuilder_ == null) {
return logEntries_.get(index);
} else {
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
public Builder setLogEntries(
- int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) {
+ int index, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) {
if (logEntriesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
public Builder setLogEntries(
- int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) {
+ int index, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) {
if (logEntriesBuilder_ == null) {
ensureLogEntriesIsMutable();
logEntries_.set(index, builderForValue.build());
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public Builder addLogEntries(org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) {
+ public Builder addLogEntries(org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) {
if (logEntriesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
public Builder addLogEntries(
- int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) {
+ int index, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry value) {
if (logEntriesBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
public Builder addLogEntries(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) {
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) {
if (logEntriesBuilder_ == null) {
ensureLogEntriesIsMutable();
logEntries_.add(builderForValue.build());
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
public Builder addLogEntries(
- int index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) {
+ int index, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder builderForValue) {
if (logEntriesBuilder_ == null) {
ensureLogEntriesIsMutable();
logEntries_.add(index, builderForValue.build());
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
public Builder addAllLogEntries(
- java.lang.Iterable<? extends org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> values) {
+ java.lang.Iterable<? extends org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry> values) {
if (logEntriesBuilder_ == null) {
ensureLogEntriesIsMutable();
super.addAll(values, logEntries_);
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder getLogEntriesBuilder(
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder getLogEntriesBuilder(
int index) {
return getLogEntriesFieldBuilder().getBuilder(index);
}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder(
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder getLogEntriesOrBuilder(
int index) {
if (logEntriesBuilder_ == null) {
return logEntries_.get(index); } else {
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public java.util.List<? extends org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
+ public java.util.List<? extends org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
getLogEntriesOrBuilderList() {
if (logEntriesBuilder_ != null) {
return logEntriesBuilder_.getMessageOrBuilderList();
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder addLogEntriesBuilder() {
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder addLogEntriesBuilder() {
return getLogEntriesFieldBuilder().addBuilder(
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance());
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance());
}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder addLogEntriesBuilder(
+ public org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder addLogEntriesBuilder(
int index) {
return getLogEntriesFieldBuilder().addBuilder(
- index, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance());
+ index, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.getDefaultInstance());
}
/**
* <code>repeated .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry logEntries = 5;</code>
*/
- public java.util.List<org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder>
+ public java.util.List<org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder>
getLogEntriesBuilderList() {
return getLogEntriesFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>
getLogEntriesFieldBuilder() {
if (logEntriesBuilder_ == null) {
logEntriesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>(
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Builder, org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntryOrBuilder>(
logEntries_,
((bitField0_ & 0x00000010) == 0x00000010),
getParentForChildren(),
"aylight.controller.cluster.raft.AppendEn",
"tries.ReplicatedLogEntry.Payload\032/\n\007Payl" +
"oad\022\036\n\026clientPayloadClassName\030\001 \001(\t*\004\010\002\020" +
- "eBV\n;org.opendaylight.controller.cluster" +
- ".raft.protobuff.messagesB\025AppendEntriesM" +
+ "eBV\n;org.opendaylight.controller.protobu" +
+ "ff.messages.cluster.raftB\025AppendEntriesM" +
"essagesH\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: MockPayload.proto
-package org.opendaylight.controller.cluster.raft.protobuff.messages;
+package org.opendaylight.controller.protobuff.messages.cluster.raft.test;
public final class MockPayloadMessages {
private MockPayloadMessages() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
- registry.add(org.opendaylight.controller.cluster.raft.protobuff.messages.MockPayloadMessages.value);
+ registry.add(org.opendaylight.controller.protobuff.messages.cluster.raft.test.MockPayloadMessages.value);
}
public static final int VALUE_FIELD_NUMBER = 2;
/**
*/
public static final
com.google.protobuf.GeneratedMessage.GeneratedExtension<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
java.lang.String> value = com.google.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
java.lang.String.class,
descriptor;
static {
java.lang.String[] descriptorData = {
- "\n\021MockPayload.proto\022(org.opendaylight.co" +
- "ntroller.cluster.raft\032\033AppendEntriesMess" +
- "ages.proto:a\n\005value\022R.org.opendaylight.c" +
- "ontroller.cluster.raft.AppendEntries.Rep" +
- "licatedLogEntry.Payload\030\002 \001(\tBR\n;org.ope" +
- "ndaylight.controller.cluster.raft.protob" +
- "uff.messagesB\023MockPayloadMessages"
+ "\n\021MockPayload.proto\022-org.opendaylight.co" +
+ "ntroller.cluster.raft.test\032\033AppendEntrie" +
+ "sMessages.proto:a\n\005value\022R.org.opendayli" +
+ "ght.controller.cluster.raft.AppendEntrie" +
+ "s.ReplicatedLogEntry.Payload\030\002 \001(\tBW\n@or" +
+ "g.opendaylight.controller.protobuff.mess" +
+ "ages.cluster.raft.testB\023MockPayloadMessa" +
+ "ges"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(),
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.getDescriptor(),
}, assigner);
}
// @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Attribute)
}
+ public interface PathArgumentAttributeOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional .org.opendaylight.controller.mdsal.QName name = 1;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ boolean hasName();
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getName();
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNameOrBuilder();
+
+ // optional string value = 2;
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ boolean hasValue();
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ java.lang.String getValue();
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ com.google.protobuf.ByteString
+ getValueBytes();
+
+ // optional int32 type = 3;
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ boolean hasType();
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ int getType();
+ }
+ /**
+ * Protobuf type {@code org.opendaylight.controller.mdsal.PathArgumentAttribute}
+ */
+ public static final class PathArgumentAttribute extends
+ com.google.protobuf.GeneratedMessage
+ implements PathArgumentAttributeOrBuilder {
+ // Use PathArgumentAttribute.newBuilder() to construct.
+ private PathArgumentAttribute(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ this.unknownFields = builder.getUnknownFields();
+ }
+ private PathArgumentAttribute(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+ private static final PathArgumentAttribute defaultInstance;
+ public static PathArgumentAttribute getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public PathArgumentAttribute getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ private final com.google.protobuf.UnknownFieldSet unknownFields;
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private PathArgumentAttribute(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ initFields();
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder subBuilder = null;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ subBuilder = name_.toBuilder();
+ }
+ name_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.PARSER, extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(name_);
+ name_ = subBuilder.buildPartial();
+ }
+ bitField0_ |= 0x00000001;
+ break;
+ }
+ case 18: {
+ bitField0_ |= 0x00000002;
+ value_ = input.readBytes();
+ break;
+ }
+ case 24: {
+ bitField0_ |= 0x00000004;
+ type_ = input.readInt32();
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder.class);
+ }
+
+ public static com.google.protobuf.Parser<PathArgumentAttribute> PARSER =
+ new com.google.protobuf.AbstractParser<PathArgumentAttribute>() {
+ public PathArgumentAttribute parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new PathArgumentAttribute(input, extensionRegistry);
+ }
+ };
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<PathArgumentAttribute> getParserForType() {
+ return PARSER;
+ }
+
+ private int bitField0_;
+ // optional .org.opendaylight.controller.mdsal.QName name = 1;
+ public static final int NAME_FIELD_NUMBER = 1;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName name_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public boolean hasName() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getName() {
+ return name_;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNameOrBuilder() {
+ return name_;
+ }
+
+ // optional string value = 2;
+ public static final int VALUE_FIELD_NUMBER = 2;
+ private java.lang.Object value_;
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public boolean hasValue() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public java.lang.String getValue() {
+ java.lang.Object ref = value_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (bs.isValidUtf8()) {
+ value_ = s;
+ }
+ return s;
+ }
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public com.google.protobuf.ByteString
+ getValueBytes() {
+ java.lang.Object ref = value_;
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ value_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ // optional int32 type = 3;
+ public static final int TYPE_FIELD_NUMBER = 3;
+ private int type_;
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ public boolean hasType() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ public int getType() {
+ return type_;
+ }
+
+ private void initFields() {
+ name_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ value_ = "";
+ type_ = 0;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeMessage(1, name_);
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, getValueBytes());
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeInt32(3, type_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(1, name_);
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(2, getValueBytes());
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(3, type_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code org.opendaylight.controller.mdsal.PathArgumentAttribute}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.class, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder.class);
+ }
+
+ // Construct using org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ getNameFieldBuilder();
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ if (nameBuilder_ == null) {
+ name_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ } else {
+ nameBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000001);
+ value_ = "";
+ bitField0_ = (bitField0_ & ~0x00000002);
+ type_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_descriptor;
+ }
+
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute getDefaultInstanceForType() {
+ return org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.getDefaultInstance();
+ }
+
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute build() {
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute buildPartial() {
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute result = new org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ if (nameBuilder_ == null) {
+ result.name_ = name_;
+ } else {
+ result.name_ = nameBuilder_.build();
+ }
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.value_ = value_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.type_ = type_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute) {
+ return mergeFrom((org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute other) {
+ if (other == org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.getDefaultInstance()) return this;
+ if (other.hasName()) {
+ mergeName(other.getName());
+ }
+ if (other.hasValue()) {
+ bitField0_ |= 0x00000002;
+ value_ = other.value_;
+ onChanged();
+ }
+ if (other.hasType()) {
+ setType(other.getType());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ // optional .org.opendaylight.controller.mdsal.QName name = 1;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName name_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder> nameBuilder_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public boolean hasName() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getName() {
+ if (nameBuilder_ == null) {
+ return name_;
+ } else {
+ return nameBuilder_.getMessage();
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public Builder setName(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName value) {
+ if (nameBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ name_ = value;
+ onChanged();
+ } else {
+ nameBuilder_.setMessage(value);
+ }
+ bitField0_ |= 0x00000001;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public Builder setName(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder builderForValue) {
+ if (nameBuilder_ == null) {
+ name_ = builderForValue.build();
+ onChanged();
+ } else {
+ nameBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000001;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public Builder mergeName(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName value) {
+ if (nameBuilder_ == null) {
+ if (((bitField0_ & 0x00000001) == 0x00000001) &&
+ name_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance()) {
+ name_ =
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.newBuilder(name_).mergeFrom(value).buildPartial();
+ } else {
+ name_ = value;
+ }
+ onChanged();
+ } else {
+ nameBuilder_.mergeFrom(value);
+ }
+ bitField0_ |= 0x00000001;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public Builder clearName() {
+ if (nameBuilder_ == null) {
+ name_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ onChanged();
+ } else {
+ nameBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000001);
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder getNameBuilder() {
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return getNameFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNameOrBuilder() {
+ if (nameBuilder_ != null) {
+ return nameBuilder_.getMessageOrBuilder();
+ } else {
+ return name_;
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName name = 1;</code>
+ */
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>
+ getNameFieldBuilder() {
+ if (nameBuilder_ == null) {
+ nameBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>(
+ name_,
+ getParentForChildren(),
+ isClean());
+ name_ = null;
+ }
+ return nameBuilder_;
+ }
+
+ // optional string value = 2;
+ private java.lang.Object value_ = "";
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public boolean hasValue() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public java.lang.String getValue() {
+ java.lang.Object ref = value_;
+ if (!(ref instanceof java.lang.String)) {
+ java.lang.String s = ((com.google.protobuf.ByteString) ref)
+ .toStringUtf8();
+ value_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public com.google.protobuf.ByteString
+ getValueBytes() {
+ java.lang.Object ref = value_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ value_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public Builder setValue(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ value_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public Builder clearValue() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ value_ = getDefaultInstance().getValue();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string value = 2;</code>
+ */
+ public Builder setValueBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ value_ = value;
+ onChanged();
+ return this;
+ }
+
+ // optional int32 type = 3;
+ private int type_ ;
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ public boolean hasType() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ public int getType() {
+ return type_;
+ }
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ public Builder setType(int value) {
+ bitField0_ |= 0x00000004;
+ type_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 type = 3;</code>
+ */
+ public Builder clearType() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ type_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PathArgumentAttribute)
+ }
+
+ static {
+ defaultInstance = new PathArgumentAttribute(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.PathArgumentAttribute)
+ }
+
public interface QNameOrBuilder
extends com.google.protobuf.MessageOrBuilder {
- // required string value = 1;
+ // optional string value = 1;
+ /**
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
+ */
+ boolean hasValue();
+ /**
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
+ */
+ java.lang.String getValue();
+ /**
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
+ */
+ com.google.protobuf.ByteString
+ getValueBytes();
+
+ // optional int32 namespace = 2;
/**
- * <code>required string value = 1;</code>
+ * <code>optional int32 namespace = 2;</code>
*/
- boolean hasValue();
+ boolean hasNamespace();
/**
- * <code>required string value = 1;</code>
+ * <code>optional int32 namespace = 2;</code>
*/
- java.lang.String getValue();
+ int getNamespace();
+
+ // optional int32 revision = 3;
/**
- * <code>required string value = 1;</code>
+ * <code>optional int32 revision = 3;</code>
*/
- com.google.protobuf.ByteString
- getValueBytes();
+ boolean hasRevision();
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ int getRevision();
+
+ // optional int32 localName = 4;
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ boolean hasLocalName();
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ int getLocalName();
}
/**
* Protobuf type {@code org.opendaylight.controller.mdsal.QName}
value_ = input.readBytes();
break;
}
+ case 16: {
+ bitField0_ |= 0x00000002;
+ namespace_ = input.readInt32();
+ break;
+ }
+ case 24: {
+ bitField0_ |= 0x00000004;
+ revision_ = input.readInt32();
+ break;
+ }
+ case 32: {
+ bitField0_ |= 0x00000008;
+ localName_ = input.readInt32();
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
}
private int bitField0_;
- // required string value = 1;
+ // optional string value = 1;
public static final int VALUE_FIELD_NUMBER = 1;
private java.lang.Object value_;
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public boolean hasValue() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public java.lang.String getValue() {
java.lang.Object ref = value_;
}
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public com.google.protobuf.ByteString
getValueBytes() {
}
}
+ // optional int32 namespace = 2;
+ public static final int NAMESPACE_FIELD_NUMBER = 2;
+ private int namespace_;
+ /**
+ * <code>optional int32 namespace = 2;</code>
+ */
+ public boolean hasNamespace() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional int32 namespace = 2;</code>
+ */
+ public int getNamespace() {
+ return namespace_;
+ }
+
+ // optional int32 revision = 3;
+ public static final int REVISION_FIELD_NUMBER = 3;
+ private int revision_;
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ public boolean hasRevision() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ public int getRevision() {
+ return revision_;
+ }
+
+ // optional int32 localName = 4;
+ public static final int LOCALNAME_FIELD_NUMBER = 4;
+ private int localName_;
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ public boolean hasLocalName() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ public int getLocalName() {
+ return localName_;
+ }
+
private void initFields() {
value_ = "";
+ namespace_ = 0;
+ revision_ = 0;
+ localName_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
- if (!hasValue()) {
- memoizedIsInitialized = 0;
- return false;
- }
memoizedIsInitialized = 1;
return true;
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeBytes(1, getValueBytes());
}
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeInt32(2, namespace_);
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeInt32(3, revision_);
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ output.writeInt32(4, localName_);
+ }
getUnknownFields().writeTo(output);
}
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, getValueBytes());
}
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(2, namespace_);
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(3, revision_);
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(4, localName_);
+ }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
super.clear();
value_ = "";
bitField0_ = (bitField0_ & ~0x00000001);
+ namespace_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ revision_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ localName_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000008);
return this;
}
to_bitField0_ |= 0x00000001;
}
result.value_ = value_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.namespace_ = namespace_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.revision_ = revision_;
+ if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.localName_ = localName_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
value_ = other.value_;
onChanged();
}
+ if (other.hasNamespace()) {
+ setNamespace(other.getNamespace());
+ }
+ if (other.hasRevision()) {
+ setRevision(other.getRevision());
+ }
+ if (other.hasLocalName()) {
+ setLocalName(other.getLocalName());
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
public final boolean isInitialized() {
- if (!hasValue()) {
-
- return false;
- }
return true;
}
}
private int bitField0_;
- // required string value = 1;
+ // optional string value = 1;
private java.lang.Object value_ = "";
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public boolean hasValue() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public java.lang.String getValue() {
java.lang.Object ref = value_;
}
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public com.google.protobuf.ByteString
getValueBytes() {
}
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public Builder setValue(
java.lang.String value) {
return this;
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public Builder clearValue() {
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public Builder setValueBytes(
com.google.protobuf.ByteString value) {
return this;
}
+ // optional int32 namespace = 2;
+ private int namespace_ ;
+ /**
+ * <code>optional int32 namespace = 2;</code>
+ */
+ public boolean hasNamespace() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional int32 namespace = 2;</code>
+ */
+ public int getNamespace() {
+ return namespace_;
+ }
+ /**
+ * <code>optional int32 namespace = 2;</code>
+ */
+ public Builder setNamespace(int value) {
+ bitField0_ |= 0x00000002;
+ namespace_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 namespace = 2;</code>
+ */
+ public Builder clearNamespace() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ namespace_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // optional int32 revision = 3;
+ private int revision_ ;
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ public boolean hasRevision() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ public int getRevision() {
+ return revision_;
+ }
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ public Builder setRevision(int value) {
+ bitField0_ |= 0x00000004;
+ revision_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 revision = 3;</code>
+ */
+ public Builder clearRevision() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ revision_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // optional int32 localName = 4;
+ private int localName_ ;
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ public boolean hasLocalName() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ public int getLocalName() {
+ return localName_;
+ }
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ public Builder setLocalName(int value) {
+ bitField0_ |= 0x00000008;
+ localName_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 localName = 4;</code>
+ */
+ public Builder clearLocalName() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ localName_ = 0;
+ onChanged();
+ return this;
+ }
+
// @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.QName)
}
public interface PathArgumentOrBuilder
extends com.google.protobuf.MessageOrBuilder {
- // required string value = 1;
+ // optional string value = 1;
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
boolean hasValue();
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
java.lang.String getValue();
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
com.google.protobuf.ByteString
getValueBytes();
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
boolean hasType();
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
java.lang.String getType();
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
com.google.protobuf.ByteString
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder();
- // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;
+ // repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute>
+ getAttributeList();
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute getAttribute(int index);
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ int getAttributeCount();
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder>
+ getAttributeOrBuilderList();
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder getAttributeOrBuilder(
+ int index);
+
+ // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>
getAttributesList();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index);
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
int getAttributesCount();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>
getAttributesOrBuilderList();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder(
int index);
+
+ // optional int32 intType = 6;
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ boolean hasIntType();
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ int getIntType();
}
/**
* Protobuf type {@code org.opendaylight.controller.mdsal.PathArgument}
}
case 34: {
if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
- attributes_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>();
+ attribute_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute>();
mutable_bitField0_ |= 0x00000008;
}
+ attribute_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.PARSER, extensionRegistry));
+ break;
+ }
+ case 42: {
+ if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
+ attributes_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>();
+ mutable_bitField0_ |= 0x00000010;
+ }
attributes_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.PARSER, extensionRegistry));
break;
}
+ case 48: {
+ bitField0_ |= 0x00000008;
+ intType_ = input.readInt32();
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
e.getMessage()).setUnfinishedMessage(this);
} finally {
if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
+ attribute_ = java.util.Collections.unmodifiableList(attribute_);
+ }
+ if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
attributes_ = java.util.Collections.unmodifiableList(attributes_);
}
this.unknownFields = unknownFields.build();
}
private int bitField0_;
- // required string value = 1;
+ // optional string value = 1;
public static final int VALUE_FIELD_NUMBER = 1;
private java.lang.Object value_;
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public boolean hasValue() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public java.lang.String getValue() {
java.lang.Object ref = value_;
}
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public com.google.protobuf.ByteString
getValueBytes() {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public boolean hasType() {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public java.lang.String getType() {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public com.google.protobuf.ByteString
return (com.google.protobuf.ByteString) ref;
}
}
-
- // optional .org.opendaylight.controller.mdsal.QName nodeType = 3;
- public static final int NODETYPE_FIELD_NUMBER = 3;
- private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName nodeType_;
+
+ // optional .org.opendaylight.controller.mdsal.QName nodeType = 3;
+ public static final int NODETYPE_FIELD_NUMBER = 3;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName nodeType_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public boolean hasNodeType() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getNodeType() {
+ return nodeType_;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder() {
+ return nodeType_;
+ }
+
+ // repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;
+ public static final int ATTRIBUTE_FIELD_NUMBER = 4;
+ private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute> attribute_;
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute> getAttributeList() {
+ return attribute_;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder>
+ getAttributeOrBuilderList() {
+ return attribute_;
+ }
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public boolean hasNodeType() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
+ public int getAttributeCount() {
+ return attribute_.size();
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName getNodeType() {
- return nodeType_;
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute getAttribute(int index) {
+ return attribute_.get(index);
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder() {
- return nodeType_;
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder getAttributeOrBuilder(
+ int index) {
+ return attribute_.get(index);
}
- // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;
- public static final int ATTRIBUTES_FIELD_NUMBER = 4;
+ // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;
+ public static final int ATTRIBUTES_FIELD_NUMBER = 5;
private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> attributes_;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> getAttributesList() {
return attributes_;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>
getAttributesOrBuilderList() {
return attributes_;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public int getAttributesCount() {
return attributes_.size();
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) {
return attributes_.get(index);
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder(
int index) {
return attributes_.get(index);
}
+ // optional int32 intType = 6;
+ public static final int INTTYPE_FIELD_NUMBER = 6;
+ private int intType_;
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ public boolean hasIntType() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ public int getIntType() {
+ return intType_;
+ }
+
private void initFields() {
value_ = "";
type_ = "";
nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ attribute_ = java.util.Collections.emptyList();
attributes_ = java.util.Collections.emptyList();
+ intType_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
- if (!hasValue()) {
- memoizedIsInitialized = 0;
- return false;
- }
- if (hasNodeType()) {
- if (!getNodeType().isInitialized()) {
- memoizedIsInitialized = 0;
- return false;
- }
- }
for (int i = 0; i < getAttributesCount(); i++) {
if (!getAttributes(i).isInitialized()) {
memoizedIsInitialized = 0;
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeMessage(3, nodeType_);
}
+ for (int i = 0; i < attribute_.size(); i++) {
+ output.writeMessage(4, attribute_.get(i));
+ }
for (int i = 0; i < attributes_.size(); i++) {
- output.writeMessage(4, attributes_.get(i));
+ output.writeMessage(5, attributes_.get(i));
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ output.writeInt32(6, intType_);
}
getUnknownFields().writeTo(output);
}
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(3, nodeType_);
}
+ for (int i = 0; i < attribute_.size(); i++) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(4, attribute_.get(i));
+ }
for (int i = 0; i < attributes_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(4, attributes_.get(i));
+ .computeMessageSize(5, attributes_.get(i));
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(6, intType_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
getNodeTypeFieldBuilder();
+ getAttributeFieldBuilder();
getAttributesFieldBuilder();
}
}
nodeTypeBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000004);
+ if (attributeBuilder_ == null) {
+ attribute_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000008);
+ } else {
+ attributeBuilder_.clear();
+ }
if (attributesBuilder_ == null) {
attributes_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000010);
} else {
attributesBuilder_.clear();
}
+ intType_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000020);
return this;
}
} else {
result.nodeType_ = nodeTypeBuilder_.build();
}
- if (attributesBuilder_ == null) {
+ if (attributeBuilder_ == null) {
if (((bitField0_ & 0x00000008) == 0x00000008)) {
- attributes_ = java.util.Collections.unmodifiableList(attributes_);
+ attribute_ = java.util.Collections.unmodifiableList(attribute_);
bitField0_ = (bitField0_ & ~0x00000008);
}
+ result.attribute_ = attribute_;
+ } else {
+ result.attribute_ = attributeBuilder_.build();
+ }
+ if (attributesBuilder_ == null) {
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
+ attributes_ = java.util.Collections.unmodifiableList(attributes_);
+ bitField0_ = (bitField0_ & ~0x00000010);
+ }
result.attributes_ = attributes_;
} else {
result.attributes_ = attributesBuilder_.build();
}
+ if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.intType_ = intType_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
if (other.hasNodeType()) {
mergeNodeType(other.getNodeType());
}
+ if (attributeBuilder_ == null) {
+ if (!other.attribute_.isEmpty()) {
+ if (attribute_.isEmpty()) {
+ attribute_ = other.attribute_;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ } else {
+ ensureAttributeIsMutable();
+ attribute_.addAll(other.attribute_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.attribute_.isEmpty()) {
+ if (attributeBuilder_.isEmpty()) {
+ attributeBuilder_.dispose();
+ attributeBuilder_ = null;
+ attribute_ = other.attribute_;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ attributeBuilder_ =
+ com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+ getAttributeFieldBuilder() : null;
+ } else {
+ attributeBuilder_.addAllMessages(other.attribute_);
+ }
+ }
+ }
if (attributesBuilder_ == null) {
if (!other.attributes_.isEmpty()) {
if (attributes_.isEmpty()) {
attributes_ = other.attributes_;
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000010);
} else {
ensureAttributesIsMutable();
attributes_.addAll(other.attributes_);
attributesBuilder_.dispose();
attributesBuilder_ = null;
attributes_ = other.attributes_;
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000010);
attributesBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getAttributesFieldBuilder() : null;
}
}
}
+ if (other.hasIntType()) {
+ setIntType(other.getIntType());
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
public final boolean isInitialized() {
- if (!hasValue()) {
-
- return false;
- }
- if (hasNodeType()) {
- if (!getNodeType().isInitialized()) {
-
- return false;
- }
- }
for (int i = 0; i < getAttributesCount(); i++) {
if (!getAttributes(i).isInitialized()) {
}
private int bitField0_;
- // required string value = 1;
+ // optional string value = 1;
private java.lang.Object value_ = "";
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public boolean hasValue() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public java.lang.String getValue() {
java.lang.Object ref = value_;
}
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public com.google.protobuf.ByteString
getValueBytes() {
}
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public Builder setValue(
java.lang.String value) {
return this;
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public Builder clearValue() {
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
/**
- * <code>required string value = 1;</code>
+ * <code>optional string value = 1;</code>
+ *
+ * <pre>
+ * @deprecated
+ * </pre>
*/
public Builder setValueBytes(
com.google.protobuf.ByteString value) {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public boolean hasType() {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public java.lang.String getType() {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public com.google.protobuf.ByteString
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public Builder setType(
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public Builder clearType() {
* <code>optional string type = 2;</code>
*
* <pre>
- *NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ * @deprecated
* </pre>
*/
public Builder setTypeBytes(
nodeType_ = builderForValue.build();
onChanged();
} else {
- nodeTypeBuilder_.setMessage(builderForValue.build());
+ nodeTypeBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000004;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public Builder mergeNodeType(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName value) {
+ if (nodeTypeBuilder_ == null) {
+ if (((bitField0_ & 0x00000004) == 0x00000004) &&
+ nodeType_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance()) {
+ nodeType_ =
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.newBuilder(nodeType_).mergeFrom(value).buildPartial();
+ } else {
+ nodeType_ = value;
+ }
+ onChanged();
+ } else {
+ nodeTypeBuilder_.mergeFrom(value);
+ }
+ bitField0_ |= 0x00000004;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public Builder clearNodeType() {
+ if (nodeTypeBuilder_ == null) {
+ nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ onChanged();
+ } else {
+ nodeTypeBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000004);
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder getNodeTypeBuilder() {
+ bitField0_ |= 0x00000004;
+ onChanged();
+ return getNodeTypeFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder() {
+ if (nodeTypeBuilder_ != null) {
+ return nodeTypeBuilder_.getMessageOrBuilder();
+ } else {
+ return nodeType_;
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ */
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>
+ getNodeTypeFieldBuilder() {
+ if (nodeTypeBuilder_ == null) {
+ nodeTypeBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>(
+ nodeType_,
+ getParentForChildren(),
+ isClean());
+ nodeType_ = null;
+ }
+ return nodeTypeBuilder_;
+ }
+
+ // repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;
+ private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute> attribute_ =
+ java.util.Collections.emptyList();
+ private void ensureAttributeIsMutable() {
+ if (!((bitField0_ & 0x00000008) == 0x00000008)) {
+ attribute_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute>(attribute_);
+ bitField0_ |= 0x00000008;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder> attributeBuilder_;
+
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute> getAttributeList() {
+ if (attributeBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(attribute_);
+ } else {
+ return attributeBuilder_.getMessageList();
+ }
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public int getAttributeCount() {
+ if (attributeBuilder_ == null) {
+ return attribute_.size();
+ } else {
+ return attributeBuilder_.getCount();
+ }
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute getAttribute(int index) {
+ if (attributeBuilder_ == null) {
+ return attribute_.get(index);
+ } else {
+ return attributeBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder setAttribute(
+ int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute value) {
+ if (attributeBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureAttributeIsMutable();
+ attribute_.set(index, value);
+ onChanged();
+ } else {
+ attributeBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder setAttribute(
+ int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder builderForValue) {
+ if (attributeBuilder_ == null) {
+ ensureAttributeIsMutable();
+ attribute_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ attributeBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder addAttribute(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute value) {
+ if (attributeBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureAttributeIsMutable();
+ attribute_.add(value);
+ onChanged();
+ } else {
+ attributeBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder addAttribute(
+ int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute value) {
+ if (attributeBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureAttributeIsMutable();
+ attribute_.add(index, value);
+ onChanged();
+ } else {
+ attributeBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder addAttribute(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder builderForValue) {
+ if (attributeBuilder_ == null) {
+ ensureAttributeIsMutable();
+ attribute_.add(builderForValue.build());
+ onChanged();
+ } else {
+ attributeBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder addAttribute(
+ int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder builderForValue) {
+ if (attributeBuilder_ == null) {
+ ensureAttributeIsMutable();
+ attribute_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ attributeBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public Builder addAllAttribute(
+ java.lang.Iterable<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute> values) {
+ if (attributeBuilder_ == null) {
+ ensureAttributeIsMutable();
+ super.addAll(values, attribute_);
+ onChanged();
+ } else {
+ attributeBuilder_.addAllMessages(values);
}
- bitField0_ |= 0x00000004;
return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public Builder mergeNodeType(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName value) {
- if (nodeTypeBuilder_ == null) {
- if (((bitField0_ & 0x00000004) == 0x00000004) &&
- nodeType_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance()) {
- nodeType_ =
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.newBuilder(nodeType_).mergeFrom(value).buildPartial();
- } else {
- nodeType_ = value;
- }
+ public Builder clearAttribute() {
+ if (attributeBuilder_ == null) {
+ attribute_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000008);
onChanged();
} else {
- nodeTypeBuilder_.mergeFrom(value);
+ attributeBuilder_.clear();
}
- bitField0_ |= 0x00000004;
return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public Builder clearNodeType() {
- if (nodeTypeBuilder_ == null) {
- nodeType_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.getDefaultInstance();
+ public Builder removeAttribute(int index) {
+ if (attributeBuilder_ == null) {
+ ensureAttributeIsMutable();
+ attribute_.remove(index);
onChanged();
} else {
- nodeTypeBuilder_.clear();
+ attributeBuilder_.remove(index);
}
- bitField0_ = (bitField0_ & ~0x00000004);
return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder getNodeTypeBuilder() {
- bitField0_ |= 0x00000004;
- onChanged();
- return getNodeTypeFieldBuilder().getBuilder();
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder getAttributeBuilder(
+ int index) {
+ return getAttributeFieldBuilder().getBuilder(index);
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder getNodeTypeOrBuilder() {
- if (nodeTypeBuilder_ != null) {
- return nodeTypeBuilder_.getMessageOrBuilder();
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder getAttributeOrBuilder(
+ int index) {
+ if (attributeBuilder_ == null) {
+ return attribute_.get(index); } else {
+ return attributeBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder>
+ getAttributeOrBuilderList() {
+ if (attributeBuilder_ != null) {
+ return attributeBuilder_.getMessageOrBuilderList();
} else {
- return nodeType_;
+ return java.util.Collections.unmodifiableList(attribute_);
}
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.QName nodeType = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
*/
- private com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>
- getNodeTypeFieldBuilder() {
- if (nodeTypeBuilder_ == null) {
- nodeTypeBuilder_ = new com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder>(
- nodeType_,
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder addAttributeBuilder() {
+ return getAttributeFieldBuilder().addBuilder(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder addAttributeBuilder(
+ int index) {
+ return getAttributeFieldBuilder().addBuilder(
+ index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .org.opendaylight.controller.mdsal.PathArgumentAttribute attribute = 4;</code>
+ */
+ public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder>
+ getAttributeBuilderList() {
+ return getAttributeFieldBuilder().getBuilderList();
+ }
+ private com.google.protobuf.RepeatedFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder>
+ getAttributeFieldBuilder() {
+ if (attributeBuilder_ == null) {
+ attributeBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentAttributeOrBuilder>(
+ attribute_,
+ ((bitField0_ & 0x00000008) == 0x00000008),
getParentForChildren(),
isClean());
- nodeType_ = null;
+ attribute_ = null;
}
- return nodeTypeBuilder_;
+ return attributeBuilder_;
}
- // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;
+ // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;
private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> attributes_ =
java.util.Collections.emptyList();
private void ensureAttributesIsMutable() {
- if (!((bitField0_ & 0x00000008) == 0x00000008)) {
+ if (!((bitField0_ & 0x00000010) == 0x00000010)) {
attributes_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>(attributes_);
- bitField0_ |= 0x00000008;
+ bitField0_ |= 0x00000010;
}
}
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> attributesBuilder_;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> getAttributesList() {
if (attributesBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public int getAttributesCount() {
if (attributesBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) {
if (attributesBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder setAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder setAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder addAttributes(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) {
if (attributesBuilder_ == null) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder addAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder addAttributes(
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder addAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder addAllAttributes(
java.lang.Iterable<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> values) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder clearAttributes() {
if (attributesBuilder_ == null) {
attributes_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000010);
onChanged();
} else {
attributesBuilder_.clear();
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public Builder removeAttributes(int index) {
if (attributesBuilder_ == null) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder getAttributesBuilder(
int index) {
return getAttributesFieldBuilder().getBuilder(index);
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder(
int index) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>
getAttributesOrBuilderList() {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder() {
return getAttributesFieldBuilder().addBuilder(
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance());
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder(
int index) {
index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance());
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
+ *
+ * <pre>
+ * @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ * </pre>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder>
getAttributesBuilderList() {
attributesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>(
attributes_,
- ((bitField0_ & 0x00000008) == 0x00000008),
+ ((bitField0_ & 0x00000010) == 0x00000010),
getParentForChildren(),
isClean());
attributes_ = null;
return attributesBuilder_;
}
+ // optional int32 intType = 6;
+ private int intType_ ;
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ public boolean hasIntType() {
+ return ((bitField0_ & 0x00000020) == 0x00000020);
+ }
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ public int getIntType() {
+ return intType_;
+ }
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ public Builder setIntType(int value) {
+ bitField0_ |= 0x00000020;
+ intType_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 intType = 6;</code>
+ */
+ public Builder clearIntType() {
+ bitField0_ = (bitField0_ & ~0x00000020);
+ intType_ = 0;
+ onChanged();
+ return this;
+ }
+
// @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PathArgument)
}
// optional string path = 1;
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
boolean hasPath();
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
java.lang.String getPath();
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
com.google.protobuf.ByteString
getPathBytes();
// optional string type = 2;
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
boolean hasType();
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
java.lang.String getType();
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
com.google.protobuf.ByteString
getTypeBytes();
- // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;
+ // optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ boolean hasPathArgument();
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getPathArgument();
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getPathArgumentOrBuilder();
+
+ // optional int32 intType = 4;
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ boolean hasIntType();
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ int getIntType();
+
+ // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>
getAttributesList();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index);
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
int getAttributesCount();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>
getAttributesOrBuilderList();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder(
int index);
- // repeated .org.opendaylight.controller.mdsal.Node child = 4;
+ // repeated .org.opendaylight.controller.mdsal.Node child = 6;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node>
getChildList();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getChild(int index);
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
int getChildCount();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>
getChildOrBuilderList();
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getChildOrBuilder(
int index);
- // optional string value = 5;
+ // optional string value = 7;
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
boolean hasValue();
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
java.lang.String getValue();
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
com.google.protobuf.ByteString
getValueBytes();
- // optional string valueType = 6;
+ // optional string valueType = 8;
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
boolean hasValueType();
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
java.lang.String getValueType();
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
com.google.protobuf.ByteString
getValueTypeBytes();
- // repeated string bitsValue = 7;
+ // optional int32 intValueType = 9;
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ boolean hasIntValueType();
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ int getIntValueType();
+
+ // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ boolean hasInstanceIdentifierValue();
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue();
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder();
+
+ // repeated string bitsValue = 11;
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
java.util.List<java.lang.String>
getBitsValueList();
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
int getBitsValueCount();
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
java.lang.String getBitsValue(int index);
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
com.google.protobuf.ByteString
getBitsValueBytes(int index);
- // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;
+ // repeated string code = 12;
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- boolean hasInstanceIdentifierValue();
+ java.util.List<java.lang.String>
+ getCodeList();
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue();
+ int getCodeCount();
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder();
+ java.lang.String getCode(int index);
+ /**
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
+ */
+ com.google.protobuf.ByteString
+ getCodeBytes(int index);
}
/**
* Protobuf type {@code org.opendaylight.controller.mdsal.Node}
break;
}
case 26: {
- if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder subBuilder = null;
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ subBuilder = pathArgument_.toBuilder();
+ }
+ pathArgument_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.PARSER, extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(pathArgument_);
+ pathArgument_ = subBuilder.buildPartial();
+ }
+ bitField0_ |= 0x00000004;
+ break;
+ }
+ case 32: {
+ bitField0_ |= 0x00000008;
+ intType_ = input.readInt32();
+ break;
+ }
+ case 42: {
+ if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
attributes_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>();
- mutable_bitField0_ |= 0x00000004;
+ mutable_bitField0_ |= 0x00000010;
}
attributes_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.PARSER, extensionRegistry));
break;
}
- case 34: {
- if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
+ case 50: {
+ if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
child_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node>();
- mutable_bitField0_ |= 0x00000008;
+ mutable_bitField0_ |= 0x00000020;
}
child_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.PARSER, extensionRegistry));
break;
}
- case 42: {
- bitField0_ |= 0x00000004;
+ case 58: {
+ bitField0_ |= 0x00000010;
value_ = input.readBytes();
break;
}
- case 50: {
- bitField0_ |= 0x00000008;
+ case 66: {
+ bitField0_ |= 0x00000020;
valueType_ = input.readBytes();
break;
}
- case 58: {
- if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
- bitsValue_ = new com.google.protobuf.LazyStringArrayList();
- mutable_bitField0_ |= 0x00000040;
- }
- bitsValue_.add(input.readBytes());
+ case 72: {
+ bitField0_ |= 0x00000040;
+ intValueType_ = input.readInt32();
break;
}
- case 66: {
+ case 82: {
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder subBuilder = null;
- if (((bitField0_ & 0x00000010) == 0x00000010)) {
+ if (((bitField0_ & 0x00000080) == 0x00000080)) {
subBuilder = instanceIdentifierValue_.toBuilder();
}
instanceIdentifierValue_ = input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.PARSER, extensionRegistry);
subBuilder.mergeFrom(instanceIdentifierValue_);
instanceIdentifierValue_ = subBuilder.buildPartial();
}
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000080;
+ break;
+ }
+ case 90: {
+ if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) {
+ bitsValue_ = new com.google.protobuf.LazyStringArrayList();
+ mutable_bitField0_ |= 0x00000400;
+ }
+ bitsValue_.add(input.readBytes());
+ break;
+ }
+ case 98: {
+ if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) {
+ code_ = new com.google.protobuf.LazyStringArrayList();
+ mutable_bitField0_ |= 0x00000800;
+ }
+ code_.add(input.readBytes());
break;
}
}
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
- if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
+ if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
attributes_ = java.util.Collections.unmodifiableList(attributes_);
}
- if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
+ if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
child_ = java.util.Collections.unmodifiableList(child_);
}
- if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
+ if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) {
bitsValue_ = new com.google.protobuf.UnmodifiableLazyStringList(bitsValue_);
}
+ if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) {
+ code_ = new com.google.protobuf.UnmodifiableLazyStringList(code_);
+ }
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
private java.lang.Object path_;
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public boolean hasPath() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public java.lang.String getPath() {
java.lang.Object ref = path_;
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public com.google.protobuf.ByteString
getPathBytes() {
private java.lang.Object type_;
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public boolean hasType() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public java.lang.String getType() {
java.lang.Object ref = type_;
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public com.google.protobuf.ByteString
getTypeBytes() {
}
}
- // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;
- public static final int ATTRIBUTES_FIELD_NUMBER = 3;
+ // optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;
+ public static final int PATHARGUMENT_FIELD_NUMBER = 3;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument pathArgument_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public boolean hasPathArgument() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getPathArgument() {
+ return pathArgument_;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getPathArgumentOrBuilder() {
+ return pathArgument_;
+ }
+
+ // optional int32 intType = 4;
+ public static final int INTTYPE_FIELD_NUMBER = 4;
+ private int intType_;
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ public boolean hasIntType() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ public int getIntType() {
+ return intType_;
+ }
+
+ // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;
+ public static final int ATTRIBUTES_FIELD_NUMBER = 5;
private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> attributes_;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> getAttributesList() {
return attributes_;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>
getAttributesOrBuilderList() {
return attributes_;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public int getAttributesCount() {
return attributes_.size();
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) {
return attributes_.get(index);
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder(
int index) {
return attributes_.get(index);
}
- // repeated .org.opendaylight.controller.mdsal.Node child = 4;
- public static final int CHILD_FIELD_NUMBER = 4;
+ // repeated .org.opendaylight.controller.mdsal.Node child = 6;
+ public static final int CHILD_FIELD_NUMBER = 6;
private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node> child_;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node> getChildList() {
return child_;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>
getChildOrBuilderList() {
return child_;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public int getChildCount() {
return child_.size();
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getChild(int index) {
return child_.get(index);
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getChildOrBuilder(
int index) {
return child_.get(index);
}
- // optional string value = 5;
- public static final int VALUE_FIELD_NUMBER = 5;
+ // optional string value = 7;
+ public static final int VALUE_FIELD_NUMBER = 7;
private java.lang.Object value_;
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public boolean hasValue() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
+ return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public java.lang.String getValue() {
java.lang.Object ref = value_;
}
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public com.google.protobuf.ByteString
getValueBytes() {
}
}
- // optional string valueType = 6;
- public static final int VALUETYPE_FIELD_NUMBER = 6;
+ // optional string valueType = 8;
+ public static final int VALUETYPE_FIELD_NUMBER = 8;
private java.lang.Object valueType_;
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
public boolean hasValueType() {
- return ((bitField0_ & 0x00000008) == 0x00000008);
+ return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
public java.lang.String getValueType() {
java.lang.Object ref = valueType_;
}
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
public com.google.protobuf.ByteString
getValueTypeBytes() {
}
}
- // repeated string bitsValue = 7;
- public static final int BITSVALUE_FIELD_NUMBER = 7;
+ // optional int32 intValueType = 9;
+ public static final int INTVALUETYPE_FIELD_NUMBER = 9;
+ private int intValueType_;
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ public boolean hasIntValueType() {
+ return ((bitField0_ & 0x00000040) == 0x00000040);
+ }
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ public int getIntValueType() {
+ return intValueType_;
+ }
+
+ // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;
+ public static final int INSTANCEIDENTIFIERVALUE_FIELD_NUMBER = 10;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierValue_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public boolean hasInstanceIdentifierValue() {
+ return ((bitField0_ & 0x00000080) == 0x00000080);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue() {
+ return instanceIdentifierValue_;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder() {
+ return instanceIdentifierValue_;
+ }
+
+ // repeated string bitsValue = 11;
+ public static final int BITSVALUE_FIELD_NUMBER = 11;
private com.google.protobuf.LazyStringList bitsValue_;
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public java.util.List<java.lang.String>
getBitsValueList() {
return bitsValue_;
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public int getBitsValueCount() {
return bitsValue_.size();
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public java.lang.String getBitsValue(int index) {
return bitsValue_.get(index);
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public com.google.protobuf.ByteString
getBitsValueBytes(int index) {
return bitsValue_.getByteString(index);
}
- // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;
- public static final int INSTANCEIDENTIFIERVALUE_FIELD_NUMBER = 8;
- private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierValue_;
+ // repeated string code = 12;
+ public static final int CODE_FIELD_NUMBER = 12;
+ private com.google.protobuf.LazyStringList code_;
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public boolean hasInstanceIdentifierValue() {
- return ((bitField0_ & 0x00000010) == 0x00000010);
+ public java.util.List<java.lang.String>
+ getCodeList() {
+ return code_;
+ }
+ /**
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
+ */
+ public int getCodeCount() {
+ return code_.size();
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue() {
- return instanceIdentifierValue_;
+ public java.lang.String getCode(int index) {
+ return code_.get(index);
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder() {
- return instanceIdentifierValue_;
+ public com.google.protobuf.ByteString
+ getCodeBytes(int index) {
+ return code_.getByteString(index);
}
private void initFields() {
path_ = "";
type_ = "";
+ pathArgument_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance();
+ intType_ = 0;
attributes_ = java.util.Collections.emptyList();
child_ = java.util.Collections.emptyList();
value_ = "";
valueType_ = "";
- bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ intValueType_ = 0;
instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
+ bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
+ if (hasPathArgument()) {
+ if (!getPathArgument().isInitialized()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ }
for (int i = 0; i < getAttributesCount(); i++) {
if (!getAttributes(i).isInitialized()) {
memoizedIsInitialized = 0;
if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBytes(2, getTypeBytes());
}
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeMessage(3, pathArgument_);
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ output.writeInt32(4, intType_);
+ }
for (int i = 0; i < attributes_.size(); i++) {
- output.writeMessage(3, attributes_.get(i));
+ output.writeMessage(5, attributes_.get(i));
}
for (int i = 0; i < child_.size(); i++) {
- output.writeMessage(4, child_.get(i));
+ output.writeMessage(6, child_.get(i));
}
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
- output.writeBytes(5, getValueBytes());
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
+ output.writeBytes(7, getValueBytes());
}
- if (((bitField0_ & 0x00000008) == 0x00000008)) {
- output.writeBytes(6, getValueTypeBytes());
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
+ output.writeBytes(8, getValueTypeBytes());
+ }
+ if (((bitField0_ & 0x00000040) == 0x00000040)) {
+ output.writeInt32(9, intValueType_);
+ }
+ if (((bitField0_ & 0x00000080) == 0x00000080)) {
+ output.writeMessage(10, instanceIdentifierValue_);
}
for (int i = 0; i < bitsValue_.size(); i++) {
- output.writeBytes(7, bitsValue_.getByteString(i));
+ output.writeBytes(11, bitsValue_.getByteString(i));
}
- if (((bitField0_ & 0x00000010) == 0x00000010)) {
- output.writeMessage(8, instanceIdentifierValue_);
+ for (int i = 0; i < code_.size(); i++) {
+ output.writeBytes(12, code_.getByteString(i));
}
getUnknownFields().writeTo(output);
}
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, getTypeBytes());
}
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(3, pathArgument_);
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(4, intType_);
+ }
for (int i = 0; i < attributes_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(3, attributes_.get(i));
+ .computeMessageSize(5, attributes_.get(i));
}
for (int i = 0; i < child_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(4, child_.get(i));
+ .computeMessageSize(6, child_.get(i));
}
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(5, getValueBytes());
+ .computeBytesSize(7, getValueBytes());
}
- if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(6, getValueTypeBytes());
+ .computeBytesSize(8, getValueTypeBytes());
+ }
+ if (((bitField0_ & 0x00000040) == 0x00000040)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(9, intValueType_);
+ }
+ if (((bitField0_ & 0x00000080) == 0x00000080)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(10, instanceIdentifierValue_);
}
{
int dataSize = 0;
size += dataSize;
size += 1 * getBitsValueList().size();
}
- if (((bitField0_ & 0x00000010) == 0x00000010)) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(8, instanceIdentifierValue_);
+ {
+ int dataSize = 0;
+ for (int i = 0; i < code_.size(); i++) {
+ dataSize += com.google.protobuf.CodedOutputStream
+ .computeBytesSizeNoTag(code_.getByteString(i));
+ }
+ size += dataSize;
+ size += 1 * getCodeList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ getPathArgumentFieldBuilder();
getAttributesFieldBuilder();
getChildFieldBuilder();
getInstanceIdentifierValueFieldBuilder();
bitField0_ = (bitField0_ & ~0x00000001);
type_ = "";
bitField0_ = (bitField0_ & ~0x00000002);
+ if (pathArgumentBuilder_ == null) {
+ pathArgument_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance();
+ } else {
+ pathArgumentBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000004);
+ intType_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000008);
if (attributesBuilder_ == null) {
attributes_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000010);
} else {
attributesBuilder_.clear();
}
if (childBuilder_ == null) {
child_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000020);
} else {
childBuilder_.clear();
}
value_ = "";
- bitField0_ = (bitField0_ & ~0x00000010);
- valueType_ = "";
- bitField0_ = (bitField0_ & ~0x00000020);
- bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
bitField0_ = (bitField0_ & ~0x00000040);
+ valueType_ = "";
+ bitField0_ = (bitField0_ & ~0x00000080);
+ intValueType_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000100);
if (instanceIdentifierValueBuilder_ == null) {
instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
} else {
instanceIdentifierValueBuilder_.clear();
}
- bitField0_ = (bitField0_ & ~0x00000080);
+ bitField0_ = (bitField0_ & ~0x00000200);
+ bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000400);
+ code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000800);
return this;
}
to_bitField0_ |= 0x00000002;
}
result.type_ = type_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ if (pathArgumentBuilder_ == null) {
+ result.pathArgument_ = pathArgument_;
+ } else {
+ result.pathArgument_ = pathArgumentBuilder_.build();
+ }
+ if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.intType_ = intType_;
if (attributesBuilder_ == null) {
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
attributes_ = java.util.Collections.unmodifiableList(attributes_);
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000010);
}
result.attributes_ = attributes_;
} else {
result.attributes_ = attributesBuilder_.build();
}
if (childBuilder_ == null) {
- if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
child_ = java.util.Collections.unmodifiableList(child_);
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000020);
}
result.child_ = child_;
} else {
result.child_ = childBuilder_.build();
}
- if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
- to_bitField0_ |= 0x00000004;
+ if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
+ to_bitField0_ |= 0x00000010;
}
result.value_ = value_;
- if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
- to_bitField0_ |= 0x00000008;
+ if (((from_bitField0_ & 0x00000080) == 0x00000080)) {
+ to_bitField0_ |= 0x00000020;
}
result.valueType_ = valueType_;
- if (((bitField0_ & 0x00000040) == 0x00000040)) {
- bitsValue_ = new com.google.protobuf.UnmodifiableLazyStringList(
- bitsValue_);
- bitField0_ = (bitField0_ & ~0x00000040);
+ if (((from_bitField0_ & 0x00000100) == 0x00000100)) {
+ to_bitField0_ |= 0x00000040;
}
- result.bitsValue_ = bitsValue_;
- if (((from_bitField0_ & 0x00000080) == 0x00000080)) {
- to_bitField0_ |= 0x00000010;
+ result.intValueType_ = intValueType_;
+ if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
+ to_bitField0_ |= 0x00000080;
}
if (instanceIdentifierValueBuilder_ == null) {
result.instanceIdentifierValue_ = instanceIdentifierValue_;
} else {
result.instanceIdentifierValue_ = instanceIdentifierValueBuilder_.build();
}
+ if (((bitField0_ & 0x00000400) == 0x00000400)) {
+ bitsValue_ = new com.google.protobuf.UnmodifiableLazyStringList(
+ bitsValue_);
+ bitField0_ = (bitField0_ & ~0x00000400);
+ }
+ result.bitsValue_ = bitsValue_;
+ if (((bitField0_ & 0x00000800) == 0x00000800)) {
+ code_ = new com.google.protobuf.UnmodifiableLazyStringList(
+ code_);
+ bitField0_ = (bitField0_ & ~0x00000800);
+ }
+ result.code_ = code_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
type_ = other.type_;
onChanged();
}
+ if (other.hasPathArgument()) {
+ mergePathArgument(other.getPathArgument());
+ }
+ if (other.hasIntType()) {
+ setIntType(other.getIntType());
+ }
if (attributesBuilder_ == null) {
if (!other.attributes_.isEmpty()) {
if (attributes_.isEmpty()) {
attributes_ = other.attributes_;
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000010);
} else {
ensureAttributesIsMutable();
attributes_.addAll(other.attributes_);
attributesBuilder_.dispose();
attributesBuilder_ = null;
attributes_ = other.attributes_;
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000010);
attributesBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getAttributesFieldBuilder() : null;
if (!other.child_.isEmpty()) {
if (child_.isEmpty()) {
child_ = other.child_;
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000020);
} else {
ensureChildIsMutable();
child_.addAll(other.child_);
childBuilder_.dispose();
childBuilder_ = null;
child_ = other.child_;
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000020);
childBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getChildFieldBuilder() : null;
}
}
if (other.hasValue()) {
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000040;
value_ = other.value_;
onChanged();
}
if (other.hasValueType()) {
- bitField0_ |= 0x00000020;
+ bitField0_ |= 0x00000080;
valueType_ = other.valueType_;
onChanged();
}
+ if (other.hasIntValueType()) {
+ setIntValueType(other.getIntValueType());
+ }
+ if (other.hasInstanceIdentifierValue()) {
+ mergeInstanceIdentifierValue(other.getInstanceIdentifierValue());
+ }
if (!other.bitsValue_.isEmpty()) {
if (bitsValue_.isEmpty()) {
bitsValue_ = other.bitsValue_;
- bitField0_ = (bitField0_ & ~0x00000040);
+ bitField0_ = (bitField0_ & ~0x00000400);
} else {
ensureBitsValueIsMutable();
bitsValue_.addAll(other.bitsValue_);
}
onChanged();
}
- if (other.hasInstanceIdentifierValue()) {
- mergeInstanceIdentifierValue(other.getInstanceIdentifierValue());
+ if (!other.code_.isEmpty()) {
+ if (code_.isEmpty()) {
+ code_ = other.code_;
+ bitField0_ = (bitField0_ & ~0x00000800);
+ } else {
+ ensureCodeIsMutable();
+ code_.addAll(other.code_);
+ }
+ onChanged();
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
public final boolean isInitialized() {
+ if (hasPathArgument()) {
+ if (!getPathArgument().isInitialized()) {
+
+ return false;
+ }
+ }
for (int i = 0; i < getAttributesCount(); i++) {
if (!getAttributes(i).isInitialized()) {
private java.lang.Object path_ = "";
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public boolean hasPath() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public java.lang.String getPath() {
java.lang.Object ref = path_;
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public com.google.protobuf.ByteString
getPathBytes() {
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public Builder setPath(
java.lang.String value) {
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public Builder clearPath() {
bitField0_ = (bitField0_ & ~0x00000001);
}
/**
* <code>optional string path = 1;</code>
+ *
+ * <pre>
+ * @deprecated(use pathArgument)
+ * </pre>
*/
public Builder setPathBytes(
com.google.protobuf.ByteString value) {
private java.lang.Object type_ = "";
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public boolean hasType() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public java.lang.String getType() {
java.lang.Object ref = type_;
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public com.google.protobuf.ByteString
getTypeBytes() {
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public Builder setType(
java.lang.String value) {
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public Builder clearType() {
bitField0_ = (bitField0_ & ~0x00000002);
}
/**
* <code>optional string type = 2;</code>
+ *
+ * <pre>
+ * @deprecated(use intType)
+ * </pre>
*/
public Builder setTypeBytes(
com.google.protobuf.ByteString value) {
return this;
}
- // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;
+ // optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument pathArgument_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance();
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder> pathArgumentBuilder_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public boolean hasPathArgument() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument getPathArgument() {
+ if (pathArgumentBuilder_ == null) {
+ return pathArgument_;
+ } else {
+ return pathArgumentBuilder_.getMessage();
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public Builder setPathArgument(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument value) {
+ if (pathArgumentBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ pathArgument_ = value;
+ onChanged();
+ } else {
+ pathArgumentBuilder_.setMessage(value);
+ }
+ bitField0_ |= 0x00000004;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public Builder setPathArgument(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder builderForValue) {
+ if (pathArgumentBuilder_ == null) {
+ pathArgument_ = builderForValue.build();
+ onChanged();
+ } else {
+ pathArgumentBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000004;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public Builder mergePathArgument(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument value) {
+ if (pathArgumentBuilder_ == null) {
+ if (((bitField0_ & 0x00000004) == 0x00000004) &&
+ pathArgument_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance()) {
+ pathArgument_ =
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.newBuilder(pathArgument_).mergeFrom(value).buildPartial();
+ } else {
+ pathArgument_ = value;
+ }
+ onChanged();
+ } else {
+ pathArgumentBuilder_.mergeFrom(value);
+ }
+ bitField0_ |= 0x00000004;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public Builder clearPathArgument() {
+ if (pathArgumentBuilder_ == null) {
+ pathArgument_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.getDefaultInstance();
+ onChanged();
+ } else {
+ pathArgumentBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000004);
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder getPathArgumentBuilder() {
+ bitField0_ |= 0x00000004;
+ onChanged();
+ return getPathArgumentFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getPathArgumentOrBuilder() {
+ if (pathArgumentBuilder_ != null) {
+ return pathArgumentBuilder_.getMessageOrBuilder();
+ } else {
+ return pathArgument_;
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.PathArgument pathArgument = 3;</code>
+ */
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder>
+ getPathArgumentFieldBuilder() {
+ if (pathArgumentBuilder_ == null) {
+ pathArgumentBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder>(
+ pathArgument_,
+ getParentForChildren(),
+ isClean());
+ pathArgument_ = null;
+ }
+ return pathArgumentBuilder_;
+ }
+
+ // optional int32 intType = 4;
+ private int intType_ ;
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ public boolean hasIntType() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ public int getIntType() {
+ return intType_;
+ }
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ public Builder setIntType(int value) {
+ bitField0_ |= 0x00000008;
+ intType_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 intType = 4;</code>
+ */
+ public Builder clearIntType() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ intType_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;
private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> attributes_ =
java.util.Collections.emptyList();
private void ensureAttributesIsMutable() {
- if (!((bitField0_ & 0x00000004) == 0x00000004)) {
+ if (!((bitField0_ & 0x00000010) == 0x00000010)) {
attributes_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute>(attributes_);
- bitField0_ |= 0x00000004;
+ bitField0_ |= 0x00000010;
}
}
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> attributesBuilder_;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> getAttributesList() {
if (attributesBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public int getAttributesCount() {
if (attributesBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute getAttributes(int index) {
if (attributesBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder setAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder setAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder addAttributes(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) {
if (attributesBuilder_ == null) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder addAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute value) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder addAttributes(
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder addAttributes(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder addAllAttributes(
java.lang.Iterable<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute> values) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder clearAttributes() {
if (attributesBuilder_ == null) {
attributes_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000010);
onChanged();
} else {
attributesBuilder_.clear();
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public Builder removeAttributes(int index) {
if (attributesBuilder_ == null) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder getAttributesBuilder(
int index) {
return getAttributesFieldBuilder().getBuilder(index);
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder getAttributesOrBuilder(
int index) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>
getAttributesOrBuilderList() {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder() {
return getAttributesFieldBuilder().addBuilder(
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance());
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder addAttributesBuilder(
int index) {
index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.getDefaultInstance());
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Attribute attributes = 5;</code>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder>
getAttributesBuilderList() {
attributesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder>(
attributes_,
- ((bitField0_ & 0x00000004) == 0x00000004),
+ ((bitField0_ & 0x00000010) == 0x00000010),
getParentForChildren(),
isClean());
attributes_ = null;
return attributesBuilder_;
}
- // repeated .org.opendaylight.controller.mdsal.Node child = 4;
+ // repeated .org.opendaylight.controller.mdsal.Node child = 6;
private java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node> child_ =
java.util.Collections.emptyList();
private void ensureChildIsMutable() {
- if (!((bitField0_ & 0x00000008) == 0x00000008)) {
+ if (!((bitField0_ & 0x00000020) == 0x00000020)) {
child_ = new java.util.ArrayList<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node>(child_);
- bitField0_ |= 0x00000008;
+ bitField0_ |= 0x00000020;
}
}
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> childBuilder_;
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node> getChildList() {
if (childBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public int getChildCount() {
if (childBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node getChild(int index) {
if (childBuilder_ == null) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder setChild(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder setChild(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder addChild(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) {
if (childBuilder_ == null) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder addChild(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node value) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder addChild(
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder addChild(
int index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder builderForValue) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder addAllChild(
java.lang.Iterable<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node> values) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder clearChild() {
if (childBuilder_ == null) {
child_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00000008);
+ bitField0_ = (bitField0_ & ~0x00000020);
onChanged();
} else {
childBuilder_.clear();
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public Builder removeChild(int index) {
if (childBuilder_ == null) {
return this;
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder getChildBuilder(
int index) {
return getChildFieldBuilder().getBuilder(index);
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder getChildOrBuilder(
int index) {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public java.util.List<? extends org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>
getChildOrBuilderList() {
}
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder addChildBuilder() {
return getChildFieldBuilder().addBuilder(
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance());
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder addChildBuilder(
int index) {
index, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.getDefaultInstance());
}
/**
- * <code>repeated .org.opendaylight.controller.mdsal.Node child = 4;</code>
+ * <code>repeated .org.opendaylight.controller.mdsal.Node child = 6;</code>
*/
public java.util.List<org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder>
getChildBuilderList() {
childBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder>(
child_,
- ((bitField0_ & 0x00000008) == 0x00000008),
+ ((bitField0_ & 0x00000020) == 0x00000020),
getParentForChildren(),
isClean());
child_ = null;
return childBuilder_;
}
- // optional string value = 5;
+ // optional string value = 7;
private java.lang.Object value_ = "";
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public boolean hasValue() {
- return ((bitField0_ & 0x00000010) == 0x00000010);
+ return ((bitField0_ & 0x00000040) == 0x00000040);
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public java.lang.String getValue() {
java.lang.Object ref = value_;
}
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public com.google.protobuf.ByteString
getValueBytes() {
}
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public Builder setValue(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000040;
value_ = value;
onChanged();
return this;
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public Builder clearValue() {
- bitField0_ = (bitField0_ & ~0x00000010);
+ bitField0_ = (bitField0_ & ~0x00000040);
value_ = getDefaultInstance().getValue();
onChanged();
return this;
}
/**
- * <code>optional string value = 5;</code>
+ * <code>optional string value = 7;</code>
*/
public Builder setValueBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000010;
+ bitField0_ |= 0x00000040;
value_ = value;
onChanged();
return this;
}
- // optional string valueType = 6;
+ // optional string valueType = 8;
private java.lang.Object valueType_ = "";
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
public boolean hasValueType() {
- return ((bitField0_ & 0x00000020) == 0x00000020);
+ return ((bitField0_ & 0x00000080) == 0x00000080);
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
*/
public java.lang.String getValueType() {
java.lang.Object ref = valueType_;
}
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
+ */
+ public com.google.protobuf.ByteString
+ getValueTypeBytes() {
+ java.lang.Object ref = valueType_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ valueType_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
+ */
+ public Builder setValueType(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000080;
+ valueType_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
+ */
+ public Builder clearValueType() {
+ bitField0_ = (bitField0_ & ~0x00000080);
+ valueType_ = getDefaultInstance().getValueType();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string valueType = 8;</code>
+ *
+ * <pre>
+ * @deprecated(use intValueType)
+ * </pre>
+ */
+ public Builder setValueTypeBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000080;
+ valueType_ = value;
+ onChanged();
+ return this;
+ }
+
+ // optional int32 intValueType = 9;
+ private int intValueType_ ;
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ public boolean hasIntValueType() {
+ return ((bitField0_ & 0x00000100) == 0x00000100);
+ }
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ public int getIntValueType() {
+ return intValueType_;
+ }
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ public Builder setIntValueType(int value) {
+ bitField0_ |= 0x00000100;
+ intValueType_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 intValueType = 9;</code>
+ *
+ * <pre>
+ * instead of valueType
+ * </pre>
+ */
+ public Builder clearIntValueType() {
+ bitField0_ = (bitField0_ & ~0x00000100);
+ intValueType_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;
+ private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierValueBuilder_;
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public boolean hasInstanceIdentifierValue() {
+ return ((bitField0_ & 0x00000200) == 0x00000200);
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue() {
+ if (instanceIdentifierValueBuilder_ == null) {
+ return instanceIdentifierValue_;
+ } else {
+ return instanceIdentifierValueBuilder_.getMessage();
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public Builder setInstanceIdentifierValue(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) {
+ if (instanceIdentifierValueBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ instanceIdentifierValue_ = value;
+ onChanged();
+ } else {
+ instanceIdentifierValueBuilder_.setMessage(value);
+ }
+ bitField0_ |= 0x00000200;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ public Builder setInstanceIdentifierValue(
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) {
+ if (instanceIdentifierValueBuilder_ == null) {
+ instanceIdentifierValue_ = builderForValue.build();
+ onChanged();
+ } else {
+ instanceIdentifierValueBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000200;
+ return this;
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
*/
- public com.google.protobuf.ByteString
- getValueTypeBytes() {
- java.lang.Object ref = valueType_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- valueType_ = b;
- return b;
+ public Builder mergeInstanceIdentifierValue(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) {
+ if (instanceIdentifierValueBuilder_ == null) {
+ if (((bitField0_ & 0x00000200) == 0x00000200) &&
+ instanceIdentifierValue_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) {
+ instanceIdentifierValue_ =
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierValue_).mergeFrom(value).buildPartial();
+ } else {
+ instanceIdentifierValue_ = value;
+ }
+ onChanged();
} else {
- return (com.google.protobuf.ByteString) ref;
+ instanceIdentifierValueBuilder_.mergeFrom(value);
}
+ bitField0_ |= 0x00000200;
+ return this;
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
*/
- public Builder setValueType(
- java.lang.String value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000020;
- valueType_ = value;
- onChanged();
+ public Builder clearInstanceIdentifierValue() {
+ if (instanceIdentifierValueBuilder_ == null) {
+ instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
+ onChanged();
+ } else {
+ instanceIdentifierValueBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000200);
return this;
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
*/
- public Builder clearValueType() {
- bitField0_ = (bitField0_ & ~0x00000020);
- valueType_ = getDefaultInstance().getValueType();
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierValueBuilder() {
+ bitField0_ |= 0x00000200;
onChanged();
- return this;
+ return getInstanceIdentifierValueFieldBuilder().getBuilder();
}
/**
- * <code>optional string valueType = 6;</code>
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
*/
- public Builder setValueTypeBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000020;
- valueType_ = value;
- onChanged();
- return this;
+ public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder() {
+ if (instanceIdentifierValueBuilder_ != null) {
+ return instanceIdentifierValueBuilder_.getMessageOrBuilder();
+ } else {
+ return instanceIdentifierValue_;
+ }
+ }
+ /**
+ * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 10;</code>
+ *
+ * <pre>
+ * Specific values
+ * </pre>
+ */
+ private com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>
+ getInstanceIdentifierValueFieldBuilder() {
+ if (instanceIdentifierValueBuilder_ == null) {
+ instanceIdentifierValueBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>(
+ instanceIdentifierValue_,
+ getParentForChildren(),
+ isClean());
+ instanceIdentifierValue_ = null;
+ }
+ return instanceIdentifierValueBuilder_;
}
- // repeated string bitsValue = 7;
+ // repeated string bitsValue = 11;
private com.google.protobuf.LazyStringList bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
private void ensureBitsValueIsMutable() {
- if (!((bitField0_ & 0x00000040) == 0x00000040)) {
+ if (!((bitField0_ & 0x00000400) == 0x00000400)) {
bitsValue_ = new com.google.protobuf.LazyStringArrayList(bitsValue_);
- bitField0_ |= 0x00000040;
+ bitField0_ |= 0x00000400;
}
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public java.util.List<java.lang.String>
getBitsValueList() {
return java.util.Collections.unmodifiableList(bitsValue_);
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public int getBitsValueCount() {
return bitsValue_.size();
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public java.lang.String getBitsValue(int index) {
return bitsValue_.get(index);
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public com.google.protobuf.ByteString
getBitsValueBytes(int index) {
return bitsValue_.getByteString(index);
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public Builder setBitsValue(
int index, java.lang.String value) {
return this;
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public Builder addBitsValue(
java.lang.String value) {
return this;
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public Builder addAllBitsValue(
java.lang.Iterable<java.lang.String> values) {
return this;
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public Builder clearBitsValue() {
bitsValue_ = com.google.protobuf.LazyStringArrayList.EMPTY;
- bitField0_ = (bitField0_ & ~0x00000040);
+ bitField0_ = (bitField0_ & ~0x00000400);
onChanged();
return this;
}
/**
- * <code>repeated string bitsValue = 7;</code>
+ * <code>repeated string bitsValue = 11;</code>
+ *
+ * <pre>
+ * intValueType = Bits
+ * </pre>
*/
public Builder addBitsValueBytes(
com.google.protobuf.ByteString value) {
return this;
}
- // optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;
- private org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
- private com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> instanceIdentifierValueBuilder_;
+ // repeated string code = 12;
+ private com.google.protobuf.LazyStringList code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ private void ensureCodeIsMutable() {
+ if (!((bitField0_ & 0x00000800) == 0x00000800)) {
+ code_ = new com.google.protobuf.LazyStringArrayList(code_);
+ bitField0_ |= 0x00000800;
+ }
+ }
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public boolean hasInstanceIdentifierValue() {
- return ((bitField0_ & 0x00000080) == 0x00000080);
+ public java.util.List<java.lang.String>
+ getCodeList() {
+ return java.util.Collections.unmodifiableList(code_);
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier getInstanceIdentifierValue() {
- if (instanceIdentifierValueBuilder_ == null) {
- return instanceIdentifierValue_;
- } else {
- return instanceIdentifierValueBuilder_.getMessage();
- }
+ public int getCodeCount() {
+ return code_.size();
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public Builder setInstanceIdentifierValue(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) {
- if (instanceIdentifierValueBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- instanceIdentifierValue_ = value;
- onChanged();
- } else {
- instanceIdentifierValueBuilder_.setMessage(value);
- }
- bitField0_ |= 0x00000080;
- return this;
+ public java.lang.String getCode(int index) {
+ return code_.get(index);
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public Builder setInstanceIdentifierValue(
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder builderForValue) {
- if (instanceIdentifierValueBuilder_ == null) {
- instanceIdentifierValue_ = builderForValue.build();
- onChanged();
- } else {
- instanceIdentifierValueBuilder_.setMessage(builderForValue.build());
- }
- bitField0_ |= 0x00000080;
- return this;
+ public com.google.protobuf.ByteString
+ getCodeBytes(int index) {
+ return code_.getByteString(index);
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public Builder mergeInstanceIdentifierValue(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier value) {
- if (instanceIdentifierValueBuilder_ == null) {
- if (((bitField0_ & 0x00000080) == 0x00000080) &&
- instanceIdentifierValue_ != org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance()) {
- instanceIdentifierValue_ =
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.newBuilder(instanceIdentifierValue_).mergeFrom(value).buildPartial();
- } else {
- instanceIdentifierValue_ = value;
- }
- onChanged();
- } else {
- instanceIdentifierValueBuilder_.mergeFrom(value);
- }
- bitField0_ |= 0x00000080;
+ public Builder setCode(
+ int index, java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureCodeIsMutable();
+ code_.set(index, value);
+ onChanged();
return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public Builder clearInstanceIdentifierValue() {
- if (instanceIdentifierValueBuilder_ == null) {
- instanceIdentifierValue_ = org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.getDefaultInstance();
- onChanged();
- } else {
- instanceIdentifierValueBuilder_.clear();
- }
- bitField0_ = (bitField0_ & ~0x00000080);
+ public Builder addCode(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureCodeIsMutable();
+ code_.add(value);
+ onChanged();
return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder getInstanceIdentifierValueBuilder() {
- bitField0_ |= 0x00000080;
+ public Builder addAllCode(
+ java.lang.Iterable<java.lang.String> values) {
+ ensureCodeIsMutable();
+ super.addAll(values, code_);
onChanged();
- return getInstanceIdentifierValueFieldBuilder().getBuilder();
+ return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- public org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder getInstanceIdentifierValueOrBuilder() {
- if (instanceIdentifierValueBuilder_ != null) {
- return instanceIdentifierValueBuilder_.getMessageOrBuilder();
- } else {
- return instanceIdentifierValue_;
- }
+ public Builder clearCode() {
+ code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000800);
+ onChanged();
+ return this;
}
/**
- * <code>optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8;</code>
+ * <code>repeated string code = 12;</code>
+ *
+ * <pre>
+ * A list of string codes which can be used for any repeated strings in the NormalizedNode
+ * </pre>
*/
- private com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>
- getInstanceIdentifierValueFieldBuilder() {
- if (instanceIdentifierValueBuilder_ == null) {
- instanceIdentifierValueBuilder_ = new com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>(
- instanceIdentifierValue_,
- getParentForChildren(),
- isClean());
- instanceIdentifierValue_ = null;
- }
- return instanceIdentifierValueBuilder_;
+ public Builder addCodeBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureCodeIsMutable();
+ code_.add(value);
+ onChanged();
+ return this;
}
// @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Node)
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_org_opendaylight_controller_mdsal_Attribute_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_fieldAccessorTable;
private static com.google.protobuf.Descriptors.Descriptor
internal_static_org_opendaylight_controller_mdsal_QName_descriptor;
private static
java.lang.String[] descriptorData = {
"\n\014Common.proto\022!org.opendaylight.control" +
"ler.mdsal\"6\n\tAttribute\022\014\n\004name\030\001 \002(\t\022\r\n\005" +
- "value\030\002 \001(\t\022\014\n\004type\030\003 \001(\t\"\026\n\005QName\022\r\n\005va" +
- "lue\030\001 \002(\t\"\251\001\n\014PathArgument\022\r\n\005value\030\001 \002(" +
- "\t\022\014\n\004type\030\002 \001(\t\022:\n\010nodeType\030\003 \001(\0132(.org." +
- "opendaylight.controller.mdsal.QName\022@\n\na" +
- "ttributes\030\004 \003(\0132,.org.opendaylight.contr" +
- "oller.mdsal.Attribute\"X\n\022InstanceIdentif" +
- "ier\022B\n\targuments\030\001 \003(\0132/.org.opendayligh" +
- "t.controller.mdsal.PathArgument\"\251\002\n\004Node",
- "\022\014\n\004path\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022@\n\nattribut" +
- "es\030\003 \003(\0132,.org.opendaylight.controller.m" +
- "dsal.Attribute\0226\n\005child\030\004 \003(\0132\'.org.open" +
- "daylight.controller.mdsal.Node\022\r\n\005value\030" +
- "\005 \001(\t\022\021\n\tvalueType\030\006 \001(\t\022\021\n\tbitsValue\030\007 " +
- "\003(\t\022V\n\027instanceIdentifierValue\030\010 \001(\01325.o" +
- "rg.opendaylight.controller.mdsal.Instanc" +
- "eIdentifier\"`\n\tContainer\022\022\n\nparentPath\030\001" +
- " \002(\t\022?\n\016normalizedNode\030\002 \001(\0132\'.org.opend" +
- "aylight.controller.mdsal.Node\"\246\001\n\014NodeMa",
- "pEntry\022U\n\026instanceIdentifierPath\030\001 \002(\01325" +
- ".org.opendaylight.controller.mdsal.Insta" +
- "nceIdentifier\022?\n\016normalizedNode\030\002 \001(\0132\'." +
- "org.opendaylight.controller.mdsal.Node\"N" +
- "\n\007NodeMap\022C\n\nmapEntries\030\001 \003(\0132/.org.open" +
- "daylight.controller.mdsal.NodeMapEntryBO" +
- "\n5org.opendaylight.controller.protobuff." +
- "messages.commonB\026NormalizedNodeMessages"
+ "value\030\002 \001(\t\022\014\n\004type\030\003 \001(\t\"l\n\025PathArgumen" +
+ "tAttribute\0226\n\004name\030\001 \001(\0132(.org.opendayli" +
+ "ght.controller.mdsal.QName\022\r\n\005value\030\002 \001(" +
+ "\t\022\014\n\004type\030\003 \001(\005\"N\n\005QName\022\r\n\005value\030\001 \001(\t\022" +
+ "\021\n\tnamespace\030\002 \001(\005\022\020\n\010revision\030\003 \001(\005\022\021\n\t" +
+ "localName\030\004 \001(\005\"\207\002\n\014PathArgument\022\r\n\005valu" +
+ "e\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022:\n\010nodeType\030\003 \001(\0132" +
+ "(.org.opendaylight.controller.mdsal.QNam",
+ "e\022K\n\tattribute\030\004 \003(\01328.org.opendaylight." +
+ "controller.mdsal.PathArgumentAttribute\022@" +
+ "\n\nattributes\030\005 \003(\0132,.org.opendaylight.co" +
+ "ntroller.mdsal.Attribute\022\017\n\007intType\030\006 \001(" +
+ "\005\"X\n\022InstanceIdentifier\022B\n\targuments\030\001 \003" +
+ "(\0132/.org.opendaylight.controller.mdsal.P" +
+ "athArgument\"\245\003\n\004Node\022\014\n\004path\030\001 \001(\t\022\014\n\004ty" +
+ "pe\030\002 \001(\t\022E\n\014pathArgument\030\003 \001(\0132/.org.ope" +
+ "ndaylight.controller.mdsal.PathArgument\022" +
+ "\017\n\007intType\030\004 \001(\005\022@\n\nattributes\030\005 \003(\0132,.o",
+ "rg.opendaylight.controller.mdsal.Attribu" +
+ "te\0226\n\005child\030\006 \003(\0132\'.org.opendaylight.con" +
+ "troller.mdsal.Node\022\r\n\005value\030\007 \001(\t\022\021\n\tval" +
+ "ueType\030\010 \001(\t\022\024\n\014intValueType\030\t \001(\005\022V\n\027in" +
+ "stanceIdentifierValue\030\n \001(\01325.org.openda" +
+ "ylight.controller.mdsal.InstanceIdentifi" +
+ "er\022\021\n\tbitsValue\030\013 \003(\t\022\014\n\004code\030\014 \003(\t\"`\n\tC" +
+ "ontainer\022\022\n\nparentPath\030\001 \002(\t\022?\n\016normaliz" +
+ "edNode\030\002 \001(\0132\'.org.opendaylight.controll" +
+ "er.mdsal.Node\"\246\001\n\014NodeMapEntry\022U\n\026instan",
+ "ceIdentifierPath\030\001 \002(\01325.org.opendayligh" +
+ "t.controller.mdsal.InstanceIdentifier\022?\n" +
+ "\016normalizedNode\030\002 \001(\0132\'.org.opendaylight" +
+ ".controller.mdsal.Node\"N\n\007NodeMap\022C\n\nmap" +
+ "Entries\030\001 \003(\0132/.org.opendaylight.control" +
+ "ler.mdsal.NodeMapEntryBO\n5org.opendaylig" +
+ "ht.controller.protobuff.messages.commonB" +
+ "\026NormalizedNodeMessages"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_Attribute_descriptor,
new java.lang.String[] { "Name", "Value", "Type", });
- internal_static_org_opendaylight_controller_mdsal_QName_descriptor =
+ internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_descriptor =
getDescriptor().getMessageTypes().get(1);
+ internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_org_opendaylight_controller_mdsal_PathArgumentAttribute_descriptor,
+ new java.lang.String[] { "Name", "Value", "Type", });
+ internal_static_org_opendaylight_controller_mdsal_QName_descriptor =
+ getDescriptor().getMessageTypes().get(2);
internal_static_org_opendaylight_controller_mdsal_QName_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_QName_descriptor,
- new java.lang.String[] { "Value", });
+ new java.lang.String[] { "Value", "Namespace", "Revision", "LocalName", });
internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor =
- getDescriptor().getMessageTypes().get(2);
+ getDescriptor().getMessageTypes().get(3);
internal_static_org_opendaylight_controller_mdsal_PathArgument_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_PathArgument_descriptor,
- new java.lang.String[] { "Value", "Type", "NodeType", "Attributes", });
+ new java.lang.String[] { "Value", "Type", "NodeType", "Attribute", "Attributes", "IntType", });
internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor =
- getDescriptor().getMessageTypes().get(3);
+ getDescriptor().getMessageTypes().get(4);
internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor,
new java.lang.String[] { "Arguments", });
internal_static_org_opendaylight_controller_mdsal_Node_descriptor =
- getDescriptor().getMessageTypes().get(4);
+ getDescriptor().getMessageTypes().get(5);
internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_Node_descriptor,
- new java.lang.String[] { "Path", "Type", "Attributes", "Child", "Value", "ValueType", "BitsValue", "InstanceIdentifierValue", });
+ new java.lang.String[] { "Path", "Type", "PathArgument", "IntType", "Attributes", "Child", "Value", "ValueType", "IntValueType", "InstanceIdentifierValue", "BitsValue", "Code", });
internal_static_org_opendaylight_controller_mdsal_Container_descriptor =
- getDescriptor().getMessageTypes().get(5);
+ getDescriptor().getMessageTypes().get(6);
internal_static_org_opendaylight_controller_mdsal_Container_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_Container_descriptor,
new java.lang.String[] { "ParentPath", "NormalizedNode", });
internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor =
- getDescriptor().getMessageTypes().get(6);
+ getDescriptor().getMessageTypes().get(7);
internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_NodeMapEntry_descriptor,
new java.lang.String[] { "InstanceIdentifierPath", "NormalizedNode", });
internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor =
- getDescriptor().getMessageTypes().get(7);
+ getDescriptor().getMessageTypes().get(8);
internal_static_org_opendaylight_controller_mdsal_NodeMap_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_opendaylight_controller_mdsal_NodeMap_descriptor,
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(),
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(),
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.getDescriptor(),
}, assigner);
}
*/
public static final
com.google.protobuf.GeneratedMessage.GeneratedExtension<
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload,
org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification> modification = com.google.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.CompositeModification.class,
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
- org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages.getDescriptor(),
+ org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages.getDescriptor(),
org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.getDescriptor(),
org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.getDescriptor(),
}, assigner);
public final boolean isInitialized() {
if (!hasInstanceIdentifierPathArguments()) {
-
+
return false;
}
if (!getInstanceIdentifierPathArguments().isInitialized()) {
-
+
return false;
}
return true;
* <code>required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1;</code>
*/
private com.google.protobuf.SingleFieldBuilder<
- org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>
+ org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder>
getInstanceIdentifierPathArgumentsFieldBuilder() {
if (instanceIdentifierPathArgumentsBuilder_ == null) {
instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder<
public final boolean isInitialized() {
if (!hasExists()) {
-
+
return false;
}
return true;
package org.opendaylight.controller.cluster.raft;
-option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
+option java_package = "org.opendaylight.controller.protobuff.messages.cluster.raft";
option java_outer_classname = "AppendEntriesMessages";
option optimize_for = SPEED;
optional string type=3;
}
+message PathArgumentAttribute{
+ optional QName name =1;
+ optional string value=2;
+ optional int32 type=3;
+}
+
+
message QName {
- required string value=1;
+ optional string value=1; // @deprecated
+ optional int32 namespace=2;
+ optional int32 revision=3;
+ optional int32 localName=4;
}
message PathArgument {
- required string value=1;
- optional string type=2; //NodeIdentifier, NodeWithValue, NodeIdentifierWithPredicates
+ optional string value=1; // @deprecated
+ optional string type=2; // @deprecated
+
optional QName nodeType=3;
- repeated Attribute attributes=4;
+ repeated PathArgumentAttribute attribute=4;
+ repeated Attribute attributes=5; // @deprecated For backward compatibility (see InstanceIdentifierUtils)
+ optional int32 intType = 6;
}
message InstanceIdentifier {
}
message Node{
- optional string path = 1;
- optional string type = 2;
- repeated Attribute attributes = 3;
- repeated Node child=4;
- optional string value = 5;
- optional string valueType = 6;
- repeated string bitsValue = 7;
- optional InstanceIdentifier instanceIdentifierValue = 8;
+ optional string path = 1; // @deprecated(use pathArgument)
+ optional string type = 2; // @deprecated(use intType)
+ optional PathArgument pathArgument = 3;
+ optional int32 intType = 4;
+
+ repeated Attribute attributes = 5;
+
+ repeated Node child = 6;
+
+ optional string value = 7;
+ optional string valueType = 8; // @deprecated(use intValueType)
+ optional int32 intValueType = 9; // instead of valueType
+
+ // Specific values
+ optional InstanceIdentifier instanceIdentifierValue = 10; // intValueType = YangInstanceIdentifier
+ repeated string bitsValue = 11; // intValueType = Bits
+
+ repeated string code = 12; // A list of string codes which can be used for any repeated strings in the NormalizedNode
}
message Container{
import "AppendEntriesMessages.proto";
-option java_package = "org.opendaylight.controller.cluster.example.protobuff.messages";
+option java_package = "org.opendaylight.controller.protobuff.messages.cluster.example";
option java_outer_classname = "KeyValueMessages";
option optimize_for = SPEED;
import "AppendEntriesMessages.proto";
-package org.opendaylight.controller.cluster.raft;
+package org.opendaylight.controller.cluster.raft.test;
-option java_package = "org.opendaylight.controller.cluster.raft.protobuff.messages";
+option java_package = "org.opendaylight.controller.protobuff.messages.cluster.raft.test";
option java_outer_classname = "MockPayloadMessages";
extend AppendEntries.ReplicatedLogEntry.Payload {
package org.opendaylight.controller.cluster.datastore.node;
-import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeGetter;
import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator;
+import org.opendaylight.controller.cluster.datastore.node.utils.PathUtils;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
import org.opendaylight.controller.cluster.datastore.util.TestModel;
import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container;
import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import java.util.ArrayList;
import java.util.List;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
public class NormalizedNodeToNodeCodecTest {
}
private YangInstanceIdentifier instanceIdentifierFromString(String s) {
-
- String[] ids = s.split("/");
-
- List<YangInstanceIdentifier.PathArgument> pathArguments = new ArrayList<>();
- for (String nodeId : ids) {
- if (!"".equals(nodeId)) {
- pathArguments.add(NodeIdentifierFactory.getArgument(nodeId));
- }
- }
- final YangInstanceIdentifier instanceIdentifier =
- YangInstanceIdentifier.create(pathArguments);
- return instanceIdentifier;
+ return PathUtils.toYangInstanceIdentifier(s);
}
-
@Test
public void testNormalizeNodeAttributesToProtoBuffNode() {
final NormalizedNode<?, ?> documentOne = TestModel.createTestContainer();
NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id);
new NormalizedNodeNavigator(normalizedNodeGetter).navigate(
- YangInstanceIdentifier.builder().build().toString(), documentOne);
+ PathUtils.toString(YangInstanceIdentifier.builder().build()), documentOne);
// Validate the value of id can be retrieved from the normalized node
NormalizedNode output = normalizedNodeGetter.getOutput();
assertNotNull(container);
assertEquals(id, container.getParentPath() + "/"
- + container.getNormalizedNode().getPath());
+ + NormalizedNodeSerializer.deSerialize(container.getNormalizedNode(),
+ container.getNormalizedNode().getPathArgument()));
// Decode the normalized node from the ProtocolBuffer form
// first get the node representation of normalized node
.decode(
instanceIdentifierFromString("/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"),
container.getNormalizedNode());
- assertNotNull(decode != null);
+ assertNotNull(decode);
// let us ensure that the return decode normalized node encode returns same container
Container containerResult =
.build(), decode);
assertEquals(container.getParentPath(), containerResult.getParentPath());
- assertEquals(container.getNormalizedNode().getChildCount(), container
- .getNormalizedNode().getChildCount());
- Assert.assertEquals(containerResult.getNormalizedNode().getChildCount(),
+ assertEquals(containerResult.getNormalizedNode().getChildCount(),
container.getNormalizedNode().getChildCount());
// check first level children are proper
for (Node resultChild : childrenResult) {
bFound = false;
for (Node originalChild : childrenOriginal) {
- if (originalChild.getPath().equals(resultChild.getPath())
- && resultChild.getType().equals(resultChild.getType())) {
+
+ YangInstanceIdentifier.PathArgument result = NormalizedNodeSerializer.deSerialize(
+ containerResult.getNormalizedNode(),
+ resultChild.getPathArgument());
+
+ YangInstanceIdentifier.PathArgument original = NormalizedNodeSerializer.deSerialize(
+ container.getNormalizedNode(),
+ originalChild.getPathArgument());
+
+ if (original.equals(result)
+ && resultChild.getIntType() == resultChild.getIntType()) {
bFound = true;
break;
}
}
- Assert.assertTrue(bFound);
+ assertTrue(bFound);
}
}
--- /dev/null
+package org.opendaylight.controller.cluster.datastore.node.utils;
+
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class PathUtilsTest {
+
+ @Test
+ public void getParentPath(){
+ assertEquals("", PathUtils.getParentPath("foobar"));
+ assertEquals("", PathUtils.getParentPath("/a"));
+ assertEquals("/a", PathUtils.getParentPath("/a/b"));
+ assertEquals("/a/b", PathUtils.getParentPath("/a/b/c"));
+ assertEquals("/a/b", PathUtils.getParentPath("a/b/c"));
+ }
+
+ @Test
+ public void toStringNodeIdentifier(){
+ YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifier();
+
+ String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test";
+
+ assertEquals(expected , PathUtils.toString(pathArgument));
+ }
+
+ @Test
+ public void toStringAugmentationIdentifier(){
+ String expected = "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}";
+
+ YangInstanceIdentifier.PathArgument pathArgument = augmentationIdentifier();
+
+ assertEquals(expected, PathUtils.toString(pathArgument));
+ }
+
+ @Test
+ public void toStringNodeWithValue(){
+
+ YangInstanceIdentifier.PathArgument pathArgument = nodeWithValue();
+
+ String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]";
+
+ assertEquals(expected, PathUtils.toString(pathArgument));
+ }
+
+
+ @Test
+ public void toStringNodeIdentifierWithPredicates(){
+
+ YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifierWithPredicates();
+
+ String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]";
+
+ assertEquals(expected, PathUtils.toString(pathArgument));
+ }
+
+ @Test
+ public void toStringYangInstanceIdentifier(){
+
+ YangInstanceIdentifier path =
+ YangInstanceIdentifier.create(nodeIdentifier())
+ .node(nodeIdentifierWithPredicates())
+ .node(augmentationIdentifier()).node(nodeWithValue());
+
+
+ String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test/" +
+ "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" +
+ "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}/" +
+ "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]";
+
+ assertEquals(expected, PathUtils.toString(path));
+
+ }
+
+ @Test
+ public void toYangInstanceIdentifier(){
+ String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test/" +
+ "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" +
+ "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}/" +
+ "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]";
+
+ YangInstanceIdentifier yangInstanceIdentifier =
+ PathUtils.toYangInstanceIdentifier(expected);
+
+ String actual = PathUtils.toString(yangInstanceIdentifier);
+
+ assertEquals(expected, actual);
+
+ }
+
+ private YangInstanceIdentifier.NodeIdentifier nodeIdentifier(){
+ return new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME);
+ }
+
+ private YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier(){
+ Set<QName> childNames = new HashSet();
+ childNames.add(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics"));
+
+ return new YangInstanceIdentifier.AugmentationIdentifier(childNames);
+ }
+
+ private YangInstanceIdentifier.NodeWithValue nodeWithValue(){
+ return new YangInstanceIdentifier.NodeWithValue(TestModel.TEST_QNAME, Integer.valueOf(100));
+ }
+
+ private YangInstanceIdentifier.NodeIdentifierWithPredicates nodeIdentifierWithPredicates(){
+ Map<QName, Object> keys = new HashMap<>();
+
+ keys.put(TestModel.ID_QNAME, Integer.valueOf(100));
+
+ return new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.TEST_QNAME, keys);
+ }
+}
--- /dev/null
+package org.opendaylight.controller.cluster.datastore.node.utils;
+
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.yangtools.yang.common.QName;
+
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+public class QNameFactoryTest {
+
+ @Test
+ public void testBasic(){
+ QName expected = TestModel.AUG_NAME_QNAME;
+ QName created = QNameFactory.create(expected.toString());
+
+ assertFalse( expected == created);
+
+ assertEquals(expected, created);
+
+ QName cached = QNameFactory.create(expected.toString());
+
+ assertEquals(expected, cached);
+
+ assertTrue( cached == created );
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class NormalizedNodeSerializerTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void testSerializeDeSerialize(){
+
+ // This test basically serializes and deSerializes a largish document
+ // which contains most of the types of nodes that go into a normalized
+ // node and uses several value types as well. It is in general a good
+ // sanity test which could be augmented with specific unit tests.
+
+ long start = System.nanoTime();
+
+ NormalizedNode<?, ?> expectedNode =
+ TestModel.createDocumentOne(TestModel.createTestContext());
+
+ NormalizedNodeMessages.Node expected = NormalizedNodeSerializer
+ .serialize(expectedNode);
+
+ System.out.println("Serialize Time = " + (System.nanoTime() - start)/1000000);
+
+ System.out.println("Serialized Size = " + expected.getSerializedSize());
+
+ System.out.println(expected.toString());
+
+ start = System.nanoTime();
+
+ NormalizedNode actualNode =
+ NormalizedNodeSerializer.deSerialize(expected);
+
+ System.out.println("DeSerialize Time = " + (System.nanoTime() - start)/1000000);
+
+ // Compare the original normalized node to the normalized node that was
+ // created by serializing the original node and deSerializing it back.
+ assertEquals(expectedNode, actualNode);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSerializeNullNormalizedNode(){
+ assertNotNull(NormalizedNodeSerializer.serialize(null));
+ }
+
+ @Test
+ public void testDeSerializeNullProtocolBufferNode(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("node should not be null");
+
+ NormalizedNodeSerializer.deSerialize(null);
+ }
+
+ @Test
+ public void testDeSerializePathArgumentNullNode(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("node should not be null");
+
+ NormalizedNodeSerializer
+ .deSerialize(null, NormalizedNodeMessages.PathArgument.getDefaultInstance());
+ }
+
+ @Test
+ public void testDeSerializePathArgumentNullPathArgument(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("pathArgument should not be null");
+
+ NormalizedNodeSerializer.deSerialize(NormalizedNodeMessages.Node.getDefaultInstance() , null);
+ }
+
+ @Test
+ public void testDeSerializePathArgument(){
+
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+
+ nodeBuilder.addCode("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test1");
+ nodeBuilder.addCode("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test");
+
+
+ nodeBuilder.addCode("2014-04-13");
+ nodeBuilder.addCode("2014-05-13");
+ nodeBuilder.addCode("2014-03-13");
+
+ nodeBuilder.addCode("dummy1");
+ nodeBuilder.addCode("dummy2");
+ nodeBuilder.addCode("dummy3");
+ nodeBuilder.addCode("capability");
+
+
+
+ NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
+
+ pathBuilder.setIntType(PathArgumentType.NODE_IDENTIFIER.ordinal());
+
+ NormalizedNodeMessages.QName.Builder qNameBuilder = NormalizedNodeMessages.QName.newBuilder();
+ qNameBuilder.setNamespace(1);
+ qNameBuilder.setRevision(4);
+ qNameBuilder.setLocalName(8);
+
+ pathBuilder.setNodeType(qNameBuilder);
+
+ YangInstanceIdentifier.PathArgument pathArgument =
+ NormalizedNodeSerializer
+ .deSerialize(nodeBuilder.build(), pathBuilder.build());
+
+ assertNotNull(pathArgument);
+
+ assertEquals("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", pathArgument.getNodeType().getNamespace().toString());
+ assertEquals("2014-03-13", pathArgument.getNodeType().getFormattedRevision());
+ assertEquals("capability", pathArgument.getNodeType().getLocalName());
+ }
+
+
+}
--- /dev/null
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class PathArgumentSerializerTest{
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void testSerializeNullContext(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("context should not be null");
+
+ PathArgumentSerializer.serialize(null, mock(
+ YangInstanceIdentifier.PathArgument.class));
+ }
+
+ @Test
+ public void testSerializeNullPathArgument(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("pathArgument should not be null");
+
+ PathArgumentSerializer.serialize(mock(
+ NormalizedNodeSerializationContext.class), null);
+
+ }
+
+ @Test
+ public void testDeSerializeNullContext(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("context should not be null");
+
+ PathArgumentSerializer.deSerialize(null, NormalizedNodeMessages.PathArgument.getDefaultInstance());
+
+ }
+
+ @Test
+ public void testDeSerializeNullPathArgument(){
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("pathArgument should not be null");
+
+ PathArgumentSerializer.deSerialize(mock(NormalizedNodeDeSerializationContext.class), null);
+
+ }
+
+ @Test
+ public void testSerializeNodeIdentifier(){
+ NormalizedNodeSerializationContext serializationContext =
+ mock(NormalizedNodeSerializationContext.class);
+
+ when(serializationContext.addLocalName(anyString())).thenReturn(5);
+ when(serializationContext.addNamespace(any(URI.class))).thenReturn(10);
+ when(serializationContext.addRevision(any(Date.class))).thenReturn(11);
+
+ NormalizedNodeMessages.PathArgument actual = PathArgumentSerializer
+ .serialize(serializationContext,
+ new YangInstanceIdentifier.NodeIdentifier(
+ TestModel.TEST_QNAME));
+
+ assertEquals(PathArgumentType.NODE_IDENTIFIER.ordinal(), actual.getIntType());
+ assertEquals(5, actual.getNodeType().getLocalName());
+ assertEquals(10, actual.getNodeType().getNamespace());
+ assertEquals(11, actual.getNodeType().getRevision());
+
+
+ }
+
+ @Test
+ public void testSerializeNodeIdentifierWithValue(){
+ NormalizedNodeSerializationContext serializationContext =
+ mock(NormalizedNodeSerializationContext.class);
+
+ when(serializationContext.addLocalName(anyString())).thenReturn(5);
+ when(serializationContext.addNamespace(any(URI.class))).thenReturn(10);
+ when(serializationContext.addRevision(any(Date.class))).thenReturn(11);
+
+ NormalizedNodeMessages.PathArgument actual = PathArgumentSerializer
+ .serialize(serializationContext,
+ new YangInstanceIdentifier.NodeWithValue(
+ TestModel.TEST_QNAME, "foo"));
+
+ assertEquals(PathArgumentType.NODE_IDENTIFIER_WITH_VALUE.ordinal(), actual.getIntType());
+ assertEquals(5, actual.getNodeType().getLocalName());
+ assertEquals(10, actual.getNodeType().getNamespace());
+ assertEquals(11, actual.getNodeType().getRevision());
+ assertEquals("foo", actual.getAttribute(0).getValue());
+
+
+ }
+
+ @Test
+ public void testSerializeNodeIdentifierWithPredicates(){
+ NormalizedNodeSerializationContext serializationContext =
+ mock(NormalizedNodeSerializationContext.class);
+
+
+ when(serializationContext.addLocalName("test")).thenReturn(5);
+ when(serializationContext.addLocalName("child-name")).thenReturn(55);
+
+ when(serializationContext.addNamespace(TestModel.TEST_QNAME.getNamespace())).thenReturn(
+ 10);
+ when(serializationContext.addNamespace(TestModel.CHILD_NAME_QNAME.getNamespace())).thenReturn(66);
+
+ when(serializationContext.addRevision(TestModel.TEST_QNAME.getRevision())).thenReturn(
+ 11);
+ when(serializationContext.addRevision(TestModel.CHILD_NAME_QNAME.getRevision())).thenReturn(77);
+
+ Map<QName, Object> predicates = new HashMap<>();
+
+ predicates.put(TestModel.CHILD_NAME_QNAME, "foobar");
+
+ NormalizedNodeMessages.PathArgument actual = PathArgumentSerializer
+ .serialize(serializationContext,
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ TestModel.TEST_QNAME, predicates));
+
+ assertEquals(PathArgumentType.NODE_IDENTIFIER_WITH_PREDICATES.ordinal(), actual.getIntType());
+ assertEquals(5, actual.getNodeType().getLocalName());
+ assertEquals(10, actual.getNodeType().getNamespace());
+ assertEquals(11, actual.getNodeType().getRevision());
+
+ assertEquals(55, actual.getAttribute(0).getName().getLocalName());
+ assertEquals(66, actual.getAttribute(0).getName().getNamespace());
+ assertEquals(77, actual.getAttribute(0).getName().getRevision());
+
+ assertEquals("foobar", actual.getAttribute(0).getValue());
+
+
+ }
+
+ @Test
+ public void testSerializeAugmentationIdentifier(){
+ NormalizedNodeSerializationContext serializationContext =
+ mock(NormalizedNodeSerializationContext.class);
+
+ when(serializationContext.addLocalName(anyString())).thenReturn(55);
+ when(serializationContext.addNamespace(any(URI.class))).thenReturn(66);
+ when(serializationContext.addRevision(any(Date.class))).thenReturn(77);
+
+ NormalizedNodeMessages.PathArgument actual = PathArgumentSerializer
+ .serialize(serializationContext,
+ new YangInstanceIdentifier.AugmentationIdentifier(
+ ImmutableSet.of(TestModel.TEST_QNAME)));
+
+ assertEquals(PathArgumentType.AUGMENTATION_IDENTIFIER.ordinal(), actual.getIntType());
+
+ assertEquals(55, actual.getAttribute(0).getName().getLocalName());
+ assertEquals(66, actual.getAttribute(0).getName().getNamespace());
+ assertEquals(77, actual.getAttribute(0).getName().getRevision());
+
+ }
+
+ @Test
+ public void testDeSerializeNodeIdentifier(){
+
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
+ NormalizedNodeMessages.QName.Builder qNameBuilder = NormalizedNodeMessages.QName.newBuilder();
+
+ qNameBuilder.setNamespace(0);
+ qNameBuilder.setRevision(1);
+ qNameBuilder.setLocalName(2);
+
+ pathBuilder.setNodeType(qNameBuilder);
+ pathBuilder.setIntType(PathArgumentType.NODE_IDENTIFIER.ordinal());
+
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getNamespace().toString());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getFormattedRevision());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getLocalName());
+
+ YangInstanceIdentifier.PathArgument pathArgument =
+ NormalizedNodeSerializer
+ .deSerialize(nodeBuilder.build(), pathBuilder.build());
+
+ assertEquals(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME), pathArgument);
+
+ }
+
+ @Test
+ public void testDeSerializeNodeWithValue(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
+ NormalizedNodeMessages.QName.Builder qNameBuilder = NormalizedNodeMessages.QName.newBuilder();
+
+ qNameBuilder.setNamespace(0);
+ qNameBuilder.setRevision(1);
+ qNameBuilder.setLocalName(2);
+
+ pathBuilder.setNodeType(qNameBuilder);
+ pathBuilder.setIntType(PathArgumentType.NODE_IDENTIFIER_WITH_VALUE.ordinal());
+ pathBuilder.addAttribute(
+ NormalizedNodeMessages.PathArgumentAttribute.newBuilder()
+ .setValue("foo").setType(ValueType.STRING_TYPE.ordinal()));
+
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getNamespace().toString());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getFormattedRevision());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getLocalName());
+
+ YangInstanceIdentifier.PathArgument pathArgument =
+ NormalizedNodeSerializer
+ .deSerialize(nodeBuilder.build(), pathBuilder.build());
+
+ assertEquals(new YangInstanceIdentifier.NodeWithValue(TestModel.TEST_QNAME, "foo"), pathArgument);
+
+ }
+ @Test
+ public void testDeSerializeNodeIdentifierWithPredicates(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
+ NormalizedNodeMessages.QName.Builder qNameBuilder = NormalizedNodeMessages.QName.newBuilder();
+
+ qNameBuilder.setNamespace(0);
+ qNameBuilder.setRevision(1);
+ qNameBuilder.setLocalName(2);
+
+ pathBuilder.setNodeType(qNameBuilder);
+ pathBuilder.setIntType(PathArgumentType.NODE_IDENTIFIER_WITH_PREDICATES.ordinal());
+ pathBuilder.addAttribute(NormalizedNodeMessages.PathArgumentAttribute.newBuilder().setName(qNameBuilder).setValue(
+ "foo").setType(ValueType.STRING_TYPE.ordinal()));
+
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getNamespace().toString());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getFormattedRevision());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getLocalName());
+
+ YangInstanceIdentifier.PathArgument pathArgument =
+ NormalizedNodeSerializer
+ .deSerialize(nodeBuilder.build(), pathBuilder.build());
+
+ assertEquals(new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.TEST_QNAME,
+ ImmutableMap.<QName, Object>of(TestModel.TEST_QNAME, "foo")), pathArgument);
+
+ }
+ @Test
+ public void testDeSerializeNodeAugmentationIdentifier(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
+ NormalizedNodeMessages.QName.Builder qNameBuilder = NormalizedNodeMessages.QName.newBuilder();
+
+ qNameBuilder.setNamespace(0);
+ qNameBuilder.setRevision(1);
+ qNameBuilder.setLocalName(2);
+
+ pathBuilder.setIntType(PathArgumentType.AUGMENTATION_IDENTIFIER.ordinal());
+ pathBuilder.addAttribute(NormalizedNodeMessages.PathArgumentAttribute.newBuilder().setName(qNameBuilder).setType(ValueType.STRING_TYPE.ordinal()));
+
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getNamespace().toString());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getFormattedRevision());
+ nodeBuilder.addCode(TestModel.TEST_QNAME.getLocalName());
+
+ YangInstanceIdentifier.PathArgument pathArgument =
+ NormalizedNodeSerializer
+ .deSerialize(nodeBuilder.build(), pathBuilder.build());
+
+ assertEquals(new YangInstanceIdentifier.AugmentationIdentifier(ImmutableSet.of(TestModel.TEST_QNAME)), pathArgument);
+
+ }
+
+
+
+}
--- /dev/null
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public class ValueSerializerTest{
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void testSerializeShort(){
+ short v1 = 5;
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.SHORT_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("5", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.SHORT_TYPE.ordinal(), builder1.getType());
+ assertEquals("5", builder.getValue());
+
+ }
+
+ @Test
+ public void testSerializeInteger(){
+ String hexNumber = "f3";
+
+ Integer expected = Integer.valueOf(hexNumber, 16);
+
+
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), expected);
+
+ assertEquals(ValueType.INT_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("243", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), expected);
+
+ assertEquals(ValueType.INT_TYPE.ordinal(), builder1.getType());
+ assertEquals("243", builder1.getValue());
+
+
+ }
+
+
+ @Test
+ public void testSerializeLong(){
+ long v1 = 5;
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.LONG_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("5", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.LONG_TYPE.ordinal(), builder1.getType());
+ assertEquals("5", builder1.getValue());
+
+ }
+
+ @Test
+ public void testSerializeByte(){
+ byte v1 = 5;
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BYTE_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("5", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BYTE_TYPE.ordinal(), builder1.getType());
+ assertEquals("5", builder1.getValue());
+
+ }
+
+ @Test
+ public void testSerializeBits(){
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class),
+ ImmutableSet.of("foo", "bar"));
+
+ assertEquals(ValueType.BITS_TYPE.ordinal(), builder.getIntValueType());
+ assertTrue( "foo not in bits", builder.getBitsValueList().contains("foo"));
+ assertTrue( "bar not in bits", builder.getBitsValueList().contains("bar"));
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class),
+ ImmutableSet.of("foo", "bar"));
+
+ assertEquals(ValueType.BITS_TYPE.ordinal(), builder1.getType());
+ assertEquals("[foo, bar]", builder1.getValue());
+
+ }
+
+ @Test
+ public void testSerializeWrongTypeOfSet(){
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Expected value type to be Bits but was :");
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class),
+ ImmutableSet.of(1, 2));
+
+ }
+
+ @Test
+ public void testSerializeEmptyString(){
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class),"");
+
+ assertEquals(ValueType.STRING_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class),"");
+
+ assertEquals(ValueType.STRING_TYPE.ordinal(), builder1.getType());
+ assertEquals("", builder1.getValue());
+
+ }
+
+ @Test
+ public void testSerializeString(){
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class),"foo");
+
+ assertEquals(ValueType.STRING_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("foo", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class),"foo");
+
+ assertEquals(ValueType.STRING_TYPE.ordinal(), builder1.getType());
+ assertEquals("foo", builder1.getValue());
+
+ }
+
+
+ @Test
+ public void testSerializeBoolean(){
+ boolean v1 = true;
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BOOL_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("true", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BOOL_TYPE.ordinal(), builder1.getType());
+ assertEquals("true", builder1.getValue());
+ }
+
+ @Test
+ public void testSerializeQName(){
+ QName v1 = TestModel.TEST_QNAME;
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.QNAME_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.QNAME_TYPE.ordinal(), builder1.getType());
+ assertEquals("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test", builder1.getValue());
+
+ }
+
+ @Test
+ public void testSerializeYangIdentifier(){
+ YangInstanceIdentifier v1 = TestModel.TEST_PATH;
+
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+
+ assertEquals(ValueType.YANG_IDENTIFIER_TYPE.ordinal(), builder.getIntValueType());
+ NormalizedNodeMessages.InstanceIdentifier serializedYangInstanceIdentifier =
+ builder.getInstanceIdentifierValue();
+
+ assertEquals(1, serializedYangInstanceIdentifier.getArgumentsCount());
+ assertEquals(TestModel.TEST_QNAME.toString(), serializedYangInstanceIdentifier.getArguments(0).getNodeType().getValue());
+ }
+
+ @Test
+ public void testSerializeBigInteger(){
+ BigInteger v1 = new BigInteger("1000000000000000000000000");
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BIG_INTEGER_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("1000000000000000000000000", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BIG_INTEGER_TYPE.ordinal(), builder1.getType());
+ assertEquals("1000000000000000000000000", builder1.getValue());
+
+ }
+
+ @Test
+ public void testSerializeBigDecimal(){
+ BigDecimal v1 = new BigDecimal("1000000000000000000000000.51616");
+ NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
+ ValueSerializer.serialize(builder, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BIG_DECIMAL_TYPE.ordinal(), builder.getIntValueType());
+ assertEquals("1000000000000000000000000.51616", builder.getValue());
+
+ NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+ ValueSerializer.serialize(builder1, mock(
+ NormalizedNodeSerializationContext.class), v1);
+
+ assertEquals(ValueType.BIG_DECIMAL_TYPE.ordinal(), builder1.getType());
+ assertEquals("1000000000000000000000000.51616", builder1.getValue());
+
+ }
+
+ @Test
+ public void testDeSerializeShort(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.SHORT_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof Short);
+ assertEquals(25, ((Short) o).shortValue());
+ }
+
+ @Test
+ public void testDeSerializeByte(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.BYTE_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof Byte);
+ assertEquals(25, ((Byte) o).byteValue());
+
+ }
+
+ @Test
+ public void testDeSerializeInteger(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.INT_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof Integer);
+ assertEquals(25, ((Integer) o).intValue());
+
+ }
+
+ @Test
+ public void testDeSerializeLong(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.LONG_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof Long);
+ assertEquals(25, ((Long) o).longValue());
+
+ }
+
+ @Test
+ public void testDeSerializeBoolean(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.BOOL_TYPE.ordinal());
+ nodeBuilder.setValue("false");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof Boolean);
+ assertEquals(false, ((Boolean) o).booleanValue());
+
+ }
+
+ @Test
+ public void testDeSerializeQName(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.QNAME_TYPE.ordinal());
+ nodeBuilder.setValue(TestModel.TEST_QNAME.toString());
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof QName);
+ assertEquals(TestModel.TEST_QNAME, o);
+
+ }
+
+ @Test
+ public void testDeSerializeBits(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.BITS_TYPE.ordinal());
+ nodeBuilder.addAllBitsValue(ImmutableList.of("foo", "bar"));
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof Set);
+ assertTrue(((Set)o).contains("foo"));
+ assertTrue(((Set) o).contains("bar"));
+
+ }
+
+ @Test
+ public void testDeSerializeYangIdentifier(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ NormalizedNodeMessages.InstanceIdentifier.Builder idBuilder = NormalizedNodeMessages.InstanceIdentifier.newBuilder();
+ NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
+
+ pathBuilder.setValue(TestModel.TEST_QNAME.toString());
+ pathBuilder.setIntType(PathArgumentType.NODE_IDENTIFIER.ordinal());
+
+ idBuilder.addArguments(pathBuilder);
+
+ nodeBuilder.setIntValueType(ValueType.YANG_IDENTIFIER_TYPE.ordinal());
+ nodeBuilder.setInstanceIdentifierValue(idBuilder);
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof YangInstanceIdentifier);
+ assertEquals(TestModel.TEST_PATH, o);
+
+ }
+
+ @Test
+ public void testDeSerializeString(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.STRING_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof String);
+ assertEquals("25", o);
+
+ }
+
+ @Test
+ public void testDeSerializeBigInteger(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.BIG_INTEGER_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof BigInteger);
+ assertEquals(new BigInteger("25"), o);
+
+ }
+
+ @Test
+ public void testDeSerializeBigDecimal(){
+ NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder();
+ nodeBuilder.setIntValueType(ValueType.BIG_DECIMAL_TYPE.ordinal());
+ nodeBuilder.setValue("25");
+
+ Object o = ValueSerializer
+ .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+ nodeBuilder.build());
+
+ assertTrue(o instanceof BigDecimal);
+ assertEquals(new BigDecimal("25"), o);
+
+ }
+
+}
package org.opendaylight.controller.cluster.datastore.util;
+import com.google.common.collect.ImmutableSet;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
// Create augmentations
MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test");
+ // Create a bits leaf
+ NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
+ myBits = Builders.leafBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(
+ QName.create(TEST_QNAME, "my-bits"))).withValue(
+ ImmutableSet.of("foo", "bar"));
- // Create the document
+
+ // Create the document
return ImmutableContainerNodeBuilder
.create()
.withNodeIdentifier(
new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+ .withChild(myBits.build())
.withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
.withChild(ImmutableNodes.leafNode(POINTER_QNAME, "pointer"))
.withChild(
actorSystem.eventStream().subscribe(mockReceiver.getRef(), DeadLetter.class);
- final FiniteDuration TEN_SEC = new FiniteDuration(10, TimeUnit.SECONDS);
+ final FiniteDuration TWENTY_SEC = new FiniteDuration(20, TimeUnit.SECONDS);
+
String boundedMailBox = actorSystem.name() + ".bounded-mailbox";
ActorRef pingPongActor = actorSystem.actorOf(PingPongActor.props(lock).withMailbox(boundedMailBox),
"pingpongactor");
pingPongActor.tell("ping", mockReceiver.getRef());
}
- mockReceiver.expectMsgClass(TEN_SEC, DeadLetter.class);
+ mockReceiver.expectMsgClass(TWENTY_SEC, DeadLetter.class);
lock.unlock();
- Object[] eleven = mockReceiver.receiveN(11, TEN_SEC);
+ Object[] eleven = mockReceiver.receiveN(11, TWENTY_SEC);
}
/**
@Override
public void onReceive(Object message) throws Exception {
lock.lock();
- if ("ping".equals(message))
- getSender().tell("pong", getSelf());
+ try {
+ if ("ping".equals(message))
+ getSender().tell("pong", getSelf());
+ } finally {
+ lock.unlock();
+ }
}
}
}
\ No newline at end of file
}
container test {
+ leaf my-bits {
+ type bits {
+ bit ten-mb-hd;
+ bit ten-mb-fd;
+ bit hundred-mb-hd;
+ bit hundred-mb-fd;
+ bit one-gb-hd;
+ bit one-gb-fd;
+ bit ten-gb-fd;
+ bit forty-gb-fd;
+ bit hundred-gb-fd;
+ bit one-tb-fd;
+ bit other;
+ bit copper;
+ bit fiber;
+ bit autoeng;
+ bit pause;
+ bit pause-asym;
+ }
+ }
+
leaf desc {
type string;
}
<description>Configuration files for md-sal clustering</description>
<packaging>jar</packaging>
<build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/initial/05-clustering.xml.conf</file>
+ <type>xml</type>
+ <classifier>config</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
</project>
odl-cluster-data {
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 100ms
+ }
akka {
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
cluster {
- seed-nodes = ["akka.tcp://opendaylight-cluster-data@<CHANGE_ME>:2550"]
+ seed-nodes = ["akka.tcp://opendaylight-cluster-data@<CHANGE_SEED_IP>:2550"]
auto-down-unreachable-after = 10s
}
}
odl-cluster-rpc {
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 100ms
+ }
akka {
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
cluster {
- seed-nodes = ["akka.tcp://opendaylight-cluster-rpc@<CHANGE_ME>:2551"]
+ seed-nodes = ["akka.tcp://opendaylight-cluster-rpc@<CHANGE_SEED_IP>:2551"]
auto-down-unreachable-after = 10s
}
import org.opendaylight.yangtools.concepts.Path;
/**
- * A chain of transactions. Transactions in a chain need to be committed in sequence and each
- * transaction should see the effects of previous transactions as if they happened. A chain
- * makes no guarantees of atomicity, in fact transactions are committed as soon as possible.
+ * A chain of transactions. Transactions in a chain need to be committed in
+ * sequence and each transaction should see the effects of previous committed transactions
+ * as they occurred. A chain makes no guarantees of atomicity across the chained transactions -
+ * the transactions are committed as soon as possible in the order that they were submitted.
*
+ * This behaviour is different from the default AsyncDataBroker, where a
+ * transaction is always created from the current global state, not taking into
+ * account any transactions previously committed by the calling thread. Due to
+ * the asynchronous nature of transaction submission this can lead to surprising
+ * results. If a thread executes the following sequence sufficiently quickly:
+ *
+ * AsyncWriteTransaction t1 = broker.newWriteOnlyTransaction();
+ * t1.put(id, data);
+ * t1.submit();
+ *
+ * AsyncReadTransaction t2 = broker.newReadOnlyTransaction();
+ * Optional<?> maybeData = t2.read(id).get();
+ *
+ * it may happen, that it sees maybeData.isPresent() == false, simply because
+ * t1 has not completed the processes of being applied and t2 is actually
+ * allocated from the previous state. This is obviously bad for users who create
+ * incremental state in the datastore and actually read what they write in
+ * subsequent transactions.
+ *
+ * Using a TransactionChain instead of a broker solves this particular problem,
+ * and leads to expected behavior: t2 will always see the data written in t1
+ * present.
*/
-public interface TransactionChain<P extends Path<P>, D> extends AutoCloseable, AsyncDataTransactionFactory<P, D> {
+public interface TransactionChain<P extends Path<P>, D> extends AutoCloseable,
+ AsyncDataTransactionFactory<P, D> {
/**
* Create a new read only transaction which will continue the chain.
- * The previous read-write transaction has to be either COMMITED or CANCELLED.
+ *
+ * <p>
+ * The previous write transaction has to be either SUBMITTED
+ * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED
+ * ({@link #close close} was invoked).
+ * <p>
+ * The returned read-only transaction presents an isolated view of the data if the previous
+ * write transaction was successful - in other words, this read-only transaction will see the
+ * state changes made by the previous write transaction in the chain. However, state which
+ * was introduced by other transactions outside this transaction chain after creation of
+ * the previous transaction is not visible.
*
* @return New transaction in the chain.
- * @throws IllegalStateException if the previous transaction was not COMMITED
- * or CANCELLED.
- * @throws TransactionChainClosedException if the chain has been closed.
+ * @throws IllegalStateException
+ * if the previous transaction was not SUBMITTED or CANCELLED.
+ * @throws TransactionChainClosedException
+ * if the chain has been closed.
*/
@Override
public AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
-
/**
- * Create a new read write transaction which will continue the chain.
- * The previous read-write transaction has to be either COMMITED or CANCELLED.
+ * Create a new read-write transaction which will continue the chain.
+ *
+ * <p>
+ * The previous write transaction has to be either SUBMITTED
+ * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED
+ * ({@link #close close} was invoked).
+ * <p>
+ * The returned read-write transaction presents an isolated view of the data if the previous
+ * write transaction was successful - in other words, this read-write transaction will see the
+ * state changes made by the previous write transaction in the chain. However, state which
+ * was introduced by other transactions outside this transaction chain after creation of
+ * the previous transaction is not visible.
+ * <p>
+ * Committing this read-write transaction using {@link AsyncWriteTransaction#submit submit}
+ * will submit the state changes in this transaction to be visible to any subsequent
+ * transaction in this chain and also to any transaction outside this chain.
*
* @return New transaction in the chain.
- * @throws IllegalStateException if the previous transaction was not COMMITTED
- * or CANCELLED.
- * @throws TransactionChainClosedException if the chain has been closed.
+ * @throws IllegalStateException
+ * if the previous transaction was not SUBMITTED or CANCELLED.
+ * @throws TransactionChainClosedException
+ * if the chain has been closed.
*/
@Override
public AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
+ /**
+ * Create a new write-only transaction which will continue the chain.
+ *
+ * <p>
+ * The previous write transaction has to be either SUBMITTED
+ * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED
+ * ({@link #close close} was invoked).
+ * <p>
+ * The returned write-only transaction presents an isolated view of the data if the previous
+ * write transaction was successful - in other words, this write-only transaction will see the
+ * state changes made by the previous write transaction in the chain. However, state which
+ * was introduced by other transactions outside this transaction chain after creation of
+ * the previous transaction is not visible.
+ * <p>
+ * Committing this write-only transaction using {@link AsyncWriteTransaction#submit submit}
+ * will submit the state changes in this transaction to be visible to any subsequent
+ * transaction in this chain and also to any transaction outside this chain.
+ *
+ * @return New transaction in the chain.
+ * @throws IllegalStateException
+ * if the previous transaction was not SUBMITTED or CANCELLED.
+ * @throws TransactionChainClosedException
+ * if the chain has been closed.
+ */
+ @Override
+ public AsyncWriteTransaction<P, D> newWriteOnlyTransaction();
+
@Override
void close();
}
-
* Interface for creating transaction chains.
*/
public interface TransactionChainFactory<P extends Path<P>, D> {
+
/**
* Create a new transaction chain. The chain will be initialized to read
* from its backing datastore, with no outstanding transaction. Listener
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+import java.lang.management.ManagementFactory;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Abstract base for an MXBean implementation class.
+ * <p>
+ * This class is not intended for use outside of MD-SAL and its part of private
+ * implementation (still exported as public to be reused across MD-SAL implementation
+ * components) and may be removed in subsequent
+ * releases.
+ *
+ * @author Thomas Pantelis
+ */
+@Beta
+public abstract class AbstractMXBean {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractMXBean.class);
+
+ public static String BASE_JMX_PREFIX = "org.opendaylight.controller:";
+
+ private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+
+ private final String mBeanName;
+ private final String mBeanType;
+ private final String mBeanCategory;
+
+ /**
+ * Constructor.
+ *
+ * @param mBeanName Used as the <code>name</code> property in the bean's ObjectName.
+ * @param mBeanType Used as the <code>type</code> property in the bean's ObjectName.
+ * @param mBeanCategory Used as the <code>Category</code> property in the bean's ObjectName.
+ */
+ protected AbstractMXBean(@Nonnull String mBeanName, @Nonnull String mBeanType,
+ @Nullable String mBeanCategory) {
+ this.mBeanName = mBeanName;
+ this.mBeanType = mBeanType;
+ this.mBeanCategory = mBeanCategory;
+ }
+
+ private ObjectName getMBeanObjectName() throws MalformedObjectNameException {
+ StringBuilder builder = new StringBuilder(BASE_JMX_PREFIX)
+ .append("type=").append(getMBeanType());
+
+ if(getMBeanCategory() != null) {
+ builder.append(",Category=").append(getMBeanCategory());
+ }
+
+ builder.append(",name=").append(getMBeanName());
+ return new ObjectName(builder.toString());
+ }
+
+ /**
+ * Registers this bean with the platform MBean server with the domain defined by
+ * {@link #BASE_JMX_PREFIX}.
+ *
+ * @return true is successfully registered, false otherwise.
+ */
+ public boolean registerMBean() {
+ boolean registered = false;
+ try {
+ // Object to identify MBean
+ final ObjectName mbeanName = this.getMBeanObjectName();
+
+ LOG.debug("Register MBean {}", mbeanName);
+
+ // unregistered if already registered
+ if(server.isRegistered(mbeanName)) {
+
+ LOG.debug("MBean {} found to be already registered", mbeanName);
+
+ try {
+ unregisterMBean(mbeanName);
+ } catch(Exception e) {
+
+ LOG.warn("unregister mbean {} resulted in exception {} ", mbeanName, e);
+ }
+ }
+ server.registerMBean(this, mbeanName);
+ registered = true;
+
+ LOG.debug("MBean {} registered successfully", mbeanName.getCanonicalName());
+ } catch(Exception e) {
+
+ LOG.error("registration failed {}", e);
+
+ }
+ return registered;
+ }
+
+ /**
+ * Unregisters this bean with the platform MBean server.
+ *
+ * @return true is successfully unregistered, false otherwise.
+ */
+ public boolean unregisterMBean() {
+ boolean unregister = false;
+ try {
+ ObjectName mbeanName = this.getMBeanObjectName();
+ unregisterMBean(mbeanName);
+ unregister = true;
+ } catch(Exception e) {
+
+ LOG.error("Failed when unregistering MBean {}", e);
+ }
+
+ return unregister;
+ }
+
+ private void unregisterMBean(ObjectName mbeanName) throws MBeanRegistrationException,
+ InstanceNotFoundException {
+ server.unregisterMBean(mbeanName);
+ }
+
+ /**
+ * Returns the <code>name</code> property of the bean's ObjectName.
+ */
+ public String getMBeanName() {
+ return mBeanName;
+ }
+
+ /**
+ * Returns the <code>type</code> property of the bean's ObjectName.
+ */
+ public String getMBeanType() {
+ return mBeanType;
+ }
+
+ /**
+ * Returns the <code>Category</code> property of the bean's ObjectName.
+ */
+ public String getMBeanCategory() {
+ return mBeanCategory;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+import java.util.List;
+
+import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
+
+/**
+ * MXBean interface for {@link QueuedNotificationManager} statistic metrics.
+ *
+ * @author Thomas Pantelis
+ */
+public interface QueuedNotificationManagerMXBean {
+
+ /**
+ * Returns a list of stat instances for each current listener notification task in progress.
+ */
+ List<ListenerNotificationQueueStats> getCurrentListenerQueueStats();
+
+ /**
+ * Returns the configured maximum listener queue size.
+ */
+ int getMaxListenerQueueSize();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+import java.util.List;
+
+import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
+import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Implementation of the QueuedNotificationManagerMXBean interface.
+ *
+ * <p>
+ * This class is not intended for use outside of MD-SAL and its part of private
+ * implementation (still exported as public to be reused across MD-SAL implementation
+ * components) and may be removed in subsequent
+ * releases.
+ *
+ * @author Thomas Pantelis
+ */
+public class QueuedNotificationManagerMXBeanImpl extends AbstractMXBean
+ implements QueuedNotificationManagerMXBean {
+
+ private final QueuedNotificationManager<?,?> manager;
+
+ public QueuedNotificationManagerMXBeanImpl( QueuedNotificationManager<?,?> manager,
+ String mBeanName, String mBeanType, String mBeanCategory ) {
+ super(mBeanName, mBeanType, mBeanCategory);
+ this.manager = Preconditions.checkNotNull( manager );
+ }
+
+ @Override
+ public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
+ return manager.getListenerNotificationQueueStats();
+ }
+
+ @Override
+ public int getMaxListenerQueueSize() {
+ return manager.getMaxQueueCapacity();
+ }
+
+ public QueuedNotificationManagerStats toQueuedNotificationManagerStats() {
+ return new QueuedNotificationManagerStats( getMaxListenerQueueSize(),
+ getCurrentListenerQueueStats() );
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
+
+/**
+ * A bean class that holds various QueuedNotificationManager statistic metrics. This class is
+ * suitable for mapping to the MXBean CompositeDataSupport type.
+ *
+ * <p>
+ * This class is not intended for use outside of MD-SAL and its part of private
+ * implementation (still exported as public to be reused across MD-SAL implementation
+ * components) and may be removed in subsequent
+ * releases.
+ * @author Thomas Pantelis
+ * @see QueuedNotificationManagerMXBeanImpl
+ */
+public class QueuedNotificationManagerStats {
+
+ private final int maxListenerQueueSize;
+ private final List<ListenerNotificationQueueStats> currentListenerQueueStats;
+
+ @ConstructorProperties({"maxListenerQueueSize","currentListenerQueueStats"})
+ public QueuedNotificationManagerStats( int maxListenerQueueSize,
+ List<ListenerNotificationQueueStats> currentListenerQueueStats ) {
+ super();
+ this.maxListenerQueueSize = maxListenerQueueSize;
+ this.currentListenerQueueStats = currentListenerQueueStats;
+ }
+
+ public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
+ return currentListenerQueueStats;
+ }
+
+ public int getMaxListenerQueueSize() {
+ return maxListenerQueueSize;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * A bean class that holds various thread executor statistic metrics. This class is suitable for
+ * mapping to the MXBean CompositeDataSupport type;
+ *
+ * @author Thomas Pantelis
+ * @see ThreadExecutorStatsMXBeanImpl
+ */
+public class ThreadExecutorStats {
+
+ private final long activeThreadCount;
+ private final long completedTaskCount;
+ private final long currentQueueSize;
+ private final long maxThreadPoolSize;
+ private final long totalTaskCount;
+ private final long largestThreadPoolSize;
+ private final long maxQueueSize;
+ private final long currentThreadPoolSize;
+
+ // The following fields are defined as Long because they may be null if we can't a value
+ // from the underlying executor.
+ private final Long largestQueueSize;
+ private final Long rejectedTaskCount;
+
+ @ConstructorProperties({"activeThreadCount","currentThreadPoolSize","largestThreadPoolSize",
+ "maxThreadPoolSize","currentQueueSize","largestQueueSize","maxQueueSize",
+ "completedTaskCount","totalTaskCount","rejectedTaskCount"})
+ public ThreadExecutorStats(long activeThreadCount, long currentThreadPoolSize,
+ long largestThreadPoolSize, long maxThreadPoolSize, long currentQueueSize,
+ Long largestQueueSize, long maxQueueSize, long completedTaskCount,
+ long totalTaskCount, Long rejectedTaskCount) {
+ this.activeThreadCount = activeThreadCount;
+ this.currentThreadPoolSize = currentThreadPoolSize;
+ this.largestQueueSize = largestQueueSize;
+ this.largestThreadPoolSize = largestThreadPoolSize;
+ this.maxThreadPoolSize = maxThreadPoolSize;
+ this.currentQueueSize = currentQueueSize;
+ this.maxQueueSize = maxQueueSize;
+ this.completedTaskCount = completedTaskCount;
+ this.totalTaskCount = totalTaskCount;
+ this.rejectedTaskCount = rejectedTaskCount;
+ }
+
+ public long getActiveThreadCount() {
+ return activeThreadCount;
+ }
+
+ public long getCompletedTaskCount() {
+ return completedTaskCount;
+ }
+
+ public Long getRejectedTaskCount() {
+ return rejectedTaskCount;
+ }
+
+ public long getCurrentQueueSize() {
+ return currentQueueSize;
+ }
+
+ public Long getLargestQueueSize() {
+ return largestQueueSize;
+ }
+
+ public long getMaxThreadPoolSize() {
+ return maxThreadPoolSize;
+ }
+
+ public long getTotalTaskCount() {
+ return totalTaskCount;
+ }
+
+ public long getLargestThreadPoolSize() {
+ return largestThreadPoolSize;
+ }
+
+ public long getMaxQueueSize() {
+ return maxQueueSize;
+ }
+
+ public long getCurrentThreadPoolSize() {
+ return currentThreadPoolSize;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+/**
+ * MXBean interface for thread executor statistic metrics.
+ *
+ * @author Thomas Pantelis
+ */
+public interface ThreadExecutorStatsMXBean {
+
+ /**
+ * Returns the current thread pool size.
+ */
+ long getCurrentThreadPoolSize();
+
+ /**
+ * Returns the largest thread pool size.
+ */
+ long getLargestThreadPoolSize();
+
+ /**
+ * Returns the maximum thread pool size.
+ */
+ long getMaxThreadPoolSize();
+
+ /**
+ * Returns the current queue size.
+ */
+ long getCurrentQueueSize();
+
+ /**
+ * Returns the largest queue size, if available.
+ */
+ Long getLargestQueueSize();
+
+ /**
+ * Returns the maximum queue size.
+ */
+ long getMaxQueueSize();
+
+ /**
+ * Returns the active thread count.
+ */
+ long getActiveThreadCount();
+
+ /**
+ * Returns the completed task count.
+ */
+ long getCompletedTaskCount();
+
+ /**
+ * Returns the total task count.
+ */
+ long getTotalTaskCount();
+
+ /**
+ * Returns the rejected task count, if available.
+ */
+ Long getRejectedTaskCount();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.common.util.jmx;
+
+import com.google.common.base.Preconditions;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executor;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.util.concurrent.CountingRejectedExecutionHandler;
+import org.opendaylight.yangtools.util.concurrent.TrackingLinkedBlockingQueue;
+
+/**
+ * MXBean implementation of the ThreadExecutorStatsMXBean interface that retrieves statistics
+ * from a backing {@link java.util.concurrent.ExecutorService}.
+ *
+ * @author Thomas Pantelis
+ */
+public class ThreadExecutorStatsMXBeanImpl extends AbstractMXBean
+ implements ThreadExecutorStatsMXBean {
+
+ private final ThreadPoolExecutor executor;
+
+ /**
+ * Constructs an instance for the given {@link Executor}.
+ *
+ * @param executor the backing {@link Executor}
+ * @param mBeanName Used as the <code>name</code> property in the bean's ObjectName.
+ * @param mBeanType Used as the <code>type</code> property in the bean's ObjectName.
+ * @param mBeanCategory Used as the <code>Category</code> property in the bean's ObjectName.
+ */
+ public ThreadExecutorStatsMXBeanImpl(Executor executor, String mBeanName,
+ String mBeanType, @Nullable String mBeanCategory) {
+ super(mBeanName, mBeanType, mBeanCategory);
+
+ Preconditions.checkArgument(executor instanceof ThreadPoolExecutor,
+ "The ExecutorService of type {} is not an instanceof ThreadPoolExecutor",
+ executor.getClass());
+ this.executor = (ThreadPoolExecutor)executor;
+ }
+
+ @Override
+ public long getCurrentThreadPoolSize() {
+ return executor.getPoolSize();
+ }
+
+ @Override
+ public long getLargestThreadPoolSize() {
+ return executor.getLargestPoolSize();
+ }
+
+ @Override
+ public long getMaxThreadPoolSize() {
+ return executor.getMaximumPoolSize();
+ }
+
+ @Override
+ public long getCurrentQueueSize() {
+ return executor.getQueue().size();
+ }
+
+ @Override
+ public Long getLargestQueueSize() {
+ BlockingQueue<Runnable> queue = executor.getQueue();
+ if(queue instanceof TrackingLinkedBlockingQueue) {
+ return Long.valueOf(((TrackingLinkedBlockingQueue<?>)queue).getLargestQueueSize());
+ }
+
+ return null;
+ }
+
+ @Override
+ public long getMaxQueueSize() {
+ long queueSize = executor.getQueue().size();
+ return executor.getQueue().remainingCapacity() + queueSize;
+ }
+
+ @Override
+ public long getActiveThreadCount() {
+ return executor.getActiveCount();
+ }
+
+ @Override
+ public long getCompletedTaskCount() {
+ return executor.getCompletedTaskCount();
+ }
+
+ @Override
+ public long getTotalTaskCount() {
+ return executor.getTaskCount();
+ }
+
+ @Override
+ public Long getRejectedTaskCount() {
+ RejectedExecutionHandler rejectedHandler = executor.getRejectedExecutionHandler();
+ if(rejectedHandler instanceof CountingRejectedExecutionHandler) {
+ return Long.valueOf(((CountingRejectedExecutionHandler)rejectedHandler)
+ .getRejectedTaskCount());
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns a {@link ThreadExecutorStats} instance containing a snapshot of the statistic
+ * metrics.
+ */
+ public ThreadExecutorStats toThreadExecutorStats() {
+ return new ThreadExecutorStats(getActiveThreadCount(), getCurrentThreadPoolSize(),
+ getLargestThreadPoolSize(), getMaxThreadPoolSize(), getCurrentQueueSize(),
+ getLargestQueueSize(), getMaxQueueSize(), getCompletedTaskCount(),
+ getTotalTaskCount(), getRejectedTaskCount());
+ }
+}
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
- <version>3.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-graphite</artifactId>
</dependency>
<!-- Test Dependencies -->
<dependency>
<configuration>
<includes>
<include>org.opendaylight.controller.*</include>
+
</includes>
+ <excludes>
+ <exclude>org.opendaylight.controller.config.yang.config.*</exclude>
+ </excludes>
<check>false</check>
</configuration>
<executions>
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.UnknownFieldSet;
import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
import java.io.Serializable;
import akka.actor.Props;
import akka.japi.Creator;
+
import com.google.common.base.Preconditions;
+
import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
import org.opendaylight.controller.cluster.datastore.messages.DataChangedReply;
import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class DataChangeListener extends AbstractUntypedActor {
private final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener;
- private final SchemaContext schemaContext;
- private final YangInstanceIdentifier pathId;
- private boolean notificationsEnabled = false;
+ private volatile boolean notificationsEnabled = false;
- public DataChangeListener(SchemaContext schemaContext,
- AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener, YangInstanceIdentifier pathId) {
-
- this.schemaContext = Preconditions.checkNotNull(schemaContext, "schemaContext should not be null");
+ public DataChangeListener(AsyncDataChangeListener<YangInstanceIdentifier,
+ NormalizedNode<?, ?>> listener) {
this.listener = Preconditions.checkNotNull(listener, "listener should not be null");
- this.pathId = Preconditions.checkNotNull(pathId, "pathId should not be null");
}
@Override public void handleReceive(Object message) throws Exception {
}
}
- public static Props props(final SchemaContext schemaContext, final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener, final YangInstanceIdentifier pathId) {
- return Props.create(new Creator<DataChangeListener>() {
- @Override
- public DataChangeListener create() throws Exception {
- return new DataChangeListener(schemaContext,listener,pathId );
- }
+ public static Props props(final AsyncDataChangeListener<YangInstanceIdentifier,
+ NormalizedNode<?, ?>> listener) {
+ return Props.create(new DataChangeListenerCreator(listener));
+ }
+
+ private static class DataChangeListenerCreator implements Creator<DataChangeListener> {
+ private static final long serialVersionUID = 1L;
+
+ final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener;
- });
+ DataChangeListenerCreator(
+ AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener) {
+ this.listener = listener;
+ }
+ @Override
+ public DataChangeListener create() throws Exception {
+ return new DataChangeListener(listener);
+ }
}
}
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorSelection;
+
import com.google.common.base.Preconditions;
+
import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
private final ActorSelection dataChangeListenerActor;
private final SchemaContext schemaContext;
- public DataChangeListenerProxy(SchemaContext schemaContext,ActorSelection dataChangeListenerActor) {
+ public DataChangeListenerProxy(SchemaContext schemaContext, ActorSelection dataChangeListenerActor) {
this.dataChangeListenerActor = Preconditions.checkNotNull(dataChangeListenerActor, "dataChangeListenerActor should not be null");
this.schemaContext = schemaContext;
}
@Override public void onDataChanged(
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
- dataChangeListenerActor.tell(new DataChanged(schemaContext,change), null);
+ dataChangeListenerActor.tell(new DataChanged(schemaContext, change), null);
}
}
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.japi.Creator;
+
import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration;
import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistrationReply;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public class DataChangeListenerRegistration extends AbstractUntypedActor {
- private final org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
+ private final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
registration;
public DataChangeListenerRegistration(
- org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
+ ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
this.registration = registration;
}
}
public static Props props(
- final org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
- return Props.create(new Creator<DataChangeListenerRegistration>() {
-
- @Override
- public DataChangeListenerRegistration create() throws Exception {
- return new DataChangeListenerRegistration(registration);
- }
- });
+ final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> registration) {
+ return Props.create(new DataChangeListenerRegistrationCreator(registration));
}
private void closeListenerRegistration(
.tell(new CloseDataChangeListenerRegistrationReply().toSerializable(), getSelf());
getSelf().tell(PoisonPill.getInstance(), getSelf());
}
+
+ private static class DataChangeListenerRegistrationCreator
+ implements Creator<DataChangeListenerRegistration> {
+ final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier,
+ NormalizedNode<?, ?>>> registration;
+
+ DataChangeListenerRegistrationCreator(
+ ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier,
+ NormalizedNode<?, ?>>> registration) {
+ this.registration = registration;
+ }
+
+ @Override
+ public DataChangeListenerRegistration create() throws Exception {
+ return new DataChangeListenerRegistration(registration);
+ }
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.cluster.datastore;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import scala.concurrent.duration.Duration;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Contains contextual data for shards.
+ *
+ * @author Thomas Pantelis
+ */
+public class DatastoreContext {
+
+ private final InMemoryDOMDataStoreConfigProperties dataStoreProperties;
+ private final Duration shardTransactionIdleTimeout;
+
+ public DatastoreContext() {
+ this.dataStoreProperties = null;
+ this.shardTransactionIdleTimeout = Duration.create(10, TimeUnit.MINUTES);
+ }
+
+ public DatastoreContext(InMemoryDOMDataStoreConfigProperties dataStoreProperties,
+ Duration shardTransactionIdleTimeout) {
+ this.dataStoreProperties = Preconditions.checkNotNull(dataStoreProperties);
+ this.shardTransactionIdleTimeout = Preconditions.checkNotNull(shardTransactionIdleTimeout);
+ }
+
+ public InMemoryDOMDataStoreConfigProperties getDataStoreProperties() {
+ return dataStoreProperties;
+ }
+
+ public Duration getShardTransactionIdleTimeout() {
+ return shardTransactionIdleTimeout;
+ }
+
+
+}
package org.opendaylight.controller.cluster.datastore;
+import java.util.concurrent.TimeUnit;
+
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import com.google.common.base.Preconditions;
+
import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
-import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import scala.concurrent.duration.Duration;
+
/**
*
*/
private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStore.class);
private final ActorContext actorContext;
-
- private SchemaContext schemaContext;
+ private final DatastoreContext datastoreContext;
public DistributedDataStore(ActorSystem actorSystem, String type, ClusterWrapper cluster,
- Configuration configuration, InMemoryDOMDataStoreConfigProperties dataStoreProperties) {
+ Configuration configuration, DistributedDataStoreProperties dataStoreProperties) {
Preconditions.checkNotNull(actorSystem, "actorSystem should not be null");
Preconditions.checkNotNull(type, "type should not be null");
Preconditions.checkNotNull(cluster, "cluster should not be null");
LOG.info("Creating ShardManager : {}", shardManagerId);
- this.actorContext = new ActorContext(actorSystem, actorSystem
- .actorOf(ShardManager.props(type, cluster, configuration, dataStoreProperties),
- shardManagerId ), cluster, configuration);
+ datastoreContext = new DatastoreContext(InMemoryDOMDataStoreConfigProperties.create(
+ dataStoreProperties.getMaxShardDataChangeExecutorPoolSize(),
+ dataStoreProperties.getMaxShardDataChangeExecutorQueueSize(),
+ dataStoreProperties.getMaxShardDataChangeListenerQueueSize()),
+ Duration.create(dataStoreProperties.getShardTransactionIdleTimeoutInMinutes(),
+ TimeUnit.MINUTES));
+
+ actorContext
+ = new ActorContext(
+ actorSystem, actorSystem.actorOf(
+ ShardManager.props(type, cluster, configuration, datastoreContext).
+ withMailbox(ActorContext.MAILBOX), shardManagerId ), cluster, configuration);
}
public DistributedDataStore(ActorContext actorContext) {
this.actorContext = Preconditions.checkNotNull(actorContext, "actorContext should not be null");
+ this.datastoreContext = new DatastoreContext();
}
LOG.debug("Registering listener: {} for path: {} scope: {}", listener, path, scope);
ActorRef dataChangeListenerActor = actorContext.getActorSystem().actorOf(
- DataChangeListener.props(schemaContext,listener,path ));
+ DataChangeListener.props(listener ));
String shardName = ShardStrategyFactory.getStrategy(path).findShard(path);
@Override
public DOMStoreTransactionChain createTransactionChain() {
- return new TransactionChainProxy(actorContext, schemaContext);
+ return new TransactionChainProxy(actorContext);
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY,
- schemaContext);
+ return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY);
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new TransactionProxy(actorContext, TransactionProxy.TransactionType.WRITE_ONLY,
- schemaContext);
+ return new TransactionProxy(actorContext, TransactionProxy.TransactionType.WRITE_ONLY);
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_WRITE,
- schemaContext);
+ return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_WRITE);
}
- @Override public void onGlobalContextUpdated(SchemaContext schemaContext) {
- this.schemaContext = schemaContext;
- actorContext.getShardManager().tell(
- new UpdateSchemaContext(schemaContext), null);
+ @Override
+ public void onGlobalContextUpdated(SchemaContext schemaContext) {
+ actorContext.setSchemaContext(schemaContext);
}
- @Override public void close() throws Exception {
+ @Override
+ public void close() throws Exception {
actorContext.shutdown();
-
}
}
import akka.actor.ActorSystem;
import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
public class DistributedDataStoreFactory {
public static DistributedDataStore createInstance(String name, SchemaService schemaService,
- InMemoryDOMDataStoreConfigProperties dataStoreProperties) {
+ DistributedDataStoreProperties dataStoreProperties) {
ActorSystem actorSystem = ActorSystemFactory.getInstance();
Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf");
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.cluster.datastore;
+
+/**
+ * Wrapper class for DistributedDataStore configuration properties.
+ *
+ * @author Thomas Pantelis
+ */
+public class DistributedDataStoreProperties {
+ private final int maxShardDataChangeListenerQueueSize;
+ private final int maxShardDataChangeExecutorQueueSize;
+ private final int maxShardDataChangeExecutorPoolSize;
+ private final int shardTransactionIdleTimeoutInMinutes;
+
+ public DistributedDataStoreProperties() {
+ maxShardDataChangeListenerQueueSize = 1000;
+ maxShardDataChangeExecutorQueueSize = 1000;
+ maxShardDataChangeExecutorPoolSize = 20;
+ shardTransactionIdleTimeoutInMinutes = 10;
+ }
+
+ public DistributedDataStoreProperties(int maxShardDataChangeListenerQueueSize,
+ int maxShardDataChangeExecutorQueueSize, int maxShardDataChangeExecutorPoolSize,
+ int shardTransactionIdleTimeoutInMinutes) {
+ this.maxShardDataChangeListenerQueueSize = maxShardDataChangeListenerQueueSize;
+ this.maxShardDataChangeExecutorQueueSize = maxShardDataChangeExecutorQueueSize;
+ this.maxShardDataChangeExecutorPoolSize = maxShardDataChangeExecutorPoolSize;
+ this.shardTransactionIdleTimeoutInMinutes = shardTransactionIdleTimeoutInMinutes;
+ }
+
+ public int getMaxShardDataChangeListenerQueueSize() {
+ return maxShardDataChangeListenerQueueSize;
+ }
+
+ public int getMaxShardDataChangeExecutorQueueSize() {
+ return maxShardDataChangeExecutorQueueSize;
+ }
+
+ public int getMaxShardDataChangeExecutorPoolSize() {
+ return maxShardDataChangeExecutorPoolSize;
+ }
+
+ public int getShardTransactionIdleTimeoutInMinutes() {
+ return shardTransactionIdleTimeoutInMinutes;
+ }
+}
import akka.event.LoggingAdapter;
import akka.japi.Creator;
import akka.serialization.Serialization;
+
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardTransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
import scala.concurrent.duration.FiniteDuration;
import java.util.ArrayList;
/// The name of this shard
private final ShardIdentifier name;
- private volatile SchemaContext schemaContext;
-
private final ShardStats shardMBean;
private final List<ActorSelection> dataChangeListeners = new ArrayList<>();
+ private final DatastoreContext datastoreContext;
+
+
+ private SchemaContext schemaContext;
+
private Shard(ShardIdentifier name, Map<ShardIdentifier, String> peerAddresses,
- InMemoryDOMDataStoreConfigProperties dataStoreProperties) {
+ DatastoreContext datastoreContext) {
super(name.toString(), mapPeerAddresses(peerAddresses), Optional.of(configParams));
this.name = name;
+ this.datastoreContext = datastoreContext;
String setting = System.getProperty("shard.persistent");
LOG.info("Shard created : {} persistent : {}", name, persistent);
- store = InMemoryDOMDataStoreFactory.create(name.toString(), null, dataStoreProperties);
+ store = InMemoryDOMDataStoreFactory.create(name.toString(), null,
+ datastoreContext.getDataStoreProperties());
shardMBean = ShardMBeanFactory.getShardStatsMBean(name.toString());
+
}
private static Map<String, String> mapPeerAddresses(
return map;
}
-
-
-
public static Props props(final ShardIdentifier name,
final Map<ShardIdentifier, String> peerAddresses,
- final InMemoryDOMDataStoreConfigProperties dataStoreProperties) {
+ DatastoreContext datastoreContext) {
Preconditions.checkNotNull(name, "name should not be null");
- Preconditions
- .checkNotNull(peerAddresses, "peerAddresses should not be null");
-
- return Props.create(new Creator<Shard>() {
-
- @Override
- public Shard create() throws Exception {
- return new Shard(name, peerAddresses, dataStoreProperties);
- }
+ Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");
+ Preconditions.checkNotNull(datastoreContext, "shardContext should not be null");
- });
+ return Props.create(new ShardCreator(name, peerAddresses, datastoreContext));
}
-
@Override public void onReceiveCommand(Object message) {
LOG.debug("Received message {} from {}", message.getClass().toString(),
getSender());
shardMBean.incrementReadOnlyTransactionCount();
return getContext().actorOf(
- ShardTransaction
- .props(store.newReadOnlyTransaction(), getSelf(),
- schemaContext), transactionId.toString());
+ ShardTransaction.props(store.newReadOnlyTransaction(), getSelf(),
+ schemaContext,datastoreContext, name.toString()), transactionId.toString());
} else if (createTransaction.getTransactionType()
== TransactionProxy.TransactionType.READ_WRITE.ordinal()) {
shardMBean.incrementReadWriteTransactionCount();
return getContext().actorOf(
- ShardTransaction
- .props(store.newReadWriteTransaction(), getSelf(),
- schemaContext), transactionId.toString());
+ ShardTransaction.props(store.newReadWriteTransaction(), getSelf(),
+ schemaContext, datastoreContext,name.toString()), transactionId.toString());
} else if (createTransaction.getTransactionType()
shardMBean.incrementWriteOnlyTransactionCount();
return getContext().actorOf(
- ShardTransaction
- .props(store.newWriteOnlyTransaction(), getSelf(),
- schemaContext), transactionId.toString());
+ ShardTransaction.props(store.newWriteOnlyTransaction(), getSelf(),
+ schemaContext, datastoreContext, name.toString()), transactionId.toString());
} else {
throw new IllegalArgumentException(
"Shard="+name + ":CreateTransaction message has unidentified transaction type="
final ActorRef self = getSelf();
Futures.addCallback(future, new FutureCallback<Void>() {
+ @Override
public void onSuccess(Void v) {
sender.tell(new CommitTransactionReply().toSerializable(),self);
shardMBean.incrementCommittedTransactionCount();
shardMBean.setLastCommittedTransactionTime(new Date());
}
+ @Override
public void onFailure(Throwable t) {
LOG.error(t, "An exception happened during commit");
shardMBean.incrementFailedTransactionsCount();
dataChangeListeners.add(dataChangeListenerPath);
AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>
- listener =
- new DataChangeListenerProxy(schemaContext, dataChangeListenerPath);
+ listener = new DataChangeListenerProxy(schemaContext, dataChangeListenerPath);
- org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
- registration =
- store.registerChangeListener(registerChangeListener.getPath(),
+ ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
+ registration = store.registerChangeListener(registerChangeListener.getPath(),
listener, registerChangeListener.getScope());
ActorRef listenerRegistration =
getContext().actorOf(
private void createTransactionChain() {
DOMStoreTransactionChain chain = store.createTransactionChain();
- ActorRef transactionChain =
- getContext().actorOf(
- ShardTransactionChain.props(chain, schemaContext));
- getSender()
- .tell(new CreateTransactionChainReply(transactionChain.path())
- .toSerializable(),
+ ActorRef transactionChain = getContext().actorOf(
+ ShardTransactionChain.props(chain, schemaContext, datastoreContext,name.toString() ));
+ getSender().tell(new CreateTransactionChainReply(transactionChain.path()).toSerializable(),
getSelf());
}
return HEART_BEAT_INTERVAL;
}
}
+
+ private static class ShardCreator implements Creator<Shard> {
+
+ private static final long serialVersionUID = 1L;
+
+ final ShardIdentifier name;
+ final Map<ShardIdentifier, String> peerAddresses;
+ final DatastoreContext datastoreContext;
+
+ ShardCreator(ShardIdentifier name, Map<ShardIdentifier, String> peerAddresses,
+ DatastoreContext datastoreContext) {
+ this.name = name;
+ this.peerAddresses = peerAddresses;
+ this.datastoreContext = datastoreContext;
+ }
+
+ @Override
+ public Shard create() throws Exception {
+ return new Shard(name, peerAddresses, datastoreContext);
+ }
+ }
}
import akka.cluster.ClusterEvent;
import akka.japi.Creator;
import akka.japi.Function;
+
import com.google.common.base.Preconditions;
+
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shardmanager.ShardManagerInfo;
import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound;
import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound;
import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import scala.concurrent.duration.Duration;
import java.util.ArrayList;
private ShardManagerInfoMBean mBean;
- private final InMemoryDOMDataStoreConfigProperties dataStoreProperties;
+ private final DatastoreContext datastoreContext;
/**
* @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be
* configuration or operational
*/
private ShardManager(String type, ClusterWrapper cluster, Configuration configuration,
- InMemoryDOMDataStoreConfigProperties dataStoreProperties) {
+ DatastoreContext datastoreContext) {
this.type = Preconditions.checkNotNull(type, "type should not be null");
this.cluster = Preconditions.checkNotNull(cluster, "cluster should not be null");
this.configuration = Preconditions.checkNotNull(configuration, "configuration should not be null");
- this.dataStoreProperties = dataStoreProperties;
+ this.datastoreContext = datastoreContext;
// Subscribe this actor to cluster member events
cluster.subscribeToMemberEvents(getSelf());
public static Props props(final String type,
final ClusterWrapper cluster,
final Configuration configuration,
- final InMemoryDOMDataStoreConfigProperties dataStoreProperties) {
+ final DatastoreContext datastoreContext) {
Preconditions.checkNotNull(type, "type should not be null");
Preconditions.checkNotNull(cluster, "cluster should not be null");
Preconditions.checkNotNull(configuration, "configuration should not be null");
- return Props.create(new Creator<ShardManager>() {
-
- @Override
- public ShardManager create() throws Exception {
- return new ShardManager(type, cluster, configuration, dataStoreProperties);
- }
- });
+ return Props.create(new ShardManagerCreator(type, cluster, configuration, datastoreContext));
}
-
@Override
public void handleReceive(Object message) throws Exception {
if (message.getClass().equals(FindPrimary.SERIALIZABLE_CLASS)) {
ShardIdentifier shardId = getShardIdentifier(memberName, shardName);
Map<ShardIdentifier, String> peerAddresses = getPeerAddresses(shardName);
ActorRef actor = getContext()
- .actorOf(Shard.props(shardId, peerAddresses, dataStoreProperties),
- shardId.toString());
+ .actorOf(Shard.props(shardId, peerAddresses, datastoreContext).
+ withMailbox(ActorContext.MAILBOX), shardId.toString());
+
localShardActorNames.add(shardId.toString());
localShards.put(shardName, new ShardInformation(shardName, actor, peerAddresses));
}
}
}
}
+
+ private static class ShardManagerCreator implements Creator<ShardManager> {
+ private static final long serialVersionUID = 1L;
+
+ final String type;
+ final ClusterWrapper cluster;
+ final Configuration configuration;
+ final DatastoreContext datastoreContext;
+
+ ShardManagerCreator(String type, ClusterWrapper cluster,
+ Configuration configuration, DatastoreContext datastoreContext) {
+ this.type = type;
+ this.cluster = cluster;
+ this.configuration = configuration;
+ this.datastoreContext = datastoreContext;
+ }
+
+ @Override
+ public ShardManager create() throws Exception {
+ return new ShardManager(type, cluster, configuration, datastoreContext);
+ }
+ }
}
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorRef;
-import akka.actor.PoisonPill;
-import akka.event.Logging;
-import akka.event.LoggingAdapter;
-import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
-import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
+
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.ReadData;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* Date: 8/6/14
*/
public class ShardReadTransaction extends ShardTransaction {
- private final DOMStoreReadTransaction transaction;
- private final LoggingAdapter log =
- Logging.getLogger(getContext().system(), this);
-
- public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
- super(shardActor, schemaContext);
- this.transaction = transaction;
-
- }
+ private final DOMStoreReadTransaction transaction;
- public ShardReadTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
- super(transactionChain, shardActor, schemaContext);
- this.transaction = transaction;
- }
-
- @Override
- public void handleReceive(Object message) throws Exception {
- if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- readData(transaction, ReadData.fromSerializable(message));
- } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
- dataExists(transaction, DataExists.fromSerializable(message));
- } else {
- super.handleReceive(message);
+ public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor,
+ SchemaContext schemaContext,String shardName) {
+ super(shardActor, schemaContext, shardName);
+ this.transaction = transaction;
}
- }
- protected void closeTransaction(CloseTransaction message) {
- transaction.close();
- getSender().tell(new CloseTransactionReply().toSerializable(), getSelf());
- getSelf().tell(PoisonPill.getInstance(), getSelf());
- }
- //default scope test method to check if we get correct exception
- void forUnitTestOnlyExplicitTransactionClose(){
- transaction.close();
- }
+ @Override
+ public void handleReceive(Object message) throws Exception {
+ if(ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ readData(transaction, ReadData.fromSerializable(message));
+ } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ dataExists(transaction, DataExists.fromSerializable(message));
+ } else {
+ super.handleReceive(message);
+ }
+ }
+ @Override
+ protected DOMStoreTransaction getDOMStoreTransaction() {
+ return transaction;
+ }
}
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorRef;
-import akka.actor.PoisonPill;
-import akka.event.Logging;
-import akka.event.LoggingAdapter;
-import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
-import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
+
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
import org.opendaylight.controller.cluster.datastore.messages.MergeData;
import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
import org.opendaylight.controller.cluster.datastore.messages.WriteData;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* Date: 8/6/14
*/
public class ShardReadWriteTransaction extends ShardTransaction {
- private final DOMStoreReadWriteTransaction transaction;
- private final LoggingAdapter log =
- Logging.getLogger(getContext().system(), this);
- public ShardReadWriteTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
- super(transactionChain, shardActor, schemaContext);
- this.transaction = transaction;
- }
-
- public ShardReadWriteTransaction(DOMStoreReadWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
- super( shardActor, schemaContext);
- this.transaction = transaction;
- }
+ private final DOMStoreReadWriteTransaction transaction;
- @Override
- public void handleReceive(Object message) throws Exception {
- if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- readData(transaction,ReadData.fromSerializable(message));
- }else if (WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- writeData(transaction, WriteData.fromSerializable(message, schemaContext));
- } else if (MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- mergeData(transaction, MergeData.fromSerializable(message, schemaContext));
- } else if (DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- deleteData(transaction,DeleteData.fromSerializable(message));
- } else if (ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) {
- readyTransaction(transaction,new ReadyTransaction());
- } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
- dataExists(transaction, DataExists.fromSerializable(message));
- }else {
- super.handleReceive(message);
+ public ShardReadWriteTransaction(DOMStoreReadWriteTransaction transaction, ActorRef shardActor,
+ SchemaContext schemaContext,String shardName) {
+ super(shardActor, schemaContext, shardName);
+ this.transaction = transaction;
}
- }
- protected void closeTransaction(CloseTransaction message) {
- transaction.close();
- getSender().tell(new CloseTransactionReply().toSerializable(), getSelf());
- getSelf().tell(PoisonPill.getInstance(), getSelf());
- }
+ @Override
+ public void handleReceive(Object message) throws Exception {
+ if(ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ readData(transaction, ReadData.fromSerializable(message));
+ } else if(WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ writeData(transaction, WriteData.fromSerializable(message, schemaContext));
+ } else if(MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ mergeData(transaction, MergeData.fromSerializable(message, schemaContext));
+ } else if(DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ deleteData(transaction, DeleteData.fromSerializable(message));
+ } else if(ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ readyTransaction(transaction, new ReadyTransaction());
+ } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ dataExists(transaction, DataExists.fromSerializable(message));
+ } else {
+ super.handleReceive(message);
+ }
+ }
- /**
- * The following method is used in unit testing only
- * hence the default scope.
- * This is done to test out failure cases.
- */
- public void forUnitTestOnlyExplicitTransactionClose() {
- transaction.close();
+ @Override
+ protected DOMStoreTransaction getDOMStoreTransaction() {
+ return transaction;
}
}
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorRef;
+import akka.actor.PoisonPill;
import akka.actor.Props;
-import akka.event.Logging;
-import akka.event.LoggingAdapter;
+import akka.actor.ReceiveTimeout;
import akka.japi.Creator;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
+import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply;
import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
public abstract class ShardTransaction extends AbstractUntypedActor {
- private final ActorRef shardActor;
- protected final SchemaContext schemaContext;
-
- // FIXME : see below
- // If transactionChain is not null then this transaction is part of a
- // transactionChain. Not really clear as to what that buys us
- private final DOMStoreTransactionChain transactionChain;
-
-
- private final MutableCompositeModification modification =
- new MutableCompositeModification();
-
- private final LoggingAdapter log =
- Logging.getLogger(getContext().system(), this);
-
- protected ShardTransaction(
- ActorRef shardActor, SchemaContext schemaContext) {
- this(null, shardActor, schemaContext);
- }
-
- protected ShardTransaction(DOMStoreTransactionChain transactionChain,
- ActorRef shardActor, SchemaContext schemaContext) {
- this.transactionChain = transactionChain;
- this.shardActor = shardActor;
- this.schemaContext = schemaContext;
- }
-
-
-
- public static Props props(final DOMStoreReadTransaction transaction,
- final ActorRef shardActor, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransaction>() {
-
- @Override
- public ShardTransaction create() throws Exception {
- return new ShardReadTransaction(transaction, shardActor, schemaContext);
- }
- });
- }
-
- public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreReadTransaction transaction,
- final ActorRef shardActor, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransaction>() {
-
- @Override
- public ShardTransaction create() throws Exception {
- return new ShardReadTransaction(transactionChain, transaction, shardActor, schemaContext);
- }
- });
- }
-
- public static Props props(final DOMStoreReadWriteTransaction transaction,
- final ActorRef shardActor, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransaction>() {
-
- @Override
- public ShardTransaction create() throws Exception {
- return new ShardReadWriteTransaction(transaction, shardActor, schemaContext);
- }
- });
- }
-
- public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreReadWriteTransaction transaction,
- final ActorRef shardActor, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransaction>() {
-
- @Override
- public ShardTransaction create() throws Exception {
- return new ShardReadWriteTransaction(transactionChain, transaction, shardActor, schemaContext);
- }
- });
- }
-
-
- public static Props props(final DOMStoreWriteTransaction transaction,
- final ActorRef shardActor, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransaction>() {
-
- @Override
- public ShardTransaction create() throws Exception {
- return new ShardWriteTransaction(transaction, shardActor, schemaContext);
- }
- });
- }
-
- public static Props props(final DOMStoreTransactionChain transactionChain, final DOMStoreWriteTransaction transaction,
- final ActorRef shardActor, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransaction>() {
-
- @Override
- public ShardTransaction create() throws Exception {
- return new ShardWriteTransaction(transactionChain, transaction, shardActor, schemaContext);
- }
- });
- }
-
-
- @Override
- public void handleReceive(Object message) throws Exception {
- if (message.getClass().equals(CloseTransaction.SERIALIZABLE_CLASS)) {
- closeTransaction(new CloseTransaction());
- } else if (message instanceof GetCompositedModification) {
- // This is here for testing only
- getSender().tell(new GetCompositeModificationReply(
- new ImmutableCompositeModification(modification)), getSelf());
- }else{
- throw new UnknownMessageException(message);
+ private final ActorRef shardActor;
+ protected final SchemaContext schemaContext;
+ private final String shardName;
+
+
+ private final MutableCompositeModification modification = new MutableCompositeModification();
+
+ protected ShardTransaction(ActorRef shardActor, SchemaContext schemaContext,
+ String shardName) {
+ this.shardActor = shardActor;
+ this.schemaContext = schemaContext;
+ this.shardName = shardName;
+ }
+
+ public static Props props(DOMStoreTransaction transaction, ActorRef shardActor,
+ SchemaContext schemaContext,DatastoreContext datastoreContext, String shardName) {
+ return Props.create(new ShardTransactionCreator(transaction, shardActor, schemaContext,
+ datastoreContext, shardName));
}
- }
- abstract protected void closeTransaction(CloseTransaction message);
+ protected abstract DOMStoreTransaction getDOMStoreTransaction();
+
+ @Override
+ public void handleReceive(Object message) throws Exception {
+ if (message.getClass().equals(CloseTransaction.SERIALIZABLE_CLASS)) {
+ closeTransaction(true);
+ } else if (message instanceof GetCompositedModification) {
+ // This is here for testing only
+ getSender().tell(new GetCompositeModificationReply(
+ new ImmutableCompositeModification(modification)), getSelf());
+ } else if (message instanceof ReceiveTimeout) {
+ LOG.debug("Got ReceiveTimeout for inactivity - closing Tx");
+ closeTransaction(false);
+ } else {
+ throw new UnknownMessageException(message);
+ }
+ }
- protected void readData(DOMStoreReadTransaction transaction,ReadData message) {
- final ActorRef sender = getSender();
- final ActorRef self = getSelf();
- final YangInstanceIdentifier path = message.getPath();
- final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future =
- transaction.read(path);
+ private void closeTransaction(boolean sendReply) {
+ getDOMStoreTransaction().close();
- future.addListener(new Runnable() {
- @Override
- public void run() {
- try {
- Optional<NormalizedNode<?, ?>> optional = future.checkedGet();
- if (optional.isPresent()) {
- sender.tell(new ReadDataReply(schemaContext,optional.get()).toSerializable(), self);
- } else {
- sender.tell(new ReadDataReply(schemaContext,null).toSerializable(), self);
- }
- } catch (Exception e) {
- sender.tell(new akka.actor.Status.Failure(e),self);
+ if(sendReply) {
+ getSender().tell(new CloseTransactionReply().toSerializable(), getSelf());
}
- }
- }, getContext().dispatcher());
- }
+ getSelf().tell(PoisonPill.getInstance(), getSelf());
+ }
+
+ protected void readData(DOMStoreReadTransaction transaction,ReadData message) {
+ final ActorRef sender = getSender();
+ final ActorRef self = getSelf();
+ final YangInstanceIdentifier path = message.getPath();
+ final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future =
+ transaction.read(path);
+
+ future.addListener(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Optional<NormalizedNode<?, ?>> optional = future.checkedGet();
+ if (optional.isPresent()) {
+ sender.tell(new ReadDataReply(schemaContext,optional.get()).toSerializable(), self);
+ } else {
+ sender.tell(new ReadDataReply(schemaContext,null).toSerializable(), self);
+ }
+ } catch (Exception e) {
+ ShardMBeanFactory.getShardStatsMBean(shardName).incrementFailedReadTransactionsCount();
+ sender.tell(new akka.actor.Status.Failure(e), self);
+ }
+
+ }
+ }, getContext().dispatcher());
+ }
protected void dataExists(DOMStoreReadTransaction transaction, DataExists message) {
final YangInstanceIdentifier path = message.getPath();
}
- protected void writeData(DOMStoreWriteTransaction transaction, WriteData message) {
- modification.addModification(
- new WriteModification(message.getPath(), message.getData(),schemaContext));
- LOG.debug("writeData at path : " + message.getPath().toString());
+ protected void writeData(DOMStoreWriteTransaction transaction, WriteData message) {
+ modification.addModification(
+ new WriteModification(message.getPath(), message.getData(),schemaContext));
+ LOG.debug("writeData at path : " + message.getPath().toString());
- try {
- transaction.write(message.getPath(), message.getData());
- getSender().tell(new WriteDataReply().toSerializable(), getSelf());
- }catch(Exception e){
- getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ try {
+ transaction.write(message.getPath(), message.getData());
+ getSender().tell(new WriteDataReply().toSerializable(), getSelf());
+ }catch(Exception e){
+ getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ }
}
- }
-
- protected void mergeData(DOMStoreWriteTransaction transaction, MergeData message) {
- modification.addModification(
- new MergeModification(message.getPath(), message.getData(), schemaContext));
- LOG.debug("mergeData at path : " + message.getPath().toString());
- try {
- transaction.merge(message.getPath(), message.getData());
- getSender().tell(new MergeDataReply().toSerializable(), getSelf());
- }catch(Exception e){
- getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+
+ protected void mergeData(DOMStoreWriteTransaction transaction, MergeData message) {
+ modification.addModification(
+ new MergeModification(message.getPath(), message.getData(), schemaContext));
+ LOG.debug("mergeData at path : " + message.getPath().toString());
+ try {
+ transaction.merge(message.getPath(), message.getData());
+ getSender().tell(new MergeDataReply().toSerializable(), getSelf());
+ }catch(Exception e){
+ getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ }
}
- }
-
- protected void deleteData(DOMStoreWriteTransaction transaction, DeleteData message) {
- LOG.debug("deleteData at path : " + message.getPath().toString());
- modification.addModification(new DeleteModification(message.getPath()));
- try {
- transaction.delete(message.getPath());
- getSender().tell(new DeleteDataReply().toSerializable(), getSelf());
- }catch(Exception e){
- getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+
+ protected void deleteData(DOMStoreWriteTransaction transaction, DeleteData message) {
+ LOG.debug("deleteData at path : " + message.getPath().toString());
+ modification.addModification(new DeleteModification(message.getPath()));
+ try {
+ transaction.delete(message.getPath());
+ getSender().tell(new DeleteDataReply().toSerializable(), getSelf());
+ }catch(Exception e){
+ getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ }
}
- }
- protected void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message) {
- DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
- ActorRef cohortActor = getContext().actorOf(
- ThreePhaseCommitCohort.props(cohort, shardActor, modification), "cohort");
- getSender()
+ protected void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message) {
+ DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
+ ActorRef cohortActor = getContext().actorOf(
+ ThreePhaseCommitCohort.props(cohort, shardActor, modification, shardName), "cohort");
+ getSender()
.tell(new ReadyTransactionReply(cohortActor.path()).toSerializable(), getSelf());
- }
+ }
+ private static class ShardTransactionCreator implements Creator<ShardTransaction> {
- // These classes are in here for test purposes only
+ private static final long serialVersionUID = 1L;
+ final DOMStoreTransaction transaction;
+ final ActorRef shardActor;
+ final SchemaContext schemaContext;
+ final DatastoreContext datastoreContext;
+ final String shardName;
- static class GetCompositedModification {
+ ShardTransactionCreator(DOMStoreTransaction transaction, ActorRef shardActor,
+ SchemaContext schemaContext, DatastoreContext datastoreContext, String shardName) {
+ this.transaction = transaction;
+ this.shardActor = shardActor;
+ this.shardName = shardName;
+ this.schemaContext = schemaContext;
+ this.datastoreContext = datastoreContext;
+ }
- }
+ @Override
+ public ShardTransaction create() throws Exception {
+ ShardTransaction tx;
+ if(transaction instanceof DOMStoreReadWriteTransaction) {
+ tx = new ShardReadWriteTransaction((DOMStoreReadWriteTransaction)transaction,
+ shardActor, schemaContext, shardName);
+ } else if(transaction instanceof DOMStoreReadTransaction) {
+ tx = new ShardReadTransaction((DOMStoreReadTransaction)transaction, shardActor,
+ schemaContext, shardName);
+ } else {
+ tx = new ShardWriteTransaction((DOMStoreWriteTransaction)transaction,
+ shardActor, schemaContext, shardName);
+ }
+
+ tx.getContext().setReceiveTimeout(datastoreContext.getShardTransactionIdleTimeout());
+ return tx;
+ }
+ }
+ // These classes are in here for test purposes only
- static class GetCompositeModificationReply {
- private final CompositeModification modification;
+ static class GetCompositedModification {
+ }
- GetCompositeModificationReply(CompositeModification modification) {
- this.modification = modification;
- }
+ static class GetCompositeModificationReply {
+ private final CompositeModification modification;
- public CompositeModification getModification() {
- return modification;
+ GetCompositeModificationReply(CompositeModification modification) {
+ this.modification = modification;
+ }
+
+
+ public CompositeModification getModification() {
+ return modification;
+ }
}
- }
}
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.japi.Creator;
+
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChainReply;
import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
public class ShardTransactionChain extends AbstractUntypedActor {
private final DOMStoreTransactionChain chain;
+ private final DatastoreContext datastoreContext;
private final SchemaContext schemaContext;
+ private final String shardName;
- public ShardTransactionChain(DOMStoreTransactionChain chain, SchemaContext schemaContext) {
+ public ShardTransactionChain(DOMStoreTransactionChain chain, SchemaContext schemaContext,
+ DatastoreContext datastoreContext,String shardName) {
this.chain = chain;
+ this.datastoreContext = datastoreContext;
this.schemaContext = schemaContext;
+ this.shardName = shardName;
}
@Override
return getContext().parent();
}
- private ActorRef createTypedTransactionActor(CreateTransaction createTransaction,String transactionId){
- if(createTransaction.getTransactionType()== TransactionProxy.TransactionType.READ_ONLY.ordinal()){
- return getContext().actorOf(
- ShardTransaction.props( chain.newReadOnlyTransaction(), getShardActor(), schemaContext), transactionId);
-
- }else if (createTransaction.getTransactionType()== TransactionProxy.TransactionType.READ_WRITE.ordinal()){
- return getContext().actorOf(
- ShardTransaction.props( chain.newReadWriteTransaction(), getShardActor(), schemaContext), transactionId);
-
-
- }else if (createTransaction.getTransactionType()== TransactionProxy.TransactionType.WRITE_ONLY.ordinal()){
- return getContext().actorOf(
- ShardTransaction.props( chain.newWriteOnlyTransaction(), getShardActor(), schemaContext), transactionId);
- }else{
- throw new IllegalArgumentException ("CreateTransaction message has unidentified transaction type="+createTransaction.getTransactionType()) ;
+ private ActorRef createTypedTransactionActor(CreateTransaction createTransaction,
+ String transactionId) {
+ if(createTransaction.getTransactionType() ==
+ TransactionProxy.TransactionType.READ_ONLY.ordinal()) {
+ return getContext().actorOf(
+ ShardTransaction.props( chain.newReadOnlyTransaction(), getShardActor(),
+ schemaContext, datastoreContext,shardName), transactionId);
+ } else if (createTransaction.getTransactionType() ==
+ TransactionProxy.TransactionType.READ_WRITE.ordinal()) {
+ return getContext().actorOf(
+ ShardTransaction.props( chain.newReadWriteTransaction(), getShardActor(),
+ schemaContext, datastoreContext,shardName), transactionId);
+ } else if (createTransaction.getTransactionType() ==
+ TransactionProxy.TransactionType.WRITE_ONLY.ordinal()) {
+ return getContext().actorOf(
+ ShardTransaction.props( chain.newWriteOnlyTransaction(), getShardActor(),
+ schemaContext, datastoreContext,shardName), transactionId);
+ } else {
+ throw new IllegalArgumentException (
+ "CreateTransaction message has unidentified transaction type=" +
+ createTransaction.getTransactionType());
+ }
}
- }
private void createTransaction(CreateTransaction createTransaction) {
getSelf());
}
- public static Props props(final DOMStoreTransactionChain chain, final SchemaContext schemaContext) {
- return Props.create(new Creator<ShardTransactionChain>() {
+ public static Props props(DOMStoreTransactionChain chain, SchemaContext schemaContext,
+ DatastoreContext datastoreContext, String shardName) {
+ return Props.create(new ShardTransactionChainCreator(chain, schemaContext, datastoreContext, shardName));
+ }
+
+ private static class ShardTransactionChainCreator implements Creator<ShardTransactionChain> {
+ private static final long serialVersionUID = 1L;
+
+ final DOMStoreTransactionChain chain;
+ final DatastoreContext datastoreContext;
+ final SchemaContext schemaContext;
+ final String shardName;
+
- @Override
- public ShardTransactionChain create() throws Exception {
- return new ShardTransactionChain(chain, schemaContext);
- }
- });
+ ShardTransactionChainCreator(DOMStoreTransactionChain chain, SchemaContext schemaContext,
+ DatastoreContext datastoreContext, String shardName) {
+ this.chain = chain;
+ this.datastoreContext = datastoreContext;
+ this.schemaContext = schemaContext;
+ this.shardName = shardName;
+ }
+
+ @Override
+ public ShardTransactionChain create() throws Exception {
+ return new ShardTransactionChain(chain, schemaContext, datastoreContext,shardName);
+ }
}
}
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorRef;
-import akka.actor.PoisonPill;
-import akka.event.Logging;
-import akka.event.LoggingAdapter;
-import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
-import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
+
import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
import org.opendaylight.controller.cluster.datastore.messages.MergeData;
import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
import org.opendaylight.controller.cluster.datastore.messages.WriteData;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
* Date: 8/6/14
*/
public class ShardWriteTransaction extends ShardTransaction {
- private final DOMStoreWriteTransaction transaction;
- private final LoggingAdapter log =
- Logging.getLogger(getContext().system(), this);
- public ShardWriteTransaction(DOMStoreWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
- super( shardActor, schemaContext);
- this.transaction = transaction;
-
- }
+ private final DOMStoreWriteTransaction transaction;
- public ShardWriteTransaction(DOMStoreTransactionChain transactionChain, DOMStoreWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
- super(transactionChain, shardActor, schemaContext);
- this.transaction = transaction;
- }
-
- @Override
- public void handleReceive(Object message) throws Exception {
- if (WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- writeData(transaction, WriteData.fromSerializable(message, schemaContext));
- } else if (MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- mergeData(transaction, MergeData.fromSerializable(message, schemaContext));
- } else if (DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
- deleteData(transaction,DeleteData.fromSerializable(message));
- } else if (ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) {
- readyTransaction(transaction,new ReadyTransaction());
- }else {
- super.handleReceive(message);
+ public ShardWriteTransaction(DOMStoreWriteTransaction transaction, ActorRef shardActor,
+ SchemaContext schemaContext,String shardName) {
+ super(shardActor, schemaContext, shardName);
+ this.transaction = transaction;
}
- }
- protected void closeTransaction(CloseTransaction message) {
- transaction.close();
- getSender().tell(new CloseTransactionReply().toSerializable(), getSelf());
- getSelf().tell(PoisonPill.getInstance(), getSelf());
- }
+ @Override
+ public void handleReceive(Object message) throws Exception {
+ if(WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ writeData(transaction, WriteData.fromSerializable(message, schemaContext));
+ } else if(MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ mergeData(transaction, MergeData.fromSerializable(message, schemaContext));
+ } else if(DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ deleteData(transaction, DeleteData.fromSerializable(message));
+ } else if(ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) {
+ readyTransaction(transaction, new ReadyTransaction());
+ } else {
+ super.handleReceive(message);
+ }
+ }
- /**
- * The following method is used in unit testing only
- * hence the default scope.
- * This is done to test out failure cases.
- */
- public void forUnitTestOnlyExplicitTransactionClose() {
- transaction.close();
+ @Override
+ protected DOMStoreTransaction getDOMStoreTransaction() {
+ return transaction;
}
}
import akka.event.Logging;
import akka.event.LoggingAdapter;
import akka.japi.Creator;
+
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+
+import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory;
import org.opendaylight.controller.cluster.datastore.messages.AbortTransaction;
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply;
import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransaction;
private final DOMStoreThreePhaseCommitCohort cohort;
private final ActorRef shardActor;
private final CompositeModification modification;
+ private final String shardName;
public ThreePhaseCommitCohort(DOMStoreThreePhaseCommitCohort cohort,
- ActorRef shardActor, CompositeModification modification) {
+ ActorRef shardActor, CompositeModification modification,String shardName) {
this.cohort = cohort;
this.shardActor = shardActor;
this.modification = modification;
+ this.shardName = shardName;
}
private final LoggingAdapter log =
Logging.getLogger(getContext().system(), this);
public static Props props(final DOMStoreThreePhaseCommitCohort cohort,
- final ActorRef shardActor, final CompositeModification modification) {
- return Props.create(new Creator<ThreePhaseCommitCohort>() {
- @Override
- public ThreePhaseCommitCohort create() throws Exception {
- return new ThreePhaseCommitCohort(cohort, shardActor,
- modification);
- }
- });
+ final ActorRef shardActor, final CompositeModification modification,
+ String shardName) {
+ return Props.create(new ThreePhaseCommitCohortCreator(cohort, shardActor, modification,
+ shardName));
}
-
@Override
public void handleReceive(Object message) throws Exception {
if (message.getClass()
final ActorRef self = getSelf();
Futures.addCallback(future, new FutureCallback<Void>() {
+ @Override
public void onSuccess(Void v) {
+ ShardMBeanFactory.getShardStatsMBean(shardName).incrementAbortTransactionsCount();
sender
.tell(new AbortTransactionReply().toSerializable(),
- self);
+ self);
}
+ @Override
public void onFailure(Throwable t) {
LOG.error(t, "An exception happened during abort");
sender
final ActorRef sender = getSender();
final ActorRef self = getSelf();
Futures.addCallback(future, new FutureCallback<Void>() {
+ @Override
public void onSuccess(Void v) {
sender
.tell(new PreCommitTransactionReply().toSerializable(),
self);
}
+ @Override
public void onFailure(Throwable t) {
LOG.error(t, "An exception happened during pre-commit");
sender
final ActorRef sender = getSender();
final ActorRef self = getSelf();
Futures.addCallback(future, new FutureCallback<Boolean>() {
+ @Override
public void onSuccess(Boolean canCommit) {
sender.tell(new CanCommitTransactionReply(canCommit)
.toSerializable(), self);
}
+ @Override
public void onFailure(Throwable t) {
LOG.error(t, "An exception happened during canCommit");
sender
.tell(new akka.actor.Status.Failure(t), self);
}
});
+ }
+ private static class ThreePhaseCommitCohortCreator implements Creator<ThreePhaseCommitCohort> {
+ final DOMStoreThreePhaseCommitCohort cohort;
+ final ActorRef shardActor;
+ final CompositeModification modification;
+ final String shardName;
+
+ ThreePhaseCommitCohortCreator(DOMStoreThreePhaseCommitCohort cohort,
+ ActorRef shardActor, CompositeModification modification, String shardName) {
+ this.cohort = cohort;
+ this.shardActor = shardActor;
+ this.modification = modification;
+ this.shardName = shardName;
+ }
+ @Override
+ public ThreePhaseCommitCohort create() throws Exception {
+ return new ThreePhaseCommitCohort(cohort, shardActor, modification, shardName);
+ }
}
}
import akka.dispatch.Futures;
import akka.dispatch.OnComplete;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
+import scala.runtime.AbstractFunction1;
import java.util.Collections;
import java.util.List;
*/
public class ThreePhaseCommitCohortProxy implements DOMStoreThreePhaseCommitCohort{
- private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStore.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ThreePhaseCommitCohortProxy.class);
private final ActorContext actorContext;
- private final List<ActorPath> cohortPaths;
+ private final List<Future<ActorPath>> cohortPathFutures;
+ private volatile List<ActorPath> cohortPaths;
private final String transactionId;
- public ThreePhaseCommitCohortProxy(ActorContext actorContext, List<ActorPath> cohortPaths,
- String transactionId) {
+ public ThreePhaseCommitCohortProxy(ActorContext actorContext,
+ List<Future<ActorPath>> cohortPathFutures, String transactionId) {
this.actorContext = actorContext;
- this.cohortPaths = cohortPaths;
+ this.cohortPathFutures = cohortPathFutures;
this.transactionId = transactionId;
}
+ private Future<Void> buildCohortPathsList() {
+
+ Future<Iterable<ActorPath>> combinedFutures = Futures.sequence(cohortPathFutures,
+ actorContext.getActorSystem().dispatcher());
+
+ return combinedFutures.transform(new AbstractFunction1<Iterable<ActorPath>, Void>() {
+ @Override
+ public Void apply(Iterable<ActorPath> paths) {
+ cohortPaths = Lists.newArrayList(paths);
+
+ LOG.debug("Tx {} successfully built cohort path list: {}",
+ transactionId, cohortPaths);
+ return null;
+ }
+ }, TransactionProxy.SAME_FAILURE_TRANSFORMER, actorContext.getActorSystem().dispatcher());
+ }
+
@Override
public ListenableFuture<Boolean> canCommit() {
- LOG.debug("txn {} canCommit", transactionId);
+ LOG.debug("Tx {} canCommit", transactionId);
+
+ final SettableFuture<Boolean> returnFuture = SettableFuture.create();
+
+ // The first phase of canCommit is to gather the list of cohort actor paths that will
+ // participate in the commit. buildCohortPathsList combines the cohort path Futures into
+ // one Future which we wait on asynchronously here. The cohort actor paths are
+ // extracted from ReadyTransactionReply messages by the Futures that were obtained earlier
+ // and passed to us from upstream processing. If any one fails then we'll fail canCommit.
+
+ buildCohortPathsList().onComplete(new OnComplete<Void>() {
+ @Override
+ public void onComplete(Throwable failure, Void notUsed) throws Throwable {
+ if(failure != null) {
+ LOG.debug("Tx {}: a cohort path Future failed: {}", transactionId, failure);
+ returnFuture.setException(failure);
+ } else {
+ finishCanCommit(returnFuture);
+ }
+ }
+ }, actorContext.getActorSystem().dispatcher());
+
+ return returnFuture;
+ }
+
+ private void finishCanCommit(final SettableFuture<Boolean> returnFuture) {
+
+ LOG.debug("Tx {} finishCanCommit", transactionId);
+
+ // The last phase of canCommit is to invoke all the cohort actors asynchronously to perform
+ // their canCommit processing. If any one fails then we'll fail canCommit.
Future<Iterable<Object>> combinedFuture =
invokeCohorts(new CanCommitTransaction().toSerializable());
- final SettableFuture<Boolean> returnFuture = SettableFuture.create();
-
combinedFuture.onComplete(new OnComplete<Iterable<Object>>() {
@Override
public void onComplete(Throwable failure, Iterable<Object> responses) throws Throwable {
if(failure != null) {
+ LOG.debug("Tx {}: a canCommit cohort Future failed: {}", transactionId, failure);
returnFuture.setException(failure);
return;
}
}
}
+ LOG.debug("Tx {}: canCommit returning result: {}", transactionId, result);
+
returnFuture.set(Boolean.valueOf(result));
}
}, actorContext.getActorSystem().dispatcher());
-
- return returnFuture;
}
private Future<Iterable<Object>> invokeCohorts(Object message) {
List<Future<Object>> futureList = Lists.newArrayListWithCapacity(cohortPaths.size());
for(ActorPath actorPath : cohortPaths) {
- LOG.debug("txn {} Sending {} to {}", transactionId, message, actorPath);
+ LOG.debug("Tx {}: Sending {} to cohort {}", transactionId, message, actorPath);
ActorSelection cohort = actorContext.actorSelection(actorPath);
@Override
public ListenableFuture<Void> preCommit() {
- LOG.debug("txn {} preCommit", transactionId);
- return voidOperation(new PreCommitTransaction().toSerializable(),
+ return voidOperation("preCommit", new PreCommitTransaction().toSerializable(),
PreCommitTransactionReply.SERIALIZABLE_CLASS, true);
}
@Override
public ListenableFuture<Void> abort() {
- LOG.debug("txn {} abort", transactionId);
-
// Note - we pass false for propagateException. In the front-end data broker, this method
// is called when one of the 3 phases fails with an exception. We'd rather have that
// original exception propagated to the client. If our abort fails and we propagate the
// exception then that exception will supersede and suppress the original exception. But
// it's the original exception that is the root cause and of more interest to the client.
- return voidOperation(new AbortTransaction().toSerializable(),
+ return voidOperation("abort", new AbortTransaction().toSerializable(),
AbortTransactionReply.SERIALIZABLE_CLASS, false);
}
@Override
public ListenableFuture<Void> commit() {
- LOG.debug("txn {} commit", transactionId);
- return voidOperation(new CommitTransaction().toSerializable(),
+ return voidOperation("commit", new CommitTransaction().toSerializable(),
CommitTransactionReply.SERIALIZABLE_CLASS, true);
}
- private ListenableFuture<Void> voidOperation(final Object message,
+ private ListenableFuture<Void> voidOperation(final String operationName, final Object message,
final Class<?> expectedResponseClass, final boolean propagateException) {
- Future<Iterable<Object>> combinedFuture = invokeCohorts(message);
+ LOG.debug("Tx {} {}", transactionId, operationName);
final SettableFuture<Void> returnFuture = SettableFuture.create();
+ // The cohort actor list should already be built at this point by the canCommit phase but,
+ // if not for some reason, we'll try to build it here.
+
+ if(cohortPaths != null) {
+ finishVoidOperation(operationName, message, expectedResponseClass, propagateException,
+ returnFuture);
+ } else {
+ buildCohortPathsList().onComplete(new OnComplete<Void>() {
+ @Override
+ public void onComplete(Throwable failure, Void notUsed) throws Throwable {
+ if(failure != null) {
+ LOG.debug("Tx {}: a {} cohort path Future failed: {}", transactionId,
+ operationName, failure);
+
+ if(propagateException) {
+ returnFuture.setException(failure);
+ } else {
+ returnFuture.set(null);
+ }
+ } else {
+ finishVoidOperation(operationName, message, expectedResponseClass,
+ propagateException, returnFuture);
+ }
+ }
+ }, actorContext.getActorSystem().dispatcher());
+ }
+
+ return returnFuture;
+ }
+
+ private void finishVoidOperation(final String operationName, final Object message,
+ final Class<?> expectedResponseClass, final boolean propagateException,
+ final SettableFuture<Void> returnFuture) {
+
+ LOG.debug("Tx {} finish {}", transactionId, operationName);
+
+ Future<Iterable<Object>> combinedFuture = invokeCohorts(message);
+
combinedFuture.onComplete(new OnComplete<Iterable<Object>>() {
@Override
public void onComplete(Throwable failure, Iterable<Object> responses) throws Throwable {
}
if(exceptionToPropagate != null) {
+ LOG.debug("Tx {}: a {} cohort Future failed: {}", transactionId,
+ operationName, exceptionToPropagate);
+
if(propagateException) {
// We don't log the exception here to avoid redundant logging since we're
// propagating to the caller in MD-SAL core who will log it.
returnFuture.set(null);
}
} else {
+ LOG.debug("Tx {}: {} succeeded", transactionId, operationName);
returnFuture.set(null);
}
}
}, actorContext.getActorSystem().dispatcher());
-
- return returnFuture;
}
- public List<ActorPath> getCohortPaths() {
- return Collections.unmodifiableList(this.cohortPaths);
+ @VisibleForTesting
+ List<Future<ActorPath>> getCohortPathFutures() {
+ return Collections.unmodifiableList(cohortPathFutures);
}
}
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* TransactionChainProxy acts as a proxy for a DOMStoreTransactionChain created on a remote shard
*/
public class TransactionChainProxy implements DOMStoreTransactionChain{
private final ActorContext actorContext;
- private final SchemaContext schemaContext;
- public TransactionChainProxy(ActorContext actorContext, SchemaContext schemaContext) {
+ public TransactionChainProxy(ActorContext actorContext) {
this.actorContext = actorContext;
- this.schemaContext = schemaContext;
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
return new TransactionProxy(actorContext,
- TransactionProxy.TransactionType.READ_ONLY, schemaContext);
+ TransactionProxy.TransactionType.READ_ONLY);
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
return new TransactionProxy(actorContext,
- TransactionProxy.TransactionType.WRITE_ONLY, schemaContext);
+ TransactionProxy.TransactionType.READ_WRITE);
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
return new TransactionProxy(actorContext,
- TransactionProxy.TransactionType.READ_WRITE, schemaContext);
+ TransactionProxy.TransactionType.WRITE_ONLY);
}
@Override
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorPath;
-import akka.actor.ActorRef;
import akka.actor.ActorSelection;
-import akka.actor.Props;
import akka.dispatch.OnComplete;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.FinalizablePhantomReference;
+import com.google.common.base.FinalizableReferenceQueue;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import scala.Function1;
import scala.concurrent.Future;
+import scala.runtime.AbstractFunction1;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
/**
READ_WRITE
}
+ static Function1<Throwable, Throwable> SAME_FAILURE_TRANSFORMER = new AbstractFunction1<
+ Throwable, Throwable>() {
+ @Override
+ public Throwable apply(Throwable failure) {
+ return failure;
+ }
+ };
+
private static final AtomicLong counter = new AtomicLong();
private static final Logger
LOG = LoggerFactory.getLogger(TransactionProxy.class);
+ /**
+ * Used to enqueue the PhantomReferences for read-only TransactionProxy instances. The
+ * FinalizableReferenceQueue is safe to use statically in an OSGi environment as it uses some
+ * trickery to clean up its internal thread when the bundle is unloaded.
+ */
+ private static final FinalizableReferenceQueue phantomReferenceQueue =
+ new FinalizableReferenceQueue();
+
+ /**
+ * This stores the TransactionProxyCleanupPhantomReference instances statically, This is
+ * necessary because PhantomReferences need a hard reference so they're not garbage collected.
+ * Once finalized, the TransactionProxyCleanupPhantomReference removes itself from this map
+ * and thus becomes eligible for garbage collection.
+ */
+ private static final Map<TransactionProxyCleanupPhantomReference,
+ TransactionProxyCleanupPhantomReference> phantomReferenceCache =
+ new ConcurrentHashMap<>();
+
+ /**
+ * A PhantomReference that closes remote transactions for a TransactionProxy when it's
+ * garbage collected. This is used for read-only transactions as they're not explicitly closed
+ * by clients. So the only way to detect that a transaction is no longer in use and it's safe
+ * to clean up is when it's garbage collected. It's inexact as to when an instance will be GC'ed
+ * but TransactionProxy instances should generally be short-lived enough to avoid being moved
+ * to the old generation space and thus should be cleaned up in a timely manner as the GC
+ * runs on the young generation (eden, swap1...) space much more frequently.
+ */
+ private static class TransactionProxyCleanupPhantomReference
+ extends FinalizablePhantomReference<TransactionProxy> {
+
+ private final List<ActorSelection> remoteTransactionActors;
+ private final AtomicBoolean remoteTransactionActorsMB;
+ private final ActorContext actorContext;
+ private final TransactionIdentifier identifier;
+
+ protected TransactionProxyCleanupPhantomReference(TransactionProxy referent) {
+ super(referent, phantomReferenceQueue);
+
+ // Note we need to cache the relevant fields from the TransactionProxy as we can't
+ // have a hard reference to the TransactionProxy instance itself.
+
+ remoteTransactionActors = referent.remoteTransactionActors;
+ remoteTransactionActorsMB = referent.remoteTransactionActorsMB;
+ actorContext = referent.actorContext;
+ identifier = referent.identifier;
+ }
+
+ @Override
+ public void finalizeReferent() {
+ LOG.trace("Cleaning up {} Tx actors for TransactionProxy {}",
+ remoteTransactionActors.size(), identifier);
+
+ phantomReferenceCache.remove(this);
+
+ // Access the memory barrier volatile to ensure all previous updates to the
+ // remoteTransactionActors list are visible to this thread.
+
+ if(remoteTransactionActorsMB.get()) {
+ for(ActorSelection actor : remoteTransactionActors) {
+ LOG.trace("Sending CloseTransaction to {}", actor);
+ actorContext.sendRemoteOperationAsync(actor,
+ new CloseTransaction().toSerializable());
+ }
+ }
+ }
+ }
+
+ /**
+ * Stores the remote Tx actors for each requested data store path to be used by the
+ * PhantomReference to close the remote Tx's. This is only used for read-only Tx's. The
+ * remoteTransactionActorsMB volatile serves as a memory barrier to publish updates to the
+ * remoteTransactionActors list so they will be visible to the thread accessing the
+ * PhantomReference.
+ */
+ private List<ActorSelection> remoteTransactionActors;
+ private AtomicBoolean remoteTransactionActorsMB;
+
+ private final Map<String, TransactionContext> remoteTransactionPaths = new HashMap<>();
+
private final TransactionType transactionType;
private final ActorContext actorContext;
- private final Map<String, TransactionContext> remoteTransactionPaths = new HashMap<>();
private final TransactionIdentifier identifier;
private final SchemaContext schemaContext;
private boolean inReadyState;
- public TransactionProxy(ActorContext actorContext, TransactionType transactionType,
- SchemaContext schemaContext) {
- this.actorContext = Preconditions.checkNotNull(actorContext, "actorContext should not be null");
- this.transactionType = Preconditions.checkNotNull(transactionType, "transactionType should not be null");
- this.schemaContext = Preconditions.checkNotNull(schemaContext, "schemaContext should not be null");
+ public TransactionProxy(ActorContext actorContext, TransactionType transactionType) {
+ this.actorContext = Preconditions.checkNotNull(actorContext,
+ "actorContext should not be null");
+ this.transactionType = Preconditions.checkNotNull(transactionType,
+ "transactionType should not be null");
+ this.schemaContext = Preconditions.checkNotNull(actorContext.getSchemaContext(),
+ "schemaContext should not be null");
String memberName = actorContext.getCurrentMemberName();
if(memberName == null){
this.identifier = TransactionIdentifier.builder().memberName(memberName).counter(
counter.getAndIncrement()).build();
- LOG.debug("Created txn {}", identifier);
+ if(transactionType == TransactionType.READ_ONLY) {
+ // Read-only Tx's aren't explicitly closed by the client so we create a PhantomReference
+ // to close the remote Tx's when this instance is no longer in use and is garbage
+ // collected.
+ remoteTransactionActors = Lists.newArrayList();
+ remoteTransactionActorsMB = new AtomicBoolean();
+
+ TransactionProxyCleanupPhantomReference cleanup =
+ new TransactionProxyCleanupPhantomReference(this);
+ phantomReferenceCache.put(cleanup, cleanup);
+ }
+
+ LOG.debug("Created txn {} of type {}", identifier, transactionType);
+ }
+
+ @VisibleForTesting
+ List<Future<Object>> getRecordedOperationFutures() {
+ List<Future<Object>> recordedOperationFutures = Lists.newArrayList();
+ for(TransactionContext transactionContext : remoteTransactionPaths.values()) {
+ recordedOperationFutures.addAll(transactionContext.getRecordedOperationFutures());
+ }
+
+ return recordedOperationFutures;
}
@Override
Preconditions.checkState(transactionType != TransactionType.WRITE_ONLY,
"Read operation on write-only transaction is not allowed");
- LOG.debug("txn {} read {}", identifier, path);
+ LOG.debug("Tx {} read {}", identifier, path);
createTransactionIfMissing(actorContext, path);
Preconditions.checkState(transactionType != TransactionType.WRITE_ONLY,
"Exists operation on write-only transaction is not allowed");
- LOG.debug("txn {} exists {}", identifier, path);
+ LOG.debug("Tx {} exists {}", identifier, path);
createTransactionIfMissing(actorContext, path);
Preconditions.checkState(transactionType != TransactionType.READ_ONLY,
"Modification operation on read-only transaction is not allowed");
Preconditions.checkState(!inReadyState,
- "Transaction is sealed - further modifications are allowed");
+ "Transaction is sealed - further modifications are not allowed");
}
@Override
checkModificationState();
- LOG.debug("txn {} write {}", identifier, path);
+ LOG.debug("Tx {} write {}", identifier, path);
createTransactionIfMissing(actorContext, path);
checkModificationState();
- LOG.debug("txn {} merge {}", identifier, path);
+ LOG.debug("Tx {} merge {}", identifier, path);
createTransactionIfMissing(actorContext, path);
checkModificationState();
- LOG.debug("txn {} delete {}", identifier, path);
+ LOG.debug("Tx {} delete {}", identifier, path);
createTransactionIfMissing(actorContext, path);
inReadyState = true;
- List<ActorPath> cohortPaths = new ArrayList<>();
-
- LOG.debug("txn {} Trying to get {} transactions ready for commit", identifier,
+ LOG.debug("Tx {} Trying to get {} transactions ready for commit", identifier,
remoteTransactionPaths.size());
+ List<Future<ActorPath>> cohortPathFutures = Lists.newArrayList();
+
for(TransactionContext transactionContext : remoteTransactionPaths.values()) {
- LOG.debug("txn {} Readying transaction for shard {}", identifier,
+ LOG.debug("Tx {} Readying transaction for shard {}", identifier,
transactionContext.getShardName());
- Object result = transactionContext.readyTransaction();
-
- if(result.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)){
- ReadyTransactionReply reply = ReadyTransactionReply.fromSerializable(
- actorContext.getActorSystem(),result);
- String resolvedCohortPath = transactionContext.getResolvedCohortPath(
- reply.getCohortPath().toString());
- cohortPaths.add(actorContext.actorFor(resolvedCohortPath));
- } else {
- LOG.error("Was expecting {} but got {}", ReadyTransactionReply.SERIALIZABLE_CLASS,
- result.getClass());
- }
+ cohortPathFutures.add(transactionContext.readyTransaction());
}
- return new ThreePhaseCommitCohortProxy(actorContext, cohortPaths, identifier.toString());
+ return new ThreePhaseCommitCohortProxy(actorContext, cohortPathFutures,
+ identifier.toString());
}
@Override
for(TransactionContext transactionContext : remoteTransactionPaths.values()) {
transactionContext.closeTransaction();
}
+
+ remoteTransactionPaths.clear();
+
+ if(transactionType == TransactionType.READ_ONLY) {
+ remoteTransactionActors.clear();
+ remoteTransactionActorsMB.set(true);
+ }
}
private TransactionContext transactionContext(YangInstanceIdentifier path){
String transactionPath = reply.getTransactionPath();
- LOG.debug("txn {} Received transaction path = {}", identifier, transactionPath);
+ LOG.debug("Tx {} Received transaction path = {}", identifier, transactionPath);
+
+ ActorSelection transactionActor = actorContext.actorSelection(transactionPath);
- ActorSelection transactionActor =
- actorContext.actorSelection(transactionPath);
- transactionContext =
- new TransactionContextImpl(shardName, transactionPath,
- transactionActor);
+ if(transactionType == TransactionType.READ_ONLY) {
+ // Add the actor to the remoteTransactionActors list for access by the
+ // cleanup PhantonReference.
+ remoteTransactionActors.add(transactionActor);
+
+ // Write to the memory barrier volatile to publish the above update to the
+ // remoteTransactionActors list for thread visibility.
+ remoteTransactionActorsMB.set(true);
+ }
+
+ transactionContext = new TransactionContextImpl(shardName, transactionPath,
+ transactionActor, identifier, actorContext, schemaContext);
remoteTransactionPaths.put(shardName, transactionContext);
} else {
- LOG.error("Was expecting {} but got {}", CreateTransactionReply.SERIALIZABLE_CLASS,
- response.getClass());
+ throw new IllegalArgumentException(String.format(
+ "Invalid reply type {} for CreateTransaction", response.getClass()));
}
} catch(Exception e){
- LOG.error("txn {} Creating NoOpTransaction because of : {}", identifier, e.getMessage());
- remoteTransactionPaths.put(shardName, new NoOpTransactionContext(shardName, e));
+ LOG.debug("Tx {} Creating NoOpTransaction because of : {}", identifier, e.getMessage());
+ remoteTransactionPaths.put(shardName, new NoOpTransactionContext(shardName, e, identifier));
}
}
private interface TransactionContext {
String getShardName();
- String getResolvedCohortPath(String cohortPath);
+ void closeTransaction();
- public void closeTransaction();
+ Future<ActorPath> readyTransaction();
- public Object readyTransaction();
+ void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
void deleteData(YangInstanceIdentifier path);
CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readData(
final YangInstanceIdentifier path);
- void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
-
CheckedFuture<Boolean, ReadFailedException> dataExists(YangInstanceIdentifier path);
- }
+ List<Future<Object>> getRecordedOperationFutures();
+ }
- private class TransactionContextImpl implements TransactionContext {
- private final String shardName;
- private final String actorPath;
- private final ActorSelection actor;
+ private static abstract class AbstractTransactionContext implements TransactionContext {
+ protected final TransactionIdentifier identifier;
+ protected final String shardName;
+ protected final List<Future<Object>> recordedOperationFutures = Lists.newArrayList();
- private TransactionContextImpl(String shardName, String actorPath,
- ActorSelection actor) {
+ AbstractTransactionContext(String shardName, TransactionIdentifier identifier) {
this.shardName = shardName;
- this.actorPath = actorPath;
- this.actor = actor;
+ this.identifier = identifier;
}
@Override
return shardName;
}
+ @Override
+ public List<Future<Object>> getRecordedOperationFutures() {
+ return recordedOperationFutures;
+ }
+ }
+
+ private static class TransactionContextImpl extends AbstractTransactionContext {
+ private final Logger LOG = LoggerFactory.getLogger(TransactionContextImpl.class);
+
+ private final ActorContext actorContext;
+ private final SchemaContext schemaContext;
+ private final String actorPath;
+ private final ActorSelection actor;
+
+ private TransactionContextImpl(String shardName, String actorPath,
+ ActorSelection actor, TransactionIdentifier identifier, ActorContext actorContext,
+ SchemaContext schemaContext) {
+ super(shardName, identifier);
+ this.actorPath = actorPath;
+ this.actor = actor;
+ this.actorContext = actorContext;
+ this.schemaContext = schemaContext;
+ }
+
private ActorSelection getActor() {
return actor;
}
- @Override
- public String getResolvedCohortPath(String cohortPath) {
+ private String getResolvedCohortPath(String cohortPath) {
return actorContext.resolvePath(actorPath, cohortPath);
}
@Override
public void closeTransaction() {
+ LOG.debug("Tx {} closeTransaction called", identifier);
actorContext.sendRemoteOperationAsync(getActor(), new CloseTransaction().toSerializable());
}
@Override
- public Object readyTransaction() {
- return actorContext.executeRemoteOperation(getActor(),
+ public Future<ActorPath> readyTransaction() {
+ LOG.debug("Tx {} readyTransaction called with {} previous recorded operations pending",
+ identifier, recordedOperationFutures.size());
+
+ // Send the ReadyTransaction message to the Tx actor.
+
+ final Future<Object> replyFuture = actorContext.executeRemoteOperationAsync(getActor(),
new ReadyTransaction().toSerializable(), ActorContext.ASK_DURATION);
+
+ // Combine all the previously recorded put/merge/delete operation reply Futures and the
+ // ReadyTransactionReply Future into one Future. If any one fails then the combined
+ // Future will fail. We need all prior operations and the ready operation to succeed
+ // in order to attempt commit.
+
+ List<Future<Object>> futureList =
+ Lists.newArrayListWithCapacity(recordedOperationFutures.size() + 1);
+ futureList.addAll(recordedOperationFutures);
+ futureList.add(replyFuture);
+
+ Future<Iterable<Object>> combinedFutures = akka.dispatch.Futures.sequence(futureList,
+ actorContext.getActorSystem().dispatcher());
+
+ // Transform the combined Future into a Future that returns the cohort actor path from
+ // the ReadyTransactionReply. That's the end result of the ready operation.
+
+ return combinedFutures.transform(new AbstractFunction1<Iterable<Object>, ActorPath>() {
+ @Override
+ public ActorPath apply(Iterable<Object> notUsed) {
+
+ LOG.debug("Tx {} readyTransaction: pending recorded operations succeeded",
+ identifier);
+
+ // At this point all the Futures succeeded and we need to extract the cohort
+ // actor path from the ReadyTransactionReply. For the recorded operations, they
+ // don't return any data so we're only interested that they completed
+ // successfully. We could be paranoid and verify the correct reply types but
+ // that really should never happen so it's not worth the overhead of
+ // de-serializing each reply.
+
+ // Note the Future get call here won't block as it's complete.
+ Object serializedReadyReply = replyFuture.value().get().get();
+ if(serializedReadyReply.getClass().equals(
+ ReadyTransactionReply.SERIALIZABLE_CLASS)) {
+ ReadyTransactionReply reply = ReadyTransactionReply.fromSerializable(
+ actorContext.getActorSystem(), serializedReadyReply);
+
+ String resolvedCohortPath = getResolvedCohortPath(
+ reply.getCohortPath().toString());
+
+ LOG.debug("Tx {} readyTransaction: resolved cohort path {}",
+ identifier, resolvedCohortPath);
+
+ return actorContext.actorFor(resolvedCohortPath);
+ } else {
+ // Throwing an exception here will fail the Future.
+
+ throw new IllegalArgumentException(String.format("Invalid reply type {}",
+ serializedReadyReply.getClass()));
+ }
+ }
+ }, SAME_FAILURE_TRANSFORMER, actorContext.getActorSystem().dispatcher());
}
@Override
public void deleteData(YangInstanceIdentifier path) {
- actorContext.sendRemoteOperationAsync(getActor(), new DeleteData(path).toSerializable() );
+ LOG.debug("Tx {} deleteData called path = {}", identifier, path);
+ recordedOperationFutures.add(actorContext.executeRemoteOperationAsync(getActor(),
+ new DeleteData(path).toSerializable(), ActorContext.ASK_DURATION ));
}
@Override
public void mergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
- actorContext.sendRemoteOperationAsync(getActor(),
- new MergeData(path, data, schemaContext).toSerializable());
+ LOG.debug("Tx {} mergeData called path = {}", identifier, path);
+ recordedOperationFutures.add(actorContext.executeRemoteOperationAsync(getActor(),
+ new MergeData(path, data, schemaContext).toSerializable(),
+ ActorContext.ASK_DURATION));
+ }
+
+ @Override
+ public void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+ LOG.debug("Tx {} writeData called path = {}", identifier, path);
+ recordedOperationFutures.add(actorContext.executeRemoteOperationAsync(getActor(),
+ new WriteData(path, data, schemaContext).toSerializable(),
+ ActorContext.ASK_DURATION));
}
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readData(
- final YangInstanceIdentifier path) {
+ final YangInstanceIdentifier path) {
+
+ LOG.debug("Tx {} readData called path = {}", identifier, path);
final SettableFuture<Optional<NormalizedNode<?, ?>>> returnFuture = SettableFuture.create();
+ // If there were any previous recorded put/merge/delete operation reply Futures then we
+ // must wait for them to successfully complete. This is necessary to honor the read
+ // uncommitted semantics of the public API contract. If any one fails then fail the read.
+
+ if(recordedOperationFutures.isEmpty()) {
+ finishReadData(path, returnFuture);
+ } else {
+ LOG.debug("Tx {} readData: verifying {} previous recorded operations",
+ identifier, recordedOperationFutures.size());
+
+ // Note: we make a copy of recordedOperationFutures to be on the safe side in case
+ // Futures#sequence accesses the passed List on a different thread, as
+ // recordedOperationFutures is not synchronized.
+
+ Future<Iterable<Object>> combinedFutures = akka.dispatch.Futures.sequence(
+ Lists.newArrayList(recordedOperationFutures),
+ actorContext.getActorSystem().dispatcher());
+ OnComplete<Iterable<Object>> onComplete = new OnComplete<Iterable<Object>>() {
+ @Override
+ public void onComplete(Throwable failure, Iterable<Object> notUsed)
+ throws Throwable {
+ if(failure != null) {
+ LOG.debug("Tx {} readData: a recorded operation failed: {}",
+ identifier, failure);
+
+ returnFuture.setException(new ReadFailedException(
+ "The read could not be performed because a previous put, merge,"
+ + "or delete operation failed", failure));
+ } else {
+ finishReadData(path, returnFuture);
+ }
+ }
+ };
+
+ combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
+ }
+
+ return MappingCheckedFuture.create(returnFuture, ReadFailedException.MAPPER);
+ }
+
+ private void finishReadData(final YangInstanceIdentifier path,
+ final SettableFuture<Optional<NormalizedNode<?, ?>>> returnFuture) {
+
+ LOG.debug("Tx {} finishReadData called path = {}", identifier, path);
+
OnComplete<Object> onComplete = new OnComplete<Object>() {
@Override
- public void onComplete(Throwable failure, Object response) throws Throwable {
+ public void onComplete(Throwable failure, Object readResponse) throws Throwable {
if(failure != null) {
+ LOG.debug("Tx {} read operation failed: {}", identifier, failure);
+
returnFuture.setException(new ReadFailedException(
"Error reading data for path " + path, failure));
+
} else {
- if (response.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) {
+ LOG.debug("Tx {} read operation succeeded", identifier, failure);
+
+ if (readResponse.getClass().equals(ReadDataReply.SERIALIZABLE_CLASS)) {
ReadDataReply reply = ReadDataReply.fromSerializable(schemaContext,
- path, response);
+ path, readResponse);
if (reply.getNormalizedNode() == null) {
returnFuture.set(Optional.<NormalizedNode<?, ?>>absent());
} else {
}
};
- Future<Object> future = actorContext.executeRemoteOperationAsync(getActor(),
+ Future<Object> readFuture = actorContext.executeRemoteOperationAsync(getActor(),
new ReadData(path).toSerializable(), ActorContext.ASK_DURATION);
- future.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
-
- return MappingCheckedFuture.create(returnFuture, ReadFailedException.MAPPER);
- }
-
- @Override
- public void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
- actorContext.sendRemoteOperationAsync(getActor(),
- new WriteData(path, data, schemaContext).toSerializable());
+ readFuture.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
}
@Override
public CheckedFuture<Boolean, ReadFailedException> dataExists(
final YangInstanceIdentifier path) {
+ LOG.debug("Tx {} dataExists called path = {}", identifier, path);
+
final SettableFuture<Boolean> returnFuture = SettableFuture.create();
+ // If there were any previous recorded put/merge/delete operation reply Futures then we
+ // must wait for them to successfully complete. This is necessary to honor the read
+ // uncommitted semantics of the public API contract. If any one fails then fail this
+ // request.
+
+ if(recordedOperationFutures.isEmpty()) {
+ finishDataExists(path, returnFuture);
+ } else {
+ LOG.debug("Tx {} dataExists: verifying {} previous recorded operations",
+ identifier, recordedOperationFutures.size());
+
+ // Note: we make a copy of recordedOperationFutures to be on the safe side in case
+ // Futures#sequence accesses the passed List on a different thread, as
+ // recordedOperationFutures is not synchronized.
+
+ Future<Iterable<Object>> combinedFutures = akka.dispatch.Futures.sequence(
+ Lists.newArrayList(recordedOperationFutures),
+ actorContext.getActorSystem().dispatcher());
+ OnComplete<Iterable<Object>> onComplete = new OnComplete<Iterable<Object>>() {
+ @Override
+ public void onComplete(Throwable failure, Iterable<Object> notUsed)
+ throws Throwable {
+ if(failure != null) {
+ LOG.debug("Tx {} dataExists: a recorded operation failed: {}",
+ identifier, failure);
+
+ returnFuture.setException(new ReadFailedException(
+ "The data exists could not be performed because a previous "
+ + "put, merge, or delete operation failed", failure));
+ } else {
+ finishDataExists(path, returnFuture);
+ }
+ }
+ };
+
+ combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
+ }
+
+ return MappingCheckedFuture.create(returnFuture, ReadFailedException.MAPPER);
+ }
+
+ private void finishDataExists(final YangInstanceIdentifier path,
+ final SettableFuture<Boolean> returnFuture) {
+
+ LOG.debug("Tx {} finishDataExists called path = {}", identifier, path);
+
OnComplete<Object> onComplete = new OnComplete<Object>() {
@Override
public void onComplete(Throwable failure, Object response) throws Throwable {
if(failure != null) {
+ LOG.debug("Tx {} dataExists operation failed: {}", identifier, failure);
+
returnFuture.setException(new ReadFailedException(
- "Error checking exists for path " + path, failure));
+ "Error checking data exists for path " + path, failure));
} else {
+ LOG.debug("Tx {} dataExists operation succeeded", identifier, failure);
+
if (response.getClass().equals(DataExistsReply.SERIALIZABLE_CLASS)) {
returnFuture.set(Boolean.valueOf(DataExistsReply.
fromSerializable(response).exists()));
Future<Object> future = actorContext.executeRemoteOperationAsync(getActor(),
new DataExists(path).toSerializable(), ActorContext.ASK_DURATION);
future.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
-
- return MappingCheckedFuture.create(returnFuture, ReadFailedException.MAPPER);
}
}
- private class NoOpTransactionContext implements TransactionContext {
+ private static class NoOpTransactionContext extends AbstractTransactionContext {
- private final Logger
- LOG = LoggerFactory.getLogger(NoOpTransactionContext.class);
+ private final Logger LOG = LoggerFactory.getLogger(NoOpTransactionContext.class);
- private final String shardName;
private final Exception failure;
- private ActorRef cohort;
-
- public NoOpTransactionContext(String shardName, Exception failure){
- this.shardName = shardName;
+ public NoOpTransactionContext(String shardName, Exception failure,
+ TransactionIdentifier identifier){
+ super(shardName, identifier);
this.failure = failure;
}
@Override
- public String getShardName() {
- return shardName;
-
+ public void closeTransaction() {
+ LOG.debug("NoOpTransactionContext {} closeTransaction called", identifier);
}
@Override
- public String getResolvedCohortPath(String cohortPath) {
- return cohort.path().toString();
+ public Future<ActorPath> readyTransaction() {
+ LOG.debug("Tx {} readyTransaction called", identifier);
+ return akka.dispatch.Futures.failed(failure);
}
@Override
- public void closeTransaction() {
- LOG.warn("txn {} closeTransaction called", identifier);
- }
-
- @Override public Object readyTransaction() {
- LOG.warn("txn {} readyTransaction called", identifier);
- cohort = actorContext.getActorSystem().actorOf(Props.create(NoOpCohort.class));
- return new ReadyTransactionReply(cohort.path()).toSerializable();
+ public void deleteData(YangInstanceIdentifier path) {
+ LOG.debug("Tx {} deleteData called path = {}", identifier, path);
}
@Override
- public void deleteData(YangInstanceIdentifier path) {
- LOG.warn("txt {} deleteData called path = {}", identifier, path);
+ public void mergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+ LOG.debug("Tx {} mergeData called path = {}", identifier, path);
}
@Override
- public void mergeData(YangInstanceIdentifier path,
- NormalizedNode<?, ?> data) {
- LOG.warn("txn {} mergeData called path = {}", identifier, path);
+ public void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+ LOG.debug("Tx {} writeData called path = {}", identifier, path);
}
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readData(
YangInstanceIdentifier path) {
- LOG.warn("txn {} readData called path = {}", identifier, path);
+ LOG.debug("Tx {} readData called path = {}", identifier, path);
return Futures.immediateFailedCheckedFuture(new ReadFailedException(
"Error reading data for path " + path, failure));
}
- @Override public void writeData(YangInstanceIdentifier path,
- NormalizedNode<?, ?> data) {
- LOG.warn("txn {} writeData called path = {}", identifier, path);
- }
-
- @Override public CheckedFuture<Boolean, ReadFailedException> dataExists(
+ @Override
+ public CheckedFuture<Boolean, ReadFailedException> dataExists(
YangInstanceIdentifier path) {
- LOG.warn("txn {} dataExists called path = {}", identifier, path);
+ LOG.debug("Tx {} dataExists called path = {}", identifier, path);
return Futures.immediateFailedCheckedFuture(new ReadFailedException(
"Error checking exists for path " + path, failure));
}
}
-
-
-
}
/**
* All MBeans should extend this class that help in registering and
* unregistering the MBeans.
- *
+ * @author Basheeruddin <syedbahm@cisco.com>
*/
+/*
+ * Copyright (c) 2014 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.cluster.datastore.jmx.mbeans.shard;
import java.util.HashMap;
import java.util.Map;
/**
- * @author: syedbahm
- * Date: 7/16/14
+ * @author Basheeruddin syedbahm@cisco.com
+ *
*/
public class ShardMBeanFactory {
private static Map<String, ShardStats> shardMBeans =
+/*
+ * Copyright (c) 2014 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.cluster.datastore.jmx.mbeans.shard;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.AbstractBaseMBean;
import java.util.Date;
/**
- * @author: syedbahm
+ * @author Basheeruddin syedbahm@cisco.com
*/
public class ShardStats extends AbstractBaseMBean implements ShardStatsMBean {
private final String shardName;
- private Long committedTransactionsCount = 0L;
+ private long committedTransactionsCount = 0L;
- private Long readOnlyTransactionCount = 0L;
+ private long readOnlyTransactionCount = 0L;
- private Long writeOnlyTransactionCount = 0L;
+ private long writeOnlyTransactionCount = 0L;
- private Long readWriteTransactionCount = 0L;
+ private long readWriteTransactionCount = 0L;
private String leader;
private String raftState;
- private Long lastLogTerm = -1L;
+ private long lastLogTerm = -1L;
- private Long lastLogIndex = -1L;
+ private long lastLogIndex = -1L;
- private Long currentTerm = -1L;
+ private long currentTerm = -1L;
- private Long commitIndex = -1L;
+ private long commitIndex = -1L;
- private Long lastApplied = -1L;
+ private long lastApplied = -1L;
private Date lastCommittedTransactionTime = new Date(0L);
- private Long failedTransactionsCount = 0L;
+ private long failedTransactionsCount = 0L;
+
+ private long failedReadTransactionsCount = 0L;
+
+ private long abortTransactionsCount = 0L;
private SimpleDateFormat sdf =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
@Override
- public Long getCommittedTransactionsCount() {
+ public long getCommittedTransactionsCount() {
return committedTransactionsCount;
}
return raftState;
}
- @Override public Long getReadOnlyTransactionCount() {
+ @Override public long getReadOnlyTransactionCount() {
return readOnlyTransactionCount;
}
- @Override public Long getWriteOnlyTransactionCount() {
+ @Override public long getWriteOnlyTransactionCount() {
return writeOnlyTransactionCount;
}
- @Override public Long getReadWriteTransactionCount() {
+ @Override public long getReadWriteTransactionCount() {
return readWriteTransactionCount;
}
- @Override public Long getLastLogIndex() {
+ @Override public long getLastLogIndex() {
return lastLogIndex;
}
- @Override public Long getLastLogTerm() {
+ @Override public long getLastLogTerm() {
return lastLogTerm;
}
- @Override public Long getCurrentTerm() {
+ @Override public long getCurrentTerm() {
return currentTerm;
}
- @Override public Long getCommitIndex() {
+ @Override public long getCommitIndex() {
return commitIndex;
}
- @Override public Long getLastApplied() {
+ @Override public long getLastApplied() {
return lastApplied;
}
return sdf.format(lastCommittedTransactionTime);
}
- @Override public Long getFailedTransactionsCount() {
+ @Override public long getFailedTransactionsCount() {
return failedTransactionsCount;
}
- public Long incrementCommittedTransactionCount() {
+ @Override public long getFailedReadTransactionsCount() {
+ return failedReadTransactionsCount;
+ }
+
+ @Override public long getAbortTransactionsCount() {
+ return abortTransactionsCount;
+ }
+
+ public long incrementCommittedTransactionCount() {
return committedTransactionsCount++;
}
- public Long incrementReadOnlyTransactionCount() {
+ public long incrementReadOnlyTransactionCount() {
return readOnlyTransactionCount++;
}
- public Long incrementWriteOnlyTransactionCount() {
+ public long incrementWriteOnlyTransactionCount() {
return writeOnlyTransactionCount++;
}
- public Long incrementReadWriteTransactionCount() {
+ public long incrementReadWriteTransactionCount() {
return readWriteTransactionCount++;
}
+ public long incrementFailedTransactionsCount() {
+ return failedTransactionsCount++;
+ }
+
+ public long incrementFailedReadTransactionsCount() {
+ return failedReadTransactionsCount++;
+ }
+
+ public long incrementAbortTransactionsCount () { return abortTransactionsCount++;}
+
public void setLeader(String leader) {
this.leader = leader;
}
this.raftState = raftState;
}
- public void setLastLogTerm(Long lastLogTerm) {
+ public void setLastLogTerm(long lastLogTerm) {
this.lastLogTerm = lastLogTerm;
}
- public void setLastLogIndex(Long lastLogIndex) {
+ public void setLastLogIndex(long lastLogIndex) {
this.lastLogIndex = lastLogIndex;
}
- public void setCurrentTerm(Long currentTerm) {
+ public void setCurrentTerm(long currentTerm) {
this.currentTerm = currentTerm;
}
- public void setCommitIndex(Long commitIndex) {
+ public void setCommitIndex(long commitIndex) {
this.commitIndex = commitIndex;
}
- public void setLastApplied(Long lastApplied) {
+ public void setLastApplied(long lastApplied) {
this.lastApplied = lastApplied;
}
return JMX_CATEGORY_SHARD;
}
+ /**
+ * resets the counters related to transactions
+ */
+
+ public void resetTransactionCounters(){
+ committedTransactionsCount = 0L;
+
+ readOnlyTransactionCount = 0L;
+
+ writeOnlyTransactionCount = 0L;
+
+ readWriteTransactionCount = 0L;
+
+ lastCommittedTransactionTime = new Date(0L);
+
+ failedTransactionsCount = 0L;
+
+ failedReadTransactionsCount = 0L;
+
+ abortTransactionsCount = 0L;
- public void incrementFailedTransactionsCount() {
- this.failedTransactionsCount++;
}
+
+
}
public interface ShardStatsMBean {
String getShardName();
- Long getCommittedTransactionsCount();
+ long getCommittedTransactionsCount();
String getLeader();
String getRaftState();
- Long getReadOnlyTransactionCount();
+ long getReadOnlyTransactionCount();
- Long getWriteOnlyTransactionCount();
+ long getWriteOnlyTransactionCount();
- Long getReadWriteTransactionCount();
+ long getReadWriteTransactionCount();
- Long getLastLogIndex();
+ long getLastLogIndex();
- Long getLastLogTerm();
+ long getLastLogTerm();
- Long getCurrentTerm();
+ long getCurrentTerm();
- Long getCommitIndex();
+ long getCommitIndex();
- Long getLastApplied();
+ long getLastApplied();
String getLastCommittedTransactionTime();
- Long getFailedTransactionsCount();
+ long getFailedTransactionsCount();
+
+ long getFailedReadTransactionsCount();
+
+ long getAbortTransactionsCount();
+
+ void resetTransactionCounters();
}
package org.opendaylight.controller.cluster.datastore.messages;
import com.google.common.base.Preconditions;
-import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages;
/**
* The FindPrimary message is used to locate the primary of any given shard
*
*/
public class FindPrimary implements SerializableMessage{
- public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.FindPrimary.class;
+ public static final Class SERIALIZABLE_CLASS = FindPrimary.class;
private final String shardName;
public FindPrimary(String shardName){
@Override
public Object toSerializable() {
- return ShardManagerMessages.FindPrimary.newBuilder().setShardName(shardName).build();
+ return this;
}
public static FindPrimary fromSerializable(Object message){
- return new FindPrimary(((ShardManagerMessages.FindPrimary)message).getShardName());
+ return (FindPrimary) message;
}
}
package org.opendaylight.controller.cluster.datastore.messages;
-import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages;
public class PrimaryFound implements SerializableMessage {
- public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryFound.class;
+ public static final Class SERIALIZABLE_CLASS = PrimaryFound.class;
private final String primaryPath;
public PrimaryFound(String primaryPath) {
@Override
public Object toSerializable() {
- return ShardManagerMessages.PrimaryFound.newBuilder().setPrimaryPath(primaryPath).build();
+ return this;
}
public static PrimaryFound fromSerializable(Object message){
- return new PrimaryFound(((ShardManagerMessages.PrimaryFound)message).getPrimaryPath());
+ return (PrimaryFound) message;
}
}
package org.opendaylight.controller.cluster.datastore.messages;
import com.google.common.base.Preconditions;
-import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages;
public class PrimaryNotFound implements SerializableMessage {
- public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryNotFound.class;
+ public static final Class SERIALIZABLE_CLASS = PrimaryNotFound.class;
private final String shardName;
@Override
public Object toSerializable() {
- return ShardManagerMessages.PrimaryNotFound.newBuilder().setShardName(shardName).build();
+ return this;
}
public static PrimaryNotFound fromSerializable(Object message){
- return new PrimaryNotFound(((ShardManagerMessages.PrimaryNotFound)message).getShardName());
+ return (PrimaryNotFound) message;
}
}
import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound;
+import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public static final Duration AWAIT_DURATION =
Duration.create(5, TimeUnit.SECONDS);
+ public static final String MAILBOX = "bounded-mailbox";
+
private final ActorSystem actorSystem;
private final ActorRef shardManager;
private final ClusterWrapper clusterWrapper;
private final Configuration configuration;
+ private volatile SchemaContext schemaContext;
public ActorContext(ActorSystem actorSystem, ActorRef shardManager,
ClusterWrapper clusterWrapper,
return actorSystem.actorSelection(actorPath);
}
+ public void setSchemaContext(SchemaContext schemaContext) {
+ this.schemaContext = schemaContext;
+
+ if(shardManager != null) {
+ shardManager.tell(new UpdateSchemaContext(schemaContext), null);
+ }
+ }
+
+ public SchemaContext getSchemaContext() {
+ return schemaContext;
+ }
/**
* Finds the primary for a given shard
package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreProperties;
public class DistributedConfigDataStoreProviderModule extends
org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedConfigDataStoreProviderModule {
@Override
public java.lang.AutoCloseable createInstance() {
+
+ ConfigProperties props = getConfigProperties();
+ if(props == null) {
+ props = new ConfigProperties();
+ }
+
return DistributedDataStoreFactory.createInstance("config", getConfigSchemaServiceDependency(),
- InMemoryDOMDataStoreConfigProperties.create(getMaxShardDataChangeExecutorPoolSize(),
- getMaxShardDataChangeExecutorQueueSize(),
- getMaxShardDataChangeListenerQueueSize()));
+ new DistributedDataStoreProperties(props.getMaxShardDataChangeExecutorPoolSize(),
+ props.getMaxShardDataChangeExecutorQueueSize(),
+ props.getMaxShardDataChangeListenerQueueSize(),
+ props.getShardTransactionIdleTimeoutInMinutes()));
}
-
}
package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreProperties;
public class DistributedOperationalDataStoreProviderModule extends
org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModule {
@Override
public java.lang.AutoCloseable createInstance() {
+
+ OperationalProperties props = getOperationalProperties();
+ if(props == null) {
+ props = new OperationalProperties();
+ }
+
return DistributedDataStoreFactory.createInstance("operational",
getOperationalSchemaServiceDependency(),
- InMemoryDOMDataStoreConfigProperties.create(getMaxShardDataChangeExecutorPoolSize(),
- getMaxShardDataChangeExecutorQueueSize(),
- getMaxShardDataChangeListenerQueueSize()));
+ new DistributedDataStoreProperties(props.getMaxShardDataChangeExecutorPoolSize(),
+ props.getMaxShardDataChangeExecutorQueueSize(),
+ props.getMaxShardDataChangeListenerQueueSize(),
+ props.getShardTransactionIdleTimeoutInMinutes()));
}
}
odl-cluster-data {
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 100ms
+ }
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
cluster {
config:java-name-prefix DistributedOperationalDataStoreProvider;
}
+ grouping data-store-properties {
+ leaf max-shard-data-change-executor-queue-size {
+ default 1000;
+ type uint16;
+ description "The maximum queue size for each shard's data store data change notification executor.";
+ }
+
+ leaf max-shard-data-change-executor-pool-size {
+ default 20;
+ type uint16;
+ description "The maximum thread pool size for each shard's data store data change notification executor.";
+ }
+
+ leaf max-shard-data-change-listener-queue-size {
+ default 1000;
+ type uint16;
+ description "The maximum queue size for each shard's data store data change listeners.";
+ }
+
+ leaf shard-transaction-idle-timeout-in-minutes {
+ default 10;
+ type uint16;
+ description "The maximum amount of time a shard transaction can be idle without receiving any messages before it self-destructs.";
+ }
+ }
+
// Augments the 'configuration' choice node under modules/module.
augment "/config:modules/config:module/config:configuration" {
case distributed-config-datastore-provider {
when "/config:modules/config:module/config:type = 'distributed-config-datastore-provider'";
- container config-schema-service {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity sal:schema-service;
+ container config-schema-service {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity sal:schema-service;
+ }
}
}
- }
- leaf max-shard-data-change-executor-queue-size {
- default 1000;
- type uint16;
- description "The maximum queue size for each shard's data store data change notification executor.";
- }
-
- leaf max-shard-data-change-executor-pool-size {
- default 20;
- type uint16;
- description "The maximum thread pool size for each shard's data store data change notification executor.";
- }
-
- leaf max-shard-data-change-listener-queue-size {
- default 1000;
- type uint16;
- description "The maximum queue size for each shard's data store data change listeners.";
- }
+ container config-properties {
+ uses data-store-properties;
+ }
}
}
}
}
- leaf max-shard-data-change-executor-queue-size {
- default 1000;
- type uint16;
- description "The maximum queue size for each shard's data store data change notification executor.";
- }
-
- leaf max-shard-data-change-executor-pool-size {
- default 20;
- type uint16;
- description "The maximum thread pool size for each shard's data store data change notification executor.";
- }
-
- leaf max-shard-data-change-listener-queue-size {
- default 1000;
- type uint16;
- description "The maximum queue size for each shard's data store data change listeners.";
- }
- }
+ container operational-properties {
+ uses data-store-properties;
+ }
}
+ }
}
import akka.actor.Props;
import akka.event.Logging;
import akka.testkit.JavaTestKit;
+
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction;
import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply;
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
import scala.concurrent.Await;
import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null);
+ final SchemaContext schemaContext = TestModel.createTestContext();
+ DatastoreContext datastoreContext = new DatastoreContext();
+
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, datastoreContext);
final ActorRef shard = getSystem().actorOf(props);
- new Within(duration("5 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
-
-
- shard.tell(
- new UpdateSchemaContext(TestModel.createTestContext()),
- getRef());
+ shard.tell(new UpdateSchemaContext(schemaContext), getRef());
// Wait for a specific log message to show up
final boolean result =
new JavaTestKit.EventFilter<Boolean>(Logging.Info.class
) {
+ @Override
protected Boolean run() {
return true;
}
shard.tell(new CreateTransactionChain().toSerializable(), getRef());
final ActorSelection transactionChain =
- new ExpectMsg<ActorSelection>(duration("1 seconds"), "CreateTransactionChainReply") {
+ new ExpectMsg<ActorSelection>(duration("3 seconds"), "CreateTransactionChainReply") {
+ @Override
protected ActorSelection match(Object in) {
if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)) {
ActorPath transactionChainPath =
transactionChain.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.WRITE_ONLY.ordinal() ).toSerializable(), getRef());
final ActorSelection transaction =
- new ExpectMsg<ActorSelection>(duration("1 seconds"), "CreateTransactionReply") {
+ new ExpectMsg<ActorSelection>(duration("3 seconds"), "CreateTransactionReply") {
+ @Override
protected ActorSelection match(Object in) {
if (CreateTransactionReply.SERIALIZABLE_CLASS.equals(in.getClass())) {
CreateTransactionReply reply = CreateTransactionReply.fromSerializable(in);
// 3. Write some data
transaction.tell(new WriteData(TestModel.TEST_PATH,
- ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()).toSerializable(),
+ ImmutableNodes.containerNode(TestModel.TEST_QNAME), schemaContext).toSerializable(),
getRef());
- Boolean writeDone = new ExpectMsg<Boolean>(duration("1 seconds"), "WriteDataReply") {
+ Boolean writeDone = new ExpectMsg<Boolean>(duration("3 seconds"), "WriteDataReply") {
+ @Override
protected Boolean match(Object in) {
if (in.getClass().equals(WriteDataReply.SERIALIZABLE_CLASS)) {
return true;
transaction.tell(new ReadyTransaction().toSerializable(), getRef());
final ActorSelection cohort =
- new ExpectMsg<ActorSelection>(duration("1 seconds"), "ReadyTransactionReply") {
+ new ExpectMsg<ActorSelection>(duration("3 seconds"), "ReadyTransactionReply") {
+ @Override
protected ActorSelection match(Object in) {
if (in.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)) {
ActorPath cohortPath =
cohort.tell(new PreCommitTransaction().toSerializable(), getRef());
Boolean preCommitDone =
- new ExpectMsg<Boolean>(duration("1 seconds"), "PreCommitTransactionReply") {
+ new ExpectMsg<Boolean>(duration("3 seconds"), "PreCommitTransactionReply") {
+ @Override
protected Boolean match(Object in) {
if (in.getClass().equals(PreCommitTransactionReply.SERIALIZABLE_CLASS)) {
return true;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.messages.AppendEntries;
import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages;
+import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import akka.actor.ActorRef;
import akka.actor.Props;
-import junit.framework.Assert;
+import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.messages.DataChanged;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
@Override
public Set<YangInstanceIdentifier> getRemovedPaths() {
- Set<YangInstanceIdentifier>ids = new HashSet();
+ Set<YangInstanceIdentifier>ids = new HashSet<>();
ids.add( CompositeModel.TEST_PATH);
return ids;
}
final Props props = Props.create(MessageCollectorActor.class);
final ActorRef actorRef = getSystem().actorOf(props);
- DataChangeListenerProxy dataChangeListenerProxy =
- new DataChangeListenerProxy(TestModel.createTestContext(),
- getSystem().actorSelection(actorRef.path()));
+ DataChangeListenerProxy dataChangeListenerProxy = new DataChangeListenerProxy(
+ TestModel.createTestContext(), getSystem().actorSelection(actorRef.path()));
dataChangeListenerProxy.onDataChanged(new MockDataChangedEvent());
public class DataChangeListenerTest extends AbstractActorTest {
private static class MockDataChangedEvent implements AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> {
- Map<YangInstanceIdentifier,NormalizedNode<?,?>> createdData = new HashMap();
- Map<YangInstanceIdentifier,NormalizedNode<?,?>> updatedData = new HashMap();
- Map<YangInstanceIdentifier,NormalizedNode<?,?>> originalData = new HashMap();
+ Map<YangInstanceIdentifier,NormalizedNode<?,?>> createdData = new HashMap<>();
+ Map<YangInstanceIdentifier,NormalizedNode<?,?>> updatedData = new HashMap<>();
+ Map<YangInstanceIdentifier,NormalizedNode<?,?>> originalData = new HashMap<>();
public void testDataChangedWhenNotificationsAreEnabled(){
new JavaTestKit(getSystem()) {{
final MockDataChangeListener listener = new MockDataChangeListener();
- final Props props = DataChangeListener.props(CompositeModel.createTestContext(),listener,CompositeModel.FAMILY_PATH );
+ final Props props = DataChangeListener.props(listener);
final ActorRef subject =
getSystem().actorOf(props, "testDataChangedNotificationsEnabled");
new Within(duration("1 seconds")) {
+ @Override
protected void run() {
// Let the DataChangeListener know that notifications should
final Boolean out = new ExpectMsg<Boolean>(duration("800 millis"), "dataChanged") {
// do not put code outside this method, will run afterwards
+ @Override
protected Boolean match(Object in) {
if (in != null && in.getClass().equals(DataChangedReply.class)) {
expectNoMsg();
}
-
-
};
}};
}
public void testDataChangedWhenNotificationsAreDisabled(){
new JavaTestKit(getSystem()) {{
final MockDataChangeListener listener = new MockDataChangeListener();
- final Props props = DataChangeListener.props(CompositeModel.createTestContext(),listener,CompositeModel.FAMILY_PATH );
+ final Props props = DataChangeListener.props(listener);
final ActorRef subject =
getSystem().actorOf(props, "testDataChangedNotificationsDisabled");
new Within(duration("1 seconds")) {
+ @Override
protected void run() {
subject.tell(
expectNoMsg();
}
-
-
};
}};
}
import akka.actor.ActorSystem;
import akka.event.Logging;
import akka.testkit.JavaTestKit;
+
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
+
import junit.framework.Assert;
+
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
{
new Within(duration("10 seconds")) {
+ @Override
protected void run() {
try {
final DistributedDataStore distributedDataStore =
- new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), configuration, null);
+ new DistributedDataStore(getSystem(), "config",
+ new MockClusterWrapper(), configuration,
+ new DistributedDataStoreProperties());
distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext());
final boolean result =
new JavaTestKit.EventFilter<Boolean>(Logging.Info.class
) {
+ @Override
protected Boolean run() {
return true;
}
{
new Within(duration("10 seconds")) {
+ @Override
protected void run() {
try {
final DistributedDataStore distributedDataStore =
new JavaTestKit.EventFilter<Boolean>(
Logging.Info.class
) {
+ @Override
protected Boolean run() {
return true;
}
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
}
+ @SuppressWarnings("resource")
@Test
public void testConstructor(){
ActorSystem actorSystem = mock(ActorSystem.class);
new DistributedDataStore(actorSystem, "config",
- mock(ClusterWrapper.class), mock(Configuration.class), null);
+ mock(ClusterWrapper.class), mock(Configuration.class),
+ new DistributedDataStoreProperties());
verify(actorSystem).actorOf(any(Props.class), eq("shardmanager-config"));
}
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), null);
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
- new Within(duration("1 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
subject.tell(new FindPrimary("inventory").toSerializable(), getRef());
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), null);
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
- new Within(duration("1 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
subject.tell(new FindPrimary(Shard.DEFAULT_NAME).toSerializable(), getRef());
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), null);
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
- new Within(duration("1 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
subject.tell(new FindLocalShard("inventory"), getRef());
- final String out = new ExpectMsg<String>(duration("1 seconds"), "find local") {
+ final String out = new ExpectMsg<String>(duration("10 seconds"), "find local") {
+ @Override
protected String match(Object in) {
if (in instanceof LocalShardNotFound) {
return ((LocalShardNotFound) in).getShardName();
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", mockClusterWrapper,
- new MockConfiguration(), null);
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
- new Within(duration("1 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
subject.tell(new FindLocalShard(Shard.DEFAULT_NAME), getRef());
- final ActorRef out = new ExpectMsg<ActorRef>(duration("1 seconds"), "find local") {
+ final ActorRef out = new ExpectMsg<ActorRef>(duration("10 seconds"), "find local") {
+ @Override
protected ActorRef match(Object in) {
if (in instanceof LocalShardFound) {
return ((LocalShardFound) in).getPath();
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), null);
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
// the run() method needs to finish within 3 seconds
- new Within(duration("1 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
MockClusterWrapper.sendMemberUp(subject, "member-2", getRef().path().toString());
final String out = new ExpectMsg<String>(duration("1 seconds"), "primary found") {
// do not put code outside this method, will run afterwards
+ @Override
protected String match(Object in) {
if (in.getClass().equals(PrimaryFound.SERIALIZABLE_CLASS)) {
PrimaryFound f = PrimaryFound.fromSerializable(in);
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), null);
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
// the run() method needs to finish within 3 seconds
- new Within(duration("1 seconds")) {
+ new Within(duration("10 seconds")) {
+ @Override
protected void run() {
MockClusterWrapper.sendMemberUp(subject, "member-2", getRef().path().toString());
import akka.actor.Props;
import akka.event.Logging;
import akka.testkit.JavaTestKit;
-import junit.framework.Assert;
+
+import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
import java.util.HashMap;
import java.util.Map;
-import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ShardTest extends AbstractActorTest {
+
+ private static final DatastoreContext DATA_STORE_CONTEXT = new DatastoreContext();
+
@Test
public void testOnReceiveCreateTransactionChain() throws Exception {
new JavaTestKit(getSystem()) {{
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testCreateTransactionChain");
final boolean result =
new JavaTestKit.EventFilter<Boolean>(Logging.Info.class
) {
+ @Override
protected Boolean run() {
return true;
}
Assert.assertEquals(true, result);
- new Within(duration("1 seconds")) {
+ new Within(duration("3 seconds")) {
+ @Override
protected void run() {
subject.tell(new CreateTransactionChain().toSerializable(), getRef());
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ final String out = new ExpectMsg<String>(duration("3 seconds"), "match hint") {
// do not put code outside this method, will run afterwards
+ @Override
protected String match(Object in) {
if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)){
CreateTransactionChainReply reply =
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testRegisterChangeListener");
- new Within(duration("1 seconds")) {
+ new Within(duration("3 seconds")) {
+ @Override
protected void run() {
subject.tell(
getRef().path(), AsyncDataBroker.DataChangeScope.BASE),
getRef());
- final Boolean notificationEnabled = new ExpectMsg<Boolean>("enable notification") {
+ final Boolean notificationEnabled = new ExpectMsg<Boolean>(
+ duration("3 seconds"), "enable notification") {
// do not put code outside this method, will run afterwards
+ @Override
protected Boolean match(Object in) {
if(in instanceof EnableNotification){
return ((EnableNotification) in).isEnabled();
assertFalse(notificationEnabled);
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ final String out = new ExpectMsg<String>(duration("3 seconds"), "match hint") {
// do not put code outside this method, will run afterwards
+ @Override
protected String match(Object in) {
if (in.getClass().equals(RegisterChangeListenerReply.class)) {
RegisterChangeListenerReply reply =
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, null);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testCreateTransaction");
-
// Wait for a specific log message to show up
final boolean result =
new JavaTestKit.EventFilter<Boolean>(Logging.Info.class
) {
+ @Override
protected Boolean run() {
return true;
}
Assert.assertEquals(true, result);
- new Within(duration("1 seconds")) {
+ new Within(duration("3 seconds")) {
+ @Override
protected void run() {
subject.tell(
subject.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.READ_ONLY.ordinal() ).toSerializable(),
getRef());
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ final String out = new ExpectMsg<String>(duration("3 seconds"), "match hint") {
// do not put code outside this method, will run afterwards
+ @Override
protected String match(Object in) {
if (in instanceof CreateTransactionReply) {
CreateTransactionReply reply =
out.contains("akka://test/user/testCreateTransaction/shard-txn-1"));
expectNoMsg();
}
-
-
};
}};
}
.shardName("inventory").type("config").build();
peerAddresses.put(identifier, null);
- final Props props = Shard.props(identifier, peerAddresses, null);
+ final Props props = Shard.props(identifier, peerAddresses, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testPeerAddressResolved");
- new Within(duration("1 seconds")) {
+ new Within(duration("3 seconds")) {
+ @Override
protected void run() {
subject.tell(
expectNoMsg();
}
-
-
};
}};
}
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.testkit.JavaTestKit;
+
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+
+import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChainReply;
import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import static org.junit.Assert.assertEquals;
public class ShardTransactionChainTest extends AbstractActorTest {
- private static ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(MoreExecutors.sameThreadExecutor());
-
- private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", storeExecutor,
- MoreExecutors.sameThreadExecutor());
-
- static {
- store.onGlobalContextUpdated(TestModel.createTestContext());
- }
- @Test
- public void testOnReceiveCreateTransaction() throws Exception {
- new JavaTestKit(getSystem()) {{
- final Props props = ShardTransactionChain.props(store.createTransactionChain(), TestModel.createTestContext());
- final ActorRef subject = getSystem().actorOf(props, "testCreateTransaction");
-
- new Within(duration("1 seconds")) {
- @Override
- protected void run() {
-
- subject.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.READ_ONLY.ordinal() ).toSerializable(), getRef());
-
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
- // do not put code outside this method, will run afterwards
- @Override
- protected String match(Object in) {
- if (in.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) {
- return CreateTransactionReply.fromSerializable(in).getTransactionPath();
- }else{
- throw noMatch();
- }
- }
- }.get(); // this extracts the received message
-
- assertEquals("Unexpected transaction path " + out,
- "akka://test/user/testCreateTransaction/shard-txn-1",
- out);
-
- // Will wait for the rest of the 3 seconds
- expectNoMsg();
- }
-
-
- };
- }};
- }
-
- @Test
- public void testOnReceiveCloseTransactionChain() throws Exception {
- new JavaTestKit(getSystem()) {{
- final Props props = ShardTransactionChain.props(store.createTransactionChain(), TestModel.createTestContext());
- final ActorRef subject = getSystem().actorOf(props, "testCloseTransactionChain");
-
- new Within(duration("1 seconds")) {
- @Override
- protected void run() {
-
- subject.tell(new CloseTransactionChain().toSerializable(), getRef());
-
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
- // do not put code outside this method, will run afterwards
- @Override
- protected String match(Object in) {
- if (in.getClass().equals(CloseTransactionChainReply.SERIALIZABLE_CLASS)) {
- return "match";
- } else {
- throw noMatch();
- }
- }
- }.get(); // this extracts the received message
-
- assertEquals("match", out);
- // Will wait for the rest of the 3 seconds
- expectNoMsg();
- }
-
-
- };
- }};
- }
+ private static ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(MoreExecutors.sameThreadExecutor());
+
+ private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", storeExecutor,
+ MoreExecutors.sameThreadExecutor());
+
+ private static final SchemaContext testSchemaContext = TestModel.createTestContext();
+
+ private static final DatastoreContext DATA_STORE_CONTEXT = new DatastoreContext();
+
+ private static final String mockShardName = "mockShardName";
+
+ @BeforeClass
+ public static void staticSetup() {
+ store.onGlobalContextUpdated(testSchemaContext);
+ }
+
+ @Test
+ public void testOnReceiveCreateTransaction() throws Exception {
+ new JavaTestKit(getSystem()) {{
+ final Props props = ShardTransactionChain.props(store.createTransactionChain(),
+ testSchemaContext, DATA_STORE_CONTEXT, mockShardName);
+ final ActorRef subject = getSystem().actorOf(props, "testCreateTransaction");
+
+ new Within(duration("1 seconds")) {
+ @Override
+ protected void run() {
+
+ subject.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.READ_ONLY.ordinal() ).toSerializable(), getRef());
+
+ final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ // do not put code outside this method, will run afterwards
+ @Override
+ protected String match(Object in) {
+ if (in.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) {
+ return CreateTransactionReply.fromSerializable(in).getTransactionPath();
+ }else{
+ throw noMatch();
+ }
+ }
+ }.get(); // this extracts the received message
+
+ assertEquals("Unexpected transaction path " + out,
+ "akka://test/user/testCreateTransaction/shard-txn-1",
+ out);
+
+ // Will wait for the rest of the 3 seconds
+ expectNoMsg();
+ }
+
+
+ };
+ }};
+ }
+
+ @Test
+ public void testOnReceiveCloseTransactionChain() throws Exception {
+ new JavaTestKit(getSystem()) {{
+ final Props props = ShardTransactionChain.props(store.createTransactionChain(),
+ testSchemaContext, DATA_STORE_CONTEXT,mockShardName );
+ final ActorRef subject = getSystem().actorOf(props, "testCloseTransactionChain");
+
+ new Within(duration("1 seconds")) {
+ @Override
+ protected void run() {
+
+ subject.tell(new CloseTransactionChain().toSerializable(), getRef());
+
+ final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ // do not put code outside this method, will run afterwards
+ @Override
+ protected String match(Object in) {
+ if (in.getClass().equals(CloseTransactionChainReply.SERIALIZABLE_CLASS)) {
+ return "match";
+ } else {
+ throw noMatch();
+ }
+ }
+ }.get(); // this extracts the received message
+
+ assertEquals("match", out);
+ // Will wait for the rest of the 3 seconds
+ expectNoMsg();
+ }
+
+
+ };
+ }};
+ }
}
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.testkit.TestActorRef;
+
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+
+import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
import scala.concurrent.Await;
import scala.concurrent.Future;
import scala.concurrent.duration.Duration;
import java.util.Collections;
-
-import static org.junit.Assert.assertTrue;
+import java.util.concurrent.TimeUnit;
/**
* Covers negative test cases
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("operational").build();
- static {
+ private final DatastoreContext datastoreContext = new DatastoreContext();
+
+ @BeforeClass
+ public static void staticSetup() {
store.onGlobalContextUpdated(testSchemaContext);
}
-
@Test(expected = ReadFailedException.class)
public void testNegativeReadWithReadOnlyTransactionClosed()
throws Throwable {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadOnlyTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
).build();
Future<Object> future =
akka.pattern.Patterns.ask(subject, readData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
- ((ShardReadTransaction) subject.underlyingActor())
- .forUnitTestOnlyExplicitTransactionClose();
+ subject.underlyingActor().getDOMStoreTransaction().close();
future = akka.pattern.Patterns.ask(subject, readData, 3000);
- Await.result(future, Duration.Zero());
-
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
@Test(expected = ReadFailedException.class)
- public void testNegativeReadWithReadWriteOnlyTransactionClosed()
+ public void testNegativeReadWithReadWriteTransactionClosed()
throws Throwable {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
- "testNegativeReadWithReadWriteOnlyTransactionClosed");
+ "testNegativeReadWithReadWriteTransactionClosed");
ShardTransactionMessages.ReadData readData =
ShardTransactionMessages.ReadData.newBuilder()
NormalizedNodeMessages.InstanceIdentifier.newBuilder()
.build()
).build();
+
Future<Object> future =
akka.pattern.Patterns.ask(subject, readData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
- ((ShardReadWriteTransaction) subject.underlyingActor())
- .forUnitTestOnlyExplicitTransactionClose();
+ subject.underlyingActor().getDOMStoreTransaction().close();
future = akka.pattern.Patterns.ask(subject, readData, 3000);
- Await.result(future, Duration.Zero());
-
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
@Test(expected = ReadFailedException.class)
- public void testNegativeExistsWithReadWriteOnlyTransactionClosed()
+ public void testNegativeExistsWithReadWriteTransactionClosed()
throws Throwable {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
- "testNegativeExistsWithReadWriteOnlyTransactionClosed");
+ "testNegativeExistsWithReadWriteTransactionClosed");
ShardTransactionMessages.DataExists dataExists =
ShardTransactionMessages.DataExists.newBuilder()
Future<Object> future =
akka.pattern.Patterns.ask(subject, dataExists, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
- ((ShardReadWriteTransaction) subject.underlyingActor())
- .forUnitTestOnlyExplicitTransactionClose();
+ subject.underlyingActor().getDOMStoreTransaction().close();
future = akka.pattern.Patterns.ask(subject, dataExists, 3000);
- Await.result(future, Duration.Zero());
-
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
@Test(expected = IllegalStateException.class)
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
Future<Object> future =
akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
ShardTransactionMessages.WriteData writeData =
ShardTransactionMessages.WriteData.newBuilder()
.setInstanceIdentifierPathArguments(
NormalizedNodeMessages.InstanceIdentifier.newBuilder()
.build()).setNormalizedNode(
- NormalizedNodeMessages.Node.newBuilder().build()
+ buildNormalizedNode()
).build();
future = akka.pattern.Patterns.ask(subject, writeData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
-
@Test(expected = IllegalStateException.class)
public void testNegativeReadWriteWithTransactionReady() throws Exception {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
Future<Object> future =
akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
ShardTransactionMessages.WriteData writeData =
ShardTransactionMessages.WriteData.newBuilder()
.setInstanceIdentifierPathArguments(
NormalizedNodeMessages.InstanceIdentifier.newBuilder()
- .build()).setNormalizedNode(
- NormalizedNodeMessages.Node.newBuilder().build()
-
- ).build();
+ .build()
+ )
+ .setNormalizedNode(buildNormalizedNode())
+ .build();
future = akka.pattern.Patterns.ask(subject, writeData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+ }
+ private NormalizedNodeMessages.Node buildNormalizedNode() {
+ return NormalizedNodeSerializer
+ .serialize(Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).build());
}
@Test(expected = IllegalStateException.class)
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props, "testNegativeMergeTransactionReady");
Future<Object> future =
akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
ShardTransactionMessages.MergeData mergeData =
ShardTransactionMessages.MergeData.newBuilder()
.setInstanceIdentifierPathArguments(
NormalizedNodeMessages.InstanceIdentifier.newBuilder()
.build()).setNormalizedNode(
- NormalizedNodeMessages.Node.newBuilder().build()
+ buildNormalizedNode()
).build();
future = akka.pattern.Patterns.ask(subject, mergeData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
Future<Object> future =
akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
ShardTransactionMessages.DeleteData deleteData =
ShardTransactionMessages.DeleteData.newBuilder()
.build()).build();
future = akka.pattern.Patterns.ask(subject, deleteData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
-
+ Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
}
import akka.actor.Terminated;
import akka.testkit.JavaTestKit;
import akka.testkit.TestActorRef;
+
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Assert;
+
+import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import scala.concurrent.duration.Duration;
+
import java.util.Collections;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
+ private DatastoreContext datastoreContext = new DatastoreContext();
- static {
+ @BeforeClass
+ public static void staticSetup() {
store.onGlobalContextUpdated(testSchemaContext);
}
@Test
public void testOnReceiveReadData() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext);
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testReadData");
new Within(duration("1 seconds")) {
@Test
public void testOnReceiveReadDataWhenDataNotFound() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props( store.newReadOnlyTransaction(), shard, testSchemaContext);
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props( store.newReadOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testReadDataWhenDataNotFound");
new Within(duration("1 seconds")) {
@Test
public void testOnReceiveDataExistsPositive() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext);
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testDataExistsPositive");
new Within(duration("1 seconds")) {
public void testOnReceiveDataExistsNegative() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadOnlyTransaction(), shard, testSchemaContext);
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testDataExistsNegative");
new Within(duration("1 seconds")) {
@Test
public void testOnReceiveWriteData() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newWriteOnlyTransaction(), shard, TestModel.createTestContext());
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testWriteData");
@Test
public void testOnReceiveMergeData() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard, testSchemaContext);
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testMergeData");
@Test
public void testOnReceiveDeleteData() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props( store.newWriteOnlyTransaction(), shard, TestModel.createTestContext());
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props( store.newWriteOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testDeleteData");
@Test
public void testOnReceiveReadyTransaction() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props( store.newReadWriteTransaction(), shard, TestModel.createTestContext());
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props( store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testReadyTransaction");
@Test
public void testOnReceiveCloseTransaction() throws Exception {
new JavaTestKit(getSystem()) {{
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard, TestModel.createTestContext());
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testCloseTransaction");
watch(subject);
- new Within(duration("2 seconds")) {
+ new Within(duration("6 seconds")) {
@Override
protected void run() {
subject.tell(new CloseTransaction().toSerializable(), getRef());
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ final String out = new ExpectMsg<String>(duration("3 seconds"), "match hint") {
// do not put code outside this method, will run afterwards
@Override
protected String match(Object in) {
+ System.out.println("!!!IN match 1: "+(in!=null?in.getClass():"NULL"));
if (in.getClass().equals(CloseTransactionReply.SERIALIZABLE_CLASS)) {
return "match";
} else {
assertEquals("match", out);
- final String termination = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ final String termination = new ExpectMsg<String>(duration("3 seconds"), "match hint") {
// do not put code outside this method, will run afterwards
@Override
protected String match(Object in) {
+ System.out.println("!!!IN match 2: "+(in!=null?in.getClass():"NULL"));
if (in instanceof Terminated) {
return "match";
} else {
}
}.get(); // this extracts the received message
-
- expectNoMsg();
+ assertEquals("match", termination);
}
-
-
};
}};
+ }
+ @Test(expected=UnknownMessageException.class)
+ public void testNegativePerformingWriteOperationOnReadTransaction() throws Exception {
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
+ final TestActorRef subject = TestActorRef.apply(props,getSystem());
+
+ subject.receive(new DeleteData(TestModel.TEST_PATH).toSerializable(), ActorRef.noSender());
}
+ @Test
+ public void testShardTransactionInactivity() {
+
+ datastoreContext = new DatastoreContext(InMemoryDOMDataStoreConfigProperties.getDefault(),
+ Duration.create(500, TimeUnit.MILLISECONDS));
- @Test
- public void testNegativePerformingWriteOperationOnReadTransaction() throws Exception {
- try {
+ new JavaTestKit(getSystem()) {{
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, new DatastoreContext()));
+ final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
+ final ActorRef subject =
+ getSystem().actorOf(props, "testShardTransactionInactivity");
- final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, null));
- final Props props =
- ShardTransaction.props(store.newReadOnlyTransaction(), shard, TestModel.createTestContext());
- final TestActorRef subject = TestActorRef.apply(props,getSystem());
+ watch(subject);
- subject.receive(new DeleteData(TestModel.TEST_PATH).toSerializable(), ActorRef.noSender());
- Assert.assertFalse(true);
+ // The shard Tx actor should receive a ReceiveTimeout message and self-destruct.
+ final String termination = new ExpectMsg<String>(duration("3 seconds"), "match hint") {
+ // do not put code outside this method, will run afterwards
+ @Override
+ protected String match(Object in) {
+ if (in instanceof Terminated) {
+ return "match";
+ } else {
+ throw noMatch();
+ }
+ }
+ }.get(); // this extracts the received message
- } catch (Exception cs) {
- assertEquals(UnknownMessageException.class.getSimpleName(), cs.getClass().getSimpleName());
- assertTrue(cs.getMessage(), cs.getMessage().startsWith("Unknown message received "));
+ assertEquals("match", termination);
+ }};
}
- }
}
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.testkit.TestActorRef;
+
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+
+import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
import scala.concurrent.Await;
import scala.concurrent.Future;
import scala.concurrent.duration.Duration;
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- static {
+ private final DatastoreContext datastoreContext = new DatastoreContext();
+
+
+ @BeforeClass
+ public static void staticSetup() {
store.onGlobalContextUpdated(testSchemaContext);
}
- private FiniteDuration ASK_RESULT_DURATION = Duration.create(5000, TimeUnit.MILLISECONDS);
+ private final FiniteDuration ASK_RESULT_DURATION = Duration.create(5000, TimeUnit.MILLISECONDS);
@Test(expected = TestException.class)
public void testNegativeAbortResultsInException() throws Exception {
- final ActorRef shard =
- getSystem()
- .actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, datastoreContext));
final DOMStoreThreePhaseCommitCohort mockCohort = Mockito
.mock(DOMStoreThreePhaseCommitCohort.class);
final CompositeModification mockComposite =
Mockito.mock(CompositeModification.class);
final Props props =
- ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite);
+ ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString());
final TestActorRef<ThreePhaseCommitCohort> subject = TestActorRef
.create(getSystem(), props,
assertTrue(future.isCompleted());
Await.result(future, ASK_RESULT_DURATION);
-
-
-
}
@Test(expected = OptimisticLockFailedException.class)
public void testNegativeCanCommitResultsInException() throws Exception {
- final ActorRef shard =
- getSystem()
- .actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, datastoreContext));
final DOMStoreThreePhaseCommitCohort mockCohort = Mockito
.mock(DOMStoreThreePhaseCommitCohort.class);
final CompositeModification mockComposite =
Mockito.mock(CompositeModification.class);
final Props props =
- ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite);
+ ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString());
final TestActorRef<ThreePhaseCommitCohort> subject = TestActorRef
.create(getSystem(), props,
@Test(expected = TestException.class)
public void testNegativePreCommitResultsInException() throws Exception {
- final ActorRef shard =
- getSystem()
- .actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
+ final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
+ Collections.EMPTY_MAP, datastoreContext));
final DOMStoreThreePhaseCommitCohort mockCohort = Mockito
.mock(DOMStoreThreePhaseCommitCohort.class);
final CompositeModification mockComposite =
Mockito.mock(CompositeModification.class);
final Props props =
- ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite);
+ ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString());
final TestActorRef<ThreePhaseCommitCohort> subject = TestActorRef
.create(getSystem(), props,
@Test(expected = TestException.class)
public void testNegativeCommitResultsInException() throws Exception {
- final TestActorRef<Shard> subject = TestActorRef
- .create(getSystem(),
- Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null),
+ final TestActorRef<Shard> subject = TestActorRef.create(getSystem(),
+ Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext),
"testNegativeCommitResultsInException");
final ActorRef shardTransaction =
- getSystem().actorOf(
- ShardTransaction.props(store.newReadWriteTransaction(), subject,
- TestModel.createTestContext()));
+ getSystem().actorOf(ShardTransaction.props(store.newReadWriteTransaction(), subject,
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString()));
ShardTransactionMessages.WriteData writeData =
ShardTransactionMessages.WriteData.newBuilder()
mockForwardCommitTransaction
, 3000);
Await.result(future, ASK_RESULT_DURATION);
-
-
}
private class TestException extends Exception {
}
-
-
}
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
+
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.isA;
import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransactionReply;
import org.opendaylight.controller.cluster.datastore.messages.SerializableMessage;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor;
+import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor;
+
+import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;
import java.util.List;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
+ @SuppressWarnings("serial")
+ static class TestException extends RuntimeException {
+ }
+
@Mock
private ActorContext actorContext;
doReturn(getSystem()).when(actorContext).getActorSystem();
}
- private ThreePhaseCommitCohortProxy setupProxy(int nCohorts) {
- List<ActorPath> cohorts = Lists.newArrayList();
+ private Future<ActorPath> newCohortPath() {
+ ActorPath path = getSystem().actorOf(Props.create(DoNothingActor.class)).path();
+ doReturn(mock(ActorSelection.class)).when(actorContext).actorSelection(path);
+ return Futures.successful(path);
+ }
+
+ private final ThreePhaseCommitCohortProxy setupProxy(int nCohorts) throws Exception {
+ List<Future<ActorPath>> cohortPathFutures = Lists.newArrayList();
for(int i = 1; i <= nCohorts; i++) {
- ActorPath path = getSystem().actorOf(Props.create(MessageCollectorActor.class)).path();
- cohorts.add(path);
- doReturn(mock(ActorSelection.class)).when(actorContext).actorSelection(path);
+ cohortPathFutures.add(newCohortPath());
}
- return new ThreePhaseCommitCohortProxy(actorContext, cohorts, "txn-1");
+ return new ThreePhaseCommitCohortProxy(actorContext, cohortPathFutures, "txn-1");
+ }
+
+ private ThreePhaseCommitCohortProxy setupProxyWithFailedCohortPath()
+ throws Exception {
+ List<Future<ActorPath>> cohortPathFutures = Lists.newArrayList();
+ cohortPathFutures.add(newCohortPath());
+ cohortPathFutures.add(Futures.<ActorPath>failed(new TestException()));
+
+ return new ThreePhaseCommitCohortProxy(actorContext, cohortPathFutures, "txn-1");
}
private void setupMockActorContext(Class<?> requestType, Object... responses) {
any(ActorSelection.class), isA(requestType), any(FiniteDuration.class));
}
+ private void propagateExecutionExceptionCause(ListenableFuture<?> future) throws Throwable {
+
+ try {
+ future.get(5, TimeUnit.SECONDS);
+ fail("Expected ExecutionException");
+ } catch(ExecutionException e) {
+ throw e.getCause();
+ }
+ }
+
@Test
public void testCanCommitWithOneCohort() throws Exception {
ListenableFuture<Boolean> future = proxy.canCommit();
- assertEquals("canCommit", true, future.get());
+ assertEquals("canCommit", true, future.get(5, TimeUnit.SECONDS));
setupMockActorContext(CanCommitTransaction.SERIALIZABLE_CLASS,
new CanCommitTransactionReply(false));
future = proxy.canCommit();
- assertEquals("canCommit", false, future.get());
+ assertEquals("canCommit", false, future.get(5, TimeUnit.SECONDS));
verifyCohortInvocations(2, CanCommitTransaction.SERIALIZABLE_CLASS);
}
ListenableFuture<Boolean> future = proxy.canCommit();
- assertEquals("canCommit", true, future.get());
+ assertEquals("canCommit", true, future.get(5, TimeUnit.SECONDS));
verifyCohortInvocations(2, CanCommitTransaction.SERIALIZABLE_CLASS);
}
ListenableFuture<Boolean> future = proxy.canCommit();
- assertEquals("canCommit", false, future.get());
+ assertEquals("canCommit", false, future.get(5, TimeUnit.SECONDS));
verifyCohortInvocations(3, CanCommitTransaction.SERIALIZABLE_CLASS);
}
- @Test(expected = ExecutionException.class)
- public void testCanCommitWithExceptionFailure() throws Exception {
+ @Test(expected = TestException.class)
+ public void testCanCommitWithExceptionFailure() throws Throwable {
ThreePhaseCommitCohortProxy proxy = setupProxy(1);
- setupMockActorContext(CanCommitTransaction.SERIALIZABLE_CLASS, new RuntimeException("mock"));
+ setupMockActorContext(CanCommitTransaction.SERIALIZABLE_CLASS, new TestException());
- proxy.canCommit().get();
+ propagateExecutionExceptionCause(proxy.canCommit());
}
@Test(expected = ExecutionException.class)
setupMockActorContext(CanCommitTransaction.SERIALIZABLE_CLASS,
new PreCommitTransactionReply());
- proxy.canCommit().get();
+ proxy.canCommit().get(5, TimeUnit.SECONDS);
+ }
+
+ @Test(expected = TestException.class)
+ public void testCanCommitWithFailedCohortPath() throws Throwable {
+
+ ThreePhaseCommitCohortProxy proxy = setupProxyWithFailedCohortPath();
+
+ try {
+ propagateExecutionExceptionCause(proxy.canCommit());
+ } finally {
+ verifyCohortInvocations(0, CanCommitTransaction.SERIALIZABLE_CLASS);
+ }
}
@Test
setupMockActorContext(PreCommitTransaction.SERIALIZABLE_CLASS,
new PreCommitTransactionReply());
- proxy.preCommit().get();
+ proxy.preCommit().get(5, TimeUnit.SECONDS);
verifyCohortInvocations(1, PreCommitTransaction.SERIALIZABLE_CLASS);
}
setupMockActorContext(PreCommitTransaction.SERIALIZABLE_CLASS,
new PreCommitTransactionReply(), new RuntimeException("mock"));
- proxy.preCommit().get();
+ proxy.preCommit().get(5, TimeUnit.SECONDS);
}
@Test
setupMockActorContext(AbortTransaction.SERIALIZABLE_CLASS, new AbortTransactionReply());
- proxy.abort().get();
+ proxy.abort().get(5, TimeUnit.SECONDS);
verifyCohortInvocations(1, AbortTransaction.SERIALIZABLE_CLASS);
}
setupMockActorContext(AbortTransaction.SERIALIZABLE_CLASS, new RuntimeException("mock"));
// The exception should not get propagated.
- proxy.abort().get();
+ proxy.abort().get(5, TimeUnit.SECONDS);
verifyCohortInvocations(1, AbortTransaction.SERIALIZABLE_CLASS);
}
+ @Test
+ public void testAbortWithFailedCohortPath() throws Throwable {
+
+ ThreePhaseCommitCohortProxy proxy = setupProxyWithFailedCohortPath();
+
+ // The exception should not get propagated.
+ proxy.abort().get(5, TimeUnit.SECONDS);
+
+ verifyCohortInvocations(0, AbortTransaction.SERIALIZABLE_CLASS);
+ }
+
@Test
public void testCommit() throws Exception {
setupMockActorContext(CommitTransaction.SERIALIZABLE_CLASS, new CommitTransactionReply(),
new CommitTransactionReply());
- proxy.commit().get();
+ proxy.commit().get(5, TimeUnit.SECONDS);
verifyCohortInvocations(2, CommitTransaction.SERIALIZABLE_CLASS);
}
- @Test(expected = ExecutionException.class)
- public void testCommitWithFailure() throws Exception {
+ @Test(expected = TestException.class)
+ public void testCommitWithFailure() throws Throwable {
ThreePhaseCommitCohortProxy proxy = setupProxy(2);
setupMockActorContext(CommitTransaction.SERIALIZABLE_CLASS, new CommitTransactionReply(),
- new RuntimeException("mock"));
+ new TestException());
- proxy.commit().get();
+ propagateExecutionExceptionCause(proxy.commit());
}
@Test(expected = ExecutionException.class)
- public void teseCommitWithInvalidResponseType() throws Exception {
+ public void testCommitWithInvalidResponseType() throws Exception {
ThreePhaseCommitCohortProxy proxy = setupProxy(1);
setupMockActorContext(CommitTransaction.SERIALIZABLE_CLASS, new PreCommitTransactionReply());
- proxy.commit().get();
+ proxy.commit().get(5, TimeUnit.SECONDS);
+ }
+
+ @Test(expected = TestException.class)
+ public void testCommitWithFailedCohortPath() throws Throwable {
+
+ ThreePhaseCommitCohortProxy proxy = setupProxyWithFailedCohortPath();
+
+ try {
+ propagateExecutionExceptionCause(proxy.commit());
+ } finally {
+ verifyCohortInvocations(0, CommitTransaction.SERIALIZABLE_CLASS);
+ }
}
@Test
- public void testGetCohortPaths() {
+ public void testAllThreePhasesSuccessful() throws Exception {
ThreePhaseCommitCohortProxy proxy = setupProxy(2);
- List<ActorPath> paths = proxy.getCohortPaths();
- assertNotNull("getCohortPaths returned null", paths);
- assertEquals("getCohortPaths size", 2, paths.size());
+ setupMockActorContext(CanCommitTransaction.SERIALIZABLE_CLASS,
+ new CanCommitTransactionReply(true), new CanCommitTransactionReply(true));
+
+ setupMockActorContext(PreCommitTransaction.SERIALIZABLE_CLASS,
+ new PreCommitTransactionReply(), new PreCommitTransactionReply());
+
+ setupMockActorContext(CommitTransaction.SERIALIZABLE_CLASS,
+ new CommitTransactionReply(), new CommitTransactionReply());
+
+ proxy.canCommit().get(5, TimeUnit.SECONDS);
+ proxy.preCommit().get(5, TimeUnit.SECONDS);
+ proxy.commit().get(5, TimeUnit.SECONDS);
+
+ verifyCohortInvocations(2, CanCommitTransaction.SERIALIZABLE_CLASS);
+ verifyCohortInvocations(2, PreCommitTransaction.SERIALIZABLE_CLASS);
+ verifyCohortInvocations(2, CommitTransaction.SERIALIZABLE_CLASS);
}
}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2014 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.cluster.datastore;
+
+import static org.mockito.Mockito.doReturn;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class TransactionChainProxyTest {
+ ActorContext actorContext = Mockito.mock(ActorContext.class);
+ SchemaContext schemaContext = Mockito.mock(SchemaContext.class);
+
+ @Before
+ public void setUp() {
+ doReturn(schemaContext).when(actorContext).getSchemaContext();
+ }
+
+ @SuppressWarnings("resource")
+ @Test
+ public void testNewReadOnlyTransaction() throws Exception {
+
+ DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newReadOnlyTransaction();
+ Assert.assertTrue(dst instanceof DOMStoreReadTransaction);
+
+ }
+
+ @SuppressWarnings("resource")
+ @Test
+ public void testNewReadWriteTransaction() throws Exception {
+ DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newReadWriteTransaction();
+ Assert.assertTrue(dst instanceof DOMStoreReadWriteTransaction);
+
+ }
+
+ @SuppressWarnings("resource")
+ @Test
+ public void testNewWriteOnlyTransaction() throws Exception {
+ DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newWriteOnlyTransaction();
+ Assert.assertTrue(dst instanceof DOMStoreWriteTransaction);
+
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testClose() throws Exception {
+ new TransactionChainProxy(actorContext).close();
+ }
+}
import akka.actor.ActorSelection;
import akka.actor.Props;
import akka.dispatch.Futures;
+
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply;
import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
+import org.opendaylight.controller.cluster.datastore.messages.DeleteDataReply;
import org.opendaylight.controller.cluster.datastore.messages.MergeData;
+import org.opendaylight.controller.cluster.datastore.messages.MergeDataReply;
import org.opendaylight.controller.cluster.datastore.messages.ReadData;
import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
import org.opendaylight.controller.cluster.datastore.messages.WriteData;
+import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply;
import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy;
import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import scala.concurrent.Await;
import scala.concurrent.Future;
+import scala.concurrent.duration.Duration;
import scala.concurrent.duration.FiniteDuration;
-import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.isA;
+import static org.mockito.Mockito.times;
@SuppressWarnings("resource")
public class TransactionProxyTest extends AbstractActorTest {
}
static interface Invoker {
- void invoke(TransactionProxy proxy) throws Exception;
+ CheckedFuture<?, ReadFailedException> invoke(TransactionProxy proxy) throws Exception;
}
private final Configuration configuration = new MockConfiguration();
schemaContext = TestModel.createTestContext();
doReturn(getSystem()).when(mockActorContext).getActorSystem();
+ doReturn(memberName).when(mockActorContext).getCurrentMemberName();
+ doReturn(schemaContext).when(mockActorContext).getSchemaContext();
ShardStrategyFactory.setConfiguration(configuration);
}
ArgumentMatcher<DataExists> matcher = new ArgumentMatcher<DataExists>() {
@Override
public boolean matches(Object argument) {
- DataExists obj = DataExists.fromSerializable(argument);
- return obj.getPath().equals(TestModel.TEST_PATH);
+ return DataExists.SERIALIZABLE_CLASS.equals(argument.getClass()) &&
+ DataExists.fromSerializable(argument).getPath().equals(TestModel.TEST_PATH);
}
};
ArgumentMatcher<ReadData> matcher = new ArgumentMatcher<ReadData>() {
@Override
public boolean matches(Object argument) {
- ReadData obj = ReadData.fromSerializable(argument);
- return obj.getPath().equals(TestModel.TEST_PATH);
+ return ReadData.SERIALIZABLE_CLASS.equals(argument.getClass()) &&
+ ReadData.fromSerializable(argument).getPath().equals(TestModel.TEST_PATH);
}
};
ArgumentMatcher<WriteData> matcher = new ArgumentMatcher<WriteData>() {
@Override
public boolean matches(Object argument) {
+ if(!WriteData.SERIALIZABLE_CLASS.equals(argument.getClass())) {
+ return false;
+ }
+
WriteData obj = WriteData.fromSerializable(argument, schemaContext);
return obj.getPath().equals(TestModel.TEST_PATH) &&
obj.getData().equals(nodeToWrite);
ArgumentMatcher<MergeData> matcher = new ArgumentMatcher<MergeData>() {
@Override
public boolean matches(Object argument) {
+ if(!MergeData.SERIALIZABLE_CLASS.equals(argument.getClass())) {
+ return false;
+ }
+
MergeData obj = MergeData.fromSerializable(argument, schemaContext);
return obj.getPath().equals(TestModel.TEST_PATH) &&
obj.getData().equals(nodeToWrite);
ArgumentMatcher<DeleteData> matcher = new ArgumentMatcher<DeleteData>() {
@Override
public boolean matches(Object argument) {
- DeleteData obj = DeleteData.fromSerializable(argument);
- return obj.getPath().equals(TestModel.TEST_PATH);
+ return DeleteData.SERIALIZABLE_CLASS.equals(argument.getClass()) &&
+ DeleteData.fromSerializable(argument).getPath().equals(TestModel.TEST_PATH);
}
};
return argThat(matcher);
}
- private Object readyTxReply(ActorPath path) {
- return new ReadyTransactionReply(path).toSerializable();
+ private Future<Object> readyTxReply(ActorPath path) {
+ return Futures.successful((Object)new ReadyTransactionReply(path).toSerializable());
}
private Future<Object> readDataReply(NormalizedNode<?, ?> data) {
- return Futures.successful(new ReadDataReply(schemaContext, data)
- .toSerializable());
+ return Futures.successful(new ReadDataReply(schemaContext, data).toSerializable());
}
private Future<Object> dataExistsReply(boolean exists) {
return Futures.successful(new DataExistsReply(exists).toSerializable());
}
+ private Future<Object> writeDataReply() {
+ return Futures.successful(new WriteDataReply().toSerializable());
+ }
+
+ private Future<Object> mergeDataReply() {
+ return Futures.successful(new MergeDataReply().toSerializable());
+ }
+
+ private Future<Object> deleteDataReply() {
+ return Futures.successful(new DeleteDataReply().toSerializable());
+ }
+
private ActorSelection actorSelection(ActorRef actorRef) {
return getSystem().actorSelection(actorRef.path());
}
ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
doReturn(getSystem().actorSelection(actorRef.path())).
when(mockActorContext).actorSelection(actorRef.path().toString());
- doReturn(memberName).when(mockActorContext).getCurrentMemberName();
doReturn(createTransactionReply(actorRef)).when(mockActorContext).
executeShardOperation(eq(DefaultShardStrategy.DEFAULT_SHARD),
eqCreateTransaction(memberName, type), anyDuration());
return actorRef;
}
+ private void propagateReadFailedExceptionCause(CheckedFuture<?, ReadFailedException> future)
+ throws Throwable {
+
+ try {
+ future.checkedGet(5, TimeUnit.SECONDS);
+ fail("Expected ReadFailedException");
+ } catch(ReadFailedException e) {
+ throw e.getCause();
+ }
+ }
+
@Test
public void testRead() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_ONLY);
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
eq(actorSelection(actorRef)), eqReadData(), anyDuration());
}
@Test(expected = ReadFailedException.class)
- public void testReadWhenAnInvalidMessageIsSentInReply() throws Exception {
+ public void testReadWithInvalidReplyMessageType() throws Exception {
setupActorContextWithInitialCreateTransaction(READ_ONLY);
doReturn(Futures.successful(new Object())).when(mockActorContext).
executeRemoteOperationAsync(any(ActorSelection.class), any(), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
transactionProxy.read(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
}
public void testReadWithAsyncRemoteOperatonFailure() throws Throwable {
setupActorContextWithInitialCreateTransaction(READ_ONLY);
- doThrow(new TestException()).when(mockActorContext).
+ doReturn(Futures.failed(new TestException())).when(mockActorContext).
executeRemoteOperationAsync(any(ActorSelection.class), any(), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
- try {
- transactionProxy.read(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
- fail("Expected ReadFailedException");
- } catch(ReadFailedException e) {
- // Expected - throw cause - expects TestException.
- throw e.getCause();
- }
+ propagateReadFailedExceptionCause(transactionProxy.read(TestModel.TEST_PATH));
}
private void testExceptionOnInitialCreateTransaction(Exception exToThrow, Invoker invoker)
anyString(), any(), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
- try {
- invoker.invoke(transactionProxy);
- fail("Expected ReadFailedException");
- } catch(ReadFailedException e) {
- // Expected - throw cause - expects TestException.
- throw e.getCause();
- }
+ propagateReadFailedExceptionCause(invoker.invoke(transactionProxy));
}
private void testReadWithExceptionOnInitialCreateTransaction(Exception exToThrow) throws Throwable {
testExceptionOnInitialCreateTransaction(exToThrow, new Invoker() {
@Override
- public void invoke(TransactionProxy proxy) throws Exception {
- proxy.read(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
+ public CheckedFuture<?, ReadFailedException> invoke(TransactionProxy proxy) throws Exception {
+ return proxy.read(TestModel.TEST_PATH);
}
});
}
testReadWithExceptionOnInitialCreateTransaction(new TestException());
}
+ @Test(expected = TestException.class)
+ public void testReadWithPriorRecordingOperationFailure() throws Throwable {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_WRITE);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ doReturn(Futures.failed(new TestException())).when(mockActorContext).
+ executeRemoteOperationAsync(eq(actorSelection(actorRef)), eqDeleteData(),
+ anyDuration());
+
+ doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqReadData(), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ READ_WRITE);
+
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
+ transactionProxy.delete(TestModel.TEST_PATH);
+
+ try {
+ propagateReadFailedExceptionCause(transactionProxy.read(TestModel.TEST_PATH));
+ } finally {
+ verify(mockActorContext, times(0)).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqReadData(), anyDuration());
+ }
+ }
+
+ @Test
+ public void testReadWithPriorRecordingOperationSuccessful() throws Throwable {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_WRITE);
+
+ NormalizedNode<?, ?> expectedNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(expectedNode), anyDuration());
+
+ doReturn(readDataReply(expectedNode)).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqReadData(), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ READ_WRITE);
+
+ transactionProxy.write(TestModel.TEST_PATH, expectedNode);
+
+ Optional<NormalizedNode<?, ?>> readOptional = transactionProxy.read(
+ TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
+
+ assertEquals("NormalizedNode isPresent", true, readOptional.isPresent());
+
+ assertEquals("Response NormalizedNode", expectedNode, readOptional.get());
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void testReadPreConditionCheck() {
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
+ transactionProxy.read(TestModel.TEST_PATH);
+ }
+
@Test
public void testExists() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_ONLY);
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
doReturn(dataExistsReply(false)).when(mockActorContext).executeRemoteOperationAsync(
eq(actorSelection(actorRef)), eqDataExists(), anyDuration());
public void testExistsWhenAPrimaryNotFoundExceptionIsThrown() throws Throwable {
testExceptionOnInitialCreateTransaction(new PrimaryNotFoundException("test"), new Invoker() {
@Override
- public void invoke(TransactionProxy proxy) throws Exception {
- proxy.exists(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
+ public CheckedFuture<?, ReadFailedException> invoke(TransactionProxy proxy) throws Exception {
+ return proxy.exists(TestModel.TEST_PATH);
}
});
}
@Test(expected = ReadFailedException.class)
- public void testExistsWhenAnInvalidMessageIsSentInReply() throws Exception {
+ public void testExistsWithInvalidReplyMessageType() throws Exception {
setupActorContextWithInitialCreateTransaction(READ_ONLY);
doReturn(Futures.successful(new Object())).when(mockActorContext).
executeRemoteOperationAsync(any(ActorSelection.class), any(), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
transactionProxy.exists(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
}
public void testExistsWithAsyncRemoteOperatonFailure() throws Throwable {
setupActorContextWithInitialCreateTransaction(READ_ONLY);
- doThrow(new TestException()).when(mockActorContext).
+ doReturn(Futures.failed(new TestException())).when(mockActorContext).
executeRemoteOperationAsync(any(ActorSelection.class), any(), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_ONLY, schemaContext);
+ READ_ONLY);
+
+ propagateReadFailedExceptionCause(transactionProxy.exists(TestModel.TEST_PATH));
+ }
+
+ @Test(expected = TestException.class)
+ public void testExistsWithPriorRecordingOperationFailure() throws Throwable {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_WRITE);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ doReturn(Futures.failed(new TestException())).when(mockActorContext).
+ executeRemoteOperationAsync(eq(actorSelection(actorRef)), eqDeleteData(),
+ anyDuration());
+
+ doReturn(dataExistsReply(false)).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqDataExists(), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ READ_WRITE);
+
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
+ transactionProxy.delete(TestModel.TEST_PATH);
try {
- transactionProxy.exists(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
- fail("Expected ReadFailedException");
- } catch(ReadFailedException e) {
- // Expected - throw cause - expects TestException.
- throw e.getCause();
+ propagateReadFailedExceptionCause(transactionProxy.exists(TestModel.TEST_PATH));
+ } finally {
+ verify(mockActorContext, times(0)).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqDataExists(), anyDuration());
}
}
@Test
- public void testWrite() throws Exception {
- ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
+ public void testExistsWithPriorRecordingOperationSuccessful() throws Throwable {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_WRITE);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ doReturn(dataExistsReply(true)).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqDataExists(), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ READ_WRITE);
+
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
+ Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
+
+ assertEquals("Exists response", true, exists);
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void testxistsPreConditionCheck() {
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- WRITE_ONLY, schemaContext);
+ WRITE_ONLY);
+
+ transactionProxy.exists(TestModel.TEST_PATH);
+ }
+
+ private void verifyRecordingOperationFutures(List<Future<Object>> futures,
+ Class<?>... expResultTypes) throws Exception {
+ assertEquals("getRecordingOperationFutures size", expResultTypes.length, futures.size());
+
+ int i = 0;
+ for( Future<Object> future: futures) {
+ assertNotNull("Recording operation Future is null", future);
+
+ Class<?> expResultType = expResultTypes[i++];
+ if(Throwable.class.isAssignableFrom(expResultType)) {
+ try {
+ Await.result(future, Duration.create(5, TimeUnit.SECONDS));
+ fail("Expected exception from recording operation Future");
+ } catch(Exception e) {
+ // Expected
+ }
+ } else {
+ assertEquals("Recording operation Future result type", expResultType,
+ Await.result(future, Duration.create(5, TimeUnit.SECONDS)).getClass());
+ }
+ }
+ }
+
+ @Test
+ public void testWrite() throws Exception {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
- verify(mockActorContext).sendRemoteOperationAsync(
- eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
+ verify(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
+ WriteDataReply.SERIALIZABLE_CLASS);
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void testWritePreConditionCheck() {
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ READ_ONLY);
+
+ transactionProxy.write(TestModel.TEST_PATH,
+ ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ }
+
+ @Test(expected=IllegalStateException.class)
+ public void testWriteAfterReadyPreConditionCheck() {
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
+ transactionProxy.ready();
+
+ transactionProxy.write(TestModel.TEST_PATH,
+ ImmutableNodes.containerNode(TestModel.TEST_QNAME));
}
@Test
public void testMerge() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
- TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- WRITE_ONLY, schemaContext);
-
NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+ doReturn(mergeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqMergeData(nodeToWrite), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
transactionProxy.merge(TestModel.TEST_PATH, nodeToWrite);
- verify(mockActorContext).sendRemoteOperationAsync(
- eq(actorSelection(actorRef)), eqMergeData(nodeToWrite));
+ verify(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqMergeData(nodeToWrite), anyDuration());
+
+ verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
+ MergeDataReply.SERIALIZABLE_CLASS);
}
@Test
public void testDelete() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
+ doReturn(deleteDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqDeleteData(), anyDuration());
+
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- WRITE_ONLY, schemaContext);
+ WRITE_ONLY);
transactionProxy.delete(TestModel.TEST_PATH);
- verify(mockActorContext).sendRemoteOperationAsync(
- eq(actorSelection(actorRef)), eqDeleteData());
+ verify(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqDeleteData(), anyDuration());
+
+ verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
+ DeleteDataReply.SERIALIZABLE_CLASS);
+ }
+
+ private void verifyCohortPathFutures(ThreePhaseCommitCohortProxy proxy,
+ Object... expReplies) throws Exception {
+ assertEquals("getReadyOperationFutures size", expReplies.length,
+ proxy.getCohortPathFutures().size());
+
+ int i = 0;
+ for( Future<ActorPath> future: proxy.getCohortPathFutures()) {
+ assertNotNull("Ready operation Future is null", future);
+
+ Object expReply = expReplies[i++];
+ if(expReply instanceof ActorPath) {
+ ActorPath actual = Await.result(future, Duration.create(5, TimeUnit.SECONDS));
+ assertEquals("Cohort actor path", expReply, actual);
+ } else {
+ // Expecting exception.
+ try {
+ Await.result(future, Duration.create(5, TimeUnit.SECONDS));
+ fail("Expected exception from ready operation Future");
+ } catch(Exception e) {
+ // Expected
+ }
+ }
+ }
}
@SuppressWarnings("unchecked")
public void testReady() throws Exception {
ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_WRITE);
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
eq(actorSelection(actorRef)), eqReadData(), anyDuration());
- doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeRemoteOperation(
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeRemoteOperationAsync(
eq(actorSelection(actorRef)), isA(ReadyTransaction.SERIALIZABLE_CLASS), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_WRITE, schemaContext);
+ READ_WRITE);
transactionProxy.read(TestModel.TEST_PATH);
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
+ DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
+
+ assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
+
+ ThreePhaseCommitCohortProxy proxy = (ThreePhaseCommitCohortProxy) ready;
+
+ verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
+ WriteDataReply.SERIALIZABLE_CLASS);
+
+ verifyCohortPathFutures(proxy, actorRef.path());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testReadyWithRecordingOperationFailure() throws Exception {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(mergeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqMergeData(nodeToWrite), anyDuration());
+
+ doReturn(Futures.failed(new TestException())).when(mockActorContext).
+ executeRemoteOperationAsync(eq(actorSelection(actorRef)), eqWriteData(nodeToWrite),
+ anyDuration());
+
+ doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), isA(ReadyTransaction.SERIALIZABLE_CLASS), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
+ transactionProxy.merge(TestModel.TEST_PATH, nodeToWrite);
+
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
+ DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
+
+ assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
+
+ ThreePhaseCommitCohortProxy proxy = (ThreePhaseCommitCohortProxy) ready;
+
+ verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
+ MergeDataReply.SERIALIZABLE_CLASS, TestException.class);
+
+ verifyCohortPathFutures(proxy, TestException.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testReadyWithReplyFailure() throws Exception {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(mergeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqMergeData(nodeToWrite), anyDuration());
+
+ doReturn(Futures.failed(new TestException())).when(mockActorContext).
+ executeRemoteOperationAsync(eq(actorSelection(actorRef)),
+ isA(ReadyTransaction.SERIALIZABLE_CLASS), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
+ transactionProxy.merge(TestModel.TEST_PATH, nodeToWrite);
+
+ DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
+
+ assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
+
+ ThreePhaseCommitCohortProxy proxy = (ThreePhaseCommitCohortProxy) ready;
+
+ verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
+ MergeDataReply.SERIALIZABLE_CLASS);
+
+ verifyCohortPathFutures(proxy, TestException.class);
+ }
+
+ @Test
+ public void testReadyWithInitialCreateTransactionFailure() throws Exception {
+
+ doThrow(new PrimaryNotFoundException("mock")).when(mockActorContext).executeShardOperation(
+ anyString(), any(), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ transactionProxy.merge(TestModel.TEST_PATH, nodeToWrite);
+
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
+ transactionProxy.delete(TestModel.TEST_PATH);
+
+ DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
+
+ assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
+
+ ThreePhaseCommitCohortProxy proxy = (ThreePhaseCommitCohortProxy) ready;
+
+ verifyCohortPathFutures(proxy, PrimaryNotFoundException.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testReadyWithInvalidReplyMessageType() throws Exception {
+ ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
+
+ NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+ eq(actorSelection(actorRef)), eqWriteData(nodeToWrite), anyDuration());
+
+ doReturn(Futures.successful(new Object())).when(mockActorContext).
+ executeRemoteOperationAsync(eq(actorSelection(actorRef)),
+ isA(ReadyTransaction.SERIALIZABLE_CLASS), anyDuration());
+
+ TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
+ WRITE_ONLY);
+
+ transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
+
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
ThreePhaseCommitCohortProxy proxy = (ThreePhaseCommitCohortProxy) ready;
- assertEquals("getCohortPaths", Arrays.asList(actorRef.path()), proxy.getCohortPaths());
+ verifyCohortPathFutures(proxy, IllegalArgumentException.class);
}
@Test
public void testGetIdentifier() {
setupActorContextWithInitialCreateTransaction(READ_ONLY);
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- TransactionProxy.TransactionType.READ_ONLY, schemaContext);
+ TransactionProxy.TransactionType.READ_ONLY);
Object id = transactionProxy.getIdentifier();
assertNotNull("getIdentifier returned null", id);
eq(actorSelection(actorRef)), eqReadData(), anyDuration());
TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
- READ_WRITE, schemaContext);
+ READ_WRITE);
transactionProxy.read(TestModel.TEST_PATH);
+/*
+ * Copyright (c) 2014 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.cluster.datastore.jmx.mbeans.shard;
import org.junit.After;
Object attribute =
mbeanServer.getAttribute(testMBeanName, "FailedTransactionsCount");
Assert.assertEquals((Long) attribute, (Long) 2L);
+ }
+
+ @Test
+ public void testGetAbortTransactionsCount() throws Exception {
+ //let us increment AbortTransactions count and then check
+ shardStats.incrementAbortTransactionsCount();
+ shardStats.incrementAbortTransactionsCount();
+
+
+ //now let us get from MBeanServer what is the transaction count.
+ Object attribute =
+ mbeanServer.getAttribute(testMBeanName, "AbortTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 2L);
+ }
+
+ @Test
+ public void testGetFailedReadTransactionsCount() throws Exception {
+ //let us increment FailedReadTransactions count and then check
+ shardStats.incrementFailedReadTransactionsCount();
+ shardStats.incrementFailedReadTransactionsCount();
+
+
+ //now let us get from MBeanServer what is the transaction count.
+ Object attribute =
+ mbeanServer.getAttribute(testMBeanName, "FailedReadTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 2L);
+ }
+
+ @Test
+ public void testResetTransactionCounters() throws Exception {
+
+ //let us increment committed transactions count and then check
+ shardStats.incrementCommittedTransactionCount();
+ shardStats.incrementCommittedTransactionCount();
+ shardStats.incrementCommittedTransactionCount();
+
+ //now let us get from MBeanServer what is the transaction count.
+ Object attribute = mbeanServer.getAttribute(testMBeanName,
+ "CommittedTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 3L);
+
+ //let us increment FailedReadTransactions count and then check
+ shardStats.incrementFailedReadTransactionsCount();
+ shardStats.incrementFailedReadTransactionsCount();
+
+
+ //now let us get from MBeanServer what is the transaction count.
+ attribute =
+ mbeanServer.getAttribute(testMBeanName, "FailedReadTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 2L);
+
+
+ //here we will reset the counters and check the above ones are 0 after reset
+ mbeanServer.invoke(testMBeanName, "resetTransactionCounters", null, null);
+
+ //now let us get from MBeanServer what is the transaction count.
+ attribute = mbeanServer.getAttribute(testMBeanName,
+ "CommittedTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 0L);
+ attribute =
+ mbeanServer.getAttribute(testMBeanName, "FailedReadTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 0L);
}
}
}
}
+bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 100ms
+}
LogicalDatastoreType store, YangInstanceIdentifier path);
/**
- * Checks if data is available in the logical data store located at provided path
+ /**
+ * Checks if data is available in the logical data store located at provided path.
+ * <p>
*
+ * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
+ * will succeed. It is possible that the data resides in a data store on a remote node and, if that
+ * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
+ * the data is deleted in between the calls to <code>exists</code> and <code>read</code>
+ *
+ * @param store
+ * Logical data store from which read should occur.
* @param path
* Path which uniquely identifies subtree which client want to
* check existence of
*/
package org.opendaylight.controller.config.yang.md.sal.dom.impl;
-import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
+
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException;
+import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl;
import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.broker.impl.jmx.CommitStatsMXBeanImpl;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService;
public final class DomInmemoryDataBrokerModule extends
org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomInmemoryDataBrokerModule {
+ private static final String JMX_BEAN_TYPE = "DOMDataBroker";
+
public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
* nothing on success. The executor queue capacity is bounded and, if the capacity is
* reached, subsequent submitted tasks will block the caller.
*/
- Executor listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
+ ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
getMaxDataBrokerFutureCallbackPoolSize(), getMaxDataBrokerFutureCallbackQueueSize(),
"CommitFutures");
TransactionCommitDeadlockException.DEADLOCK_EXECUTOR_FUNCTION,
listenableFutureExecutor));
+ final CommitStatsMXBeanImpl commitStatsMXBean = new CommitStatsMXBeanImpl(
+ newDataBroker.getCommitStatsTracker(), JMX_BEAN_TYPE);
+ commitStatsMXBean.registerMBean();
+
+ final ThreadExecutorStatsMXBeanImpl commitExecutorStatsMXBean =
+ new ThreadExecutorStatsMXBeanImpl(commitExecutor, "CommitExecutorStats",
+ JMX_BEAN_TYPE, null);
+ commitExecutorStatsMXBean.registerMBean();
+
+ final ThreadExecutorStatsMXBeanImpl commitFutureStatsMXBean =
+ new ThreadExecutorStatsMXBeanImpl(listenableFutureExecutor,
+ "CommitFutureExecutorStats", JMX_BEAN_TYPE, null);
+ commitFutureStatsMXBean.registerMBean();
+
+ newDataBroker.setCloseable(new AutoCloseable() {
+ @Override
+ public void close() {
+ commitStatsMXBean.unregisterMBean();
+ commitExecutorStatsMXBean.unregisterMBean();
+ commitFutureStatsMXBean.unregisterMBean();
+ }
+ });
+
return newDataBroker;
}
}
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.DurationStatsTracker;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final DOMDataCommitCoordinatorImpl coordinator;
private final AtomicLong txNum = new AtomicLong();
private final AtomicLong chainNum = new AtomicLong();
+ private volatile AutoCloseable closeable;
public DOMDataBrokerImpl(final ImmutableMap<LogicalDatastoreType, DOMStore> datastores,
final ListeningExecutorService executor) {
this.coordinator = new DOMDataCommitCoordinatorImpl(executor);
}
+ public void setCloseable(AutoCloseable closeable) {
+ this.closeable = closeable;
+ }
+
+ public DurationStatsTracker getCommitStatsTracker() {
+ return coordinator.getCommitStatsTracker();
+ }
+
+ @Override
+ public void close() {
+ super.close();
+
+ if(closeable != null) {
+ try {
+ closeable.close();
+ } catch(Exception e) {
+ LOG.debug("Error closing instance", e);
+ }
+ }
+ }
+
@Override
protected Object newTransactionIdentifier() {
return "DOM-" + txNum.getAndIncrement();
LOG.debug("Transaction: {} submitted with cohorts {}.", transaction.getIdentifier(), cohorts);
return coordinator.submit(transaction, cohorts, Optional.<DOMDataCommitErrorListener> absent());
}
-
}
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.yangtools.util.DurationStatsTracker;
import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final ListeningExecutorService executor;
+ private final DurationStatsTracker commitStatsTracker = new DurationStatsTracker();
+
/**
*
* Construct DOMDataCommitCoordinator which uses supplied executor to
this.executor = Preconditions.checkNotNull(executor, "executor must not be null.");
}
+ public DurationStatsTracker getCommitStatsTracker() {
+ return commitStatsTracker;
+ }
+
@Override
public CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
final Iterable<DOMStoreThreePhaseCommitCohort> cohorts, final Optional<DOMDataCommitErrorListener> listener) {
ListenableFuture<Void> commitFuture = null;
try {
- commitFuture = executor.submit(new CommitCoordinationTask(transaction, cohorts, listener));
+ commitFuture = executor.submit(new CommitCoordinationTask(transaction, cohorts,
+ listener, commitStatsTracker));
} catch(RejectedExecutionException e) {
LOG.error("The commit executor's queue is full - submit task was rejected. \n" +
executor, e);
private final DOMDataWriteTransaction tx;
private final Iterable<DOMStoreThreePhaseCommitCohort> cohorts;
+ private final DurationStatsTracker commitStatTracker;
@GuardedBy("this")
private CommitPhase currentPhase;
public CommitCoordinationTask(final DOMDataWriteTransaction transaction,
final Iterable<DOMStoreThreePhaseCommitCohort> cohorts,
- final Optional<DOMDataCommitErrorListener> listener) {
+ final Optional<DOMDataCommitErrorListener> listener,
+ final DurationStatsTracker commitStatTracker) {
this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null");
this.cohorts = Preconditions.checkNotNull(cohorts, "cohorts must not be null");
this.currentPhase = CommitPhase.SUBMITTED;
+ this.commitStatTracker = commitStatTracker;
}
@Override
public Void call() throws TransactionCommitFailedException {
+ long startTime = System.nanoTime();
try {
canCommitBlocking();
preCommitBlocking();
LOG.warn("Tx: {} Error during phase {}, starting Abort", tx.getIdentifier(), currentPhase, e);
abortBlocking(e);
throw e;
+ } finally {
+ if(commitStatTracker != null) {
+ commitStatTracker.addDuration(System.nanoTime() - startTime);
+ }
}
}
}
}
+ @Override
+ public String toString() {
+ return getDelegate().getClass().getName();
+ }
+
static final class TranslatingConfigListenerInvoker extends TranslatingListenerInvoker {
public TranslatingConfigListenerInvoker(final DataChangeListener listener, final DataNormalizer normalizer) {
super(listener, normalizer);
}
+ @Override
DataChangeEvent<YangInstanceIdentifier, CompositeNode> getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedChange) {
return TranslatingDataChangeEvent.createConfiguration(normalizedChange, normalizer);
}
super(listener, normalizer);
}
+ @Override
DataChangeEvent<YangInstanceIdentifier, CompositeNode> getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedChange) {
return TranslatingDataChangeEvent.createOperational(normalizedChange, normalizer);
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.dom.broker.impl.jmx;
+
+/**
+ * MXBean interface for retrieving write Tx commit statistics.
+ *
+ * @author Thomas Pantelis
+ */
+public interface CommitStatsMXBean {
+
+ /**
+ * Returns the total number of commits that have occurred.
+ */
+ long getTotalCommits();
+
+ /**
+ * Returns a string representing the time duration of the longest commit, in the appropriate
+ * scaled units, along with the date/time that it occurred.
+ */
+ String getLongestCommitTime();
+
+ /**
+ * Returns a string representing the time duration of the shortest commit, in the appropriate
+ * scaled units, along with the date/time that it occurred.
+ */
+ String getShortestCommitTime();
+
+ /**
+ * Returns a string representing average commit time duration, in the appropriate
+ * scaled units.
+ */
+ String getAverageCommitTime();
+
+ /**
+ * Clears the current stats to their defaults.
+ */
+ void clearStats();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.dom.broker.impl.jmx;
+
+import javax.annotation.Nonnull;
+
+import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
+import org.opendaylight.yangtools.util.DurationStatsTracker;
+
+/**
+ * Implementation of the CommitStatsMXBean interface.
+ *
+ * @author Thomas Pantelis
+ */
+public class CommitStatsMXBeanImpl extends AbstractMXBean implements CommitStatsMXBean {
+
+ private final DurationStatsTracker commitStatsTracker;
+
+ /**
+ * Constructor.
+ *
+ * @param commitStatsTracker the DurationStatsTracker used to obtain the stats.
+ * @param mBeanType mBeanType Used as the <code>type</code> property in the bean's ObjectName.
+ */
+ public CommitStatsMXBeanImpl(@Nonnull DurationStatsTracker commitStatsTracker,
+ @Nonnull String mBeanType) {
+ super("CommitStats", mBeanType, null);
+ this.commitStatsTracker = commitStatsTracker;
+ }
+
+ @Override
+ public long getTotalCommits() {
+ return commitStatsTracker.getTotalDurations();
+ }
+
+ @Override
+ public String getLongestCommitTime() {
+ return commitStatsTracker.getDisplayableLongestDuration();
+ }
+
+ @Override
+ public String getShortestCommitTime() {
+ return commitStatsTracker.getDisplayableShortestDuration();
+ }
+
+ @Override
+ public String getAverageCommitTime() {
+ return commitStatsTracker.getDisplayableAverageDuration();
+ }
+
+ @Override
+ public void clearStats() {
+ commitStatsTracker.reset();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.dom.broker.impl.jmx;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.util.DurationStatsTracker;
+
+/**
+ * Unit tests for CommitStatsMXBeanImpl.
+ *
+ * @author Thomas Pantelis
+ */
+public class CommitStatsMXBeanImplTest {
+
+ @Test
+ public void test() {
+
+ DurationStatsTracker commitStatsTracker = new DurationStatsTracker();
+ CommitStatsMXBeanImpl bean =
+ new CommitStatsMXBeanImpl(commitStatsTracker, "Test");
+
+ commitStatsTracker.addDuration(100);
+
+ String prefix = "100.0 ns";
+ assertEquals("getTotalCommits", 1L, bean.getTotalCommits());
+ assertEquals("getLongestCommitTime starts with \"" + prefix + "\"", true,
+ bean.getLongestCommitTime().startsWith("100.0 ns"));
+ assertEquals("getShortestCommitTime starts with \"" + prefix + "\"", true,
+ bean.getShortestCommitTime().startsWith(prefix));
+ assertEquals("getAverageCommitTime starts with \"" + prefix + "\"", true,
+ bean.getAverageCommitTime().startsWith(prefix));
+ }
+}
CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(YangInstanceIdentifier path);
/**
- * Checks if data is available in the logical data store located at provided path
+ * Checks if data is available in the logical data store located at provided path.
+ * <p>
+ *
+ * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
+ * will succeed. It is possible that the data resides in a data store on a remote node and, if that
+ * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
+ * the data is deleted in between the calls to <code>exists</code> and <code>read</code>
*
* @param path
* Path which uniquely identifies subtree which client want to
* sequence and each transaction must see the effects of previous transactions
* as if they happened. A chain makes no guarantees of atomicity, in fact
* transactions are committed as soon as possible.
- *
- *
*/
public interface DOMStoreTransactionChain extends DOMStoreTransactionFactory, AutoCloseable {
* if the chain has been closed.
*/
@Override
- public DOMStoreReadTransaction newReadOnlyTransaction();
+ DOMStoreReadTransaction newReadOnlyTransaction();
/**
* Create a new read write transaction which will continue the chain. The
* if the chain has been closed.
*/
@Override
- public DOMStoreReadWriteTransaction newReadWriteTransaction();
+ DOMStoreReadWriteTransaction newReadWriteTransaction();
/**
- * Create a new read write transaction which will continue the chain. The
+ * Create a new write-only transaction which will continue the chain. The
* previous read-write transaction has to be either READY or CANCELLED.
*
*
* if the chain has been closed.
*/
@Override
- public DOMStoreWriteTransaction newWriteOnlyTransaction();
-
+ DOMStoreWriteTransaction newWriteOnlyTransaction();
/**
* Closes Transaction Chain.
* @throws IllegalStateException If any of the outstanding created transactions was not canceled or ready.
*/
@Override
- public void close();
-
+ void close();
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.sal.core.spi.data.statistics;
+
+import java.util.concurrent.ExecutorService;
+
+import javax.annotation.Nonnull;
+
+import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
+
+/**
+ * Interface for a class that tracks statistics for a data store.
+ *
+ * @author Thomas Pantelis
+ */
+public interface DOMStoreStatsTracker {
+
+ /**
+ * Sets the executor used for DataChangeListener notifications.
+ *
+ * @param dclExecutor the executor
+ */
+ void setDataChangeListenerExecutor( @Nonnull ExecutorService dclExecutor );
+
+ /**
+ * Sets the executor used internally by the data store.
+ *
+ * @param dsExecutor the executor
+ */
+ void setDataStoreExecutor( @Nonnull ExecutorService dsExecutor );
+
+ /**
+ * Sets the QueuedNotificationManager use for DataChangeListener notifications,
+ *
+ * @param manager the manager
+ */
+ void setNotificationManager( @Nonnull QueuedNotificationManager<?, ?> manager );
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.\r
+\r
+ This program and the accompanying materials are made available under the\r
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ and is available at http://www.eclipse.org/legal/epl-v10.html\r
+--><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">\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+\r
+ <parent>\r
+ <artifactId>sal-parent</artifactId>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <version>1.1-SNAPSHOT</version>\r
+ </parent>\r
+ <artifactId>sal-dom-xsql-config</artifactId>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <description>Configuration files for md-sal</description>\r
+ <packaging>jar</packaging>\r
+ <properties>\r
+ <!-- Optional TODO: Rename your configfile to taste -->\r
+ <configfile>04-xsql.xml</configfile>\r
+ </properties>\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>build-helper-maven-plugin</artifactId>\r
+ <executions>\r
+ <execution>\r
+ <id>attach-artifacts</id>\r
+ <goals>\r
+ <goal>attach-artifact</goal>\r
+ </goals>\r
+ <phase>package</phase>\r
+ <configuration>\r
+ <artifacts>\r
+ <artifact>\r
+ <file>${project.build.directory}/classes/${configfile}</file>\r
+ <type>xml</type>\r
+ <classifier>config</classifier>\r
+ </artifact>\r
+ </artifacts>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <scm>\r
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>\r
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>\r
+ <tag>HEAD</tag>\r
+ <url>https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=summary</url>\r
+ </scm>\r
+</project>\r
--- /dev/null
+<snapshot>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:XSQL="http://netconfcentral.org/ns/XSQL">
+ XSQL:XSQL
+ </type>
+ <name>XSQL</name>
+ <data-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+ <async-data-broker>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <name>inmemory-data-broker</name>
+ </async-data-broker>
+ <schema-service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+ <name>yang-schema-service</name>
+ </schema-service>
+ </module>
+ </modules>
+ </data>
+ </configuration>
+ <required-capabilities>
+ <capability>http://netconfcentral.org/ns/XSQL?module=XSQL&revision=2014-06-26</capability>
+ </required-capabilities>
+</snapshot>
}
- protected void processCommand(StringBuffer inputString, PrintStream sout,
- TelnetConnection tc) {
+ public void processCommand(StringBuffer inputString, PrintStream sout) {
if (inputString.toString().trim().equals("r")) {
sout.println(lastInputString);
inputString = lastInputString;
for (int i = 0; i < iNames.length; i++) {
sout.println(iNames[i]);
}
- } else if (input.startsWith("cd sid")) {
- String substr = input.substring("cd sid".length()).trim();
- for (NEEntry e : elements.values()) {
- if (((Module) e.ne).getName().equals(substr)) {
- tc.currentModule = (Module) e.ne;
- }
- }
- } else if (input.equals("list sid")) {
- String arr[] = new String[elements.size()];
-
- int i = 0;
- for (NEEntry entry : elements.values()) {
- arr[i] = entry.toString();
- i++;
- }
- Arrays.sort(arr);
- for (String s : arr) {
- sout.println(s);
- }
} else if (input.equals("help") || input.equals("?")) {
// sout.println(getLongDescription());
} else if (input.equals("avmdata")) {
}
}
- processCommand(inputString, out, this);
+ processCommand(inputString, out);
inputString = new StringBuffer();
}
} catch (Exception err) {
package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
+import org.opendaylight.controller.md.sal.dom.store.impl.jmx.InMemoryDataStoreStats;
public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModule {
@Override
public java.lang.AutoCloseable createInstance() {
- return InMemoryDOMDataStoreFactory.create("DOM-CFG", getSchemaServiceDependency(),
+
+ InMemoryDOMDataStore dataStore = InMemoryDOMDataStoreFactory.create(
+ "DOM-CFG", getSchemaServiceDependency(),
InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(),
- getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize()));
+ getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize(),
+ getMaxDataStoreExecutorQueueSize()));
+
+ InMemoryDataStoreStats statsBean = new InMemoryDataStoreStats("InMemoryConfigDataStore",
+ dataStore.getDataChangeListenerNotificationManager(), dataStore.getDomStoreExecutor());
+
+ dataStore.setCloseable(statsBean);
+
+ return dataStore;
}
}
package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
+import org.opendaylight.controller.md.sal.dom.store.impl.jmx.InMemoryDataStoreStats;
public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModule {
@Override
public java.lang.AutoCloseable createInstance() {
- return InMemoryDOMDataStoreFactory.create("DOM-OPER", getOperationalSchemaServiceDependency(),
+ InMemoryDOMDataStore dataStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", getSchemaServiceDependency(),
InMemoryDOMDataStoreConfigProperties.create(getMaxDataChangeExecutorPoolSize(),
- getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize()));
- }
+ getMaxDataChangeExecutorQueueSize(), getMaxDataChangeListenerQueueSize(),
+ getMaxDataStoreExecutorQueueSize()));
+
+
+ InMemoryDataStoreStats statsBean = new InMemoryDataStoreStats("InMemoryOperationalDataStore",
+ dataStore.getDataChangeListenerNotificationManager(), dataStore.getDomStoreExecutor());
+ dataStore.setCloseable(statsBean);
+
+ return dataStore;
+ }
}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.md.sal.dom.store.impl;
-
-import com.google.common.base.Preconditions;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
-import org.opendaylight.yangtools.util.concurrent.NotificationManager;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class ChangeListenerNotifyTask implements Runnable {
- private static final Logger LOG = LoggerFactory.getLogger(ChangeListenerNotifyTask.class);
-
- @SuppressWarnings("rawtypes")
- private final NotificationManager<AsyncDataChangeListener,AsyncDataChangeEvent> notificationMgr;
- private final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> event;
- private final DataChangeListenerRegistration<?> listener;
-
- @SuppressWarnings("rawtypes")
- public ChangeListenerNotifyTask(final DataChangeListenerRegistration<?> listener,
- final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> event,
- final NotificationManager<AsyncDataChangeListener,AsyncDataChangeEvent> notificationMgr) {
- this.notificationMgr = Preconditions.checkNotNull(notificationMgr);
- this.listener = Preconditions.checkNotNull(listener);
- this.event = Preconditions.checkNotNull(event);
- }
-
- @Override
- public void run() {
- final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> l = listener.getInstance();
- if (l == null) {
- LOG.trace("Skipping event delivery to unregistered listener {}", l);
- return;
- }
- LOG.trace("Listener {} event {}", l, event);
-
- // FIXME: Yo dawg I heard you like queues, so this was queued to be queued
- notificationMgr.submitNotification(l, event);
- }
-
- @Override
- public String toString() {
- return "ChangeListenerNotifyTask [listener=" + listener + ", event=" + event + "]";
- }
-}
*/
package org.opendaylight.controller.md.sal.dom.store.impl;
+import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.yangtools.util.ExecutorServiceUtil;
-import org.opendaylight.yangtools.util.concurrent.NotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree;
-import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.ExecutorServiceUtil;
+import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
+import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.Invoker;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.concurrent.GuardedBy;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static com.google.common.base.Preconditions.checkState;
-
/**
* In-memory DOM Data Store
*
public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, SchemaContextListener,
TransactionReadyPrototype,AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
+ private static final ListenableFuture<Void> SUCCESSFUL_FUTURE = Futures.immediateFuture(null);
- @SuppressWarnings("rawtypes")
- private static final QueuedNotificationManager.Invoker<AsyncDataChangeListener,
- AsyncDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER =
- new QueuedNotificationManager.Invoker<AsyncDataChangeListener,
- AsyncDataChangeEvent>() {
-
- @SuppressWarnings("unchecked")
+ private static final Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER =
+ new Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent>() {
@Override
- public void invokeListener( AsyncDataChangeListener listener,
- AsyncDataChangeEvent notification ) {
- listener.onDataChanged(notification);
+ public void invokeListener(final DataChangeListenerRegistration<?> listener,
+ final DOMImmutableDataChangeEvent notification ) {
+ final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> inst = listener.getInstance();
+ if (inst != null) {
+ inst.onDataChanged(notification);
+ }
}
};
private final AtomicLong txCounter = new AtomicLong(0);
private final ListeningExecutorService listeningExecutor;
- @SuppressWarnings("rawtypes")
- private final NotificationManager<AsyncDataChangeListener,AsyncDataChangeEvent>
- dataChangeListenerNotificationManager;
+ private final QueuedNotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> dataChangeListenerNotificationManager;
private final ExecutorService dataChangeListenerExecutor;
+ private final ExecutorService domStoreExecutor;
+
private final String name;
- public InMemoryDOMDataStore(final String name, final ListeningExecutorService listeningExecutor,
+ private volatile AutoCloseable closeable;
+
+ public InMemoryDOMDataStore(final String name, final ExecutorService domStoreExecutor,
final ExecutorService dataChangeListenerExecutor) {
- this(name, listeningExecutor, dataChangeListenerExecutor,
- InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE);
+ this(name, domStoreExecutor, dataChangeListenerExecutor,
+ InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE);
}
- public InMemoryDOMDataStore(final String name, final ListeningExecutorService listeningExecutor,
- final ExecutorService dataChangeListenerExecutor, int maxDataChangeListenerQueueSize) {
+ public InMemoryDOMDataStore(final String name, final ExecutorService domStoreExecutor,
+ final ExecutorService dataChangeListenerExecutor, final int maxDataChangeListenerQueueSize) {
this.name = Preconditions.checkNotNull(name);
- this.listeningExecutor = Preconditions.checkNotNull(listeningExecutor);
-
+ this.domStoreExecutor = Preconditions.checkNotNull(domStoreExecutor);
+ this.listeningExecutor = MoreExecutors.listeningDecorator(this.domStoreExecutor);
this.dataChangeListenerExecutor = Preconditions.checkNotNull(dataChangeListenerExecutor);
dataChangeListenerNotificationManager =
"DataChangeListenerQueueMgr");
}
+ public void setCloseable(AutoCloseable closeable) {
+ this.closeable = closeable;
+ }
+
+ public QueuedNotificationManager<?, ?> getDataChangeListenerNotificationManager() {
+ return dataChangeListenerNotificationManager;
+ }
+
+ public ExecutorService getDomStoreExecutor() {
+ return domStoreExecutor;
+ }
+
@Override
public final String getIdentifier() {
return name;
public void close() {
ExecutorServiceUtil.tryGracefulShutdown(listeningExecutor, 30, TimeUnit.SECONDS);
ExecutorServiceUtil.tryGracefulShutdown(dataChangeListenerExecutor, 30, TimeUnit.SECONDS);
+
+ if(closeable != null) {
+ try {
+ closeable.close();
+ } catch(Exception e) {
+ LOG.debug("Error closing instance", e);
+ }
+ }
}
+
@Override
public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerChangeListener(
final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) {
.addCreated(path, data) //
.build();
- new ChangeListenerNotifyTask(reg, event,
- dataChangeListenerNotificationManager).run();
+ dataChangeListenerNotificationManager.submitNotification(reg, event);
}
}
}
@Override
- public synchronized DOMStoreThreePhaseCommitCohort ready(final SnapshotBackedWriteTransaction writeTx) {
+ public DOMStoreThreePhaseCommitCohort ready(final SnapshotBackedWriteTransaction writeTx) {
LOG.debug("Tx: {} is submitted. Modifications: {}", writeTx.getIdentifier(), writeTx.getMutatedView());
return new ThreePhaseCommitImpl(writeTx);
}
}
public synchronized void onTransactionCommited(final SnapshotBackedWriteTransaction transaction) {
- // If commited transaction is latestOutstandingTx we clear
+ // If committed transaction is latestOutstandingTx we clear
// latestOutstandingTx
// field in order to base new transactions on Datastore Data Tree
// directly.
@Override
public Void call() {
candidate = dataTree.prepare(modification);
- listenerResolver = ResolveDataChangeEventsTask.create(candidate, listenerTree,
- dataChangeListenerNotificationManager);
+ listenerResolver = ResolveDataChangeEventsTask.create(candidate, listenerTree);
return null;
}
});
@Override
public ListenableFuture<Void> abort() {
candidate = null;
- return Futures.immediateFuture(null);
+ return SUCCESSFUL_FUTURE;
}
@Override
*/
synchronized (this) {
dataTree.commit(candidate);
-
- for (ChangeListenerNotifyTask task : listenerResolver.call()) {
- LOG.trace("Scheduling invocation of listeners: {}", task);
- task.run();
- }
+ listenerResolver.resolve(dataChangeListenerNotificationManager);
}
- return Futures.immediateFuture(null);
+ return SUCCESSFUL_FUTURE;
}
}
}
public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
public static final int DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE = 1000;
+ public static final int DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE = 5000;
private static final InMemoryDOMDataStoreConfigProperties DEFAULT =
create(DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE,
DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE,
- DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE);
+ DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE,
+ DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE);
private final int maxDataChangeExecutorQueueSize;
private final int maxDataChangeExecutorPoolSize;
private final int maxDataChangeListenerQueueSize;
+ private final int maxDataStoreExecutorQueueSize;
/**
* Constructs an instance with the given property values.
* maximum queue size for the data change notification executor.
* @param maxDataChangeListenerQueueSize
* maximum queue size for the data change listeners.
+ * @param maxDataStoreExecutorQueueSize
+ * maximum queue size for the data store executor.
*/
+ public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
+ int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize,
+ int maxDataStoreExecutorQueueSize) {
+ return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
+ maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize,
+ maxDataStoreExecutorQueueSize);
+ }
+
public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) {
return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
- maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize);
+ maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize,
+ DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE);
}
/**
}
private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) {
+ int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize,
+ int maxDataStoreExecutorQueueSize) {
this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize;
this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize;
this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize;
+ this.maxDataStoreExecutorQueueSize = maxDataStoreExecutorQueueSize;
}
/**
public int getMaxDataChangeListenerQueueSize() {
return maxDataChangeListenerQueueSize;
}
+
+ /**
+ * Returns the maximum queue size for the data store executor.
+ */
+ public int getMaxDataStoreExecutorQueueSize() {
+ return maxDataStoreExecutorQueueSize;
+ }
}
package org.opendaylight.controller.md.sal.dom.store.impl;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import javax.annotation.Nullable;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-import com.google.common.util.concurrent.MoreExecutors;
/**
* A factory for creating InMemoryDOMDataStore instances.
ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL" );
+ ExecutorService domStoreExecutor = SpecialExecutors.newBoundedSingleThreadExecutor(
+ actualProperties.getMaxDataStoreExecutorQueueSize(), "DOMStore-" + name );
+
InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name,
- MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()),
- dataChangeListenerExecutor, actualProperties.getMaxDataChangeListenerQueueSize());
+ domStoreExecutor, dataChangeListenerExecutor,
+ actualProperties.getMaxDataChangeListenerQueueSize());
if(schemaService != null) {
schemaService.registerSchemaContextListener(dataStore);
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Map.Entry;
-import java.util.concurrent.Callable;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder;
import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.SimpleEventFactory;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree;
* Computes data change events for all affected registered listeners in data
* tree.
*/
-final class ResolveDataChangeEventsTask implements Callable<Iterable<ChangeListenerNotifyTask>> {
+final class ResolveDataChangeEventsTask {
private static final Logger LOG = LoggerFactory.getLogger(ResolveDataChangeEventsTask.class);
- @SuppressWarnings("rawtypes")
- private final NotificationManager<AsyncDataChangeListener, AsyncDataChangeEvent> notificationMgr;
private final DataTreeCandidate candidate;
private final ListenerTree listenerRoot;
private Multimap<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> collectedEvents;
- @SuppressWarnings("rawtypes")
- public ResolveDataChangeEventsTask(final DataTreeCandidate candidate, final ListenerTree listenerTree,
- final NotificationManager<AsyncDataChangeListener, AsyncDataChangeEvent> notificationMgr) {
+ public ResolveDataChangeEventsTask(final DataTreeCandidate candidate, final ListenerTree listenerTree) {
this.candidate = Preconditions.checkNotNull(candidate);
this.listenerRoot = Preconditions.checkNotNull(listenerTree);
- this.notificationMgr = Preconditions.checkNotNull(notificationMgr);
}
/**
- * Resolves and creates Notification Tasks
- *
- * Implementation of done as Map-Reduce with two steps: 1. resolving events
- * and their mapping to listeners 2. merging events affecting same listener
- *
- * @return An {@link Iterable} of Notification Tasks which needs to be executed in
- * order to delivery data change events.
+ * Resolves and submits notification tasks to the specified manager.
*/
- @Override
- public synchronized Iterable<ChangeListenerNotifyTask> call() {
+ public synchronized void resolve(final NotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> manager) {
try (final Walker w = listenerRoot.getWalker()) {
// Defensive: reset internal state
collectedEvents = ArrayListMultimap.create();
* Convert to tasks, but be mindful of multiple values -- those indicate multiple
* wildcard matches, which need to be merged.
*/
- final Collection<ChangeListenerNotifyTask> ret = new ArrayList<>();
for (Entry<DataChangeListenerRegistration<?>, Collection<DOMImmutableDataChangeEvent>> e : collectedEvents.asMap().entrySet()) {
final Collection<DOMImmutableDataChangeEvent> col = e.getValue();
final DOMImmutableDataChangeEvent event;
event = col.iterator().next();
}
- ret.add(new ChangeListenerNotifyTask(e.getKey(), event, notificationMgr));
+ manager.submitNotification(e.getKey(), event);
}
-
- // FIXME: so now we have tasks to submit tasks... Inception-style!
- LOG.debug("Created tasks {}", ret);
- return ret;
}
}
return scope != null;
}
- @SuppressWarnings("rawtypes")
- public static ResolveDataChangeEventsTask create(final DataTreeCandidate candidate,
- final ListenerTree listenerTree,
- final NotificationManager<AsyncDataChangeListener,AsyncDataChangeEvent> notificationMgr) {
- return new ResolveDataChangeEventsTask(candidate, listenerTree, notificationMgr);
+ public static ResolveDataChangeEventsTask create(final DataTreeCandidate candidate, final ListenerTree listenerTree) {
+ return new ResolveDataChangeEventsTask(candidate, listenerTree);
}
}
return true;
}
- // FIXME: do we need anything else? If not, flip this to 'false'
- return true;
+ return false;
}
/**
implements DOMStoreReadTransaction {
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class);
- private DataTreeSnapshot stableSnapshot;
+ private volatile DataTreeSnapshot stableSnapshot;
public SnapshotBackedReadTransaction(final Object identifier, final DataTreeSnapshot snapshot) {
super(identifier);
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
- if(stableSnapshot == null) {
+ final DataTreeSnapshot snapshot = stableSnapshot;
+ if (snapshot == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed"));
}
try {
- return Futures.immediateCheckedFuture(stableSnapshot.readNode(path));
+ return Futures.immediateCheckedFuture(snapshot.readNode(path));
} catch (Exception e) {
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
}
}
- @Override public CheckedFuture<Boolean, ReadFailedException> exists(YangInstanceIdentifier path) {
+ @Override
+ public CheckedFuture<Boolean, ReadFailedException> exists(YangInstanceIdentifier path) {
LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications 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.md.sal.dom.store.impl.jmx;
+
+import java.util.concurrent.ExecutorService;
+
+import org.opendaylight.controller.md.sal.common.util.jmx.QueuedNotificationManagerMXBeanImpl;
+import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl;
+import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
+
+/**
+ * Wrapper class for data store MXbeans.
+ *
+ * @author Thomas Pantelis
+ */
+public class InMemoryDataStoreStats implements AutoCloseable {
+
+ private final ThreadExecutorStatsMXBeanImpl notificationExecutorStatsBean;
+ private final ThreadExecutorStatsMXBeanImpl dataStoreExecutorStatsBean;
+ private final QueuedNotificationManagerMXBeanImpl notificationManagerStatsBean;
+
+ public InMemoryDataStoreStats(String mBeanType, QueuedNotificationManager<?, ?> manager,
+ ExecutorService dataStoreExecutor) {
+
+ this.notificationManagerStatsBean = new QueuedNotificationManagerMXBeanImpl(manager,
+ "notification-manager", mBeanType, null);
+ notificationManagerStatsBean.registerMBean();
+
+ this.notificationExecutorStatsBean = new ThreadExecutorStatsMXBeanImpl(manager.getExecutor(),
+ "notification-executor", mBeanType, null);
+ this.notificationExecutorStatsBean.registerMBean();
+
+ this.dataStoreExecutorStatsBean = new ThreadExecutorStatsMXBeanImpl(dataStoreExecutor,
+ "data-store-executor", mBeanType, null);
+ this.dataStoreExecutorStatsBean.registerMBean();
+ }
+
+ @Override
+ public void close() throws Exception {
+ if(notificationExecutorStatsBean != null) {
+ notificationExecutorStatsBean.unregisterMBean();
+ }
+
+ if(dataStoreExecutorStatsBean != null) {
+ dataStoreExecutorStatsBean.unregisterMBean();
+ }
+
+ if(notificationManagerStatsBean != null) {
+ notificationManagerStatsBean.unregisterMBean();
+ }
+ }
+}
config:java-name-prefix InMemoryOperationalDataStoreProvider;
}
-
- // Augments the 'configuration' choice node under modules/module.
- augment "/config:modules/config:module/config:configuration" {
- case inmemory-config-datastore-provider {
- when "/config:modules/config:module/config:type = 'inmemory-config-datastore-provider'";
-
- container schema-service {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity sal:schema-service;
- }
- }
- }
-
+ grouping datastore-configuration {
leaf max-data-change-executor-queue-size {
default 1000;
type uint16;
type uint16;
description "The maximum queue size for the data change listeners.";
}
- }
+
+ leaf max-data-store-executor-queue-size {
+ default 5000;
+ type uint16;
+ description "The maximum queue size for the data store executor.";
+ }
}
// Augments the 'configuration' choice node under modules/module.
augment "/config:modules/config:module/config:configuration" {
- case inmemory-operational-datastore-provider {
- when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'";
+ case inmemory-config-datastore-provider {
+ when "/config:modules/config:module/config:type = 'inmemory-config-datastore-provider'";
- // Yang does not allow two cases from same namespaces with same children
- // Schema-service dependency renamed to operational-schema-service
- // to prevent conflict with schema-service container from inmemory-config-datastore-provider
- container operational-schema-service {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity sal:schema-service;
+ container inmemory-config-datastore-provider {
+ container schema-service {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity sal:schema-service;
+ }
}
}
+ uses datastore-configuration;
}
+ }
+ }
- leaf max-data-change-executor-queue-size {
- default 1000;
- type uint16;
- description "The maximum queue size for the data change notification executor.";
- }
-
- leaf max-data-change-executor-pool-size {
- default 20;
- type uint16;
- description "The maximum thread pool size for the data change notification executor.";
- }
+ // Augments the 'configuration' choice node under modules/module.
+ augment "/config:modules/config:module/config:configuration" {
+ case inmemory-operational-datastore-provider {
+ when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'";
- leaf max-data-change-listener-queue-size {
- default 1000;
- type uint16;
- description "The maximum queue size for the data change listeners.";
+ container inmemory-operational-datastore-provider {
+ container schema-service {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity sal:schema-service;
+ }
+ }
+ }
+ uses datastore-configuration;
}
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<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">\r
+\r
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+\r
+ <parent>\r
+ <artifactId>sal-parent</artifactId>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <version>1.1-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <groupId>xsqlcommand</groupId>\r
+ <artifactId>xsqlcommand</artifactId>\r
+ <packaging>bundle</packaging>\r
+ <version>1.0.0-SNAPSHOT</version>\r
+ <name>Apache Karaf :: Shell odl/xsql Commands</name>\r
+\r
+ <description>Provides the OSGi odl commands</description>\r
+\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.apache.karaf.shell</groupId>\r
+ <artifactId>org.apache.karaf.shell.console</artifactId>\r
+ <version>3.0.1</version>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.osgi</groupId>\r
+ <artifactId>org.osgi.core</artifactId>\r
+ <version>5.0.0</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.osgi</groupId>\r
+ <artifactId>org.osgi.compendium</artifactId>\r
+ <version>5.0.0</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.11</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>sal-dom-xsql</artifactId>\r
+ <type>bundle</type>\r
+ <version>1.1-SNAPSHOT</version>\r
+ </dependency>\r
+ </dependencies>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <inherited>true</inherited>\r
+ <version>2.3.2</version>\r
+ <configuration>\r
+ <source>1.5</source>\r
+ <target>1.5</target>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.felix</groupId>\r
+ <artifactId>maven-bundle-plugin</artifactId>\r
+ <version>2.4.0</version>\r
+ <extensions>true</extensions>\r
+ <configuration>\r
+ <instructions>\r
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>\r
+ <Export-Package>org.opendaylight.controller.xsql*;version=${project.version}</Export-Package>\r
+ <Import-Package>!org.opendaylight.controller.xsql*,\r
+ org.apache.aries.blueprint,\r
+ org.osgi.service.blueprint.container,\r
+ org.osgi.service.blueprint.reflect,\r
+ org.apache.felix.service.command,\r
+ org.apache.karaf.shell.commands,\r
+ org.apache.karaf.shell.console,\r
+ *</Import-Package>\r
+ </instructions>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+\r
+</project>\r
--- /dev/null
+package org.opendaylight.controller.xsql;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+
+@Command(scope = "odl", name = "xsql", description = "XSQL Karaf Command")
+public class xsql extends OsgiCommandSupport {
+
+ @Option(name = "-o", aliases = { "--option" }, description = "An option to the command", required = false, multiValued = false)
+ private String option;
+
+ @Argument(name = "argument", description = "Argument to the command", required = false, multiValued = false)
+ private String argument;
+
+ protected Object doExecute() throws Exception {
+ XSQLAdapter.getInstance().processCommand(new StringBuffer(argument),
+ System.out);
+ return null;
+ }
+}
final CompositeNode schemasNode =
(CompositeNode) NetconfMessageTransformUtil.findNode(schemasNodeResult.getResult(), DATA_STATE_SCHEMAS_IDENTIFIER);
+ if(schemasNode == null) {
+ logger.warn("{}: Unable to detect available schemas, get to {} was empty", id, STATE_SCHEMAS_IDENTIFIER);
+ return EMPTY;
+ }
+
return create(id, schemasNode);
}
QName childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_FORMAT.withoutRevision();
- final String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get();
+ String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get();
+ //This is HotFix for situations where format statement in netconf-monitoring might be passed with prefix.
+ if (formatAsString.contains(":")) {
+ String[] prefixedString = formatAsString.split(":");
+ //FIXME: might be good idea to check prefix against model namespace
+ formatAsString = prefixedString[1];
+ }
if(formatAsString.equals(Yang.QNAME.getLocalName()) == false) {
logger.debug("{}: Ignoring schema due to unsupported format: {}", id, formatAsString);
return Optional.absent();
}
@Override
- public void onDeviceDisconnected() {
+ public synchronized void onDeviceDisconnected() {
salProvider.getDatastoreAdapter().updateDeviceState(false, Collections.<QName>emptySet());
salProvider.getMountInstance().onDeviceDisconnected();
}
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.io.InputStream;
-import java.util.concurrent.ExecutionException;
import org.apache.commons.io.IOUtils;
import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil;
import org.opendaylight.controller.sal.connect.util.RemoteDeviceId;
rpc.invokeRpc(GET_SCHEMA_QNAME, getSchemaRequest),
new ResultToYangSourceTransformer(id, sourceIdentifier, moduleName, revision));
- // FIXME remove this get, it is only present to wait until source is retrieved
+ final CheckedFuture<YangTextSchemaSource, SchemaSourceException> checked = Futures.makeChecked(transformed, MAPPER);
+
+ // / FIXME remove this get, it is only present to wait until source is retrieved
// (goal is to limit concurrent schema download, since NetconfDevice listener does not handle concurrent messages properly)
try {
logger.trace("{}: Blocking for {}", id, sourceIdentifier);
- transformed.get();
- } catch (final InterruptedException e) {
- throw new RuntimeException(e);
- } catch (final ExecutionException e) {
- throw new IllegalStateException(id + ": Failed while getting source: " + sourceIdentifier, e);
+ checked.checkedGet();
+ } catch (final SchemaSourceException e) {
+ return Futures.immediateFailedCheckedFuture(e);
}
- return Futures.makeChecked(transformed, MAPPER);
+ return checked;
}
/**
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-api</artifactId>
-
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
-
</dependency>
-
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
-
</dependency>
-
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
-
</dependency>
-
-
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
-
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
- <version>3.0.1</version>
</dependency>
+
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-graphite</artifactId>
+ </dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<build>
<plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>org.opendaylight.controller.*</include>
+ </includes>
+ <excludes>
+ <exclude>org.opendaylight.controller.config.yang.config.*</exclude>
+ </excludes>
+ <check>false</check>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>post-test</id>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <phase>test</phase>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
import akka.actor.SupervisorStrategy;
import akka.japi.Creator;
import akka.japi.Function;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
import org.opendaylight.controller.remote.rpc.messages.UpdateSchemaContext;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry;
+import org.opendaylight.controller.remote.rpc.utils.ActorUtil;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.yangtools.yang.common.QName;
private void createRpcActors() {
LOG.debug("Create rpc registry and broker actors");
+ Config conf = ConfigFactory.load();
- rpcRegistry = getContext().actorOf(Props.create(RpcRegistry.class), ActorConstants.RPC_REGISTRY);
+ rpcRegistry =
+ getContext().actorOf(Props.create(RpcRegistry.class).
+ withMailbox(ActorUtil.MAILBOX), ActorConstants.RPC_REGISTRY);
+
+ rpcBroker =
+ getContext().actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext).
+ withMailbox(ActorUtil.MAILBOX),ActorConstants.RPC_BROKER);
- rpcBroker = getContext().actorOf(RpcBroker.props(brokerSession, rpcRegistry, schemaContext), ActorConstants.RPC_BROKER);
RpcRegistry.Messages.SetLocalRouter localRouter = new RpcRegistry.Messages.SetLocalRouter(rpcBroker);
rpcRegistry.tell(localRouter, self());
}
import com.google.common.base.Preconditions;
import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket;
import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore;
+import org.opendaylight.controller.remote.rpc.utils.ActorUtil;
import org.opendaylight.controller.sal.connector.api.RpcRouter;
import scala.concurrent.Future;
Preconditions.checkState(localRouter != null, "Router must be set first");
- Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), 1000);
+ Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), ActorUtil.ASK_DURATION.toMillis());
futureReply.map(getMapperToAddRoutes(msg.getRouteIdentifiers()), getContext().dispatcher());
}
*/
private void receiveRemoveRoutes(RemoveRoutes msg) {
- Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), 1000);
+ Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), ActorUtil.ASK_DURATION.toMillis());
futureReply.map(getMapperToRemoveRoutes(msg.getRouteIdentifiers()), getContext().dispatcher());
}
private void receiveGetRouter(FindRouters msg) {
final ActorRef sender = getSender();
- Future<Object> futureReply = Patterns.ask(bucketStore, new GetAllBuckets(), 1000);
+ Future<Object> futureReply = Patterns.ask(bucketStore, new GetAllBuckets(), ActorUtil.ASK_DURATION.toMillis());
futureReply.map(getMapperToGetRouter(msg.getRouteIdentifier(), sender), getContext().dispatcher());
}
import akka.cluster.ClusterActorRefProvider;
import akka.event.Logging;
import akka.event.LoggingAdapter;
+import org.opendaylight.controller.remote.rpc.utils.ActorUtil;
import org.opendaylight.controller.utils.ConditionalProbe;
import java.util.HashMap;
selfAddress = provider.getDefaultAddress();
if ( provider instanceof ClusterActorRefProvider)
- getContext().actorOf(Props.create(Gossiper.class), "gossiper");
+ getContext().actorOf(Props.create(Gossiper.class).withMailbox(ActorUtil.MAILBOX), "gossiper");
}
@Override
import akka.event.Logging;
import akka.event.LoggingAdapter;
import akka.pattern.Patterns;
+import org.opendaylight.controller.remote.rpc.utils.ActorUtil;
import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;
if (autoStartGossipTicks) {
gossipTask = getContext().system().scheduler().schedule(
new FiniteDuration(1, TimeUnit.SECONDS), //initial delay
- new FiniteDuration(500, TimeUnit.MILLISECONDS), //interval
+ ActorUtil.GOSSIP_TICK_INTERVAL, //interval
getSelf(), //target
new Messages.GossiperMessages.GossipTick(), //message
getContext().dispatcher(), //execution context
return;
final ActorRef sender = getSender();
- Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), 1000);
+ Future<Object> futureReply =
+ Patterns.ask(getContext().parent(), new GetBucketVersions(), ActorUtil.ASK_DURATION.toMillis());
+
futureReply.map(getMapperToProcessRemoteStatus(sender, status), getContext().dispatcher());
}
*/
void sendGossipTo(final ActorRef remote, final Set<Address> addresses){
- Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketsByMembers(addresses), 1000);
+ Future<Object> futureReply =
+ Patterns.ask(getContext().parent(), new GetBucketsByMembers(addresses), ActorUtil.ASK_DURATION.toMillis());
futureReply.map(getMapperToSendGossip(remote), getContext().dispatcher());
}
void getLocalStatusAndSendTo(Address remoteActorSystemAddress){
//Get local status from bucket store and send to remote
- Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), 1000);
+ Future<Object> futureReply =
+ Patterns.ask(getContext().parent(), new GetBucketVersions(), ActorUtil.ASK_DURATION.toMillis());
+
+ //Find gossiper on remote system
ActorSelection remoteRef = getContext().system().actorSelection(
remoteActorSystemAddress.toString() + getSelf().path().toStringWithoutAddress());
import static akka.pattern.Patterns.ask;
public class ActorUtil {
- public static final FiniteDuration LOCAL_ASK_DURATION = Duration.create(2, TimeUnit.SECONDS);
- public static final FiniteDuration REMOTE_ASK_DURATION = Duration.create(15, TimeUnit.SECONDS);
- public static final FiniteDuration ASK_DURATION = Duration.create(17, TimeUnit.SECONDS);
- public static final FiniteDuration LOCAL_AWAIT_DURATION = Duration.create(2, TimeUnit.SECONDS);
- public static final FiniteDuration REMOTE_AWAIT_DURATION = Duration.create(15, TimeUnit.SECONDS);
- public static final FiniteDuration AWAIT_DURATION = Duration.create(17, TimeUnit.SECONDS);
-
- /**
- * Executes an operation on a local actor and wait for it's response
- * @param actor
- * @param message
- * @param askDuration
- * @param awaitDuration
- * @return The response of the operation
- */
- public static Object executeOperation(ActorRef actor, Object message,
- FiniteDuration askDuration, FiniteDuration awaitDuration) throws Exception{
- Future<Object> future =
- ask(actor, message, new Timeout(askDuration));
-
- return Await.result(future, awaitDuration);
- }
+ public static final FiniteDuration LOCAL_ASK_DURATION = Duration.create(2, TimeUnit.SECONDS);
+ public static final FiniteDuration REMOTE_ASK_DURATION = Duration.create(15, TimeUnit.SECONDS);
+ public static final FiniteDuration ASK_DURATION = Duration.create(17, TimeUnit.SECONDS);
+ public static final FiniteDuration LOCAL_AWAIT_DURATION = Duration.create(2, TimeUnit.SECONDS);
+ public static final FiniteDuration REMOTE_AWAIT_DURATION = Duration.create(15, TimeUnit.SECONDS);
+ public static final FiniteDuration AWAIT_DURATION = Duration.create(17, TimeUnit.SECONDS);
+ public static final FiniteDuration GOSSIP_TICK_INTERVAL = Duration.create(500, TimeUnit.MILLISECONDS);
+ public static final String MAILBOX = "bounded-mailbox";
+
+
+ /**
+ * Executes an operation on a local actor and wait for it's response
+ *
+ * @param actor
+ * @param message
+ * @param askDuration
+ * @param awaitDuration
+ * @return The response of the operation
+ */
+ public static Object executeOperation(ActorRef actor, Object message,
+ FiniteDuration askDuration, FiniteDuration awaitDuration) throws Exception {
+ Future<Object> future =
+ ask(actor, message, new Timeout(askDuration));
+
+ return Await.result(future, awaitDuration);
+ }
}
}
odl-cluster-rpc {
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 100ms
+ }
+
akka {
actor {
provider = "akka.cluster.ClusterActorRefProvider"
-
}
remote {
log-remote-lifecycle-events = off
import akka.actor.ActorSystem;
import akka.testkit.JavaTestKit;
import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.sal.core.api.Broker;
import scala.concurrent.Await;
import scala.concurrent.duration.Duration;
-
import java.util.concurrent.TimeUnit;
import static org.mockito.Mockito.mock;
@BeforeClass
public static void setup() throws InterruptedException {
- system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster"));
+ system = ActorSystem.create("odl-cluster-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
}
@AfterClass
Duration.create(2, TimeUnit.SECONDS));
Assert.assertTrue(actorRef.path().toString().contains(ActorConstants.RPC_MANAGER_PATH));
}
-
-
-
}
@BeforeClass
public static void setup() throws InterruptedException {
- system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster"));
+ system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
}
@AfterClass
@BeforeClass
public static void setup() throws InterruptedException {
- system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster"));
+ system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
}
@AfterClass
import akka.testkit.JavaTestKit;
import com.google.common.base.Predicate;
import com.typesafe.config.ConfigFactory;
-
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.sal.connector.api.RpcRouter;
import org.opendaylight.controller.utils.ConditionalProbe;
import org.opendaylight.yangtools.yang.common.QName;
-import scala.concurrent.Await;
-import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;
import javax.annotation.Nullable;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes;
+import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
public class RpcRegistryTest {
*/
@Test
public void testAddRemoveRpcOnSameNode() throws URISyntaxException, InterruptedException {
- validateSystemStartup();
final JavaTestKit mockBroker = new JavaTestKit(node1);
@Test
public void testRpcAddRemoveInCluster() throws URISyntaxException, InterruptedException {
- validateSystemStartup();
-
final JavaTestKit mockBroker1 = new JavaTestKit(node1);
//install probe on node2's bucket store
final JavaTestKit probe2 = createProbeForMessage(
node2, bucketStorePath, Messages.BucketStoreMessages.UpdateRemoteBuckets.class);
-
//Add rpc on node 1
registry1.tell(new SetLocalRouter(mockBroker1.getRef()), mockBroker1.getRef());
registry1.tell(getAddRouteMessage(), mockBroker1.getRef());
@Test
public void testRpcAddedOnMultiNodes() throws Exception {
- validateSystemStartup();
-
final JavaTestKit mockBroker1 = new JavaTestKit(node1);
final JavaTestKit mockBroker2 = new JavaTestKit(node2);
final JavaTestKit mockBroker3 = new JavaTestKit(node3);
}
- private void validateSystemStartup() throws InterruptedException {
-
- ActorPath gossiper1Path = new ChildActorPath(new ChildActorPath(registry1.path(), "store"), "gossiper");
- ActorPath gossiper2Path = new ChildActorPath(new ChildActorPath(registry2.path(), "store"), "gossiper");
- ActorPath gossiper3Path = new ChildActorPath(new ChildActorPath(registry3.path(), "store"), "gossiper");
-
- ActorSelection gossiper1 = node1.actorSelection(gossiper1Path);
- ActorSelection gossiper2 = node2.actorSelection(gossiper2Path);
- ActorSelection gossiper3 = node3.actorSelection(gossiper3Path);
-
-
- if (!resolveReference(gossiper1, gossiper2, gossiper3))
- Assert.fail("Could not find gossipers");
- }
-
- private Boolean resolveReference(ActorSelection... gossipers) {
-
- Boolean resolved = true;
- for (int i = 0; i < 5; i++) {
-
- resolved = true;
- System.out.println(System.currentTimeMillis() + " Resolving gossipers; trial #" + i);
-
- for (ActorSelection gossiper : gossipers) {
- ActorRef ref = null;
-
- try {
- Future<ActorRef> future = gossiper.resolveOne(new FiniteDuration(15000, TimeUnit.MILLISECONDS));
- ref = Await.result(future, new FiniteDuration(10000, TimeUnit.MILLISECONDS));
- } catch (Exception e) {
- System.out.println("Could not find gossiper in attempt#" + i + ". Got exception " + e.getMessage());
- }
-
- if (ref == null)
- resolved = false;
- }
-
- if (resolved) break;
-
- }
- return resolved;
- }
-
private AddOrUpdateRoutes getAddRouteMessage() throws URISyntaxException {
return new AddOrUpdateRoutes(createRouteIds());
}
@BeforeClass
public static void setup() throws InterruptedException {
- system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster"));
+ system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
}
@AfterClass
-odl-cluster{
+odl-cluster-rpc{
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 10ms
+ }
+
akka {
- loglevel = "DEBUG"
+ loglevel = "INFO"
#log-config-on-start = on
actor {
loglevel = "INFO"
#loggers = ["akka.event.slf4j.Slf4jLogger"]
}
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 10ms
+ }
}
memberA{
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 10ms
+ }
akka {
loglevel = "INFO"
- loggers = ["akka.event.slf4j.Slf4jLogger"]
+ #loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = "akka.cluster.ClusterActorRefProvider"
debug {
}
}
memberB{
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 10ms
+ }
akka {
loglevel = "INFO"
- loggers = ["akka.event.slf4j.Slf4jLogger"]
+ #loggers = ["akka.event.slf4j.Slf4jLogger"]
+
actor {
provider = "akka.cluster.ClusterActorRefProvider"
+ debug {
+ #lifecycle = on
+ }
}
remote {
log-received-messages = off
}
}
memberC{
+ bounded-mailbox {
+ mailbox-type = "org.opendaylight.controller.common.actor.MeteredBoundedMailbox"
+ mailbox-capacity = 1000
+ mailbox-push-timeout-time = 10ms
+ }
akka {
loglevel = "INFO"
- loggers = ["akka.event.slf4j.Slf4jLogger"]
+ #loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = "akka.cluster.ClusterActorRefProvider"
+ debug {
+ #lifecycle = on
+ }
}
remote {
log-received-messages = off
auto-down-unreachable-after = 10s
}
}
-}
\ No newline at end of file
+}
+
<artifactId>jaxrs-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-core-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-composite-node</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-codec-gson</artifactId>
+ </dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-composite-node</artifactId>
- <version>0.6.2-SNAPSHOT</version>
- </dependency>
</dependencies>
<build>
--- /dev/null
+package org.opendaylight.controller.sal.rest.api;
+
+public interface RestconfConstants {
+
+
+ public static String IDENTIFIER = "identifier";
+}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.controller.sal.restconf.impl.StructuredData;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.Node;
+
/**
* The URI hierarchy for the RESTCONF resources consists of an entry point container, 4 top-level resources, and 1
* field.
@Path("/config/{identifier:.+}")
@Produces({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML, MediaType.TEXT_XML })
- public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier,
+ public NormalizedNodeContext readConfigurationData(@Encoded @PathParam("identifier") String identifier,
@Context UriInfo uriInfo);
@GET
@Path("/operational/{identifier:.+}")
@Produces({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML, MediaType.TEXT_XML })
- public StructuredData readOperationalData(@Encoded @PathParam("identifier") String identifier,
+ public NormalizedNodeContext readOperationalData(@Encoded @PathParam("identifier") String identifier,
@Context UriInfo uriInfo);
@PUT
--- /dev/null
+package org.opendaylight.controller.sal.rest.impl;
+
+import com.google.common.base.Optional;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+import org.opendaylight.controller.sal.rest.api.RestconfConstants;
+import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
+
+public class AbstractIdentifierAwareJaxRsProvider {
+
+ @Context
+ private UriInfo uriInfo;
+
+ protected final String getIdentifier() {
+ return uriInfo.getPathParameters().getFirst(RestconfConstants.IDENTIFIER);
+ }
+
+ protected final Optional<InstanceIdentifierContext> getIdentifierWithSchema() {
+ return Optional.of(getInstanceIdentifierContext());
+ }
+
+ protected InstanceIdentifierContext getInstanceIdentifierContext() {
+ return ControllerContext.getInstance().toInstanceIdentifier(getIdentifier());
+ }
+
+ protected UriInfo getUriInfo() {
+ return uriInfo;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.sal.rest.impl;
+
+import com.google.common.base.Optional;
+import com.google.gson.stream.JsonReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+import org.opendaylight.controller.sal.rest.api.Draft02;
+import org.opendaylight.controller.sal.rest.api.RestconfService;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
+import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+@Consumes({ Draft02.MediaTypes.DATA + RestconfService.JSON, Draft02.MediaTypes.OPERATION + RestconfService.JSON,
+ MediaType.APPLICATION_JSON })
+public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader<NormalizedNodeContext> {
+
+ private final static Logger LOG = LoggerFactory.getLogger(JsonNormalizedNodeBodyReader.class);
+
+ @Override
+ public boolean isReadable(final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType) {
+ return true;
+ }
+
+ @Override
+ public NormalizedNodeContext readFrom(final Class<NormalizedNodeContext> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType,
+ final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException,
+ WebApplicationException {
+ try {
+ Optional<InstanceIdentifierContext> path = getIdentifierWithSchema();
+ NormalizedNodeResult resultHolder = new NormalizedNodeResult();
+ NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
+ JsonParserStream jsonParser = JsonParserStream.create(writer, path.get().getSchemaContext());
+ JsonReader reader = new JsonReader(new InputStreamReader(entityStream));
+ jsonParser.parse(reader);
+ return new NormalizedNodeContext(path.get(),resultHolder.getResult());
+ } catch (Exception e) {
+ LOG.debug("Error parsing json input", e);
+
+ throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
+ ErrorTag.MALFORMED_MESSAGE);
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.sal.rest.impl;
+
+import com.google.common.base.Charsets;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.util.Iterator;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import org.opendaylight.controller.sal.rest.api.Draft02;
+import org.opendaylight.controller.sal.rest.api.RestconfService;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+@Provider
+@Produces({ Draft02.MediaTypes.API + RestconfService.JSON, Draft02.MediaTypes.DATA + RestconfService.JSON,
+ Draft02.MediaTypes.OPERATION + RestconfService.JSON, MediaType.APPLICATION_JSON })
+public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<NormalizedNodeContext> {
+
+ @Override
+ public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) {
+ return type.equals(NormalizedNodeContext.class);
+ }
+
+ @Override
+ public long getSize(final NormalizedNodeContext t, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(final NormalizedNodeContext t, final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
+ throws IOException, WebApplicationException {
+ NormalizedNode<?, ?> data = t.getData();
+ InstanceIdentifierContext context = t.getInstanceIdentifierContext();
+ DataSchemaNode schema = context.getSchemaNode();
+ SchemaPath path = context.getSchemaNode().getPath();
+ OutputStreamWriter outputWriter = new OutputStreamWriter(entityStream, Charsets.UTF_8);
+ if (data == null) {
+ throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
+ }
+
+ boolean isDataRoot = false;
+ URI initialNs = null;
+ outputWriter.write('{');
+ if (SchemaPath.ROOT.equals(path)) {
+ isDataRoot = true;
+ } else {
+ path = path.getParent();
+ // FIXME: Add proper handling of reading root.
+ }
+ if(!schema.isAugmenting() && !(schema instanceof SchemaContext)) {
+ initialNs = schema.getQName().getNamespace();
+ }
+ NormalizedNodeStreamWriter jsonWriter = JSONNormalizedNodeStreamWriter.create(context.getSchemaContext(),path,initialNs,outputWriter);
+ NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(jsonWriter);
+ if(isDataRoot) {
+ writeDataRoot(outputWriter,nnWriter,(ContainerNode) data);
+ } else {
+ if(data instanceof MapEntryNode) {
+ data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild(((MapEntryNode) data)).build();
+ }
+ nnWriter.write(data);
+ }
+ nnWriter.flush();
+ outputWriter.write('}');
+ outputWriter.flush();
+ }
+
+ private void writeDataRoot(OutputStreamWriter outputWriter, NormalizedNodeWriter nnWriter, ContainerNode data) throws IOException {
+ Iterator<DataContainerChild<? extends PathArgument, ?>> iterator = data.getValue().iterator();
+ while(iterator.hasNext()) {
+ DataContainerChild<? extends PathArgument, ?> child = iterator.next();
+ nnWriter.write(child);
+ nnWriter.flush();
+ if(iterator.hasNext()) {
+ outputWriter.write(",");
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.sal.rest.impl;
+
+import com.google.common.base.Throwables;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.opendaylight.controller.sal.rest.api.Draft02;
+import org.opendaylight.controller.sal.rest.api.RestconfService;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
+import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+@Provider
+@Produces({ Draft02.MediaTypes.API + RestconfService.XML, Draft02.MediaTypes.DATA + RestconfService.XML,
+ Draft02.MediaTypes.OPERATION + RestconfService.XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter<NormalizedNodeContext> {
+
+ private static final XMLOutputFactory XML_FACTORY;
+
+ static {
+ XML_FACTORY = XMLOutputFactory.newFactory();
+ XML_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
+ }
+
+ @Override
+ public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType) {
+ return type.equals(NormalizedNodeContext.class);
+ }
+
+ @Override
+ public long getSize(final NormalizedNodeContext t, final Class<?> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(final NormalizedNodeContext t, final Class<?> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType,
+ final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
+ WebApplicationException {
+ InstanceIdentifierContext pathContext = t.getInstanceIdentifierContext();
+ if (t.getData() == null) {
+ throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
+ }
+
+ XMLStreamWriter xmlWriter;
+ try {
+ xmlWriter = XML_FACTORY.createXMLStreamWriter(entityStream);
+ } catch (XMLStreamException e) {
+ throw new IllegalStateException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new IllegalStateException(e);
+ }
+ NormalizedNode<?, ?> data = t.getData();
+ SchemaPath schemaPath = pathContext.getSchemaNode().getPath();
+
+ boolean isDataRoot = false;
+ if (SchemaPath.ROOT.equals(schemaPath)) {
+ isDataRoot = true;
+ } else {
+ schemaPath = schemaPath.getParent();
+ }
+
+ NormalizedNodeStreamWriter jsonWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter,
+ pathContext.getSchemaContext(), schemaPath);
+ NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(jsonWriter);
+ if (isDataRoot) {
+ writeRootElement(xmlWriter, nnWriter, (ContainerNode) data);
+ } else {
+ if (data instanceof MapEntryNode) {
+ // Restconf allows returning one list item. We need to wrap it
+ // in map node in order to serialize it properly
+ data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build();
+ }
+ nnWriter.write(data);
+ nnWriter.flush();
+ }
+ }
+
+ private void writeRootElement(XMLStreamWriter xmlWriter, NormalizedNodeWriter nnWriter, ContainerNode data)
+ throws IOException {
+ try {
+ QName name = SchemaContext.NAME;
+ xmlWriter.writeStartElement(name.getNamespace().toString(), name.getLocalName());
+ for (DataContainerChild<? extends PathArgument, ?> child : data.getValue()) {
+ nnWriter.write(child);
+ }
+ nnWriter.flush();
+ xmlWriter.writeEndElement();
+ xmlWriter.flush();
+ } catch (XMLStreamException e) {
+ Throwables.propagate(e);
+ }
+ }
+}
@Override
public Set<Class<?>> getClasses() {
- return ImmutableSet.<Class<?>> of(RestconfDocumentedExceptionMapper.class);
+ return ImmutableSet.<Class<?>> builder()
+ .add(RestconfDocumentedExceptionMapper.class)
+ .add(XmlNormalizedNodeBodyReader.class)
+ .add(JsonNormalizedNodeBodyReader.class)
+ .add(NormalizedNodeJsonBodyWriter.class)
+ .add(NormalizedNodeXmlBodyWriter.class)
+ .build();
}
@Override
singletons.add(controllerContext);
singletons.add(brokerFacade);
singletons.add(restconfImpl);
- singletons.add(XmlToCompositeNodeProvider.INSTANCE);
singletons.add(StructuredDataToXmlProvider.INSTANCE);
- singletons.add(JsonToCompositeNodeProvider.INSTANCE);
singletons.add(StructuredDataToJsonProvider.INSTANCE);
+ singletons.add(JsonToCompositeNodeProvider.INSTANCE);
+ singletons.add(XmlToCompositeNodeProvider.INSTANCE);
return singletons;
}
@Provider
@Produces({ Draft02.MediaTypes.API + RestconfService.JSON, Draft02.MediaTypes.DATA + RestconfService.JSON,
- Draft02.MediaTypes.OPERATION + RestconfService.JSON, MediaType.APPLICATION_JSON })
+ Draft02.MediaTypes.OPERATION + RestconfService.JSON, MediaType.APPLICATION_JSON })
public enum StructuredDataToJsonProvider implements MessageBodyWriter<StructuredData> {
INSTANCE;
@Override
- public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations,
- final MediaType mediaType) {
+ public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) {
return type.equals(StructuredData.class);
}
@Override
- public long getSize(final StructuredData t, final Class<?> type, final Type genericType,
- final Annotation[] annotations, final MediaType mediaType) {
+ public long getSize(final StructuredData t, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) {
return -1;
}
@Override
- public void writeTo(final StructuredData t, final Class<?> type, final Type genericType,
- final Annotation[] annotations, final MediaType mediaType,
- final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
- WebApplicationException {
+ public void writeTo(final StructuredData t, final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
+ throws IOException, WebApplicationException {
CompositeNode data = t.getData();
if (data == null) {
throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
--- /dev/null
+/*
+ * Copyright (c) 2014 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.sal.rest.impl;
+
+import com.google.common.base.Optional;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.List;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.opendaylight.controller.sal.rest.api.Draft02;
+import org.opendaylight.controller.sal.rest.api.RestconfService;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
+import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlUtils;
+import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+@Provider
+@Consumes({ Draft02.MediaTypes.DATA + RestconfService.XML, Draft02.MediaTypes.OPERATION + RestconfService.XML,
+ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader<NormalizedNodeContext> {
+
+ private final static Logger LOG = LoggerFactory.getLogger(XmlNormalizedNodeBodyReader.class);
+ private final static DomToNormalizedNodeParserFactory DOM_PARSER_FACTORY = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER);
+ private static final DocumentBuilderFactory BUILDERFACTORY;
+
+ static {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setCoalescing(true);
+ factory.setIgnoringElementContentWhitespace(true);
+ factory.setIgnoringComments(true);
+ BUILDERFACTORY = factory;
+ }
+
+ @Override
+ public boolean isReadable(final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType) {
+ return true;
+ }
+
+ @Override
+ public NormalizedNodeContext readFrom(final Class<NormalizedNodeContext> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType,
+ final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException,
+ WebApplicationException {
+ try {
+ Optional<InstanceIdentifierContext> path = getIdentifierWithSchema();
+
+ final DocumentBuilder dBuilder;
+ try {
+ dBuilder = BUILDERFACTORY.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException("Failed to parse XML document", e);
+ }
+ Document doc = dBuilder.parse(entityStream);
+
+ NormalizedNode<?, ?> result = parse(path.get(),doc);
+ return new NormalizedNodeContext(path.get(),result);
+ } catch (Exception e) {
+ LOG.debug("Error parsing json input", e);
+
+ throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
+ ErrorTag.MALFORMED_MESSAGE);
+ }
+ }
+
+ private static NormalizedNode<?,?> parse(InstanceIdentifierContext pathContext,Document doc) {
+ List<Element> elements = Collections.singletonList(doc.getDocumentElement());
+ DataSchemaNode schemaNode = pathContext.getSchemaNode();
+ if(schemaNode instanceof ContainerSchemaNode) {
+ return DOM_PARSER_FACTORY.getContainerNodeParser().parse(Collections.singletonList(doc.getDocumentElement()), (ContainerSchemaNode) schemaNode);
+ } else if(schemaNode instanceof ListSchemaNode) {
+ ListSchemaNode casted = (ListSchemaNode) schemaNode;
+ return DOM_PARSER_FACTORY.getMapEntryNodeParser().parse(elements, casted);
+ }
+ return null;
+ }
+}
+
import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
import org.opendaylight.yangtools.yang.data.api.Node;
+@Deprecated
public class XmlToCompositeNodeReader {
private final static XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
}
eventReader = xmlInputFactory.createXMLEventReader(entityStream);
-
if (eventReader.hasNext()) {
XMLEvent element = eventReader.peek();
if (element.isStartDocument()) {
return entityStream;
}
- private boolean isInputStreamEmpty(InputStream entityStream) throws IOException {
+ private boolean isInputStreamEmpty(final InputStream entityStream) throws IOException {
boolean isEmpty = false;
entityStream.mark(1);
if (entityStream.read() == -1) {
resolveValueOfElement(data, startElement));
}
- private String getValueOf(StartElement startElement) throws XMLStreamException {
+ private String getValueOf(final StartElement startElement) throws XMLStreamException {
String data = null;
if (eventReader.hasNext()) {
final XMLEvent innerEvent = eventReader.peek();
return data == null ? null : data.trim();
}
- private String getAdditionalData(XMLEvent event) throws XMLStreamException {
+ private String getAdditionalData(final XMLEvent event) throws XMLStreamException {
String data = "";
if (eventReader.hasNext()) {
final XMLEvent innerEvent = eventReader.peek();
return data;
}
- private String getLocalNameFor(StartElement startElement) {
+ private String getLocalNameFor(final StartElement startElement) {
return startElement.getName().getLocalPart();
}
- private URI getNamespaceFor(StartElement startElement) {
+ private URI getNamespaceFor(final StartElement startElement) {
String namespaceURI = startElement.getName().getNamespaceURI();
return namespaceURI.isEmpty() ? null : URI.create(namespaceURI);
}
- private Object resolveValueOfElement(String value, StartElement startElement) {
+ private Object resolveValueOfElement(final String value, final StartElement startElement) {
// it could be instance-identifier Built-In Type
if (value.startsWith("/")) {
IdentityValuesDTO iiValue = RestUtil.asInstanceIdentifier(value, new RestUtil.PrefixMapingFromXml(
+++ /dev/null
-/*
- * Copyright (c) 2014 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.sal.rest.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.Characters;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
-import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO;
-import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
-import org.opendaylight.controller.sal.restconf.impl.NodeWrapper;
-import org.opendaylight.controller.sal.restconf.impl.RestCodec;
-import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
-import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-
-public class XmlToNormalizedNodeReaderWithSchema {
-
- private final static XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
- private XMLEventReader eventReader;
- private InstanceIdWithSchemaNode iiWithSchema;
-
- public XmlToNormalizedNodeReaderWithSchema(final InstanceIdWithSchemaNode iiWithSchema) {
- this.iiWithSchema = iiWithSchema;
- }
-
- public Node<?> read(InputStream entityStream) throws XMLStreamException, UnsupportedFormatException, IOException {
- // Get an XML stream which can be marked, and reset, so we can check and see if there is
- // any content being provided.
- entityStream = getMarkableStream(entityStream);
-
- if (isInputStreamEmpty(entityStream)) {
- return null;
- }
-
- eventReader = xmlInputFactory.createXMLEventReader(entityStream);
- if (eventReader.hasNext()) {
- XMLEvent element = eventReader.peek();
- if (element.isStartDocument()) {
- eventReader.nextEvent();
- }
- }
-
- final Stack<NodeWrapper<?>> processingQueue = new Stack<>();
- NodeWrapper<?> root = null;
- NodeWrapper<?> element = null;
- Stack<DataSchemaNode> processingQueueSchema = new Stack<>();
-
- while (eventReader.hasNext()) {
- final XMLEvent event = eventReader.nextEvent();
-
- if (event.isStartElement()) {
- final StartElement startElement = event.asStartElement();
- CompositeNodeWrapper compParentNode = null;
- if (!processingQueue.isEmpty() && processingQueue.peek() instanceof CompositeNodeWrapper) {
- compParentNode = (CompositeNodeWrapper) processingQueue.peek();
- findSchemaNodeForElement(startElement, processingQueueSchema);
- } else {
- processingQueueSchema = checkElementAndSchemaNodeNameAndNamespace(startElement,
- iiWithSchema.getSchemaNode());
- DataSchemaNode currentSchemaNode = processingQueueSchema.peek();
- if (!(currentSchemaNode instanceof ListSchemaNode)
- && !(currentSchemaNode instanceof ContainerSchemaNode)) {
- throw new UnsupportedFormatException(
- "Top level element has to be of type list or container schema node.");
- }
- }
-
- NodeWrapper<?> newNode = null;
- if (isCompositeNodeEvent(event)) {
- newNode = resolveCompositeNodeFromStartElement(processingQueueSchema.peek().getQName());
- if (root == null) {
- root = newNode;
- }
- } else if (isSimpleNodeEvent(event)) {
- newNode = resolveSimpleNodeFromStartElement(processingQueueSchema.peek(), getValueOf(startElement));
- if (root == null) {
- root = newNode;
- }
- }
-
- if (newNode != null) {
- processingQueue.push(newNode);
- if (compParentNode != null) {
- compParentNode.addValue(newNode);
- }
- }
- } else if (event.isEndElement()) {
- element = processingQueue.pop();
-// if(((EndElement)event).getName().getLocalPart().equals
- processingQueueSchema.pop();
- }
- }
-
- if (!root.getLocalName().equals(element.getLocalName())) {
- throw new UnsupportedFormatException("XML should contain only one root element");
- }
-
- return root.unwrap();
- }
-
- private void findSchemaNodeForElement(StartElement element, Stack<DataSchemaNode> processingQueueSchema) {
- DataSchemaNode currentSchemaNode = processingQueueSchema.peek();
- if (currentSchemaNode instanceof DataNodeContainer) {
- final URI realNamespace = getNamespaceFor(element);
- final String realName = getLocalNameFor(element);
- Map<URI, DataSchemaNode> childNamesakes = resolveChildsWithNameAsElement(
- ((DataNodeContainer) currentSchemaNode), realName);
- DataSchemaNode childDataSchemaNode = childNamesakes.get(realNamespace);
- if (childDataSchemaNode == null) {
- throw new RestconfDocumentedException("Element " + realName + " has namespace " + realNamespace
- + ". Available namespaces are: " + childNamesakes.keySet(), ErrorType.APPLICATION,
- ErrorTag.INVALID_VALUE);
- }
- processingQueueSchema.push(childDataSchemaNode);
- } else {
- throw new RestconfDocumentedException("Element " + processingQueueSchema.peek().getQName().getLocalName()
- + " should be data node container .", ErrorType.APPLICATION, ErrorTag.INVALID_VALUE);
- }
-
- }
-
- /**
- * Returns map of data schema node which are accesible by URI which have equal name
- */
- private Map<URI, DataSchemaNode> resolveChildsWithNameAsElement(final DataNodeContainer dataNodeContainer,
- final String realName) {
- final Map<URI, DataSchemaNode> namespaceToDataSchemaNode = new HashMap<URI, DataSchemaNode>();
- for (DataSchemaNode dataSchemaNode : dataNodeContainer.getChildNodes()) {
- if (dataSchemaNode.equals(realName)) {
- namespaceToDataSchemaNode.put(dataSchemaNode.getQName().getNamespace(), dataSchemaNode);
- }
- }
- return namespaceToDataSchemaNode;
- }
-
- private final Stack<DataSchemaNode> checkElementAndSchemaNodeNameAndNamespace(final StartElement startElement,
- final DataSchemaNode node) {
- checkArgument(startElement != null, "Start Element cannot be NULL!");
- final String expectedName = node.getQName().getLocalName();
- final String xmlName = getLocalNameFor(startElement);
- final URI expectedNamespace = node.getQName().getNamespace();
- final URI xmlNamespace = getNamespaceFor(startElement);
- if (!expectedName.equals(xmlName)) {
- throw new RestconfDocumentedException("Xml element name: " + xmlName + "\nSchema node name: "
- + expectedName, org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType.APPLICATION,
- ErrorTag.INVALID_VALUE);
- }
-
- if (xmlNamespace != null && !expectedNamespace.equals(xmlNamespace)) {
- throw new RestconfDocumentedException("Xml element ns: " + xmlNamespace + "\nSchema node ns: "
- + expectedNamespace,
- org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType.APPLICATION,
- ErrorTag.INVALID_VALUE);
- }
- Stack<DataSchemaNode> processingQueueSchema = new Stack<>();
- processingQueueSchema.push(node);
- return processingQueueSchema;
- }
-
- /**
- * If the input stream is not markable, then it wraps the input stream with a buffered stream, which is mark able.
- * That way we can check if the stream is empty safely.
- *
- * @param entityStream
- * @return
- */
- private InputStream getMarkableStream(InputStream entityStream) {
- if (!entityStream.markSupported()) {
- entityStream = new BufferedInputStream(entityStream);
- }
- return entityStream;
- }
-
- private boolean isInputStreamEmpty(final InputStream entityStream) throws IOException {
- boolean isEmpty = false;
- entityStream.mark(1);
- if (entityStream.read() == -1) {
- isEmpty = true;
- }
- entityStream.reset();
- return isEmpty;
- }
-
- private boolean isSimpleNodeEvent(final XMLEvent event) throws XMLStreamException {
- checkArgument(event != null, "XML Event cannot be NULL!");
- if (event.isStartElement()) {
- XMLEvent innerEvent = skipCommentsAndWhitespace();
- if (innerEvent != null && (innerEvent.isCharacters() || innerEvent.isEndElement())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isCompositeNodeEvent(final XMLEvent event) throws XMLStreamException {
- checkArgument(event != null, "XML Event cannot be NULL!");
- if (event.isStartElement()) {
- XMLEvent innerEvent = skipCommentsAndWhitespace();
- if (innerEvent != null) {
- if (innerEvent.isStartElement()) {
- return true;
- }
- }
- }
- return false;
- }
-
- private XMLEvent skipCommentsAndWhitespace() throws XMLStreamException {
- while (eventReader.hasNext()) {
- XMLEvent event = eventReader.peek();
- if (event.getEventType() == XMLStreamConstants.COMMENT) {
- eventReader.nextEvent();
- continue;
- }
-
- if (event.isCharacters()) {
- Characters chars = event.asCharacters();
- if (chars.isWhiteSpace()) {
- eventReader.nextEvent();
- continue;
- }
- }
- return event;
- }
- return null;
- }
-
- private CompositeNodeWrapper resolveCompositeNodeFromStartElement(final QName qName) {
- // checkArgument(startElement != null, "Start Element cannot be NULL!");
- CompositeNodeWrapper compositeNodeWrapper = new CompositeNodeWrapper("dummy");
- compositeNodeWrapper.setQname(qName);
- return compositeNodeWrapper;
-
- }
-
- private SimpleNodeWrapper resolveSimpleNodeFromStartElement(final DataSchemaNode node, final String value)
- throws XMLStreamException {
- // checkArgument(startElement != null, "Start Element cannot be NULL!");
- Object deserializedValue = null;
-
- if (node instanceof LeafSchemaNode) {
- TypeDefinition<?> baseType = RestUtil.resolveBaseTypeFrom(((LeafSchemaNode) node).getType());
- deserializedValue = RestCodec.from(baseType, iiWithSchema.getMountPoint()).deserialize(value);
- } else if (node instanceof LeafListSchemaNode) {
- TypeDefinition<?> baseType = RestUtil.resolveBaseTypeFrom(((LeafListSchemaNode) node).getType());
- deserializedValue = RestCodec.from(baseType, iiWithSchema.getMountPoint()).deserialize(value);
- }
- // String data;
- // if (data == null) {
- // return new EmptyNodeWrapper(getNamespaceFor(startElement), getLocalNameFor(startElement));
- // }
- SimpleNodeWrapper simpleNodeWrapper = new SimpleNodeWrapper("dummy", deserializedValue);
- simpleNodeWrapper.setQname(node.getQName());
- return simpleNodeWrapper;
- }
-
- private String getValueOf(final StartElement startElement) throws XMLStreamException {
- String data = null;
- if (eventReader.hasNext()) {
- final XMLEvent innerEvent = eventReader.peek();
- if (innerEvent.isCharacters()) {
- final Characters chars = innerEvent.asCharacters();
- if (!chars.isWhiteSpace()) {
- data = innerEvent.asCharacters().getData();
- data = data + getAdditionalData(eventReader.nextEvent());
- }
- } else if (innerEvent.isEndElement()) {
- if (startElement.getLocation().getCharacterOffset() == innerEvent.getLocation().getCharacterOffset()) {
- data = null;
- } else {
- data = "";
- }
- }
- }
- return data == null ? null : data.trim();
- }
-
- private String getAdditionalData(final XMLEvent event) throws XMLStreamException {
- String data = "";
- if (eventReader.hasNext()) {
- final XMLEvent innerEvent = eventReader.peek();
- if (innerEvent.isCharacters() && !innerEvent.isEndElement()) {
- final Characters chars = innerEvent.asCharacters();
- if (!chars.isWhiteSpace()) {
- data = innerEvent.asCharacters().getData();
- data = data + getAdditionalData(eventReader.nextEvent());
- }
- }
- }
- return data;
- }
-
- private String getLocalNameFor(final StartElement startElement) {
- return startElement.getName().getLocalPart();
- }
-
- private URI getNamespaceFor(final StartElement startElement) {
- String namespaceURI = startElement.getName().getNamespaceURI();
- return namespaceURI.isEmpty() ? null : URI.create(namespaceURI);
- }
-
- private Object resolveValueOfElement(final String value, final StartElement startElement) {
- // it could be instance-identifier Built-In Type
- if (value.startsWith("/")) {
- IdentityValuesDTO iiValue = RestUtil.asInstanceIdentifier(value, new RestUtil.PrefixMapingFromXml(
- startElement));
- if (iiValue != null) {
- return iiValue;
- }
- }
- // it could be identityref Built-In Type
- String[] namespaceAndValue = value.split(":");
- if (namespaceAndValue.length == 2) {
- String namespace = startElement.getNamespaceContext().getNamespaceURI(namespaceAndValue[0]);
- if (namespace != null && !namespace.isEmpty()) {
- return new IdentityValuesDTO(namespace, namespaceAndValue[1], namespaceAndValue[0], value);
- }
- }
- // it is not "prefix:value" but just "value"
- return value;
- }
-
-}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
private NormalizedNode<?, ?> readDataViaTransaction(final DOMDataReadTransaction transaction,
LogicalDatastoreType datastore, YangInstanceIdentifier path) {
LOG.trace("Read " + datastore.name() + " via Restconf: {}", path);
- final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> listenableFuture =
- transaction.read(datastore, path);
+ final ListenableFuture<Optional<NormalizedNode<?, ?>>> listenableFuture = transaction.read(datastore, path);
+ if (listenableFuture != null) {
+ Optional<NormalizedNode<?, ?>> optional;
+ try {
+ LOG.debug("Reading result data from transaction.");
+ optional = listenableFuture.get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RestconfDocumentedException("Problem to get data from transaction.", e.getCause());
- try {
- Optional<NormalizedNode<?, ?>> optional = listenableFuture.checkedGet();
- return optional.isPresent() ? optional.get() : null;
- } catch(ReadFailedException e) {
- throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList());
+ }
+ if (optional != null) {
+ if (optional.isPresent()) {
+ return optional.get();
+ }
+ }
}
+ return null;
}
private CheckedFuture<Void, TransactionCommitFailedException> postDataViaTransaction(
final DOMDataReadWriteTransaction rWTransaction, final LogicalDatastoreType datastore,
final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload, DataNormalizationOperation<?> root) {
- CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> futureDatastoreData =
- rWTransaction.read(datastore, path);
+ ListenableFuture<Optional<NormalizedNode<?, ?>>> futureDatastoreData = rWTransaction.read(datastore, path);
try {
- final Optional<NormalizedNode<?, ?>> optionalDatastoreData = futureDatastoreData.checkedGet();
+ final Optional<NormalizedNode<?, ?>> optionalDatastoreData = futureDatastoreData.get();
if (optionalDatastoreData.isPresent() && payload.equals(optionalDatastoreData.get())) {
- LOG.trace("Post Configuration via Restconf was not executed because data already exists :{}", path);
+ String errMsg = "Post Configuration via Restconf was not executed because data already exists";
+ LOG.trace(errMsg + ":{}", path);
throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL,
ErrorTag.DATA_EXISTS);
}
- } catch(ReadFailedException e) {
- LOG.warn("Error reading from datastore with path: " + path, e);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.trace("It wasn't possible to get data loaded from datastore at path " + path);
}
ensureParentsByMerge(datastore, path, rWTransaction, root);
try {
currentOp = currentOp.getChild(currentArg);
} catch (DataNormalizationException e) {
- throw new RestconfDocumentedException(
- String.format("Error normalizing data for path %s", normalizedPath), e);
+ throw new IllegalArgumentException(
+ String.format("Invalid child encountered in path %s", normalizedPath), e);
}
currentArguments.add(currentArg);
YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(currentArguments);
+ final Boolean exists;
+
try {
- boolean exists = rwTx.exists(store, currentPath).checkedGet();
- if (!exists && iterator.hasNext()) {
- rwTx.merge(store, currentPath, currentOp.createDefault(currentArg));
- }
+ CheckedFuture<Boolean, ReadFailedException> future =
+ rwTx.exists(store, currentPath);
+ exists = future.checkedGet();
} catch (ReadFailedException e) {
LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
- throw new RestconfDocumentedException("Failed to read pre-existing data", e);
+ throw new IllegalStateException("Failed to read pre-existing data", e);
+ }
+
+
+ if (!exists && iterator.hasNext()) {
+ rwTx.merge(store, currentPath, currentOp.createDefault(currentArg));
}
}
}
this.onGlobalContextUpdated(schemas);
}
- public InstanceIdWithSchemaNode toInstanceIdentifier(final String restconfInstance) {
+ public InstanceIdentifierContext toInstanceIdentifier(final String restconfInstance) {
return this.toIdentifier(restconfInstance, false);
}
- public InstanceIdWithSchemaNode toMountPointIdentifier(final String restconfInstance) {
+ public SchemaContext getGlobalSchema() {
+ return globalSchema;
+ }
+
+ public InstanceIdentifierContext toMountPointIdentifier(final String restconfInstance) {
return this.toIdentifier(restconfInstance, true);
}
- private InstanceIdWithSchemaNode toIdentifier(final String restconfInstance, final boolean toMountPointIdentifier) {
+ private InstanceIdentifierContext toIdentifier(final String restconfInstance, final boolean toMountPointIdentifier) {
this.checkPreconditions();
final List<String> pathArgs = urlPathArgsDecode(SLASH_SPLITTER.split(restconfInstance));
InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder();
Module latestModule = globalSchema.findModuleByName(startModule, null);
- InstanceIdWithSchemaNode iiWithSchemaNode = this.collectPathArguments(builder, pathArgs, latestModule, null,
+ InstanceIdentifierContext iiWithSchemaNode = this.collectPathArguments(builder, pathArgs, latestModule, null,
toMountPointIdentifier);
if (iiWithSchemaNode == null) {
return object == null ? "" : URLEncoder.encode(object.toString(), ControllerContext.URI_ENCODING_CHAR_SET);
}
- private InstanceIdWithSchemaNode collectPathArguments(final InstanceIdentifierBuilder builder,
+ private InstanceIdentifierContext collectPathArguments(final InstanceIdentifierBuilder builder,
final List<String> strings, final DataNodeContainer parentNode, final DOMMountPoint mountPoint,
final boolean returnJustMountPoint) {
Preconditions.<List<String>> checkNotNull(strings);
}
if (strings.isEmpty()) {
- return new InstanceIdWithSchemaNode(builder.toInstance(), ((DataSchemaNode) parentNode), mountPoint);
+ return new InstanceIdentifierContext(builder.toInstance(), ((DataSchemaNode) parentNode), mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
}
String head = strings.iterator().next();
if (returnJustMountPoint) {
YangInstanceIdentifier instance = YangInstanceIdentifier.builder().toInstance();
- return new InstanceIdWithSchemaNode(instance, mountPointSchema, mount);
+ return new InstanceIdentifierContext(instance, mountPointSchema, mount,mountPointSchema);
}
if (strings.size() == 1) {
YangInstanceIdentifier instance = YangInstanceIdentifier.builder().toInstance();
- return new InstanceIdWithSchemaNode(instance, mountPointSchema, mount);
+ return new InstanceIdentifierContext(instance, mountPointSchema, mount,mountPointSchema);
}
final String moduleNameBehindMountPoint = toModuleName(strings.get(1));
returnJustMountPoint);
}
- return new InstanceIdWithSchemaNode(builder.toInstance(), targetNode, mountPoint);
+ return new InstanceIdentifierContext(builder.toInstance(), targetNode, mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
}
public static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container, final String name,
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class InstanceIdWithSchemaNode {
+public class InstanceIdentifierContext {
private final YangInstanceIdentifier instanceIdentifier;
private final DataSchemaNode schemaNode;
private final DOMMountPoint mountPoint;
+ private final SchemaContext schemaContext;
- public InstanceIdWithSchemaNode(YangInstanceIdentifier instanceIdentifier, DataSchemaNode schemaNode,
- DOMMountPoint mountPoint) {
+ public InstanceIdentifierContext(YangInstanceIdentifier instanceIdentifier, DataSchemaNode schemaNode,
+ DOMMountPoint mountPoint,SchemaContext context) {
this.instanceIdentifier = instanceIdentifier;
this.schemaNode = schemaNode;
this.mountPoint = mountPoint;
+ this.schemaContext = context;
}
public YangInstanceIdentifier getInstanceIdentifier() {
return mountPoint;
}
+ public SchemaContext getSchemaContext() {
+ return schemaContext;
+ }
+
}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.sal.restconf.impl;
+
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MixinNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+
+class NormalizedDataPrunner {
+
+ public DataContainerChild<?, ?> pruneDataAtDepth(final DataContainerChild<?, ?> node, final Integer depth) {
+ if (depth == null) {
+ return node;
+ }
+
+ if (node instanceof LeafNode || node instanceof LeafSetNode || node instanceof AnyXmlNode
+ || node instanceof OrderedLeafSetNode) {
+ return node;
+ } else if (node instanceof MixinNode) {
+ return processMixinNode(node, depth);
+ } else if (node instanceof DataContainerNode) {
+ return processContainerNode(node, depth);
+ }
+ throw new IllegalStateException("Unexpected Mixin node occured why pruning data to requested depth");
+ }
+
+ private DataContainerChild<?, ?> processMixinNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ if (node instanceof AugmentationNode) {
+ return processAugmentationNode(node, depth);
+ } else if (node instanceof ChoiceNode) {
+ return processChoiceNode(node, depth);
+ } else if (node instanceof OrderedMapNode) {
+ return processOrderedMapNode(node, depth);
+ } else if (node instanceof MapNode) {
+ return processMapNode(node, depth);
+ } else if (node instanceof UnkeyedListNode) {
+ return processUnkeyedListNode(node, depth);
+ }
+ throw new IllegalStateException("Unexpected Mixin node occured why pruning data to requested depth");
+ }
+
+ private DataContainerChild<?, ?> processContainerNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ final ContainerNode containerNode = (ContainerNode) node;
+ DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> newContainerBuilder = Builders.containerBuilder()
+ .withNodeIdentifier(containerNode.getIdentifier());
+ if (depth > 1) {
+ processDataContainerChild((DataContainerNode<?>) node, depth, newContainerBuilder);
+ }
+ return newContainerBuilder.build();
+ }
+
+ private DataContainerChild<?, ?> processChoiceNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ final ChoiceNode choiceNode = (ChoiceNode) node;
+ DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> newChoiceBuilder = Builders.choiceBuilder()
+ .withNodeIdentifier(choiceNode.getIdentifier());
+
+ processDataContainerChild((DataContainerNode<?>) node, depth, newChoiceBuilder);
+
+ return newChoiceBuilder.build();
+ }
+
+ private DataContainerChild<?, ?> processAugmentationNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ final AugmentationNode augmentationNode = (AugmentationNode) node;
+ DataContainerNodeBuilder<AugmentationIdentifier, ? extends DataContainerChild<?, ?>> newAugmentationBuilder = Builders
+ .augmentationBuilder().withNodeIdentifier(augmentationNode.getIdentifier());
+
+ processDataContainerChild((DataContainerNode<?>) node, depth, newAugmentationBuilder);
+
+ return newAugmentationBuilder.build();
+ }
+
+ private void processDataContainerChild(
+ final DataContainerNode<?> node,
+ final Integer depth,
+ final DataContainerNodeBuilder<? extends YangInstanceIdentifier.PathArgument, ? extends DataContainerNode<?>> newBuilder) {
+
+ for (DataContainerChild<? extends PathArgument, ?> nodeValue : node.getValue()) {
+ newBuilder.withChild(pruneDataAtDepth(nodeValue, depth - 1));
+ }
+
+ }
+
+ private DataContainerChild<?, ?> processUnkeyedListNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> newUnkeyedListBuilder = Builders
+ .unkeyedListBuilder();
+ if (depth > 1) {
+ for (UnkeyedListEntryNode oldUnkeyedListEntry : ((UnkeyedListNode) node).getValue()) {
+ DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> newUnkeyedListEntry = Builders
+ .unkeyedListEntryBuilder().withNodeIdentifier(oldUnkeyedListEntry.getIdentifier());
+ for (DataContainerChild<? extends PathArgument, ?> oldUnkeyedListEntryValue : oldUnkeyedListEntry
+ .getValue()) {
+ newUnkeyedListEntry.withChild(pruneDataAtDepth(oldUnkeyedListEntryValue, depth - 1));
+ }
+ newUnkeyedListBuilder.addChild(newUnkeyedListEntry.build());
+ }
+ }
+ return newUnkeyedListBuilder.build();
+ }
+
+ private DataContainerChild<?, ?> processOrderedMapNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ CollectionNodeBuilder<MapEntryNode, OrderedMapNode> newOrderedMapNodeBuilder = Builders.orderedMapBuilder();
+ processMapEntries(node, depth, newOrderedMapNodeBuilder);
+ return newOrderedMapNodeBuilder.build();
+ }
+
+ private DataContainerChild<?, ?> processMapNode(final NormalizedNode<?, ?> node, final Integer depth) {
+ CollectionNodeBuilder<MapEntryNode, MapNode> newMapNodeBuilder = Builders.mapBuilder();
+ processMapEntries(node, depth, newMapNodeBuilder);
+ return newMapNodeBuilder.build();
+ }
+
+ private void processMapEntries(final NormalizedNode<?, ?> node, final Integer depth,
+ CollectionNodeBuilder<MapEntryNode, ? extends MapNode> newOrderedMapNodeBuilder) {
+ if (depth > 1) {
+ for (MapEntryNode oldMapEntryNode : ((MapNode) node).getValue()) {
+ DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> newMapEntryNodeBuilder = Builders
+ .mapEntryBuilder().withNodeIdentifier(oldMapEntryNode.getIdentifier());
+ for (DataContainerChild<? extends PathArgument, ?> mapEntryNodeValue : oldMapEntryNode.getValue()) {
+ newMapEntryNodeBuilder.withChild(pruneDataAtDepth(mapEntryNodeValue, depth - 1));
+ }
+ newOrderedMapNodeBuilder.withChild(newMapEntryNodeBuilder.build());
+ }
+ }
+ }
+
+
+}
--- /dev/null
+package org.opendaylight.controller.sal.restconf.impl;
+
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class NormalizedNodeContext {
+
+ private final InstanceIdentifierContext context;
+ private final NormalizedNode<?,?> data;
+
+ public NormalizedNodeContext(InstanceIdentifierContext context, NormalizedNode<?, ?> data) {
+ this.context = context;
+ this.data = data;
+ }
+
+ public InstanceIdentifierContext getInstanceIdentifierContext() {
+ return context;
+ }
+
+ public NormalizedNode<?, ?> getData() {
+ return data;
+ }
+}
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-
import java.net.URI;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
Set<Module> modules = null;
DOMMountPoint mountPoint = null;
if (identifier.contains(ControllerContext.MOUNT)) {
- InstanceIdWithSchemaNode mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier);
+ InstanceIdentifierContext mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointIdentifier.getMountPoint();
modules = this.controllerContext.getAllModules(mountPoint);
} else {
Module module = null;
DOMMountPoint mountPoint = null;
if (identifier.contains(ControllerContext.MOUNT)) {
- InstanceIdWithSchemaNode mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier);
+ InstanceIdentifierContext mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointIdentifier.getMountPoint();
module = this.controllerContext.findModuleByNameAndRevision(mountPoint, moduleNameAndRevision);
} else {
Set<Module> modules = null;
DOMMountPoint mountPoint = null;
if (identifier.contains(ControllerContext.MOUNT)) {
- InstanceIdWithSchemaNode mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier);
+ InstanceIdentifierContext mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointIdentifier.getMountPoint();
modules = this.controllerContext.getAllModules(mountPoint);
} else {
DOMMountPoint mountPoint = null;
if (identifier.contains(ControllerContext.MOUNT)) {
// mounted RPC call - look up mount instance.
- InstanceIdWithSchemaNode mountPointId = controllerContext.toMountPointIdentifier(identifier);
+ InstanceIdentifierContext mountPointId = controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointId.getMountPoint();
int startOfRemoteRpcName = identifier.lastIndexOf(ControllerContext.MOUNT)
}
@Override
- public StructuredData readConfigurationData(final String identifier, final UriInfo uriInfo) {
- final InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier(identifier);
+ public NormalizedNodeContext readConfigurationData(final String identifier, final UriInfo uriInfo) {
+ final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier);
DOMMountPoint mountPoint = iiWithData.getMountPoint();
NormalizedNode<?, ?> data = null;
YangInstanceIdentifier normalizedII;
normalizedII = controllerContext.toNormalized(iiWithData.getInstanceIdentifier());
data = broker.readConfigurationData(normalizedII);
}
-
- final CompositeNode compositeNode = datastoreNormalizedNodeToCompositeNode(data, iiWithData.getSchemaNode());
- final CompositeNode prunedCompositeNode = pruneDataAtDepth(compositeNode, parseDepthParameter(uriInfo));
-
- final boolean prettyPrintMode = parsePrettyPrintParameter(uriInfo);
- return new StructuredData(prunedCompositeNode, iiWithData.getSchemaNode(), mountPoint, prettyPrintMode);
+ return new NormalizedNodeContext(iiWithData, data);
}
@SuppressWarnings("unchecked")
}
@Override
- public StructuredData readOperationalData(final String identifier, final UriInfo info) {
- final InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier(identifier);
+ public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo info) {
+ final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier);
DOMMountPoint mountPoint = iiWithData.getMountPoint();
NormalizedNode<?, ?> data = null;
YangInstanceIdentifier normalizedII;
data = broker.readOperationalData(normalizedII);
}
- final CompositeNode compositeNode = datastoreNormalizedNodeToCompositeNode(data, iiWithData.getSchemaNode());
- final CompositeNode prunedCompositeNode = pruneDataAtDepth(compositeNode, parseDepthParameter(info));
-
- final boolean prettyPrintMode = parsePrettyPrintParameter(info);
- return new StructuredData(prunedCompositeNode, iiWithData.getSchemaNode(), mountPoint, prettyPrintMode);
+ return new NormalizedNodeContext(iiWithData, data);
}
private boolean parsePrettyPrintParameter(final UriInfo info) {
@Override
public Response updateConfigurationData(final String identifier, final Node<?> payload) {
- final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
+ final InstanceIdentifierContext iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
validateInput(iiWithData.getSchemaNode(), payload);
* if key values or key count in payload and URI isn't equal
*
*/
- private void validateListKeysEqualityInPayloadAndUri(final InstanceIdWithSchemaNode iiWithData,
+ private void validateListKeysEqualityInPayloadAndUri(final InstanceIdentifierContext iiWithData,
final CompositeNode payload) {
if (iiWithData.getSchemaNode() instanceof ListSchemaNode) {
final List<QName> keyDefinitions = ((ListSchemaNode) iiWithData.getSchemaNode()).getKeyDefinition();
ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE);
}
- InstanceIdWithSchemaNode iiWithData = null;
+ InstanceIdentifierContext iiWithData = null;
CompositeNode value = null;
if (this.representsMountPointRootData(payload)) {
// payload represents mount point data and URI represents path to the mount point
value = this.normalizeNode(payload, iiWithData.getSchemaNode(), iiWithData.getMountPoint());
} else {
- final InstanceIdWithSchemaNode incompleteInstIdWithData = this.controllerContext
+ final InstanceIdentifierContext incompleteInstIdWithData = this.controllerContext
.toInstanceIdentifier(identifier);
final DataNodeContainer parentSchema = (DataNodeContainer) incompleteInstIdWithData.getSchemaNode();
DOMMountPoint mountPoint = incompleteInstIdWithData.getMountPoint();
parentSchema, payloadName, module.getNamespace());
value = this.normalizeNode(payload, schemaNode, mountPoint);
- iiWithData = addLastIdentifierFromData(incompleteInstIdWithData, value, schemaNode);
+ iiWithData = addLastIdentifierFromData(incompleteInstIdWithData, value, schemaNode,incompleteInstIdWithData.getSchemaContext());
}
final NormalizedNode<?, ?> datastoreNormalizedData = compositeNodeToDatastoreNormalizedNode(value,
final DataSchemaNode schemaNode = ControllerContext.findInstanceDataChildByNameAndNamespace(module,
payloadName, module.getNamespace());
final CompositeNode value = this.normalizeNode(payload, schemaNode, null);
- final InstanceIdWithSchemaNode iiWithData = this.addLastIdentifierFromData(null, value, schemaNode);
+ final InstanceIdentifierContext iiWithData = this.addLastIdentifierFromData(null, value, schemaNode,ControllerContext.getInstance().getGlobalSchema());
final NormalizedNode<?, ?> datastoreNormalizedData = compositeNodeToDatastoreNormalizedNode(value, schemaNode);
DOMMountPoint mountPoint = iiWithData.getMountPoint();
YangInstanceIdentifier normalizedII;
@Override
public Response deleteConfigurationData(final String identifier) {
- final InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier(identifier);
+ final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier);
DOMMountPoint mountPoint = iiWithData.getMountPoint();
YangInstanceIdentifier normalizedII;
return module;
}
- private InstanceIdWithSchemaNode addLastIdentifierFromData(final InstanceIdWithSchemaNode identifierWithSchemaNode,
- final CompositeNode data, final DataSchemaNode schemaOfData) {
+ private InstanceIdentifierContext addLastIdentifierFromData(final InstanceIdentifierContext identifierWithSchemaNode,
+ final CompositeNode data, final DataSchemaNode schemaOfData, SchemaContext schemaContext) {
YangInstanceIdentifier instanceIdentifier = null;
if (identifierWithSchemaNode != null) {
instanceIdentifier = identifierWithSchemaNode.getInstanceIdentifier();
YangInstanceIdentifier instance = iiBuilder.toInstance();
DOMMountPoint mountPoint = null;
+ SchemaContext schemaCtx = null;
if (identifierWithSchemaNode != null) {
mountPoint = identifierWithSchemaNode.getMountPoint();
}
- return new InstanceIdWithSchemaNode(instance, schemaOfData, mountPoint);
+ return new InstanceIdentifierContext(instance, schemaOfData, mountPoint,schemaContext);
}
private HashMap<QName, Object> resolveKeysFromData(final ListSchemaNode listNode, final CompositeNode dataNode) {
"It wasn't possible to translate specified data to datastore readable form."));
}
- private InstanceIdWithSchemaNode normalizeInstanceIdentifierWithSchemaNode(
- final InstanceIdWithSchemaNode iiWithSchemaNode) {
+ private InstanceIdentifierContext normalizeInstanceIdentifierWithSchemaNode(
+ final InstanceIdentifierContext iiWithSchemaNode) {
return normalizeInstanceIdentifierWithSchemaNode(iiWithSchemaNode, false);
}
- private InstanceIdWithSchemaNode normalizeInstanceIdentifierWithSchemaNode(
- final InstanceIdWithSchemaNode iiWithSchemaNode, final boolean unwrapLastListNode) {
- return new InstanceIdWithSchemaNode(instanceIdentifierToReadableFormForNormalizeNode(
+ private InstanceIdentifierContext normalizeInstanceIdentifierWithSchemaNode(
+ final InstanceIdentifierContext iiWithSchemaNode, final boolean unwrapLastListNode) {
+ return new InstanceIdentifierContext(instanceIdentifierToReadableFormForNormalizeNode(
iiWithSchemaNode.getInstanceIdentifier(), unwrapLastListNode), iiWithSchemaNode.getSchemaNode(),
- iiWithSchemaNode.getMountPoint());
+ iiWithSchemaNode.getMountPoint(),iiWithSchemaNode.getSchemaContext());
}
private YangInstanceIdentifier instanceIdentifierToReadableFormForNormalizeNode(
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.opendaylight.controller.sal.rest.impl.RestconfApplication</param-value>
</init-param>
+ <!-- AAA Auth Filter -->
+ <init-param>
+ <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
+ <param-value> org.opendaylight.aaa.sts.TokenAuthFilter</param-value>
+ </init-param>
<load-on-startup>1</load-on-startup>
</servlet>
import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
-import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.controller.sal.restconf.impl.RestconfError;
import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
when(mockMountPoint.getService(eq(RpcProvisionRegistry.class))).thenReturn(Optional.of(mockedRpcProvisionRegistry));
when(mockMountPoint.getSchemaContext()).thenReturn(TestUtils.loadSchemaContext("/invoke-rpc"));
- InstanceIdWithSchemaNode mockedInstanceId = mock(InstanceIdWithSchemaNode.class);
+ InstanceIdentifierContext mockedInstanceId = mock(InstanceIdentifierContext.class);
when(mockedInstanceId.getMountPoint()).thenReturn(mockMountPoint);
ControllerContext mockedContext = mock(ControllerContext.class);
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
-import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@Test
public void augmentedNodesInUri() {
- InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1");
+ InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1");
assertEquals("ns:augment:main:a", iiWithData.getSchemaNode().getQName().getNamespace().toString());
iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1");
assertEquals("ns:augment:main:b", iiWithData.getSchemaNode().getQName().getNamespace().toString());
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
+import org.opendaylight.controller.sal.rest.impl.RestconfApplication;
import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
JsonToCompositeNodeProvider.INSTANCE);
resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class);
+ resourceConfig.registerClasses(new RestconfApplication().getClasses());
return resourceConfig;
}
}
@Test
+ @Ignore
public void getDataWithUriDepthParameterTest() throws UnsupportedEncodingException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
* Tests behavior when invalid value of depth URI parameter
*/
@Test
+ @Ignore
public void getDataWithInvalidDepthParameterTest() {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
try {
QName qNameDepth1Cont = QName.create("urn:nested:module", "2014-06-3", "depth1-cont");
YangInstanceIdentifier ii = YangInstanceIdentifier.builder().node(qNameDepth1Cont).build();
- NormalizedNode value = (NormalizedNode<?,?>)(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(qNameDepth1Cont)).build());
+ NormalizedNode value = (Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(qNameDepth1Cont)).build());
when(brokerFacade.readConfigurationData(eq(ii))).thenReturn(value);
restconfImpl.readConfigurationData("nested-module:depth1-cont", uriInfo);
fail("Expected RestconfDocumentedException");
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.rest.api.Draft02;
import org.opendaylight.controller.sal.rest.api.RestconfService;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.controller.sal.restconf.impl.RestconfError;
import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.controller.sal.restconf.impl.StructuredData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
}
@Test
+ @Ignore
public void testToResponseWithStatusOnly() throws Exception {
// The StructuredDataToJsonProvider should throw a
// RestconfDocumentedException with no data
when(mockRestConf.readOperationalData(any(String.class), any(UriInfo.class))).thenReturn(
- new StructuredData(null, null, null));
+ new NormalizedNodeContext(null, null));
Response resp = target("/operational/foo").request(MediaType.APPLICATION_JSON).get();
return interfaceBuilder.toInstance();
}
- static NormalizedNode prepareNormalizedNodeWithIetfInterfacesInterfacesData() throws ParseException {
+ static NormalizedNode<?,?> prepareNormalizedNodeWithIetfInterfacesInterfacesData() throws ParseException {
String ietfInterfacesDate = "2013-07-04";
String namespace = "urn:ietf:params:xml:ns:yang:ietf-interfaces";
DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> mapEntryNode = ImmutableMapEntryNodeBuilder.create();
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
-import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Test
public void testToInstanceIdentifierList() throws FileNotFoundException {
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ InstanceIdentifierContext instanceIdentifier = controllerContext
.toInstanceIdentifier("simple-nodes:userWithoutClass/foo");
assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "userWithoutClass");
@Test
public void testToInstanceIdentifierContainer() throws FileNotFoundException {
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:users");
+ InstanceIdentifierContext instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:users");
assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "users");
assertTrue(instanceIdentifier.getSchemaNode() instanceof ContainerSchemaNode);
assertEquals(2, ((ContainerSchemaNode) instanceIdentifier.getSchemaNode()).getChildNodes().size());
@Test
public void testToInstanceIdentifierChoice() throws FileNotFoundException {
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ InstanceIdentifierContext instanceIdentifier = controllerContext
.toInstanceIdentifier("simple-nodes:food/nonalcoholic");
assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "nonalcoholic");
}
@Test
public void testMountPointWithExternModul() throws FileNotFoundException {
initMountService(true);
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ InstanceIdentifierContext instanceIdentifier = controllerContext
.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
assertEquals(
"[(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student[{(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)name=name}]]",
@Test
public void testMountPointWithoutExternModul() throws FileNotFoundException {
initMountService(true);
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ InstanceIdentifierContext instanceIdentifier = controllerContext
.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/");
assertTrue(Iterables.isEmpty(instanceIdentifier.getInstanceIdentifier().getPathArguments()));
}
exception.expect(RestconfDocumentedException.class);
controllerContext.setMountService(null);
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ InstanceIdentifierContext instanceIdentifier = controllerContext
.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
}
initMountService(false);
exception.expect(RestconfDocumentedException.class);
- InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ InstanceIdentifierContext instanceIdentifier = controllerContext
.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class");
}
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
-
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
<servlet>
<servlet-name>JAXRSApiDoc</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
var loadMount = function(mountIndex, mountPath) {\r
$("#message").empty();\r
$("#message").append( "<p>Loading...</p>" );\r
- loadSwagger("http://localhost:8080/apidoc/apis/mounts/" + mountIndex,\r
+ loadSwagger("/apidoc/apis/mounts/" + mountIndex,\r
"swagger-ui-container");\r
$("#message").empty();\r
$("#message").append( "<h2><b>Showing mount points for " + mountPath + "</b></h2>");\r
//loads the root swagger documenation (which comes from RestConf)\r
var loadRootSwagger = function() {\r
$("#message").empty();\r
- loadSwagger("http://localhost:8080/apidoc/apis", "swagger-ui-container");\r
+ loadSwagger("/apidoc/apis", "swagger-ui-container");\r
}\r
\r
//main method to initialize the mount list / swagger docs / tabs on page load\r
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
+
+ <!-- dependencies to use AbstractDataBrokerTest -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ <scope>test</scope>
+ </dependency>
+ <!-- used to mock up classes -->
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
--- /dev/null
+/*
+* Copyright (c) 2014 Brocade Communications 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.sample.toaster.provider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.Future;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.DisplayString;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInput;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInputBuilder;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WheatBread;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.base.Optional;
+
+public class OpenDaylightToasterTest extends AbstractDataBrokerTest{
+
+ private static InstanceIdentifier<Toaster> TOASTER_IID =
+ InstanceIdentifier.builder( Toaster.class ).build();
+ OpendaylightToaster toaster;
+
+ @Override
+ protected void setupWithDataBroker(DataBroker dataBroker) {
+ toaster = new OpendaylightToaster();
+ toaster.setDataProvider( dataBroker );
+
+ /**
+ * Doesn't look like we have support for the NotificationProviderService yet, so mock it
+ * for now.
+ */
+ NotificationProviderService mockNotification = mock( NotificationProviderService.class );
+ toaster.setNotificationProvider( mockNotification );
+ }
+
+ @Test
+ public void testToasterInitOnStartUp() throws Exception {
+ DataBroker broker = getDataBroker();
+
+ ReadOnlyTransaction rTx = broker.newReadOnlyTransaction();
+ Optional<Toaster> optional = rTx.read( LogicalDatastoreType.OPERATIONAL, TOASTER_IID ).get();
+ assertNotNull( optional );
+ assertTrue( "Operational toaster not present", optional.isPresent() );
+
+ Toaster toaster = optional.get();
+
+ assertEquals( Toaster.ToasterStatus.Up, toaster.getToasterStatus() );
+ assertEquals( new DisplayString("Opendaylight"),
+ toaster.getToasterManufacturer() );
+ assertEquals( new DisplayString("Model 1 - Binding Aware"),
+ toaster.getToasterModelNumber() );
+
+ Optional<Toaster> configToaster =
+ rTx.read( LogicalDatastoreType.CONFIGURATION, TOASTER_IID ).get();
+ assertFalse( "Didn't expect config data for toaster.",
+ configToaster.isPresent() );
+ }
+
+ @Test
+ @Ignore //ignored because it is not an e test right now. Illustrative purposes only.
+ public void testSomething() throws Exception{
+ MakeToastInput toastInput = new MakeToastInputBuilder()
+ .setToasterDoneness( 1L )
+ .setToasterToastType( WheatBread.class )
+ .build();
+
+ //NOTE: In a real test we would want to override the Thread.sleep() to prevent our junit test
+ //for sleeping for a second...
+ Future<RpcResult<Void>> makeToast = toaster.makeToast( toastInput );
+
+ RpcResult<Void> rpcResult = makeToast.get();
+
+ assertNotNull( rpcResult );
+ assertTrue( rpcResult.isSuccessful() );
+ //etc
+ }
+
+}
}
protected abstract void cleanupSingleStat(DataModificationTransaction trans, K item);
protected abstract K updateSingleStat(DataModificationTransaction trans, I item);
+ protected abstract K createInvariantKey(K item);
public abstract void request();
public final synchronized void updateStats(List<I> list) {
final DataModificationTransaction trans = startTransaction();
-
for (final I item : list) {
- trackedItems.put(updateSingleStat(trans, item), requestCounter);
+ K key = updateSingleStat(trans, item);
+ trackedItems.put(createInvariantKey(key), requestCounter);
}
trans.commit();
import java.net.UnknownHostException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.MacAddressFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
import org.slf4j.Logger;
if (statsFlow == null || storedFlow == null) {
return false;
}
- if (statsFlow.getClass() != storedFlow.getClass()) {
- return false;
- }
if (statsFlow.getContainerName()== null) {
if (storedFlow.getContainerName()!= null) {
return false;
}
if (storedFlow == null && statsFlow != null) return false;
if (statsFlow == null && storedFlow != null) return false;
- if (storedFlow.getClass() != statsFlow.getClass()) {
- return false;
- }
if (storedFlow.getEthernetMatch() == null) {
if (statsFlow.getEthernetMatch() != null) {
return false;
}
- } else if(!storedFlow.getEthernetMatch().equals(statsFlow.getEthernetMatch())) {
+ } else if(!ethernetMatchEquals(statsFlow.getEthernetMatch(),storedFlow.getEthernetMatch())) {
return false;
}
if (storedFlow.getIcmpv4Match()== null) {
return true;
}
+ /*
+ * Custom EthernetMatch is required because mac address string provided by user in EthernetMatch can be in
+ * any case (upper or lower or mix). Ethernet Match which controller receives from switch is always
+ * an upper case string. Default EthernetMatch equals doesn't use equalsIgnoreCase() and hence it fails.
+ * E.g User provided mac address string in flow match is aa:bb:cc:dd:ee:ff and when controller fetch
+ * statistic data, openflow driver library returns AA:BB:CC:DD:EE:FF and default eqauls fails here.
+ */
+ @VisibleForTesting
+ static boolean ethernetMatchEquals(EthernetMatch statsEthernetMatch, EthernetMatch storedEthernetMatch){
+ boolean verdict = true;
+ Boolean checkNullValues = checkNullValues(statsEthernetMatch, storedEthernetMatch);
+ if (checkNullValues != null) {
+ verdict = checkNullValues;
+ } else {
+ if(verdict){
+ verdict = ethernetMatchFieldsEquals(statsEthernetMatch.getEthernetSource(),storedEthernetMatch.getEthernetSource());
+ }
+ if(verdict){
+ verdict = ethernetMatchFieldsEquals(statsEthernetMatch.getEthernetDestination(),storedEthernetMatch.getEthernetDestination());
+ }
+ if(verdict){
+ if(statsEthernetMatch.getEthernetType() == null){
+ if(storedEthernetMatch.getEthernetType() != null){
+ verdict = false;
+ }
+ }else{
+ verdict = statsEthernetMatch.getEthernetType().equals(storedEthernetMatch.getEthernetType());
+ }
+ }
+ }
+ return verdict;
+ }
+
+ private static boolean ethernetMatchFieldsEquals(MacAddressFilter statsEthernetMatchFields,
+ MacAddressFilter storedEthernetMatchFields){
+ boolean verdict = true;
+ Boolean checkNullValues = checkNullValues(statsEthernetMatchFields, storedEthernetMatchFields);
+ if (checkNullValues != null) {
+ verdict = checkNullValues;
+ } else {
+ if(verdict){
+ verdict = macAddressEquals(statsEthernetMatchFields.getAddress(),storedEthernetMatchFields.getAddress());
+ }
+ if(verdict){
+ verdict = macAddressEquals(statsEthernetMatchFields.getMask(),storedEthernetMatchFields.getMask());
+ }
+ }
+ return verdict;
+ }
+
+ private static boolean macAddressEquals(MacAddress statsMacAddress, MacAddress storedMacAddress){
+ boolean verdict = true;
+ Boolean checkNullValues = checkNullValues(statsMacAddress, storedMacAddress);
+ if (checkNullValues != null) {
+ verdict = checkNullValues;
+ } else {
+ verdict = statsMacAddress.getValue().equalsIgnoreCase(storedMacAddress.getValue());
+ }
+ return verdict;
+ }
+
@VisibleForTesting
static boolean layer3MatchEquals(Layer3Match statsLayer3Match, Layer3Match storedLayer3Match){
boolean verdict = true;
return false;
return true;
}
+
+ @Override
+ public String toString() {
+ return "FlowStatsEntry [tableId=" + tableId + ", flow=" + flow + "]";
+ }
}
}
return flowCookieMap;
}
+
+ @Override
+ protected FlowStatsEntry createInvariantKey(final FlowStatsEntry item) {
+ FlowBuilder newFlow = new FlowBuilder();
+ newFlow.setId(item.getFlow().getId());
+ newFlow.setKey(item.getFlow().getKey());
+ newFlow.fieldsFrom(item.getFlow());
+ return new FlowStatsEntry(item.getTableId(),newFlow.build());
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatisticsBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
requestHelper(flowTableStatsService.getFlowTablesStatistics(input.build()));
}
}
+
+ @Override
+ protected FlowTableAndStatisticsMap createInvariantKey(FlowTableAndStatisticsMap item) {
+ FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder();
+ flowTableAndStatisticsMapBuilder.setTableId(item.getTableId());
+ flowTableAndStatisticsMapBuilder.setKey(item.getKey());
+ return flowTableAndStatisticsMapBuilder.build();
+ }
}
super.start(dbs);
}
+
+ @Override
+ protected GroupDescStats createInvariantKey(GroupDescStats item) {
+ // No invariant data exist in the group description stats.
+ return item;
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
super.start(dbs);
}
+
+ @Override
+ protected GroupStats createInvariantKey(GroupStats item) {
+ GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
+ groupStatsBuilder.setKey(item.getKey());
+ groupStatsBuilder.setGroupId(item.getGroupId());
+ return groupStatsBuilder.build();
+ }
}
super.start(dbs);
}
+
+ @Override
+ protected MeterConfigStats createInvariantKey(MeterConfigStats item) {
+ // No invariant data exist in the meter config stats.
+ return item;
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
super.start(dbs);
}
+
+ @Override
+ protected MeterStats createInvariantKey(MeterStats item) {
+ MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();
+ meterStatsBuilder.setKey(item.getKey());
+ meterStatsBuilder.setMeterId(item.getMeterId());
+ return meterStatsBuilder.build();
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
requestHelper(portStatsService.getAllNodeConnectorsStatistics(input.build()));
}
}
+
+ @Override
+ protected NodeConnectorStatisticsAndPortNumberMap createInvariantKey(NodeConnectorStatisticsAndPortNumberMap item) {
+ NodeConnectorStatisticsAndPortNumberMapBuilder ncStatsBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
+ ncStatsBuilder.setNodeConnectorId(item.getNodeConnectorId());
+ ncStatsBuilder.setKey(item.getKey());
+ return ncStatsBuilder.build();
+ }
}
super.start(dbs);
}
+
+ @Override
+ protected QueueStatsEntry createInvariantKey(QueueStatsEntry item) {
+ // No invariant data exist in the group description stats.
+ return item;
+ }
}
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
import org.slf4j.Logger;
return ipv4MatchBuilder.build();
}
+ /**
+ * Test method for {@link org.opendaylight.controller.md.statistics.manager.FlowComparator#ethernetMatchEquals(EthernetMatch, EthernetMatch)
+ */
+ @Test
+ public void testEthernetMatchEquals() {
+ String[][][] ethernetMatchSeeds = new String[][][] {
+ {{"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}},
+ {{"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"aa:bb:bc:cd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}},
+ {{"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"AA:BB:CC:DD:EE:FF", "ff:ff:ff:ff:ff:ff","0800"}},
+ {{"AA:BB:CC:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}},
+ {{"AA:BB:CC:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"aa:bb:cc:dd:ee:ff", "FF:FF:FF:FF:FF:FF","0800"}},
+ {{"AA:BB:CC:dd:ee:ff", "ff:ff:ff:ee:ee:ee","0800"}, {"aa:bb:cc:dd:ee:ff", "FF:FF:FF:FF:FF:FF","0800"}},
+
+ {{"AA:BB:CC:dd:ee:ff", null,"0800"}, {"aa:bb:cc:dd:ee:ff", null,"0800"}},
+ {{"AA:BB:CC:dd:ee:ff", null,"0800"}, {"aa:bb:cc:dd:ee:ff", null,"0806"}},
+ {{"AA:BB:CC:dd:ee:ff", null,"0800"}, {"aa:bb:cc:dd:ee:ff", "FF:FF:FF:FF:FF:FF","0800"}},
+ {{"AA:BB:CC:dd:ee:ff", null,"0800"}, {null, "FF:FF:FF:FF:FF:FF","0800"}},
+
+ {{"AA:BB:CC:dd:ee:ff", "ff:ff:ff:ff:ff:ff",null}, {null, "FF:FF:FF:FF:FF:FF","0800"}},
+ {{"AA:BB:CC:dd:ee:ff", "ff:ff:ff:ff:ff:ff",null}, {"aa:bb:cc:dd:ee:ff", "FF:FF:FF:FF:FF:FF",null}},
+ {{"AA:BB:CC:dd:ee:ff", "ff:ff:ff:ff:ff:ff",null}, {null, "FF:FF:FF:FF:FF:FF",null}},
+
+ {{null, null,null}, {null, null,"0800"}},
+ {{null, null,null}, {null, null,null}},
+ };
+
+ boolean[] matches = new boolean[] {
+ true,
+ false,
+ true,
+ true,
+ true,
+ false,
+
+ true,
+ false,
+ false,
+ false,
+ false,
+ true,
+ false,
+
+ false,
+ true
+ };
+
+ for (int i = 0; i < matches.length; i++) {
+ checkComparisonOfEthernetMatch(
+ ethernetMatchSeeds[i][0][0], ethernetMatchSeeds[i][0][1],ethernetMatchSeeds[i][0][2],
+ ethernetMatchSeeds[i][1][0], ethernetMatchSeeds[i][1][1],ethernetMatchSeeds[i][1][2],
+ matches[i]);
+ }
+ }
+
+ /*
+ * @param ethernetMatch1
+ * @param ethernetMatch2
+ */
+ private static void checkComparisonOfEthernetMatch(String macAddress1, String macAddressMask1,String etherType1,
+ String macAddress2, String macAddressMask2,String etherType2, boolean expectedResult) {
+ EthernetMatch ethernetMatch1 = prepareEthernetMatch(macAddress1, macAddressMask1,etherType1);
+ EthernetMatch ethernetMatch2 = prepareEthernetMatch(macAddress2, macAddressMask2,etherType2);
+ boolean comparisonResult;
+ try {
+ comparisonResult = FlowComparator.ethernetMatchEquals(ethernetMatch1, ethernetMatch2);
+ Assert.assertEquals("failed to compare: "+ethernetMatch1+" vs. "+ethernetMatch2,
+ expectedResult, comparisonResult);
+ } catch (Exception e) {
+ LOG.error("failed to compare: {} vs. {}", ethernetMatch1, ethernetMatch2, e);
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ private static EthernetMatch prepareEthernetMatch(String macAddress, String macAddressMask, String etherType) {
+ EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
+ EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
+ if (macAddress != null) {
+ ethernetSourceBuilder.setAddress(new MacAddress(macAddress));
+ }
+ if (macAddressMask != null) {
+ ethernetSourceBuilder.setMask(new MacAddress(macAddressMask));
+ }
+ if(etherType != null){
+ EthernetTypeBuilder ethernetType = new EthernetTypeBuilder();
+ ethernetType.setType(new EtherType(Long.parseLong(etherType,16)));
+ ethernetMatchBuilder.setEthernetType(ethernetType.build());
+ }
+ ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
+
+ return ethernetMatchBuilder.build();
+ }
}
import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNode;
import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNodeId;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
+import java.util.Collections;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, OpendaylightInventoryListener {
private final Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyExporter.class);
public void applyOperation(final ReadWriteTransaction transaction) {
final Link link = toTopologyLink(notification);
final InstanceIdentifier<Link> path = linkPath(link);
- transaction.put(LogicalDatastoreType.OPERATIONAL, path, link);
+ transaction.merge(LogicalDatastoreType.OPERATIONAL, path, link, true);
}
});
}
@Override
public void onSuccess(Optional<Topology> topologyOptional) {
if (topologyOptional.isPresent()) {
- Topology topologyData = topologyOptional.get();
- for (Link link : topologyData.getLink()) {
+ List<Link> linkList = topologyOptional.get().getLink() != null
+ ? topologyOptional.get().getLink() : Collections.<Link> emptyList();
+ for (Link link : linkList) {
if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) {
transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(link));
}
@Override
public void onSuccess(Optional<Topology> topologyOptional) {
if (topologyOptional.isPresent()) {
- Topology topologyData = topologyOptional.get();
- for (Link link : topologyData.getLink()) {
+ List<Link> linkList = topologyOptional.get().getLink() != null
+ ? topologyOptional.get().getLink() : Collections.<Link> emptyList();
+ for (Link link : linkList) {
if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) {
transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(link));
}
* of some module. Contains default value extracted from yang file.
*/
public class AttributeConfigElement {
- private final Object dafaultValue;
+ private final Object defaultValue;
private final Object value;
private Optional<?> resolvedValue;
private Object resolvedDefaultValue;
private String jmxName;
- public AttributeConfigElement(Object dafaultValue, Object value) {
- this.dafaultValue = dafaultValue;
+ public AttributeConfigElement(Object defaultValue, Object value) {
+ this.defaultValue = defaultValue;
this.value = value;
}
public void resolveValue(AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy,
String attrName) throws NetconfDocumentedException {
resolvedValue = attributeResolvingStrategy.parseAttribute(attrName, value);
- Optional<?> resolvedDefault = attributeResolvingStrategy.parseAttribute(attrName, dafaultValue);
+ Optional<?> resolvedDefault = attributeResolvingStrategy.parseAttribute(attrName, defaultValue);
resolvedDefaultValue = resolvedDefault.isPresent() ? resolvedDefault.get() : null;
}
return value;
}
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
public Optional<?> getResolvedValue() {
return resolvedValue;
}
@Override
public String toString() {
- return "AttributeConfigElement [dafaultValue=" + dafaultValue + ", value=" + value + "]";
+ return "AttributeConfigElement [defaultValue=" + defaultValue + ", value=" + value + "]";
}
}
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
List<XmlElement> recognisedChildren = Lists.newArrayList();
for (Entry<String, AttributeReadingStrategy> innerAttrEntry : innerStrategies.entrySet()) {
- List<XmlElement> childItem = null;
- childItem = complexElement.getChildElementsWithSameNamespace(innerAttrEntry.getKey());
+ List<XmlElement> childItem = complexElement.getChildElementsWithSameNamespace(
+ innerAttrEntry.getKey());
recognisedChildren.addAll(childItem);
AttributeConfigElement resolvedInner = innerAttrEntry.getValue().readElement(childItem);
- innerMap.put(innerAttrEntry.getKey(), resolvedInner.getValue());
+ Object value = resolvedInner.getValue();
+ if(value == null) {
+ value = resolvedInner.getDefaultValue();
+ }
+
+ innerMap.put(innerAttrEntry.getKey(), value);
}
complexElement.checkUnrecognisedElements(recognisedChildren);
@Override
protected AttributeReadingStrategy caseTOAttribute(CompositeType openType) {
- Preconditions.checkState(getLastAttribute() instanceof TOAttribute);
- Map<String, AttributeIfc> inner = ((TOAttribute)getLastAttribute()).getYangPropertiesToTypesMap();
+ AttributeIfc lastAttribute = getLastAttribute();
+ Preconditions.checkState(lastAttribute instanceof TOAttribute);
+ Map<String, AttributeIfc> inner = ((TOAttribute)lastAttribute).getYangPropertiesToTypesMap();
Map<String, AttributeReadingStrategy> innerStrategies = Maps.newHashMap();
innerStrategies.put(innerAttrEntry.getKey(), innerStrat);
}
- return new CompositeAttributeReadingStrategy(getLastAttribute().getNullableDefault(), innerStrategies);
+ return new CompositeAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategies);
}
@Override
protected AttributeReadingStrategy caseListAttribute(ArrayType<?> openType) {
- Preconditions.checkState(getLastAttribute() instanceof ListAttribute);
- AttributeReadingStrategy innerStrategy = prepareReadingStrategy(key, ((ListAttribute) getLastAttribute()).getInnerAttribute());
- return new ArrayAttributeReadingStrategy(getLastAttribute().getNullableDefault(), innerStrategy);
+ AttributeIfc lastAttribute = getLastAttribute();
+ Preconditions.checkState(lastAttribute instanceof ListAttribute);
+ AttributeReadingStrategy innerStrategy = prepareReadingStrategy(key, ((ListAttribute) lastAttribute).getInnerAttribute());
+ return new ArrayAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategy);
}
@Override
protected AttributeReadingStrategy caseListDependeciesAttribute(ArrayType<?> openType) {
- Preconditions.checkState(getLastAttribute() instanceof ListDependenciesAttribute);
+ AttributeIfc lastAttribute = getLastAttribute();
+ Preconditions.checkState(lastAttribute instanceof ListDependenciesAttribute);
AttributeReadingStrategy innerStrategy = caseDependencyAttribute(SimpleType.OBJECTNAME);
- return new ArrayAttributeReadingStrategy(getLastAttribute().getNullableDefault(), innerStrategy);
+ return new ArrayAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategy);
}
}
if(attributeIfc instanceof DependencyAttribute) {
serviceNameOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getLocalName();
namespaceOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString();
+ } else if (attributeIfc instanceof ListDependenciesAttribute) {
+ serviceNameOfDepAttr = ((ListDependenciesAttribute)attributeIfc).getDependency().getSie().getQName().getLocalName();
+ namespaceOfDepAttr = ((ListDependenciesAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString();
}
return switchAttribute(attributeIfc);
if(configs != null && !configs.isEmpty()) {
configPusher.pushConfigs(configs);
}
- registration = context.registerService(ConfigPusher.class.getName(), configPusher, null);
- configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator);
+ if(context != null) {
+ registration = context.registerService(ConfigPusher.class.getName(), configPusher, null);
+ configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator);
+ } else {
+ logger.warn("Unable to process configs as BundleContext is null");
+ }
} catch (InterruptedException e) {
logger.info("ConfigPusher thread stopped",e);
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2014 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
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-subsystem</artifactId>
+ <version>0.2.5-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <artifactId>netconf-auth</artifactId>
+ <packaging>bundle</packaging>
+ <name>${project.artifactId}</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2014 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.auth;
+
+public class AuthConstants {
+
+ /**
+ * This property should be set for every implementation of AuthService published to OSGi.
+ * Netconf SSH will pick the service with highest preference in case of multiple services present in OSGi.
+ */
+ public static final String SERVICE_PREFERENCE_KEY = "preference";
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.ssh.authentication;
+package org.opendaylight.controller.netconf.auth;
+/**
+ * Authentication Service definition for netconf.
+ */
public interface AuthProvider {
+ /**
+ * Authenticate user by username/password.
+ *
+ * @param username username
+ * @param password password
+ * @return true if authentication is successful, false otherwise
+ */
boolean authenticated(String username, String password);
- char[] getPEMAsCharArray();
}
import java.io.IOException;
import org.opendaylight.controller.netconf.nettyutil.AbstractChannelInitializer;
import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshHandler;
+import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
import org.opendaylight.protocol.framework.SessionListenerFactory;
final class SshClientChannelInitializer extends AbstractChannelInitializer<NetconfClientSession> {
@Override
public void initialize(final Channel ch, final Promise<NetconfClientSession> promise) {
try {
- ch.pipeline().addFirst(SshHandler.createForNetconfSubsystem(authenticationHandler));
+ // ssh handler has to be the first handler in pipeline
+ ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(authenticationHandler));
super.initialize(ch,promise);
} catch (final IOException e) {
throw new RuntimeException(e);
*/
package org.opendaylight.controller.netconf.it;
-import java.net.InetSocketAddress;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anySetOf;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.local.LocalAddress;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.util.HashedWheelTimer;
+import io.netty.util.concurrent.GlobalEventExecutor;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.IdentityTestModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreService;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreServiceImpl;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot;
import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory;
import org.opendaylight.controller.netconf.impl.SessionIdProvider;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl;
import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.w3c.dom.Element;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.util.HashedWheelTimer;
-import io.netty.util.concurrent.GlobalEventExecutor;
+public abstract class AbstractNetconfConfigTest extends AbstractConfigTest {
-public class AbstractNetconfConfigTest extends AbstractConfigTest {
+ public static final String LOOPBACK_ADDRESS = "127.0.0.1";
+ public static final int SERVER_CONNECTION_TIMEOUT_MILLIS = 5000;
+
+ static ModuleFactory[] FACTORIES = { new TestImplModuleFactory(),
+ new DepTestImplModuleFactory(), new NetconfTestImplModuleFactory(),
+ new IdentityTestModuleFactory(), new MultipleDependenciesModuleFactory() };
private EventLoopGroup nettyThreadgroup;
private HashedWheelTimer hashedWheelTimer;
+ private NetconfClientDispatcherImpl clientDispatcher;
+ private Channel serverTcpChannel;
+
+ private NetconfMessage getConfig;
+ private NetconfMessage get;
+
+ /**
+ * @Before in subclasses is called after this method.
+ */
@Before
- public void setUpAbstractNetconfConfigTest() {
+ public void setUpAbstractNetconfConfigTest() throws Exception {
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, FACTORIES));
+
nettyThreadgroup = new NioEventLoopGroup();
hashedWheelTimer = new HashedWheelTimer();
+
+ loadMessages();
+
+ setUpTestInitial();
+
+ final NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
+ factoriesListener.onAddNetconfOperationServiceFactory(new NetconfOperationServiceFactoryImpl(getYangStore()));
+
+ for (final NetconfOperationServiceFactory netconfOperationServiceFactory : getAdditionalServiceFactories()) {
+ factoriesListener.onAddNetconfOperationServiceFactory(netconfOperationServiceFactory);
+ }
+
+ serverTcpChannel = startNetconfTcpServer(factoriesListener);
+ clientDispatcher = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
+ }
+
+ /**
+ * Called before setUp method is executed, so test classes can set up resources before setUpAbstractNetconfConfigTest method is called.
+ */
+ protected void setUpTestInitial() throws Exception {}
+
+ private void loadMessages() throws Exception {
+ this.getConfig = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
+ this.get = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/get.xml");
+ }
+
+ public NetconfMessage getGetConfig() {
+ return getConfig;
+ }
+
+ public NetconfMessage getGet() {
+ return get;
+ }
+
+ private Channel startNetconfTcpServer(final NetconfOperationServiceFactoryListenerImpl factoriesListener) throws Exception {
+ final NetconfServerDispatcher dispatch = createDispatcher(factoriesListener, getNetconfMonitoringService(), getNotificationProducer());
+
+ final ChannelFuture s;
+ if(getTcpServerAddress() instanceof LocalAddress) {
+ s = dispatch.createLocalServer(((LocalAddress) getTcpServerAddress()));
+ } else {
+ s = dispatch.createServer(((InetSocketAddress) getTcpServerAddress()));
+ }
+ s.await();
+ return s.channel();
+ }
+
+ protected DefaultCommitNotificationProducer getNotificationProducer() {
+ final DefaultCommitNotificationProducer notificationProducer = mock(DefaultCommitNotificationProducer.class);
+ doNothing().when(notificationProducer).close();
+ doNothing().when(notificationProducer).sendCommitNotification(anyString(), any(Element.class), anySetOf(String.class));
+ return notificationProducer;
+ }
+
+ protected Iterable<NetconfOperationServiceFactory> getAdditionalServiceFactories() {
+ return Collections.emptySet();
+ }
+
+ protected SessionMonitoringService getNetconfMonitoringService() throws Exception {
+ final NetconfOperationProvider netconfOperationProvider = mock(NetconfOperationProvider.class);
+ final NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
+ doReturn(Collections.<NetconfOperationService>emptySet()).when(snap).getServices();
+ doReturn(snap).when(netconfOperationProvider).openSnapshot(anyString());
+ return new NetconfMonitoringServiceImpl(netconfOperationProvider);
+ }
+
+ protected abstract SocketAddress getTcpServerAddress();
+
+ public NetconfClientDispatcherImpl getClientDispatcher() {
+ return clientDispatcher;
+ }
+
+ private HardcodedYangStoreService getYangStore() throws YangStoreException, IOException {
+ final Collection<InputStream> yangDependencies = getBasicYangs();
+ return new HardcodedYangStoreService(yangDependencies);
+ }
+
+ static Collection<InputStream> getBasicYangs() throws IOException {
+
+ final List<String> paths = Arrays.asList(
+ "/META-INF/yang/config.yang",
+ "/META-INF/yang/rpc-context.yang",
+ "/META-INF/yang/config-test.yang",
+ "/META-INF/yang/config-test-impl.yang",
+ "/META-INF/yang/test-types.yang",
+ "/META-INF/yang/ietf-inet-types.yang");
+
+ final Collection<InputStream> yangDependencies = new ArrayList<>();
+ final List<String> failedToFind = new ArrayList<>();
+ for (final String path : paths) {
+ final InputStream resourceAsStream = NetconfITTest.class.getResourceAsStream(path);
+ if (resourceAsStream == null) {
+ failedToFind.add(path);
+ } else {
+ yangDependencies.add(resourceAsStream);
+ }
+ }
+ assertEquals("Some yang files were not found", Collections.<String>emptyList(), failedToFind);
+ return yangDependencies;
}
protected NetconfServerDispatcher createDispatcher(
- NetconfOperationServiceFactoryListenerImpl factoriesListener, SessionMonitoringService sessionMonitoringService,
- DefaultCommitNotificationProducer commitNotifier) {
- SessionIdProvider idProvider = new SessionIdProvider();
+ final NetconfOperationServiceFactoryListenerImpl factoriesListener, final SessionMonitoringService sessionMonitoringService,
+ final DefaultCommitNotificationProducer commitNotifier) {
+ final SessionIdProvider idProvider = new SessionIdProvider();
- NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
- hashedWheelTimer, factoriesListener, idProvider, 5000, commitNotifier, sessionMonitoringService);
+ final NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
+ hashedWheelTimer, factoriesListener, idProvider, SERVER_CONNECTION_TIMEOUT_MILLIS, commitNotifier, sessionMonitoringService);
- NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(
+ final NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(
serverNegotiatorFactory);
return new NetconfServerDispatcher(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup);
}
return nettyThreadgroup;
}
+ /**
+ * @After in subclasses is be called before this.
+ */
@After
- public void cleanUpTimer() {
+ public void cleanUpNetconf() throws Exception {
+ serverTcpChannel.close().await();
hashedWheelTimer.stop();
- nettyThreadgroup.shutdownGracefully();
+ nettyThreadgroup.shutdownGracefully().await();
}
public NetconfClientConfiguration getClientConfiguration(final InetSocketAddress tcpAddress, final int timeout) {
final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
b.withAddress(tcpAddress);
b.withSessionListener(new SimpleNetconfClientSessionListener());
- b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE,
- timeout));
+ b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, timeout));
b.withConnectionTimeoutMillis(timeout);
return b.build();
}
+
+ public static final class HardcodedYangStoreService implements YangStoreService {
+
+ private final List<InputStream> byteArrayInputStreams;
+
+ public HardcodedYangStoreService(final Collection<? extends InputStream> inputStreams) throws YangStoreException, IOException {
+ byteArrayInputStreams = new ArrayList<>();
+ for (final InputStream inputStream : inputStreams) {
+ assertNotNull(inputStream);
+ final byte[] content = IOUtils.toByteArray(inputStream);
+ final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content);
+ byteArrayInputStreams.add(byteArrayInputStream);
+ }
+ }
+
+ @Override
+ public YangStoreSnapshot getYangStoreSnapshot() throws YangStoreException {
+ for (final InputStream inputStream : byteArrayInputStreams) {
+ try {
+ inputStream.reset();
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ final YangParserImpl yangParser = new YangParserImpl();
+ final SchemaContext schemaContext = yangParser.resolveSchemaContext(new HashSet<>(yangParser.parseYangModelsFromStreamsMapped(byteArrayInputStreams).values()));
+ final YangStoreServiceImpl yangStoreService = new YangStoreServiceImpl(new SchemaContextProvider() {
+ @Override
+ public SchemaContext getSchemaContext() {
+ return schemaContext ;
+ }
+ });
+ return yangStoreService.getYangStoreSnapshot();
+ }
+ }
}
+++ /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.it;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreService;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreServiceImpl;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-public class HardcodedYangStoreService implements YangStoreService {
-
- private final List<InputStream> byteArrayInputStreams;
-
- public HardcodedYangStoreService(
- Collection<? extends InputStream> inputStreams)
- throws YangStoreException, IOException {
- byteArrayInputStreams = new ArrayList<>();
- for (InputStream inputStream : inputStreams) {
- assertNotNull(inputStream);
- byte[] content = IOUtils.toByteArray(inputStream);
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- content);
- byteArrayInputStreams.add(byteArrayInputStream);
- }
- }
-
- @Override
- public YangStoreSnapshot getYangStoreSnapshot() throws YangStoreException {
- for (InputStream inputStream : byteArrayInputStreams) {
- try {
- inputStream.reset();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- YangParserImpl yangParser = new YangParserImpl();
- final SchemaContext schemaContext = yangParser.resolveSchemaContext(new HashSet<>(yangParser.parseYangModelsFromStreamsMapped(byteArrayInputStreams).values()));
- YangStoreServiceImpl yangStoreService = new YangStoreServiceImpl(new SchemaContextProvider() {
- @Override
- public SchemaContext getSchemaContext() {
- return schemaContext ;
- }
- });
- return yangStoreService.getYangStoreSnapshot();
- }
-}
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.opendaylight.controller.netconf.util.test.XmlUnitUtil.assertContainsElementWithName;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import io.netty.channel.ChannelFuture;
import java.io.IOException;
-import java.io.InputStream;
+import java.lang.management.ManagementFactory;
import java.net.InetSocketAddress;
-import java.util.Collection;
+import java.net.SocketAddress;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.management.InstanceNotFoundException;
import javax.management.Notification;
import javax.management.NotificationListener;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification;
-import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
-import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl;
import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
import org.opendaylight.controller.netconf.mapping.api.Capability;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringActivator;
import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOperationService;
import org.opendaylight.controller.netconf.persist.impl.ConfigPersisterNotificationHandler;
public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
- private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 12023);
+ public static final int PORT = 12026;
+ private static final InetSocketAddress TCP_ADDRESS = new InetSocketAddress(LOOPBACK_ADDRESS, PORT);
- private NetconfClientDispatcher clientDispatcher;
- private DefaultCommitNotificationProducer commitNotifier;
+ private NetconfMonitoringServiceImpl netconfMonitoringService;
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,NetconfITTest.FACTORIES));
-
- NetconfMonitoringServiceImpl monitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
-
- NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
- factoriesListener.onAddNetconfOperationServiceFactory(new NetconfOperationServiceFactoryImpl(getYangStore()));
- factoriesListener
- .onAddNetconfOperationServiceFactory(new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
- new NetconfMonitoringOperationService(monitoringService)));
-
-
- commitNotifier = new DefaultCommitNotificationProducer(platformMBeanServer);
- NetconfServerDispatcher dispatch = createDispatcher(factoriesListener, mockSessionMonitoringService(), commitNotifier);
- ChannelFuture s = dispatch.createServer(tcpAddress);
- s.await();
-
- clientDispatcher = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
+ @Override
+ protected void setUpTestInitial() {
+ netconfMonitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
}
- @After
- public void cleanUp(){
- commitNotifier.close();
+ @Override
+ protected SessionMonitoringService getNetconfMonitoringService() throws Exception {
+ return netconfMonitoringService;
}
- private HardcodedYangStoreService getYangStore() throws YangStoreException, IOException {
- final Collection<InputStream> yangDependencies = NetconfITTest.getBasicYangs();
- return new HardcodedYangStoreService(yangDependencies);
+ @Override
+ protected SocketAddress getTcpServerAddress() {
+ return TCP_ADDRESS;
}
-
- protected SessionMonitoringService mockSessionMonitoringService() {
- SessionMonitoringService mockedSessionMonitor = mock(SessionMonitoringService.class);
- doNothing().when(mockedSessionMonitor).onSessionUp(any(NetconfManagementSession.class));
- doNothing().when(mockedSessionMonitor).onSessionDown(any(NetconfManagementSession.class));
- return mockedSessionMonitor;
+ @Override
+ protected Iterable<NetconfOperationServiceFactory> getAdditionalServiceFactories() {
+ return Collections.<NetconfOperationServiceFactory>singletonList(new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
+ new NetconfMonitoringOperationService(netconfMonitoringService)));
}
-
+ @Override
+ protected DefaultCommitNotificationProducer getNotificationProducer() {
+ return new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer());
+ }
@Test
public void testNetconfCommitNotifications() throws Exception {
+ final VerifyingNotificationListener notificationVerifier = createCommitNotificationListener();
+ final VerifyingPersister mockedAggregator = mockAggregator();
- VerifyingNotificationListener notificationVerifier = createCommitNotificationListener();
- VerifyingPersister mockedAggregator = mockAggregator();
-
- try (TestingNetconfClient persisterClient = new TestingNetconfClient("persister", clientDispatcher, getClientConfiguration(tcpAddress, 4000))) {
+ try (TestingNetconfClient persisterClient = new TestingNetconfClient("persister", getClientDispatcher(), getClientConfiguration(TCP_ADDRESS, 4000))) {
try (ConfigPersisterNotificationHandler configPersisterNotificationHandler = new ConfigPersisterNotificationHandler(
platformMBeanServer, mockedAggregator)) {
- try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", clientDispatcher, getClientConfiguration(tcpAddress, 4000))) {
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", getClientDispatcher(), getClientConfiguration(TCP_ADDRESS, 4000))) {
NetconfMessage response = netconfClient.sendMessage(loadGetConfigMessage());
assertContainsElementWithName(response.getDocument(), "modules");
assertContainsElementWithName(response.getDocument(), "services");
}
private VerifyingNotificationListener createCommitNotificationListener() throws InstanceNotFoundException {
- VerifyingNotificationListener listener = new VerifyingNotificationListener();
+ final VerifyingNotificationListener listener = new VerifyingNotificationListener();
platformMBeanServer.addNotificationListener(DefaultCommitNotificationProducer.OBJECT_NAME, listener, null, null);
return listener;
}
public NetconfOperationProvider getNetconfOperationProvider() {
- NetconfOperationProvider factoriesListener = mock(NetconfOperationProvider.class);
- NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
- NetconfOperationService service = mock(NetconfOperationService.class);
- Set<Capability> caps = Sets.newHashSet();
+ final NetconfOperationProvider factoriesListener = mock(NetconfOperationProvider.class);
+ final NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
+ final NetconfOperationService service = mock(NetconfOperationService.class);
+ final Set<Capability> caps = Sets.newHashSet();
doReturn(caps).when(service).getCapabilities();
- Set<NetconfOperationService> services = Sets.newHashSet(service);
+ final Set<NetconfOperationService> services = Sets.newHashSet(service);
doReturn(services).when(snap).getServices();
doReturn(snap).when(factoriesListener).openSnapshot(anyString());
public List<Notification> notifications = Lists.newArrayList();
@Override
- public void handleNotification(Notification notification, Object handback) {
+ public void handleNotification(final Notification notification, final Object handback) {
this.notifications.add(notification);
}
- void assertNotificationCount(Object size) {
+ void assertNotificationCount(final Object size) {
assertEquals(size, notifications.size());
}
- void assertNotificationContent(int notificationIndex, int expectedModulesSize, int expectedServicesSize, int expectedCapsSize) {
- Notification notification = notifications.get(notificationIndex);
+ void assertNotificationContent(final int notificationIndex, final int expectedModulesSize, final int expectedServicesSize, final int expectedCapsSize) {
+ final Notification notification = notifications.get(notificationIndex);
assertEquals(CommitJMXNotification.class, notification.getClass());
- int capsSize = ((CommitJMXNotification) notification).getCapabilities().size();
+ final int capsSize = ((CommitJMXNotification) notification).getCapabilities().size();
assertEquals("Expected capabilities count", expectedCapsSize, capsSize);
- Element configSnapshot = ((CommitJMXNotification) notification).getConfigSnapshot();
- int modulesSize = configSnapshot.getElementsByTagName("module").getLength();
+ final Element configSnapshot = ((CommitJMXNotification) notification).getConfigSnapshot();
+ final int modulesSize = configSnapshot.getElementsByTagName("module").getLength();
assertEquals("Expected modules count", expectedModulesSize, modulesSize);
- int servicesSize = configSnapshot.getElementsByTagName("instance").getLength();
+ final int servicesSize = configSnapshot.getElementsByTagName("instance").getLength();
assertEquals("Expected services count", expectedServicesSize, servicesSize);
}
}
private Persister mockedPersister;
public VerifyingPersister() throws IOException {
- Persister mockedAggregator = mock(Persister.class);
+ final Persister mockedAggregator = mock(Persister.class);
doAnswer(new Answer<Object>() {
@Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- ConfigSnapshotHolder configSnapshot = (ConfigSnapshotHolder) invocation.getArguments()[0];
+ public Object answer(final InvocationOnMock invocation) throws Throwable {
+ final ConfigSnapshotHolder configSnapshot = (ConfigSnapshotHolder) invocation.getArguments()[0];
snapshots.add(configSnapshot);
return null;
}
this.mockedPersister = mockedAggregator;
}
- void assertSnapshotCount(Object size) {
+ void assertSnapshotCount(final Object size) {
assertEquals(size, snapshots.size());
}
- void assertSnapshotContent(int notificationIndex, int expectedModulesSize, int expectedServicesSize, int expectedCapsSize)
+ void assertSnapshotContent(final int notificationIndex, final int expectedModulesSize, final int expectedServicesSize, final int expectedCapsSize)
throws SAXException, IOException {
- ConfigSnapshotHolder snapshot = snapshots.get(notificationIndex);
- int capsSize = snapshot.getCapabilities().size();
+ final ConfigSnapshotHolder snapshot = snapshots.get(notificationIndex);
+ final int capsSize = snapshot.getCapabilities().size();
assertEquals("Expected capabilities count", expectedCapsSize, capsSize);
- Document configSnapshot = readXmlToDocument(snapshot.getConfigSnapshot());
+ final Document configSnapshot = readXmlToDocument(snapshot.getConfigSnapshot());
assertElementsCount(configSnapshot, "module", expectedModulesSize);
assertElementsCount(configSnapshot, "instance", expectedServicesSize);
}
@Override
- public void persistConfig(ConfigSnapshotHolder configSnapshotHolder) throws IOException {
+ public void persistConfig(final ConfigSnapshotHolder configSnapshotHolder) throws IOException {
mockedPersister.persistConfig(configSnapshotHolder);
}
--- /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.it;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.opendaylight.controller.netconf.util.test.XmlUnitUtil.assertContainsElementWithText;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl;
+import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
+import org.opendaylight.controller.netconf.mapping.api.Capability;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringActivator;
+import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOperationService;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.w3c.dom.Document;
+
+public class NetconfITMonitoringTest extends AbstractNetconfConfigTest {
+
+ public static final int PORT = 12025;
+ public static final InetSocketAddress TCP_ADDRESS = new InetSocketAddress(LOOPBACK_ADDRESS, PORT);
+ public static final TestingCapability TESTING_CAPABILITY = new TestingCapability();
+
+ private NetconfMonitoringServiceImpl netconfMonitoringService;
+
+ @Override
+ protected void setUpTestInitial() {
+ netconfMonitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
+ }
+
+ @Override
+ protected SessionMonitoringService getNetconfMonitoringService() throws Exception {
+ return netconfMonitoringService;
+ }
+
+ @Override
+ protected Iterable<NetconfOperationServiceFactory> getAdditionalServiceFactories() {
+ return Collections.<NetconfOperationServiceFactory>singletonList(new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
+ new NetconfMonitoringOperationService(netconfMonitoringService)));
+ }
+
+ @Override
+ protected InetSocketAddress getTcpServerAddress() {
+ return TCP_ADDRESS;
+ }
+
+ static SessionMonitoringService getNetconfMonitoringListenerService(final Logger logger, final NetconfMonitoringServiceImpl monitor) {
+ return new SessionMonitoringService() {
+ @Override
+ public void onSessionUp(final NetconfManagementSession session) {
+ logger.debug("Management session up {}", session);
+ monitor.onSessionUp(session);
+ }
+
+ @Override
+ public void onSessionDown(final NetconfManagementSession session) {
+ logger.debug("Management session down {}", session);
+ monitor.onSessionDown(session);
+ }
+ };
+ }
+
+ @Test
+ public void testGetResponseFromMonitoring() throws Exception {
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient("client-monitoring", getClientDispatcher(), getClientConfiguration(TCP_ADDRESS, 10000))) {
+ try (TestingNetconfClient netconfClient2 = new TestingNetconfClient("client-monitoring2", getClientDispatcher(), getClientConfiguration(TCP_ADDRESS, 10000))) {
+ Thread.sleep(500);
+ final NetconfMessage response = netconfClient2.sendMessage(getGet());
+ assertSessionElementsInResponse(response.getDocument(), 2);
+ }
+ Thread.sleep(500);
+ final NetconfMessage response = netconfClient.sendMessage(getGet());
+ assertSessionElementsInResponse(response.getDocument(), 1);
+ }
+ }
+
+
+ @Test(timeout = 13 * 10000)
+ public void testClientHelloWithAuth() throws Exception {
+ String fileName = "netconfMessages/client_hello_with_auth.xml";
+ final String hello = XmlFileLoader.fileToString(fileName);
+
+ fileName = "netconfMessages/get.xml";
+ final String get = XmlFileLoader.fileToString(fileName);
+
+ final Socket sock = new Socket(TCP_ADDRESS.getHostName(), TCP_ADDRESS.getPort());
+ sock.getOutputStream().write(hello.getBytes(Charsets.UTF_8));
+ final String separator = "]]>]]>";
+
+ sock.getOutputStream().write(separator.getBytes(Charsets.UTF_8));
+ sock.getOutputStream().write(get.getBytes(Charsets.UTF_8));
+ sock.getOutputStream().write(separator.getBytes(Charsets.UTF_8));
+
+ final StringBuilder responseBuilder = new StringBuilder();
+
+ try (InputStream inputStream = sock.getInputStream();
+ InputStreamReader reader = new InputStreamReader(inputStream);
+ BufferedReader buff = new BufferedReader(reader)) {
+ String line;
+ while ((line = buff.readLine()) != null) {
+
+ responseBuilder.append(line);
+ responseBuilder.append(System.lineSeparator());
+
+ if(line.contains("</rpc-reply>"))
+ break;
+ }
+ }
+
+ sock.close();
+
+ final String helloMsg = responseBuilder.substring(0, responseBuilder.indexOf(separator));
+ Document doc = XmlUtil.readXmlToDocument(helloMsg);
+ assertContainsElementWithText(doc, "urn:ietf:params:netconf:capability:candidate:1.0");
+
+ final String replyMsg = responseBuilder.substring(responseBuilder.indexOf(separator) + separator.length());
+ doc = XmlUtil.readXmlToDocument(replyMsg);
+ assertContainsElementWithText(doc, "tomas");
+ }
+
+ private void assertSessionElementsInResponse(final Document document, final int i) {
+ final int elementSize = document.getElementsByTagName("session-id").getLength();
+ assertEquals("Incorrect number of session-id tags in " + XmlUtil.toString(document), i, elementSize);
+ }
+
+ public static NetconfOperationProvider getNetconfOperationProvider() {
+ final NetconfOperationProvider factoriesListener = mock(NetconfOperationProvider.class);
+ final NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
+ try {
+ doNothing().when(snap).close();
+ } catch (final Exception e) {
+ // not happening
+ throw new IllegalStateException(e);
+ }
+ final NetconfOperationService service = mock(NetconfOperationService.class);
+ final Set<Capability> caps = Sets.newHashSet();
+ caps.add(TESTING_CAPABILITY);
+
+ doReturn(caps).when(service).getCapabilities();
+ final Set<NetconfOperationService> services = Sets.newHashSet(service);
+ doReturn(services).when(snap).getServices();
+ doReturn(snap).when(factoriesListener).openSnapshot(anyString());
+
+ return factoriesListener;
+ }
+
+ private static class TestingCapability implements Capability {
+ @Override
+ public String getCapabilityUri() {
+ return "namespaceModuleRevision";
+ }
+
+ @Override
+ public Optional<String> getModuleNamespace() {
+ return Optional.of("namespace");
+ }
+
+ @Override
+ public Optional<String> getModuleName() {
+ return Optional.of("name");
+ }
+
+ @Override
+ public Optional<String> getRevision() {
+ return Optional.of("revision");
+ }
+
+ @Override
+ public Optional<String> getCapabilitySchema() {
+ return Optional.of("content");
+ }
+
+ @Override
+ public Optional<List<String>> getLocation() {
+ return Optional.absent();
+ }
+ }
+}
package org.opendaylight.controller.netconf.it;
-import static java.util.Arrays.asList;
-import static org.mockito.Matchers.any;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import ch.ethz.ssh2.Connection;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
+import com.google.common.collect.Lists;
+import io.netty.channel.local.LocalAddress;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.concurrent.GlobalEventExecutor;
import java.io.IOException;
-import java.io.InputStream;
-import java.lang.management.ManagementFactory;
import java.net.InetSocketAddress;
-import java.util.Collection;
import java.util.List;
-import junit.framework.Assert;
+import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
-import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
-import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
+import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProviderImpl;
import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
import org.opendaylight.controller.netconf.util.messages.NetconfMessageUtil;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
-import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
public class NetconfITSecureTest extends AbstractNetconfConfigTest {
- private static final InetSocketAddress tlsAddress = new InetSocketAddress("127.0.0.1", 12024);
+ public static final int PORT = 12024;
+ private static final InetSocketAddress TLS_ADDRESS = new InetSocketAddress("127.0.0.1", PORT);
+
+ public static final String USERNAME = "user";
+ public static final String PASSWORD = "pwd";
- private DefaultCommitNotificationProducer commitNot;
private NetconfSSHServer sshServer;
- private NetconfMessage getConfig;
@Before
public void setUp() throws Exception {
- this.getConfig = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
-
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, getModuleFactories().toArray(
- new ModuleFactory[0])));
-
- NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
- factoriesListener.onAddNetconfOperationServiceFactory(new NetconfOperationServiceFactoryImpl(getYangStore()));
-
- commitNot = new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer());
-
-
- final NetconfServerDispatcher dispatchS = createDispatcher(factoriesListener);
- ChannelFuture s = dispatchS.createLocalServer(NetconfConfigUtil.getNetconfLocalAddress());
- s.await();
- EventLoopGroup bossGroup = new NioEventLoopGroup();
- sshServer = NetconfSSHServer.start(tlsAddress.getPort(), NetconfConfigUtil.getNetconfLocalAddress(), getAuthProvider(), bossGroup);
- }
-
- private NetconfServerDispatcher createDispatcher(NetconfOperationServiceFactoryListenerImpl factoriesListener) {
- return super.createDispatcher(factoriesListener, NetconfITTest.getNetconfMonitoringListenerService(), commitNot);
+ final char[] pem = PEMGenerator.generate().toCharArray();
+ sshServer = NetconfSSHServer.start(TLS_ADDRESS.getPort(), NetconfConfigUtil.getNetconfLocalAddress(), getNettyThreadgroup(), pem);
+ sshServer.setAuthProvider(getAuthProvider());
}
@After
public void tearDown() throws Exception {
- sshServer.stop();
- commitNot.close();
- }
-
- private HardcodedYangStoreService getYangStore() throws YangStoreException, IOException {
- final Collection<InputStream> yangDependencies = NetconfITTest.getBasicYangs();
- return new HardcodedYangStoreService(yangDependencies);
- }
-
- protected List<ModuleFactory> getModuleFactories() {
- return asList(NetconfITTest.FACTORIES);
+ sshServer.close();
+ sshServer.join();
}
@Test
public void testSecure() throws Exception {
- NetconfClientDispatcher dispatch = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
+ final NetconfClientDispatcher dispatch = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration())) {
- NetconfMessage response = netconfClient.sendMessage(getConfig);
- Assert.assertFalse("Unexpected error message " + XmlUtil.toString(response.getDocument()),
+ NetconfMessage response = netconfClient.sendMessage(getGetConfig());
+ assertFalse("Unexpected error message " + XmlUtil.toString(response.getDocument()),
NetconfMessageUtil.isErrorMessage(response));
- NetconfMessage gs = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc message-id=\"2\"\n" +
+ final NetconfMessage gs = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc message-id=\"2\"\n" +
" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
" <get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">\n" +
" <identifier>config</identifier>\n" +
"</rpc>\n"));
response = netconfClient.sendMessage(gs);
- Assert.assertFalse("Unexpected error message " + XmlUtil.toString(response.getDocument()),
+ assertFalse("Unexpected error message " + XmlUtil.toString(response.getDocument()),
NetconfMessageUtil.isErrorMessage(response));
}
}
+ /**
+ * Test all requests are handled properly and no mismatch occurs in listener
+ */
+ @Test(timeout = 3*60*1000)
+ public void testSecureStress() throws Exception {
+ final NetconfClientDispatcher dispatch = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration())) {
+
+ final AtomicInteger responseCounter = new AtomicInteger(0);
+ final List<Future<?>> futures = Lists.newArrayList();
+
+ final int requests = 1000;
+ for (int i = 0; i < requests; i++) {
+ final Future<NetconfMessage> netconfMessageFuture = netconfClient.sendRequest(getGetConfig());
+ futures.add(netconfMessageFuture);
+ netconfMessageFuture.addListener(new GenericFutureListener<Future<? super NetconfMessage>>() {
+ @Override
+ public void operationComplete(final Future<? super NetconfMessage> future) throws Exception {
+ assertTrue("Request unsuccessful " + future.cause(), future.isSuccess());
+ responseCounter.incrementAndGet();
+ }
+ });
+ }
+
+ for (final Future<?> future : futures) {
+ future.await();
+ }
+
+ // Give future listeners some time to finish counter incrementation
+ Thread.sleep(5000);
+
+ assertEquals(requests, responseCounter.get());
+ }
+ }
+
public NetconfClientConfiguration getClientConfiguration() throws IOException {
final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
- b.withAddress(tlsAddress);
+ b.withAddress(TLS_ADDRESS);
b.withSessionListener(new SimpleNetconfClientSessionListener());
b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000));
b.withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH);
}
public AuthProvider getAuthProvider() throws Exception {
- AuthProvider mock = mock(AuthProviderImpl.class);
- doReturn(true).when(mock).authenticated(anyString(), anyString());
- doReturn(PEMGenerator.generate().toCharArray()).when(mock).getPEMAsCharArray();
- return mock;
+ final AuthProvider mockAuth = mock(AuthProvider.class);
+ doReturn("mockedAuth").when(mockAuth).toString();
+ doReturn(true).when(mockAuth).authenticated(anyString(), anyString());
+ return mockAuth;
}
public AuthenticationHandler getAuthHandler() throws IOException {
- final AuthenticationHandler authHandler = mock(AuthenticationHandler.class);
- doAnswer(new Answer() {
- @Override
- public Object answer(final InvocationOnMock invocation) throws Throwable {
- Connection conn = (Connection) invocation.getArguments()[0];
- conn.authenticateWithPassword("user", "pwd");
- return null;
- }
- }).when(authHandler).authenticate(any(Connection.class));
- doReturn("auth handler").when(authHandler).toString();
- return authHandler;
+ return new LoginPassword(USERNAME, PASSWORD);
+ }
+
+ @Override
+ protected LocalAddress getTcpServerAddress() {
+ return NetconfConfigUtil.getNetconfLocalAddress();
}
}
package org.opendaylight.controller.netconf.it;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import io.netty.channel.ChannelFuture;
import java.io.IOException;
-import java.io.InputStream;
-import java.lang.management.ManagementFactory;
import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import javax.management.ObjectName;
import javax.xml.parsers.ParserConfigurationException;
-import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.IdentityTestModuleFactory;
import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleFactory;
import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleMXBean;
import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
-import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
+import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
-import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
-import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
public class NetconfITTest extends AbstractNetconfConfigTest {
- // TODO refactor, pull common code up to AbstractNetconfITTest
+ public static final int PORT = 12023;
+ public static final InetSocketAddress TCP_ADDRESS = new InetSocketAddress(LOOPBACK_ADDRESS, PORT);
- private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 12023);
-
-
- private NetconfMessage getConfig, getConfigCandidate, editConfig, closeSession;
- private DefaultCommitNotificationProducer commitNotificationProducer;
- private NetconfServerDispatcher dispatch;
-
- private NetconfClientDispatcherImpl clientDispatcher;
-
- static ModuleFactory[] FACTORIES = {new TestImplModuleFactory(), new DepTestImplModuleFactory(),
- new NetconfTestImplModuleFactory(), new IdentityTestModuleFactory(),
- new MultipleDependenciesModuleFactory()};
+ private NetconfMessage getConfigCandidate, editConfig, closeSession;
+ private NetconfClientDispatcher clientDispatcher;
@Before
public void setUp() throws Exception {
- initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
- FACTORIES
- ));
-
loadMessages();
-
- NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
- factoriesListener.onAddNetconfOperationServiceFactory(new NetconfOperationServiceFactoryImpl(getYangStore()));
-
- commitNotificationProducer = new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer());
-
- dispatch = createDispatcher(factoriesListener);
- ChannelFuture s = dispatch.createServer(tcpAddress);
- s.await();
-
- clientDispatcher = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
- }
-
- private NetconfServerDispatcher createDispatcher(NetconfOperationServiceFactoryListenerImpl factoriesListener) {
- return super.createDispatcher(factoriesListener, getNetconfMonitoringListenerService(), commitNotificationProducer);
+ clientDispatcher = getClientDispatcher();
}
- static NetconfMonitoringServiceImpl getNetconfMonitoringListenerService() {
- NetconfOperationProvider netconfOperationProvider = mock(NetconfOperationProvider.class);
- NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
- doReturn(Collections.<NetconfOperationService>emptySet()).when(snap).getServices();
- doReturn(snap).when(netconfOperationProvider).openSnapshot(anyString());
- return new NetconfMonitoringServiceImpl(netconfOperationProvider);
- }
-
- @After
- public void tearDown() throws Exception {
- commitNotificationProducer.close();
- clientDispatcher.close();
+ @Override
+ protected InetSocketAddress getTcpServerAddress() {
+ return TCP_ADDRESS;
}
private void loadMessages() throws IOException, SAXException, ParserConfigurationException {
this.editConfig = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/edit_config.xml");
- this.getConfig = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
this.getConfigCandidate = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/getConfig_candidate.xml");
this.closeSession = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/closeSession.xml");
}
- private HardcodedYangStoreService getYangStore() throws YangStoreException, IOException {
- final Collection<InputStream> yangDependencies = getBasicYangs();
- return new HardcodedYangStoreService(yangDependencies);
- }
-
- static Collection<InputStream> getBasicYangs() throws IOException {
-
- List<String> paths = Arrays.asList("/META-INF/yang/config.yang", "/META-INF/yang/rpc-context.yang",
- "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang", "/META-INF/yang/test-types.yang",
- "/META-INF/yang/ietf-inet-types.yang");
- final Collection<InputStream> yangDependencies = new ArrayList<>();
- List<String> failedToFind = new ArrayList<>();
- for (String path : paths) {
- InputStream resourceAsStream = NetconfITTest.class.getResourceAsStream(path);
- if (resourceAsStream == null) {
- failedToFind.add(path);
- } else {
- yangDependencies.add(resourceAsStream);
- }
- }
- assertEquals("Some yang files were not found", Collections.<String>emptyList(), failedToFind);
- return yangDependencies;
- }
-
-
@Test
public void testNetconfClientDemonstration() throws Exception {
- try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", clientDispatcher, getClientConfiguration(tcpAddress, 4000))) {
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", clientDispatcher, getClientConfiguration(TCP_ADDRESS, 4000))) {
- Set<String> capabilitiesFromNetconfServer = netconfClient.getCapabilities();
- long sessionId = netconfClient.getSessionId();
+ final Set<String> capabilitiesFromNetconfServer = netconfClient.getCapabilities();
+ final long sessionId = netconfClient.getSessionId();
// NetconfMessage can be created :
// new NetconfMessage(XmlUtil.readXmlToDocument("<xml/>"));
- NetconfMessage response = netconfClient.sendMessage(getConfig);
+ final NetconfMessage response = netconfClient.sendMessage(getGetConfig());
response.getDocument();
}
}
@Test
public void testTwoSessions() throws Exception {
- try (TestingNetconfClient netconfClient = new TestingNetconfClient("1", clientDispatcher, getClientConfiguration(tcpAddress, 10000))) {
- try (TestingNetconfClient netconfClient2 = new TestingNetconfClient("2", clientDispatcher, getClientConfiguration(tcpAddress, 10000))) {
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient("1", clientDispatcher, getClientConfiguration(TCP_ADDRESS, 10000))) {
+ try (TestingNetconfClient netconfClient2 = new TestingNetconfClient("2", clientDispatcher, getClientConfiguration(TCP_ADDRESS, 10000))) {
assertNotNull(netconfClient2.getCapabilities());
}
}
}
- @Ignore
- @Test
- public void waitingTest() throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- transaction.createModule(DepTestImplModuleFactory.NAME, "eb");
- transaction.commit();
- Thread.currentThread().suspend();
- }
-
@Test
public void rpcReplyContainsAllAttributesTest() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
- final String rpc = "<rpc message-id=\"5\" a=\"a\" b=\"44\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<get/>" + "</rpc>";
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
+ final String rpc = "<rpc message-id=\"5\" a=\"a\" b=\"44\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><get/>" + "</rpc>";
final Document doc = XmlUtil.readXmlToDocument(rpc);
final NetconfMessage message = netconfClient.sendMessage(new NetconfMessage(doc));
assertNotNull(message);
@Test
public void rpcReplyErrorContainsAllAttributesTest() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
- final String rpc = "<rpc message-id=\"1\" a=\"adada\" b=\"4\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<commit/>" + "</rpc>";
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
+ final String rpc = "<rpc message-id=\"1\" a=\"adada\" b=\"4\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><commit/>" + "</rpc>";
final Document doc = XmlUtil.readXmlToDocument(rpc);
final NetconfMessage message = netconfClient.sendMessage(new NetconfMessage(doc));
final NamedNodeMap expectedAttributes = doc.getDocumentElement().getAttributes();
@Test
public void rpcOutputContainsCorrectNamespace() throws Exception {
final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- ObjectName dep = transaction.createModule(DepTestImplModuleFactory.NAME, "instanceD");
- ObjectName impl = transaction.createModule(NetconfTestImplModuleFactory.NAME, "instance");
- NetconfTestImplModuleMXBean proxy = configRegistryClient
+ final ObjectName dep = transaction.createModule(DepTestImplModuleFactory.NAME, "instanceD");
+ final ObjectName impl = transaction.createModule(NetconfTestImplModuleFactory.NAME, "instance");
+ final NetconfTestImplModuleMXBean proxy = configRegistryClient
.newMXBeanProxy(impl, NetconfTestImplModuleMXBean.class);
proxy.setTestingDep(dep);
proxy.setSimpleShort((short) 0);
transaction.commit();
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
final String expectedNamespace = "urn:opendaylight:params:xml:ns:yang:controller:test:impl";
final String rpc = "<rpc message-id=\"5\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
@Test
public void testCloseSession() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
// edit config
Document rpcReply = netconfClient.sendMessage(this.editConfig)
@Test
public void testEditConfig() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
// send edit_config.xml
final Document rpcReply = netconfClient.sendMessage(this.editConfig).getDocument();
assertIsOK(rpcReply);
@Test
public void testValidate() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
// begin transaction
Document rpcReply = netconfClient.sendMessage(getConfigCandidate).getDocument();
assertEquals("data", XmlElement.fromDomDocument(rpcReply).getOnlyChildElement().getName());
}
private Document assertGetConfigWorks(final TestingNetconfClient netconfClient) throws InterruptedException, ExecutionException, TimeoutException, NetconfDocumentedException {
- return assertGetConfigWorks(netconfClient, this.getConfig);
+ return assertGetConfigWorks(netconfClient, getGetConfig());
}
private Document assertGetConfigWorks(final TestingNetconfClient netconfClient, final NetconfMessage getConfigMessage)
@Test
public void testGetConfig() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
assertGetConfigWorks(netconfClient);
}
}
@Test
public void createYangTestBasedOnYuma() throws Exception {
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
Document rpcReply = netconfClient.sendMessage(
XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_yang-test.xml"))
.getDocument();
final ObjectName on = new ObjectName(
"org.opendaylight.controller:instanceName=impl-dep-instance,type=Module,moduleFactoryName=impl-dep");
- Set<ObjectName> cfgBeans = configRegistryClient.lookupConfigBeans();
+ final Set<ObjectName> cfgBeans = configRegistryClient.lookupConfigBeans();
assertEquals(cfgBeans, Sets.newHashSet(on));
}
}
@Test
public void testIdRef() throws Exception {
- NetconfMessage editId = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
- NetconfMessage commit = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/commit.xml");
+ final NetconfMessage editId = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
+ final NetconfMessage commit = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/commit.xml");
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
assertIsOK(netconfClient.sendMessage(editId).getDocument());
assertIsOK(netconfClient.sendMessage(commit).getDocument());
- NetconfMessage response = netconfClient.sendMessage(getConfig);
+ final NetconfMessage response = netconfClient.sendMessage(getGetConfig());
- assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>"));
- assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>"));
- assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>"));
- assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), containsString("<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), containsString("<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), containsString("<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), containsString("<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>"));
- } catch (Exception e) {
+ } catch (final Exception e) {
fail(Throwables.getStackTraceAsString(e));
}
}
return ret;
}
-
@Test
public void testMultipleDependencies() throws Exception {
// push first xml, should add parent and d1,d2 dependencies
- try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
- Document rpcReply = netconfClient.sendMessage(
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
+ final Document rpcReply = netconfClient.sendMessage(
XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_multiple-deps1.xml"))
.getDocument();
assertIsOK(rpcReply);
commit(netconfClient);
}
// verify that parent.getTestingDeps == d1,d2
- MultipleDependenciesModuleMXBean parentProxy = configRegistryClient.newMXBeanProxy(
+ final MultipleDependenciesModuleMXBean parentProxy = configRegistryClient.newMXBeanProxy(
configRegistryClient.lookupConfigBean(MultipleDependenciesModuleFactory.NAME, "parent"),
MultipleDependenciesModuleMXBean.class);
{
- List<ObjectName> testingDeps = parentProxy.getTestingDeps();
+ final List<ObjectName> testingDeps = parentProxy.getTestingDeps();
assertEquals(2, testingDeps.size());
- Set<String> actualRefs = getServiceReferences(testingDeps);
+ final Set<String> actualRefs = getServiceReferences(testingDeps);
assertEquals(Sets.newHashSet("ref_d1", "ref_d2"), actualRefs);
}
mergeD3(parentProxy);
}
- public void mergeD3(MultipleDependenciesModuleMXBean parentProxy) throws Exception {
+ public void mergeD3(final MultipleDependenciesModuleMXBean parentProxy) throws Exception {
try (TestingNetconfClient netconfClient = new TestingNetconfClient(
- "test " + tcpAddress.toString(), clientDispatcher, getClientConfiguration(tcpAddress, 5000))) {
+ "test " + TCP_ADDRESS.toString(), clientDispatcher, getClientConfiguration(TCP_ADDRESS, 5000))) {
- Document rpcReply = netconfClient.sendMessage(
+ final Document rpcReply = netconfClient.sendMessage(
XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_multiple-deps2.xml"))
.getDocument();
assertIsOK(rpcReply);
commit(netconfClient);
}
{
- List<ObjectName> testingDeps = parentProxy.getTestingDeps();
+ final List<ObjectName> testingDeps = parentProxy.getTestingDeps();
assertEquals(3, testingDeps.size());
- Set<String> actualRefs = getServiceReferences(testingDeps);
+ final Set<String> actualRefs = getServiceReferences(testingDeps);
assertEquals(Sets.newHashSet("ref_d1", "ref_d2", "ref_d3"), actualRefs);
}
}
- public Set<String> getServiceReferences(List<ObjectName> testingDeps) {
+ public Set<String> getServiceReferences(final List<ObjectName> testingDeps) {
return new HashSet<>(Lists.transform(testingDeps, new Function<ObjectName, String>() {
@Override
- public String apply(ObjectName input) {
+ public String apply(final ObjectName input) {
return ObjectNameUtil.getReferenceName(input);
}
}));
}
- public void commit(TestingNetconfClient netconfClient) throws Exception {
- Document rpcReply;
+ public void commit(final TestingNetconfClient netconfClient) throws Exception {
+ final Document rpcReply;
rpcReply = netconfClient.sendMessage(XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/commit.xml"))
.getDocument();
assertIsOK(rpcReply);
+++ /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.it;
-
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.opendaylight.controller.netconf.util.test.XmlUnitUtil.assertContainsElementWithText;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.collect.Sets;
-import io.netty.channel.ChannelFuture;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import junit.framework.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
-import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
-import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
-import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl;
-import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
-import org.opendaylight.controller.netconf.mapping.api.Capability;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringActivator;
-import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOperationService;
-import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-
-public class NetconfMonitoringITTest extends AbstractNetconfConfigTest {
-
- private static final Logger logger = LoggerFactory.getLogger(NetconfITTest.class);
-
- private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 12023);
-
- @Mock
- private DefaultCommitNotificationProducer commitNot;
- private NetconfServerDispatcher dispatch;
-
- private NetconfClientDispatcherImpl clientDispatcher;
-
- private NetconfMonitoringServiceImpl monitoringService;
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, NetconfITTest.FACTORIES));
-
- monitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider());
-
- NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
- factoriesListener.onAddNetconfOperationServiceFactory(new NetconfOperationServiceFactoryImpl(getYangStore()));
- factoriesListener
- .onAddNetconfOperationServiceFactory(new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
- new NetconfMonitoringOperationService(monitoringService)));
-
-
- dispatch = createDispatcher(factoriesListener);
- ChannelFuture s = dispatch.createServer(tcpAddress);
- s.await();
-
- clientDispatcher = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
- }
-
- private HardcodedYangStoreService getYangStore() throws YangStoreException, IOException {
- final Collection<InputStream> yangDependencies = NetconfITTest.getBasicYangs();
- return new HardcodedYangStoreService(yangDependencies);
- }
-
- private NetconfServerDispatcher createDispatcher(
- NetconfOperationServiceFactoryListenerImpl factoriesListener) {
- return super.createDispatcher(factoriesListener, getNetconfMonitoringListenerService(logger, monitoringService), commitNot);
- }
-
- static SessionMonitoringService getNetconfMonitoringListenerService(final Logger logger, final NetconfMonitoringServiceImpl monitor) {
- return new SessionMonitoringService() {
- @Override
- public void onSessionUp(NetconfManagementSession session) {
- logger.debug("Management session up {}", session);
- monitor.onSessionUp(session);
- }
-
- @Override
- public void onSessionDown(NetconfManagementSession session) {
- logger.debug("Management session down {}", session);
- monitor.onSessionDown(session);
- }
- };
- }
-
-
- @Test
- public void testGetResponseFromMonitoring() throws Exception {
- try (TestingNetconfClient netconfClient = new TestingNetconfClient("client-monitoring", clientDispatcher, getClientConfiguration(tcpAddress, 4000))) {
- try (TestingNetconfClient netconfClient2 = new TestingNetconfClient("client-monitoring2", clientDispatcher, getClientConfiguration(tcpAddress, 4000))) {
- NetconfMessage response = netconfClient.sendMessage(loadGetMessage());
- assertSessionElementsInResponse(response.getDocument(), 2);
- }
- NetconfMessage response = netconfClient.sendMessage(loadGetMessage());
- assertSessionElementsInResponse(response.getDocument(), 1);
- }
- }
-
-
- @Test(timeout = 13 * 10000)
- public void testClientHelloWithAuth() throws Exception {
- String fileName = "netconfMessages/client_hello_with_auth.xml";
- String hello = XmlFileLoader.fileToString(fileName);
-
- fileName = "netconfMessages/get.xml";
- String get = XmlFileLoader.fileToString(fileName);
-
- Socket sock = new Socket(tcpAddress.getHostName(), tcpAddress.getPort());
- sock.getOutputStream().write(hello.getBytes(Charsets.UTF_8));
- String separator = "]]>]]>";
-
- sock.getOutputStream().write(separator.getBytes(Charsets.UTF_8));
- sock.getOutputStream().write(get.getBytes(Charsets.UTF_8));
- sock.getOutputStream().write(separator.getBytes(Charsets.UTF_8));
-
- StringBuilder responseBuilder = new StringBuilder();
-
- try (InputStream inputStream = sock.getInputStream();
- InputStreamReader reader = new InputStreamReader(inputStream);
- BufferedReader buff = new BufferedReader(reader)) {
- String line;
- while ((line = buff.readLine()) != null) {
-
- responseBuilder.append(line);
- responseBuilder.append(System.lineSeparator());
-
- if(line.contains("</rpc-reply>"))
- break;
- }
- }
-
- sock.close();
-
- String helloMsg = responseBuilder.substring(0, responseBuilder.indexOf(separator));
- Document doc = XmlUtil.readXmlToDocument(helloMsg);
- assertContainsElementWithText(doc, "urn:ietf:params:netconf:capability:candidate:1.0");
-
- String replyMsg = responseBuilder.substring(responseBuilder.indexOf(separator) + separator.length());
- doc = XmlUtil.readXmlToDocument(replyMsg);
- assertContainsElementWithText(doc, "tomas");
- }
-
- private void assertSessionElementsInResponse(Document document, int i) {
- int elementSize = document.getElementsByTagName("session-id").getLength();
- Assert.assertEquals("Incorrect number of session-id tags in " + XmlUtil.toString(document),i, elementSize);
- }
-
- private NetconfMessage loadGetMessage() throws Exception {
- return XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/get.xml");
- }
-
- public static NetconfOperationProvider getNetconfOperationProvider() throws Exception {
- NetconfOperationProvider factoriesListener = mock(NetconfOperationProvider.class);
- NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
- doNothing().when(snap).close();
- NetconfOperationService service = mock(NetconfOperationService.class);
- Set<Capability> caps = Sets.newHashSet();
- caps.add(new Capability() {
- @Override
- public String getCapabilityUri() {
- return "namespaceModuleRevision";
- }
-
- @Override
- public Optional<String> getModuleNamespace() {
- return Optional.of("namespace");
- }
-
- @Override
- public Optional<String> getModuleName() {
- return Optional.of("name");
- }
-
- @Override
- public Optional<String> getRevision() {
- return Optional.of("revision");
- }
-
- @Override
- public Optional<String> getCapabilitySchema() {
- return Optional.of("content");
- }
-
- @Override
- public Optional<List<String>> getLocation() {
- return Optional.absent();
- }
- });
-
- doReturn(caps).when(service).getCapabilities();
- Set<NetconfOperationService> services = Sets.newHashSet(service);
- doReturn(services).when(snap).getServices();
- doReturn(snap).when(factoriesListener).openSnapshot(anyString());
-
- return factoriesListener;
- }
-
-
-}
public final class SSLUtil {
- private SSLUtil() {
- }
+ private SSLUtil() {}
public static SSLContext initializeSecureContext(final String pass, final InputStream ksKeysFile, final InputStream ksTrustFile,
final String algorithm) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException,
*/
package org.opendaylight.controller.netconf.monitoring;
-import com.google.common.collect.Maps;
-
+import java.util.Collections;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import java.util.Map;
-
public class Get extends AbstractNetconfOperation {
private static final Logger logger = LoggerFactory.getLogger(Get.class);
private final NetconfMonitoringService netconfMonitor;
- public Get(NetconfMonitoringService netconfMonitor) {
+ public Get(final NetconfMonitoringService netconfMonitor) {
super(MonitoringConstants.MODULE_NAME);
this.netconfMonitor = netconfMonitor;
}
- private Element getPlaceholder(Document innerResult) throws NetconfDocumentedException {
- try {
- XmlElement rootElement = null;
- rootElement = XmlElement.fromDomElementWithExpected(innerResult.getDocumentElement(),
- XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.RFC4741_TARGET_NAMESPACE);
- return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
- } catch (RuntimeException e) {
- throw new IllegalArgumentException(String.format(
- "Input xml in wrong format, Expecting root element %s with child element %s, but was %s",
- XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.DATA_KEY,
- XmlUtil.toString(innerResult.getDocumentElement())), e);
- }
+ private Element getPlaceholder(final Document innerResult)
+ throws NetconfDocumentedException {
+ final XmlElement rootElement = XmlElement.fromDomElementWithExpected(
+ innerResult.getDocumentElement(), XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.RFC4741_TARGET_NAMESPACE);
+ return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
}
@Override
}
@Override
- public Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation)
+ public Document handle(final Document requestMessage, final NetconfOperationChainedExecution subsequentOperation)
throws NetconfDocumentedException {
if (subsequentOperation.isExecutionTermination()){
throw new NetconfDocumentedException(String.format("Subsequent netconf operation expected by %s", this),
}
try {
- Document innerResult = subsequentOperation.execute(requestMessage);
+ final Document innerResult = subsequentOperation.execute(requestMessage);
- NetconfState netconfMonitoring = new NetconfState(netconfMonitor);
+ final NetconfState netconfMonitoring = new NetconfState(netconfMonitor);
Element monitoringXmlElement = new JaxBSerializer().toXml(netconfMonitoring);
monitoringXmlElement = (Element) innerResult.importNode(monitoringXmlElement, true);
- Element monitoringXmlElementPlaceholder = getPlaceholder(innerResult);
+ final Element monitoringXmlElementPlaceholder = getPlaceholder(innerResult);
monitoringXmlElementPlaceholder.appendChild(monitoringXmlElement);
return innerResult;
- } catch (RuntimeException e) {
- String errorMessage = "Get operation for netconf-state subtree failed";
+ } catch (final RuntimeException e) {
+ final String errorMessage = "Get operation for netconf-state subtree failed";
logger.warn(errorMessage, e);
- Map<String, String> info = Maps.newHashMap();
- info.put(NetconfDocumentedException.ErrorSeverity.error.toString(), e.getMessage());
+
throw new NetconfDocumentedException(errorMessage, NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.operation_failed,
- NetconfDocumentedException.ErrorSeverity.error, info);
+ NetconfDocumentedException.ErrorSeverity.error,
+ Collections.singletonMap(NetconfDocumentedException.ErrorSeverity.error.toString(), e.getMessage()));
}
}
@Override
- protected Element handle(Document document, XmlElement message, NetconfOperationChainedExecution subsequentOperation)
+ protected Element handle(final Document document, final XmlElement message, final NetconfOperationChainedExecution subsequentOperation)
throws NetconfDocumentedException {
throw new UnsupportedOperationException("Never gets called");
}
public void start(final BundleContext context) {
monitor = new NetconfMonitoringServiceTracker(context);
monitor.open();
-
}
@Override
package org.opendaylight.controller.netconf.monitoring.osgi;
import com.google.common.base.Preconditions;
+import java.util.Hashtable;
import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
public class NetconfMonitoringServiceTracker extends ServiceTracker<NetconfMonitoringService, NetconfMonitoringService> {
private static final Logger logger = LoggerFactory.getLogger(NetconfMonitoringServiceTracker.class);
private ServiceRegistration<NetconfOperationServiceFactory> reg;
- NetconfMonitoringServiceTracker(BundleContext context) {
+ NetconfMonitoringServiceTracker(final BundleContext context) {
super(context, NetconfMonitoringService.class, null);
}
@Override
- public NetconfMonitoringService addingService(ServiceReference<NetconfMonitoringService> reference) {
+ public NetconfMonitoringService addingService(final ServiceReference<NetconfMonitoringService> reference) {
Preconditions.checkState(reg == null, "Monitoring service was already added");
- NetconfMonitoringService netconfMonitoringService = super.addingService(reference);
+ final NetconfMonitoringService netconfMonitoringService = super.addingService(reference);
final NetconfMonitoringOperationService operationService = new NetconfMonitoringOperationService(
netconfMonitoringService);
- NetconfOperationServiceFactory factory = new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
+ final NetconfOperationServiceFactory factory = new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
operationService);
- Dictionary<String, ?> props = new Hashtable<>();
- reg = context.registerService(NetconfOperationServiceFactory.class, factory, props);
+ reg = context.registerService(NetconfOperationServiceFactory.class, factory, new Hashtable<String, Object>());
return netconfMonitoringService;
}
@Override
- public void removedService(ServiceReference<NetconfMonitoringService> reference,
- NetconfMonitoringService netconfMonitoringService) {
+ public void removedService(final ServiceReference<NetconfMonitoringService> reference,
+ final NetconfMonitoringService netconfMonitoringService) {
if(reg!=null) {
try {
reg.unregister();
- } catch (Exception e) {
+ } catch (final Exception e) {
logger.warn("Ignoring exception while unregistering {}", reg, e);
}
}
public class JaxBSerializer {
- public Element toXml(NetconfState monitoringModel) {
- DOMResult res = null;
+ public Element toXml(final NetconfState monitoringModel) {
+ final DOMResult res;
try {
- JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
- Marshaller marshaller = jaxbContext.createMarshaller();
+ final JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
+ final Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
res = new DOMResult();
marshaller.marshal(monitoringModel, res);
- } catch (JAXBException e) {
+ } catch (final JAXBException e) {
throw new RuntimeException("Unable to serialize netconf state " + monitoringModel, e);
}
return ((Document)res.getNode()).getDocumentElement();
private Schemas schemas;
private Sessions sessions;
- public NetconfState(NetconfMonitoringService monitoringService) {
+ public NetconfState(final NetconfMonitoringService monitoringService) {
this.sessions = monitoringService.getSessions();
this.schemas = monitoringService.getSchemas();
}
- public NetconfState() {
- }
-
-
+ public NetconfState() {}
@XmlElementWrapper(name="schemas")
@XmlElement(name="schema")
return Collections2.transform(schemas.getSchema(), new Function<Schema, MonitoringSchema>() {
@Nullable
@Override
- public MonitoringSchema apply(@Nullable Schema input) {
+ public MonitoringSchema apply(@Nullable final Schema input) {
return new MonitoringSchema(input);
}
});
return Collections2.transform(sessions.getSession(), new Function<Session, MonitoringSession>() {
@Nullable
@Override
- public MonitoringSession apply(@Nullable Session input) {
+ public MonitoringSession apply(@Nullable final Session input) {
return new MonitoringSession(input);
}
});
--- /dev/null
+/*
+ * Copyright (c) 2014 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.monitoring;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.TestCase.fail;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+
+import java.util.Collections;
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SessionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
+import org.w3c.dom.Document;
+
+public class GetTest {
+
+ @Mock
+ private NetconfMonitoringService monitor;
+ @Mock
+ private Document request;
+ @Mock
+ private NetconfOperationChainedExecution subsequentOperation;
+ private Document incorrectSubsequentResult;
+ private Document correctSubsequentResult;
+
+ private Get get;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ incorrectSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>");
+ correctSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><data></data></rpc-reply>");
+
+ doReturn(new SessionsBuilder().setSession(Collections.<Session>emptyList()).build()).when(monitor).getSessions();
+ doReturn(new SchemasBuilder().setSchema(Collections.<Schema>emptyList()).build()).when(monitor).getSchemas();
+ doReturn(false).when(subsequentOperation).isExecutionTermination();
+
+ get = new Get(monitor);
+ }
+
+ @Test
+ public void testHandleNoSubsequent() throws Exception {
+ try {
+ get.handle(null, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
+ } catch (final NetconfDocumentedException e) {
+ assertNetconfDocumentedEx(e, NetconfDocumentedException.ErrorSeverity.error, NetconfDocumentedException.ErrorTag.operation_failed, NetconfDocumentedException.ErrorType.application);
+ return;
+ }
+
+ fail("Get should fail without subsequent operation");
+ }
+
+ @Test
+ public void testHandleWrongPlaceholder() throws Exception {
+ doReturn(incorrectSubsequentResult).when(subsequentOperation).execute(request);
+ try {
+ get.handle(request, subsequentOperation);
+ } catch (final NetconfDocumentedException e) {
+ assertNetconfDocumentedEx(e, NetconfDocumentedException.ErrorSeverity.error, NetconfDocumentedException.ErrorTag.invalid_value, NetconfDocumentedException.ErrorType.application);
+ return;
+ }
+
+ fail("Get should fail with wrong xml");
+ }
+
+ @Test
+ public void testHandleRuntimeEx() throws Exception {
+ doThrow(RuntimeException.class).when(subsequentOperation).execute(request);
+ try {
+ get.handle(request, subsequentOperation);
+ } catch (final NetconfDocumentedException e) {
+ assertNetconfDocumentedEx(e, NetconfDocumentedException.ErrorSeverity.error, NetconfDocumentedException.ErrorTag.operation_failed, NetconfDocumentedException.ErrorType.application);
+ assertEquals(1, e.getErrorInfo().size());
+ return;
+ }
+
+ fail("Get should fail with wrong xml");
+ }
+
+ @Test
+ public void testSuccessHandle() throws Exception {
+ doReturn(correctSubsequentResult).when(subsequentOperation).execute(request);
+ assertTrue(get.getHandlingPriority().getPriority().get() > HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.getPriority().get());
+ final Document result = get.handle(request, subsequentOperation);
+ assertThat(XmlUtil.toString(result), CoreMatchers.containsString("sessions"));
+ assertThat(XmlUtil.toString(result), CoreMatchers.containsString("schemas"));
+
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testHandle() throws Exception {
+ get.handle(null, null, null);
+
+ }
+
+ private void assertNetconfDocumentedEx(final NetconfDocumentedException e, final NetconfDocumentedException.ErrorSeverity severity, final NetconfDocumentedException.ErrorTag errorTag, final NetconfDocumentedException.ErrorType type) {
+ assertEquals(severity, e.getErrorSeverity());
+ assertEquals(errorTag, e.getErrorTag());
+ assertEquals(type, e.getErrorType());
+ }
+}
*/
package org.opendaylight.controller.netconf.monitoring.xml;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
import com.google.common.collect.Lists;
+import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.DomainName;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Host;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.NetconfTcp;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfSsh;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Transport;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SessionsBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.SchemaKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.DateAndTime;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.ZeroBasedCounter32;
-import org.w3c.dom.Element;
-
-import java.util.Date;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
public class JaxBSerializerTest {
@Test
public void testName() throws Exception {
- NetconfMonitoringService service = new NetconfMonitoringService() {
+ final NetconfMonitoringService service = new NetconfMonitoringService() {
@Override
public Sessions getSessions() {
@Override
public Schemas getSchemas() {
- return new SchemasBuilder().setSchema(Lists.<Schema>newArrayList()).build();
+ return new SchemasBuilder().setSchema(Lists.newArrayList(getMockSchema("id", "v1", Yang.class), getMockSchema("id2", "", Yang.class))).build();
}
};
- NetconfState model = new NetconfState(service);
- Element xml = new JaxBSerializer().toXml(model);
+ final NetconfState model = new NetconfState(service);
+ final String xml = XmlUtil.toString(new JaxBSerializer().toXml(model));
+
+ assertThat(xml, CoreMatchers.containsString(
+ "<schema>\n" +
+ "<format>yang</format>\n" +
+ "<identifier>id</identifier>\n" +
+ "<location>NETCONF</location>\n" +
+ "<namespace>localhost</namespace>\n" +
+ "<version>v1</version>\n" +
+ "</schema>\n"));
+
+ assertThat(xml, CoreMatchers.containsString(
+ "<session>\n" +
+ "<session-id>1</session-id>\n" +
+ "<in-bad-rpcs>0</in-bad-rpcs>\n" +
+ "<in-rpcs>0</in-rpcs>\n" +
+ "<login-time>loginTime</login-time>\n" +
+ "<out-notifications>0</out-notifications>\n" +
+ "<out-rpc-errors>0</out-rpc-errors>\n" +
+ "<ncme:session-identifier>client</ncme:session-identifier>\n" +
+ "<source-host>address/port</source-host>\n" +
+ "<transport>ncme:netconf-tcp</transport>\n" +
+ "<username>username</username>\n" +
+ "</session>"));
+ }
+
+ private Schema getMockSchema(final String id, final String version, final Class<Yang> format) {
+ final Schema mock = mock(Schema.class);
+
+ doReturn(format).when(mock).getFormat();
+ doReturn(id).when(mock).getIdentifier();
+ doReturn(new Uri("localhost")).when(mock).getNamespace();
+ doReturn(version).when(mock).getVersion();
+ doReturn(Lists.newArrayList(new Schema.Location(Schema.Location.Enumeration.NETCONF))).when(mock).getLocation();
+ doReturn(new SchemaKey(format, id, version)).when(mock).getKey();
+ return mock;
}
- private Session getMockSession(Class<? extends Transport> transportType) {
- Session mocked = mock(Session.class);
- Session1 mockedSession1 = mock(Session1.class);
+ private Session getMockSession(final Class<? extends Transport> transportType) {
+ final Session mocked = mock(Session.class);
+ final Session1 mockedSession1 = mock(Session1.class);
doReturn("client").when(mockedSession1).getSessionIdentifier();
doReturn(1L).when(mocked).getSessionId();
- doReturn(new DateAndTime(new Date().toString())).when(mocked).getLoginTime();
+ doReturn(new DateAndTime("loginTime")).when(mocked).getLoginTime();
doReturn(new Host(new DomainName("address/port"))).when(mocked).getSourceHost();
doReturn(new ZeroBasedCounter32(0L)).when(mocked).getInBadRpcs();
doReturn(new ZeroBasedCounter32(0L)).when(mocked).getInRpcs();
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>ganymed</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.openexi</groupId>
<artifactId>nagasena</artifactId>
<groupId>org.openexi</groupId>
<artifactId>nagasena-rta</artifactId>
</dependency>
-
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ </dependency>
</dependencies>
<build>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>ch.ethz.ssh2, com.google.common.base, com.google.common.collect, io.netty.buffer,
+ <Import-Package>org.apache.sshd.*, ch.ethz.ssh2, com.google.common.base, com.google.common.collect, io.netty.buffer,
io.netty.channel, io.netty.channel.socket, io.netty.handler.codec, io.netty.handler.ssl, io.netty.util,
io.netty.util.concurrent, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.sax,
javax.xml.transform.stream, org.opendaylight.controller.netconf.api,
Optional<NetconfHelloMessageAdditionalHeader> headerOptional = ((NetconfHelloMessage) msg)
.getAdditionalHeader();
- // If additional header present, serialize it along with netconf hello
- // message
+ // If additional header present, serialize it along with netconf hello message
if (headerOptional.isPresent()) {
out.writeBytes(headerOptional.get().toFormattedString().getBytes(Charsets.UTF_8));
}
*/
package org.opendaylight.controller.netconf.nettyutil.handler;
-import java.util.List;
-
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
+import java.util.List;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class NetconfXMLToMessageDecoder extends ByteToMessageDecoder {
private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToMessageDecoder.class);
@Override
- @VisibleForTesting
public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
if (in.readableBytes() != 0) {
package org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication;
-import ch.ethz.ssh2.Connection;
-
import java.io.IOException;
+import org.apache.sshd.ClientSession;
/**
* Class providing authentication facility to SSH handler.
*/
public abstract class AuthenticationHandler {
- public abstract void authenticate(Connection connection) throws IOException;
+
+ public abstract String getUsername();
+
+ public abstract org.apache.sshd.client.future.AuthFuture authenticate(final ClientSession session) throws IOException;
}
package org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication;
-import ch.ethz.ssh2.Connection;
-
import java.io.IOException;
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.future.AuthFuture;
/**
* Class Providing username/password authentication option to
- * {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshHandler}
+ * {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler}
*/
public class LoginPassword extends AuthenticationHandler {
private final String username;
}
@Override
- public void authenticate(Connection connection) throws IOException {
- boolean isAuthenticated = connection.authenticateWithPassword(username, password);
+ public String getUsername() {
+ return username;
+ }
- if (!isAuthenticated) {
- throw new IOException("Authentication failed.");
- }
+ @Override
+ public AuthFuture authenticate(final ClientSession session) throws IOException {
+ session.addPasswordIdentity(password);
+ return session.auth();
}
}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler.ssh.client;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelOutboundHandler;
+import io.netty.channel.ChannelOutboundHandlerAdapter;
+import io.netty.channel.ChannelPromise;
+import java.io.IOException;
+import java.net.SocketAddress;
+import org.apache.sshd.ClientChannel;
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.SshClient;
+import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.common.future.CloseFuture;
+import org.apache.sshd.common.future.SshFutureListener;
+import org.apache.sshd.common.io.IoInputStream;
+import org.apache.sshd.common.io.IoOutputStream;
+import org.apache.sshd.common.io.IoReadFuture;
+import org.apache.sshd.common.io.IoWriteFuture;
+import org.apache.sshd.common.io.WritePendingException;
+import org.apache.sshd.common.util.Buffer;
+import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Netty SSH handler class. Acts as interface between Netty and SSH library.
+ */
+public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
+
+ private static final Logger logger = LoggerFactory.getLogger(AsyncSshHandler.class);
+ public static final String SUBSYSTEM = "netconf";
+
+ public static final SshClient DEFAULT_CLIENT = SshClient.setUpDefaultClient();
+
+ public static final int SSH_DEFAULT_NIO_WORKERS = 8;
+
+ static {
+ // TODO make configurable, or somehow reuse netty threadpool
+ DEFAULT_CLIENT.setNioWorkers(SSH_DEFAULT_NIO_WORKERS);
+ DEFAULT_CLIENT.start();
+ }
+
+ private final AuthenticationHandler authenticationHandler;
+ private final SshClient sshClient;
+
+ private SshReadAsyncListener sshReadAsyncListener;
+ private SshWriteAsyncHandler sshWriteAsyncHandler;
+
+ private ClientChannel channel;
+ private ClientSession session;
+ private ChannelPromise connectPromise;
+
+
+ public static AsyncSshHandler createForNetconfSubsystem(final AuthenticationHandler authenticationHandler) throws IOException {
+ return new AsyncSshHandler(authenticationHandler, DEFAULT_CLIENT);
+ }
+
+ /**
+ *
+ * @param authenticationHandler
+ * @param sshClient started SshClient
+ * @throws IOException
+ */
+ public AsyncSshHandler(final AuthenticationHandler authenticationHandler, final SshClient sshClient) throws IOException {
+ this.authenticationHandler = Preconditions.checkNotNull(authenticationHandler);
+ this.sshClient = Preconditions.checkNotNull(sshClient);
+ // Start just in case
+ sshClient.start();
+ }
+
+ private void startSsh(final ChannelHandlerContext ctx, final SocketAddress address) {
+ logger.debug("Starting SSH to {} on channel: {}", address, ctx.channel());
+
+ final ConnectFuture sshConnectionFuture = sshClient.connect(authenticationHandler.getUsername(), address);
+ sshConnectionFuture.addListener(new SshFutureListener<ConnectFuture>() {
+ @Override
+ public void operationComplete(final ConnectFuture future) {
+ if (future.isConnected()) {
+ handleSshSessionCreated(future, ctx);
+ } else {
+ handleSshSetupFailure(ctx, future.getException());
+ }
+ }
+ });
+ }
+
+ private synchronized void handleSshSessionCreated(final ConnectFuture future, final ChannelHandlerContext ctx) {
+ try {
+ logger.trace("SSH session created on channel: {}", ctx.channel());
+
+ session = future.getSession();
+ final AuthFuture authenticateFuture = authenticationHandler.authenticate(session);
+ authenticateFuture.addListener(new SshFutureListener<AuthFuture>() {
+ @Override
+ public void operationComplete(final AuthFuture future) {
+ if (future.isSuccess()) {
+ handleSshAuthenticated(session, ctx);
+ } else {
+ handleSshSetupFailure(ctx, future.getException());
+ }
+ }
+ });
+ } catch (final IOException e) {
+ handleSshSetupFailure(ctx, e);
+ }
+ }
+
+ private synchronized void handleSshAuthenticated(final ClientSession session, final ChannelHandlerContext ctx) {
+ try {
+ logger.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(), session.getServerVersion());
+
+ channel = session.createSubsystemChannel(SUBSYSTEM);
+ channel.setStreaming(ClientChannel.Streaming.Async);
+ channel.open().addListener(new SshFutureListener<OpenFuture>() {
+ @Override
+ public void operationComplete(final OpenFuture future) {
+ if(future.isOpened()) {
+ handleSshChanelOpened(ctx);
+ } else {
+ handleSshSetupFailure(ctx, future.getException());
+ }
+ }
+ });
+
+
+ } catch (final IOException e) {
+ handleSshSetupFailure(ctx, e);
+ }
+ }
+
+ private synchronized void handleSshChanelOpened(final ChannelHandlerContext ctx) {
+ logger.trace("SSH subsystem channel opened successfully on channel: {}", ctx.channel());
+
+ connectPromise.setSuccess();
+ connectPromise = null;
+
+ sshReadAsyncListener = new SshReadAsyncListener(this, ctx, channel.getAsyncOut());
+ sshWriteAsyncHandler = new SshWriteAsyncHandler(this, channel.getAsyncIn());
+
+ ctx.fireChannelActive();
+ }
+
+ private synchronized void handleSshSetupFailure(final ChannelHandlerContext ctx, final Throwable e) {
+ logger.warn("Unable to setup SSH connection on channel: {}", ctx.channel(), e);
+ connectPromise.setFailure(e);
+ connectPromise = null;
+ throw new IllegalStateException("Unable to setup SSH connection on channel: " + ctx.channel(), e);
+ }
+
+ @Override
+ public synchronized void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
+ sshWriteAsyncHandler.write(ctx, msg, promise);
+ }
+
+ @Override
+ public synchronized void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) throws Exception {
+ this.connectPromise = promise;
+ startSsh(ctx, remoteAddress);
+ }
+
+ @Override
+ public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
+ disconnect(ctx, promise);
+ }
+
+ @Override
+ public synchronized void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) {
+ if(sshReadAsyncListener != null) {
+ sshReadAsyncListener.close();
+ }
+
+ if(sshWriteAsyncHandler != null) {
+ sshWriteAsyncHandler.close();
+ }
+
+ if(session!= null && !session.isClosed() && !session.isClosing()) {
+ session.close(false).addListener(new SshFutureListener<CloseFuture>() {
+ @Override
+ public void operationComplete(final CloseFuture future) {
+ if (future.isClosed() == false) {
+ session.close(true);
+ }
+ session = null;
+ }
+ });
+ }
+
+ channel = null;
+ promise.setSuccess();
+
+ logger.debug("SSH session closed on channel: {}", ctx.channel());
+ ctx.fireChannelInactive();
+ }
+
+ /**
+ * Listener over async input stream from SSH session.
+ * This listeners schedules reads in a loop until the session is closed or read fails.
+ */
+ private static class SshReadAsyncListener implements SshFutureListener<IoReadFuture>, AutoCloseable {
+ private static final int BUFFER_SIZE = 8192;
+
+ private final ChannelOutboundHandler asyncSshHandler;
+ private final ChannelHandlerContext ctx;
+
+ private IoInputStream asyncOut;
+ private Buffer buf;
+ private IoReadFuture currentReadFuture;
+
+ public SshReadAsyncListener(final ChannelOutboundHandler asyncSshHandler, final ChannelHandlerContext ctx, final IoInputStream asyncOut) {
+ this.asyncSshHandler = asyncSshHandler;
+ this.ctx = ctx;
+ this.asyncOut = asyncOut;
+ buf = new Buffer(BUFFER_SIZE);
+ asyncOut.read(buf).addListener(this);
+ }
+
+ @Override
+ public synchronized void operationComplete(final IoReadFuture future) {
+ if(future.getException() != null) {
+
+ if(asyncOut.isClosed() || asyncOut.isClosing()) {
+
+ // Ssh dropped
+ logger.debug("Ssh session dropped on channel: {}", ctx.channel(), future.getException());
+ invokeDisconnect();
+ return;
+ } else {
+ logger.warn("Exception while reading from SSH remote on channel {}", ctx.channel(), future.getException());
+ invokeDisconnect();
+ }
+ }
+
+ if (future.getRead() > 0) {
+ ctx.fireChannelRead(Unpooled.wrappedBuffer(buf.array(), 0, future.getRead()));
+
+ // Schedule next read
+ buf = new Buffer(BUFFER_SIZE);
+ currentReadFuture = asyncOut.read(buf);
+ currentReadFuture.addListener(this);
+ }
+ }
+
+ private void invokeDisconnect() {
+ try {
+ asyncSshHandler.disconnect(ctx, ctx.newPromise());
+ } catch (final Exception e) {
+ // This should not happen
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public synchronized void close() {
+ // Remove self as listener on close to prevent reading from closed input
+ if(currentReadFuture != null) {
+ currentReadFuture.removeListener(this);
+ }
+
+ asyncOut = null;
+ }
+ }
+
+ private static final class SshWriteAsyncHandler implements AutoCloseable {
+ public static final int MAX_PENDING_WRITES = 100;
+
+ private final ChannelOutboundHandler channelHandler;
+ private IoOutputStream asyncIn;
+
+ // Counter that holds the amount of pending write messages
+ // Pending write can occur in case remote window is full
+ // In such case, we need to wait for the pending write to finish
+ private int pendingWriteCounter;
+ // Last write future, that can be pending
+ private IoWriteFuture lastWriteFuture;
+
+ public SshWriteAsyncHandler(final ChannelOutboundHandler channelHandler, final IoOutputStream asyncIn) {
+ this.channelHandler = channelHandler;
+ this.asyncIn = asyncIn;
+ }
+
+ int c = 0;
+
+ public synchronized void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
+ try {
+ if(asyncIn == null || asyncIn.isClosed() || asyncIn.isClosing()) {
+ // If we are closed/closing, set immediate fail
+ promise.setFailure(new IllegalStateException("Channel closed"));
+ } else {
+ lastWriteFuture = asyncIn.write(toBuffer(msg));
+ lastWriteFuture.addListener(new SshFutureListener<IoWriteFuture>() {
+
+ @Override
+ public void operationComplete(final IoWriteFuture future) {
+ ((ByteBuf) msg).release();
+
+ // Notify success or failure
+ if (future.isWritten()) {
+ promise.setSuccess();
+ } else {
+ promise.setFailure(future.getException());
+ }
+
+ // Reset last pending future
+ synchronized (SshWriteAsyncHandler.this) {
+ lastWriteFuture = null;
+ }
+ }
+ });
+ }
+ } catch (final WritePendingException e) {
+ // Check limit for pending writes
+ pendingWriteCounter++;
+ if(pendingWriteCounter > MAX_PENDING_WRITES) {
+ handlePendingFailed(ctx, new IllegalStateException("Too much pending writes(" + MAX_PENDING_WRITES + ") on channel: " + ctx.channel() +
+ ", remote window is not getting read or is too small"));
+ }
+
+ logger.debug("Write pending to SSH remote on channel: {}, current pending count: {}", ctx.channel(), pendingWriteCounter);
+
+ // In case of pending, re-invoke write after pending is finished
+ lastWriteFuture.addListener(new SshFutureListener<IoWriteFuture>() {
+ @Override
+ public void operationComplete(final IoWriteFuture future) {
+ if (future.isWritten()) {
+ synchronized (SshWriteAsyncHandler.this) {
+ // Pending done, decrease counter
+ pendingWriteCounter--;
+ }
+ write(ctx, msg, promise);
+ } else {
+ // Cannot reschedule pending, fail
+ handlePendingFailed(ctx, e);
+ }
+ }
+
+ });
+ }
+ }
+
+ private void handlePendingFailed(final ChannelHandlerContext ctx, final Exception e) {
+ logger.warn("Exception while writing to SSH remote on channel {}", ctx.channel(), e);
+ try {
+ channelHandler.disconnect(ctx, ctx.newPromise());
+ } catch (final Exception ex) {
+ // This should not happen
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ @Override
+ public void close() {
+ asyncIn = null;
+ }
+
+ private Buffer toBuffer(final Object msg) {
+ // TODO Buffer vs ByteBuf translate, Can we handle that better ?
+ Preconditions.checkState(msg instanceof ByteBuf);
+ final ByteBuf byteBuf = (ByteBuf) msg;
+ final byte[] temp = new byte[byteBuf.readableBytes()];
+ byteBuf.readBytes(temp, 0, byteBuf.readableBytes());
+ return new Buffer(temp);
+ }
+
+ }
+}
+++ /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.nettyutil.handler.ssh.client;
-
-import java.io.IOException;
-
-/**
- * Abstract class providing mechanism of invoking various SSH level services.
- * Class is not allowed to be extended, as it provides its own implementations via instance initiators.
- */
-abstract class Invoker {
- private boolean invoked = false;
-
- private Invoker() {
- }
-
- protected boolean isInvoked() {
- return invoked;
- }
-
- public void setInvoked() {
- this.invoked = true;
- }
-
- abstract void invoke(SshSession session) throws IOException;
-
- public static Invoker netconfSubsystem(){
- return subsystem("netconf");
- }
-
- public static Invoker subsystem(final String subsystem) {
- return new Invoker() {
- @Override
- synchronized void invoke(SshSession session) throws IOException {
- if (isInvoked()) {
- throw new IllegalStateException("Already invoked.");
- }
- try {
- session.startSubSystem(subsystem);
- } finally {
- setInvoked();
- }
- }
- };
- }
-}
+++ /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.nettyutil.handler.ssh.client;
-
-import ch.ethz.ssh2.Connection;
-import ch.ethz.ssh2.Session;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.VirtualSocket;
-
-/**
- * Wrapper class around GANYMED SSH java library.
- */
-class SshClient {
- private final VirtualSocket socket;
- private final Map<Integer, SshSession> openSessions = new HashMap<>();
- private final AuthenticationHandler authenticationHandler;
- private Connection connection;
-
- public SshClient(VirtualSocket socket, AuthenticationHandler authenticationHandler) throws IOException {
- this.socket = socket;
- this.authenticationHandler = authenticationHandler;
- }
-
- public SshSession openSession() throws IOException {
- if (connection == null) {
- connect();
- }
-
- Session session = connection.openSession();
- SshSession sshSession = new SshSession(session);
- openSessions.put(openSessions.size(), sshSession);
-
- return sshSession;
- }
-
- private void connect() throws IOException {
- connection = new Connection(socket);
-
- connection.connect();
- authenticationHandler.authenticate(connection);
- }
-
-
- public void close() {
- for (SshSession session : openSessions.values()){
- session.close();
- }
-
- openSessions.clear();
-
- if (connection != null) {
- connection.close();
- }
- }
-
- @Override
- public String toString() {
- return "SshClient{" +
- "socket=" + socket +
- '}';
- }
-}
+++ /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.nettyutil.handler.ssh.client;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelPromise;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Worker thread class. Handles all downstream and upstream events in SSH Netty
- * pipeline.
- */
-class SshClientAdapter implements Runnable {
- private static final Logger logger = LoggerFactory.getLogger(SshClientAdapter.class);
-
- private static final int BUFFER_SIZE = 1024;
-
- private final SshClient sshClient;
- private final Invoker invoker;
-
- private OutputStream stdIn;
-
- private final Queue<ByteBuf> postponed = new LinkedList<>();
-
- private ChannelHandlerContext ctx;
- private ChannelPromise disconnectPromise;
-
- private final AtomicBoolean stopRequested = new AtomicBoolean(false);
-
- private final Object lock = new Object();
-
- public SshClientAdapter(final SshClient sshClient, final Invoker invoker) {
- this.sshClient = sshClient;
- this.invoker = invoker;
- }
-
- // TODO ganymed spawns a Thread that receives the data from remote inside TransportManager
- // Get rid of this thread and reuse Ganymed internal thread (not sure if its possible without modifications in ganymed)
- public void run() {
- try {
- final SshSession session = sshClient.openSession();
- invoker.invoke(session);
- final InputStream stdOut = session.getStdout();
-
- synchronized (lock) {
- stdIn = session.getStdin();
- while (postponed.peek() != null) {
- writeImpl(postponed.poll());
- }
- }
-
- while (!stopRequested.get()) {
- final byte[] readBuff = new byte[BUFFER_SIZE];
- final int c = stdOut.read(readBuff);
- if (c == -1) {
- continue;
- }
-
- ctx.fireChannelRead(Unpooled.copiedBuffer(readBuff, 0, c));
- }
- } catch (final Exception e) {
- logger.error("Unexpected exception", e);
- } finally {
- sshClient.close();
-
- synchronized (lock) {
- if (disconnectPromise != null) {
- ctx.disconnect(disconnectPromise);
- }
- }
- }
- }
-
- // TODO: needs rework to match netconf framer API.
- public void write(final ByteBuf message) throws IOException {
- synchronized (lock) {
- if (stdIn == null) {
- postponed.add(message);
- return;
- }
- writeImpl(message);
- }
- }
-
- private void writeImpl(final ByteBuf message) throws IOException {
- message.getBytes(0, stdIn, message.readableBytes());
- message.release();
- stdIn.flush();
- }
-
- public void stop(final ChannelPromise promise) {
- synchronized (lock) {
- stopRequested.set(true);
- disconnectPromise = promise;
- }
- }
-
- public Thread start(final ChannelHandlerContext ctx, final ChannelFuture channelFuture) {
- checkArgument(channelFuture.isSuccess());
- checkNotNull(ctx.channel().remoteAddress());
- synchronized (this) {
- checkState(this.ctx == null);
- this.ctx = ctx;
- }
- final String threadName = toString();
- final Thread thread = new Thread(this, threadName);
- thread.start();
- return thread;
- }
-
- @Override
- public String toString() {
- return "SshClientAdapter{" +
- "sshClient=" + sshClient +
- '}';
- }
-}
+++ /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.nettyutil.handler.ssh.client;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelOutboundHandlerAdapter;
-import io.netty.channel.ChannelPromise;
-import java.io.IOException;
-import java.net.SocketAddress;
-import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.VirtualSocket;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Netty SSH handler class. Acts as interface between Netty and SSH library. All standard Netty message handling
- * stops at instance of this class. All downstream events are handed of to wrapped {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshClientAdapter};
- */
-public class SshHandler extends ChannelOutboundHandlerAdapter {
- private static final Logger logger = LoggerFactory.getLogger(SshHandler.class);
- private static final String SOCKET = "socket";
-
- private final VirtualSocket virtualSocket = new VirtualSocket();
- private final SshClientAdapter sshClientAdapter;
-
-
- public static SshHandler createForNetconfSubsystem(AuthenticationHandler authenticationHandler) throws IOException {
- return new SshHandler(authenticationHandler, Invoker.netconfSubsystem());
- }
-
-
- public SshHandler(AuthenticationHandler authenticationHandler, Invoker invoker) throws IOException {
- SshClient sshClient = new SshClient(virtualSocket, authenticationHandler);
- this.sshClientAdapter = new SshClientAdapter(sshClient, invoker);
- }
-
- @Override
- public void handlerAdded(ChannelHandlerContext ctx){
- if (ctx.channel().pipeline().get(SOCKET) == null) {
- ctx.channel().pipeline().addFirst(SOCKET, virtualSocket);
- }
- }
-
- @Override
- public void handlerRemoved(ChannelHandlerContext ctx) {
- if (ctx.channel().pipeline().get(SOCKET) != null) {
- ctx.channel().pipeline().remove(SOCKET);
- }
- }
-
- @Override
- public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws IOException {
- this.sshClientAdapter.write((ByteBuf) msg);
- }
-
- @Override
- public void connect(final ChannelHandlerContext ctx,
- SocketAddress remoteAddress,
- SocketAddress localAddress,
- ChannelPromise promise) {
- ctx.connect(remoteAddress, localAddress, promise);
-
- promise.addListener(new ChannelFutureListener() {
- public void operationComplete(ChannelFuture channelFuture) {
- if (channelFuture.isSuccess()) {
- sshClientAdapter.start(ctx, channelFuture);
- } else {
- logger.debug("Failed to connect to remote host");
- }
- }}
- );
- }
-
- @Override
- public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) {
- sshClientAdapter.stop(promise);
- }
-}
+++ /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.nettyutil.handler.ssh.client;
-
-import ch.ethz.ssh2.Session;
-import ch.ethz.ssh2.channel.Channel;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Wrapper class for proprietary SSH sessions implementations
- */
-class SshSession implements Closeable {
- private final Session session;
-
- public SshSession(final Session session) {
- this.session = session;
- }
-
- public void startSubSystem(final String name) throws IOException {
- session.startSubSystem(name);
- }
-
- public InputStream getStdout() {
- return session.getStdout();
- }
-
- // FIXME according to http://www.ganymed.ethz.ch/ssh2/FAQ.html#blocking you should read data from both stdout and stderr to prevent window filling up (since stdout and stderr share a window)
- // FIXME stdErr is not used anywhere
- public InputStream getStderr() {
- return session.getStderr();
- }
-
- public OutputStream getStdin() {
- return session.getStdin();
- }
-
- @Override
- public void close() {
- if (session.getState() == Channel.STATE_OPEN || session.getState() == Channel.STATE_OPENING) {
- session.close();
- }
- }
-}
+++ /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.nettyutil.handler.ssh.virtualsocket;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Class provides {@link InputStream} functionality to users of virtual socket.
- */
-public class ChannelInputStream extends InputStream implements ChannelInboundHandler {
- private final Object lock = new Object();
- private final ByteBuf bb = Unpooled.buffer();
-
- @Override
- public int read(byte b[], int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off < 0 || len < 0 || len > b.length - off) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return 0;
- }
-
- int bytesRead = 1;
- synchronized (lock) {
- int c = read();
-
- b[off] = (byte)c;
-
- if(this.bb.readableBytes() == 0) {
- return bytesRead;
- }
-
- int ltr = len-1;
- ltr = (ltr <= bb.readableBytes()) ? ltr : bb.readableBytes();
-
- bb.readBytes(b, 1, ltr);
- bytesRead += ltr;
- }
- return bytesRead;
- }
-
- @Override
- public int read() throws IOException {
- synchronized (lock) {
- while (this.bb.readableBytes() == 0) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IllegalStateException(e);
- }
- }
- return this.bb.readByte() & 0xFF;
- }
- }
-
- @Override
- public int available() throws IOException {
- synchronized (lock) {
- return this.bb.readableBytes();
- }
- }
-
- public void channelRegistered(ChannelHandlerContext ctx) {
- ctx.fireChannelRegistered();
- }
-
- public void channelUnregistered(ChannelHandlerContext ctx) {
- ctx.fireChannelUnregistered();
- }
-
- public void channelActive(ChannelHandlerContext ctx) {
- ctx.fireChannelActive();
- }
-
- public void channelInactive(ChannelHandlerContext ctx) {
- ctx.fireChannelInactive();
- }
-
- public void channelRead(ChannelHandlerContext ctx, Object o) {
- synchronized(lock) {
- this.bb.discardReadBytes();
- this.bb.writeBytes((ByteBuf) o);
- ((ByteBuf) o).release();
- lock.notifyAll();
- }
- }
-
- public void channelReadComplete(ChannelHandlerContext ctx) {
- ctx.fireChannelReadComplete();
- }
-
- public void userEventTriggered(ChannelHandlerContext ctx, Object o) {
- ctx.fireUserEventTriggered(o);
- }
-
- public void channelWritabilityChanged(ChannelHandlerContext ctx) {
- ctx.fireChannelWritabilityChanged();
- }
-
- public void handlerAdded(ChannelHandlerContext ctx) {
- }
-
- public void handlerRemoved(ChannelHandlerContext ctx) {
- }
-
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable throwable) {
- ctx.fireExceptionCaught(throwable);
- }
-}
-
+++ /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.nettyutil.handler.ssh.virtualsocket;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelOutboundHandler;
-import io.netty.channel.ChannelPromise;
-
-import java.io.OutputStream;
-import java.net.SocketAddress;
-
-/**
- * Class provides {@link OutputStream) functionality to users of virtual socket.
- */
-public class ChannelOutputStream extends OutputStream implements ChannelOutboundHandler {
- private final Object lock = new Object();
- private ByteBuf buff = Unpooled.buffer();
- private ChannelHandlerContext ctx;
-
- @Override
- public void flush() {
- synchronized(lock) {
- ctx.writeAndFlush(buff).awaitUninterruptibly();
- buff = Unpooled.buffer();
- }
- }
-
- @Override
- public void write(int b) {
- synchronized(lock) {
- buff.writeByte(b);
- }
- }
-
- public void bind(ChannelHandlerContext ctx, SocketAddress localAddress,
- ChannelPromise promise) {
- ctx.bind(localAddress, promise);
- }
-
- public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress,
- SocketAddress localAddress, ChannelPromise promise) {
- this.ctx = ctx;
- ctx.connect(remoteAddress, localAddress, promise);
- }
-
- public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) {
- ctx.disconnect(promise);
- }
-
- public void close(ChannelHandlerContext ctx, ChannelPromise promise) {
- ctx.close(promise);
- }
-
- public void deregister(ChannelHandlerContext ctx, ChannelPromise channelPromise) {
- ctx.deregister(channelPromise);
- }
-
- public void read(ChannelHandlerContext ctx) {
- ctx.read();
- }
-
- public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
- // pass
- }
-
- public void flush(ChannelHandlerContext ctx) {
- // pass
- }
-
- public void handlerAdded(ChannelHandlerContext ctx)
- throws Exception {
- }
-
- public void handlerRemoved(ChannelHandlerContext ctx)
- throws Exception {
- }
-
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
- ctx.fireExceptionCaught(cause);
- }
-}
+++ /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.nettyutil.handler.ssh.virtualsocket;
-
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelHandlerContext;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.nio.channels.SocketChannel;
-
-/**
- * Handler class providing Socket functionality to OIO client application. By using VirtualSocket user can
- * use OIO application in asynchronous environment and NIO EventLoop. Using VirtualSocket OIO applications
- * are able to use full potential of NIO environment.
- */
-//TODO: refactor - socket should be created when connection is established
-public class VirtualSocket extends Socket implements ChannelHandler {
- private static final String INPUT_STREAM = "inputStream";
- private static final String OUTPUT_STREAM = "outputStream";
-
- private final ChannelInputStream chais = new ChannelInputStream();
- private final ChannelOutputStream chaos = new ChannelOutputStream();
- private ChannelHandlerContext ctx;
-
-
- public InputStream getInputStream() {
- return this.chais;
- }
-
- public OutputStream getOutputStream() {
- return this.chaos;
- }
-
- public void handlerAdded(ChannelHandlerContext ctx) {
- this.ctx = ctx;
-
- if (ctx.channel().pipeline().get(OUTPUT_STREAM) == null) {
- ctx.channel().pipeline().addFirst(OUTPUT_STREAM, chaos);
- }
-
- if (ctx.channel().pipeline().get(INPUT_STREAM) == null) {
- ctx.channel().pipeline().addFirst(INPUT_STREAM, chais);
- }
- }
-
- public void handlerRemoved(ChannelHandlerContext ctx) {
- if (ctx.channel().pipeline().get(OUTPUT_STREAM) != null) {
- ctx.channel().pipeline().remove(OUTPUT_STREAM);
- }
-
- if (ctx.channel().pipeline().get(INPUT_STREAM) != null) {
- ctx.channel().pipeline().remove(INPUT_STREAM);
- }
- }
-
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable throwable) {
- // TODO exceptionCaught is deprecated transform this handler
- ctx.fireExceptionCaught(throwable);
- }
-
-
- @Override
- public void connect(SocketAddress endpoint) throws IOException {}
-
- @Override
- public void connect(SocketAddress endpoint, int timeout) throws IOException {}
-
- @Override
- public void bind(SocketAddress bindpoint) throws IOException {}
-
- @Override
- public InetAddress getInetAddress() {
- InetSocketAddress isa = getInetSocketAddress();
- return isa.getAddress();
- }
-
- @Override
- public InetAddress getLocalAddress() {return null;}
-
- @Override
- public int getPort() {
- return getInetSocketAddress().getPort();
- }
-
- private InetSocketAddress getInetSocketAddress() {
- return (InetSocketAddress)getRemoteSocketAddress();
- }
-
- @Override
- public int getLocalPort() {return -1;}
-
- @Override
- public SocketAddress getRemoteSocketAddress() {
- return this.ctx.channel().remoteAddress();
- }
-
- @Override
- public SocketAddress getLocalSocketAddress() {
- return this.ctx.channel().localAddress();
- }
-
- @Override
- public SocketChannel getChannel() {return null;}
-
- @Override
- public void setTcpNoDelay(boolean on) throws SocketException {}
-
- @Override
- public boolean getTcpNoDelay() throws SocketException {return false;}
-
- @Override
- public void setSoLinger(boolean on, int linger) throws SocketException {}
-
- @Override
- public int getSoLinger() throws SocketException {return -1;}
-
- @Override
- public void sendUrgentData(int data) throws IOException {}
-
- @Override
- public void setOOBInline(boolean on) throws SocketException {}
-
- @Override
- public boolean getOOBInline() throws SocketException {return false;}
-
- @Override
- public synchronized void setSoTimeout(int timeout) throws SocketException {}
-
- @Override
- public synchronized int getSoTimeout() throws SocketException {return -1;}
-
- @Override
- public synchronized void setSendBufferSize(int size) throws SocketException {}
-
- @Override
- public synchronized int getSendBufferSize() throws SocketException {return -1;}
-
- @Override
- public synchronized void setReceiveBufferSize(int size) throws SocketException {}
-
- @Override
- public synchronized int getReceiveBufferSize() throws SocketException {return -1;}
-
- @Override
- public void setKeepAlive(boolean on) throws SocketException {}
-
- @Override
- public boolean getKeepAlive() throws SocketException {return false;}
-
- @Override
- public void setTrafficClass(int tc) throws SocketException {}
-
- @Override
- public int getTrafficClass() throws SocketException {return -1;}
-
- @Override
- public void setReuseAddress(boolean on) throws SocketException {}
-
- @Override
- public boolean getReuseAddress() throws SocketException {return false;}
-
- @Override
- public synchronized void close() throws IOException {}
-
- @Override
- public void shutdownInput() throws IOException {}
-
- @Override
- public void shutdownOutput() throws IOException {}
-
- @Override
- public String toString() {
- return "VirtualSocket{" + getInetAddress() + ":" + getPort() + "}";
- }
-
- @Override
- public boolean isConnected() {return false;}
-
- @Override
- public boolean isBound() {return false;}
-
- @Override
- public boolean isClosed() {return false;}
-
- @Override
- public boolean isInputShutdown() {return false;}
-
- @Override
- public boolean isOutputShutdown() {return false;}
-
- @Override
- public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {}
-}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doAnswer;
+
+import com.google.common.collect.Lists;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
+
+public class ChunkedFramingMechanismEncoderTest {
+
+ private int chunkSize;
+ @Mock
+ private ChannelHandlerContext ctx;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ chunkSize = 256;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalSize() throws Exception {
+ new ChunkedFramingMechanismEncoder(10);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalSizeMax() throws Exception {
+ new ChunkedFramingMechanismEncoder(Integer.MAX_VALUE);
+ }
+
+ @Test
+ public void testEncode() throws Exception {
+ final List<ByteBuf> chunks = Lists.newArrayList();
+ doAnswer(new Answer() {
+ @Override
+ public Object answer(final InvocationOnMock invocation) throws Throwable {
+ chunks.add((ByteBuf) invocation.getArguments()[0]);
+ return null;
+ }
+ }).when(ctx).write(anyObject());
+
+ final ChunkedFramingMechanismEncoder encoder = new ChunkedFramingMechanismEncoder(chunkSize);
+ final int lastChunkSize = 20;
+ final ByteBuf src = Unpooled.wrappedBuffer(getByteArray(chunkSize * 4 + lastChunkSize));
+ final ByteBuf destination = Unpooled.buffer();
+ encoder.encode(ctx, src, destination);
+ assertEquals(4, chunks.size());
+
+ final int framingSize = "#256\n".getBytes().length + 1/* new line at end */;
+
+ for (final ByteBuf chunk : chunks) {
+ assertEquals(chunkSize + framingSize, chunk.readableBytes());
+ }
+
+ final int lastFramingSize = "#20\n".length() + NetconfMessageConstants.END_OF_CHUNK.length + 1/* new line at end */;
+ assertEquals(lastChunkSize + lastFramingSize, destination.readableBytes());
+ }
+
+ private byte[] getByteArray(final int size) {
+ final byte[] bytes = new byte[size];
+ for (int i = 0; i < size; i++) {
+ bytes[i] = 'a';
+ }
+ return bytes;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
+
+public class EOMFramingMechanismEncoderTest {
+
+ @Test
+ public void testEncode() throws Exception {
+ final byte[] content = new byte[50];
+ final ByteBuf source = Unpooled.wrappedBuffer(content);
+ final ByteBuf destination = Unpooled.buffer();
+ new EOMFramingMechanismEncoder().encode(null, source, destination);
+
+ assertEquals(Unpooled.wrappedBuffer(source.array(), NetconfMessageConstants.END_OF_MESSAGE), destination);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler;
+
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
+
+public class FramingMechanismHandlerFactoryTest {
+
+ @Test
+ public void testCreate() throws Exception {
+ MatcherAssert.assertThat(FramingMechanismHandlerFactory
+ .createHandler(FramingMechanism.CHUNK), CoreMatchers
+ .instanceOf(ChunkedFramingMechanismEncoder.class));
+ MatcherAssert.assertThat(FramingMechanismHandlerFactory
+ .createHandler(FramingMechanism.EOM), CoreMatchers
+ .instanceOf(EOMFramingMechanismEncoder.class));
+ }
+}
\ No newline at end of file
*/
package org.opendaylight.controller.netconf.nettyutil.handler;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import junit.framework.Assert;
+import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.List;
-
public class NetconfChunkAggregatorTest {
private static final String CHUNKED_MESSAGE = "\n#4\n" +
@Test
public void testMultipleChunks() throws Exception {
- List<Object> output = Lists.newArrayList();
- ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE.getBytes(Charsets.UTF_8));
+ final List<Object> output = Lists.newArrayList();
+ final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE.getBytes(Charsets.UTF_8));
agr.decode(null, input, output);
- Assert.assertEquals(1, output.size());
- ByteBuf chunk = (ByteBuf) output.get(0);
+ assertEquals(1, output.size());
+ final ByteBuf chunk = (ByteBuf) output.get(0);
- Assert.assertEquals(EXPECTED_MESSAGE, chunk.toString(Charsets.UTF_8));
+ assertEquals(EXPECTED_MESSAGE, chunk.toString(Charsets.UTF_8));
}
@Test
public void testOneChunks() throws Exception {
- List<Object> output = Lists.newArrayList();
- ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE_ONE.getBytes(Charsets.UTF_8));
+ final List<Object> output = Lists.newArrayList();
+ final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE_ONE.getBytes(Charsets.UTF_8));
agr.decode(null, input, output);
- Assert.assertEquals(1, output.size());
- ByteBuf chunk = (ByteBuf) output.get(0);
+ assertEquals(1, output.size());
+ final ByteBuf chunk = (ByteBuf) output.get(0);
- Assert.assertEquals(EXPECTED_MESSAGE, chunk.toString(Charsets.UTF_8));
+ assertEquals(EXPECTED_MESSAGE, chunk.toString(Charsets.UTF_8));
}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage;
+import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+
+public class NetconfHelloMessageToXMLEncoderTest {
+
+ @Mock
+ private ChannelHandlerContext ctx;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testEncode() throws Exception {
+ final NetconfMessage msg = new NetconfHelloMessage(XmlUtil.readXmlToDocument("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"),
+ NetconfHelloMessageAdditionalHeader.fromString("[tomas;10.0.0.0:10000;tcp;client;]"));
+ final ByteBuf destination = Unpooled.buffer();
+ new NetconfHelloMessageToXMLEncoder().encode(ctx, msg, destination);
+
+ final String encoded = new String(destination.array());
+ assertThat(encoded, containsString("[tomas;10.0.0.0:10000;tcp;client;]"));
+ assertThat(encoded, containsString("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
+ }
+
+ @Test
+ public void testEncodeNoHeader() throws Exception {
+ final NetconfMessage msg = new NetconfHelloMessage(XmlUtil.readXmlToDocument("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
+ final ByteBuf destination = Unpooled.buffer();
+ new NetconfHelloMessageToXMLEncoder().encode(ctx, msg, destination);
+
+ final String encoded = new String(destination.array());
+ assertThat(encoded, not(containsString("[tomas;10.0.0.0:10000;tcp;client;]")));
+ assertThat(encoded, containsString("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testEncodeNotHello() throws Exception {
+ final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
+ new NetconfHelloMessageToXMLEncoder().encode(ctx, msg, null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.util.List;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+
+public class NetconfXMLToHelloMessageDecoderTest {
+
+ @Test
+ public void testDecodeWithHeader() throws Exception {
+ final ByteBuf src = Unpooled.wrappedBuffer(String.format("%s\n%s",
+ "[tomas;10.0.0.0:10000;tcp;client;]", "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>").getBytes());
+ final List<Object> out = Lists.newArrayList();
+ new NetconfXMLToHelloMessageDecoder().decode(null, src, out);
+
+ assertEquals(1, out.size());
+ assertThat(out.get(0), CoreMatchers.instanceOf(NetconfHelloMessage.class));
+ final NetconfHelloMessage hello = (NetconfHelloMessage) out.get(0);
+ assertTrue(hello.getAdditionalHeader().isPresent());
+ assertEquals("[tomas;10.0.0.0:10000;tcp;client;]\n", hello.getAdditionalHeader().get().toFormattedString());
+ assertThat(XmlUtil.toString(hello.getDocument()), CoreMatchers.containsString("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\""));
+ }
+
+ @Test
+ public void testDecodeNoHeader() throws Exception {
+ final ByteBuf src = Unpooled.wrappedBuffer("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
+ final List<Object> out = Lists.newArrayList();
+ new NetconfXMLToHelloMessageDecoder().decode(null, src, out);
+
+ assertEquals(1, out.size());
+ assertThat(out.get(0), CoreMatchers.instanceOf(NetconfHelloMessage.class));
+ final NetconfHelloMessage hello = (NetconfHelloMessage) out.get(0);
+ assertFalse(hello.getAdditionalHeader().isPresent());
+ }
+
+ @Test
+ public void testDecodeCaching() throws Exception {
+ final ByteBuf msg1 = Unpooled.wrappedBuffer("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
+ final ByteBuf msg2 = Unpooled.wrappedBuffer("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
+ final ByteBuf src = Unpooled.wrappedBuffer("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
+ final List<Object> out = Lists.newArrayList();
+ final NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
+ decoder.decode(null, src, out);
+ decoder.decode(null, msg1, out);
+ decoder.decode(null, msg2, out);
+
+ assertEquals(1, out.size());
+
+ assertEquals(2, Iterables.size(decoder.getPostHelloNetconfMessages()));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testDecodeNotHelloReceived() throws Exception {
+ final ByteBuf msg1 = Unpooled.wrappedBuffer("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
+ final List<Object> out = Lists.newArrayList();
+ NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
+ decoder.decode(null, msg1, out);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.common.collect.Lists;
+import io.netty.buffer.Unpooled;
+import java.util.ArrayList;
+import org.junit.Test;
+
+public class NetconfXMLToMessageDecoderTest {
+
+ @Test
+ public void testDecodeNoMoreContent() throws Exception {
+ final ArrayList<Object> out = Lists.newArrayList();
+ new NetconfXMLToMessageDecoder().decode(null, Unpooled.buffer(), out);
+ assertEquals(0, out.size());
+ }
+
+ @Test
+ public void testDecode() throws Exception {
+ final ArrayList<Object> out = Lists.newArrayList();
+ new NetconfXMLToMessageDecoder().decode(null, Unpooled.wrappedBuffer("<msg/>".getBytes()), out);
+ assertEquals(1, out.size());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.nettyutil.handler.ssh.authentication;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.future.AuthFuture;
+import org.junit.Test;
+
+public class LoginPasswordTest {
+
+ @Test
+ public void testLoginPassword() throws Exception {
+ final LoginPassword loginPassword = new LoginPassword("user", "pwd");
+ assertEquals("user", loginPassword.getUsername());
+
+ final ClientSession session = mock(ClientSession.class);
+ doNothing().when(session).addPasswordIdentity("pwd");
+ doReturn(mock(AuthFuture.class)).when(session).auth();
+ loginPassword.authenticate(session);
+
+ verify(session).addPasswordIdentity("pwd");
+ verify(session).auth();
+ }
+}
\ No newline at end of file
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-auth</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>usermanager</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>ganymed</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<configuration>
<instructions>
<Bundle-Activator>org.opendaylight.controller.netconf.ssh.osgi.NetconfSSHActivator</Bundle-Activator>
- <Import-Package>com.google.common.base,
- ch.ethz.ssh2,
- ch.ethz.ssh2.signature,
- org.apache.commons.io,
- org.opendaylight.controller.netconf.util.osgi,
- org.opendaylight.controller.usermanager,
- org.opendaylight.controller.sal.authorization,
- org.opendaylight.controller.sal.utils,
- org.osgi.framework,
- org.osgi.util.tracker,
- org.slf4j,
- org.bouncycastle.openssl,
- io.netty.bootstrap, io.netty.buffer, io.netty.channel, io.netty.channel.local, io.netty.channel.nio,
- io.netty.handler.stream, io.netty.util.concurrent, org.apache.commons.lang3,
- org.opendaylight.controller.netconf.util.messages</Import-Package>
+ <Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
*/
package org.opendaylight.controller.netconf.ssh;
-import com.google.common.annotations.VisibleForTesting;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalAddress;
+import com.google.common.base.Preconditions;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
+
import javax.annotation.concurrent.ThreadSafe;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
+
+import org.opendaylight.controller.netconf.auth.AuthProvider;
import org.opendaylight.controller.netconf.ssh.threads.Handshaker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.local.LocalAddress;
+
/**
* Thread that accepts client connections. Accepted socket is forwarded to {@link org.opendaylight.controller.netconf.ssh.threads.Handshaker},
* which is executed in {@link #handshakeExecutor}.
private final ServerSocket serverSocket;
private final LocalAddress localAddress;
private final EventLoopGroup bossGroup;
- private final AuthProvider authProvider;
+ private Optional<AuthProvider> authProvider = Optional.absent();
private final ExecutorService handshakeExecutor;
+ private final char[] pem;
private volatile boolean up;
- private NetconfSSHServer(int serverPort, LocalAddress localAddress, AuthProvider authProvider, EventLoopGroup bossGroup) throws IOException {
+ private NetconfSSHServer(final int serverPort, final LocalAddress localAddress, final EventLoopGroup bossGroup, final char[] pem) throws IOException {
super(NetconfSSHServer.class.getSimpleName());
this.bossGroup = bossGroup;
+ this.pem = pem;
logger.trace("Creating SSH server socket on port {}", serverPort);
this.serverSocket = new ServerSocket(serverPort);
if (serverSocket.isBound() == false) {
}
logger.trace("Server socket created.");
this.localAddress = localAddress;
- this.authProvider = authProvider;
this.up = true;
handshakeExecutor = Executors.newFixedThreadPool(10);
}
- public static NetconfSSHServer start(int serverPort, LocalAddress localAddress, AuthProvider authProvider, EventLoopGroup bossGroup) throws IOException {
- NetconfSSHServer netconfSSHServer = new NetconfSSHServer(serverPort, localAddress, authProvider, bossGroup);
+ public static NetconfSSHServer start(final int serverPort, final LocalAddress localAddress, final EventLoopGroup bossGroup, final char[] pemArray) throws IOException {
+ final NetconfSSHServer netconfSSHServer = new NetconfSSHServer(serverPort, localAddress, bossGroup, pemArray);
netconfSSHServer.start();
return netconfSSHServer;
}
+ public synchronized AuthProvider getAuthProvider() {
+ Preconditions.checkState(authProvider.isPresent(), "AuthenticationProvider is not set up, cannot authenticate user");
+ return authProvider.get();
+ }
+
+ public synchronized void setAuthProvider(final AuthProvider authProvider) {
+ if(this.authProvider != null) {
+ logger.debug("Changing auth provider to {}", authProvider);
+ }
+ this.authProvider = Optional.fromNullable(authProvider);
+ }
+
@Override
public void close() throws IOException {
up = false;
Socket acceptedSocket = null;
try {
acceptedSocket = serverSocket.accept();
- } catch (IOException e) {
+ } catch (final IOException e) {
if (up == false) {
logger.trace("Exiting server thread", e);
} else {
}
if (acceptedSocket != null) {
try {
- Handshaker task = new Handshaker(acceptedSocket, localAddress, sessionIdCounter.incrementAndGet(), authProvider, bossGroup);
+ final Handshaker task = new Handshaker(acceptedSocket, localAddress, sessionIdCounter.incrementAndGet(), getAuthProvider(), bossGroup, pem);
handshakeExecutor.submit(task);
- } catch (IOException e) {
+ } catch (final IOException e) {
logger.warn("Cannot set PEMHostKey, closing connection", e);
- try {
- acceptedSocket.close();
- } catch (IOException e1) {
- logger.warn("Ignoring exception while closing socket", e);
- }
+ closeSocket(acceptedSocket);
+ } catch (final IllegalStateException e) {
+ logger.warn("Cannot accept connection, closing", e);
+ closeSocket(acceptedSocket);
}
}
}
logger.debug("Server thread is exiting");
}
+
+ private void closeSocket(final Socket acceptedSocket) {
+ try {
+ acceptedSocket.close();
+ } catch (final IOException e) {
+ logger.warn("Ignoring exception while closing socket", e);
+ }
+ }
+
}
import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Optional;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalAddress;
-import io.netty.channel.nio.NioEventLoopGroup;
+import com.google.common.base.Preconditions;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
+
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang3.StringUtils;
+import org.opendaylight.controller.netconf.auth.AuthConstants;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProviderImpl;
import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil.InfixProp;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.local.LocalAddress;
+import io.netty.channel.nio.NioEventLoopGroup;
+
/**
* Activator for netconf SSH bundle which creates SSH bridge between netconf client and netconf server. Activator
* starts SSH Server in its own thread. This thread is closed when activator calls stop() method. Server opens socket
*/
public class NetconfSSHActivator implements BundleActivator {
private static final Logger logger = LoggerFactory.getLogger(NetconfSSHActivator.class);
+ private static AuthProviderTracker authProviderTracker;
private NetconfSSHServer server;
}
@Override
- public void stop(BundleContext context) throws IOException {
+ public void stop(final BundleContext context) throws IOException {
if (server != null) {
server.close();
}
+
+ if(authProviderTracker != null) {
+ authProviderTracker.stop();
+ }
}
- private static NetconfSSHServer startSSHServer(BundleContext bundleContext) throws IOException {
- Optional<InetSocketAddress> maybeSshSocketAddress = NetconfConfigUtil.extractNetconfServerAddress(bundleContext,
+ private static NetconfSSHServer startSSHServer(final BundleContext bundleContext) throws IOException {
+ final Optional<InetSocketAddress> maybeSshSocketAddress = NetconfConfigUtil.extractNetconfServerAddress(bundleContext,
InfixProp.ssh);
if (maybeSshSocketAddress.isPresent() == false) {
logger.trace("SSH bridge not configured");
return null;
}
- InetSocketAddress sshSocketAddress = maybeSshSocketAddress.get();
- logger.trace("Starting netconf SSH bridge at {}", sshSocketAddress);
- LocalAddress localAddress = NetconfConfigUtil.getNetconfLocalAddress();
+ final InetSocketAddress sshSocketAddress = maybeSshSocketAddress.get();
+ logger.trace("Starting netconf SSH bridge at {}", sshSocketAddress);
+
+ final LocalAddress localAddress = NetconfConfigUtil.getNetconfLocalAddress();
- String path = FilenameUtils.separatorsToSystem(NetconfConfigUtil.getPrivateKeyPath(bundleContext));
- checkState(StringUtils.isNotBlank(path), "Path to ssh private key is blank. Reconfigure %s", NetconfConfigUtil.getPrivateKeyKey());
- String privateKeyPEMString = PEMGenerator.readOrGeneratePK(new File(path));
+ final String path = FilenameUtils.separatorsToSystem(NetconfConfigUtil.getPrivateKeyPath(bundleContext));
+ checkState(!Strings.isNullOrEmpty(path), "Path to ssh private key is blank. Reconfigure %s", NetconfConfigUtil.getPrivateKeyKey());
+ final String privateKeyPEMString = PEMGenerator.readOrGeneratePK(new File(path));
- final AuthProvider authProvider = new AuthProviderImpl(privateKeyPEMString, bundleContext);
- EventLoopGroup bossGroup = new NioEventLoopGroup();
- NetconfSSHServer server = NetconfSSHServer.start(sshSocketAddress.getPort(), localAddress, authProvider, bossGroup);
+ final EventLoopGroup bossGroup = new NioEventLoopGroup();
+ final NetconfSSHServer server = NetconfSSHServer.start(sshSocketAddress.getPort(), localAddress, bossGroup, privateKeyPEMString.toCharArray());
+
+ authProviderTracker = new AuthProviderTracker(bundleContext, server);
+
+ return server;
+ }
+ private static Thread runNetconfSshThread(final NetconfSSHServer server) {
final Thread serverThread = new Thread(server, "netconf SSH server thread");
serverThread.setDaemon(true);
serverThread.start();
logger.trace("Netconf SSH bridge up and running.");
- return server;
+ return serverThread;
}
+ private static class AuthProviderTracker implements ServiceTrackerCustomizer<AuthProvider, AuthProvider> {
+ private final BundleContext bundleContext;
+ private final NetconfSSHServer server;
+
+ private Integer maxPreference;
+ private Thread sshThread;
+ private final ServiceTracker<AuthProvider, AuthProvider> listenerTracker;
+
+ public AuthProviderTracker(final BundleContext bundleContext, final NetconfSSHServer server) {
+ this.bundleContext = bundleContext;
+ this.server = server;
+ listenerTracker = new ServiceTracker<>(bundleContext, AuthProvider.class, this);
+ listenerTracker.open();
+ }
+
+ @Override
+ public AuthProvider addingService(final ServiceReference<AuthProvider> reference) {
+ logger.trace("Service {} added", reference);
+ final AuthProvider authService = bundleContext.getService(reference);
+ final Integer newServicePreference = getPreference(reference);
+ if(isBetter(newServicePreference)) {
+ server.setAuthProvider(authService);
+ if(sshThread == null) {
+ sshThread = runNetconfSshThread(server);
+ }
+ }
+ return authService;
+ }
+
+ private Integer getPreference(final ServiceReference<AuthProvider> reference) {
+ final Object preferenceProperty = reference.getProperty(AuthConstants.SERVICE_PREFERENCE_KEY);
+ return preferenceProperty == null ? Integer.MIN_VALUE : Integer.valueOf(preferenceProperty.toString());
+ }
+
+ private boolean isBetter(final Integer newServicePreference) {
+ Preconditions.checkNotNull(newServicePreference);
+ if(maxPreference == null) {
+ return true;
+ }
+ return newServicePreference > maxPreference;
+ }
+
+ @Override
+ public void modifiedService(final ServiceReference<AuthProvider> reference, final AuthProvider service) {
+ final AuthProvider authService = bundleContext.getService(reference);
+ final Integer newServicePreference = getPreference(reference);
+ if(isBetter(newServicePreference)) {
+ logger.trace("Replacing modified service {} in netconf SSH.", reference);
+ server.setAuthProvider(authService);
+ }
+ }
+
+ @Override
+ public void removedService(final ServiceReference<AuthProvider> reference, final AuthProvider service) {
+ logger.trace("Removing service {} from netconf SSH. " +
+ "SSH won't authenticate users until AuthProvider service will be started.", reference);
+ maxPreference = null;
+ server.setAuthProvider(null);
+ }
+
+ public void stop() {
+ listenerTracker.close();
+ // sshThread should finish normally since sshServer.close stops processing
+ }
+
+ }
}
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import javax.annotation.concurrent.NotThreadSafe;
+import javax.annotation.concurrent.ThreadSafe;
+
+import org.opendaylight.controller.netconf.auth.AuthProvider;
+import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import ch.ethz.ssh2.AuthenticationResult;
import ch.ethz.ssh2.PtySettings;
import ch.ethz.ssh2.ServerAuthenticationCallback;
import ch.ethz.ssh2.ServerSession;
import ch.ethz.ssh2.ServerSessionCallback;
import ch.ethz.ssh2.SimpleServerSessionCallback;
+
import com.google.common.base.Supplier;
+
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufProcessor;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
import io.netty.handler.stream.ChunkedStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import javax.annotation.concurrent.NotThreadSafe;
-import javax.annotation.concurrent.ThreadSafe;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
-import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* One instance represents per connection, responsible for ssh handshake.
public Handshaker(Socket socket, LocalAddress localAddress, long sessionId, AuthProvider authProvider,
- EventLoopGroup bossGroup) throws IOException {
+ EventLoopGroup bossGroup, final char[] pem) throws IOException {
this.session = "Session " + sessionId;
getGanymedAutoCloseable(ganymedConnection), localAddress, bossGroup);
// initialize ganymed
- ganymedConnection.setPEMHostKey(authProvider.getPEMAsCharArray(), null);
+ ganymedConnection.setPEMHostKey(pem, null);
ganymedConnection.setAuthenticationCallback(serverAuthenticationCallback);
ganymedConnection.setServerConnectionCallback(serverConnectionCallback);
}
+++ /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;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.controller.sal.authorization.AuthResultEnum;
-import org.opendaylight.controller.sal.authorization.UserLevel;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
-import org.opendaylight.controller.usermanager.AuthorizationConfig;
-import org.opendaylight.controller.usermanager.ISessionManager;
-import org.opendaylight.controller.usermanager.IUserManager;
-import org.opendaylight.controller.usermanager.ServerConfig;
-import org.opendaylight.controller.usermanager.UserConfig;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.web.context.SecurityContextRepository;
-
-public class StubUserManager implements IUserManager{
-
-
- private static String user;
- private static String password;
-
- public StubUserManager(String user, String password){
- StubUserManager.user = user;
- StubUserManager.password = password;
- }
- @Override
- public List<String> getUserRoles(String userName) {
- return null;
- }
-
- @Override
- public AuthResultEnum authenticate(String username, String password) {
- if (StubUserManager.user.equals(username) && StubUserManager.password.equals(password)){
- return AuthResultEnum.AUTH_ACCEPT_LOC;
- }
- return AuthResultEnum.AUTH_REJECT_LOC;
- }
-
- @Override
- public Status addAAAServer(ServerConfig configObject) {
- return null;
- }
-
- @Override
- public Status removeAAAServer(ServerConfig configObject) {
- return null;
- }
-
- @Override
- public Status addLocalUser(UserConfig configObject) {
- return new Status(StatusCode.SUCCESS);
- }
-
- @Override
- public Status modifyLocalUser(UserConfig configObject) {
- return null;
- }
-
- @Override
- public Status removeLocalUser(UserConfig configObject) {
- return null;
- }
-
- @Override
- public Status removeLocalUser(String userName) {
- return null;
- }
-
- @Override
- public Status addAuthInfo(AuthorizationConfig AAAconf) {
- return null;
- }
-
- @Override
- public Status removeAuthInfo(AuthorizationConfig AAAconf) {
- return null;
- }
-
- @Override
- public List<AuthorizationConfig> getAuthorizationList() {
- return null;
- }
-
- @Override
- public Set<String> getAAAProviderNames() {
- return null;
- }
-
- @Override
- public Status changeLocalUserPassword(String user, String curPassword, String newPassword) {
- return null;
- }
-
- @Override
- public List<ServerConfig> getAAAServerList() {
- return null;
- }
-
- @Override
- public List<UserConfig> getLocalUserList() {
- return null;
- }
-
- @Override
- public Status saveLocalUserList() {
- return null;
- }
-
- @Override
- public Status saveAAAServerList() {
- return null;
- }
-
- @Override
- public Status saveAuthorizationList() {
- return null;
- }
-
- @Override
- public void userLogout(String username) {
-
- }
-
- @Override
- public void userTimedOut(String username) {
-
- }
-
- @Override
- public Map<String, List<String>> getUserLoggedIn() {
- return null;
- }
-
- @Override
- public String getAccessDate(String user) {
- return null;
- }
-
- @Override
- public UserLevel getUserLevel(String userName) {
- return null;
- }
-
- @Override
- public List<UserLevel> getUserLevels(String userName) {
- return null;
- }
-
- @Override
- public SecurityContextRepository getSecurityContextRepo() {
- return null;
- }
-
- @Override
- public ISessionManager getSessionManager() {
- return null;
- }
-
- @Override
- public boolean isRoleInUse(String role) {
- return false;
- }
-
- @Override
- public String getPassword(String username) {
- return null;
- }
-
- @Override
- public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
- return null;
- }
-
-}
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
import org.opendaylight.controller.netconf.netty.EchoClientHandler.State;
import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
-import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshHandler;
+import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProviderImpl;
import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.slf4j.Logger;
@Test
public void test() throws Exception {
new Thread(new EchoServer(), "EchoServer").start();
- AuthProvider authProvider = mock(AuthProviderImpl.class);
- doReturn(PEMGenerator.generate().toCharArray()).when(authProvider).getPEMAsCharArray();
+ AuthProvider authProvider = mock(AuthProvider.class);
doReturn(true).when(authProvider).authenticated(anyString(), anyString());
+ doReturn("auth").when(authProvider).toString();
+
NetconfSSHServer netconfSSHServer = NetconfSSHServer.start(10831, NetconfConfigUtil.getNetconfLocalAddress(),
- authProvider, new NioEventLoopGroup());
+ new NioEventLoopGroup(), PEMGenerator.generate().toCharArray());
+ netconfSSHServer.setAuthProvider(authProvider);
InetSocketAddress address = netconfSSHServer.getLocalSocketAddress();
final EchoClientHandler echoClientHandler = connectClient(address);
ChannelInitializer<NioSocketChannel> channelInitializer = new ChannelInitializer<NioSocketChannel>() {
@Override
public void initChannel(NioSocketChannel ch) throws Exception {
- ch.pipeline().addFirst(SshHandler.createForNetconfSubsystem(new LoginPassword("a", "a")));
+ ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(new LoginPassword("a", "a")));
ch.pipeline().addLast(echoClientHandler);
}
};
Thread.sleep(100);
}
assertFalse(echoClientHandler.isConnected());
- assertEquals(State.FAILED_TO_CONNECT, echoClientHandler.getState());
+ assertEquals(State.CONNECTION_CLOSED, echoClientHandler.getState());
}
}
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.netconf.StubUserManager;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.osgi.framework.BundleContext;
doReturn(new ServiceReference[0]).when(mockedContext).getServiceReferences(anyString(), anyString());
logger.info("Creating SSH server");
- StubUserManager um = new StubUserManager(USER, PASSWORD);
String pem;
try (InputStream is = getClass().getResourceAsStream("/RSA.pk")) {
pem = IOUtils.toString(is);
}
- AuthProviderImpl ap = new AuthProviderImpl(pem, mockedContext);
- ap.setNullableUserManager(um);
+
+
EventLoopGroup bossGroup = new NioEventLoopGroup();
NetconfSSHServer server = NetconfSSHServer.start(PORT, NetconfConfigUtil.getNetconfLocalAddress(),
- ap, bossGroup);
+ bossGroup, pem.toCharArray());
+ server.setAuthProvider(new AuthProvider() {
+ @Override
+ public boolean authenticated(final String username, final String password) {
+ return true;
+ }
+ });
sshServerThread = new Thread(server);
sshServerThread.setDaemon(true);
package org.opendaylight.controller.netconf.test.tool;
-import java.io.File;
-import java.io.IOException;
-import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
-import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
class AcceptingAuthProvider implements AuthProvider {
- private final String privateKeyPEMString;
-
- public AcceptingAuthProvider() {
- try {
- this.privateKeyPEMString = PEMGenerator.readOrGeneratePK(new File("PK"));
- } catch (final IOException e) {
- throw new RuntimeException(e);
- }
- }
@Override
public synchronized boolean authenticated(final String username, final String password) {
return true;
}
- @Override
- public char[] getPEMAsCharArray() {
- return privateKeyPEMString.toCharArray();
- }
}
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import java.io.Closeable;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOperationService;
import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
+import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
server = dispatcher.createLocalServer(tcpLocalAddress);
try {
- NetconfSSHServer.start(currentPort, tcpLocalAddress, new AcceptingAuthProvider(), nettyThreadgroup);
+ final NetconfSSHServer sshServer = NetconfSSHServer.start(currentPort, tcpLocalAddress, nettyThreadgroup, getPemArray());
+ sshServer.setAuthProvider(new AcceptingAuthProvider());
} catch (final Exception e) {
LOG.warn("Cannot start simulated device on {}, skipping", address, e);
// Close local server and continue
return openDevices;
}
+ private char[] getPemArray() {
+ try {
+ return PEMGenerator.readOrGeneratePK(new File("PK")).toCharArray();
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
private Map<ModuleBuilder, String> parseSchemasToModuleBuilders(final Main.Params params) {
final SharedSchemaRepository consumer = new SharedSchemaRepository("netconf-simulator");
consumer.registerSchemaSourceListener(TextToASTTransformer.create(consumer, consumer));
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2014 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
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-subsystem</artifactId>
+ <version>0.2.5-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <artifactId>netconf-usermanager</artifactId>
+ <packaging>bundle</packaging>
+ <name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-auth</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>usermanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-Activator>org.opendaylight.controller.netconf.auth.usermanager.AuthProviderActivator</Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2014 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.auth.usermanager;
+
+import java.util.Hashtable;
+import org.opendaylight.controller.netconf.auth.AuthConstants;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class AuthProviderActivator implements BundleActivator {
+
+ public static final int PREFERENCE = 0;
+ private ServiceRegistration<AuthProvider> authProviderServiceRegistration;
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ final AuthProvider authProvider = new AuthProviderImpl(context);
+ // Set preference of this service to 0
+ final Hashtable<String, Object> properties = new Hashtable<>(1);
+ properties.put(AuthConstants.SERVICE_PREFERENCE_KEY, PREFERENCE);
+
+ authProviderServiceRegistration = context.registerService(AuthProvider.class, authProvider, properties);
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ if(authProviderServiceRegistration != null) {
+ authProviderServiceRegistration.unregister();
+ }
+ }
+}
* 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.ssh.authentication;
+package org.opendaylight.controller.netconf.auth.usermanager;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.VisibleForTesting;
+import org.opendaylight.controller.netconf.auth.AuthProvider;
import org.opendaylight.controller.sal.authorization.AuthResultEnum;
import org.opendaylight.controller.usermanager.IUserManager;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * AuthProvider implementation delegating to AD-SAL UserManager instance.
+ */
public class AuthProviderImpl implements AuthProvider {
private static final Logger logger = LoggerFactory.getLogger(AuthProviderImpl.class);
- private final String pem;
private IUserManager nullableUserManager;
- public AuthProviderImpl(String pemCertificate, final BundleContext bundleContext) {
- checkNotNull(pemCertificate, "Parameter 'pemCertificate' is null");
- pem = pemCertificate;
+ public AuthProviderImpl(final BundleContext bundleContext) {
- ServiceTrackerCustomizer<IUserManager, IUserManager> customizer = new ServiceTrackerCustomizer<IUserManager, IUserManager>() {
+ final ServiceTrackerCustomizer<IUserManager, IUserManager> customizer = new ServiceTrackerCustomizer<IUserManager, IUserManager>() {
@Override
public IUserManager addingService(final ServiceReference<IUserManager> reference) {
- logger.trace("Service {} added", reference);
+ logger.trace("UerManager {} added", reference);
nullableUserManager = bundleContext.getService(reference);
return nullableUserManager;
}
@Override
public void modifiedService(final ServiceReference<IUserManager> reference, final IUserManager service) {
- logger.trace("Replacing modified service {} in netconf SSH.", reference);
+ logger.trace("Replacing modified UerManager {}", reference);
nullableUserManager = service;
}
@Override
public void removedService(final ServiceReference<IUserManager> reference, final IUserManager service) {
- logger.trace("Removing service {} from netconf SSH. " +
- "SSH won't authenticate users until IUserManager service will be started.", reference);
+ logger.trace("Removing UerManager {}. This AuthProvider will fail to authenticate every time", reference);
synchronized (AuthProviderImpl.this) {
nullableUserManager = null;
}
}
};
- ServiceTracker<IUserManager, IUserManager> listenerTracker = new ServiceTracker<>(bundleContext, IUserManager.class, customizer);
+ final ServiceTracker<IUserManager, IUserManager> listenerTracker = new ServiceTracker<>(bundleContext, IUserManager.class, customizer);
listenerTracker.open();
}
* available, IllegalStateException is thrown.
*/
@Override
- public synchronized boolean authenticated(String username, String password) {
+ public synchronized boolean authenticated(final String username, final String password) {
if (nullableUserManager == null) {
logger.warn("Cannot authenticate user '{}', user manager service is missing", username);
throw new IllegalStateException("User manager service is not available");
}
- AuthResultEnum authResult = nullableUserManager.authenticate(username, password);
+ final AuthResultEnum authResult = nullableUserManager.authenticate(username, password);
logger.debug("Authentication result for user '{}' : {}", username, authResult);
return authResult.equals(AuthResultEnum.AUTH_ACCEPT) || authResult.equals(AuthResultEnum.AUTH_ACCEPT_LOC);
}
- @Override
- public char[] getPEMAsCharArray() {
- return pem.toCharArray();
- }
-
@VisibleForTesting
- void setNullableUserManager(IUserManager nullableUserManager) {
+ void setNullableUserManager(final IUserManager nullableUserManager) {
this.nullableUserManager = nullableUserManager;
}
}
<module>ietf-netconf-monitoring</module>
<module>ietf-netconf-monitoring-extension</module>
<module>netconf-connector-config</module>
+ <module>netconf-auth</module>
+ <module>netconf-usermanager</module>
</modules>
<dependencies>
* instance of deleted LoadBalancerPool object
* @return void
*/
- public void NeutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
+ public void neutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember loadBalancerPoolMember);
}
this.portUUID = portUUID;
}
+ public String getID() {
+ return id;
+ }
+
public void setID(String id) {
this.id = id;
}
public void setSubnetUUID(String subnetUUID) {
this.subnetUUID = subnetUUID;
}
+
+ @Override
+ public String toString() {
+ return "Neutron_IPs{" +
+ "ipAddress='" + ipAddress + '\'' +
+ ", subnetUUID='" + subnetUUID + '\'' + "}";
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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,
protected static final Logger logger = LoggerFactory
.getLogger(Activator.class);
+ /**
+ * Priority to determine whether to override existing protocol service.
+ */
+ private static final int PLUGIN_PRIORITY = 10;
/**
* Function that is used to communicate to dependency manager the list of
// Set the protocolPluginType property which will be used
// by SAL
props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW);
+ props.put(GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(),
+ Integer.valueOf(PLUGIN_PRIORITY));
c.setInterface(IPluginInDataPacketService.class.getName(), props);
// Hook the services coming in from SAL, as optional in
// case SAL is not yet there, could happen
// Set the protocolPluginType property which will be used
// by SAL
props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW);
+ props.put(GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(),
+ Integer.valueOf(PLUGIN_PRIORITY));
c.setInterface(new String[] {
IReadFilterInternalListener.class.getName(),
IPluginInReadService.class.getName() }, props);
// Set the protocolPluginType property which will be used
// by SAL
props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW);
+ props.put(GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(),
+ Integer.valueOf(PLUGIN_PRIORITY));
c.setInterface(
new String[] { IPluginInFlowProgrammerService.class.getName(), IMessageListener.class.getName(),
IContainerListener.class.getName(), IInventoryShimExternalListener.class.getName(),
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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.sal.action;
/**
SET_NW_SRC("setNwSrc", 0, 0),
SET_NW_DST("setNwDst", 0, 0),
SET_NW_TOS("setNwTos", 0, 0x3f),
- SET_TP_SRC("setTpSrc", 1, 0xffff),
- SET_TP_DST("setTpDst", 1, 0xffff),
+ SET_TP_SRC("setTpSrc", 0, 0xffff), // Set transport source port
+ SET_TP_DST("setTpDst", 0, 0xffff), // Set transport destination port
SET_NEXT_HOP("setNextHop", 0, 0);
private String id;
-
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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,
STATICVLAN("staticvlan"),
CLUSTERINGSERVICES("clusteringservices"),
STARTUPHOME("configuration/startup/"),
- PROTOCOLPLUGINTYPE("protocolPluginType");
+ PROTOCOLPLUGINTYPE("protocolPluginType"),
+ PROTOCOLPLUGINPRIORITY("protocolPluginPriority");
private GlobalConstants(String name) {
this.name = name;
public String toString() {
return name;
}
-}
\ No newline at end of file
+}
-
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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.sal.action;
import org.opendaylight.controller.sal.core.ConstructionException;
action = new SetTpDst(65535);
Assert.assertTrue(action.isValid());
+ action = new SetTpSrc(0);
+ Assert.assertTrue(action.isValid());
+
action = new SetTpDst(0);
- Assert.assertFalse(action.isValid());
+ Assert.assertTrue(action.isValid());
action = new SetTpSrc(-1);
Assert.assertFalse(action.isValid());
-
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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,
import org.opendaylight.controller.sal.packet.Packet;
import org.opendaylight.controller.sal.packet.PacketResult;
import org.opendaylight.controller.sal.packet.RawPacket;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.NetUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* adding a new service, removing a service, going through all of
* them maybe different.
*/
- private ConcurrentHashMap<String, IPluginInDataPacketService>
+ private ConcurrentHashMap<String, ProtocolService<IPluginInDataPacketService>>
pluginInDataService =
- new ConcurrentHashMap<String, IPluginInDataPacketService>();
+ new ConcurrentHashMap<String, ProtocolService<IPluginInDataPacketService>>();
private Map<String, AtomicInteger> statistics = new HashMap<String, AtomicInteger>();
/**
String t = p.getNode()
.getType();
// Now locate the TX dispatcher
- IPluginInDataPacketService s = pluginInDataService
- .get(t);
- if (s != null) {
+ ProtocolService<IPluginInDataPacketService> service =
+ pluginInDataService.get(t);
+ if (service != null) {
try {
- s.transmitDataPacket(pkt);
+ service.getService().transmitDataPacket(pkt);
increaseStat("TXPacketSuccess");
} catch (Exception e) {
increaseStat("TXPacketFailedForException");
}
void setPluginInDataService(Map props, IPluginInDataPacketService s) {
- if (this.pluginInDataService == null) {
- logger.error("pluginInDataService store null");
- return;
- }
- String type = null;
- logger.trace("Received setPluginInDataService request");
- for (Object e : props.entrySet()) {
- Map.Entry entry = (Map.Entry) e;
- logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
- }
-
- Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
- if (value instanceof String) {
- type = (String) value;
- }
- if (type == null) {
- logger.error("Received a PluginInDataService without any "
- + "protocolPluginType provided");
- } else {
- this.pluginInDataService.put(type, s);
- logger.debug("Stored the PluginInDataService for type: {}", type);
- }
+ ProtocolService.set(this.pluginInDataService, props, s, logger);
}
void unsetPluginInDataService(Map props, IPluginInDataPacketService s) {
- if (this.pluginInDataService == null) {
- logger.error("pluginInDataService store null");
- return;
- }
-
- String type = null;
- logger.trace("Received unsetPluginInDataService request");
- for (Object e : props.entrySet()) {
- Map.Entry entry = (Map.Entry) e;
- logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
- }
-
- Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
- if (value instanceof String) {
- type = (String) value;
- }
- if (type == null) {
- logger.error("Received a PluginInDataService without any "
- + "protocolPluginType provided");
- } else if (this.pluginInDataService.get(type).equals(s)) {
- this.pluginInDataService.remove(type);
- logger.debug("Removed the PluginInDataService for type: {}", type);
- }
+ ProtocolService.unset(this.pluginInDataService, props, s, logger);
}
void setListenDataPacket(Map props, IListenDataPacket s) {
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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,
import org.opendaylight.controller.sal.match.Match;
import org.opendaylight.controller.sal.match.MatchType;
import org.opendaylight.controller.sal.utils.EtherTypes;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.IPProtocols;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
import org.opendaylight.controller.sal.utils.Status;
protected static final Logger logger = LoggerFactory
.getLogger(FlowProgrammerService.class);
- private ConcurrentHashMap<String, IPluginInFlowProgrammerService> pluginFlowProgrammer;
+ private ConcurrentHashMap<String, ProtocolService<IPluginInFlowProgrammerService>> pluginFlowProgrammer;
private Set<IFlowProgrammerListener> listener;
private AtomicLong seq;
public FlowProgrammerService() {
- pluginFlowProgrammer = new ConcurrentHashMap<String, IPluginInFlowProgrammerService>();
+ pluginFlowProgrammer = new ConcurrentHashMap<String, ProtocolService<IPluginInFlowProgrammerService>>();
listener = new HashSet<IFlowProgrammerListener>();
seq = new AtomicLong();
/*
// Set the reference to the plugin flow programmer
public void setService(Map<String, Object> props, IPluginInFlowProgrammerService s) {
- if (this.pluginFlowProgrammer == null) {
- logger.error("pluginFlowProgrammer store null");
- return;
- }
-
- if (logger.isTraceEnabled()) {
- logger.trace("Got a service set request {}", s);
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
- }
- }
-
- String type = null;
- Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
- if (value instanceof String) {
- type = (String) value;
- }
- if (type == null) {
- logger.error("Received a pluginFlowProgrammer without any "
- + "protocolPluginType provided");
- } else {
- this.pluginFlowProgrammer.put(type, s);
- logger.debug("Stored the pluginFlowProgrammer for type: {}", type);
- }
+ ProtocolService.set(this.pluginFlowProgrammer, props, s, logger);
}
public void unsetService(Map<String, Object> props, IPluginInFlowProgrammerService s) {
- if (this.pluginFlowProgrammer == null) {
- logger.error("pluginFlowProgrammer store null");
- return;
- }
-
- logger.debug("Received unsetpluginFlowProgrammer request");
- if (logger.isTraceEnabled()) {
- logger.trace("Got a service set request {}", s);
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
- }
- }
-
- String type = null;
- Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
- if (value instanceof String) {
- type = (String) value;
- }
- if (type == null) {
- logger.error("Received a pluginFlowProgrammer without any "
- + "protocolPluginType provided");
- } else if (this.pluginFlowProgrammer.get(type).equals(s)) {
- this.pluginFlowProgrammer.remove(type);
- logger.debug("Removed the pluginFlowProgrammer for type: {}", type);
- }
+ ProtocolService.unset(this.pluginFlowProgrammer, props, s, logger);
}
public void setListener(IFlowProgrammerListener s) {
@Override
public Status addFlow(Node node, Flow flow) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType()).addFlow(
- node, flow);
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().addFlow(node, flow);
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status removeFlow(Node node, Flow flow) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .removeFlow(node, flow);
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().removeFlow(node, flow);
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status removeAllFlows(Node node) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .removeAllFlows(node);
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().removeAllFlows(node);
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .modifyFlow(node, oldFlow, newFlow);
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().modifyFlow(node, oldFlow, newFlow);
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status addFlowAsync(Node node, Flow flow) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType()).addFlowAsync(
- node, flow, getNextRid());
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().addFlowAsync(node, flow, getNextRid());
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status removeFlowAsync(Node node, Flow flow) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .removeFlowAsync(node, flow, getNextRid());
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().removeFlowAsync(node, flow, getNextRid());
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow) {
if (pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .modifyFlowAsync(node, oldFlow, newFlow, getNextRid());
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().modifyFlowAsync(node, oldFlow, newFlow, getNextRid());
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status syncSendBarrierMessage(Node node) {
if (this.pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .syncSendBarrierMessage(node);
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().syncSendBarrierMessage(node);
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
@Override
public Status asyncSendBarrierMessage(Node node) {
if (this.pluginFlowProgrammer != null) {
- if (this.pluginFlowProgrammer.get(node.getType()) != null) {
- return this.pluginFlowProgrammer.get(node.getType())
- .asyncSendBarrierMessage(node);
+ ProtocolService<IPluginInFlowProgrammerService> service =
+ this.pluginFlowProgrammer.get(node.getType());
+ if (service != null) {
+ return service.getService().asyncSendBarrierMessage(node);
}
}
return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
--- /dev/null
+/*
+ * Copyright (c) 2014 NEC Corporation 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.sal.implementation.internal;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
+
+import org.slf4j.Logger;
+
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+
+/**
+ * An instance of this class keeps a protocol plugin service handler.
+ *
+ * @param <T> Type of protocol plugin service.
+ */
+public final class ProtocolService<T> {
+ /**
+ * Default priority value.
+ */
+ private static final int DEFAULT_PRIORITY = 0;
+
+ /**
+ * A protocol plugin service handler.
+ */
+ private final T service;
+
+ /**
+ * A priority value assigned to this protocol plugin.
+ */
+ private final int priority;
+
+ /**
+ * Set protocol plugin service.
+ *
+ * @param map A map that keeps protocol plugin services.
+ * @param props Service properties.
+ * @param s Protocol plugin service.
+ * @param logger A logger instance.
+ * @param <S> Type of protocol plugin service.
+ */
+ public static <S> void set(ConcurrentMap<String, ProtocolService<S>> map,
+ Map<?, ?> props, S s, Logger logger) {
+ if (map == null) {
+ logger.error("Protocol plugin service store is null.");
+ return;
+ }
+ if (s == null) {
+ logger.error("Protocol plugin service is null.");
+ return;
+ }
+ if (props == null) {
+ logger.error("Service property is null.");
+ return;
+ }
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Received set service request: {}", s);
+ for (Map.Entry<?, ?> entry: props.entrySet()) {
+ logger.trace("Prop key:({}) value:({})", entry.getKey(),
+ entry.getValue());
+ }
+ }
+
+ Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
+ if (!(value instanceof String)) {
+ logger.error("Unexpected protocol type: {}", value);
+ return;
+ }
+
+ String type = (String)value;
+ ProtocolService<S> service = new ProtocolService<S>(props, s);
+ ProtocolService<S> old = map.putIfAbsent(type, service);
+ while (old != null) {
+ // Compare priority value.
+ if (old.getPriority() >= service.getPriority()) {
+ logger.trace("Protocol plugin service for {} is already set: " +
+ "current={}, requested={}", type, old, service);
+ return;
+ }
+
+ if (map.replace(type, old, service)) {
+ break;
+ }
+ old = map.putIfAbsent(type, service);
+ }
+
+ logger.debug("Stored protocol plugin service for {}: {}",
+ type, service);
+ }
+
+ /**
+ * Unset protocol plugin service.
+ *
+ * @param map A map that keeps protocol plugin services.
+ * @param props Service properties.
+ * @param s Protocol plugin service.
+ * @param logger A logger instance.
+ * @param <S> Type of protocol plugin service.
+ */
+ public static <S> void unset(ConcurrentMap<String, ProtocolService<S>> map,
+ Map<?, ?> props, S s, Logger logger) {
+ if (map == null) {
+ logger.error("Protocol plugin service store is null.");
+ return;
+ }
+ if (s == null) {
+ logger.error("Protocol plugin service is null.");
+ return;
+ }
+ if (props == null) {
+ logger.error("Service property is null.");
+ return;
+ }
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Received unset service request: {}", s);
+ for (Map.Entry<?, ?> entry: props.entrySet()) {
+ logger.trace("Prop key:({}) value:({})",
+ entry.getKey(), entry.getValue());
+ }
+ }
+
+ Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
+ if (!(value instanceof String)) {
+ logger.error("Unexpected protocol type {}: service={}", value, s);
+ return;
+ }
+
+ String type = (String)value;
+ ProtocolService<S> plugin = new ProtocolService<S>(props, s);
+ if (map.remove(type, plugin)) {
+ logger.debug("Removed protocol plugin service for {}: {}",
+ type, plugin);
+ } else {
+ logger.trace("Ignore unset service request for {}: {}",
+ type, plugin);
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param props Protocol plugin service properties.
+ * @param s A protocol plugin service handler.
+ */
+ public ProtocolService(Map<?, ?> props, T s) {
+ service = s;
+
+ String key = GlobalConstants.PROTOCOLPLUGINPRIORITY.toString();
+ Object value = props.get(key);
+ if (value instanceof Integer) {
+ priority = ((Integer)value).intValue();
+ } else {
+ priority = DEFAULT_PRIORITY;
+ }
+ }
+
+ /**
+ * Return a protocol plugin service handler.
+ *
+ * @return A protocol plugin service handler.
+ */
+ public T getService() {
+ return service;
+ }
+
+ /**
+ * Return a priority value assigned to this protocol plugin.
+ *
+ * @return A priority value.
+ */
+ public int getPriority() {
+ return priority;
+ }
+
+ /**
+ * Determine whether the given object is identical to this object.
+ *
+ * @param o An object to be compared.
+ * @return {@code true} if identical. Otherwise {@code false}.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o == null || o.getClass() != getClass()) {
+ return false;
+ }
+
+ ProtocolService plugin = (ProtocolService)o;
+ return (service.equals(plugin.service) && priority == plugin.priority);
+ }
+
+ /**
+ * Return the hash code of this object.
+ *
+ * @return The hash code.
+ */
+ @Override
+ public int hashCode() {
+ return service.hashCode() + (priority * 31);
+ }
+
+ /**
+ * Return a string representation of this instance.
+ *
+ * @return A string representation of this instance.
+ */
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder("[service=");
+ return builder.append(service).append(", priority=").append(priority).
+ append(']').toString();
+ }
+}
-
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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,
import org.opendaylight.controller.sal.reader.NodeDescription;
import org.opendaylight.controller.sal.reader.NodeTableStatistics;
import org.opendaylight.controller.sal.utils.EtherTypes;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.IPProtocols;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
import org.opendaylight.controller.sal.utils.NodeCreator;
public class ReadService implements IReadService, CommandProvider, IPluginOutReadService {
protected static final Logger logger = LoggerFactory.getLogger(ReadService.class);
- private ConcurrentHashMap<String, IPluginInReadService> pluginReader =
- new ConcurrentHashMap<String, IPluginInReadService>();
+ private ConcurrentHashMap<String, ProtocolService<IPluginInReadService>> pluginReader =
+ new ConcurrentHashMap<String, ProtocolService<IPluginInReadService>>();
private Set<IReadServiceListener> readerListeners =
new CopyOnWriteArraySet<IReadServiceListener>();
// Set the reference to the plugin flow Reader service
public void setService(Map<?, ?> props, IPluginInReadService s) {
- if (this.pluginReader == null) {
- logger.error("pluginReader store null");
- return;
- }
-
- logger.trace("Got a service set request {}", s);
- String type = null;
- for (Object e : props.entrySet()) {
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) e;
- logger.trace("Prop key:({}) value:({})", entry.getKey(),
- entry.getValue());
- }
-
- Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
- if (value instanceof String) {
- type = (String) value;
- }
- if (type == null) {
- logger.error("Received a pluginReader without any "
- + "protocolPluginType provided");
- } else {
- this.pluginReader.put(type, s);
- logger.debug("Stored the pluginReader for type: {}", type);
- }
+ ProtocolService.set(this.pluginReader, props, s, logger);
}
public void unsetService(Map<?, ?> props, IPluginInReadService s) {
- if (this.pluginReader == null) {
- logger.error("pluginReader store null");
- return;
- }
-
- String type = null;
- logger.debug("Received unsetpluginReader request");
- for (Object e : props.entrySet()) {
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) e;
- logger.trace("Prop key:({}) value:({})", entry.getKey(),
- entry.getValue());
- }
-
- Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
- if (value instanceof String) {
- type = (String) value;
- }
- if (type == null) {
- logger.error("Received a pluginReader without any "
- + "protocolPluginType provided");
- } else if (this.pluginReader.get(type).equals(s)) {
- this.pluginReader.remove(type);
- logger.debug("Removed the pluginReader for type: {}", type);
- }
+ ProtocolService.unset(this.pluginReader, props, s, logger);
}
+
public void setReaderListener(IReadServiceListener service) {
logger.trace("Got a listener set request {}", service);
this.readerListeners.add(service);
@Override
public FlowOnNode readFlow(Node node, Flow flow) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readFlow(node, flow, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readFlow(node, flow, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public FlowOnNode nonCachedReadFlow(Node node, Flow flow) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readFlow(node, flow, false);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readFlow(node, flow, false);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public List<FlowOnNode> readAllFlows(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readAllFlow(node, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readAllFlow(node, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public List<FlowOnNode> nonCachedReadAllFlows(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readAllFlow(node, false);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readAllFlow(node, false);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public NodeDescription readDescription(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readDescription(node, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readDescription(node, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public NodeDescription nonCachedReadDescription(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readDescription(node, false);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readDescription(node, false);
}
}
logger.warn("Plugin {} unavailable", node.getType());
public NodeConnectorStatistics readNodeConnector(NodeConnector connector) {
Node node = connector.getNode();
if (pluginReader != null && node != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readNodeConnector(connector, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readNodeConnector(connector, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
NodeConnector connector) {
Node node = connector.getNode();
if (pluginReader != null && node != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readNodeConnector(connector, false);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readNodeConnector(connector, false);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public List<NodeConnectorStatistics> readNodeConnectors(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readAllNodeConnector(node, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readAllNodeConnector(node, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public List<NodeTableStatistics> readNodeTable(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readAllNodeTable(node, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readAllNodeTable(node, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
public NodeTableStatistics nonCachedReadNodeTable(NodeTable table) {
Node node = table.getNode();
if (pluginReader != null && node != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readNodeTable(table, false);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readNodeTable(table, false);
}
}
logger.warn("Plugin {} unavailable", node.getType());
public NodeTableStatistics readNodeTable(NodeTable table) {
Node node = table.getNode();
if (pluginReader != null && node != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readNodeTable(table, true);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readNodeTable(table, true);
}
}
logger.warn("Plugin {} unavailable", node.getType());
@Override
public List<NodeConnectorStatistics> nonCachedReadNodeConnectors(Node node) {
if (pluginReader != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .readAllNodeConnector(node, false);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().readAllNodeConnector(node, false);
}
}
logger.warn("Plugin {} unavailable", node.getType());
public long getTransmitRate(NodeConnector connector) {
Node node = connector.getNode();
if (pluginReader != null && node != null) {
- if (this.pluginReader.get(node.getType()) != null) {
- return this.pluginReader.get(node.getType())
- .getTransmitRate(connector);
+ ProtocolService<IPluginInReadService> service =
+ this.pluginReader.get(node.getType());
+ if (service != null) {
+ return service.getService().getTransmitRate(connector);
}
}
logger.warn("Plugin {} unavailable", node.getType());
--- /dev/null
+/*
+ * Copyright (c) 2014 NEC Corporation 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.sal.implementation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.opendaylight.controller.sal.implementation.internal.ProtocolService;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+
+/**
+ * Unit test for {@link ProtocolService}.
+ */
+public class ProtocolServiceTest {
+ private static final Logger LOG =
+ LoggerFactory.getLogger(ProtocolServiceTest.class);
+
+ @Test
+ public void testInstance() {
+ HashSet<ProtocolService<ITestService>> set = new HashSet<>();
+ TestService sv1 = new TestService();
+ HashMap<String, Object> prop1 = new HashMap<>();
+
+ ProtocolService<ITestService> ps1 =
+ new ProtocolService<ITestService>(prop1, sv1);
+ assertEquals(sv1, ps1.getService());
+ // Default priority is 0.
+ assertEquals(0, ps1.getPriority());
+ assertTrue(set.add(ps1));
+ assertFalse(set.add(ps1));
+
+ // Specify the same service and priority.
+ String priKey = GlobalConstants.PROTOCOLPLUGINPRIORITY.toString();
+ prop1.put(priKey, Integer.valueOf(0));
+ ProtocolService<ITestService> ps2 =
+ new ProtocolService<ITestService>(prop1, sv1);
+ assertEquals(sv1, ps2.getService());
+ assertEquals(0, ps2.getPriority());
+ assertEquals(ps1, ps2);
+ assertFalse(set.add(ps1));
+
+ // Specify different priority.
+ prop1.put(priKey, Integer.valueOf(Integer.MAX_VALUE));
+ ps2 = new ProtocolService<ITestService>(prop1, sv1);
+ assertEquals(sv1, ps2.getService());
+ assertEquals(Integer.MAX_VALUE, ps2.getPriority());
+ assertFalse(ps1.equals(ps2));
+ assertTrue(set.add(ps2));
+ assertFalse(set.add(ps2));
+
+ // Specify another service.
+ TestService sv2 = new TestService();
+ prop1.put(priKey, Integer.valueOf(0));
+ ps2 = new ProtocolService<ITestService>(prop1, sv2);
+ assertEquals(sv2, ps2.getService());
+ assertEquals(0, ps2.getPriority());
+ assertFalse(ps1.equals(ps2));
+ assertTrue(set.add(ps2));
+ assertFalse(set.add(ps2));
+ }
+
+ @Test
+ public void testSetUnsetError() {
+ ConcurrentMap<String, ProtocolService<ITestService>> services =
+ new ConcurrentHashMap<>();
+ TestService sv = new TestService();
+ Map<String, Object> props = new HashMap<>();
+
+ // null service.
+ ProtocolService.set(services, props, null, LOG);
+ assertTrue(services.isEmpty());
+
+ ProtocolService.unset(services, props, null, LOG);
+ assertTrue(services.isEmpty());
+
+ // null service property.
+ ProtocolService.set(services, null, sv, LOG);
+ assertTrue(services.isEmpty());
+
+ ProtocolService.unset(services, null, sv, LOG);
+ assertTrue(services.isEmpty());
+
+ // Type is not specified.
+ ProtocolService.set(services, props, sv, LOG);
+ assertTrue(services.isEmpty());
+
+ ProtocolService.unset(services, props, sv, LOG);
+ assertTrue(services.isEmpty());
+
+ // null service map.
+ final String typeKey = GlobalConstants.PROTOCOLPLUGINTYPE.toString();
+ assertEquals(null, props.put(typeKey, "OF"));
+ ProtocolService.set(null, props, sv, LOG);
+ assertTrue(services.isEmpty());
+
+ ProtocolService.unset(null, props, sv, LOG);
+ assertTrue(services.isEmpty());
+ }
+
+ @Test
+ public void testSetUnset() {
+ ConcurrentMap<String, ProtocolService<ITestService>> serviceMap =
+ new ConcurrentHashMap<>();
+ ConcurrentMap<String, ProtocolService<ITestService>> expected =
+ new ConcurrentHashMap<>();
+
+ final String typeKey = GlobalConstants.PROTOCOLPLUGINTYPE.toString();
+ final String priKey = GlobalConstants.PROTOCOLPLUGINPRIORITY.toString();
+ final String[] protocols = {"OF", "PE", "PK"};
+ final int basePri = 0;
+ final int loop = 5;
+
+ // Should override the service if higher priority is specified.
+ for (String proto: protocols) {
+ for (int pri = basePri - loop + 1; pri <= basePri; pri++) {
+ TestService sv = new TestService();
+ Map<String, Object> props = new HashMap<>();
+ assertEquals(null, props.put(typeKey, proto));
+ assertEquals(null, props.put(priKey, Integer.valueOf(pri)));
+ ProtocolService.set(serviceMap, props, sv, LOG);
+
+ ProtocolService<ITestService> service = serviceMap.get(proto);
+ assertNotNull(service);
+ assertEquals(sv, service.getService());
+ assertEquals(pri, service.getPriority());
+
+ ProtocolService<ITestService> service1 =
+ new ProtocolService<ITestService>(props, sv);
+ expected.put(proto, service1);
+ assertEquals(expected, serviceMap);
+
+ // Unset service request should be ignored if different
+ // parameters are specified.
+ TestService another = new TestService();
+ ProtocolService.unset(serviceMap, props, another, LOG);
+ assertEquals(expected, serviceMap);
+
+ props.put(priKey, Integer.valueOf(Integer.MAX_VALUE));
+ ProtocolService.unset(serviceMap, props, sv, LOG);
+ assertEquals(expected, serviceMap);
+ }
+ }
+
+ // Should reject the set service request if lower priority is specified.
+ for (String proto: protocols) {
+ for (int pri = basePri - loop; pri < basePri; pri++) {
+ TestService sv = new TestService();
+ Map<String, Object> props = new HashMap<>();
+ assertEquals(null, props.put(typeKey, proto));
+ assertEquals(null, props.put(priKey, Integer.valueOf(pri)));
+ ProtocolService.set(serviceMap, props, sv, LOG);
+ assertEquals(expected, serviceMap);
+ }
+ }
+
+ // Unset protocol services.
+ for (String proto: protocols) {
+ ProtocolService<ITestService> service = expected.remove(proto);
+ assertNotNull(service);
+
+ ITestService sv = service.getService();
+ Map<String, Object> props = new HashMap<>();
+ assertEquals(null, props.put(typeKey, proto));
+ assertEquals(null, props.put(priKey, Integer.valueOf(basePri)));
+ ProtocolService.unset(serviceMap, props, sv, LOG);
+ assertEquals(expected, serviceMap);
+
+ // Should be ignored if the specified service does not exist.
+ ProtocolService.unset(serviceMap, props, sv, LOG);
+ assertEquals(expected, serviceMap);
+ }
+
+ assertTrue(serviceMap.isEmpty());
+ }
+}
+
+interface ITestService {
+}
+
+class TestService implements ITestService {
+}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
- <version>0.7.1-SNAPSHOT</version>
+ <version>${sal.version}</version>
</dependency>
</dependencies>
</plugin>
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 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,
var h3 = "Set Transport Source Port";
var placeholder = "Transport Source Port";
var id = one.f.flows.id.modal.action.modifyTransportSourcePort;
- var help = "Range: 1 - 65535";
+ var help = "Range: 0 - 65535";
var action = 'SET_TP_SRC';
var name = "Source Port";
var body = function() {
var h3 = "Set Transport Destination Port";
var placeholder = "Transport Destination Port";
var id = one.f.flows.id.modal.action.modifyTransportDestinationPort;
- var help = "Range: 1 - 65535";
+ var help = "Range: 0 - 65535";
var action = 'SET_TP_DST';
var name = "Destination Port";
var body = function() {
<module>opendaylight/forwardingrulesmanager/implementation</module>
<module>opendaylight/hosttracker/api</module>
<module>opendaylight/hosttracker/implementation</module>
+ <module>opendaylight/hosttracker/shell</module>
<module>opendaylight/hosttracker_new/api</module>
<module>opendaylight/hosttracker_new/implementation</module>
<module>opendaylight/containermanager/api</module>
<module>opendaylight/connectionmanager/api</module>
<module>opendaylight/connectionmanager/implementation</module>
<module>opendaylight/security</module>
+ <module>opendaylight/karaf-tomcat-security</module>
<!-- third-parties uncomment them if you need snapshot version of it -->
<!-- <module>third-party/openflowj</module> -->
<module>opendaylight/distribution/opendaylight-karaf</module>
<module>opendaylight/distribution/opendaylight-karaf-resources</module>
<module>features</module>
+
+ <!-- archetypes -->
+ <module>opendaylight/archetypes</module>
</modules>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>