<configfile finalname="configuration/initial/module-shards.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/moduleshardconf</configfile>
<configfile finalname="configuration/initial/modules.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/moduleconf</configfile>
</feature>
+
+ <feature name='odl-clustering-test-app' version='${project.version}'>
+ <feature version='${yangtools.version}'>odl-yangtools-models</feature>
+ <feature version='${project.version}'>odl-mdsal-broker</feature>
+ <bundle>mvn:org.opendaylight.controller.samples/clustering-it-model/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller.samples/clustering-it-provider/${project.version}</bundle>
+ <configfile finalname="${config.configfile.directory}/20-clustering-test-app.xml">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/config</configfile>
+ </feature>
+
</features>
<maven>3.0</maven>
</prerequisites>
<modules>
- <module>base</module>
- <module>controller</module>
- <module>adsal</module>
- <module>nsf</module>
- <module>extras</module>
<module>config</module>
<module>config-persister</module>
<module>config-netty</module>
<module>flow</module>
<module>netconf</module>
<module>protocol-framework</module>
- <module>adsal-compatibility</module>
<module>akka</module>
<module>netconf-connector</module>
<module>restconf</module>
-->
<feature version='${project.version}'>odl-restconf</feature>
<feature version='${project.version}'>odl-mdsal-apidocs</feature>
- <feature version='${project.version}'>odl-clustering-test-app</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.
<bundle>wrap:mvn:org.json/json/${org.json.version}</bundle>
</feature>
- <feature name='odl-clustering-test-app' version='${project.version}'>
- <feature version='${project.version}'>odl-mdsal-clustering</feature>
- <feature version='${project.version}'>odl-restconf</feature>
- <feature version='${yangtools.version}'>odl-yangtools-models</feature>
- <bundle>mvn:org.opendaylight.controller.samples/clustering-it-model/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller.samples/clustering-it-provider/${project.version}</bundle>
- <configfile finalname="${config.configfile.directory}/20-clustering-test-app.xml">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/config</configfile>
- <configfile finalname="configuration/initial/module-shards.conf" override="true" >mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/testmoduleshardconf</configfile>
- <configfile finalname="configuration/initial/modules.conf" override="true">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/testmoduleconf</configfile>
- </feature>
-
<feature name='odl-toaster-rest' version='${project.version}'>
<feature version='${project.version}'>odl-restconf</feature>
<feature version='${project.version}'>odl-toaster</feature>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<artifactId>appauth</artifactId>
<version>0.5.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<artifactId>arphandler</artifactId>
<version>0.6.0-SNAPSHOT</version>
<artifactId>clustering.services.integrationtest</artifactId>
<version>0.5.0-SNAPSHOT</version>
<properties>
- <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.jacoco.itReportPath>../../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<!-- Sonar jacoco plugin to get integration test coverage info -->
- <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPath>../../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
- <destFile>../implementation/target/jacoco-it.exec</destFile>
+ <destFile>../../implementation/target/jacoco-it.exec</destFile>
<includes>
<include>org.opendaylight.controller.*</include>
</includes>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>clustering.services</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>clustering.services-implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>clustering.stub</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>clustering.test</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>commons.httpclient</artifactId>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>controller/checkstyle.xml</configLocation>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>commons.integrationtest</artifactId>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>controller/checkstyle.xml</configLocation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>${surefire.version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>configuration</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>configuration.implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>connectionmanager</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>connectionmanager.implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>containermanager</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>containermanager.implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>containermanager.it.implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>containermanager.shell</artifactId>
<version>${containermanager.shell.version}</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<artifactId>dummy-console</artifactId>
<version>1.2.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>commons.opendaylight</artifactId>\r
<version>1.5.0-SNAPSHOT</version>\r
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>\r
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>\r
</parent>\r
<artifactId>features-adsal-compatibility</artifactId>\r
<packaging>jar</packaging>\r
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>
</parent>
<artifactId>features-adsal</artifactId>
<version>${sal.version}</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>
</parent>
<artifactId>features-base</artifactId>
<packaging>jar</packaging>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>features-test</artifactId>
- <version>0.7.0-SNAPSHOT</version>
</dependency>
<!-- dependency for opendaylight-karaf-empty for use by testing -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>
</parent>
<artifactId>controller-features</artifactId>
<packaging>pom</packaging>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>
</parent>
<artifactId>extras-features</artifactId>
<packaging>kar</packaging>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../opendaylight/commons/opendaylight</relativePath>
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>
</parent>
<artifactId>features-nsf</artifactId>
<version>${nsf.version}</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>forwarding.staticrouting</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>forwardingrulesmanager</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>forwardingrulesmanager.implementation</artifactId>
<artifactId>forwardingrulesmanager.integrationtest</artifactId>
<version>0.5.0-SNAPSHOT</version>
<properties>
- <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.jacoco.itReportPath>../../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<!-- Sonar jacoco plugin to get integration test coverage info -->
- <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPath>../../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
- <destFile>../implementation/target/jacoco-it.exec</destFile>
+ <destFile>../../implementation/target/jacoco-it.exec</destFile>
<includes>
<include>org.opendaylight.controller.*</include>
</includes>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>hosttracker</artifactId>
<version>0.6.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>hosttracker.implementation</artifactId>
<version>0.6.0-SNAPSHOT</version>
<artifactId>hosttracker.integrationtest</artifactId>
<version>0.6.0-SNAPSHOT</version>
<properties>
- <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.jacoco.itReportPath>../../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<!-- Sonar jacoco plugin to get integration test coverage info -->
- <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPath>../../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
- <destFile>../implementation/target/jacoco-it.exec</destFile>
+ <destFile>../../implementation/target/jacoco-it.exec</destFile>
<includes>
<include>org.opendaylight.controller.*</include>
</includes>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>hosttracker.shell</artifactId>
<version>${hosttracker.shell.version}</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>hosttracker_new</artifactId>
<version>0.5.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>hosttracker_new.implementation</artifactId>
<version>0.5.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<artifactId>karaf-tomcat-security</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>logging.bridge</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>${artifactId}</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>bundlescanner</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>bundlescanner.implementation</artifactId>
if (classes == null || classes.size() == 0) return;
Map<String,String> names = new HashMap<String,String>();
StringBuilder conflictsMsg = new StringBuilder();
- for (Class c : classes) {
- XmlRootElement root = (XmlRootElement) c.getAnnotation(XmlRootElement.class);
+ for (Class<?> c : classes) {
+ XmlRootElement root = c.getAnnotation(XmlRootElement.class);
if (root == null) continue;
String rootName = root.name();
if ("##default".equals(rootName)) {
}
@Override
- public Enumeration findEntries(String path, String filePattern, boolean recurse) {
+ public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
return Collections.enumeration(classes);
}
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>commons.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>connectionmanager.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>containermanager.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>controllermanager.northbound</artifactId>
<version>0.1.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>flowprogrammer.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>hosttracker.northbound</artifactId>
<version>0.5.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>httpservice-bridge</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>northbound.client</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>jolokia-bridge</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>networkconfig.bridgedomain.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>forwarding.staticrouting.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>statistics.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>subnets.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>swagger-ui</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>usermanager.northbound</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron.northbound</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</fileset>
<mapper>
<regexpmapper from="^(.*)/([^/]+)/*/target/enunciate/generate/swagger/ui/(.*Northbound).*$$" to="\3"></regexpmapper>
+ <regexpmapper from="^(.*)/neutron/([^/]+)/*/target/enunciate/generate/swagger/ui/(.*resource-list.json)$$" to="neutron-\3"></regexpmapper>
<regexpmapper from="^(.*)/([^/]+)/*/target/enunciate/generate/swagger/ui/(.*resource-list.json)$$" to="\2-\3"></regexpmapper>
</mapper>
</copy>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>switchmanager.northbound</artifactId>
<version>0.5.0-SNAPSHOT</version>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>topology.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>usermanager.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../opendaylight/commons/opendaylight</relativePath>
+ <relativePath>../../../../opendaylight/commons/opendaylight</relativePath>
</parent>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
--- /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.parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../commons/parent</relativePath>
+ </parent>
+
+ <artifactId>adsal-parent</artifactId>
+ <packaging>pom</packaging>
+ <modules>
+ <module>forwarding/staticrouting</module>
+ <module>clustering/services</module>
+ <module>clustering/services_implementation</module>
+ <module>clustering/stub</module>
+ <module>clustering/test</module>
+ <module>configuration/api</module>
+ <module>configuration/implementation</module>
+ <module>routing/dijkstra_implementation</module>
+ <module>arphandler</module>
+ <module>forwardingrulesmanager/api</module>
+ <module>forwardingrulesmanager/implementation</module>
+ <module>hosttracker/api</module>
+ <module>hosttracker/implementation</module>
+ <module>hosttracker/shell</module>
+ <module>hosttracker_new/api</module>
+ <module>hosttracker_new/implementation</module>
+ <module>containermanager/api</module>
+ <module>containermanager/implementation</module>
+ <module>containermanager/shell</module>
+ <module>appauth</module>
+ <module>switchmanager/api</module>
+ <module>switchmanager/implementation</module>
+ <module>statisticsmanager/api</module>
+ <module>statisticsmanager/implementation</module>
+ <module>topologymanager/implementation</module>
+ <module>topologymanager/shell</module>
+ <module>usermanager/api</module>
+ <module>usermanager/implementation</module>
+ <module>connectionmanager/api</module>
+ <module>connectionmanager/implementation</module>
+ <module>security</module>
+ <module>karaf-tomcat-security</module>
+
+ <!-- SAL bundles -->
+ <module>sal/api</module>
+ <module>sal/implementation</module>
+
+ <!-- SAL Extension bundles -->
+ <module>sal/connection/api</module>
+ <module>sal/connection/implementation</module>
+ <module>sal/networkconfiguration/api</module>
+ <module>sal/networkconfiguration/implementation</module>
+
+ <!-- Web bundles -->
+ <module>web/root</module>
+ <module>web/flows</module>
+ <module>web/devices</module>
+ <module>web/troubleshoot</module>
+ <module>web/topology</module>
+ <module>web/osgi-brandfragment</module>
+
+ <!-- Northbound bundles -->
+ <module>northbound/commons</module>
+ <module>northbound/bundlescanner/api</module>
+ <module>northbound/bundlescanner/implementation</module>
+ <module>northbound/topology</module>
+ <module>northbound/staticrouting</module>
+ <module>northbound/statistics</module>
+ <module>northbound/flowprogrammer</module>
+ <module>northbound/hosttracker</module>
+ <module>northbound/subnets</module>
+ <module>northbound/switchmanager</module>
+ <module>northbound/containermanager</module>
+ <module>northbound/networkconfiguration/bridgedomain</module>
+ <module>northbound/httpservice-bridge</module>
+ <module>northbound/jolokia</module>
+ <module>northbound/connectionmanager</module>
+ <module>northbound/usermanager</module>
+ <module>northbound/controllermanager</module>
+
+ <!-- Debug and logging -->
+ <module>logging/bridge</module>
+
+ <!-- Southbound bundles -->
+ <module>protocol_plugins/openflow</module>
+ <module>protocol_plugins/stub</module>
+
+ <!-- Samples -->
+ <module>samples/simpleforwarding</module>
+ <module>samples/loadbalancer</module>
+ <module>samples/northbound/loadbalancer</module>
+
+ <module>dummy-console</module>
+
+ <!-- features -->
+ <module>features/base</module>
+ <module>features/controller</module>
+ <module>features/adsal</module>
+ <module>features/nsf</module>
+ <module>features/extras</module>
+ <module>features/adsal-compatibility</module>
+ </modules>
+ <profiles>
+ <profile>
+ <id>integrationtests</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>clustering/integrationtest</module>
+ <module>configuration/integrationtest</module>
+ <module>forwardingrulesmanager/integrationtest</module>
+ <module>hosttracker/integrationtest</module>
+ <module>switchmanager/integrationtest</module>
+ <module>topologymanager/integrationtest</module>
+ <!-- Northbound integration tests -->
+ <module>northbound/integrationtest</module>
+ <module>statisticsmanager/integrationtest</module>
+ <module>containermanager/it.implementation</module>
+ <module>commons/integrationtest</module>
+
+ <module>commons/httpclient</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>docs</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>northbound/java-client</module>
+ <module>northbound/swagger-ui</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>protocol_plugins.openflow</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>protocol_plugins.stub</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>routing.dijkstra_implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>sal</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>sal.connection</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>sal.connection.implementation</artifactId>
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-
import org.opendaylight.controller.sal.connection.ConnectionConstants;
import org.opendaylight.controller.sal.connection.ConnectionLocality;
import org.opendaylight.controller.sal.connection.IConnectionListener;
private ConcurrentMap<String, IPluginInConnectionService> pluginService =
new ConcurrentHashMap<String, IPluginInConnectionService>();
- void setPluginService (Map props, IPluginInConnectionService s) {
+ void setPluginService (Map<?, ?> props, IPluginInConnectionService s) {
String type = null;
Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
if (value instanceof String) {
}
}
- void unsetPluginService(Map props, IPluginInConnectionService s) {
+ void unsetPluginService(Map<?, ?> props, IPluginInConnectionService s) {
String type = null;
Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>sal.implementation</artifactId>
}
}
- void setPluginInDataService(Map props, IPluginInDataPacketService s) {
+ void setPluginInDataService(Map<?, ?> props, IPluginInDataPacketService s) {
ProtocolService.set(this.pluginInDataService, props, s, logger);
}
- void unsetPluginInDataService(Map props, IPluginInDataPacketService s) {
+ void unsetPluginInDataService(Map<?, ?> props, IPluginInDataPacketService s) {
ProtocolService.unset(this.pluginInDataService, props, s, logger);
}
- void setListenDataPacket(Map props, IListenDataPacket s) {
+ void setListenDataPacket(Map<?, ?> props, IListenDataPacket s) {
if (this.listenDataPacket == null || this.indexDataPacket == null) {
logger.error("data structure to store data is NULL");
return;
}
logger.trace("Received setListenDataPacket request");
- for (Object e : props.entrySet()) {
- Map.Entry entry = (Map.Entry) e;
- logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
+ for (Map.Entry<?, ?> e : props.entrySet()) {
+ logger.trace("Prop key:({}) value:({})",e.getKey(), e.getValue());
}
String listenerName = null;
}
}
- void unsetListenDataPacket(Map props, IListenDataPacket s) {
+ void unsetListenDataPacket(Map<?, ?> props, IListenDataPacket s) {
if (this.listenDataPacket == null || this.indexDataPacket == null) {
logger.error("data structure to store data is NULL");
return;
}
logger.trace("Received UNsetListenDataPacket request");
- for (Object e : props.entrySet()) {
- Map.Entry entry = (Map.Entry) e;
- logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
+ for (Map.Entry<?, ?> e : props.entrySet()) {
+ logger.trace("Prop key:({}) value:({})",e.getKey(), e.getValue());
}
String listenerName = null;
return false;
}
- ProtocolService plugin = (ProtocolService)o;
+ ProtocolService<?> plugin = (ProtocolService<?>)o;
return (service.equals(plugin.service) && priority == plugin.priority);
}
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>sal.networkconfiguration</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>sal.networkconfiguration.implementation</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.5.0-SNAPSHOT</version>
+ <relativePath>../../../commons/opendaylight</relativePath>
+ </parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustersession</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>javax.servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.catalina</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.catalina.ha</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.coyote</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.juli.extras</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.tomcat.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>orbit</groupId>
+ <artifactId>org.apache.tomcat.util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.5.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.5.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Fragment-Host>org.eclipse.gemini.web.tomcat</Fragment-Host>
+ <Export-Package>org.opendaylight.controller.clustersession</Export-Package>
+ <Import-Package>org.apache.catalina,
+ org.apache.catalina.session,
+ org.apache.catalina.util,
+ org.apache.catalina.ha.session,
+ javax.servlet,
+ javax.servlet.http,
+ org.slf4j,
+ org.osgi.framework,
+ org.eclipse.osgi.framework.console,
+ org.opendaylight.controller.clustering.services</Import-Package>
+ </instructions>
+ <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.opendaylight.controller.clustersession;
+
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.catalina.Manager;
+import org.apache.catalina.SessionListener;
+import org.apache.catalina.session.StandardSession;
+import org.opendaylight.controller.clustersession.service.ClusterSessionService;
+
+public class ClusterSession extends StandardSession implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private transient ClusterSessionService sessionService;
+
+ public ClusterSession(Manager manager, ClusterSessionService sessionService) {
+ super(manager);
+ this.sessionService = sessionService;
+ }
+
+ public void setSessionService(ClusterSessionService sessionService){
+ this.sessionService = sessionService;
+ }
+
+ @Override
+ public void setAuthType(String authType) {
+ super.setAuthType(authType);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setCreationTime(long time) {
+ super.setCreationTime(time);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setMaxInactiveInterval(int interval) {
+ super.setMaxInactiveInterval(interval);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setNew(boolean isNew) {
+ super.setNew(isNew);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setPrincipal(Principal principal) {
+ super.setPrincipal(principal);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setValid(boolean isValid) {
+ super.setValid(isValid);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void access() {
+ super.access();
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void endAccess() {
+ super.endAccess();
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void removeAttribute(String name, boolean notify) {
+ super.removeAttribute(name, notify);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setAttribute(String name, Object value, boolean notify) {
+ super.setAttribute(name, value, notify);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void recycle() {
+ super.recycle();
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void removeNote(String name) {
+ super.removeNote(name);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void addSessionListener(SessionListener listener) {
+ super.addSessionListener(listener);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void removeSessionListener(SessionListener listener) {
+ super.removeSessionListener(listener);
+ sessionService.updateSession(this);
+ }
+
+ @Override
+ public void setNote(String name, Object value) {
+ super.setNote(name, value);
+ sessionService.updateSession(this);
+ }
+
+ /*
+ * Certain fields inside Standard session are not serialized, We need to process them here
+ */
+ public void afterDeserialization(){
+ if (listeners == null){
+ listeners = new ArrayList<SessionListener>();
+ }
+ if (notes == null){
+ notes = new ConcurrentHashMap<String, Object>();
+ }
+ if(support == null){
+ support = new PropertyChangeSupport(this);
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ClusterSession[");
+ sb.append(id);
+ sb.append(", isNew : ");
+ sb.append(isNew);
+ sb.append(", isValid : ");
+ sb.append(isValid);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ /*
+ * These methods are added for deserialization purpose
+ */
+
+ public void setAuthTypeInternal(String authType){
+ this.authType = authType;
+ }
+
+ public void setPrincipalInternal(Principal principal){
+ this.principal = principal;
+ }
+
+ public void setNoteInternal(String name, Object value) {
+ notes.put(name, value);
+ }
+}
--- /dev/null
+package org.opendaylight.controller.clustersession;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class ClusterSessionData implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ private ClusterSession session;
+
+ private byte[] principalData;
+
+ private byte[] savedRequestData;
+
+ private byte[] savedPrincipalData;
+
+ private String authType;
+
+ private String userName;
+
+ private String password;
+
+ public ClusterSession getSession() {
+ return session;
+ }
+
+ public void setSession(final ClusterSession session) {
+ this.session = session;
+ }
+
+ public byte[] getPrincipalData() {
+ return principalData;
+ }
+
+ public void setPrincipalData(final byte[] principalData) {
+ this.principalData = Arrays.copyOf(principalData, principalData.length);
+ }
+
+ public String getAuthType() {
+ return authType;
+ }
+
+ public void setAuthType(String authType) {
+ this.authType = authType;
+ }
+
+ public byte[] getSavedRequestData() {
+ return savedRequestData;
+ }
+
+ public void setSavedRequestData(byte[] savedRequestData) {
+ this.savedRequestData = Arrays.copyOf(savedRequestData, savedRequestData.length);
+ }
+
+ public byte[] getSavedPrincipalData() {
+ return savedPrincipalData;
+ }
+
+ public void setSavedPrincipalData(byte[] savedPrincipalData) {
+ this.savedPrincipalData = Arrays.copyOf(savedPrincipalData, savedPrincipalData.length);
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ */
+package org.opendaylight.controller.clustersession;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleState;
+import org.apache.catalina.Session;
+import org.apache.catalina.session.ManagerBase;
+import org.apache.catalina.util.SessionIdGenerator;
+import org.opendaylight.controller.clustersession.impl.ClusterSessionServiceImpl;
+import org.opendaylight.controller.clustersession.service.ClusterSessionService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * ClusterSession Manager is a custom session manager, that is used to persist session data
+ * across cluster of a storage such as infinispan or memcache
+ * @author harman singh
+ *
+ */
+public class ClusterSessionManager extends ManagerBase{
+ /**
+ * Has this component been _started yet?
+ */
+ protected boolean started = false;
+
+ protected ClusterSessionService sessionService;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClusterSessionManager.class);
+ /**
+ * The descriptive information about this implementation.
+ */
+ protected static final String INFO = "ClusterSessionManager/1.0";
+
+ /**
+ * The descriptive name of this Manager implementation (for logging).
+ */
+ protected static final String NAME = "ClusterSessionManager";
+
+ public ClusterSessionManager(){
+ sessionService = new ClusterSessionServiceImpl(this);
+ }
+
+ /**
+ * Return descriptive information about this Manager implementation and
+ * the corresponding version number, in the format
+ * <code><description>/<version></code>.
+ */
+ @Override
+ public String getInfo(){
+ return INFO;
+ }
+
+ /**
+ * Return the descriptive short name of this Manager implementation.
+ */
+ @Override
+ public String getName(){
+ return NAME;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void load() throws ClassNotFoundException, IOException {
+ // We are not persisting any session in database, infinispan does not persist data.
+ // loading of persisted session is not required.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void unload() throws IOException {
+ // We are not persisting any session in database, infinispan does not persist data.
+ // unloading of session to persistence layer is not required.
+ }
+
+ /**
+ * Start this component and implement the requirements
+ * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents this component from being used
+ */
+ @Override
+ protected synchronized void startInternal() throws LifecycleException {
+ sessionIdGenerator = new SessionIdGenerator();
+ sessionIdGenerator.setJvmRoute(getJvmRoute());
+ sessionIdGenerator.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
+ sessionIdGenerator.setSecureRandomClass(getSecureRandomClass());
+ sessionIdGenerator.setSecureRandomProvider(getSecureRandomProvider());
+ sessionIdGenerator.setSessionIdLength(getSessionIdLength());
+ sessionService.startInternal(sessionIdGenerator);
+ setState(LifecycleState.STARTING);
+ }
+
+ /**
+ * Stop this component and implement the requirements
+ * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents this component from being used
+ */
+ @Override
+ protected synchronized void stopInternal() throws LifecycleException {
+ setState(LifecycleState.STOPPING);
+
+ // Expire all active sessions
+ Session sessions[] = findSessions();
+ for (int i = 0; i < sessions.length; i++) {
+ Session session = sessions[i];
+ try {
+ if (session.isValid()) {
+ session.expire();
+ }
+ } catch (Exception e) {
+ LOGGER.warn(e.toString());
+ } finally {
+ // Measure against memory leaking if references to the session
+ // object are kept in a shared field somewhere
+ session.recycle();
+ }
+ }
+ // Require a new random number generator if we are restarted
+ super.stopInternal();
+ sessionService.stopInternal();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void expireSession(final String sessionId){
+ LOGGER.debug("SESSION EXPIRE : ", sessionId);
+ sessionService.expireSession(sessionId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void remove(final Session session){
+ LOGGER.debug("SESSION REMOVE : ", session.getId());
+ sessionService.removeSession(session.getId());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void remove(Session session, boolean update) {
+ sessionService.removeSession(session.getId());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session findSession(final String id) throws IOException{
+ return sessionService.findSession(id);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session createSession(final String sessionId){
+ LOGGER.debug("SESSION CREATE : ", sessionId);
+ if(sessionId != null){
+ Session session = sessionService.findSession(sessionId);
+ if(session != null){
+ return session;
+ }
+ }
+ return sessionService.createSession(sessionId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session createEmptySession(){
+ return sessionService.createEmptySession();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void add(Session session){
+ LOGGER.debug("SESSION ADD : ", session.getId());
+ sessionService.addSession((ClusterSession)session);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HashMap<String, String> getSession(String sessionId){
+ return sessionService.getSession(sessionId);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session[] findSessions() {
+ return sessionService.findSessions();
+ }
+
+ public ClusterSessionService getSessionService() {
+ return sessionService;
+ }
+
+ public void setSessionService(ClusterSessionService sessionService) {
+ this.sessionService = sessionService;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ */
+package org.opendaylight.controller.clustersession;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.authenticator.SavedRequest;
+import org.apache.catalina.ha.session.SerializablePrincipal;
+import org.apache.catalina.realm.GenericPrincipal;
+import org.opendaylight.controller.clustersession.service.ClusterSessionService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ClusterSessionUtil will be used to convert ClusterSession object into ClusterSessionData object,
+ * which is serializable and can be passed for storage. This class also perform deserialization to
+ * create ClusterSession object
+ * @author harman singh
+ *
+ */
+
+public class ClusterSessionUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClusterSessionUtil.class);
+
+ private ClusterSessionUtil() {
+
+ }
+
+ /**
+ * Serialize the ClusterSession object to provide ClusterSessionData object,
+ * that will be used for storage like in inifinispan or memcache etc.
+ * @param session an instance of ClusterSession
+ * @return an instance of ClusterSessionData
+ */
+ public static ClusterSessionData getSerializableSession(ClusterSession session) {
+ if(session == null){
+ return null;
+ }
+ ClusterSessionData sessionData = new ClusterSessionData();
+ sessionData.setSession(session);
+ sessionData.setAuthType(session.getAuthType());
+ sessionData.setPrincipalData(serializePrincipal(session.getPrincipal()));
+ sessionData.setSavedRequestData(serializeSavedRequest(session.getNote(Constants.FORM_REQUEST_NOTE)));
+ Principal notePrincipal = (Principal) session.getNote(Constants.FORM_PRINCIPAL_NOTE);
+ byte[] principalBytes = serializePrincipal(notePrincipal);
+ sessionData.setSavedPrincipalData(principalBytes);
+ if(session.getPrincipal() == null && notePrincipal != null){
+ sessionData.setPrincipalData(principalBytes);
+ }
+ sessionData.setUserName((String) session.getNote(Constants.FORM_USERNAME));
+ sessionData.setPassword((String) session.getNote(Constants.FORM_PASSWORD));
+ return sessionData;
+ }
+
+ /**
+ * Deserialize the ClusterSessionData object that usually comes from storage
+ * to provide ClusterSession object,
+ * that will be used by Session Manager
+ * @param sessionData an instance of ClusterSessionData
+ * @param sessionService an instance of ClusterSessionService
+ * @param manager an instance of ClusterSessionManager
+ * @return an instance of ClusterSession
+ */
+
+ public static ClusterSession getDeserializedSession(ClusterSessionData sessionData, ClusterSessionService sessionService,
+ ClusterSessionManager manager) {
+ if(sessionData == null){
+ return null;
+ }
+ ClusterSession session = sessionData.getSession();
+ session.afterDeserialization();
+ session.setManager(manager);
+ session.setSessionService(sessionService);
+ if(sessionData.getAuthType() != null) {
+ session.setAuthTypeInternal(sessionData.getAuthType());
+ }
+ if(sessionData.getPrincipalData() != null && sessionData.getPrincipalData().length > 0){
+ session.setPrincipalInternal(deserializePrincipal(sessionData.getPrincipalData()));
+ }
+ if(sessionData.getSavedPrincipalData() != null && sessionData.getSavedPrincipalData().length > 0){
+ session.setNoteInternal(Constants.FORM_PRINCIPAL_NOTE, deserializePrincipal(sessionData.getSavedPrincipalData()));
+ }
+ if(sessionData.getSavedRequestData() != null && sessionData.getSavedRequestData().length > 0){
+ session.setNoteInternal(Constants.FORM_REQUEST_NOTE, deserializeSavedRequest(sessionData.getSavedRequestData()));
+ }
+ if(sessionData.getUserName() != null){
+ session.setNoteInternal(Constants.FORM_USERNAME, sessionData.getUserName());
+ }
+ if(sessionData.getPassword() != null){
+ session.setNoteInternal(Constants.FORM_PASSWORD, sessionData.getPassword());
+ }
+ return session;
+ }
+
+ private static byte[] serializePrincipal(final Principal principal){
+ if(principal == null) {
+ return new byte[0];
+ }
+ ByteArrayOutputStream bos = null;
+ ObjectOutputStream oos = null;
+ try {
+ bos = new ByteArrayOutputStream();
+ oos = new ObjectOutputStream(bos);
+ SerializablePrincipal.writePrincipal((GenericPrincipal) principal, oos );
+ oos.flush();
+ return bos.toByteArray();
+ } catch (IOException e) {
+ throw new IllegalArgumentException( "Non-serializable object", e);
+ } finally {
+ closeSilently(bos);
+ closeSilently(oos);
+ }
+ }
+
+ private static byte[] serializeSavedRequest(final Object obj) {
+ if(obj == null) {
+ return new byte[0];
+ }
+ final SavedRequest savedRequest = (SavedRequest) obj;
+ ByteArrayOutputStream bos = null;
+ ObjectOutputStream oos = null;
+ try {
+ bos = new ByteArrayOutputStream();
+ oos = new ObjectOutputStream(bos);
+ oos.writeObject(savedRequest.getContentType());
+ oos.writeObject(getHeaders(savedRequest));
+ oos.writeObject(newArrayList(savedRequest.getLocales()));
+ oos.writeObject(savedRequest.getMethod());
+ oos.writeObject(savedRequest.getQueryString());
+ oos.writeObject(savedRequest.getRequestURI());
+ oos.writeObject(savedRequest.getDecodedRequestURI());
+ oos.flush();
+ return bos.toByteArray();
+ } catch (IOException e) {
+ throw new IllegalArgumentException( "Non-serializable object", e);
+ } finally {
+ closeSilently(bos);
+ closeSilently(oos);
+ }
+ }
+
+ private static Principal deserializePrincipal(final byte[] data) {
+ ByteArrayInputStream bis = null;
+ ObjectInputStream ois = null;
+ try {
+ bis = new ByteArrayInputStream(data);
+ ois = new ObjectInputStream(bis);
+ return SerializablePrincipal.readPrincipal(ois);
+ } catch (IOException e) {
+ throw new IllegalArgumentException( "Could not deserialize principal", e);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException( "Could not deserialize principal", e);
+ } finally {
+ closeSilently(bis);
+ closeSilently(ois);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static SavedRequest deserializeSavedRequest(final byte[] data) {
+ ByteArrayInputStream bis = null;
+ ObjectInputStream ois = null;
+ try {
+ bis = new ByteArrayInputStream(data);
+ ois = new ObjectInputStream(bis);
+ final SavedRequest savedRequest = new SavedRequest();
+ savedRequest.setContentType((String) ois.readObject());
+ setHeaders(savedRequest, (Map<String, List<String>>) ois.readObject());
+ setLocales(savedRequest, (List<Locale>) ois.readObject());
+ savedRequest.setMethod((String) ois.readObject());
+ savedRequest.setQueryString((String) ois.readObject());
+ savedRequest.setRequestURI((String) ois.readObject());
+ savedRequest.setDecodedRequestURI((String) ois.readObject());
+ return savedRequest;
+ } catch (final IOException e) {
+ throw new IllegalArgumentException( "Could not deserialize SavedRequest", e );
+ } catch (final ClassNotFoundException e) {
+ throw new IllegalArgumentException( "Could not deserialize SavedRequest", e );
+ } finally {
+ closeSilently(bis);
+ closeSilently(ois);
+ }
+ }
+
+ private static void setLocales(final SavedRequest savedRequest, final List<Locale> locales) {
+ if(locales != null && !locales.isEmpty()) {
+ for (final Locale locale : locales) {
+ savedRequest.addLocale(locale);
+ }
+ }
+ }
+
+ private static <T> List<T> newArrayList(final Iterator<T> iter) {
+ if(!iter.hasNext()) {
+ return Collections.emptyList();
+ }
+ final List<T> result = new ArrayList<T>();
+ while (iter.hasNext()) {
+ result.add(iter.next());
+ }
+ return result;
+ }
+
+ private static Map<String, List<String>> getHeaders(final SavedRequest obj) {
+ final Map<String, List<String>> result = new HashMap<String, List<String>>();
+ final Iterator<String> namesIter = obj.getHeaderNames();
+ while (namesIter.hasNext()) {
+ final String name = namesIter.next();
+ final List<String> values = new ArrayList<String>();
+ result.put(name, values);
+ final Iterator<String> valuesIter = obj.getHeaderValues(name);
+ while (valuesIter.hasNext()) {
+ final String value = valuesIter.next();
+ values.add(value);
+ }
+ }
+ return result;
+ }
+
+ private static void setHeaders(final SavedRequest obj, final Map<String, List<String>> headers) {
+ if(headers != null) {
+ for (final Entry<String, List<String>> entry : headers.entrySet()) {
+ final List<String> values = entry.getValue();
+ for (final String value : values) {
+ obj.addHeader(entry.getKey(), value);
+ }
+ }
+ }
+ }
+
+ private static void closeSilently(final OutputStream os) {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (final IOException f) {
+ LOGGER.debug("Exception occurred while closing output stream", f.toString());
+ }
+ }
+ }
+
+ private static void closeSilently(final InputStream is) {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (final IOException f) {
+ LOGGER.debug("Exception occurred while closing input stream", f.toString());
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ */
+package org.opendaylight.controller.clustersession.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.catalina.Session;
+import org.apache.catalina.util.SessionIdGenerator;
+import org.opendaylight.controller.clustering.services.CacheConfigException;
+import org.opendaylight.controller.clustering.services.CacheExistException;
+import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
+import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.clustersession.ClusterSession;
+import org.opendaylight.controller.clustersession.ClusterSessionData;
+import org.opendaylight.controller.clustersession.ClusterSessionManager;
+import org.opendaylight.controller.clustersession.ClusterSessionUtil;
+import org.opendaylight.controller.clustersession.service.ClusterSessionService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+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;
+
+/**
+ * Implementation to persist and retrieve session data from infinispan cache
+ * @author harman singh
+ *
+ */
+public class ClusterSessionServiceImpl implements ClusterSessionService,
+ ServiceTrackerCustomizer<IClusterGlobalServices, IClusterGlobalServices>{
+
+ private IClusterGlobalServices clusterGlobalServices = null;
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClusterSessionServiceImpl.class);
+ private ConcurrentMap<String, ClusterSessionData> sessions = null;
+ private static final String SESSION_CACHE = "customSessionManager.sessionData";
+ private ClusterSessionManager manager = null;
+ private SessionIdGenerator sessionIdGenerator = null;
+ private BundleContext context = null;
+ private ServiceTracker<IClusterGlobalServices, IClusterGlobalServices> clusterTracker;
+ public ClusterSessionServiceImpl(ClusterSessionManager manager) {
+ this.manager = manager;
+ }
+ /**
+ * This method initialize the cluster service of opendaylight and
+ * create a cache map in infinispan
+ */
+
+ @Override
+ public void startInternal(SessionIdGenerator sessionIdGenerator){
+ this.sessionIdGenerator = sessionIdGenerator;
+ context = FrameworkUtil.getBundle(ClusterSessionManager.class).getBundleContext();
+ getClusterService();
+ createCache();
+ }
+
+ /**
+ * Removes the cluster service tracker while shut down
+ */
+ @Override
+ public void stopInternal(){
+ if(clusterTracker != null){
+ clusterTracker.close();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session findSession(final String id){
+ if(id == null) {
+ return null;
+ }
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return null;
+ }
+ ClusterSessionData sessionData = sessions.get(id);
+ if(sessionData != null) {
+ LOGGER.debug("SESSION FOUND : ", id);
+ } else {
+ LOGGER.debug("SESSION NOTFOUND : ", id);
+ }
+ return ClusterSessionUtil.getDeserializedSession(sessionData, this, this.manager);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session[] findSessions() {
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return new Session[0];
+ }
+ Collection<ClusterSessionData> sessionDataList = sessions.values();
+ ArrayList<ClusterSession> sessionList = new ArrayList<ClusterSession>();
+ for(ClusterSessionData sessionData : sessionDataList){
+ sessionList.add(ClusterSessionUtil.getDeserializedSession(sessionData, this, this.manager));
+ }
+ return sessionList.toArray(new Session[0]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void removeSession(final String id){
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return;
+ }
+ sessions.remove(id);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void expireSession(final String id){
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return;
+ }
+ ClusterSessionData sessionData = sessions.get(id);
+ if(sessionData != null) {
+ sessionData.getSession().expire();
+ removeSession(id);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session createSession(final String sessionId){
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return null;
+ }
+ Session session = createEmptySession();
+ session.setNew(true);
+ session.setValid(true);
+ session.setCreationTime(System.currentTimeMillis());
+ String id = sessionId;
+ if (id == null) {
+ id = generateSessionId();
+ }
+ session.setId(id);
+ return session;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSession(final ClusterSession session){
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return;
+ }
+ ClusterSessionData sessionData = ClusterSessionUtil.getSerializableSession(session);
+ sessions.put(session.getId(), sessionData);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Session createEmptySession(){
+ return getNewSession();
+ }
+
+ /**
+ * Returns information about the session with the given session id.
+ *
+ * <p>The session information is organized as a HashMap, mapping
+ * session attribute names to the String representation of their values.
+ *
+ * @param sessionId Session id
+ *
+ * @return HashMap mapping session attribute names to the String
+ * representation of their values, or null if no session with the
+ * specified id exists, or if the session does not have any attributes
+ */
+ public HashMap<String, String> getSession(String sessionId) {
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return null;
+ }
+ ClusterSessionData sessionData = sessions.get(sessionId);
+ if (sessionData == null) {
+ return null;
+ }
+ ClusterSession s = ClusterSessionUtil.getDeserializedSession(sessionData, this, this.manager);
+ Enumeration<String> ee = s.getAttributeNames();
+ if (ee == null || !ee.hasMoreElements()) {
+ return null;
+ }
+ HashMap<String, String> map = new HashMap<String, String>();
+ while (ee.hasMoreElements()) {
+ String attrName = ee.nextElement();
+ map.put(attrName, s.getAttribute(attrName).toString());
+ }
+ return map;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void updateSession(ClusterSession session) {
+ if(sessions == null) {
+ LOGGER.debug("Session cache not present, try to create.");
+ createCache();
+ return;
+ }
+ if(session.getId() != null && sessions.get(session.getId()) != null){
+ ClusterSessionData sessionData = ClusterSessionUtil.getSerializableSession(session);
+ sessions.put(session.getId(), sessionData);
+ }
+ }
+
+ @Override
+ public IClusterGlobalServices addingService(ServiceReference<IClusterGlobalServices> reference) {
+ if (clusterGlobalServices == null) {
+ this.clusterGlobalServices = context.getService(reference);
+ createCache();
+ return clusterGlobalServices;
+ }
+ return null;
+ }
+
+ @Override
+ public void modifiedService(ServiceReference<IClusterGlobalServices> reference, IClusterGlobalServices service) {
+ // This method is added from ServiceTracker interface, We don't have to modify service.
+ }
+
+ @Override
+ public void removedService(ServiceReference<IClusterGlobalServices> reference, IClusterGlobalServices service) {
+ if (clusterGlobalServices == service) {
+ clusterGlobalServices = null;
+ }
+ }
+
+ /*
+ * Return an instance of Standard Session object with current session manager
+ */
+ private ClusterSession getNewSession() {
+ return new ClusterSession(this.manager, this);
+ }
+
+ /*
+ * Generate and return a new session identifier.
+ */
+ private String generateSessionId() {
+ String result = null;
+ do {
+ result = sessionIdGenerator.generateSessionId();
+ } while (sessions.containsKey(result));
+ return result;
+ }
+
+ private void createCache() {
+ allocateCache();
+ retrieveCache();
+ }
+
+ /*
+ * This is a fragment bundle, so We can't use Activator to set Service.
+ * This is the alternative to get registered clustered service
+ */
+ private void getClusterService(){
+ if (context != null) {
+ clusterTracker = new ServiceTracker<>(context, IClusterGlobalServices.class, this);
+ clusterTracker.open();
+ }
+ }
+
+ /*
+ * Allocate space in infinispan to persist session data
+ */
+ private void allocateCache() {
+ if (clusterGlobalServices == null) {
+ LOGGER.trace("un-initialized clusterGlobalService, can't create cache");
+ return;
+ }
+ try {
+ clusterGlobalServices.createCache(SESSION_CACHE,
+ EnumSet.of(IClusterServices.cacheMode.SYNC , IClusterServices.cacheMode.TRANSACTIONAL));
+
+ } catch (CacheConfigException cce) {
+ LOGGER.error("Cache configuration invalid - check cache mode", cce.toString());
+ } catch (CacheExistException ce) {
+ LOGGER.debug("Skipping cache creation as already present", ce.toString());
+ }
+ }
+
+ /*
+ * Fetch cached session data map object from infinispan
+ */
+ @SuppressWarnings("unchecked")
+ private void retrieveCache(){
+ if (clusterGlobalServices == null) {
+ LOGGER.trace("un-initialized clusterGlobalService, can't retrieve cache");
+ return;
+ }
+ sessions = (ConcurrentMap<String, ClusterSessionData>)clusterGlobalServices.getCache(SESSION_CACHE);
+ if(sessions == null){
+ LOGGER.warn("Failed to get session cache");
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.controller.clustersession.service;
+
+import java.util.HashMap;
+
+import org.apache.catalina.Session;
+import org.apache.catalina.util.SessionIdGenerator;
+import org.opendaylight.controller.clustersession.ClusterSession;
+
+/**
+ * A service to handle session persistence and retrieval in any data store
+ *
+ * @author harman singh
+ *
+ */
+public interface ClusterSessionService {
+
+ /**
+ * This method performs all startup operations
+ */
+ void startInternal(SessionIdGenerator sessionIdGenerator);
+
+ /**
+ * Method to perform all clean up operations
+ */
+ void stopInternal();
+
+ /**
+ * Find Session object based on provided session id from persistance
+ * @param id
+ * @return an instance of Session
+ */
+ Session findSession(final String id);
+
+ /**
+ * Get an array of session objects available in storage
+ */
+ Session[] findSessions();
+
+ /**
+ * Remove a session object from persistence
+ * @param id of session object need to be removed
+ */
+ void removeSession(final String id);
+
+ /**
+ * Expire and remove a session object from persistence
+ * @param id of session object need to be expired
+ */
+ void expireSession(final String id);
+
+ /**
+ * Create a session object based on session id, if session is not present
+ * use random session id
+ * @param sessionId
+ * @return an instance of Session
+ */
+ Session createSession(final String sessionId);
+
+ /**
+ * Add a session object in persistence
+ * @param session an instance of ClusterSession
+ */
+ void addSession(final ClusterSession session);
+
+ /**
+ * Create an empty Session object
+ * @return session object
+ */
+ Session createEmptySession();
+
+ /**
+ * Fetch attributes of Session object fetched by supplied session id
+ * @param sessionId
+ * @return
+ */
+ HashMap<String, String> getSession(String sessionId);
+
+ /**
+ * update the session object in persistence
+ * @param session
+ */
+ void updateSession(final ClusterSession session);
+
+}
--- /dev/null
+package org.opendaylight.controller.clustersession;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Session;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
+import org.opendaylight.controller.clustersession.impl.ClusterSessionServiceImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({FrameworkUtil.class})
+public class ClusterSessionManagerTest {
+ static ClusterSessionManager manager = null;
+ static ClusterSessionServiceImpl sessionService = null;
+ private static final String SESSION_CACHE = "customSessionManager.sessionData";
+ static ConcurrentMap<String, ClusterSessionData> sessions = new ConcurrentHashMap<String, ClusterSessionData>();
+ private String sessionId = "1234567";
+ final String AUTH_TYPE = "FORM";
+ final String ATTRIBUTE_NAME = "AuthType";
+ final int SESSION_ID_LENGTH = 7;
+ @SuppressWarnings("unchecked")
+ @BeforeClass
+ public static void init(){
+ Bundle bundle = mock(Bundle.class);
+ BundleContext context = mock(BundleContext.class);
+ IClusterGlobalServices clusterGlobalService = mock(IClusterGlobalServices.class);
+ ServiceReference<IClusterGlobalServices> serviceReference = mock(ServiceReference.class);
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ when(FrameworkUtil.getBundle(ClusterSessionManager.class)).thenReturn(bundle);
+ when(bundle.getBundleContext()).thenReturn(context);
+ when(context.getService(serviceReference)).thenReturn(clusterGlobalService);
+ when((ConcurrentMap<String, ClusterSessionData>)clusterGlobalService.getCache(SESSION_CACHE)).thenReturn(sessions);
+ Context containerContext = mock(Context.class);
+ manager = new ClusterSessionManager();
+ manager.setContainer(containerContext);
+ try {
+ manager.startInternal();
+ } catch (LifecycleException e) {
+ }
+ sessionService = (ClusterSessionServiceImpl) manager.getSessionService();
+ sessionService.addingService(serviceReference);
+ }
+
+ @Test
+ public void checkSessionManagerCreated(){
+ assertEquals("session manager info does not match", "ClusterSessionManager/1.0", manager.getInfo());
+ assertEquals("session manager name does not match", "ClusterSessionManager", manager.getName());
+ }
+
+ @Test
+ public void testCreateEmptySession(){
+ Session session = manager.createEmptySession();
+ assertEquals("session manager does not match", manager, session.getManager());
+ }
+
+ @Test
+ public void testCreateRandomSessionId(){
+ Session session = manager.createSession(null);
+ assertEquals("Session should be valid", true, session.isValid());
+ manager.remove(session);
+ }
+
+ @Test
+ public void testCreateSession(){
+ Session session = manager.createSession(sessionId);
+ assertEquals("Session should be valid", true, session.isValid());
+ assertEquals("Session id does not match", sessionId, session.getId());
+ manager.remove(session);
+ }
+
+ @Test
+ public void testReCreateSession(){
+ Session session = manager.createSession(sessionId);
+ assertEquals("Session should be valid", true, session.isValid());
+ assertEquals("Session id does not match", sessionId, session.getId());
+ manager.createSession(sessionId);
+ manager.remove(session);
+ }
+
+ @Test
+ public void testSessionCRUD() throws IOException{
+ Session foundSession = manager.findSession(sessionId);
+ assertNull("Session should not exist here", foundSession);
+ Session session = manager.createSession(sessionId);
+ manager.add(session);
+ foundSession = manager.findSession(sessionId);
+ assertEquals("Session was not found, id does not match", sessionId, foundSession.getId());
+ manager.remove(session);
+ foundSession = manager.findSession(sessionId);
+ assertEquals("Session was not removed", null, foundSession);
+ }
+
+ @Test
+ public void testExpireSession() throws IOException{
+ Session session = manager.createSession(sessionId);
+ session.setAuthType(AUTH_TYPE);
+ manager.add(session);
+ Session foundSession = manager.findSession(sessionId);
+ assertEquals("Session was not found", sessionId, foundSession.getId());
+ manager.expireSession(sessionId);
+ foundSession = manager.findSession(sessionId);
+ assertEquals("Session was not expired", null, foundSession);
+ }
+
+ @Test
+ public void testFindSessions(){
+ Session session = manager.createSession(sessionId);
+ session.setAuthType(AUTH_TYPE);
+ manager.add(session);
+ Session[] sessions = manager.findSessions();
+ assertEquals("Session array size does not match", 1, sessions.length);
+ assertEquals("Session array size does not match", sessionId, sessions[0].getId());
+ manager.remove(session);
+ }
+
+ @Test
+ public void testGetSession(){
+ ClusterSession session = (ClusterSession) manager.createSession(sessionId);
+ session.setAttribute(ATTRIBUTE_NAME, AUTH_TYPE);
+ manager.add(session);
+ HashMap<String, String> sessionAttributes = manager.getSession(sessionId);
+ assertNotNull("Session attribute should not be null", sessionAttributes);
+ assertEquals("Session attribute size does not match", 1, sessionAttributes.size());
+ assertEquals("Session attribute size does not match", AUTH_TYPE, sessionAttributes.get(ATTRIBUTE_NAME));
+ manager.remove(session);
+ }
+
+ @AfterClass
+ public static void cleanup(){
+ try {
+ manager.stopInternal();
+ } catch (LifecycleException e) {
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.controller.clustersession;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Session;
+import org.apache.catalina.util.SessionIdGenerator;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
+import org.opendaylight.controller.clustersession.impl.ClusterSessionServiceImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({FrameworkUtil.class})
+public class ClusterSessionServiceImplTest {
+ static ClusterSessionManager manager = null;
+ static ClusterSessionServiceImpl sessionService = null;
+ private static final String SESSION_CACHE = "customSessionManager.sessionData";
+ static ConcurrentMap<String, ClusterSessionData> sessions = new ConcurrentHashMap<String, ClusterSessionData>();
+ private String sessionId = "1234567";
+ final String AUTH_TYPE = "FORM";
+ final String ATTRIBUTE_NAME = "AuthType";
+
+ @SuppressWarnings("unchecked")
+ @BeforeClass
+ public static void init(){
+ Bundle bundle = mock(Bundle.class);
+ BundleContext context = mock(BundleContext.class);
+ IClusterGlobalServices clusterGlobalService = mock(IClusterGlobalServices.class);
+ ServiceReference<IClusterGlobalServices> serviceReference = mock(ServiceReference.class);
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ when(FrameworkUtil.getBundle(ClusterSessionManager.class)).thenReturn(bundle);
+ when(bundle.getBundleContext()).thenReturn(context);
+ when(context.getService(serviceReference)).thenReturn(clusterGlobalService);
+ when((ConcurrentMap<String, ClusterSessionData>)clusterGlobalService.getCache(SESSION_CACHE)).thenReturn(sessions);
+ Context containerContext = mock(Context.class);
+ manager = new ClusterSessionManager();
+ sessionService = (ClusterSessionServiceImpl) manager.getSessionService();
+ manager.setContainer(containerContext);
+ sessionService.startInternal(new SessionIdGenerator());
+ sessionService.addingService(serviceReference);
+ }
+
+ @Test
+ public void testCreateEmptySession(){
+ Session session = sessionService.createEmptySession();
+ assertEquals("session manager does not match", manager, session.getManager());
+ }
+
+ @Test
+ public void testCreateSessionwithRandomId(){
+ Session session = sessionService.createSession(null);
+ assertEquals("Session should be valid", true, session.isValid());
+ sessionService.removeSession(session.getId());
+ }
+
+ @Test
+ public void testCreateSession(){
+ Session session = sessionService.createSession(sessionId);
+ assertEquals("Session should be valid", true, session.isValid());
+ assertEquals("Session id does not match", sessionId, session.getId());
+ sessionService.removeSession(sessionId);
+ }
+
+ @Test
+ public void testNullfindSession() {
+ Session session = sessionService.findSession(null);
+ assertNull("Session should be null", session);
+ }
+
+ @Test
+ public void testSessionCRUD(){
+ Session foundSession = sessionService.findSession(sessionId);
+ assertNull("Session should not exist here", foundSession);
+ Session session = sessionService.createSession(sessionId);
+ foundSession = sessionService.findSession(sessionId);
+ assertEquals("Session was not added", sessionId, foundSession.getId());
+ session.setAuthType(AUTH_TYPE);
+ sessionService.updateSession((ClusterSession)session);
+ foundSession = sessionService.findSession(sessionId);
+ assertEquals("Session was not found, id does not match", sessionId, foundSession.getId());
+ assertEquals("Session was not found, auth type does match", AUTH_TYPE, foundSession.getAuthType());
+ sessionService.removeSession(sessionId);
+ foundSession = sessionService.findSession(sessionId);
+ assertEquals("Session was not removed", null, foundSession);
+ }
+
+ @Test
+ public void testExpireSession(){
+ Session session = sessionService.createSession(sessionId);
+ session.setAuthType(AUTH_TYPE);
+ sessionService.addSession((ClusterSession)session);
+ Session foundSession = sessionService.findSession(sessionId);
+ assertEquals("Session was not found", sessionId, foundSession.getId());
+ sessionService.expireSession(sessionId);
+ foundSession = sessionService.findSession(sessionId);
+ assertEquals("Session was not expired", null, foundSession);
+ }
+
+ @Test
+ public void testFindSessions(){
+ Session session = sessionService.createSession(sessionId);
+ session.setAuthType(AUTH_TYPE);
+ sessionService.addSession((ClusterSession)session);
+ Session[] sessions = sessionService.findSessions();
+ assertEquals("Session array size does not match", 1, sessions.length);
+ assertEquals("Session array size does not match", sessionId, sessions[0].getId());
+ sessionService.removeSession(sessionId);
+ }
+
+ @Test
+ public void testGetSession(){
+ ClusterSession session = (ClusterSession) sessionService.createSession(sessionId);
+ session.setAttribute(ATTRIBUTE_NAME, AUTH_TYPE);
+ HashMap<String, String> sessionAttributes = sessionService.getSession(sessionId);
+ assertNotNull("Session attribute should not be null", sessionAttributes);
+ assertEquals("Session attribute size does not match", 1, sessionAttributes.size());
+ assertEquals("Session attribute size does not match", AUTH_TYPE, sessionAttributes.get(ATTRIBUTE_NAME));
+ sessionService.removeSession(sessionId);
+ }
+
+ @Test
+ public void testNullSessionCache(){
+ ClusterSessionManager clustermanager = new ClusterSessionManager();
+ ClusterSessionServiceImpl service = new ClusterSessionServiceImpl(clustermanager);
+ Session session = service.findSession(sessionId);
+ assertNull("Session should be null, as cache is null", session);
+ Session[] sessions = service.findSessions();
+ assertEquals("Session array should be empty", 0, sessions.length);
+ service.removeSession(sessionId);
+ service.expireSession(sessionId);
+ session = service.createSession(sessionId);
+ assertNull("Session should be null, as cache is null", session);
+ service.addSession(null);
+ Map<String,String> attributes = service.getSession(sessionId);
+ assertNull("Attributes should be null, as cache is null", attributes);
+ service.updateSession(null);
+ }
+
+ @AfterClass
+ public static void cleanup(){
+ sessionService.stopInternal();
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.controller.clustersession;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.catalina.authenticator.Constants;
+import org.apache.catalina.authenticator.SavedRequest;
+import org.apache.catalina.realm.GenericPrincipal;
+import org.junit.Test;
+import org.opendaylight.controller.clustersession.impl.ClusterSessionServiceImpl;
+import org.opendaylight.controller.clustersession.service.ClusterSessionService;
+
+
+public class ClusterSessionUtilTest {
+
+ final String AUTH_TYPE = "FORM";
+ final String ADMIN = "admin";
+ final String REQUEST_URI = "/test";
+ final String BLANK = "";
+ final String HEADER_NAME = "ContentType";
+ final String HEADER_VALUE = "JSON";
+ final long creationTime = 54545454L;
+ final int interval = 0;
+ ClusterSessionManager manager = new ClusterSessionManager();
+ ClusterSessionService sessionService = new ClusterSessionServiceImpl(manager);
+
+ @Test
+ public void testNullSerializableClusterSession() {
+ ClusterSessionData sessionData = ClusterSessionUtil.getSerializableSession(null);
+ assertEquals("Session data should be null for null session", null, sessionData);
+ }
+
+ @Test
+ public void testSerializableClusterSession() {
+ ClusterSession customSession = createClusterSesion();
+ ClusterSessionData sessionData = ClusterSessionUtil.getSerializableSession(customSession);
+ assertEquals("Session authentication type not valid", AUTH_TYPE, sessionData.getAuthType());
+ assertEquals("Session username does not match", ADMIN, sessionData.getUserName());
+ assertEquals("Session password does not match", ADMIN, sessionData.getPassword());
+ assertEquals("Session prinicpal does not match", ADMIN, sessionData.getSession().getPrincipal().getName());
+ }
+
+ @Test
+ public void testNullDeserialzableclusterSession() {
+ ClusterSession session = ClusterSessionUtil.getDeserializedSession(null, sessionService, manager);
+ assertEquals("Session should be null for null session data", null, session);
+ }
+
+ @Test
+ public void testDeserializableClusterSesion() {
+ ClusterSession customSession = createClusterSesion();
+ ClusterSessionData sessionData = ClusterSessionUtil.getSerializableSession(customSession);
+ customSession = sessionData.getSession();
+ customSession.setAuthType(AUTH_TYPE);
+ customSession.setNote(Constants.FORM_PRINCIPAL_NOTE, BLANK);
+ customSession.setNote(Constants.FORM_REQUEST_NOTE, BLANK);
+ ClusterSession session = ClusterSessionUtil.getDeserializedSession(sessionData, sessionService, manager);
+ assertEquals("Session authentication type not valid", AUTH_TYPE, session.getAuthType());
+ assertEquals("prinicpal name is not valid", ADMIN, session.getPrincipal().getName());
+ SavedRequest savedRequest = (SavedRequest)session.getNote(Constants.FORM_REQUEST_NOTE);
+ assertEquals("saved request uri does not match", REQUEST_URI, savedRequest.getRequestURI());
+ assertEquals("saved request header does not match", HEADER_VALUE, savedRequest.getHeaderValues(HEADER_NAME).next());
+ assertEquals("saved request header does not match", Locale.ENGLISH, savedRequest.getLocales().next());
+ String username = (String)session.getNote(Constants.FORM_USERNAME);
+ assertEquals("username does not match", ADMIN, username);
+ String password = (String)session.getNote(Constants.FORM_PASSWORD);
+ assertEquals("password does not match", ADMIN, password);
+ assertEquals("session manager does not match", manager, session.getManager());
+ assertEquals("session creation time does not match", creationTime, session.getCreationTime());
+ assertEquals("session man inactive interval does not match", interval, session.getMaxInactiveInterval());
+ assertEquals("is session new does not match", true, session.isNew());
+ assertEquals("is session valid does not match", true, session.isValid());
+ }
+
+ @Test
+ public void testSerializationtoFile(){
+ ClusterSession customSession = createClusterSesion();
+ ClusterSessionData sessionData = ClusterSessionUtil.getSerializableSession(customSession);
+ try(
+ OutputStream file = new FileOutputStream("sessionData.ser");
+ OutputStream buffer = new BufferedOutputStream(file);
+ ObjectOutput output = new ObjectOutputStream(buffer);
+ ){
+ output.writeObject(sessionData);
+ }
+ catch(IOException ex){
+ fail("IO exception while serializing object to a file.");
+ }
+ try(
+ InputStream file = new FileInputStream("sessionData.ser");
+ InputStream buffer = new BufferedInputStream(file);
+ ObjectInput input = new ObjectInputStream (buffer);
+ ){
+ //deserialize the session
+ ClusterSessionData recovedSession = (ClusterSessionData)input.readObject();
+ //display its data
+ ClusterSession session = ClusterSessionUtil.getDeserializedSession(recovedSession, sessionService, manager);
+ assertEquals("Session authentication type not valid", AUTH_TYPE, session.getAuthType());
+ assertEquals("prinicpal name is not valid", ADMIN, session.getPrincipal().getName());
+ SavedRequest savedRequest = (SavedRequest)session.getNote(Constants.FORM_REQUEST_NOTE);
+ assertEquals("saved request uri is not valid", REQUEST_URI, savedRequest.getRequestURI());
+ assertEquals("saved request header does not match", HEADER_VALUE, savedRequest.getHeaderValues(HEADER_NAME).next());
+ assertEquals("saved request header does not match", Locale.ENGLISH, savedRequest.getLocales().next());
+ String username = (String)session.getNote(Constants.FORM_USERNAME);
+ assertEquals("username does not match", ADMIN, username);
+ String password = (String)session.getNote(Constants.FORM_PASSWORD);
+ assertEquals("password does not match", ADMIN, password);
+ }
+ catch(ClassNotFoundException ex){
+ fail("Exception in object deserialization from file");
+ }
+ catch(IOException ex){
+ fail("Exception in object deserialization from file");
+ }
+ File serializedFile = new File("sessionData.ser");
+ serializedFile.delete();
+ }
+
+ private ClusterSession createClusterSesion(){
+ ClusterSession clusterSession = new ClusterSession(manager, sessionService);
+ clusterSession.setAuthType(AUTH_TYPE);
+ clusterSession.setCreationTime(creationTime);
+ clusterSession.setMaxInactiveInterval(interval);
+ clusterSession.setNew(true);
+ clusterSession.setValid(true);
+ List<String> roles = new ArrayList<String>();
+ roles.add(ADMIN);
+ GenericPrincipal principal = new GenericPrincipal(ADMIN, ADMIN, roles);
+ clusterSession.setPrincipal(principal);
+ clusterSession.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
+ SavedRequest savedRequest = new SavedRequest();
+ savedRequest.setRequestURI(REQUEST_URI);
+ savedRequest.addHeader(HEADER_NAME, HEADER_VALUE);
+ savedRequest.addLocale(Locale.ENGLISH);
+ clusterSession.setNote(Constants.FORM_REQUEST_NOTE, savedRequest);
+ clusterSession.setNote(Constants.FORM_USERNAME, ADMIN);
+ clusterSession.setNote(Constants.FORM_PASSWORD, ADMIN);
+ return clusterSession;
+ }
+}
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>samples.loadbalancer</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../../commons/opendaylight</relativePath>
+ <relativePath>../../../../commons/opendaylight</relativePath>
</parent>
<artifactId>samples.loadbalancer.northbound</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>samples.simpleforwarding</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<artifactId>security</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>statisticsmanager</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>statisticsmanager.implementation</artifactId>
<artifactId>statisticsmanager.integrationtest</artifactId>
<version>0.5.0-SNAPSHOT</version>
<properties>
- <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.jacoco.itReportPath>../../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<!-- Sonar jacoco plugin to get integration test coverage info -->
- <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPath>../../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
- <destFile>../implementation/target/jacoco-it.exec</destFile>
+ <destFile>../../implementation/target/jacoco-it.exec</destFile>
<includes>
<include>org.opendaylight.controller.*</include>
</includes>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>switchmanager</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>switchmanager.implementation</artifactId>
<artifactId>switchmanager.integrationtest</artifactId>
<version>0.5.0-SNAPSHOT</version>
<properties>
- <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.jacoco.itReportPath>../../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<!-- Sonar jacoco plugin to get integration test coverage info -->
- <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPath>../../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
- <destFile>../implementation/target/jacoco-it.exec</destFile>
+ <destFile>../../implementation/target/jacoco-it.exec</destFile>
<includes>
<include>org.opendaylight.controller.*</include>
</includes>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>topologymanager</artifactId>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>${bundle.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<artifactId>topologymanager.integrationtest</artifactId>
<version>0.5.0-SNAPSHOT</version>
<properties>
- <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.jacoco.itReportPath>../../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<!-- Sonar jacoco plugin to get integration test coverage info -->
- <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPath>../../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
- <destFile>../implementation/target/jacoco-it.exec</destFile>
+ <destFile>../../implementation/target/jacoco-it.exec</destFile>
<includes>
<include>org.opendaylight.controller.*</include>
</includes>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>topologymanager.shell</artifactId>
<version>${topologymanager.shell.version}</version>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>topologymanager</artifactId>
- <version>${topologymanager.version}</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>${bundle.plugin.version}</version>
<configuration>
<instructions>
<Import-Package>org.apache.felix.service.command,
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>usermanager</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>usermanager.implementation</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>devices.web</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>flows.web</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>osgi-brandfragment.web</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>web</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>topology.web</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <relativePath>../../../commons/opendaylight</relativePath>
</parent>
<artifactId>troubleshoot.web</artifactId>
final String jspFilter = "jspFilter";
final String exactMatch = "/somePath";
final String prefixFilter = "prefixFilter";
- LinkedHashMap<String, String> patternMap = new LinkedHashMap<String, String>() {
- {
- put(exactMatch, exactMatchFilter);
- put("/*", defaultFilter);
- put("*.jsp", jspFilter);
- put("/foo/*", prefixFilter);
- }
- };
+ LinkedHashMap<String, String> patternMap = new LinkedHashMap<>();
+ patternMap.put(exactMatch, exactMatchFilter);
+ patternMap.put("/*", defaultFilter);
+ patternMap.put("*.jsp", jspFilter);
+ patternMap.put("/foo/*", prefixFilter);
urlMatcher = new UrlMatcher<>(patternMap);
assertMatches("/abc", defaultFilter);
assertMatches(exactMatch, exactMatchFilter, defaultFilter);
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>controller/checkstyle.xml</configLocation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>${surefire.version}</version>
<configuration>
<argLine>${testvm.argLine} ${jacoco.agent.ut.arg}</argLine>
<systemProperties>
Object serviceTypeRaw = args[0];
Object serviceInstance = args[1];
- Dictionary<String, ?> props = (Dictionary) args[2];
+ Dictionary<String, ?> props = (Dictionary<String, ?>) args[2];
if (serviceTypeRaw instanceof Class) {
Class<?> serviceType = (Class<?>) serviceTypeRaw;
import org.opendaylight.controller.config.persist.api.PropertiesProvider;
public class PropertiesProviderTest implements PropertiesProvider {
- private final Map<String,String> properties = new HashMap();
+ private final Map<String,String> properties = new HashMap<>();
public void addProperty(String key,String value){
properties.put(key,value);
}
}
assertEquals("Expected identities not found " + copyOfExpectedNames,
- Collections.EMPTY_MAP, copyOfExpectedNames);
+ Collections.emptyMap(), copyOfExpectedNames);
}
@Test
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/</excludes>
</configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/</excludes>
</configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/</excludes>
</configuration>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
- <version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-inmemory-datastore</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller.model</groupId>
<artifactId>model-topology</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
<!-- toaster example I'm pretty sure we should trim -->
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>sample-toaster</artifactId>
- <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>sample-toaster-consumer</artifactId>
- <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>sample-toaster-provider</artifactId>
- <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<dependency>
<groupId>org.opendaylight.yangtools.thirdparty</groupId>
<artifactId>antlr4-runtime-osgi-nohead</artifactId>
- <version>4.0</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools.thirdparty</groupId>
<artifactId>xtend-lib-osgi</artifactId>
- <version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.openexi</groupId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
-<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
-<stringAttribute key="M2_GOALS" value="clean org.reficio:p2-maven-plugin:site"/>
-<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
-<booleanAttribute key="M2_OFFLINE" value="false"/>
-<stringAttribute key="M2_PROFILES" value=""/>
-<listAttribute key="M2_PROPERTIES"/>
-<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
-<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
-<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
-<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="true"/>
-<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
-<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.m2e.launching.MavenSourceLocator"/>
-<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"/> </sourceLookupDirector> "/>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx768m -XX:MaxPermSize=256m"/>
-<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/distribution.p2site}"/>
-</launchConfiguration>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
-
- <!-- p2site distribution is created with the intention of providing a -->
- <!-- target platform that could be use for PDE to create an OSGi -->
- <!-- launcher, this should allow to enable the hot code replacement on -->
- <!-- the controller. -->
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
- </parent>
- <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>
-
- <pluginRepositories>
- <pluginRepository>
- <id>reficio</id>
- <url>${nexusproxy}/repositories/reficioplugin/</url>
- </pluginRepository>
- </pluginRepositories>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>distribution.p2site</artifactId>
- <version>0.2.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.reficio</groupId>
- <artifactId>p2-maven-plugin</artifactId>
- <version>1.0.0</version>
- <executions>
- <execution>
- <id>default-cli</id>
- <configuration>
- <pedantic>true</pedantic>
- <artifacts>
- <artfiact>
- <id>org.slf4j:jcl-over-slf4j:${slf4j.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.slf4j:slf4j-api:${slf4j.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.slf4j:log4j-over-slf4j:${slf4j.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>ch.qos.logback:logback-core:${logback.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>ch.qos.logback:logback-classic:${logback.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.codehaus.jackson:jackson-mapper-asl:${jackson.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.codehaus.jackson:jackson-core-asl:${jackson.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.codehaus.jackson:jackson-jaxrs:${jackson.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.codehaus.jettison:jettison:1.3.3</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>commons-io:commons-io:2.4</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>commons-fileupload:commons-fileupload:1.2.2</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:javax.servlet:3.0.0.v201112011016</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:javax.servlet.jsp:2.2.0.v201112011158</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.equinox.ds:1.4.0.v20120522-1841</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.equinox.util:1.0.400.v20120522-2049</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.osgi.services:3.3.100.v20120522-1822</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.osgi:3.8.1.v20120830-144521</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.apache.felix.gogo.command:0.8.0.v201108120515</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.apache.felix.gogo.runtime:0.8.0.v201108120515</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.apache.felix.gogo.shell:0.8.0.v201110170705</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.equinox.cm:1.0.400.v20120522-1841</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.equinox.console:1.0.0.v20120522-1841</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>equinoxSDK381:org.eclipse.equinox.launcher:1.3.0.v20120522-1813</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.gemini.web.core:${geminiweb.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.gemini.web.extender:${geminiweb.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.gemini.web.tomcat:${geminiweb.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.kernel.equinox.extensions:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.util.common:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.util.io:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.util.math:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.util.osgi:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.util.osgi.manifest:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>geminiweb:org.eclipse.virgo.util.parser.manifest:${virgo.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.apache.felix:org.apache.felix.dependencymanager:3.1.0</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.apache.felix:org.apache.felix.dependencymanager.shell:3.0.1</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>com.google.code.gson:gson:2.1</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.1.Final</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.apache.commons:commons-lang3:3.1</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>virgomirror:org.eclipse.jdt.core.compiler.batch:3.8.0.I20120518-2145</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>eclipselink:javax.persistence:2.0.4.v201112161009</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.activation:1.1.0.v201211130549</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.annotation:1.1.0.v201209060031</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.ejb:3.1.1.v201204261316</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.el:2.2.0.v201108011116</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.mail.glassfish:1.4.1.v201108011116</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.xml.rpc:1.1.0.v201005080400</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.catalina:7.0.32.v201211201336</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.catalina.ha:7.0.32.v201211201952</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.catalina.tribes:7.0.32.v201211201952</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.coyote:7.0.32.v201211201952</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.el:7.0.32.v201211081135</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.jasper:7.0.32.v201211201952</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.juli.extras:7.0.32.v201211081135</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.tomcat.api:7.0.32.v201211081135</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:org.apache.tomcat.util:7.0.32.v201211201952</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.servlet.jsp.jstl:1.2.0.v201105211821</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>orbit:javax.servlet.jsp.jstl.impl:1.2.0.v201210211230</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.asm:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.aop:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.context:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.context.support:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.core:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.beans:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.expression:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.web:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.aopalliance:com.springsource.org.aopalliance:1.0.0</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.web.servlet:${spring.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework.security:spring-security-config:${spring-security.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework.security:spring-security-core:${spring-security.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework.security:spring-security-web:${spring-security.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework.security:spring-security-taglibs:${spring-security.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.springframework:org.springframework.transaction:${spring-security.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>org.ow2.chameleon.management:chameleon-mbeans:1.0.0</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>com.sun.jersey:jersey-core:${jersey.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>com.sun.jersey:jersey-server:${jersey.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>com.sun.jersey:jersey-client:${jersey.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- <artfiact>
- <id>com.sun.jersey:jersey-json:${jersey.version}</id>
- <transitive>false</transitive>
- <override>false</override>
- </artfiact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>8.1.5.v20120716</version>
- <configuration>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
- <webApp>
- <contextPath>/site</contextPath>
- </webApp>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
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.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.slf4j.Logger;
InstanceIdentifierBuilder<Node> builder = ((InstanceIdentifier<Node>) ref.getValue()).builder();
InstanceIdentifierBuilder<FlowCapableNode> augmentation = builder.augmentation(FlowCapableNode.class);
final InstanceIdentifier<FlowCapableNode> path = augmentation.build();
- CheckedFuture readFuture = tx.read(LogicalDatastoreType.OPERATIONAL, path);
- Futures.addCallback(readFuture, new FutureCallback<Optional<? extends DataObject>>() {
+ CheckedFuture<Optional<FlowCapableNode>, ?> readFuture = tx.read(LogicalDatastoreType.OPERATIONAL, path);
+ Futures.addCallback(readFuture, new FutureCallback<Optional<FlowCapableNode>>() {
@Override
- public void onSuccess(Optional<? extends DataObject> optional) {
+ public void onSuccess(Optional<FlowCapableNode> optional) {
enqueueWriteNodeDataTx(node, flowNode, path);
if (!optional.isPresent()) {
enqueuePutTable0Tx(ref);
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-clustering-commons</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
public static Props props(final ActorRef target){
return Props.create(new Creator<ClientActor>(){
+ private static final long serialVersionUID = 1L;
@Override public ClientActor create() throws Exception {
return new ClientActor(target);
public static Props props(final String id, final Map<String, String> peerAddresses,
final Optional<ConfigParams> configParams){
return Props.create(new Creator<ExampleActor>(){
+ private static final long serialVersionUID = 1L;
@Override public ExampleActor create() throws Exception {
return new ExampleActor(id, peerAddresses, configParams);
@Override protected void applySnapshot(final ByteString snapshot) {
state.clear();
try {
- state.putAll((HashMap) toObject(snapshot));
+ state.putAll((Map<String, String>) toObject(snapshot));
} catch (Exception e) {
LOG.error(e, "Exception in applying snapshot");
}
if(LOG.isDebugEnabled()) {
- LOG.debug("Snapshot applied to state : {}", ((HashMap) state).size());
+ LOG.debug("Snapshot applied to state : {}", ((Map<?, ?>) state).size());
}
}
import java.util.Map;
public class KeyValue extends Payload implements Serializable {
+ private static final long serialVersionUID = 1L;
private String key;
private String value;
import java.io.Serializable;
public class KeyValueSaved implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class PrintRole implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class PrintState implements Serializable {
+ private static final long serialVersionUID = 1L;
}
}
static class DeleteEntries implements Serializable {
+ private static final long serialVersionUID = 1L;
private final int fromIndex;
-
public DeleteEntries(int fromIndex) {
this.fromIndex = fromIndex;
}
}
static class UpdateElectionTerm implements Serializable {
+ private static final long serialVersionUID = 1L;
private final long currentTerm;
private final String votedFor;
public class ReplicatedLogImplEntry implements ReplicatedLogEntry,
Serializable {
+ private static final long serialVersionUID = 1L;
private final long index;
private final long term;
public class Snapshot implements Serializable {
+ private static final long serialVersionUID = 1L;
private final byte[] state;
private final List<ReplicatedLogEntry> unAppliedEntries;
private final long lastIndex;
*
*/
public class ApplyLogEntries implements Serializable {
+ private static final long serialVersionUID = 1L;
private final int toIndex;
public ApplyLogEntries(int toIndex) {
* Internal message, issued by follower to its actor
*/
public class ApplySnapshot implements Serializable {
+ private static final long serialVersionUID = 1L;
private final Snapshot snapshot;
public ApplySnapshot(Snapshot snapshot) {
import java.io.Serializable;
public class ApplyState implements Serializable {
+ private static final long serialVersionUID = 1L;
private final ActorRef clientActor;
private final String identifier;
private final ReplicatedLogEntry replicatedLogEntry;
* Message sent to commit an entry to the log
*/
public class CommitEntry implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class ElectionTimeout implements Serializable {
+ private static final long serialVersionUID = 1L;
}
* Message sent to Persist an entry into the transaction journal
*/
public class PersistEntry implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class Replicate implements Serializable {
+ private static final long serialVersionUID = 1L;
private final ActorRef clientActor;
private final String identifier;
private final ReplicatedLogEntry replicatedLogEntry;
* it and use it to save it's state
*/
public class SaveSnapshot implements Serializable {
+ private static final long serialVersionUID = 1L;
}
* Typically the Leader to itself on a schedule
*/
public class SendHeartBeat implements Serializable {
+ private static final long serialVersionUID = 1L;
}
public class Leader extends AbstractRaftActorBehavior {
- protected final Map<String, FollowerLogInformation> followerToLog = new HashMap();
+ protected final Map<String, FollowerLogInformation> followerToLog = new HashMap<>();
protected final Map<String, FollowerToSnapshot> mapFollowerToSnapshot = new HashMap<>();
private final Set<String> followers;
import java.io.Serializable;
public class FindLeader implements Serializable{
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class FindLeaderReply implements Serializable {
+ private static final long serialVersionUID = 1L;
private final String leaderActor;
public FindLeaderReply(String leaderActor) {
package org.opendaylight.controller.cluster.raft.messages;
public class AbstractRaftRPC implements RaftRPC {
+ private static final long serialVersionUID = 1L;
// term
protected long term;
* heartbeat (§5.2).
*/
public class AppendEntries extends AbstractRaftRPC {
-
- public static final Class SERIALIZABLE_CLASS = AppendEntriesMessages.AppendEntries.class;
+ public static final Class<AppendEntriesMessages.AppendEntries> SERIALIZABLE_CLASS = AppendEntriesMessages.AppendEntries.class;
private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(AppendEntries.class);
+ private static final long serialVersionUID = 1L;
// So that follower can redirect clients
private final String leaderId;
* Reply for the AppendEntriesRpc message
*/
public class AppendEntriesReply extends AbstractRaftRPC {
+ private static final long serialVersionUID = 1L;
// true if follower contained entry matching
// prevLogIndex and prevLogTerm
public class InstallSnapshot extends AbstractRaftRPC {
- public static final Class SERIALIZABLE_CLASS = InstallSnapshotMessages.InstallSnapshot.class;
+ public static final Class<InstallSnapshotMessages.InstallSnapshot> SERIALIZABLE_CLASS = InstallSnapshotMessages.InstallSnapshot.class;
+ private static final long serialVersionUID = 1L;
private final String leaderId;
private final long lastIncludedIndex;
package org.opendaylight.controller.cluster.raft.messages;
public class InstallSnapshotReply extends AbstractRaftRPC {
+ private static final long serialVersionUID = 1L;
// The followerId - this will be used to figure out which follower is
// responding
* Invoked by candidates to gather votes (§5.2).
*/
public class RequestVote extends AbstractRaftRPC {
+ private static final long serialVersionUID = 1L;
// candidate requesting vote
private String candidateId;
package org.opendaylight.controller.cluster.raft.messages;
public class RequestVoteReply extends AbstractRaftRPC {
+ private static final long serialVersionUID = 1L;
// true means candidate received vot
private final boolean voteGranted;
private long lastApplied = 0;
private final ElectionTerm electionTerm;
private ReplicatedLog replicatedLog;
- private Map<String, String> peerAddresses = new HashMap();
+ private Map<String, String> peerAddresses = new HashMap<>();
private ConfigParams configParams;
public MockRaftActorContext(){
}
public static class MockPayload extends Payload implements Serializable {
+ private static final long serialVersionUID = 1L;
private String value = "";
public MockPayload(){
}
public static class MockReplicatedLogEntry implements ReplicatedLogEntry, Serializable {
+ private static final long serialVersionUID = 1L;
private final long term;
private final long index;
private final RaftActor delegate;
public static final class MockRaftActorCreator implements Creator<MockRaftActor> {
+ private static final long serialVersionUID = 1L;
private final Map<String, String> peerAddresses;
private final String id;
private final Optional<ConfigParams> config;
Object data = toObject(snapshot);
System.out.println("!!!!!applyRecoverySnapshot: "+data);
if (data instanceof List) {
- state.addAll((List) data);
+ state.addAll((List<?>) data);
}
} catch (Exception e) {
e.printStackTrace();
super(actorSystem);
raftActor = this.getSystem().actorOf(MockRaftActor.props(actorName,
- Collections.EMPTY_MAP, Optional.<ConfigParams>absent()), actorName);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>absent()), actorName);
}
return raftActor;
}
- public boolean waitForLogMessage(final Class logEventClass, String message){
+ public boolean waitForLogMessage(final Class<?> logEventClass, String message){
// Wait for a specific log message to show up
return
new JavaTestKit.EventFilter<Boolean>(logEventClass
config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
ActorRef followerActor = getSystem().actorOf(MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config)), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config)), persistenceId);
watch(followerActor);
//reinstate the actor
TestActorRef<MockRaftActor> ref = TestActorRef.create(getSystem(),
- MockRaftActor.props(persistenceId, Collections.EMPTY_MAP,
+ MockRaftActor.props(persistenceId, Collections.<String,String>emptyMap(),
Optional.<ConfigParams>of(config)));
ref.underlyingActor().waitForRecoveryComplete();
config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config)), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config)), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), new DataPersistenceProviderMonitor()), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), new DataPersistenceProviderMonitor()), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
dataPersistenceProviderMonitor.setPersistLatch(persistLatch);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProviderMonitor), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProviderMonitor), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(),
- MockRaftActor.props(persistenceId,Collections.EMPTY_MAP,
+ MockRaftActor.props(persistenceId,Collections.<String,String>emptyMap(),
Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProvider), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProviderMonitor dataPersistenceProviderMonitor = new DataPersistenceProviderMonitor();
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProviderMonitor), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProviderMonitor), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
DataPersistenceProviderMonitor dataPersistenceProviderMonitor = new DataPersistenceProviderMonitor();
TestActorRef<MockRaftActor> mockActorRef = TestActorRef.create(getSystem(), MockRaftActor.props(persistenceId,
- Collections.EMPTY_MAP, Optional.<ConfigParams>of(config), dataPersistenceProviderMonitor), persistenceId);
+ Collections.<String,String>emptyMap(), Optional.<ConfigParams>of(config), dataPersistenceProviderMonitor), persistenceId);
MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
import org.opendaylight.controller.cluster.raft.MockRaftActorContext;
import org.opendaylight.controller.cluster.raft.RaftActorContext;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout;
import org.opendaylight.controller.cluster.raft.messages.AppendEntries;
import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
import org.opendaylight.controller.cluster.raft.messages.RequestVote;
import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import static org.junit.Assert.assertEquals;
public class CandidateTest extends AbstractRaftActorBehaviorTest {
Candidate candidate = new Candidate(createActorContext(getTestActor()));
- candidate.handleMessage(getTestActor(), new AppendEntries(0, "test", 0,0,Collections.EMPTY_LIST, 0));
+ candidate.handleMessage(getTestActor(), new AppendEntries(0, "test", 0,0,Collections.<ReplicatedLogEntry>emptyList(), 0));
final Boolean out = new ExpectMsg<Boolean>(duration("1 seconds"), "AppendEntriesResponse") {
// do not put code outside this method, will run afterwards
MockRaftActorContext actorContext = (MockRaftActorContext) createActorContext();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
MockRaftActorContext actorContext =
(MockRaftActorContext) createActorContext();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
new JavaTestKit(getSystem()) {{
ActorRef followerActor = getSystem().actorOf(Props.create(MessageCollectorActor.class));
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ForwardMessageToBehaviorActor.setBehavior(follower);
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ForwardMessageToBehaviorActor.setBehavior(follower);
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
MockRaftActorContext leaderActorContext =
new MockRaftActorContext("leader", getSystem(), leaderActor);
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put("follower-1",
followerActor.path().toString());
leaderActorContext.setReplicatedLog(
new MockRaftActorContext.MockReplicatedLogBuilder().createEntries(0, 3, 1).build());
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put("follower-1",
followerActor.path().toString());
* @param clazz
* @return
*/
- public static Object getFirstMatching(ActorRef actor, Class clazz) throws Exception {
+ public static Object getFirstMatching(ActorRef actor, Class<?> clazz) throws Exception {
List<Object> allMessages = getAllMessages(actor);
for(Object message : allMessages){
return null;
}
- public static List<Object> getAllMatching(ActorRef actor, Class clazz) throws Exception {
+ public static List<Object> getAllMatching(ActorRef actor, Class<?> clazz) throws Exception {
List<Object> allMessages = getAllMessages(actor);
List<Object> output = Lists.newArrayList();
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-data-codec</artifactId>
- <version>0.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
*/
package org.opendaylight.controller.config.yang.md.sal.binding.impl;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.Hashtable;
-import java.util.Map.Entry;
-import java.util.Set;
import javassist.ClassPool;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-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.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
*/
public final class RuntimeMappingModule extends AbstractRuntimeMappingModule {
- private static final Logger LOG = LoggerFactory.getLogger(RuntimeMappingModule.class);
-
private BundleContext bundleContext;
public RuntimeMappingModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
public java.lang.AutoCloseable createInstance() {
final GeneratedClassLoadingStrategy classLoading = getGlobalClassLoadingStrategy();
final BindingIndependentMappingService legacyMapping = getGlobalLegacyMappingService(classLoading);
- BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(new StreamWriterGenerator(SingletonHolder.JAVASSIST));
+ BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
BindingToNormalizedNodeCodec instance = new BindingToNormalizedNodeCodec(classLoading, legacyMapping, codecRegistry);
bundleContext.registerService(SchemaContextListener.class, instance, new Hashtable<String,String>());
return instance;
public void setBundleContext(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
-
- private static final class RuntimeGeneratedMappingServiceProxy implements //
- BindingIndependentMappingService, //
- Delegator<BindingIndependentMappingService>, //
- AutoCloseable {
-
- private BindingIndependentMappingService delegate;
- private ServiceReference<BindingIndependentMappingService> reference;
- private BundleContext bundleContext;
-
- public RuntimeGeneratedMappingServiceProxy(final BundleContext bundleContext,
- final ServiceReference<BindingIndependentMappingService> serviceRef,
- final BindingIndependentMappingService delegate) {
- this.bundleContext = Preconditions.checkNotNull(bundleContext);
- this.reference = Preconditions.checkNotNull(serviceRef);
- this.delegate = Preconditions.checkNotNull(delegate);
- }
-
- @Override
- public CodecRegistry getCodecRegistry() {
- return delegate.getCodecRegistry();
- }
-
- @Override
- public CompositeNode toDataDom(final DataObject data) {
- return delegate.toDataDom(data);
- }
-
- @Override
- public Entry<YangInstanceIdentifier, CompositeNode> toDataDom(
- final Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry) {
- return delegate.toDataDom(entry);
- }
-
- @Override
- public YangInstanceIdentifier toDataDom(final InstanceIdentifier<? extends DataObject> path) {
- return delegate.toDataDom(path);
- }
-
- @Override
- public DataObject dataObjectFromDataDom(
- final InstanceIdentifier<? extends DataObject> path,
- final CompositeNode result) throws DeserializationException {
- return delegate.dataObjectFromDataDom(path, result);
- }
-
- @Override
- public InstanceIdentifier<?> fromDataDom(final YangInstanceIdentifier entry)
- throws DeserializationException {
- return delegate.fromDataDom(entry);
- }
-
- @Override
- public Set<QName> getRpcQNamesFor(final Class<? extends RpcService> service) {
- return delegate.getRpcQNamesFor(service);
- }
-
- @Override
- public Optional<Class<? extends RpcService>> getRpcServiceClassFor(final String namespace, final String revision) {
- return delegate.getRpcServiceClassFor(namespace,revision);
- }
-
- @Override
- public DataContainer dataObjectFromDataDom(final Class<? extends DataContainer> inputClass, final CompositeNode domInput) {
- return delegate.dataObjectFromDataDom(inputClass, domInput);
- }
-
- @Override
- public void close() {
- if(delegate != null) {
- delegate = null;
-
- try {
- bundleContext.ungetService(reference);
- } catch (IllegalStateException e) {
- // Indicates the BundleContext is no longer valid which can happen normally on shutdown.
- LOG.debug( "Error unregistering service", e );
- }
-
- bundleContext= null;
- reference = null;
- }
- }
-
- @Override
- public BindingIndependentMappingService getDelegate() {
- return delegate;
- }
- }
}
if (path.isWildcarded()) {
return Optional.absent();
}
- return (Optional) getCodec().deserializeFunction(path).apply(Optional.<NormalizedNode<?, ?>> of(data));
+ return (Optional<DataObject>) getCodec().deserializeFunction(path).apply(Optional.<NormalizedNode<?, ?>> of(data));
}
private class TranslatingDataChangeInvoker implements DOMDataChangeListener {
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-test-model</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
- <version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
- <version>1.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
- <version>1.5</version>
</dependency>
<dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
- <version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
public T mailboxCapacity(int capacity) {
Preconditions.checkArgument(capacity > 0, "mailbox capacity must be >0");
- Map<String, Object> boundedMailbox = (Map) configHolder.get(TAG_MAILBOX);
+ Map<String, Object> boundedMailbox = (Map<String, Object>) configHolder.get(TAG_MAILBOX);
boundedMailbox.put(TAG_MAILBOX_CAPACITY, capacity);
return (T)this;
}
Duration pushTimeout = Duration.create(timeout);
Preconditions.checkArgument(pushTimeout.isFinite(), "invalid value for mailbox push timeout");
- Map<String, Object> boundedMailbox = (Map) configHolder.get(TAG_MAILBOX);
+ Map<String, Object> boundedMailbox = (Map<String, Object>) configHolder.get(TAG_MAILBOX);
boundedMailbox.put(TAG_MAILBOX_PUSH_TIMEOUT, timeout);
return (T)this;
}
return; //there's no actor to monitor
}
String actorName = owner.get().path().toStringWithoutAddress();
- String metricName = registry.name(actorName, QUEUE_SIZE);
+ String metricName = MetricRegistry.name(actorName, QUEUE_SIZE);
if (registry.getMetrics().containsKey(metricName))
return; //already registered
- Gauge queueSize = getQueueSizeGuage(monitoredQueue);
+ Gauge<Integer> queueSize = getQueueSizeGuage(monitoredQueue);
registerQueueSizeMetric(metricName, queueSize);
}
public static class MeteredMessageQueue extends BoundedDequeBasedMailbox.MessageQueue {
+ private static final long serialVersionUID = 1L;
public MeteredMessageQueue(int capacity, FiniteDuration pushTimeOut) {
super(capacity, pushTimeOut);
}
}
- private Gauge getQueueSizeGuage(final MeteredMessageQueue monitoredQueue ){
+ private Gauge<Integer> getQueueSizeGuage(final MeteredMessageQueue monitoredQueue ){
return new Gauge<Integer>() {
@Override
public Integer getValue() {
};
}
- private void registerQueueSizeMetric(String metricName, Gauge metric){
+ private void registerQueueSizeMetric(String metricName, Gauge<Integer> metric){
try {
registry.register(metricName,metric);
} catch (IllegalArgumentException e) {
import java.io.Serializable;
public class Monitor implements Serializable {
+ private static final long serialVersionUID = 1L;
private final ActorRef actorRef;
public Monitor(ActorRef actorRef){
public class NormalizedNodeGetter implements
NormalizedNodeVisitor {
private final String path;
- NormalizedNode output;
+ NormalizedNode<?, ?> output;
public NormalizedNodeGetter(String path){
Preconditions.checkNotNull(path);
}
@Override
- public void visitNode(int level, String parentPath, NormalizedNode normalizedNode) {
+ public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
String nodePath = parentPath + "/"+ PathUtils.toString(normalizedNode.getIdentifier());
if(nodePath.toString().equals(path)){
}
}
- public NormalizedNode getOutput(){
+ public NormalizedNode<?, ?> getOutput(){
return output;
}
}
String newParentPath = parentPath + "/" + node.getIdentifier().toString();
final Iterable<? extends NormalizedNode<?, ?>> value = node.getValue();
- for(NormalizedNode normalizedNode : value){
+ for(NormalizedNode<?, ?> normalizedNode : value){
if(normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer){
navigateNormalizedNodeContainerMixin(level + 1, newParentPath, (NormalizedNodeContainer) normalizedNode);
} else {
private void navigateNormalizedNode(int level, String parentPath, NormalizedNode<?,?> normalizedNode){
if(normalizedNode instanceof DataContainerNode){
- final DataContainerNode<?> dataContainerNode = (DataContainerNode) normalizedNode;
+ final DataContainerNode<?> dataContainerNode = (DataContainerNode<?>) normalizedNode;
navigateDataContainerNode(level + 1, parentPath, dataContainerNode);
} else {
}
@Override
- public void visitNode(int level, String parentPath, NormalizedNode normalizedNode) {
+ public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
System.out.println(spaces((level) * 4) + normalizedNode.getClass().toString() + ":" + normalizedNode.getIdentifier());
if(normalizedNode instanceof LeafNode || normalizedNode instanceof LeafSetEntryNode){
System.out.println(spaces((level) * 4) + " parentPath = " + parentPath);
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public interface NormalizedNodeVisitor {
- public void visitNode(int level, String parentPath, NormalizedNode normalizedNode);
+ public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode);
}
* @param node
* @return
*/
- public static NormalizedNodeMessages.Node serialize(NormalizedNode node){
+ public static NormalizedNodeMessages.Node serialize(NormalizedNode<?, ?> node){
Preconditions.checkNotNull(node, "node should not be null");
return new Serializer(node).serialize();
}
- public static Serializer newSerializer(NormalizedNode node) {
+ public static Serializer newSerializer(NormalizedNode<?, ?> node) {
Preconditions.checkNotNull(node, "node should not be null");
return new Serializer(node);
}
* @param node
* @return
*/
- public static NormalizedNode deSerialize(NormalizedNodeMessages.Node node) {
+ public static NormalizedNode<?, ?> deSerialize(NormalizedNodeMessages.Node node) {
Preconditions.checkNotNull(node, "node should not be null");
return new DeSerializer(null, node).deSerialize();
}
public static class Serializer extends QNameSerializationContextImpl
implements NormalizedNodeSerializationContext {
- private final NormalizedNode node;
+ private final NormalizedNode<?, ?> node;
private NormalizedNodeMessages.InstanceIdentifier serializedPath;
- private Serializer(NormalizedNode node) {
+ private Serializer(NormalizedNode<?, ?> node) {
this.node = node;
}
}
private NormalizedNodeMessages.Node.Builder serialize(
- NormalizedNode node) {
+ NormalizedNode<?, ?> node) {
NormalizedNodeMessages.Node.Builder builder =
NormalizedNodeMessages.Node.newBuilder();
for (Object o : iterable) {
if (o instanceof NormalizedNode) {
- builder.addChild(serialize((NormalizedNode) o));
+ builder.addChild(serialize((NormalizedNode<?, ?>) o));
}
}
} else if (value instanceof NormalizedNode) {
- builder.addChild(serialize((NormalizedNode) value));
+ builder.addChild(serialize((NormalizedNode<?, ?>) value));
} else {
static {
deSerializationFunctions.put(CONTAINER_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode>
deSerializationFunctions.put(LEAF_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
deSerializationFunctions.put(MAP_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
CollectionNodeBuilder<MapEntryNode, MapNode>
deSerializationFunctions.put(MAP_ENTRY_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
deSerializationFunctions.put(AUGMENTATION_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
DataContainerNodeBuilder<YangInstanceIdentifier.AugmentationIdentifier, AugmentationNode>
deSerializationFunctions.put(LEAF_SET_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
ListNodeBuilder<Object, LeafSetEntryNode<Object>>
deSerializationFunctions.put(LEAF_SET_ENTRY_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeWithValue, Object, LeafSetEntryNode<Object>>
deSerializationFunctions.put(CHOICE_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode>
deSerializationFunctions.put(ORDERED_LEAF_SET_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
ListNodeBuilder<Object, LeafSetEntryNode<Object>>
deSerializationFunctions.put(ORDERED_MAP_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
CollectionNodeBuilder<MapEntryNode, OrderedMapNode>
deSerializationFunctions.put(UNKEYED_LIST_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode>
deSerializationFunctions.put(UNKEYED_LIST_ENTRY_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode>
deSerializationFunctions.put(ANY_XML_NODE_TYPE,
new DeSerializationFunction() {
- @Override public NormalizedNode apply(
+ @Override public NormalizedNode<?, ?> apply(
DeSerializer deSerializer,
NormalizedNodeMessages.Node node) {
NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode>
return deserializedPath;
}
- public NormalizedNode deSerialize() {
- NormalizedNode deserializedNode = deSerialize(node);
+ public NormalizedNode<?, ?> deSerialize() {
+ NormalizedNode<?, ?> deserializedNode = deSerialize(node);
if(path != null) {
deserializedPath = InstanceIdentifierUtils.fromSerializable(path, this);
}
return deserializedNode;
}
- private NormalizedNode deSerialize(NormalizedNodeMessages.Node node){
+ private NormalizedNode<?, ?> deSerialize(NormalizedNodeMessages.Node node){
Preconditions.checkNotNull(node, "node should not be null");
DeSerializationFunction deSerializationFunction = deSerializationFunctions.get(
}
- private NormalizedNode buildCollectionNode(
+ private NormalizedNode<?, ?> buildCollectionNode(
CollectionNodeBuilder builder,
NormalizedNodeMessages.Node node) {
}
- private NormalizedNode buildListNode(
+ private NormalizedNode<?, ?> buildListNode(
ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder,
NormalizedNodeMessages.Node node) {
builder.withNodeIdentifier(toNodeIdentifier(node.getPathArgument()));
return builder.build();
}
- private NormalizedNode buildDataContainer(DataContainerNodeBuilder builder, NormalizedNodeMessages.Node node){
+ private NormalizedNode<?, ?> buildDataContainer(DataContainerNodeBuilder builder, NormalizedNodeMessages.Node node){
for(NormalizedNodeMessages.Node child : node.getChildList()){
builder.withChild((DataContainerChild<?, ?>) deSerialize(child));
return builder.build();
}
- private NormalizedNode buildNormalizedNode(NormalizedNodeAttrBuilder builder, NormalizedNodeMessages.Node node){
+ private NormalizedNode<?, ?> buildNormalizedNode(NormalizedNodeAttrBuilder builder, NormalizedNodeMessages.Node node){
builder.withValue(ValueSerializer.deSerialize(this, node));
}
private static interface DeSerializationFunction {
- NormalizedNode apply(DeSerializer deserializer, NormalizedNodeMessages.Node node);
+ NormalizedNode<?, ?> apply(DeSerializer deserializer, NormalizedNodeMessages.Node node);
}
}
}
UNKEYED_LIST_ENTRY_NODE_TYPE,
ANY_XML_NODE_TYPE;
- public static NormalizedNodeType getSerializableNodeType(NormalizedNode node){
+ public static NormalizedNodeType getSerializableNodeType(NormalizedNode<?, ?> node){
Preconditions.checkNotNull(node, "node should not be null");
if(node instanceof LeafNode){
builder.setInstanceIdentifierValue(
InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
} else if(value instanceof Set) {
- Set set = (Set) value;
+ Set<?> set = (Set<?>) value;
if (!set.isEmpty()) {
for (Object o : set) {
if (o instanceof String) {
return InstanceIdentifierUtils.fromSerializable(
node.getInstanceIdentifierValue(), context);
} else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
- return new HashSet(node.getBitsValueList());
+ return new HashSet<>(node.getBitsValueList());
} else if(node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()){
return node.getBytesValue().toByteArray();
}
BIG_DECIMAL_TYPE,
BINARY_TYPE;
- private static Map<Class, ValueType> types = new HashMap<>();
+ private static Map<Class<?>, ValueType> types = new HashMap<>();
static {
types.put(String.class, STRING_TYPE);
case NodeTypes.ANY_XML_NODE :
LOG.debug("Read xml node");
- Node value = (Node) readObject();
+ Node<?> value = (Node<?>) readObject();
return Builders.anyXmlBuilder().withValue(value).build();
case NodeTypes.MAP_NODE :
}
}
- private void writeObjSet(Set set) throws IOException {
+ private void writeObjSet(Set<?> set) throws IOException {
if(!set.isEmpty()){
writer.writeInt(set.size());
for(Object o : set){
writer.writeShort((Short) value);
break;
case ValueTypes.BITS_TYPE:
- writeObjSet((Set) value);
+ writeObjSet((Set<?>) value);
break;
case ValueTypes.YANG_IDENTIFIER_TYPE:
writeYangInstanceIdentifier((YangInstanceIdentifier) value);
public static final byte BIG_INTEGER_TYPE = 10;
public static final byte BIG_DECIMAL_TYPE = 11;
- private static Map<Class, Byte> types = new HashMap<>();
+ private static Map<Class<?>, Byte> types = new HashMap<>();
static {
types.put(String.class, Byte.valueOf(STRING_TYPE));
public class CompositeModificationPayload extends Payload implements
Serializable {
+ private static final long serialVersionUID = 1L;
private final PersistentMessages.CompositeModification modification;
public static Props props(final ReentrantLock lock){
return Props.create(new Creator<PingPongActor>(){
+ private static final long serialVersionUID = 1L;
@Override
public PingPongActor create() throws Exception {
return new PingPongActor(lock);
PathUtils.toString(YangInstanceIdentifier.builder().build()), documentOne);
// Validate the value of id can be retrieved from the normalized node
- NormalizedNode output = normalizedNodeGetter.getOutput();
+ NormalizedNode<?, ?> output = normalizedNodeGetter.getOutput();
assertNotNull(output);
package org.opendaylight.controller.cluster.datastore.node.utils;
+import com.google.common.collect.ImmutableSet;
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 {
}
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"));
+ Set<QName> childNames = ImmutableSet.of(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics"));
return new YangInstanceIdentifier.AugmentationIdentifier(childNames);
}
start = System.nanoTime();
- NormalizedNode actualNode =
+ NormalizedNode<?, ?> actualNode =
NormalizedNodeSerializer.deSerialize(expected);
System.out.println("DeSerialize Time = " + (System.nanoTime() - start)/1000000);
nodeBuilder.build());
assertTrue(o instanceof Set);
- assertTrue(((Set)o).contains("foo"));
- assertTrue(((Set) o).contains("bar"));
+ assertTrue(((Set<?>)o).contains("foo"));
+ assertTrue(((Set<?>) o).contains("bar"));
}
package org.opendaylight.controller.cluster.datastore.util;
+import com.google.common.collect.ImmutableSet;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameDeSerializationContext;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
public class InstanceIdentifierUtilsTest {
@Test
public void testAugmentationIdentifier() {
- YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.AugmentationIdentifier(new HashSet(
- Arrays.asList(TEST_QNAME)));
+ YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.AugmentationIdentifier(
+ ImmutableSet.of(TEST_QNAME));
List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
@Test
public void testInputXmlToCompositeNode() {
CompositeNode node = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), XML_CONTENT, schema);
- ImmutableList<SimpleNode> input = (ImmutableList)node.getValue().get(0).getValue();
- SimpleNode firstNode = input.get(0);
+ ImmutableList<SimpleNode<?>> input = (ImmutableList<SimpleNode<?>>)node.getValue().get(0).getValue();
+ SimpleNode<?> firstNode = input.get(0);
Assert.assertEquals("id", firstNode.getNodeType().getLocalName());
Assert.assertEquals("flowid", firstNode.getValue());
- SimpleNode secondNode = input.get(1);
+ SimpleNode<?> secondNode = input.get(1);
Assert.assertEquals("flow", secondNode.getNodeType().getLocalName());
YangInstanceIdentifier instance = (YangInstanceIdentifier) secondNode.getValue();
@Test
public void testInputCompositeNodeToXML() {
CompositeNode input = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), XML_CONTENT, schema);
- List<Node<?>> childNodes = new ArrayList();
+ List<Node<?>> childNodes = new ArrayList<>();
childNodes.add(input);
QName rpcQName = schema.getOperations().iterator().next().getQName();
CompositeNode node = new ImmutableCompositeNode(rpcQName, input.getValue(), ModifyAction.REPLACE);
private static class DataChangeListenerRegistrationCreator
implements Creator<DataChangeListenerRegistration> {
+ private static final long serialVersionUID = 1L;
final ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier,
NormalizedNode<?, ?>>> registration;
}
static class SchemaContextModules implements Serializable {
+ private static final long serialVersionUID = 1L;
private final Set<String> modules;
SchemaContextModules(Set<String> modules){
import akka.actor.ActorSelection;
import akka.dispatch.OnComplete;
import com.google.common.base.Preconditions;
-import java.util.AbstractMap.SimpleEntry;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+import java.util.concurrent.atomic.AtomicInteger;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
import scala.concurrent.Promise;
* TransactionChainProxy acts as a proxy for a DOMStoreTransactionChain created on a remote shard
*/
public class TransactionChainProxy implements DOMStoreTransactionChain {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TransactionChainProxy.class);
+
private interface State {
boolean isReady();
- SimpleEntry<Object, List<Future<ActorSelection>>> getReadyFutures();
-
- void setReadyFutures(Object txIdentifier, List<Future<ActorSelection>> readyFutures);
+ List<Future<ActorSelection>> getPreviousReadyFutures();
}
private static class Allocated implements State {
- private volatile SimpleEntry<Object, List<Future<ActorSelection>>> readyFutures;
+ private final ChainedTransactionProxy transaction;
- @Override
- public boolean isReady() {
- return readyFutures != null;
+ Allocated(ChainedTransactionProxy transaction) {
+ this.transaction = transaction;
}
@Override
- public SimpleEntry<Object, List<Future<ActorSelection>>> getReadyFutures() {
- return readyFutures != null ? readyFutures : EMPTY_READY_FUTURES;
+ public boolean isReady() {
+ return transaction.isReady();
}
@Override
- public void setReadyFutures(Object txIdentifier, List<Future<ActorSelection>> readyFutures) {
- this.readyFutures = new SimpleEntry<>(txIdentifier, readyFutures);
+ public List<Future<ActorSelection>> getPreviousReadyFutures() {
+ return transaction.getReadyFutures();
}
}
private static abstract class AbstractDefaultState implements State {
@Override
- public SimpleEntry<Object, List<Future<ActorSelection>>> getReadyFutures() {
- return EMPTY_READY_FUTURES;
- }
-
- @Override
- public void setReadyFutures(Object txIdentifier, List<Future<ActorSelection>> readyFutures) {
- throw new IllegalStateException("No transaction is allocated");
+ public List<Future<ActorSelection>> getPreviousReadyFutures() {
+ return Collections.emptyList();
}
}
}
};
- private static final SimpleEntry<Object, List<Future<ActorSelection>>> EMPTY_READY_FUTURES =
- new SimpleEntry<Object, List<Future<ActorSelection>>>("",
- Collections.<Future<ActorSelection>>emptyList());
-
- private static final AtomicReferenceFieldUpdater<TransactionChainProxy, State> STATE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(TransactionChainProxy.class, State.class, "state");
+ private static final AtomicInteger counter = new AtomicInteger(0);
private final ActorContext actorContext;
private final String transactionChainId;
- private volatile State state = IDLE_STATE;
+ private volatile State currentState = IDLE_STATE;
public TransactionChainProxy(ActorContext actorContext) {
this.actorContext = actorContext;
- transactionChainId = actorContext.getCurrentMemberName() + "-" + System.currentTimeMillis();
+ transactionChainId = actorContext.getCurrentMemberName() + "-txn-chain-" + counter.incrementAndGet();
+ }
+
+ public String getTransactionChainId() {
+ return transactionChainId;
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- checkReadyState();
- return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY);
+ State localState = currentState;
+ checkReadyState(localState);
+
+ return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY,
+ transactionChainId, localState.getPreviousReadyFutures());
}
@Override
@Override
public void close() {
- state = CLOSED_STATE;
+ currentState = CLOSED_STATE;
// Send a close transaction chain request to each and every shard
actorContext.broadcast(new CloseTransactionChain(transactionChainId));
}
private ChainedTransactionProxy allocateWriteTransaction(TransactionProxy.TransactionType type) {
- checkReadyState();
+ State localState = currentState;
- ChainedTransactionProxy txProxy = new ChainedTransactionProxy(actorContext, type);
- STATE_UPDATER.compareAndSet(this, IDLE_STATE, new Allocated());
+ checkReadyState(localState);
+
+ // Pass the ready Futures from the previous Tx.
+ ChainedTransactionProxy txProxy = new ChainedTransactionProxy(actorContext, type,
+ transactionChainId, localState.getPreviousReadyFutures());
+
+ currentState = new Allocated(txProxy);
return txProxy;
}
- private void checkReadyState() {
- Preconditions.checkState(state.isReady(), "Previous transaction %s is not ready yet",
- state.getReadyFutures().getKey());
+ private void checkReadyState(State state) {
+ Preconditions.checkState(state.isReady(), "Previous transaction is not ready yet");
}
- private class ChainedTransactionProxy extends TransactionProxy {
+ private static class ChainedTransactionProxy extends TransactionProxy {
+
+ /**
+ * Stores the ready Futures from the previous Tx in the chain.
+ */
+ private final List<Future<ActorSelection>> previousReadyFutures;
+
+ /**
+ * Stores the ready Futures from this transaction when it is readied.
+ */
+ private volatile List<Future<ActorSelection>> readyFutures;
- ChainedTransactionProxy(ActorContext actorContext, TransactionType transactionType) {
+ private ChainedTransactionProxy(ActorContext actorContext, TransactionType transactionType,
+ String transactionChainId, List<Future<ActorSelection>> previousReadyFutures) {
super(actorContext, transactionType, transactionChainId);
+ this.previousReadyFutures = previousReadyFutures;
+ }
+
+ List<Future<ActorSelection>> getReadyFutures() {
+ return readyFutures;
+ }
+
+ boolean isReady() {
+ return readyFutures != null;
}
@Override
protected void onTransactionReady(List<Future<ActorSelection>> readyFutures) {
- state.setReadyFutures(getIdentifier(), readyFutures);
+ LOG.debug("onTransactionReady {} pending readyFutures size {} chain {}", getIdentifier(),
+ readyFutures.size(), getTransactionChainId());
+ this.readyFutures = readyFutures;
}
/**
final Object serializedCreateMessage) {
// Check if there are any previous ready Futures, otherwise let the super class handle it.
- // The second check is done to ensure the the previous ready Futures aren't for this
- // Tx instance as deadlock would occur if we tried to wait on our own Futures. This can
- // occur in this scenario:
- //
- // - the TransactionProxy is created and the client does a write.
- //
- // - the TransactionProxy then attempts to create the shard Tx. However it first
- // sends a FindPrimaryShard message to the shard manager to find the local shard
- // This call is done async.
- //
- // - the client submits the Tx and the TransactionProxy is readied and we cache
- // the ready Futures here.
- //
- // - then the FindPrimaryShard call completes and this method is called to create
- // the shard Tx. However the cached Futures were from the ready on this Tx. If we
- // tried to wait on them, it would cause a form of deadlock as the ready Future
- // would be waiting on the Tx create Future and vice versa.
- SimpleEntry<Object, List<Future<ActorSelection>>> readyFuturesEntry = state.getReadyFutures();
- List<Future<ActorSelection>> readyFutures = readyFuturesEntry.getValue();
- if(readyFutures.isEmpty() || getIdentifier().equals(readyFuturesEntry.getKey())) {
+ if(previousReadyFutures.isEmpty()) {
return super.sendCreateTransaction(shard, serializedCreateMessage);
}
// Combine the ready Futures into 1.
Future<Iterable<ActorSelection>> combinedFutures = akka.dispatch.Futures.sequence(
- readyFutures, actorContext.getActorSystem().dispatcher());
+ previousReadyFutures, getActorContext().getActorSystem().dispatcher());
// Add a callback for completion of the combined Futures.
final Promise<Object> createTxPromise = akka.dispatch.Futures.promise();
// A Ready Future failed so fail the returned Promise.
createTxPromise.failure(failure);
} else {
+ LOG.debug("Previous Tx readied - sending CreateTransaction for {} on chain {}",
+ getIdentifier(), getTransactionChainId());
+
// Send the CreateTx message and use the resulting Future to complete the
// returned Promise.
- createTxPromise.completeWith(actorContext.executeOperationAsync(shard,
+ createTxPromise.completeWith(getActorContext().executeOperationAsync(shard,
serializedCreateMessage));
}
}
};
- combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
+ combinedFutures.onComplete(onComplete, getActorContext().getActorSystem().dispatcher());
return createTxPromise.future();
}
phantomReferenceCache.put(cleanup, cleanup);
}
- LOG.debug("Created txn {} of type {}", identifier, transactionType);
+ LOG.debug("Created txn {} of type {} on chain {}", identifier, transactionType, transactionChainId);
}
@VisibleForTesting
for(TransactionFutureCallback txFutureCallback : txFutureCallbackMap.values()) {
- LOG.debug("Tx {} Readying transaction for shard {}", identifier,
- txFutureCallback.getShardName());
+ LOG.debug("Tx {} Readying transaction for shard {} chain {}", identifier,
+ txFutureCallback.getShardName(), transactionChainId);
TransactionContext transactionContext = txFutureCallback.getTransactionContext();
if(transactionContext != null) {
return transactionChainId;
}
+ protected ActorContext getActorContext() {
+ return actorContext;
+ }
+
/**
* Interface for a transaction operation to be invoked later.
*/
package org.opendaylight.controller.cluster.datastore.exceptions;
public class NotInitializedException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
public NotInitializedException(String message) {
super(message);
}
package org.opendaylight.controller.cluster.datastore.exceptions;
public class PrimaryNotFoundException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
public PrimaryNotFoundException(String message){
super(message);
}
package org.opendaylight.controller.cluster.datastore.exceptions;
public class TimeoutException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
public TimeoutException(String message, Exception e){
super(message, e);
}
package org.opendaylight.controller.cluster.datastore.exceptions;
public class UnknownMessageException extends Exception {
+ private static final long serialVersionUID = 1L;
private final Object message;
public UnknownMessageException(Object message) {
import java.io.Serializable;
public class ActorInitialized implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class ActorNotInitialized implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
}};
}
+ @Test
+ public void testCreateChainedTransactionsInQuickSuccession() throws Exception{
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionsInQuickSuccession", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ int nTxs = 20;
+ List<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(nTxs);
+ for(int i = 0; i < nTxs; i++) {
+ DOMStoreReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
+
+ rwTx.merge(TestModel.TEST_PATH, testNode);
+
+ cohorts.add(rwTx.ready());
+
+ }
+
+ for(DOMStoreThreePhaseCommitCohort cohort: cohorts) {
+ doCommit(cohort);
+ }
+
+ txChain.close();
+
+ cleanup(dataStore);
+ }};
+ }
+
+ @Test
+ public void testCreateChainedTransactionAfterEmptyTxReadied() throws Exception{
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionAfterEmptyTxReadied", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ DOMStoreReadWriteTransaction rwTx1 = txChain.newReadWriteTransaction();
+
+ rwTx1.ready();
+
+ DOMStoreReadWriteTransaction rwTx2 = txChain.newReadWriteTransaction();
+
+ Optional<NormalizedNode<?, ?>> optional = rwTx2.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
+ assertEquals("isPresent", false, optional.isPresent());
+
+ txChain.close();
+
+ cleanup(dataStore);
+ }};
+ }
+
@Test
public void testCreateChainedTransactionWhenPreviousNotReady() throws Throwable {
new IntegrationTestKit(getSystem()) {{
throws Exception {
final CountDownLatch persistLatch = new CountDownLatch(1);
final Creator<ShardManager> creator = new Creator<ShardManager>() {
+ private static final long serialVersionUID = 1L;
@Override
public ShardManager create() throws Exception {
return new ShardManager(shardMrgIDSuffix, new MockClusterWrapper(), new MockConfiguration(), DatastoreContext.newBuilder().build()) {
}
private static class DelegatingShardManagerCreator implements Creator<ShardManager> {
+ private static final long serialVersionUID = 1L;
private Creator<ShardManager> delegate;
public DelegatingShardManagerCreator(Creator<ShardManager> delegate) {
super(actorSystem);
}
- protected void waitForLogMessage(final Class logLevel, ActorRef subject, String logMessage){
+ protected void waitForLogMessage(final Class<?> logLevel, ActorRef subject, String logMessage){
// Wait for a specific log message to show up
final boolean result =
new JavaTestKit.EventFilter<Boolean>(logLevel
package org.opendaylight.controller.cluster.datastore;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
public class TransactionChainProxyTest {
ActorContext actorContext = mock(ActorContext.class);
SchemaContext schemaContext = mock(SchemaContext.class);
verify(context, times(1)).broadcast(anyObject());
}
+
+ @Test
+ public void testTransactionChainsHaveUniqueId(){
+ TransactionChainProxy one = new TransactionChainProxy(mock(ActorContext.class));
+ TransactionChainProxy two = new TransactionChainProxy(mock(ActorContext.class));
+
+ Assert.assertNotEquals(one.getTransactionChainId(), two.getTransactionChainId());
+ }
}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-inmemory-datastore</artifactId>
- <version>1.2.0-SNAPSHOT</version>
-
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
private DataNormalizer mockNormalizer() throws DataNormalizationException {
final DataNormalizer mock = mock(DataNormalizer.class);
- doReturn(new AbstractMap.SimpleEntry<YangInstanceIdentifier, NormalizedNode<?, ?>>(id, normalizedNode) {})
+ doReturn(new AbstractMap.SimpleEntry<YangInstanceIdentifier, NormalizedNode<?, ?>>(id, normalizedNode))
.when(mock).toNormalized(any(YangInstanceIdentifier.class), any(CompositeNode.class));
doReturn(compositeNode).when(mock).toLegacy(any(YangInstanceIdentifier.class), any(NormalizedNode.class));
doReturn(id).when(mock).toLegacy(any(YangInstanceIdentifier.class));
JDBCResultSet rs = new JDBCResultSet(sql);
try {
int count = 0;
- jdbcServer.execute(rs, this);
+ JDBCServer.execute(rs, this);
boolean isFirst = true;
int loc = rs.getFields().size() - 1;
int totalWidth = 0;
return cacheLoadedSuccessfuly;
}
- private static Map<Class, Set<Class>> superClassMap = new HashMap<Class, Set<Class>>();
+ private static Map<Class<?>, Set<Class<?>>> superClassMap = new HashMap<>();
- public static Set<Class> getInheritance(Class myObjectClass,
- Class returnType) {
+ public static Set<Class<?>> getInheritance(Class<?> myObjectClass,
+ Class<?> returnType) {
if (returnType != null && myObjectClass.equals(returnType)) {
- return new HashSet<Class>();
+ return new HashSet<>();
}
- Set<Class> result = superClassMap.get(myObjectClass);
+ Set<Class<?>> result = superClassMap.get(myObjectClass);
if (result != null) {
return result;
}
- result = new HashSet<Class>();
+ result = new HashSet<>();
superClassMap.put(myObjectClass, result);
if (returnType != null) {
if (!returnType.equals(myObjectClass)) {
- Class mySuperClass = myObjectClass.getSuperclass();
+ Class<?> mySuperClass = myObjectClass.getSuperclass();
while (mySuperClass != null) {
result.add(mySuperClass);
mySuperClass = mySuperClass.getSuperclass();
return result;
}
- public static Set<Class> collectInterfaces(Class cls) {
- Set<Class> result = new HashSet();
- Class myInterfaces[] = cls.getInterfaces();
+ public static Set<Class<?>> collectInterfaces(Class<?> cls) {
+ Set<Class<?>> result = new HashSet<>();
+ Class<?> myInterfaces[] = cls.getInterfaces();
if (myInterfaces != null) {
- for (Class in : myInterfaces) {
+ for (Class<?> in : myInterfaces) {
result.add(in);
result.addAll(collectInterfaces(in));
}
map.put(blNode.getBluePrintNodeName(), blNode);
}
- public Class getGenericType(ParameterizedType type) {
+ public Class<?> getGenericType(ParameterizedType type) {
Type[] typeArguments = type.getActualTypeArguments();
for (Type typeArgument : typeArguments) {
if (typeArgument instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) typeArgument;
- return (Class) pType.getRawType();
+ return (Class<?>) pType.getRawType();
} else if (typeArgument instanceof Class) {
- return (Class) typeArgument;
+ return (Class<?>) typeArgument;
}
}
return null;
}
- public Class getMethodReturnTypeFromGeneric(Method m) {
+ public Class<?> getMethodReturnTypeFromGeneric(Method m) {
Type rType = m.getGenericReturnType();
if (rType instanceof ParameterizedType) {
return getGenericType((ParameterizedType) rType);
this.children.add(ch);
}
- public boolean isModelChild(Class p) {
+ public boolean isModelChild(Class<?> p) {
if (this.relations.size() == 0) {
return false;
}
return "Unknown";
}
- public Class getInterface() {
+ public Class<?> getInterface() {
return this.myInterface;
}
}
}
- public List execute(Object o) {
- List result = new LinkedList();
+ public List<?> execute(Object o) {
+ List<Object> result = new LinkedList<>();
if (o == null) {
return null;
}
if (Set.class.isAssignableFrom(o.getClass())) {
- Set lst = (Set) o;
+ Set<?> lst = (Set<?>) o;
for (Object oo : lst) {
addToResult(result, execute(oo));
}
return result;
} else if (List.class.isAssignableFrom(o.getClass())) {
- List lst = (List) o;
+ List<?> lst = (List<?>) o;
for (Object oo : lst) {
addToResult(result, execute(oo));
}
return result;
}
- public static void addToResult(List result, Object o) {
+ private static void addToResult(List<Object> result, Object o) {
if (o == null) {
return;
}
if (Set.class.isAssignableFrom(o.getClass())) {
- Set lst = (Set) o;
+ Set<?> lst = (Set<?>) o;
for (Object oo : lst) {
result.add(oo);
}
} else if (List.class.isAssignableFrom(o.getClass())) {
- List lst = (List) o;
+ List<?> lst = (List<?>) o;
for (Object oo : lst) {
result.add(oo);
}
import java.io.Serializable;
-public class XSQLColumn implements Serializable, Comparable {
+public class XSQLColumn implements Serializable, Comparable<Object> {
+ private static final long serialVersionUID = 4854919735031714751L;
+
private String name = null;
private String tableName = null;
private int charWidth = -1;
- private Class type = null;
+ private Class<?> type = null;
private transient Object bluePrintNode = null;
private String origName = null;
private String origTableName = null;
types.put(Status.class, Status.class);
}
- public static boolean isColumnType(Class cls) {
+ public static boolean isColumnType(Class<?> cls) {
return types.containsKey(cls);
}
return "NULL";
}
- public static Class getTypeForODLColumn(Object odlNode){
+ public static Class<?> getTypeForODLColumn(Object odlNode){
Object type = get(odlNode,"type");
if(type instanceof Uint32 || type instanceof Uint64){
return long.class;
import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
public class JDBCCommand implements Serializable {
+ private static final long serialVersionUID = 1L;
+
public int type = 0;
public static final int TYPE_EXECUTE_QUERY = 1;
public static final int TYPE_QUERY_REPLY = 2;
return 1;
}
- public int isObjectFitCriteria(Object element, Class cls) {
+ public int isObjectFitCriteria(Object element, Class<?> cls) {
Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria.get(cls
.getName());
if (tblCriteria == null) {
}
}
- public void addRecord(ArrayList hierarchy) {
+ public void addRecord(ArrayList<?> hierarchy) {
Map rec = new HashMap();
for (int i = hierarchy.size() - 1; i >= 0; i--) {
Object element = hierarchy.get(i);
return true;
}
- public void addRecord(ArrayList hierarchy) {
+ public void addRecord(ArrayList<?> hierarchy) {
rs.addRecord(hierarchy);
}
import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
final DataNodeContainer schemaForGetConfig = NetconfMessageTransformUtil.createSchemaForGetConfig(schemaContext.get());
w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaForGetConfig, codecProvider);
} else {
- final DataNodeContainer schemaForGetConfig = NetconfMessageTransformUtil.createSchemaForRpc(rpc, schemaContext.get());
- w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaForGetConfig, codecProvider);
+ final Optional<RpcDefinition> schemaForRpc = NetconfMessageTransformUtil.findSchemaForRpc(rpc, schemaContext.get());
+ if(schemaForRpc.isPresent()) {
+ final DataNodeContainer schemaForGetConfig = NetconfMessageTransformUtil.createSchemaForRpc(schemaForRpc.get());
+ w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaForGetConfig, codecProvider);
+ } else {
+ w3cPayload = toRpcRequestWithoutSchema(rpcPayload, codecProvider);
+ }
}
} else {
- w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, codecProvider);
+ w3cPayload = toRpcRequestWithoutSchema(rpcPayload, codecProvider);
}
} catch (final UnsupportedDataTypeException e) {
throw new IllegalArgumentException("Unable to create message", e);
return new NetconfMessage(w3cPayload);
}
+ private Document toRpcRequestWithoutSchema(final CompositeNodeTOImpl rpcPayload, final XmlCodecProvider codecProvider) {
+ return XmlDocumentUtils.toDocument(rpcPayload, codecProvider);
+ }
+
@Override
public synchronized RpcResult<CompositeNode> toRpcResult(final NetconfMessage message, final QName rpc) {
if(schemaContext.isPresent()) {
*/
package org.opendaylight.controller.sal.connect.netconf.util;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.Node;
import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
public class NetconfMessageTransformUtil {
public static final String MESSAGE_ID_ATTR = "message-id";
static Node<?> toNode(final YangInstanceIdentifier.NodeIdentifierWithPredicates argument, final Node<?> node) {
final List<Node<?>> list = new ArrayList<>();
for (final Map.Entry<QName, Object> arg : argument.getKeyValues().entrySet()) {
- list.add(new SimpleNodeTOImpl(arg.getKey(), null, arg.getValue()));
+ list.add(new SimpleNodeTOImpl<>(arg.getKey(), null, arg.getValue()));
}
if (node != null) {
list.add(node);
return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(editConfigProxy));
}
+
+ public static Optional<RpcDefinition> findSchemaForRpc(final QName rpcName, final SchemaContext schemaContext) {
+ Preconditions.checkNotNull(rpcName);
+ Preconditions.checkNotNull(schemaContext);
+
+ for (final RpcDefinition rpcDefinition : schemaContext.getOperations()) {
+ if(rpcDefinition.getQName().equals(rpcName)) {
+ return Optional.of(rpcDefinition);
+ }
+ }
+
+ return Optional.absent();
+ }
+
/**
* Creates artificial schema node for schema defined rpc. This artificial schema looks like:
* <pre>
* This makes the translation of schema defined rpc request
* to xml use schema which is crucial for some types of nodes e.g. identity-ref.
*/
- public static DataNodeContainer createSchemaForRpc(final QName rpcName, final SchemaContext schemaContext) {
- Preconditions.checkNotNull(rpcName);
- Preconditions.checkNotNull(schemaContext);
-
- for (final RpcDefinition rpcDefinition : schemaContext.getOperations()) {
- if(rpcDefinition.getQName().equals(rpcName)) {
- final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcName, rpcDefinition.getInput().getChildNodes());
- return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
- }
- }
-
- throw new IllegalArgumentException("Rpc " + rpcName + " not found in schema context " + schemaContext + ". Unable to invoke Rpc");
+ public static DataNodeContainer createSchemaForRpc(final RpcDefinition rpcDefinition) {
+ final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcDefinition.getQName(), rpcDefinition.getInput().getChildNodes());
+ return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
}
public static CompositeNodeTOImpl wrap(final QName name, final Node<?> node) {
import java.util.Collections;
import java.util.List;
import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.opendaylight.controller.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.Module;
final org.w3c.dom.Node streamName = subscribeName.getFirstChild();
assertEquals(streamName.getLocalName(), "stream-name");
+
+ }
+
+ @Test
+ public void testRpcResponse() throws Exception {
+ final NetconfMessage response = new NetconfMessage(XmlUtil.readXmlToDocument(
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"m-5\">\n" +
+ "<data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">" +
+ "module schema" +
+ "</data>\n" +
+ "</rpc-reply>\n"
+ ));
+ final RpcResult<CompositeNode> compositeNodeRpcResult = messageTransformer.toRpcResult(response, SUBSCRIBE_RPC_NAME);
+ final Node<?> dataNode = compositeNodeRpcResult.getResult().getValue().get(0);
+ assertEquals("module schema", dataNode.getValue());
}
}
--- /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.connect.netconf.schema.mapping;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.controller.sal.connect.netconf.NetconfToRpcRequestTest;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+public class NetconfMessageTransformerTest {
+
+ private static final QName COMMIT_Q_NAME = QName.create("namespace", "2012-12-12", "commit");
+
+ @Test
+ public void testToRpcRequestNoSchemaForRequest() throws Exception {
+ final NetconfMessageTransformer netconfMessageTransformer = getTransformer();
+ final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(COMMIT_Q_NAME,
+ NodeFactory.createImmutableCompositeNode(COMMIT_Q_NAME, null, Collections.<Node<?>>emptyList()));
+ assertThat(XmlUtil.toString(netconfMessage.getDocument()), CoreMatchers.containsString("<commit"));
+ }
+
+ private NetconfMessageTransformer getTransformer() {
+ final NetconfMessageTransformer netconfMessageTransformer = new NetconfMessageTransformer();
+ netconfMessageTransformer.onGlobalContextUpdated(getSchema());
+ return netconfMessageTransformer;
+ }
+
+ @Test
+ public void testToRpcResultNoSchemaForResult() throws Exception {
+ final NetconfMessageTransformer netconfMessageTransformer = getTransformer();
+ final NetconfMessage response = new NetconfMessage(XmlUtil.readXmlToDocument(
+ "<rpc-reply><ok/></rpc-reply>"
+ ));
+ final RpcResult<CompositeNode> compositeNodeRpcResult = netconfMessageTransformer.toRpcResult(response, COMMIT_Q_NAME);
+ assertTrue(compositeNodeRpcResult.isSuccessful());
+ assertEquals("ok", compositeNodeRpcResult.getResult().getValue().get(0).getKey().getLocalName());
+ }
+
+ public SchemaContext getSchema() {
+ final List<InputStream> modelsToParse = Collections
+ .singletonList(NetconfToRpcRequestTest.class.getResourceAsStream("/schemas/rpc-notification-subscription.yang"));
+ final YangParserImpl parser = new YangParserImpl();
+ final Set<Module> configModules = parser.parseYangModelsFromStreams(modelsToParse);
+ final SchemaContext cfgCtx = parser.resolveSchemaContext(configModules);
+ assertNotNull(cfgCtx);
+ return cfgCtx;
+ }
+}
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
final Broker.ProviderSession brokerSession,
final RpcProvisionRegistry rpcProvisionRegistry) {
return Props.create(new Creator<RpcManager>() {
+ private static final long serialVersionUID = 1L;
@Override
public RpcManager create() throws Exception {
return new RpcManager(schemaContext, brokerSession, rpcProvisionRegistry);
import java.io.Serializable;
public class ExecuteRpc implements Serializable {
+ private static final long serialVersionUID = 1L;
private final String inputCompositeNode;
private final QName rpc;
import java.io.Serializable;
public class InvokeRpc implements Serializable {
+ private static final long serialVersionUID = 1L;
private final QName rpc;
private final YangInstanceIdentifier identifier;
*/
package org.opendaylight.controller.remote.rpc.messages;
-
-
import java.io.Serializable;
public class RpcResponse implements Serializable {
+ private static final long serialVersionUID = 1L;
private final String resultCompositeNode;
public RpcResponse(final String resultCompositeNode) {
import java.util.Map;
public class RoutingTable implements Copier<RoutingTable>, Serializable {
+ private static final long serialVersionUID = 1L;
private Map<RpcRouter.RouteIdentifier<?, ?, ?>, Long> table = new HashMap<>();
private ActorRef router;
import java.io.Serializable;
public class BucketImpl<T extends Copier<T>> implements Bucket<T>, Serializable {
+ private static final long serialVersionUID = 1L;
private Long version = System.currentTimeMillis();
public static class BucketStoreMessages{
- public static class GetLocalBucket implements Serializable{}
+ public static class GetLocalBucket implements Serializable {
+ private static final long serialVersionUID = 1L;
+ }
public static class ContainsBucket implements Serializable {
+ private static final long serialVersionUID = 1L;
final private Bucket bucket;
public ContainsBucket(Bucket bucket){
}
public static class UpdateBucket extends ContainsBucket implements Serializable {
+ private static final long serialVersionUID = 1L;
public UpdateBucket(Bucket bucket){
super(bucket);
}
}
public static class GetLocalBucketReply extends ContainsBucket implements Serializable {
+ private static final long serialVersionUID = 1L;
public GetLocalBucketReply(Bucket bucket){
super(bucket);
}
}
- public static class GetAllBuckets implements Serializable{}
+ public static class GetAllBuckets implements Serializable {
+ private static final long serialVersionUID = 1L;
+ }
public static class GetBucketsByMembers implements Serializable{
+ private static final long serialVersionUID = 1L;
private Set<Address> members;
public GetBucketsByMembers(Set<Address> members){
}
public static class ContainsBuckets implements Serializable{
+ private static final long serialVersionUID = 1L;
private Map<Address, Bucket> buckets;
public ContainsBuckets(Map<Address, Bucket> buckets){
}
public static class GetAllBucketsReply extends ContainsBuckets implements Serializable{
+ private static final long serialVersionUID = 1L;
public GetAllBucketsReply(Map<Address, Bucket> buckets) {
super(buckets);
}
}
public static class GetBucketsByMembersReply extends ContainsBuckets implements Serializable{
+ private static final long serialVersionUID = 1L;
public GetBucketsByMembersReply(Map<Address, Bucket> buckets) {
super(buckets);
}
}
- public static class GetBucketVersions implements Serializable{}
+ public static class GetBucketVersions implements Serializable {
+ private static final long serialVersionUID = 1L;
+ }
public static class ContainsBucketVersions implements Serializable{
+ private static final long serialVersionUID = 1L;
Map<Address, Long> versions;
public ContainsBucketVersions(Map<Address, Long> versions) {
}
public static class GetBucketVersionsReply extends ContainsBucketVersions implements Serializable{
+ private static final long serialVersionUID = 1L;
public GetBucketVersionsReply(Map<Address, Long> versions) {
super(versions);
}
}
public static class UpdateRemoteBuckets extends ContainsBuckets implements Serializable{
+ private static final long serialVersionUID = 1L;
public UpdateRemoteBuckets(Map<Address, Bucket> buckets) {
super(buckets);
}
}
public static class GossiperMessages{
- public static class Tick implements Serializable {}
+ public static class Tick implements Serializable {
+ private static final long serialVersionUID = 1L;
+ }
- public static final class GossipTick extends Tick {}
+ public static final class GossipTick extends Tick {
+ private static final long serialVersionUID = 1L;
+ }
public static final class GossipStatus extends ContainsBucketVersions implements Serializable{
+ private static final long serialVersionUID = 1L;
private Address from;
public GossipStatus(Address from, Map<Address, Long> versions) {
}
public static final class GossipEnvelope extends ContainsBuckets implements Serializable {
+ private static final long serialVersionUID = 1L;
private final Address from;
private final Address to;
public class ConditionalProbe {
private final ActorRef actorRef;
- private final Predicate predicate;
+ private final Predicate<Object> predicate;
Logger log = LoggerFactory.getLogger(ConditionalProbe.class);
- public ConditionalProbe(ActorRef actorRef, Predicate predicate) {
+ public ConditionalProbe(ActorRef actorRef, Predicate<Object> predicate) {
this.actorRef = actorRef;
this.predicate = predicate;
}
Messages.BucketStoreMessages.UpdateRemoteBuckets.class);
}
- private JavaTestKit createProbeForMessage(ActorSystem node, ActorPath subjectPath, final Class clazz) {
+ private JavaTestKit createProbeForMessage(ActorSystem node, ActorPath subjectPath, final Class<?> clazz) {
final JavaTestKit probe = new JavaTestKit(node);
ConditionalProbe conditionalProbe =
- new ConditionalProbe(probe.getRef(), new Predicate() {
+ new ConditionalProbe(probe.getRef(), new Predicate<Object>() {
@Override
public boolean apply(@Nullable Object input) {
if (input != null)
@Test
public void testReceiveGossipTick_WhenNoRemoteMemberShouldIgnore(){
- mockGossiper.setClusterMembers(Collections.EMPTY_LIST);
+ mockGossiper.setClusterMembers(Collections.<Address>emptyList());
doNothing().when(mockGossiper).getLocalStatusAndSendTo(any(Address.class));
mockGossiper.receiveGossipTick();
verify(mockGossiper, times(0)).getLocalStatusAndSendTo(any(Address.class));
<artifactId>sal-rest-docgen</artifactId>
<packaging>bundle</packaging>
- <properties>
- <jaxrs-api.version>3.0.4.Final</jaxrs-api.version>
- </properties>
-
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
- <version>${jaxrs-api.version}</version>
</dependency>
<dependency>
@Override
public void start(BundleContext context) throws Exception {
bundleContext = context;
- brokerServiceTracker = new ServiceTracker(context, Broker.class, this);
+ brokerServiceTracker = new ServiceTracker<>(context, Broker.class, this);
brokerServiceTracker.open();
}
notifications.add(new QName(notificationType.toString()));
String notificationStreamName = RemoteStreamTools.createNotificationStream(salRemoteService, notifications);
final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext, notificationStreamName);
- RemoteNotificationListener remoteNotificationListener = new RemoteNotificationListener(listener);
+ RemoteNotificationListener<T> remoteNotificationListener = new RemoteNotificationListener<T>(listener);
final ListenerRegistration<?> listenerRegistration = restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName)))
.registerNotificationListener(remoteNotificationListener);
package org.opendaylight.controller.sal.restconf.broker.listeners;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.Notification;
-public class RemoteNotificationListener implements org.opendaylight.yangtools.yang.binding.NotificationListener {
+public class RemoteNotificationListener<T extends Notification> implements org.opendaylight.yangtools.yang.binding.NotificationListener {
- org.opendaylight.controller.sal.binding.api.NotificationListener listener;
+ NotificationListener<T> listener;
- public RemoteNotificationListener(NotificationListener listener){
+ public RemoteNotificationListener(NotificationListener<T> listener){
this.listener = listener;
}
- public NotificationListener getListener(){
+ public NotificationListener<T> getListener() {
return this.listener;
}
import org.opendaylight.yangtools.yang.binding.Notification;
-public class SalNotificationListener implements NotificationListener {
- private NotificationListener notificationListener;
+public class SalNotificationListener<T extends Notification> implements NotificationListener<T> {
+ private NotificationListener<T> notificationListener;
- public SalNotificationListener( NotificationListener notificationListener){
+ public SalNotificationListener( NotificationListener<T> notificationListener){
this.notificationListener = notificationListener;
}
@Override
public void onNotification(Notification notification) {
- this.notificationListener.onNotification(notification);
+ this.notificationListener.onNotification((T)notification);
}
}
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
protected Object preprocess(Object value) {
Util.checkType(value, Map.class);
- Preconditions.checkArgument(((Map)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
- return ((Map)value).values().iterator().next();
+ Preconditions.checkArgument(((Map<?, ?>)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
+ return ((Map<?, ?>)value).values().iterator().next();
}
}
protected Object preprocess(Object value) {
Util.checkType(value, Map.class);
- Preconditions.checkArgument(((Map)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
- Object stringValue = ((Map) value).values().iterator().next();
+ Preconditions.checkArgument(((Map<?, ?>)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
+ Object stringValue = ((Map<?, ?>) value).values().iterator().next();
Util.checkType(stringValue, String.class);
return stringValue;
protected Object preprocess(Object value) {
Util.checkType(value, Map.class);
- Preconditions.checkArgument(((Map)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
- Object listOfStrings = ((Map) value).values().iterator().next();
+ Preconditions.checkArgument(((Map<?, ?>)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
+ Object listOfStrings = ((Map<?, ?>) value).values().iterator().next();
Util.checkType(listOfStrings, List.class);
StringBuilder b = new StringBuilder();
- for (Object character: (List)listOfStrings) {
+ for (Object character: (List<?>)listOfStrings) {
Util.checkType(character, String.class);
b.append(character);
}
package org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc;
import static org.junit.Assert.assertEquals;
-
+import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
return Arrays.asList(new Object[][] {
// With namespaces
{ "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']/b:listener-state[b:peer-id='127.0.0.1']",
- new HashMap<String, String>() {{
- put("listener-state", "127.0.0.1");
- }}},
+ new HashMap<>(ImmutableMap.of("listener-state", "127.0.0.1"))},
{ "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']",
null},
{ "/modules/module[name=instanceName and type=moduleType]/inner[key=\"b\"]", Collections.singletonMap("inner", "b")},
{ "/modules/module[name=instanceName and type=\"moduleType\"]/inner[key2=a]/inner2[key=b]",
- new HashMap<String, String>() {{
- put("inner", "a");
- put("inner2", "b");
- }}
+ new HashMap<>(ImmutableMap.of("inner", "a", "inner2", "b"))
},
});
}
import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
-
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public void testGetSessionNegotiator() throws Exception {
NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
Timer timer = new HashedWheelTimer();
- SessionListenerFactory listenerFactory = mock(SessionListenerFactory.class);
+ SessionListenerFactory<NetconfClientSessionListener> listenerFactory = mock(SessionListenerFactory.class);
doReturn(sessionListener).when(listenerFactory).getSessionListener();
Channel channel = mock(Channel.class);
- Promise promise = mock(Promise.class);
+ Promise<NetconfClientSession> promise = mock(Promise.class);
NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(timer,
Optional.<NetconfHelloMessageAdditionalHeader>absent(), 200L);
- SessionNegotiator sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise);
+ SessionNegotiator<?> sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise);
assertNotNull(sessionNegotiator);
}
}
return pipeline;
}
- private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(final Promise promise,
+ private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(final Promise<NetconfClientSession> promise,
final NetconfMessage startExi) {
ChannelProgressivePromise progressivePromise = mock(ChannelProgressivePromise.class);
NetconfClientSessionPreferences preferences = new NetconfClientSessionPreferences(helloMessage, startExi);
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
negotiator.channelActive(null);
- Set caps = Sets.newSet("a", "b");
+ Set<String> caps = Sets.newSet("a", "b");
NetconfHelloMessage helloServerMessage = NetconfHelloMessage.createServerHello(caps, 10);
negotiator.handleMessage(helloServerMessage);
verify(promise).setSuccess(anyObject());
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, exiMessage);
negotiator.channelActive(null);
- Set caps = Sets.newSet("exi:1.0");
+ Set<String> caps = Sets.newSet("exi:1.0");
NetconfHelloMessage helloMessage = NetconfHelloMessage.createServerHello(caps, 10);
doAnswer(new Answer<Object>() {
private Channel channel;
private ChannelFuture channelFuture;
- Set caps;
+ Set<String> caps;
private NetconfHelloMessage helloMessage;
private NetconfMessage message;
private NetconfClientSessionListener sessionListener;
NetconfClientSessionNegotiatorFactory negotiatorFactory = mock(NetconfClientSessionNegotiatorFactory.class);
NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
- SessionNegotiator sessionNegotiator = mock(SessionNegotiator.class);
+ SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
doReturn("").when(sessionNegotiator).toString();
doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(any(SessionListenerFactory.class), any(Channel.class), any(Promise.class));
ChannelPipeline pipeline = mock(ChannelPipeline.class);
@Test
public void testInitializeSessionNegotiator() throws Exception {
NetconfClientSessionNegotiatorFactory factory = mock(NetconfClientSessionNegotiatorFactory.class);
- SessionNegotiator sessionNegotiator = mock(SessionNegotiator.class);
+ SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
doReturn("").when(sessionNegotiator).toString();
doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(SessionListenerFactory.class), any(Channel.class), any(Promise.class));
NetconfClientSessionListener listener = mock(NetconfClientSessionListener.class);
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.netty.channel.Channel;
-import java.util.List;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
public void testSessions() throws Exception {
doReturn("sessToStr").when(managementSession).toString();
service.onSessionUp(managementSession);
- List list = Lists.newArrayList(managementSession);
}
@Test(expected = RuntimeException.class)
public void testGetSchemas3() throws Exception {
doReturn("").when(managementSession).toString();
Capability cap = mock(Capability.class);
- Set caps = Sets.newHashSet(cap);
- Set services = Sets.newHashSet(operationService);
+ Set<Capability> caps = Sets.newHashSet(cap);
+ Set<NetconfOperationService> services = Sets.newHashSet(operationService);
doReturn(snapshot).when(operationProvider).openSnapshot(anyString());
doReturn(services).when(snapshot).getServices();
doReturn(caps).when(operationService).getCapabilities();
- Optional opt = mock(Optional.class);
+ Optional<String> opt = mock(Optional.class);
doReturn(opt).when(cap).getCapabilitySchema();
doReturn(true).when(opt).isPresent();
doReturn(opt).when(cap).getModuleNamespace();
doReturn("namespace").when(opt).get();
- Optional optRev = Optional.of("rev");
+ Optional<String> optRev = Optional.of("rev");
doReturn(optRev).when(cap).getRevision();
doReturn(Optional.of("modName")).when(cap).getModuleName();
doReturn(Optional.of(Lists.newArrayList("loc"))).when(cap).getLocation();
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.SshProxyServer;
+import org.opendaylight.controller.netconf.ssh.SshProxyServerConfigurationBuilder;
import org.opendaylight.controller.netconf.util.messages.NetconfMessageUtil;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
clientGroup = new NioEventLoopGroup();
minaTimerEx = Executors.newScheduledThreadPool(1);
sshProxyServer = new SshProxyServer(minaTimerEx, clientGroup, nioExec);
- sshProxyServer.bind(TLS_ADDRESS, NetconfConfigUtil.getNetconfLocalAddress(), new PasswordAuthenticator() {
+ sshProxyServer.bind(
+ new SshProxyServerConfigurationBuilder()
+ .setBindingAddress(TLS_ADDRESS)
+ .setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress())
+ .setAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(final String username, final String password, final ServerSession session) {
return true;
}
- }, new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString()));
+ })
+ .setKeyPairProvider(new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString()))
+ .setIdleTimeout(Integer.MAX_VALUE)
+ .createSshProxyServerConfiguration());
}
@After
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
<executions>
<execution>
<goals>
import com.google.common.collect.Lists;
import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalAddress;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.nio.channels.AsynchronousChannelGroup;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.sshd.SshServer;
import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.KeyPairProvider;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.RuntimeSshException;
import org.apache.sshd.common.io.IoAcceptor;
import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
import org.apache.sshd.common.util.CloseableUtils;
import org.apache.sshd.server.Command;
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.ServerFactoryManager;
/**
* Proxy SSH server that just delegates decrypted content to a delegate server within same VM.
this.sshServer = SshServer.setUpDefaultServer();
}
- public void bind(final InetSocketAddress bindingAddress, final LocalAddress localAddress, final PasswordAuthenticator authenticator, final KeyPairProvider keyPairProvider) throws IOException {
- sshServer.setHost(bindingAddress.getHostString());
- sshServer.setPort(bindingAddress.getPort());
+ public void bind(final SshProxyServerConfiguration sshProxyServerConfiguration) throws IOException {
+ sshServer.setHost(sshProxyServerConfiguration.getBindingAddress().getHostString());
+ sshServer.setPort(sshProxyServerConfiguration.getBindingAddress().getPort());
- sshServer.setPasswordAuthenticator(authenticator);
- sshServer.setKeyPairProvider(keyPairProvider);
+ sshServer.setPasswordAuthenticator(sshProxyServerConfiguration.getAuthenticator());
+ sshServer.setKeyPairProvider(sshProxyServerConfiguration.getKeyPairProvider());
sshServer.setIoServiceFactoryFactory(nioServiceWithPoolFactoryFactory);
sshServer.setScheduledExecutorService(minaTimerExecutor);
+ sshServer.setProperties(getProperties(sshProxyServerConfiguration));
final RemoteNetconfCommand.NetconfCommandFactory netconfCommandFactory =
- new RemoteNetconfCommand.NetconfCommandFactory(clientGroup, localAddress);
+ new RemoteNetconfCommand.NetconfCommandFactory(clientGroup, sshProxyServerConfiguration.getLocalAddress());
sshServer.setSubsystemFactories(Lists.<NamedFactory<Command>>newArrayList(netconfCommandFactory));
sshServer.start();
}
+ private static Map<String, String> getProperties(final SshProxyServerConfiguration sshProxyServerConfiguration) {
+ return new HashMap<String, String>()
+ {{
+ put(ServerFactoryManager.IDLE_TIMEOUT, String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
+ }};
+ }
+
@Override
public void close() {
try {
--- /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.ssh;
+
+import com.google.common.base.Preconditions;
+import io.netty.channel.local.LocalAddress;
+import java.net.InetSocketAddress;
+import org.apache.sshd.common.KeyPairProvider;
+import org.apache.sshd.server.PasswordAuthenticator;
+
+public final class SshProxyServerConfiguration {
+ private final InetSocketAddress bindingAddress;
+ private final LocalAddress localAddress;
+ private final PasswordAuthenticator authenticator;
+ private final KeyPairProvider keyPairProvider;
+ private final int idleTimeout;
+
+ SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress, final PasswordAuthenticator authenticator, final KeyPairProvider keyPairProvider, final int idleTimeout) {
+ this.bindingAddress = Preconditions.checkNotNull(bindingAddress);
+ this.localAddress = Preconditions.checkNotNull(localAddress);
+ this.authenticator = Preconditions.checkNotNull(authenticator);
+ this.keyPairProvider = Preconditions.checkNotNull(keyPairProvider);
+ // Idle timeout cannot be disabled in the sshd by using =< 0 value
+ Preconditions.checkArgument(idleTimeout > 0, "Idle timeout has to be > 0");
+ this.idleTimeout = idleTimeout;
+ }
+
+ public InetSocketAddress getBindingAddress() {
+ return bindingAddress;
+ }
+
+ public LocalAddress getLocalAddress() {
+ return localAddress;
+ }
+
+ public PasswordAuthenticator getAuthenticator() {
+ return authenticator;
+ }
+
+ public KeyPairProvider getKeyPairProvider() {
+ return keyPairProvider;
+ }
+
+ public int getIdleTimeout() {
+ return idleTimeout;
+ }
+
+
+}
--- /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.ssh;
+
+import io.netty.channel.local.LocalAddress;
+import java.net.InetSocketAddress;
+import org.apache.sshd.common.KeyPairProvider;
+import org.apache.sshd.server.PasswordAuthenticator;
+
+public final class SshProxyServerConfigurationBuilder {
+ private InetSocketAddress bindingAddress;
+ private LocalAddress localAddress;
+ private PasswordAuthenticator authenticator;
+ private KeyPairProvider keyPairProvider;
+ private int idleTimeout;
+
+ public SshProxyServerConfigurationBuilder setBindingAddress(final InetSocketAddress bindingAddress) {
+ this.bindingAddress = bindingAddress;
+ return this;
+ }
+
+ public SshProxyServerConfigurationBuilder setLocalAddress(final LocalAddress localAddress) {
+ this.localAddress = localAddress;
+ return this;
+ }
+
+ public SshProxyServerConfigurationBuilder setAuthenticator(final PasswordAuthenticator authenticator) {
+ this.authenticator = authenticator;
+ return this;
+ }
+
+ public SshProxyServerConfigurationBuilder setKeyPairProvider(final KeyPairProvider keyPairProvider) {
+ this.keyPairProvider = keyPairProvider;
+ return this;
+ }
+
+ public SshProxyServerConfigurationBuilder setIdleTimeout(final int idleTimeout) {
+ this.idleTimeout = idleTimeout;
+ return this;
+ }
+
+ public SshProxyServerConfiguration createSshProxyServerConfiguration() {
+ return new SshProxyServerConfiguration(bindingAddress, localAddress, authenticator, keyPairProvider, idleTimeout);
+ }
+
+ public SshProxyServerConfigurationBuilder create () {
+ return new SshProxyServerConfigurationBuilder();
+ }
+}
\ No newline at end of file
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FilenameUtils;
import org.apache.sshd.common.util.ThreadUtils;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
import org.opendaylight.controller.netconf.ssh.SshProxyServer;
+import org.opendaylight.controller.netconf.ssh.SshProxyServerConfigurationBuilder;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil.InfixProp;
import org.osgi.framework.BundleActivator;
private static final java.lang.String ALGORITHM = "RSA";
private static final int KEY_SIZE = 4096;
public static final int POOL_SIZE = 8;
+ private static final int DEFAULT_IDLE_TIMEOUT = (int) TimeUnit.MINUTES.toMillis(20);
private ScheduledExecutorService minaTimerExecutor;
private NioEventLoopGroup clientGroup;
NetconfConfigUtil.getPrivateKeyKey());
final SshProxyServer sshProxyServer = new SshProxyServer(minaTimerExecutor, clientGroup, nioExecutor);
- sshProxyServer.bind(sshSocketAddress, localAddress, authProviderTracker, new PEMGeneratorHostKeyProvider(path, ALGORITHM, KEY_SIZE));
+ sshProxyServer.bind(
+ new SshProxyServerConfigurationBuilder()
+ .setBindingAddress(sshSocketAddress)
+ .setLocalAddress(localAddress)
+ .setAuthenticator(authProviderTracker)
+ .setKeyPairProvider(new PEMGeneratorHostKeyProvider(path, ALGORITHM, KEY_SIZE))
+ .setIdleTimeout(DEFAULT_IDLE_TIMEOUT)
+ .createSshProxyServerConfiguration());
return sshProxyServer;
}
import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
import org.opendaylight.controller.netconf.ssh.SshProxyServer;
+import org.opendaylight.controller.netconf.ssh.SshProxyServerConfigurationBuilder;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 10831);
final SshProxyServer sshProxyServer = new SshProxyServer(minaTimerEx, nettyGroup, nioExec);
- sshProxyServer.bind(addr, NetconfConfigUtil.getNetconfLocalAddress(),
- new PasswordAuthenticator() {
+ sshProxyServer.bind(
+ new SshProxyServerConfigurationBuilder().setBindingAddress(addr).setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()).setAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(final String username, final String password, final ServerSession session) {
return true;
}
- }, new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString()));
+ }).setKeyPairProvider(new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString())).setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration());
final EchoClientHandler echoClientHandler = connectClient(addr);
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.netconf.ssh.SshProxyServer;
+import org.opendaylight.controller.netconf.ssh.SshProxyServerConfigurationBuilder;
import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceListener;
final InetSocketAddress addr = InetSocketAddress.createUnresolved(HOST, PORT);
server = new SshProxyServer(minaTimerEx, clientGroup, nioExec);
- server.bind(addr, NetconfConfigUtil.getNetconfLocalAddress(),
- new PasswordAuthenticator() {
+ server.bind(
+ new SshProxyServerConfigurationBuilder().setBindingAddress(addr).setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()).setAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(final String username, final String password, final ServerSession session) {
return true;
}
- }, new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString()));
+ }).setKeyPairProvider(new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString())).setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration());
logger.info("SSH server started on " + PORT);
}
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOperationService;
import org.opendaylight.controller.netconf.ssh.SshProxyServer;
+import org.opendaylight.controller.netconf.ssh.SshProxyServerConfiguration;
+import org.opendaylight.controller.netconf.ssh.SshProxyServerConfigurationBuilder;
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 {
final SshProxyServer sshServer = new SshProxyServer(minaTimerExecutor, nettyThreadgroup, nioExecutor);
- sshServer.bind(bindingAddress, tcpLocalAddress,
- new PasswordAuthenticator() {
- @Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
- // All connections are accepted
- return true;
- }
- }, keyPairProvider);
-
+ sshServer.bind(getSshConfiguration(bindingAddress, tcpLocalAddress));
sshWrappers.add(sshServer);
} catch (final Exception e) {
LOG.warn("Cannot start simulated device on {}, skipping", address, e);
return openDevices;
}
+ private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress, final LocalAddress tcpLocalAddress) throws IOException {
+ return new SshProxyServerConfigurationBuilder()
+ .setBindingAddress(bindingAddress)
+ .setLocalAddress(tcpLocalAddress)
+ .setAuthenticator(new PasswordAuthenticator() {
+ @Override
+ public boolean authenticate(final String username, final String password, final ServerSession session) {
+ return true;
+ }
+ })
+ .setKeyPairProvider(new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString()))
+ .setIdleTimeout(Integer.MAX_VALUE)
+ .createSshProxyServerConfiguration();
+ }
+
private PEMGeneratorHostKeyProvider getPemGeneratorHostKeyProvider() {
try {
final Path tempFile = Files.createTempFile("tempKeyNetconfTest", "suffix");
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.12</version>
<configuration>
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
@QueryParam("name") String queryFirewallPolicyName,
@QueryParam("description") String querySecurityPolicyDescription,
@QueryParam("shared") String querySecurityPolicyIsShared,
- @QueryParam("firewall_rules") List querySecurityPolicyFirewallRules,
+ @QueryParam("firewall_rules") List<String> querySecurityPolicyFirewallRules,
@QueryParam("audited") Boolean querySecurityPolicyIsAudited,
// pagination
@QueryParam("limit") String limit,
package org.opendaylight.controller.networkconfig.neutron.northbound;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronNetworkRequest implements INeutronRequest {
+public class NeutronNetworkRequest implements INeutronRequest<NeutronNetwork> {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
singletonNetwork = net;
}
+ @Override
public NeutronNetwork getSingleton() {
return singletonNetwork;
}
+ @Override
public boolean isSingleton() {
return (singletonNetwork != null);
}
+ @Override
public List<NeutronNetwork> getBulk() {
return bulkRequest;
}
package org.opendaylight.controller.networkconfig.neutron.northbound;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronPortRequest implements INeutronRequest {
+public class NeutronPortRequest implements INeutronRequest<NeutronPort> {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
singletonPort = port;
}
+ @Override
public NeutronPort getSingleton() {
return singletonPort;
}
+ @Override
public boolean isSingleton() {
return (singletonPort != null);
}
+ @Override
public List<NeutronPort> getBulk() {
return bulkRequest;
}
package org.opendaylight.controller.networkconfig.neutron.northbound;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronSubnetRequest implements INeutronRequest {
+public class NeutronSubnetRequest implements INeutronRequest<NeutronSubnet> {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
links = null;
}
+ @Override
public NeutronSubnet getSingleton() {
return singletonSubnet;
}
+ @Override
public List<NeutronSubnet> getBulk() {
return bulkRequest;
}
+ @Override
public boolean isSingleton() {
return (singletonSubnet != null);
}
package org.opendaylight.controller.networkconfig.neutron.northbound;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import javax.ws.rs.core.UriInfo;
import org.opendaylight.controller.networkconfig.neutron.INeutronObject;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import javax.ws.rs.core.UriInfo;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
public class PaginatedRequestFactory {
+ private static final Comparator<INeutronObject> NEUTRON_OBJECT_COMPARATOR = new Comparator<INeutronObject>() {
+ @Override
+ public int compare(INeutronObject o1, INeutronObject o2) {
+ return o1.getID().compareTo(o2.getID());
+ }
+ };
public static class PaginationResults<T extends INeutronObject> {
List<T> collection;
}
}
- public static <T extends INeutronObject> INeutronRequest createRequest(Integer limit, String marker,
+ private static final class MarkerObject implements INeutronObject {
+ private final String id;
+
+ MarkerObject(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getID() {
+ return id;
+ }
+
+ @Override
+ public void setID(String id) {
+ throw new UnsupportedOperationException("Marker has constant ID");
+ }
+ }
+
+ /*
+ * SuppressWarnings is needed because the compiler does not understand that we
+ * are actually safe here.
+ *
+ * FIXME: the only caller performs a cast back, so this is not actually necessary.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends INeutronObject> INeutronRequest<T> createRequest(Integer limit, String marker,
Boolean pageReverse,
UriInfo uriInfo,
List<T> collection,
Class<T> clazz) {
- PaginationResults results = _paginate(limit, marker, pageReverse, uriInfo, collection);
+ PaginationResults<T> results = _paginate(limit, marker, pageReverse, uriInfo, collection);
if (clazz.equals(NeutronNetwork.class)){
- return new NeutronNetworkRequest(results.collection, results.links);
+ return (INeutronRequest<T>) new NeutronNetworkRequest((List<NeutronNetwork>) results.collection, results.links);
}
if (clazz.equals(NeutronSubnet.class)){
- return new NeutronSubnetRequest(results.collection, results.links);
+ return (INeutronRequest<T>) new NeutronSubnetRequest((List<NeutronSubnet>) results.collection, results.links);
}
if (clazz.equals(NeutronPort.class)){
- return new NeutronPortRequest(results.collection, results.links);
+ return (INeutronRequest<T>) new NeutronPortRequest((List<NeutronPort>) results.collection, results.links);
}
return null;
}
- private static <T extends INeutronObject> PaginationResults _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List<T> collection) {
+ private static <T extends INeutronObject> PaginationResults<T> _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List<T> collection) {
List<NeutronPageLink> links = new ArrayList<>();
- Integer startPos = null;
+ final int startPos;
String startMarker;
String endMarker;
Boolean firstPage = false;
Boolean lastPage = false;
- Comparator<INeutronObject> neutronObjectComparator = new Comparator<INeutronObject>() {
- @Override
- public int compare(INeutronObject o1, INeutronObject o2) {
- return o1.getID().compareTo(o2.getID());
- }
- };
-
- Collections.sort(collection, neutronObjectComparator);
-
- if (marker == null) {
- startPos = 0;
- }
-
- else {
-
- class MarkerObject implements INeutronObject {
- private String id;
-
- public String getID() {
- return id;
- }
+ Collections.sort(collection, NEUTRON_OBJECT_COMPARATOR);
- public void setID(String id) {
- this.id = id;
- }
+ if (marker != null) {
+ int offset = Collections.binarySearch(collection, new MarkerObject(marker), NEUTRON_OBJECT_COMPARATOR);
+ if (offset < 0) {
+ throw new ResourceNotFoundException("UUID for marker: " + marker + " could not be found");
}
- INeutronObject markerObject = new MarkerObject();
-
- markerObject.setID(marker);
-
- startPos = Collections.binarySearch(collection, markerObject, neutronObjectComparator);
-
- if (!pageReverse){
- startPos = startPos + 1;
+ if (!pageReverse) {
+ startPos = offset + 1;
}
else {
- startPos = startPos - limit;
+ startPos = offset - limit;
}
-
}
-
- if (startPos == null) {
- throw new ResourceNotFoundException("UUID for marker:" + marker + " could not be found");
+ else {
+ startPos = 0;
}
if (startPos == 0){
links.add(previous);
}
- return new PaginationResults(collection, links);
+ return new PaginationResults<T>(collection, links);
}
}
</prerequisites>
<modules>
<module>opendaylight/distribution/opendaylight</module>
- <module>opendaylight/forwarding/staticrouting</module>
- <module>opendaylight/clustering/services</module>
- <module>opendaylight/clustering/services_implementation</module>
- <module>opendaylight/clustering/stub</module>
- <module>opendaylight/clustering/test</module>
- <module>opendaylight/configuration/api</module>
- <module>opendaylight/configuration/implementation</module>
- <module>opendaylight/routing/dijkstra_implementation</module>
- <module>opendaylight/arphandler</module>
- <module>opendaylight/forwardingrulesmanager/api</module>
- <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/containermanager/implementation</module>
- <module>opendaylight/containermanager/shell</module>
- <module>opendaylight/appauth</module>
- <module>opendaylight/switchmanager/api</module>
- <module>opendaylight/switchmanager/implementation</module>
- <module>opendaylight/statisticsmanager/api</module>
- <module>opendaylight/statisticsmanager/implementation</module>
- <module>opendaylight/topologymanager/implementation</module>
- <module>opendaylight/topologymanager/shell</module>
- <module>opendaylight/usermanager/api</module>
- <module>opendaylight/usermanager/implementation</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>third-party/commons/thirdparty</module>
- <!-- SAL bundles -->
- <module>opendaylight/sal/api</module>
- <module>opendaylight/sal/implementation</module>
-
- <!-- SAL Extension bundles -->
- <module>opendaylight/sal/connection/api</module>
- <module>opendaylight/sal/connection/implementation</module>
- <module>opendaylight/sal/networkconfiguration/api</module>
- <module>opendaylight/sal/networkconfiguration/implementation</module>
-
<!-- md-sal -->
<module>opendaylight/md-sal</module>
<!-- config -->
<!-- netconf -->
<module>opendaylight/netconf</module>
- <!-- Web bundles -->
- <module>opendaylight/web/root</module>
- <module>opendaylight/web/flows</module>
- <module>opendaylight/web/devices</module>
- <module>opendaylight/web/troubleshoot</module>
- <module>opendaylight/web/topology</module>
- <module>opendaylight/web/osgi-brandfragment</module>
+ <!-- adsal -->
+ <module>opendaylight/adsal</module>
<!-- Neutron -->
<module>opendaylight/networkconfiguration/neutron</module>
<module>opendaylight/networkconfiguration/neutron/implementation</module>
- <module>opendaylight/northbound/networkconfiguration/neutron</module>
-
- <!-- Northbound bundles -->
- <module>opendaylight/northbound/commons</module>
- <module>opendaylight/northbound/bundlescanner/api</module>
- <module>opendaylight/northbound/bundlescanner/implementation</module>
- <module>opendaylight/northbound/topology</module>
- <module>opendaylight/northbound/staticrouting</module>
- <module>opendaylight/northbound/statistics</module>
- <module>opendaylight/northbound/flowprogrammer</module>
- <module>opendaylight/northbound/hosttracker</module>
- <module>opendaylight/northbound/subnets</module>
- <module>opendaylight/northbound/switchmanager</module>
- <module>opendaylight/northbound/containermanager</module>
- <module>opendaylight/northbound/networkconfiguration/bridgedomain</module>
- <module>opendaylight/northbound/httpservice-bridge</module>
- <module>opendaylight/northbound/jolokia</module>
- <module>opendaylight/northbound/connectionmanager</module>
- <module>opendaylight/northbound/usermanager</module>
- <module>opendaylight/northbound/controllermanager</module>
-
- <!-- Debug and logging -->
- <module>opendaylight/logging/bridge</module>
-
- <!-- Southbound bundles -->
- <module>opendaylight/protocol_plugins/openflow</module>
- <module>opendaylight/protocol_plugins/stub</module>
-
- <!-- Samples -->
- <module>opendaylight/samples/simpleforwarding</module>
- <module>opendaylight/samples/loadbalancer</module>
- <module>opendaylight/samples/northbound/loadbalancer</module>
+ <module>opendaylight/networkconfiguration/neutron/northbound</module>
<!-- Parents -->
<module>opendaylight/commons/concepts</module>
<module>opendaylight/commons/protocol-framework</module>
- <module>opendaylight/commons/httpclient</module>
<module>opendaylight/commons/checkstyle</module>
<module>opendaylight/commons/opendaylight</module>
<module>opendaylight/commons/parent</module>
<module>opendaylight/commons/liblldp</module>
<!-- Karaf Distribution -->
- <module>opendaylight/dummy-console</module>
<module>opendaylight/karaf-branding</module>
<module>opendaylight/distribution/opendaylight-karaf-empty</module>
<module>opendaylight/distribution/opendaylight-karaf</module>
<activeByDefault>false</activeByDefault>
</activation>
<modules>
- <module>opendaylight/clustering/integrationtest</module>
- <module>opendaylight/configuration/integrationtest</module>
- <module>opendaylight/forwardingrulesmanager/integrationtest</module>
- <module>opendaylight/hosttracker/integrationtest</module>
- <module>opendaylight/switchmanager/integrationtest</module>
- <module>opendaylight/topologymanager/integrationtest</module>
- <!-- Northbound integration tests -->
- <module>opendaylight/northbound/integrationtest</module>
- <module>opendaylight/statisticsmanager/integrationtest</module>
- <module>opendaylight/commons/integrationtest</module>
- <module>opendaylight/containermanager/it.implementation</module>
<module>opendaylight/distribution/sanitytest/</module>
</modules>
</profile>
- <profile>
- <id>docs</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <modules>
- <module>opendaylight/northbound/java-client</module>
- <module>opendaylight/northbound/swagger-ui</module>
- </modules>
- </profile>
</profiles>
</project>