From: Ed Warnicke Date: Mon, 25 Aug 2014 18:03:42 +0000 (+0000) Subject: Merge "Do not use protobuf serialization for FindPrimary and it's responses" X-Git-Tag: release/helium~211 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=315a10ec8b79abec3f4d718359ebb4202bffcb11;hp=38126131b91a300c7545df31b9b1ba846292696e Merge "Do not use protobuf serialization for FindPrimary and it's responses" --- diff --git a/features/adsal/pom.xml b/features/adsal/pom.xml index 0ccb17a664..0ce976e2ef 100644 --- a/features/adsal/pom.xml +++ b/features/adsal/pom.xml @@ -9,7 +9,7 @@ features-adsal ${sal.version} - pom + jar Features :: AD-SAL Features AD-SAL Features POM @@ -18,11 +18,74 @@ org.opendaylight.controller - base-features - ${project.parent.version} + features-base features xml - runtime + + + + org.opendaylight.yangtools + features-test + + + + org.opendaylight.controller + opendaylight-karaf-empty + 1.4.2-SNAPSHOT + zip + + + + org.opendaylight.controller + dummy-console + + + org.opendaylight.controller + sal + + + org.opendaylight.controller + sal.connection + + + org.opendaylight.controller + sal.connection.implementation + + + org.opendaylight.controller + sal.implementation + + + org.opendaylight.controller + sal.networkconfiguration + + + org.opendaylight.controller + sal.networkconfiguration.implementation + + + org.opendaylight.controller + clustering.services + + + org.opendaylight.controller + clustering.services-implementation + + + org.opendaylight.controller + clustering.stub + + + org.opendaylight.controller + configuration + + + org.opendaylight.controller + configuration.implementation + + + org.opendaylight.controller + logging.bridge @@ -68,6 +131,20 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + org.opendaylight.controller + opendaylight-karaf-empty + ${commons.opendaylight.version} + + + org.opendaylight.yangtools:features-test + + + diff --git a/features/adsal/src/main/resources/features.xml b/features/adsal/src/main/resources/features.xml index f955315164..e12ca8e5e9 100644 --- a/features/adsal/src/main/resources/features.xml +++ b/features/adsal/src/main/resources/features.xml @@ -1,6 +1,7 @@ + mvn:org.opendaylight.controller/features-base/${commons.opendaylight.version}/xml/features odl-adsal-core odl-adsal-networkconfiguration @@ -9,15 +10,16 @@ odl-adsal-configuration - base-felix-dm - base-dummy-console + odl-base-felix-dm + odl-base-dummy-console odl-adsal-thirdparty - mvn:org.apache.commons/commons-lang3/${commons.lang3.version} + mvn:org.apache.commons/commons-lang3/${commons.lang3.version} mvn:org.opendaylight.controller/sal/${sal.version} mvn:org.opendaylight.controller/sal.implementation/${sal.implementation.version} + odl-adsal-core mvn:org.opendaylight.controller/sal.networkconfiguration/${sal.networkconfiguration.version} mvn:org.opendaylight.controller/sal.networkconfiguration.implementation/${sal.networkconfiguration.version} @@ -28,8 +30,8 @@ transaction - base-felix-dm - base-eclipselink-persistence + odl-base-felix-dm + odl-base-eclipselink-persistence odl-adsal-core mvn:org.opendaylight.controller/clustering.services/${clustering.services.version} mvn:org.opendaylight.controller/clustering.services-implementation/${clustering.services_implementation.version} diff --git a/features/base/pom.xml b/features/base/pom.xml index d925f51b94..ed8e2a8c20 100644 --- a/features/base/pom.xml +++ b/features/base/pom.xml @@ -7,13 +7,465 @@ 1.4.2-SNAPSHOT ../../opendaylight/commons/opendaylight - base-features - pom + features-base + jar ${project.artifactId} Base Features POM features.xml + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + org.opendaylight.controller + dummy-console + + + org.opendaylight.controller + karaf-tomcat-security + + + org.opendaylight.controller.thirdparty + ganymed + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-json-org + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-base + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + + + com.fasterxml.jackson.module + jackson-module-jaxb-annotations + + + com.google.code.gson + gson + + + com.google.guava + guava + + + com.sun.jersey + jersey-client + + + + com.sun.jersey + jersey-core + + + com.sun.jersey + jersey-server + + + commons-codec + commons-codec + + + commons-fileupload + commons-fileupload + + + commons-io + commons-io + + + commons-net + commons-net + + + eclipselink + javax.persistence + + + eclipselink + javax.resource + + + equinoxSDK381 + javax.servlet + + + equinoxSDK381 + javax.servlet.jsp + + + equinoxSDK381 + org.apache.felix.gogo.command + + + equinoxSDK381 + org.apache.felix.gogo.runtime + + + equinoxSDK381 + org.apache.felix.gogo.shell + + + equinoxSDK381 + org.eclipse.equinox.cm + + + equinoxSDK381 + org.eclipse.equinox.console + + + equinoxSDK381 + org.eclipse.equinox.ds + + + equinoxSDK381 + org.eclipse.equinox.launcher + + + equinoxSDK381 + org.eclipse.equinox.util + + + equinoxSDK381 + org.eclipse.osgi + + + equinoxSDK381 + org.eclipse.osgi.services + + + + geminiweb + org.eclipse.gemini.web.core + + + geminiweb + org.eclipse.gemini.web.extender + + + geminiweb + org.eclipse.gemini.web.tomcat + + + geminiweb + org.eclipse.virgo.kernel.equinox.extensions + + + geminiweb + org.eclipse.virgo.util.common + + + geminiweb + org.eclipse.virgo.util.io + + + geminiweb + org.eclipse.virgo.util.math + + + geminiweb + org.eclipse.virgo.util.osgi + + + geminiweb + org.eclipse.virgo.util.osgi.manifest + + + geminiweb + org.eclipse.virgo.util.parser.manifest + + + io.netty + netty-buffer + + + io.netty + netty-codec + + + io.netty + netty-codec-http + + + io.netty + netty-common + + + + + io.netty + netty-handler + + + io.netty + netty-transport + + + orbit + javax.activation + + + orbit + javax.annotation + + + orbit + javax.ejb + + + orbit + javax.el + + + orbit + javax.mail.glassfish + + + orbit + javax.servlet.jsp.jstl + + + orbit + javax.servlet.jsp.jstl.impl + + + orbit + javax.xml.rpc + + + orbit + org.apache.catalina + 7.0.53.v201406061610 + + + orbit + org.apache.catalina.ha + 7.0.53.v201406070630 + + + orbit + org.apache.catalina.tribes + 7.0.53.v201406070630 + + + orbit + org.apache.coyote + 7.0.53.v201406070630 + + + orbit + org.apache.el + 7.0.53.v201406060720 + + + orbit + org.apache.jasper + 7.0.53.v201406070630 + + + orbit + org.apache.juli.extras + 7.0.53.v201406060720 + + + orbit + org.apache.tomcat.api + 7.0.53.v201406060720 + + + orbit + org.apache.tomcat.util + 7.0.53.v201406070630 + + + org.aopalliance + com.springsource.org.aopalliance + + + org.apache.commons + commons-lang3 + + + org.apache.felix + org.apache.felix.dependencymanager + + + org.apache.felix + org.apache.felix.dependencymanager.shell + + + org.apache.felix + org.apache.felix.fileinstall + + + + org.apache.felix + org.apache.felix.webconsole + all + + + + org.codehaus.jettison + jettison + + + + org.eclipse.equinox.http + servlet + + + org.eclipse.persistence + org.eclipse.persistence.antlr + + + org.eclipse.persistence + org.eclipse.persistence.core + + + org.eclipse.persistence + org.eclipse.persistence.moxy + + + org.javassist + javassist + + + org.jboss.spec.javax.transaction + jboss-transaction-api_1.1_spec + + + org.jolokia + jolokia-osgi + + + + org.json + json + + + + org.ow2.asm + asm-all + + + + org.ow2.chameleon.management + chameleon-mbeans + + + + + org.slf4j + jcl-over-slf4j + + + org.slf4j + log4j-over-slf4j + + + org.slf4j + slf4j-api + + + org.springframework + org.springframework.aop + + + + org.springframework + org.springframework.asm + + + org.springframework + org.springframework.beans + + + org.springframework + org.springframework.context + + + org.springframework + org.springframework.context.support + + + org.springframework + org.springframework.core + + + org.springframework + org.springframework.expression + + + org.springframework + org.springframework.transaction + + + org.springframework + org.springframework.web + + + org.springframework + org.springframework.web.servlet + + + + org.springframework.security + spring-security-config + + + org.springframework.security + spring-security-core + + + org.springframework.security + spring-security-taglibs + + + org.springframework.security + spring-security-web + + + virgomirror + org.eclipse.jdt.core.compiler.batch + + + + + org.opendaylight.yangtools + features-test + 0.6.2-SNAPSHOT + + + + org.opendaylight.controller + opendaylight-karaf-empty + 1.4.2-SNAPSHOT + zip + + @@ -75,6 +527,20 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + org.opendaylight.controller + opendaylight-karaf-empty + ${commons.opendaylight.version} + + + org.opendaylight.yangtools:features-test + + + diff --git a/features/base/src/main/resources/features.xml b/features/base/src/main/resources/features.xml index c335600e21..999cf704d2 100644 --- a/features/base/src/main/resources/features.xml +++ b/features/base/src/main/resources/features.xml @@ -1,35 +1,35 @@ - + - + http transaction - base-felix-dm - base-aries-spi-fly - base-dummy-console - base-apache-commons - base-eclipselink-persistence - base-gemini-web - base-tomcat - base-netty - base-jersey - base-jackson - base-spring-security + odl-base-felix-dm + odl-base-aries-spi-fly + odl-base-dummy-console + odl-base-apache-commons + odl-base-eclipselink-persistence + odl-base-gemini-web + odl-base-tomcat + odl-base-netty + odl-base-jersey + odl-base-jackson + odl-base-spring-security - + mvn:org.opendaylight.controller/dummy-console/1.1.0-SNAPSHOT - - mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version} - mvn:org.apache.felix/org.apache.felix.dependencymanager/${felix.dependencymanager.version} - mvn:org.apache.felix/org.apache.felix.dependencymanager.shell/${felix.dependencymanager.shell.version} + + mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version} + mvn:org.apache.felix/org.apache.felix.dependencymanager/${felix.dependencymanager.version} + mvn:org.apache.felix/org.apache.felix.dependencymanager.shell/${felix.dependencymanager.shell.version} - - mvn:org.apache.aries/org.apache.aries.util/1.1.0 - mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/${spifly.version} - mvn:org.ow2.asm/asm-all/4.0 + + mvn:org.apache.aries/org.apache.aries.util/1.1.0 + mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/${spifly.version} + mvn:org.ow2.asm/asm-all/4.0 - + wrap:mvn:io.netty/netty-buffer/${netty.version} wrap:mvn:io.netty/netty-codec/${netty.version} wrap:mvn:io.netty/netty-transport/${netty.version} @@ -38,95 +38,96 @@ wrap:mvn:io.netty/netty-codec-http/${netty.version} mvn:org.opendaylight.controller.thirdparty/ganymed/1.1-SNAPSHOT - - base-gemini-web - mvn:org.opendaylight.controller.thirdparty/com.sun.jersey.jersey-servlet/${jersey.version} + + odl-base-gemini-web mvn:com.sun.jersey/jersey-server/${jersey.version} mvn:com.sun.jersey/jersey-core/${jersey.version} mvn:com.sun.jersey/jersey-client/${jersey.version} mvn:com.sun.jersey/jersey-servlet/${jersey.version} - + http mvn:com.eclipsesource.jaxrs/jersey-all/${jersey2.version} mvn:com.eclipsesource.jaxrs/publisher/${jersey2.publisher.version} - mvn:javax.ws.rs/javax.ws.rs-api/${jsr311.v2.api.version} + mvn:javax.ws.rs/javax.ws.rs-api/${jsr311.v2.api.version} mvn:javax.annotation/javax.annotation-api/${javax.annotation.version} - - mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version} - mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version} - mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version} - mvn:org.codehaus.jettison/jettison/${jettison.version} - mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version} - mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version} - mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version} + + mvn:com.sun.jersey/jersey-core/${jersey.version} + mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version} + mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version} + mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version} + mvn:org.codehaus.jettison/jettison/${jettison.version} + mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version} + mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version} + mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version} - - mvn:org.slf4j/slf4j-jdk14/1.7.2 - mvn:org.slf4j/slf4j-nop/1.7.2 - mvn:org.slf4j/slf4j-simple/1.7.2 - mvn:org.slf4j/slf4j-api/1.7.2 + + mvn:org.slf4j/slf4j-jdk14/1.7.2 + mvn:org.slf4j/slf4j-nop/1.7.2 + mvn:org.slf4j/slf4j-simple/1.7.2 + mvn:org.slf4j/slf4j-api/1.7.2 - - mvn:com.google.guava/guava/${guava.version} - mvn:org.javassist/javassist/${javassist.version} - mvn:commons-io/commons-io/${commons.io.version} - mvn:commons-codec/commons-codec/${commons.codec.version} - mvn:org.apache.commons/commons-lang3/${commons.lang3.version} - mvn:commons-net/commons-net/${commons.net.version} + + mvn:com.google.guava/guava/${guava.version} + mvn:org.javassist/javassist/${javassist.version} + mvn:commons-io/commons-io/${commons.io.version} + mvn:commons-codec/commons-codec/${commons.codec.version} + mvn:org.apache.commons/commons-lang3/${commons.lang3.version} + mvn:commons-net/commons-net/${commons.net.version} - - mvn:eclipselink/javax.persistence/2.0.4.v201112161009 - mvn:eclipselink/javax.resource/1.5.0.v200906010428 - mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/2.5.0 - mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0 + + mvn:eclipselink/javax.persistence/2.0.4.v201112161009 + mvn:eclipselink/javax.resource/1.5.0.v200906010428 + mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/2.5.0 + mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.5.0 - + http transaction - base-slf4j - base-felix-dm - base-jackson - base-apache-commons - mvn:com.google.code.gson/gson/${gson.version} - mvn:commons-fileupload/commons-fileupload/${commons.fileupload.version} - mvn:geminiweb/org.eclipse.gemini.web.core/${geminiweb.version} - mvn:geminiweb/org.eclipse.gemini.web.extender/${geminiweb.version} - mvn:geminiweb/org.eclipse.virgo.util.common/${virgo.version} - mvn:geminiweb/org.eclipse.virgo.util.io/${virgo.version} - mvn:geminiweb/org.eclipse.virgo.util.math/${virgo.version} - mvn:geminiweb/org.eclipse.virgo.util.osgi/${virgo.version} - mvn:geminiweb/org.eclipse.virgo.util.osgi.manifest/${virgo.version} - mvn:geminiweb/org.eclipse.virgo.util.parser.manifest/${virgo.version} - mvn:org.apache.felix/org.apache.felix.fileinstall/3.1.6 - mvn:orbit/javax.activation/1.1.0.v201211130549 - mvn:orbit/javax.annotation/1.1.0.v201209060031 - mvn:orbit/javax.ejb/3.1.1.v201204261316 - mvn:orbit/javax.el/2.2.0.v201108011116 - mvn:orbit/javax.mail.glassfish/1.4.1.v201108011116 - mvn:orbit/javax.xml.rpc/1.1.0.v201005080400 - mvn:org.eclipse.jetty.orbit/javax.servlet.jsp/2.2.0.v201112011158 - mvn:orbit/javax.servlet.jsp.jstl/1.2.0.v201105211821 - mvn:orbit/javax.servlet.jsp.jstl.impl/1.2.0.v201210211230 + odl-base-slf4j + odl-base-felix-dm + odl-base-jackson + odl-base-apache-commons + mvn:com.google.code.gson/gson/${gson.version} + mvn:commons-fileupload/commons-fileupload/${commons.fileupload.version} + mvn:geminiweb/org.eclipse.gemini.web.core/${geminiweb.version} + mvn:geminiweb/org.eclipse.gemini.web.extender/${geminiweb.version} + mvn:geminiweb/org.eclipse.virgo.util.common/${virgo.version} + mvn:geminiweb/org.eclipse.virgo.util.io/${virgo.version} + mvn:geminiweb/org.eclipse.virgo.util.math/${virgo.version} + mvn:geminiweb/org.eclipse.virgo.util.osgi/${virgo.version} + mvn:geminiweb/org.eclipse.virgo.util.osgi.manifest/${virgo.version} + mvn:geminiweb/org.eclipse.virgo.util.parser.manifest/${virgo.version} + mvn:org.apache.felix/org.apache.felix.fileinstall/3.1.6 + mvn:orbit/javax.activation/1.1.0.v201211130549 + mvn:orbit/javax.annotation/1.1.0.v201209060031 + mvn:orbit/javax.ejb/3.1.1.v201204261316 + mvn:orbit/javax.el/2.2.0.v201108011116 + mvn:orbit/javax.mail.glassfish/1.4.1.v201108011116 + mvn:orbit/javax.xml.rpc/1.1.0.v201005080400 + mvn:org.eclipse.jetty.orbit/javax.servlet.jsp/2.2.0.v201112011158 + mvn:orbit/javax.servlet.jsp.jstl/1.2.0.v201105211821 + mvn:orbit/javax.servlet.jsp.jstl.impl/1.2.0.v201210211230 - - base-gemini-web - base-eclipselink-persistence - mvn:orbit/org.apache.catalina/${commons.karaf.catalina} - mvn:geminiweb/org.eclipse.gemini.web.tomcat/${geminiweb.version} - mvn:orbit/org.apache.catalina.ha/${commons.karaf.catalina.ha} - mvn:orbit/org.apache.catalina.tribes/${commons.karaf.catalina.tribes} - mvn:orbit/org.apache.coyote/${commons.karaf.coyote} - mvn:orbit/org.apache.el/${commons.karaf.el} - mvn:orbit/org.apache.jasper/${commons.karaf.jasper} - mvn:orbit/org.apache.juli.extras/${commons.karaf.juli.version} - mvn:orbit/org.apache.tomcat.api/${commons.karaf.tomcat.api} - mvn:orbit/org.apache.tomcat.util/${commons.karaf.tomcat.util} + + odl-base-gemini-web + odl-base-eclipselink-persistence + mvn:orbit/org.apache.catalina/${commons.karaf.catalina} + mvn:geminiweb/org.eclipse.gemini.web.tomcat/${geminiweb.version} + mvn:orbit/org.apache.catalina.ha/${commons.karaf.catalina.ha} + mvn:orbit/org.apache.catalina.tribes/${commons.karaf.catalina.tribes} + mvn:orbit/org.apache.coyote/${commons.karaf.coyote} + mvn:orbit/org.apache.el/${commons.karaf.el} + mvn:orbit/org.apache.jasper/${commons.karaf.jasper} + mvn:orbit/org.apache.juli.extras/${commons.karaf.juli.version} + mvn:orbit/org.apache.tomcat.api/${commons.karaf.tomcat.api} + mvn:orbit/org.apache.tomcat.util/${commons.karaf.tomcat.util} mvn:org.opendaylight.controller/karaf-tomcat-security/${karaf.security.version} - wrap:mvn:virgomirror/org.eclipse.jdt.core.compiler.batch/${eclipse.jdt.core.compiler.batch.version} + wrap:mvn:virgomirror/org.eclipse.jdt.core.compiler.batch/${eclipse.jdt.core.compiler.batch.version} - + mvn:org.ow2.asm/asm-all/${asm.version} mvn:org.aopalliance/com.springsource.org.aopalliance/${aopalliance.version} mvn:org.springframework/org.springframework.aop/${spring.version} @@ -138,14 +139,14 @@ mvn:org.springframework/org.springframework.expression/${spring.version} mvn:org.springframework/org.springframework.transaction/${spring.version} - - base-spring - base-gemini-web + + odl-base-spring + odl-base-gemini-web mvn:org.springframework/org.springframework.web/${spring.version} mvn:org.springframework/org.springframework.web.servlet/${spring.version} - - base-spring-web + + odl-base-spring-web mvn:org.springframework.security/spring-security-config/${spring-security.version} mvn:org.springframework.security/spring-security-core/${spring-security.version} mvn:org.springframework.security/spring-security-taglibs/${spring-security.version} diff --git a/features/config-netty/src/main/resources/features.xml b/features/config-netty/src/main/resources/features.xml index 7f57d8cb84..f8df1aa58c 100644 --- a/features/config-netty/src/main/resources/features.xml +++ b/features/config-netty/src/main/resources/features.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.controller/features-config-persister/${config.version}/xml/features - + odl-config-netty-config-api mvn:org.opendaylight.controller/netty-event-executor-config/${project.version} mvn:org.opendaylight.controller/netty-threadgroup-config/${project.version} diff --git a/features/config-persister/src/main/resources/features.xml b/features/config-persister/src/main/resources/features.xml index a3c005b3bd..20fb19f5ff 100644 --- a/features/config-persister/src/main/resources/features.xml +++ b/features/config-persister/src/main/resources/features.xml @@ -6,11 +6,11 @@ mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features mvn:org.opendaylight.controller/features-netconf/${netconf.version}/xml/features mvn:org.opendaylight.controller/features-config/${config.version}/xml/features - + odl-config-persister odl-config-startup - + odl-netconf-api odl-config-api odl-yangtools-binding-generator @@ -27,7 +27,7 @@ mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version} mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version} - + odl-config-netconf-connector odl-config-persister odl-netconf-impl diff --git a/features/config/src/main/resources/features.xml b/features/config/src/main/resources/features.xml index 5027588acb..b4dd03f491 100644 --- a/features/config/src/main/resources/features.xml +++ b/features/config/src/main/resources/features.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features - + odl-mdsal-common odl-config-api odl-config-netty-config-api @@ -13,7 +13,7 @@ odl-config-manager - + odl-yangtools-data-binding mvn:org.opendaylight.controller/sal-common/${mdsal.version} mvn:org.opendaylight.controller/sal-common-api/${mdsal.version} @@ -21,13 +21,13 @@ mvn:org.opendaylight.controller/sal-common-util/${mdsal.version} - + mvn:org.opendaylight.controller/config-api/${project.version} odl-yangtools-common odl-yangtools-binding - + odl-config-api mvn:org.opendaylight.controller/netty-config-api/${project.version} mvn:io.netty/netty-transport/${netty.version} @@ -35,7 +35,7 @@ mvn:io.netty/netty-buffer/${netty.version} - + odl-yangtools-common odl-yangtools-binding odl-yangtools-binding-generator @@ -49,7 +49,7 @@ mvn:com.google.guava/guava/${guava.version} mvn:org.javassist/javassist/${javassist.version} - + odl-config-core mvn:org.opendaylight.controller/config-manager/${project.version} diff --git a/features/flow/src/main/resources/features.xml b/features/flow/src/main/resources/features.xml index 3f914be4ae..0540458630 100644 --- a/features/flow/src/main/resources/features.xml +++ b/features/flow/src/main/resources/features.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features - + odl-yangtools-models mvn:org.opendaylight.controller.model/model-flow-base/${project.version} mvn:org.opendaylight.controller.model/model-flow-service/${project.version} @@ -12,7 +12,7 @@ mvn:org.opendaylight.controller.model/model-inventory/${project.version} mvn:org.opendaylight.controller.model/model-topology/${project.version} - + odl-mdsal-broker odl-flow-model mvn:org.opendaylight.controller.md/topology-manager/${project.version} diff --git a/features/mdsal/pom.xml b/features/mdsal/pom.xml index ac6b82b26f..5be0061698 100644 --- a/features/mdsal/pom.xml +++ b/features/mdsal/pom.xml @@ -123,8 +123,8 @@ jersey-server - org.opendaylight.controller.thirdparty - com.sun.jersey.jersey-servlet + com.sun.jersey + jersey-servlet io.netty diff --git a/features/mdsal/src/main/resources/features.xml b/features/mdsal/src/main/resources/features.xml index a3d7ed0f83..754e97dee3 100644 --- a/features/mdsal/src/main/resources/features.xml +++ b/features/mdsal/src/main/resources/features.xml @@ -7,13 +7,13 @@ mvn:org.opendaylight.controller/features-config/${config.version}/xml/features mvn:org.opendaylight.controller/features-config-persister/${config.version}/xml/features mvn:org.opendaylight.controller/features-config-netty/${config.version}/xml/features - + odl-mdsal-broker odl-mdsal-netconf-connector odl-restconf odl-toaster - + odl-yangtools-common odl-yangtools-binding odl-mdsal-common @@ -30,7 +30,7 @@ mvn:org.opendaylight.controller/sal-inmemory-datastore/${project.version} mvn:org.opendaylight.controller/md-sal-config/${mdsal.version}/xml/config - + odl-mdsal-broker odl-netconf-client odl-yangtools-models @@ -39,14 +39,14 @@ mvn:org.opendaylight.controller/netconf-config-dispatcher/${config.version} mvn:org.opendaylight.controller/netconf-connector-config/${netconf.version}/xml/config - + odl-mdsal-broker war mvn:org.opendaylight.controller/sal-rest-connector/${project.version} mvn:com.google.code.gson/gson/${gson.version} mvn:com.sun.jersey/jersey-core/${jersey.version} mvn:com.sun.jersey/jersey-server/${jersey.version} - mvn:org.opendaylight.controller.thirdparty/com.sun.jersey.jersey-servlet/${jersey.version} + mvn:com.sun.jersey/jersey-servlet/${jersey.version} mvn:io.netty/netty-buffer/${netty.version} mvn:io.netty/netty-codec/${netty.version} mvn:io.netty/netty-codec-http/${netty.version} @@ -56,7 +56,7 @@ mvn:org.opendaylight.controller/sal-remote/${project.version} mvn:org.opendaylight.controller/sal-rest-connector-config/${mdsal.version}/xml/config - + odl-yangtools-common odl-yangtools-binding odl-mdsal-broker diff --git a/features/netconf/pom.xml b/features/netconf/pom.xml index 106e54a338..51d6f6291b 100644 --- a/features/netconf/pom.xml +++ b/features/netconf/pom.xml @@ -74,6 +74,10 @@ org.opendaylight.controller.thirdparty ganymed + + org.apache.sshd + sshd-core + org.openexi nagasena diff --git a/features/netconf/src/main/resources/features.xml b/features/netconf/src/main/resources/features.xml index 0033b0d83c..1453a5fb96 100644 --- a/features/netconf/src/main/resources/features.xml +++ b/features/netconf/src/main/resources/features.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.controller/features-protocol-framework/${protocol-framework.version}/xml/features mvn:org.opendaylight.controller/features-config/${config.version}/xml/features - + odl-netconf-api odl-netconf-mapping-api odl-netconf-util @@ -16,7 +16,7 @@ odl-netconf-monitoring - + odl-protocol-framework mvn:org.opendaylight.controller/netconf-api/${project.version} mvn:org.opendaylight.controller/ietf-netconf-monitoring/${project.version} @@ -24,7 +24,7 @@ mvn:org.opendaylight.yangtools.model/ietf-inet-types/${ietf-inet-types.version} mvn:org.opendaylight.yangtools.model/ietf-yang-types/${ietf-yang-types.version} - + odl-netconf-api mvn:org.opendaylight.controller/netconf-mapping-api/${project.version} @@ -32,26 +32,27 @@ odl-netconf-mapping-api mvn:org.opendaylight.controller/netconf-util/${project.version} - + odl-netconf-api odl-netconf-mapping-api odl-netconf-util odl-netconf-netty-util mvn:org.opendaylight.controller/netconf-impl/${project.version} - + odl-config-manager odl-netconf-api odl-netconf-mapping-api odl-netconf-util mvn:org.opendaylight.controller/config-netconf-connector/${project.version} - + odl-netconf-api odl-netconf-mapping-api odl-netconf-util mvn:org.opendaylight.controller/netconf-netty-util/${project.version} mvn:org.opendaylight.controller.thirdparty/ganymed/${ganymed.version} + mvn:org.apache.sshd/sshd-core/${sshd-core.version} mvn:org.openexi/nagasena/${exi.nagasena.version} mvn:io.netty/netty-codec/${netty.version} mvn:io.netty/netty-handler/${netty.version} @@ -59,14 +60,14 @@ mvn:io.netty/netty-buffer/${netty.version} mvn:io.netty/netty-transport/${netty.version} - + odl-netconf-netty-util mvn:org.opendaylight.controller/netconf-client/${project.version} - mvn:org.opendaylight.controller/netconf-config/${netconf.version}/xml/config + mvn:org.opendaylight.controller/netconf-config/${netconf.version}/xml/config - + odl-netconf-util mvn:org.opendaylight.controller/netconf-monitoring/${project.version} - \ No newline at end of file + diff --git a/features/nsf/pom.xml b/features/nsf/pom.xml index 224aef1dac..5be411caae 100644 --- a/features/nsf/pom.xml +++ b/features/nsf/pom.xml @@ -8,12 +8,248 @@ ../../opendaylight/commons/opendaylight features-nsf - pom + ${nsf.version} + jar OpenDaylight :: Features :: Network Service Functions Feature for Network Service Functions features.xml + + + + org.opendaylight.yangtools + features-test + + + + org.opendaylight.controller + opendaylight-karaf-empty + 1.4.2-SNAPSHOT + zip + + + + org.opendaylight.controller + appauth + + + org.opendaylight.controller + arphandler + + + org.opendaylight.controller + bundlescanner + + + org.opendaylight.controller + bundlescanner.implementation + + + org.opendaylight.controller + commons.northbound + + + org.opendaylight.controller + configuration + + + org.opendaylight.controller + configuration.implementation + + + org.opendaylight.controller + connectionmanager + + + org.opendaylight.controller + connectionmanager.implementation + + + org.opendaylight.controller + connectionmanager.northbound + + + org.opendaylight.controller + containermanager + + + org.opendaylight.controller + containermanager.implementation + + + org.opendaylight.controller + containermanager.shell + + + org.opendaylight.controller + containermanager.northbound + + + org.opendaylight.controller + controllermanager.northbound + + + org.opendaylight.controller + devices.web + + + org.opendaylight.controller + flowprogrammer.northbound + + + org.opendaylight.controller + flows.web + + + org.opendaylight.controller + routing.dijkstra_implementation + + + org.opendaylight.controller + forwarding.staticrouting + + + org.opendaylight.controller + forwarding.staticrouting.northbound + + + org.opendaylight.controller + forwardingrulesmanager + + + org.opendaylight.controller + forwardingrulesmanager.implementation + + + org.opendaylight.controller + hosttracker + + + org.opendaylight.controller + hosttracker.shell + + + org.opendaylight.controller + hosttracker.implementation + + + org.opendaylight.controller + hosttracker.northbound + + + org.opendaylight.controller + httpservice-bridge + + + org.opendaylight.controller + jolokia-bridge + + + org.opendaylight.controller + logging.bridge + + + org.opendaylight.controller + networkconfig.bridgedomain.northbound + + + org.opendaylight.controller + networkconfig.neutron + + + org.opendaylight.controller + networkconfig.neutron.implementation + + + org.opendaylight.controller + networkconfig.neutron.northbound + + + org.opendaylight.controller + osgi-brandfragment.web + + + org.opendaylight.controller + samples.loadbalancer + + + org.opendaylight.controller + samples.loadbalancer.northbound + + + org.opendaylight.controller + samples.simpleforwarding + + + org.opendaylight.controller + security + + + org.opendaylight.controller + statistics.northbound + + + org.opendaylight.controller + statisticsmanager + + + org.opendaylight.controller + statisticsmanager.implementation + + + org.opendaylight.controller + subnets.northbound + + + org.opendaylight.controller + switchmanager + + + org.opendaylight.controller + switchmanager.implementation + + + org.opendaylight.controller + switchmanager.northbound + + + org.opendaylight.controller + topology.northbound + + + org.opendaylight.controller + topology.web + + + org.opendaylight.controller + topologymanager + + + org.opendaylight.controller + topologymanager.shell + + + org.opendaylight.controller + troubleshoot.web + + + org.opendaylight.controller + usermanager + + + org.opendaylight.controller + usermanager.implementation + + + org.opendaylight.controller + usermanager.northbound + + + org.opendaylight.controller.thirdparty + net.sf.jung2 + + @@ -57,6 +293,20 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + org.opendaylight.controller + opendaylight-karaf-empty + ${commons.opendaylight.version} + + + org.opendaylight.yangtools:features-test + + + diff --git a/features/nsf/src/main/resources/features.xml b/features/nsf/src/main/resources/features.xml index 130d72e01a..8dc51f1644 100644 --- a/features/nsf/src/main/resources/features.xml +++ b/features/nsf/src/main/resources/features.xml @@ -1,5 +1,7 @@ + mvn:org.opendaylight.controller/features-base/${commons.opendaylight.version}/xml/features + mvn:org.opendaylight.controller/features-adsal/${sal.version}/xml/features odl-adsal-all odl-nsf-managers @@ -11,7 +13,7 @@ - base-all + odl-base-all odl-adsal-all mvn:org.opendaylight.controller/usermanager/${usermanager.version} mvn:org.opendaylight.controller/usermanager.implementation/${usermanager.version} @@ -43,16 +45,16 @@ mvn:org.opendaylight.controller/hosttracker.implementation/${hosttracker.implementation.version} mvn:org.opendaylight.controller/hosttracker.shell/${hosttracker.shell.version} - mvn:org.opendaylight.controller/forwarding.staticrouting + mvn:org.opendaylight.controller/forwarding.staticrouting/${forwarding.staticrouting} mvn:org.opendaylight.controller.thirdparty/net.sf.jung2/2.0.1 - mvn:org.opendaylight.controller/routing.dijkstra_implementation + mvn:org.opendaylight.controller/routing.dijkstra_implementation/${routing.dijkstra_implementation.version} - base-all + odl-base-all odl-nsf-managers - mvn:org.ow2.asm/asm-all/${asm.version} + mvn:org.ow2.asm/asm-all/${asm.version} + + 4.0.0 + + ${artifactId} + ${groupId} + Configuration files for md-sal + + jar + + + 80-configfile.xml + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${configfile} + xml + config + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/${repoName}.git + scm:git:ssh://git.opendaylight.org:29418/${repoName}.git + HEAD + https://git.opendaylight.org/gerrit/gitweb?p=${repoName}.git;a=summary + + diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/archetype-resources/src/main/resources/80-configfile.xml b/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/archetype-resources/src/main/resources/80-configfile.xml new file mode 100644 index 0000000000..432b947351 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/archetype-resources/src/main/resources/80-configfile.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/src/test/resources/projects/basic/archetype.properties b/opendaylight/archetypes/opendaylight-configfile-archetype/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..7a940e7a6e --- /dev/null +++ b/opendaylight/archetypes/opendaylight-configfile-archetype/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,6 @@ +#Mon Aug 25 05:45:18 CDT 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +repoName=foo diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/src/test/resources/projects/basic/goal.txt b/opendaylight/archetypes/opendaylight-configfile-archetype/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml new file mode 100644 index 0000000000..8883c64295 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + org.opendaylight.controller + opendaylight-karaf-distro-archetype + 1.0.0-SNAPSHOT + maven-archetype + + distribution-karaf-archetype + + + + + org.apache.maven.archetype + archetype-packaging + 2.2 + + + + + + + maven-archetype-plugin + 2.2 + + + + + + https://wiki.opendaylight.org/view/CrossProject:Integration_Group/distribution-karaf + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main + + diff --git a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..4c4f5103ee --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/archetype-resources/pom.xml b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..965c619695 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,285 @@ + + + 4.0.0 + + ${artifactId} + ${groupId} + + pom + + 3.0 + + + + 1.0.0-SNAPSHOT + 1.4.2-SNAPSHOT + 3.0.1 + + + + + + org.apache.karaf.features + framework + ${karaf.version} + kar + + + org.apache.karaf.features + standard + ${karaf.version} + features + xml + runtime + + + + + org.opendaylight.controller + karaf.branding + ${branding.version} + compile + + + + + org.opendaylight.controller + opendaylight-karaf-resources + ${karaf.resources.version} + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.felix + maven-bundle-plugin + [0,) + + cleanVersions + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [0,) + + copy + unpack + + + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + [0,) + + commands-generate-help + + + + + + + + + org.fusesource.scalate + maven-scalate-plugin + [0,) + + sitegen + + + + + + + + + org.apache.servicemix.tooling + depends-maven-plugin + [0,) + + generate-depends-file + + + + + + + + + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + true + + + standard + + + + + + + process-resources + + install-kars + + process-resources + + + package + + instance-create-archive + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + copy + + copy + + generate-resources + + + + org.opendaylight.controller + karaf.branding + ${karaf.branding.version} + target/assembly/lib + karaf.branding-${branding.version}.jar + + + + + + unpack-karaf-resources + + unpack-dependencies + + prepare-package + + ${project.build.directory}/assembly + org.opendaylight.controller + opendaylight-karaf-resources + META-INF\/** + true + false + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + prepare-package + + run + + + + + + + + + + + + + + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/${repoName}.git + scm:git:ssh://git.opendaylight.org:29418/${repoName}.git + HEAD + https://git.opendaylight.org/gerrit/gitweb?p=${repoName}.git;a=summary + + diff --git a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/test/resources/projects/basic/archetype.properties b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..dd29db648f --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,6 @@ +#Thu Aug 21 14:44:29 CDT 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +repoName=foo diff --git a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/test/resources/projects/basic/goal.txt b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/opendaylight/archetypes/opendaylight-karaf-features/pom.xml b/opendaylight/archetypes/opendaylight-karaf-features/pom.xml new file mode 100644 index 0000000000..4973a69537 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-features/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + org.opendaylight.controller + opendaylight-karaf-features-archetype + 1.0.0-SNAPSHOT + maven-archetype + + opendaylight-karaf-features-archetype + + + + + org.apache.maven.archetype + archetype-packaging + 2.2 + + + + + + + maven-archetype-plugin + 2.2 + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git/ + scm:git:ssh://git.opendaylight.org:29418/controller.git/ + https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=summary + + diff --git a/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/META-INF/maven/archetype-metadata.xml b/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..158e448265 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,14 @@ + + + + + + + + src/main/resources + **/*.xml + + + diff --git a/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/pom.xml b/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..e135e6b656 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,194 @@ + + + + 4.0.0 + + features-${repoName} + ${groupId} + + jar + + features.xml + + 1.0.0-SNAPSHOT + 1.4.2-SNAPSHOT + 3.0.1 + 0.6.2-SNAPSHOT + 1.4.2-SNAPSHOT + 2.16 + + + + + + + + + + + + org.opendaylight.yangtools + features-test + ${feature.test.version} + test + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${karaf.empty.version} + zip + + + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + generate-resources + + resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + package + + attach-artifact + + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + + org.opendaylight.controller + opendaylight-karaf-empty + ${karaf.empty.version} + + + org.opendaylight.yangtools:features-test + + + + + + + scm:git:ssh://git.opendaylight.org:29418/${repoName}.git + scm:git:ssh://git.opendaylight.org:29418/${repoName}.git + HEAD + https://git.opendaylight.org/gerrit/gitweb?p=${repoName}.git;a=summary + + diff --git a/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/src/main/resources/features.xml b/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/src/main/resources/features.xml new file mode 100644 index 0000000000..4a59657431 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/src/main/resources/features.xml @@ -0,0 +1,86 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + + + + + + + + + + + + + diff --git a/opendaylight/archetypes/opendaylight-karaf-features/src/test/resources/projects/basic/archetype.properties b/opendaylight/archetypes/opendaylight-karaf-features/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..bab8cd295d --- /dev/null +++ b/opendaylight/archetypes/opendaylight-karaf-features/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,6 @@ +#Thu Aug 21 23:46:25 CDT 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +repoName=foo diff --git a/opendaylight/archetypes/opendaylight-karaf-features/src/test/resources/projects/basic/goal.txt b/opendaylight/archetypes/opendaylight-karaf-features/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/opendaylight/archetypes/pom.xml b/opendaylight/archetypes/pom.xml index 36af861e84..cb597c10bd 100644 --- a/opendaylight/archetypes/pom.xml +++ b/opendaylight/archetypes/pom.xml @@ -6,9 +6,9 @@ org.opendaylight.controller - commons.parent - 1.0.1-SNAPSHOT - ../commons/parent + commons.opendaylight + 1.4.2-SNAPSHOT + ../commons/opendaylight scm:git:ssh://git.opendaylight.org:29418/controller.git @@ -39,5 +39,8 @@ odl-model-project + opendaylight-configfile-archetype + opendaylight-karaf-distro-archetype + opendaylight-karaf-features diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 5ead566d9d..b9a6f38412 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -210,11 +210,13 @@ 0.4.2-SNAPSHOT 0.0.2-SNAPSHOT 0.4.2-SNAPSHOT + 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT src/main/xtend-gen 2013.09.07.4-SNAPSHOT 1.0.0-SNAPSHOT 0.6.2-SNAPSHOT + 0.12.0 @@ -235,6 +237,11 @@ netconf-netty-util ${netconf.version} + + org.apache.sshd + sshd-core + ${sshd-core.version} + ch.qos.logback logback-classic @@ -319,12 +326,16 @@ jersey-core ${jersey.version} - com.sun.jersey jersey-server ${jersey.version} + + com.sun.jersey + jersey-servlet + ${jersey-servlet.version} + com.typesafe.akka @@ -1004,6 +1015,11 @@ hosttracker.northbound ${hosttracker.northbound.version} + + org.opendaylight.controller + hosttracker.shell + ${hosttracker.shell.version} + org.opendaylight.controller hosttracker_new @@ -1041,6 +1057,11 @@ logging.bridge ${logging.bridge.version} + + org.opendaylight.controller + dummy-console + ${dummy-console.version} + @@ -1396,6 +1417,11 @@ security ${security.version} + + org.opendaylight.controller + karaf-tomcat-security + ${karaf.security.version} + org.opendaylight.controller @@ -1469,6 +1495,11 @@ topologymanager ${topologymanager.version} + + org.opendaylight.controller + topologymanager.shell + ${topologymanager.shell.version} + org.opendaylight.controller troubleshoot.web @@ -1926,6 +1957,14 @@ xml runtime + + org.opendaylight.controller + features-base + ${commons.opendaylight.version} + features + xml + runtime + org.opendaylight.controller features-adsal @@ -1934,6 +1973,14 @@ xml runtime + + org.opendaylight.controller + features-nsf + ${nsf.version} + features + xml + runtime + org.opendaylight.controller features-mdsal diff --git a/opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml b/opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml index 73a46f0f8a..fbcd0a4c77 100644 --- a/opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml +++ b/opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml @@ -48,7 +48,7 @@ - + + + org.opendaylight.controller + features-base + features + xml + + + org.opendaylight.controller + features-adsal + features + xml + + + org.opendaylight.controller + features-nsf + features + xml + org.opendaylight.controller @@ -242,6 +261,11 @@ + + + + + diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index d70bf46411..9a7677099d 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -1156,6 +1156,10 @@ org.opendaylight.controller.thirdparty ganymed + + org.apache.sshd + sshd-core + org.opendaylight.yangtools binding-generator-api diff --git a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java index 344694381a..dba2908e9c 100644 --- a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java +++ b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java @@ -73,6 +73,7 @@ public class TestHelper { mavenBundle(CONTROLLER, "netconf-client").versionAsInProject(), // mavenBundle(CONTROLLER, "netconf-util").versionAsInProject(), // mavenBundle(CONTROLLER, "netconf-netty-util").versionAsInProject(), // + mavenBundle("org.apache.sshd", "sshd-core").versionAsInProject(), // mavenBundle("org.openexi", "nagasena").versionAsInProject(), // mavenBundle("org.openexi", "nagasena-rta").versionAsInProject(), // mavenBundle(CONTROLLER + ".thirdparty", "ganymed").versionAsInProject(), // diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java index 17bdb36e56..d1ae264c3b 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java @@ -32,7 +32,7 @@ public class NormalizedNodeToNodeCodec { String parentPath = ""; if(id != null){ - parentPath = PathUtils.getParentPath(id.toString()); + parentPath = PathUtils.getParentPath(PathUtils.toString(id)); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java index 31e6521a28..32f3be82fc 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java @@ -25,7 +25,7 @@ public class NormalizedNodeGetter implements @Override public void visitNode(int level, String parentPath, NormalizedNode normalizedNode) { - String nodePath = parentPath + "/"+ normalizedNode.getIdentifier().toString(); + String nodePath = parentPath + "/"+ PathUtils.toString(normalizedNode.getIdentifier()); if(nodePath.toString().equals(path)){ output = normalizedNode; diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java index 1dd0f3b827..25b65f0168 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java @@ -10,7 +10,16 @@ package org.opendaylight.controller.cluster.datastore.node.utils; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + public class PathUtils { + public static String getParentPath(String currentElementPath){ StringBuilder parentPath = new StringBuilder(); @@ -27,4 +36,86 @@ public class PathUtils { } return parentPath.toString(); } + + /** + * Given a YangInstanceIdentifier return a serialized version of the same + * as a String + * + * @param path + * @return + */ + public static String toString(YangInstanceIdentifier path){ + StringBuilder sb = new StringBuilder(); + Iterator iterator = + path.getPathArguments().iterator(); + + while(iterator.hasNext()){ + sb.append(toString(iterator.next())); + if(iterator.hasNext()){ + sb.append("/"); + } + } + return sb.toString(); + } + + /** + * Given a YangInstanceIdentifier.PathArgument return a serialized version + * of the same as a String + * + * @param pathArgument + * @return + */ + public static String toString(YangInstanceIdentifier.PathArgument pathArgument){ + if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifier){ + return toString((YangInstanceIdentifier.NodeIdentifier) pathArgument); + } else if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){ + return toString((YangInstanceIdentifier.AugmentationIdentifier) pathArgument); + } else if(pathArgument instanceof YangInstanceIdentifier.NodeWithValue){ + return toString((YangInstanceIdentifier.NodeWithValue) pathArgument); + } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates){ + return toString((YangInstanceIdentifier.NodeIdentifierWithPredicates) pathArgument); + } + + return pathArgument.toString(); + } + + /** + * Given a serialized string version of a YangInstanceIdentifier convert + * to a YangInstanceIdentifier + * + * @param path + * @return + */ + public static YangInstanceIdentifier toYangInstanceIdentifier(String path){ + String[] segments = path.split("/"); + + List pathArguments = new ArrayList<>(); + for (String segment : segments) { + if (!"".equals(segment)) { + pathArguments.add(NodeIdentifierFactory.getArgument(segment)); + } + } + return YangInstanceIdentifier.create(pathArguments); + } + + private static String toString(YangInstanceIdentifier.NodeIdentifier pathArgument){ + return pathArgument.getNodeType().toString(); + } + + private static String toString(YangInstanceIdentifier.AugmentationIdentifier pathArgument){ + Set childNames = pathArgument.getPossibleChildNames(); + final StringBuilder sb = new StringBuilder("AugmentationIdentifier{"); + sb.append("childNames=").append(childNames).append('}'); + return sb.toString(); + + } + + private static String toString(YangInstanceIdentifier.NodeWithValue pathArgument){ + return pathArgument.getNodeType().toString() + "[" + pathArgument.getValue() + "]"; + } + + private static String toString(YangInstanceIdentifier.NodeIdentifierWithPredicates pathArgument){ + return pathArgument.getNodeType().toString() + '[' + pathArgument.getKeyValues() + ']'; + } + } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java index bdad86ddc1..c42865c659 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java @@ -13,9 +13,9 @@ package org.opendaylight.controller.cluster.datastore.node; import junit.framework.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeGetter; import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator; +import org.opendaylight.controller.cluster.datastore.node.utils.PathUtils; import org.opendaylight.controller.cluster.datastore.util.TestModel; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node; @@ -24,7 +24,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; @@ -43,21 +42,9 @@ public class NormalizedNodeToNodeCodecTest { } private YangInstanceIdentifier instanceIdentifierFromString(String s) { - - String[] ids = s.split("/"); - - List pathArguments = new ArrayList<>(); - for (String nodeId : ids) { - if (!"".equals(nodeId)) { - pathArguments.add(NodeIdentifierFactory.getArgument(nodeId)); - } - } - final YangInstanceIdentifier instanceIdentifier = - YangInstanceIdentifier.create(pathArguments); - return instanceIdentifier; + return PathUtils.toYangInstanceIdentifier(s); } - @Test public void testNormalizeNodeAttributesToProtoBuffNode() { final NormalizedNode documentOne = TestModel.createTestContainer(); @@ -69,7 +56,7 @@ public class NormalizedNodeToNodeCodecTest { NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id); new NormalizedNodeNavigator(normalizedNodeGetter).navigate( - YangInstanceIdentifier.builder().build().toString(), documentOne); + PathUtils.toString(YangInstanceIdentifier.builder().build()), documentOne); // Validate the value of id can be retrieved from the normalized node NormalizedNode output = normalizedNodeGetter.getOutput(); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java new file mode 100644 index 0000000000..ffa8a1059e --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java @@ -0,0 +1,121 @@ +package org.opendaylight.controller.cluster.datastore.node.utils; + +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.util.TestModel; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static junit.framework.TestCase.assertEquals; + +public class PathUtilsTest { + + @Test + public void getParentPath(){ + assertEquals("", PathUtils.getParentPath("foobar")); + assertEquals("", PathUtils.getParentPath("/a")); + assertEquals("/a", PathUtils.getParentPath("/a/b")); + assertEquals("/a/b", PathUtils.getParentPath("/a/b/c")); + assertEquals("/a/b", PathUtils.getParentPath("a/b/c")); + } + + @Test + public void toStringNodeIdentifier(){ + YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifier(); + + String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"; + + assertEquals(expected , PathUtils.toString(pathArgument)); + } + + @Test + public void toStringAugmentationIdentifier(){ + String expected = "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}"; + + YangInstanceIdentifier.PathArgument pathArgument = augmentationIdentifier(); + + assertEquals(expected, PathUtils.toString(pathArgument)); + } + + @Test + public void toStringNodeWithValue(){ + + YangInstanceIdentifier.PathArgument pathArgument = nodeWithValue(); + + String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; + + assertEquals(expected, PathUtils.toString(pathArgument)); + } + + + @Test + public void toStringNodeIdentifierWithPredicates(){ + + YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifierWithPredicates(); + + String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]"; + + assertEquals(expected, PathUtils.toString(pathArgument)); + } + + @Test + public void toStringYangInstanceIdentifier(){ + + YangInstanceIdentifier path = + YangInstanceIdentifier.create(nodeIdentifier()) + .node(nodeIdentifierWithPredicates()) + .node(augmentationIdentifier()).node(nodeWithValue()); + + + String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test/" + + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" + + "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}/" + + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; + + assertEquals(expected, PathUtils.toString(path)); + + } + + @Test + public void toYangInstanceIdentifier(){ + String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test/" + + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" + + "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}/" + + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; + + YangInstanceIdentifier yangInstanceIdentifier = + PathUtils.toYangInstanceIdentifier(expected); + + String actual = PathUtils.toString(yangInstanceIdentifier); + + assertEquals(expected, actual); + + } + + private YangInstanceIdentifier.NodeIdentifier nodeIdentifier(){ + return new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME); + } + + private YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier(){ + Set childNames = new HashSet(); + childNames.add(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics")); + + return new YangInstanceIdentifier.AugmentationIdentifier(childNames); + } + + private YangInstanceIdentifier.NodeWithValue nodeWithValue(){ + return new YangInstanceIdentifier.NodeWithValue(TestModel.TEST_QNAME, Integer.valueOf(100)); + } + + private YangInstanceIdentifier.NodeIdentifierWithPredicates nodeIdentifierWithPredicates(){ + Map keys = new HashMap<>(); + + keys.put(TestModel.ID_QNAME, Integer.valueOf(100)); + + return new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.TEST_QNAME, keys); + } +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index 129013378e..7ad3b8201e 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -191,7 +191,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch } @Override - public synchronized DOMStoreThreePhaseCommitCohort ready(final SnapshotBackedWriteTransaction writeTx) { + public DOMStoreThreePhaseCommitCohort ready(final SnapshotBackedWriteTransaction writeTx) { LOG.debug("Tx: {} is submitted. Modifications: {}", writeTx.getIdentifier(), writeTx.getMutatedView()); return new ThreePhaseCommitImpl(writeTx); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java index 44ee61c116..2caa76d49d 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java @@ -33,7 +33,7 @@ final class SnapshotBackedReadTransaction extends AbstractDOMStoreTransaction implements DOMStoreReadTransaction { private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class); - private DataTreeSnapshot stableSnapshot; + private volatile DataTreeSnapshot stableSnapshot; public SnapshotBackedReadTransaction(final Object identifier, final DataTreeSnapshot snapshot) { super(identifier); @@ -52,19 +52,21 @@ final class SnapshotBackedReadTransaction extends AbstractDOMStoreTransaction LOG.debug("Tx: {} Read: {}", getIdentifier(), path); checkNotNull(path, "Path must not be null."); - if(stableSnapshot == null) { + final DataTreeSnapshot snapshot = stableSnapshot; + if (snapshot == null) { return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed")); } try { - return Futures.immediateCheckedFuture(stableSnapshot.readNode(path)); + return Futures.immediateCheckedFuture(snapshot.readNode(path)); } catch (Exception e) { LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e); return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e)); } } - @Override public CheckedFuture exists(YangInstanceIdentifier path) { + @Override + public CheckedFuture exists(YangInstanceIdentifier path) { LOG.debug("Tx: {} Exists: {}", getIdentifier(), path); checkNotNull(path, "Path must not be null."); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemas.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemas.java index d6bfc0c3b6..23b039c254 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemas.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemas.java @@ -115,6 +115,11 @@ public final class NetconfStateSchemas { final CompositeNode schemasNode = (CompositeNode) NetconfMessageTransformUtil.findNode(schemasNodeResult.getResult(), DATA_STATE_SCHEMAS_IDENTIFIER); + if(schemasNode == null) { + logger.warn("{}: Unable to detect available schemas, get to {} was empty", id, STATE_SCHEMAS_IDENTIFIER); + return EMPTY; + } + return create(id, schemasNode); } diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java index 451cad4816..10aec4ca2e 100644 --- a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java +++ b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java @@ -15,11 +15,9 @@ import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMap import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNode; import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNodeId; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; +import java.util.Collections; +import java.util.List; + import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; @@ -50,6 +48,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; + class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, OpendaylightInventoryListener { private final Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyExporter.class); @@ -193,8 +197,9 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open @Override public void onSuccess(Optional topologyOptional) { if (topologyOptional.isPresent()) { - Topology topologyData = topologyOptional.get(); - for (Link link : topologyData.getLink()) { + List linkList = topologyOptional.get().getLink() != null + ? topologyOptional.get().getLink() : Collections. emptyList(); + for (Link link : linkList) { if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(link)); } @@ -220,8 +225,9 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open @Override public void onSuccess(Optional topologyOptional) { if (topologyOptional.isPresent()) { - Topology topologyData = topologyOptional.get(); - for (Link link : topologyData.getLink()) { + List linkList = topologyOptional.get().getLink() != null + ? topologyOptional.get().getLink() : Collections. emptyList(); + for (Link link : linkList) { if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(link)); } diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java index 0a48e6c67d..8e9f9978c4 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java @@ -173,8 +173,12 @@ public class ConfigPersisterActivator implements BundleActivator { if(configs != null && !configs.isEmpty()) { configPusher.pushConfigs(configs); } - registration = context.registerService(ConfigPusher.class.getName(), configPusher, null); - configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator); + if(context != null) { + registration = context.registerService(ConfigPusher.class.getName(), configPusher, null); + configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator); + } else { + logger.warn("Unable to process configs as BundleContext is null"); + } } catch (InterruptedException e) { logger.info("ConfigPusher thread stopped",e); } diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializer.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializer.java index 87b3f837e8..2aa5d15224 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializer.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializer.java @@ -12,7 +12,7 @@ import io.netty.util.concurrent.Promise; import java.io.IOException; import org.opendaylight.controller.netconf.nettyutil.AbstractChannelInitializer; import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; -import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshHandler; +import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler; import org.opendaylight.protocol.framework.SessionListenerFactory; final class SshClientChannelInitializer extends AbstractChannelInitializer { @@ -32,7 +32,7 @@ final class SshClientChannelInitializer extends AbstractChannelInitializer promise) { try { - ch.pipeline().addFirst(SshHandler.createForNetconfSubsystem(authenticationHandler)); + ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(authenticationHandler)); super.initialize(ch,promise); } catch (final IOException e) { throw new RuntimeException(e); diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java index 6826b4a09c..56f674bc34 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java @@ -9,13 +9,10 @@ package org.opendaylight.controller.netconf.it; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import ch.ethz.ssh2.Connection; import io.netty.channel.ChannelFuture; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; @@ -30,8 +27,6 @@ import junit.framework.Assert; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.spi.ModuleFactory; import org.opendaylight.controller.netconf.api.NetconfMessage; @@ -47,6 +42,7 @@ import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProduce import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher; import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl; import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; +import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.LoginPassword; import org.opendaylight.controller.netconf.ssh.NetconfSSHServer; import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider; import org.opendaylight.controller.netconf.ssh.authentication.AuthProviderImpl; @@ -144,16 +140,6 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { } public AuthenticationHandler getAuthHandler() throws IOException { - final AuthenticationHandler authHandler = mock(AuthenticationHandler.class); - doAnswer(new Answer() { - @Override - public Object answer(final InvocationOnMock invocation) throws Throwable { - Connection conn = (Connection) invocation.getArguments()[0]; - conn.authenticateWithPassword("user", "pwd"); - return null; - } - }).when(authHandler).authenticate(any(Connection.class)); - doReturn("auth handler").when(authHandler).toString(); - return authHandler; + return new LoginPassword("user", "pwd"); } } diff --git a/opendaylight/netconf/netconf-netty-util/pom.xml b/opendaylight/netconf/netconf-netty-util/pom.xml index 13041598d1..80dc1ae0fd 100644 --- a/opendaylight/netconf/netconf-netty-util/pom.xml +++ b/opendaylight/netconf/netconf-netty-util/pom.xml @@ -52,6 +52,10 @@ org.opendaylight.controller.thirdparty ganymed + + org.apache.sshd + sshd-core + org.openexi nagasena @@ -73,6 +77,7 @@ xmlunit xmlunit + @@ -82,7 +87,7 @@ maven-bundle-plugin - ch.ethz.ssh2, com.google.common.base, com.google.common.collect, io.netty.buffer, + org.apache.sshd.*, ch.ethz.ssh2, com.google.common.base, com.google.common.collect, io.netty.buffer, io.netty.channel, io.netty.channel.socket, io.netty.handler.codec, io.netty.handler.ssl, io.netty.util, io.netty.util.concurrent, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.sax, javax.xml.transform.stream, org.opendaylight.controller.netconf.api, diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/AuthenticationHandler.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/AuthenticationHandler.java index b22b792d52..eea2b8693a 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/AuthenticationHandler.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/AuthenticationHandler.java @@ -9,12 +9,17 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication; import ch.ethz.ssh2.Connection; - import java.io.IOException; +import org.apache.sshd.ClientSession; /** * Class providing authentication facility to SSH handler. */ public abstract class AuthenticationHandler { public abstract void authenticate(Connection connection) throws IOException; + + + public abstract String getUsername(); + + public abstract org.apache.sshd.client.future.AuthFuture authenticate(final ClientSession session) throws IOException; } diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java index b67aa0f96d..553e5359ff 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java @@ -8,10 +8,13 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication; -import ch.ethz.ssh2.Connection; - import java.io.IOException; +import org.apache.sshd.ClientSession; +import org.apache.sshd.client.future.AuthFuture; + +import ch.ethz.ssh2.Connection; + /** * Class Providing username/password authentication option to * {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshHandler} @@ -27,10 +30,21 @@ public class LoginPassword extends AuthenticationHandler { @Override public void authenticate(Connection connection) throws IOException { - boolean isAuthenticated = connection.authenticateWithPassword(username, password); + final boolean isAuthenticated = connection.authenticateWithPassword(username, password); if (!isAuthenticated) { throw new IOException("Authentication failed."); } } + + @Override + public String getUsername() { + return username; + } + + @Override + public AuthFuture authenticate(final ClientSession session) throws IOException { + session.addPasswordIdentity(password); + return session.auth(); + } } diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java new file mode 100644 index 0000000000..2761a45d03 --- /dev/null +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; + +import com.google.common.base.Preconditions; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import java.io.IOException; +import java.net.SocketAddress; +import org.apache.sshd.ClientChannel; +import org.apache.sshd.ClientSession; +import org.apache.sshd.SshClient; +import org.apache.sshd.client.future.AuthFuture; +import org.apache.sshd.client.future.ConnectFuture; +import org.apache.sshd.client.future.OpenFuture; +import org.apache.sshd.common.future.CloseFuture; +import org.apache.sshd.common.future.SshFutureListener; +import org.apache.sshd.common.io.IoInputStream; +import org.apache.sshd.common.io.IoReadFuture; +import org.apache.sshd.common.util.Buffer; +import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Netty SSH handler class. Acts as interface between Netty and SSH library. + */ +public class AsyncSshHandler extends ChannelOutboundHandlerAdapter { + + private static final Logger logger = LoggerFactory.getLogger(AsyncSshHandler.class); + public static final String SUBSYSTEM = "netconf"; + + public static final SshClient DEFAULT_CLIENT = SshClient.setUpDefaultClient(); + + public static final int SSH_DEFAULT_NIO_WORKERS = 8; + + static { + // TODO make configurable, or somehow reuse netty threadpool + DEFAULT_CLIENT.setNioWorkers(SSH_DEFAULT_NIO_WORKERS); + DEFAULT_CLIENT.start(); + } + + private final AuthenticationHandler authenticationHandler; + private final SshClient sshClient; + + private SshReadAsyncListener sshReadAsyncListener; + private ClientChannel channel; + private ClientSession session; + private ChannelPromise connectPromise; + + public static AsyncSshHandler createForNetconfSubsystem(final AuthenticationHandler authenticationHandler) throws IOException { + return new AsyncSshHandler(authenticationHandler, DEFAULT_CLIENT); + } + + /** + * + * @param authenticationHandler + * @param sshClient started SshClient + * @throws IOException + */ + public AsyncSshHandler(final AuthenticationHandler authenticationHandler, final SshClient sshClient) throws IOException { + this.authenticationHandler = Preconditions.checkNotNull(authenticationHandler); + this.sshClient = Preconditions.checkNotNull(sshClient); + // Start just in case + sshClient.start(); + } + + private void startSsh(final ChannelHandlerContext ctx, final SocketAddress address) { + logger.debug("Starting SSH to {} on channel: {}", address, ctx.channel()); + + final ConnectFuture sshConnectionFuture = sshClient.connect(authenticationHandler.getUsername(), address); + sshConnectionFuture.addListener(new SshFutureListener() { + @Override + public void operationComplete(final ConnectFuture future) { + if (future.isConnected()) { + handleSshSessionCreated(future, ctx); + } else { + handleSshSetupFailure(ctx, future.getException()); + } + } + }); + } + + private synchronized void handleSshSessionCreated(final ConnectFuture future, final ChannelHandlerContext ctx) { + try { + logger.trace("SSH session created on channel: {}", ctx.channel()); + + session = future.getSession(); + final AuthFuture authenticateFuture = authenticationHandler.authenticate(session); + authenticateFuture.addListener(new SshFutureListener() { + @Override + public void operationComplete(final AuthFuture future) { + if (future.isSuccess()) { + handleSshAuthenticated(session, ctx); + } else { + handleSshSetupFailure(ctx, future.getException()); + } + } + }); + } catch (final IOException e) { + handleSshSetupFailure(ctx, e); + } + } + + private synchronized void handleSshAuthenticated(final ClientSession session, final ChannelHandlerContext ctx) { + try { + logger.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(), session.getServerVersion()); + + channel = session.createSubsystemChannel(SUBSYSTEM); + channel.setStreaming(ClientChannel.Streaming.Async); + channel.open().addListener(new SshFutureListener() { + @Override + public void operationComplete(final OpenFuture future) { + if(future.isOpened()) { + handleSshChanelOpened(ctx); + } else { + handleSshSetupFailure(ctx, future.getException()); + } + } + }); + + + } catch (final IOException e) { + handleSshSetupFailure(ctx, e); + } + } + + private synchronized void handleSshChanelOpened(final ChannelHandlerContext ctx) { + logger.trace("SSH subsystem channel opened successfully on channel: {}", ctx.channel()); + + connectPromise.setSuccess(); + connectPromise = null; + ctx.fireChannelActive(); + + final IoInputStream asyncOut = channel.getAsyncOut(); + sshReadAsyncListener = new SshReadAsyncListener(ctx, asyncOut); + } + + private synchronized void handleSshSetupFailure(final ChannelHandlerContext ctx, final Throwable e) { + logger.warn("Unable to setup SSH connection on channel: {}", ctx.channel(), e); + connectPromise.setFailure(e); + connectPromise = null; + throw new IllegalStateException("Unable to setup SSH connection on channel: " + ctx.channel(), e); + } + + @Override + public synchronized void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) { + try { + if(channel.getAsyncIn().isClosed() || channel.getAsyncIn().isClosing()) { + handleSshSessionClosed(ctx); + } else { + channel.getAsyncIn().write(toBuffer(msg)); + ((ByteBuf) msg).release(); + } + } catch (final Exception e) { + logger.warn("Exception while writing to SSH remote on channel {}", ctx.channel(), e); + throw new IllegalStateException("Exception while writing to SSH remote on channel " + ctx.channel(),e); + } + } + + private static void handleSshSessionClosed(final ChannelHandlerContext ctx) { + logger.debug("SSH session closed on channel: {}", ctx.channel()); + ctx.fireChannelInactive(); + } + + private Buffer toBuffer(final Object msg) { + // TODO Buffer vs ByteBuf translate, Can we handle that better ? + Preconditions.checkState(msg instanceof ByteBuf); + final ByteBuf byteBuf = (ByteBuf) msg; + final byte[] temp = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(temp, 0, byteBuf.readableBytes()); + return new Buffer(temp); + } + + @Override + public synchronized void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) throws Exception { + this.connectPromise = promise; + startSsh(ctx, remoteAddress); + } + + @Override + public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception { + disconnect(ctx, promise); + } + + @Override + public synchronized void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception { + if(sshReadAsyncListener != null) { + sshReadAsyncListener.close(); + } + + session.close(false).addListener(new SshFutureListener() { + @Override + public void operationComplete(final CloseFuture future) { + if(future.isClosed() == false) { + session.close(true); + } + session = null; + } + }); + + channel = null; + } + + /** + * Listener over async input stream from SSH session. + * This listeners schedules reads in a loop until the session is closed or read fails. + */ + private static class SshReadAsyncListener implements SshFutureListener, AutoCloseable { + private static final int BUFFER_SIZE = 8192; + + private final ChannelHandlerContext ctx; + + private IoInputStream asyncOut; + private Buffer buf; + private IoReadFuture currentReadFuture; + + public SshReadAsyncListener(final ChannelHandlerContext ctx, final IoInputStream asyncOut) { + this.ctx = ctx; + this.asyncOut = asyncOut; + buf = new Buffer(BUFFER_SIZE); + asyncOut.read(buf).addListener(this); + } + + @Override + public synchronized void operationComplete(final IoReadFuture future) { + if(future.getException() != null) { + + if(asyncOut.isClosed() || asyncOut.isClosing()) { + // We are closing + handleSshSessionClosed(ctx); + } else { + logger.warn("Exception while reading from SSH remote on channel {}", ctx.channel(), future.getException()); + throw new IllegalStateException("Exception while reading from SSH remote on channel " + ctx.channel(), future.getException()); + } + } + + if (future.getRead() > 0) { + ctx.fireChannelRead(Unpooled.wrappedBuffer(buf.array(), 0, future.getRead())); + + // Schedule next read + buf = new Buffer(BUFFER_SIZE); + currentReadFuture = asyncOut.read(buf); + currentReadFuture.addListener(this); + } + } + + @Override + public synchronized void close() throws Exception { + // Remove self as listener on close to prevent reading from closed input + if(currentReadFuture != null) { + currentReadFuture.removeListener(this); + } + + asyncOut = null; + } + } +} diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/Invoker.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/Invoker.java deleted file mode 100644 index eab2546d6e..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/Invoker.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; - -import java.io.IOException; - -/** - * Abstract class providing mechanism of invoking various SSH level services. - * Class is not allowed to be extended, as it provides its own implementations via instance initiators. - */ -abstract class Invoker { - private boolean invoked = false; - - private Invoker() { - } - - protected boolean isInvoked() { - return invoked; - } - - public void setInvoked() { - this.invoked = true; - } - - abstract void invoke(SshSession session) throws IOException; - - public static Invoker netconfSubsystem(){ - return subsystem("netconf"); - } - - public static Invoker subsystem(final String subsystem) { - return new Invoker() { - @Override - synchronized void invoke(SshSession session) throws IOException { - if (isInvoked()) { - throw new IllegalStateException("Already invoked."); - } - try { - session.startSubSystem(subsystem); - } finally { - setInvoked(); - } - } - }; - } -} diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClient.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClient.java deleted file mode 100644 index 271b781b99..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClient.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; - -import ch.ethz.ssh2.Connection; -import ch.ethz.ssh2.Session; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; -import org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.VirtualSocket; - -/** - * Wrapper class around GANYMED SSH java library. - */ -class SshClient { - private final VirtualSocket socket; - private final Map openSessions = new HashMap<>(); - private final AuthenticationHandler authenticationHandler; - private Connection connection; - - public SshClient(VirtualSocket socket, AuthenticationHandler authenticationHandler) throws IOException { - this.socket = socket; - this.authenticationHandler = authenticationHandler; - } - - public SshSession openSession() throws IOException { - if (connection == null) { - connect(); - } - - Session session = connection.openSession(); - SshSession sshSession = new SshSession(session); - openSessions.put(openSessions.size(), sshSession); - - return sshSession; - } - - private void connect() throws IOException { - connection = new Connection(socket); - - connection.connect(); - authenticationHandler.authenticate(connection); - } - - - public void close() { - for (SshSession session : openSessions.values()){ - session.close(); - } - - openSessions.clear(); - - if (connection != null) { - connection.close(); - } - } - - @Override - public String toString() { - return "SshClient{" + - "socket=" + socket + - '}'; - } -} diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java deleted file mode 100644 index 4ca7bdf958..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.LinkedList; -import java.util.Queue; -import java.util.concurrent.atomic.AtomicBoolean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Worker thread class. Handles all downstream and upstream events in SSH Netty - * pipeline. - */ -class SshClientAdapter implements Runnable { - private static final Logger logger = LoggerFactory.getLogger(SshClientAdapter.class); - - private static final int BUFFER_SIZE = 1024; - - private final SshClient sshClient; - private final Invoker invoker; - - private OutputStream stdIn; - - private final Queue postponed = new LinkedList<>(); - - private ChannelHandlerContext ctx; - private ChannelPromise disconnectPromise; - - private final AtomicBoolean stopRequested = new AtomicBoolean(false); - - private final Object lock = new Object(); - - public SshClientAdapter(final SshClient sshClient, final Invoker invoker) { - this.sshClient = sshClient; - this.invoker = invoker; - } - - // TODO ganymed spawns a Thread that receives the data from remote inside TransportManager - // Get rid of this thread and reuse Ganymed internal thread (not sure if its possible without modifications in ganymed) - public void run() { - try { - final SshSession session = sshClient.openSession(); - invoker.invoke(session); - final InputStream stdOut = session.getStdout(); - - synchronized (lock) { - stdIn = session.getStdin(); - while (postponed.peek() != null) { - writeImpl(postponed.poll()); - } - } - - while (!stopRequested.get()) { - final byte[] readBuff = new byte[BUFFER_SIZE]; - final int c = stdOut.read(readBuff); - if (c == -1) { - continue; - } - - ctx.fireChannelRead(Unpooled.copiedBuffer(readBuff, 0, c)); - } - } catch (final Exception e) { - logger.error("Unexpected exception", e); - } finally { - sshClient.close(); - - synchronized (lock) { - if (disconnectPromise != null) { - ctx.disconnect(disconnectPromise); - } - } - } - } - - // TODO: needs rework to match netconf framer API. - public void write(final ByteBuf message) throws IOException { - synchronized (lock) { - if (stdIn == null) { - postponed.add(message); - return; - } - writeImpl(message); - } - } - - private void writeImpl(final ByteBuf message) throws IOException { - message.getBytes(0, stdIn, message.readableBytes()); - message.release(); - stdIn.flush(); - } - - public void stop(final ChannelPromise promise) { - synchronized (lock) { - stopRequested.set(true); - disconnectPromise = promise; - } - } - - public Thread start(final ChannelHandlerContext ctx, final ChannelFuture channelFuture) { - checkArgument(channelFuture.isSuccess()); - checkNotNull(ctx.channel().remoteAddress()); - synchronized (this) { - checkState(this.ctx == null); - this.ctx = ctx; - } - final String threadName = toString(); - final Thread thread = new Thread(this, threadName); - thread.start(); - return thread; - } - - @Override - public String toString() { - return "SshClientAdapter{" + - "sshClient=" + sshClient + - '}'; - } -} diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshHandler.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshHandler.java deleted file mode 100644 index c710a010e2..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; -import io.netty.channel.ChannelPromise; -import java.io.IOException; -import java.net.SocketAddress; -import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; -import org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.VirtualSocket; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Netty SSH handler class. Acts as interface between Netty and SSH library. All standard Netty message handling - * stops at instance of this class. All downstream events are handed of to wrapped {@link org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshClientAdapter}; - */ -public class SshHandler extends ChannelOutboundHandlerAdapter { - private static final Logger logger = LoggerFactory.getLogger(SshHandler.class); - private static final String SOCKET = "socket"; - - private final VirtualSocket virtualSocket = new VirtualSocket(); - private final SshClientAdapter sshClientAdapter; - - - public static SshHandler createForNetconfSubsystem(AuthenticationHandler authenticationHandler) throws IOException { - return new SshHandler(authenticationHandler, Invoker.netconfSubsystem()); - } - - - public SshHandler(AuthenticationHandler authenticationHandler, Invoker invoker) throws IOException { - SshClient sshClient = new SshClient(virtualSocket, authenticationHandler); - this.sshClientAdapter = new SshClientAdapter(sshClient, invoker); - } - - @Override - public void handlerAdded(ChannelHandlerContext ctx){ - if (ctx.channel().pipeline().get(SOCKET) == null) { - ctx.channel().pipeline().addFirst(SOCKET, virtualSocket); - } - } - - @Override - public void handlerRemoved(ChannelHandlerContext ctx) { - if (ctx.channel().pipeline().get(SOCKET) != null) { - ctx.channel().pipeline().remove(SOCKET); - } - } - - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws IOException { - this.sshClientAdapter.write((ByteBuf) msg); - } - - @Override - public void connect(final ChannelHandlerContext ctx, - SocketAddress remoteAddress, - SocketAddress localAddress, - ChannelPromise promise) { - ctx.connect(remoteAddress, localAddress, promise); - - promise.addListener(new ChannelFutureListener() { - public void operationComplete(ChannelFuture channelFuture) { - if (channelFuture.isSuccess()) { - sshClientAdapter.start(ctx, channelFuture); - } else { - logger.debug("Failed to connect to remote host"); - } - }} - ); - } - - @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) { - sshClientAdapter.stop(promise); - } -} diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java deleted file mode 100644 index 9cdc5926f0..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; - -import ch.ethz.ssh2.Session; -import ch.ethz.ssh2.channel.Channel; -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * Wrapper class for proprietary SSH sessions implementations - */ -class SshSession implements Closeable { - private final Session session; - - public SshSession(final Session session) { - this.session = session; - } - - public void startSubSystem(final String name) throws IOException { - session.startSubSystem(name); - } - - public InputStream getStdout() { - return session.getStdout(); - } - - // FIXME according to http://www.ganymed.ethz.ch/ssh2/FAQ.html#blocking you should read data from both stdout and stderr to prevent window filling up (since stdout and stderr share a window) - // FIXME stdErr is not used anywhere - public InputStream getStderr() { - return session.getStderr(); - } - - public OutputStream getStdin() { - return session.getStdin(); - } - - @Override - public void close() { - if (session.getState() == Channel.STATE_OPEN || session.getState() == Channel.STATE_OPENING) { - session.close(); - } - } -} diff --git a/opendaylight/netconf/netconf-ssh/pom.xml b/opendaylight/netconf/netconf-ssh/pom.xml index febf3abf8e..8d48077f93 100644 --- a/opendaylight/netconf/netconf-ssh/pom.xml +++ b/opendaylight/netconf/netconf-ssh/pom.xml @@ -40,6 +40,10 @@ org.opendaylight.controller.thirdparty ganymed + + org.apache.sshd + sshd-core + org.slf4j slf4j-api diff --git a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/SSHTest.java b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/SSHTest.java index 61297835a0..1b2201170a 100644 --- a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/SSHTest.java +++ b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/SSHTest.java @@ -29,7 +29,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.netconf.netty.EchoClientHandler.State; import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.LoginPassword; -import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.SshHandler; +import org.opendaylight.controller.netconf.nettyutil.handler.ssh.client.AsyncSshHandler; import org.opendaylight.controller.netconf.ssh.NetconfSSHServer; import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider; import org.opendaylight.controller.netconf.ssh.authentication.AuthProviderImpl; @@ -94,7 +94,7 @@ public class SSHTest { ChannelInitializer channelInitializer = new ChannelInitializer() { @Override public void initChannel(NioSocketChannel ch) throws Exception { - ch.pipeline().addFirst(SshHandler.createForNetconfSubsystem(new LoginPassword("a", "a"))); + ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(new LoginPassword("a", "a"))); ch.pipeline().addLast(echoClientHandler); } }; diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java index 4a6a291e6a..d92c57bd8a 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -57,6 +57,10 @@ public class Activator extends ComponentActivatorAbstractBase { protected static final Logger logger = LoggerFactory .getLogger(Activator.class); + /** + * Priority to determine whether to override existing protocol service. + */ + private static final int PLUGIN_PRIORITY = 10; /** * Function that is used to communicate to dependency manager the list of @@ -136,6 +140,8 @@ public class Activator extends ComponentActivatorAbstractBase { // Set the protocolPluginType property which will be used // by SAL props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW); + props.put(GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(), + Integer.valueOf(PLUGIN_PRIORITY)); c.setInterface(IPluginInDataPacketService.class.getName(), props); // Hook the services coming in from SAL, as optional in // case SAL is not yet there, could happen @@ -165,6 +171,8 @@ public class Activator extends ComponentActivatorAbstractBase { // Set the protocolPluginType property which will be used // by SAL props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW); + props.put(GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(), + Integer.valueOf(PLUGIN_PRIORITY)); c.setInterface(new String[] { IReadFilterInternalListener.class.getName(), IPluginInReadService.class.getName() }, props); @@ -256,6 +264,8 @@ public class Activator extends ComponentActivatorAbstractBase { // Set the protocolPluginType property which will be used // by SAL props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW); + props.put(GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(), + Integer.valueOf(PLUGIN_PRIORITY)); c.setInterface( new String[] { IPluginInFlowProgrammerService.class.getName(), IMessageListener.class.getName(), IContainerListener.class.getName(), IInventoryShimExternalListener.class.getName(), diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/GlobalConstants.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/GlobalConstants.java index 174f2546ba..ceb4553470 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/GlobalConstants.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/GlobalConstants.java @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -20,7 +19,8 @@ public enum GlobalConstants { STATICVLAN("staticvlan"), CLUSTERINGSERVICES("clusteringservices"), STARTUPHOME("configuration/startup/"), - PROTOCOLPLUGINTYPE("protocolPluginType"); + PROTOCOLPLUGINTYPE("protocolPluginType"), + PROTOCOLPLUGINPRIORITY("protocolPluginPriority"); private GlobalConstants(String name) { this.name = name; @@ -31,4 +31,4 @@ public enum GlobalConstants { public String toString() { return name; } -} \ No newline at end of file +} diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java index e9039261a3..0c9ebab8c3 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -40,7 +39,6 @@ import org.opendaylight.controller.sal.packet.LinkEncap; import org.opendaylight.controller.sal.packet.Packet; import org.opendaylight.controller.sal.packet.PacketResult; import org.opendaylight.controller.sal.packet.RawPacket; -import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.NetUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,9 +57,9 @@ public class DataPacketService implements IPluginOutDataPacketService, * adding a new service, removing a service, going through all of * them maybe different. */ - private ConcurrentHashMap + private ConcurrentHashMap> pluginInDataService = - new ConcurrentHashMap(); + new ConcurrentHashMap>(); private Map statistics = new HashMap(); /** @@ -186,11 +184,11 @@ public class DataPacketService implements IPluginOutDataPacketService, String t = p.getNode() .getType(); // Now locate the TX dispatcher - IPluginInDataPacketService s = pluginInDataService - .get(t); - if (s != null) { + ProtocolService service = + pluginInDataService.get(t); + if (service != null) { try { - s.transmitDataPacket(pkt); + service.getService().transmitDataPacket(pkt); increaseStat("TXPacketSuccess"); } catch (Exception e) { increaseStat("TXPacketFailedForException"); @@ -207,54 +205,11 @@ public class DataPacketService implements IPluginOutDataPacketService, } void setPluginInDataService(Map props, IPluginInDataPacketService s) { - if (this.pluginInDataService == null) { - logger.error("pluginInDataService store null"); - return; - } - String type = null; - logger.trace("Received setPluginInDataService request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue()); - } - - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a PluginInDataService without any " - + "protocolPluginType provided"); - } else { - this.pluginInDataService.put(type, s); - logger.debug("Stored the PluginInDataService for type: {}", type); - } + ProtocolService.set(this.pluginInDataService, props, s, logger); } void unsetPluginInDataService(Map props, IPluginInDataPacketService s) { - if (this.pluginInDataService == null) { - logger.error("pluginInDataService store null"); - return; - } - - String type = null; - logger.trace("Received unsetPluginInDataService request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue()); - } - - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a PluginInDataService without any " - + "protocolPluginType provided"); - } else if (this.pluginInDataService.get(type).equals(s)) { - this.pluginInDataService.remove(type); - logger.debug("Removed the PluginInDataService for type: {}", type); - } + ProtocolService.unset(this.pluginInDataService, props, s, logger); } void setListenDataPacket(Map props, IListenDataPacket s) { diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java index 854125b356..60a7882bda 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -38,7 +38,6 @@ import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerSe import org.opendaylight.controller.sal.match.Match; import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.controller.sal.utils.EtherTypes; -import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.IPProtocols; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.Status; @@ -58,12 +57,12 @@ public class FlowProgrammerService implements IFlowProgrammerService, protected static final Logger logger = LoggerFactory .getLogger(FlowProgrammerService.class); - private ConcurrentHashMap pluginFlowProgrammer; + private ConcurrentHashMap> pluginFlowProgrammer; private Set listener; private AtomicLong seq; public FlowProgrammerService() { - pluginFlowProgrammer = new ConcurrentHashMap(); + pluginFlowProgrammer = new ConcurrentHashMap>(); listener = new HashSet(); seq = new AtomicLong(); /* @@ -117,58 +116,11 @@ public class FlowProgrammerService implements IFlowProgrammerService, // Set the reference to the plugin flow programmer public void setService(Map props, IPluginInFlowProgrammerService s) { - if (this.pluginFlowProgrammer == null) { - logger.error("pluginFlowProgrammer store null"); - return; - } - - if (logger.isTraceEnabled()) { - logger.trace("Got a service set request {}", s); - for (Map.Entry entry : props.entrySet()) { - logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue()); - } - } - - String type = null; - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a pluginFlowProgrammer without any " - + "protocolPluginType provided"); - } else { - this.pluginFlowProgrammer.put(type, s); - logger.debug("Stored the pluginFlowProgrammer for type: {}", type); - } + ProtocolService.set(this.pluginFlowProgrammer, props, s, logger); } public void unsetService(Map props, IPluginInFlowProgrammerService s) { - if (this.pluginFlowProgrammer == null) { - logger.error("pluginFlowProgrammer store null"); - return; - } - - logger.debug("Received unsetpluginFlowProgrammer request"); - if (logger.isTraceEnabled()) { - logger.trace("Got a service set request {}", s); - for (Map.Entry entry : props.entrySet()) { - logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue()); - } - } - - String type = null; - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a pluginFlowProgrammer without any " - + "protocolPluginType provided"); - } else if (this.pluginFlowProgrammer.get(type).equals(s)) { - this.pluginFlowProgrammer.remove(type); - logger.debug("Removed the pluginFlowProgrammer for type: {}", type); - } + ProtocolService.unset(this.pluginFlowProgrammer, props, s, logger); } public void setListener(IFlowProgrammerListener s) { @@ -182,9 +134,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status addFlow(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()).addFlow( - node, flow); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().addFlow(node, flow); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -193,9 +146,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status removeFlow(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .removeFlow(node, flow); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().removeFlow(node, flow); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -204,9 +158,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status removeAllFlows(Node node) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .removeAllFlows(node); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().removeAllFlows(node); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -215,9 +170,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .modifyFlow(node, oldFlow, newFlow); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().modifyFlow(node, oldFlow, newFlow); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -226,9 +182,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status addFlowAsync(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()).addFlowAsync( - node, flow, getNextRid()); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().addFlowAsync(node, flow, getNextRid()); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -237,9 +194,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status removeFlowAsync(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .removeFlowAsync(node, flow, getNextRid()); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().removeFlowAsync(node, flow, getNextRid()); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -248,9 +206,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .modifyFlowAsync(node, oldFlow, newFlow, getNextRid()); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().modifyFlowAsync(node, oldFlow, newFlow, getNextRid()); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -508,9 +467,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status syncSendBarrierMessage(Node node) { if (this.pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .syncSendBarrierMessage(node); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().syncSendBarrierMessage(node); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -519,9 +479,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status asyncSendBarrierMessage(Node node) { if (this.pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .asyncSendBarrierMessage(node); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().asyncSendBarrierMessage(node); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ProtocolService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ProtocolService.java new file mode 100644 index 0000000000..e9dc2ad0ee --- /dev/null +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ProtocolService.java @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2014 NEC Corporation and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.sal.implementation.internal; + +import java.util.Map; +import java.util.concurrent.ConcurrentMap; + +import org.slf4j.Logger; + +import org.opendaylight.controller.sal.utils.GlobalConstants; + +/** + * An instance of this class keeps a protocol plugin service handler. + * + * @param Type of protocol plugin service. + */ +public final class ProtocolService { + /** + * Default priority value. + */ + private static final int DEFAULT_PRIORITY = 0; + + /** + * A protocol plugin service handler. + */ + private final T service; + + /** + * A priority value assigned to this protocol plugin. + */ + private final int priority; + + /** + * Set protocol plugin service. + * + * @param map A map that keeps protocol plugin services. + * @param props Service properties. + * @param s Protocol plugin service. + * @param logger A logger instance. + * @param Type of protocol plugin service. + */ + public static void set(ConcurrentMap> map, + Map props, S s, Logger logger) { + if (map == null) { + logger.error("Protocol plugin service store is null."); + return; + } + if (s == null) { + logger.error("Protocol plugin service is null."); + return; + } + if (props == null) { + logger.error("Service property is null."); + return; + } + + if (logger.isTraceEnabled()) { + logger.trace("Received set service request: {}", s); + for (Map.Entry entry: props.entrySet()) { + logger.trace("Prop key:({}) value:({})", entry.getKey(), + entry.getValue()); + } + } + + Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); + if (!(value instanceof String)) { + logger.error("Unexpected protocol type: {}", value); + return; + } + + String type = (String)value; + ProtocolService service = new ProtocolService(props, s); + ProtocolService old = map.putIfAbsent(type, service); + while (old != null) { + // Compare priority value. + if (old.getPriority() >= service.getPriority()) { + logger.trace("Protocol plugin service for {} is already set: " + + "current={}, requested={}", type, old, service); + return; + } + + if (map.replace(type, old, service)) { + break; + } + old = map.putIfAbsent(type, service); + } + + logger.debug("Stored protocol plugin service for {}: {}", + type, service); + } + + /** + * Unset protocol plugin service. + * + * @param map A map that keeps protocol plugin services. + * @param props Service properties. + * @param s Protocol plugin service. + * @param logger A logger instance. + * @param Type of protocol plugin service. + */ + public static void unset(ConcurrentMap> map, + Map props, S s, Logger logger) { + if (map == null) { + logger.error("Protocol plugin service store is null."); + return; + } + if (s == null) { + logger.error("Protocol plugin service is null."); + return; + } + if (props == null) { + logger.error("Service property is null."); + return; + } + + if (logger.isTraceEnabled()) { + logger.trace("Received unset service request: {}", s); + for (Map.Entry entry: props.entrySet()) { + logger.trace("Prop key:({}) value:({})", + entry.getKey(), entry.getValue()); + } + } + + Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); + if (!(value instanceof String)) { + logger.error("Unexpected protocol type {}: service={}", value, s); + return; + } + + String type = (String)value; + ProtocolService plugin = new ProtocolService(props, s); + if (map.remove(type, plugin)) { + logger.debug("Removed protocol plugin service for {}: {}", + type, plugin); + } else { + logger.trace("Ignore unset service request for {}: {}", + type, plugin); + } + } + + /** + * Constructor. + * + * @param props Protocol plugin service properties. + * @param s A protocol plugin service handler. + */ + public ProtocolService(Map props, T s) { + service = s; + + String key = GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(); + Object value = props.get(key); + if (value instanceof Integer) { + priority = ((Integer)value).intValue(); + } else { + priority = DEFAULT_PRIORITY; + } + } + + /** + * Return a protocol plugin service handler. + * + * @return A protocol plugin service handler. + */ + public T getService() { + return service; + } + + /** + * Return a priority value assigned to this protocol plugin. + * + * @return A priority value. + */ + public int getPriority() { + return priority; + } + + /** + * Determine whether the given object is identical to this object. + * + * @param o An object to be compared. + * @return {@code true} if identical. Otherwise {@code false}. + */ + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o == null || o.getClass() != getClass()) { + return false; + } + + ProtocolService plugin = (ProtocolService)o; + return (service.equals(plugin.service) && priority == plugin.priority); + } + + /** + * Return the hash code of this object. + * + * @return The hash code. + */ + @Override + public int hashCode() { + return service.hashCode() + (priority * 31); + } + + /** + * Return a string representation of this instance. + * + * @return A string representation of this instance. + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder("[service="); + return builder.append(service).append(", priority=").append(priority). + append(']').toString(); + } +} diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java index 12de35f536..356c0e57c8 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -43,7 +42,6 @@ import org.opendaylight.controller.sal.reader.NodeConnectorStatistics; import org.opendaylight.controller.sal.reader.NodeDescription; import org.opendaylight.controller.sal.reader.NodeTableStatistics; import org.opendaylight.controller.sal.utils.EtherTypes; -import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.IPProtocols; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.NodeCreator; @@ -60,8 +58,8 @@ import org.slf4j.LoggerFactory; public class ReadService implements IReadService, CommandProvider, IPluginOutReadService { protected static final Logger logger = LoggerFactory.getLogger(ReadService.class); - private ConcurrentHashMap pluginReader = - new ConcurrentHashMap(); + private ConcurrentHashMap> pluginReader = + new ConcurrentHashMap>(); private Set readerListeners = new CopyOnWriteArraySet(); @@ -107,58 +105,13 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea // Set the reference to the plugin flow Reader service public void setService(Map props, IPluginInReadService s) { - if (this.pluginReader == null) { - logger.error("pluginReader store null"); - return; - } - - logger.trace("Got a service set request {}", s); - String type = null; - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})", entry.getKey(), - entry.getValue()); - } - - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a pluginReader without any " - + "protocolPluginType provided"); - } else { - this.pluginReader.put(type, s); - logger.debug("Stored the pluginReader for type: {}", type); - } + ProtocolService.set(this.pluginReader, props, s, logger); } public void unsetService(Map props, IPluginInReadService s) { - if (this.pluginReader == null) { - logger.error("pluginReader store null"); - return; - } - - String type = null; - logger.debug("Received unsetpluginReader request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})", entry.getKey(), - entry.getValue()); - } - - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a pluginReader without any " - + "protocolPluginType provided"); - } else if (this.pluginReader.get(type).equals(s)) { - this.pluginReader.remove(type); - logger.debug("Removed the pluginReader for type: {}", type); - } + ProtocolService.unset(this.pluginReader, props, s, logger); } + public void setReaderListener(IReadServiceListener service) { logger.trace("Got a listener set request {}", service); this.readerListeners.add(service); @@ -172,9 +125,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public FlowOnNode readFlow(Node node, Flow flow) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readFlow(node, flow, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readFlow(node, flow, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -184,9 +138,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public FlowOnNode nonCachedReadFlow(Node node, Flow flow) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readFlow(node, flow, false); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readFlow(node, flow, false); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -196,9 +151,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public List readAllFlows(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readAllFlow(node, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readAllFlow(node, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -208,9 +164,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public List nonCachedReadAllFlows(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readAllFlow(node, false); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readAllFlow(node, false); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -220,9 +177,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public NodeDescription readDescription(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readDescription(node, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readDescription(node, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -232,9 +190,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public NodeDescription nonCachedReadDescription(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readDescription(node, false); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readDescription(node, false); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -245,9 +204,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea public NodeConnectorStatistics readNodeConnector(NodeConnector connector) { Node node = connector.getNode(); if (pluginReader != null && node != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readNodeConnector(connector, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readNodeConnector(connector, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -259,9 +219,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea NodeConnector connector) { Node node = connector.getNode(); if (pluginReader != null && node != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readNodeConnector(connector, false); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readNodeConnector(connector, false); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -271,9 +232,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public List readNodeConnectors(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readAllNodeConnector(node, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readAllNodeConnector(node, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -283,9 +245,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public List readNodeTable(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readAllNodeTable(node, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readAllNodeTable(node, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -297,9 +260,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea public NodeTableStatistics nonCachedReadNodeTable(NodeTable table) { Node node = table.getNode(); if (pluginReader != null && node != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readNodeTable(table, false); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readNodeTable(table, false); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -310,9 +274,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea public NodeTableStatistics readNodeTable(NodeTable table) { Node node = table.getNode(); if (pluginReader != null && node != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readNodeTable(table, true); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readNodeTable(table, true); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -322,9 +287,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea @Override public List nonCachedReadNodeConnectors(Node node) { if (pluginReader != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .readAllNodeConnector(node, false); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().readAllNodeConnector(node, false); } } logger.warn("Plugin {} unavailable", node.getType()); @@ -335,9 +301,10 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea public long getTransmitRate(NodeConnector connector) { Node node = connector.getNode(); if (pluginReader != null && node != null) { - if (this.pluginReader.get(node.getType()) != null) { - return this.pluginReader.get(node.getType()) - .getTransmitRate(connector); + ProtocolService service = + this.pluginReader.get(node.getType()); + if (service != null) { + return service.getService().getTransmitRate(connector); } } logger.warn("Plugin {} unavailable", node.getType()); diff --git a/opendaylight/sal/implementation/src/test/java/org/opendaylight/controller/sal/implementation/ProtocolServiceTest.java b/opendaylight/sal/implementation/src/test/java/org/opendaylight/controller/sal/implementation/ProtocolServiceTest.java new file mode 100644 index 0000000000..079350bcc9 --- /dev/null +++ b/opendaylight/sal/implementation/src/test/java/org/opendaylight/controller/sal/implementation/ProtocolServiceTest.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2014 NEC Corporation and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.sal.implementation; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.opendaylight.controller.sal.implementation.internal.ProtocolService; +import org.opendaylight.controller.sal.utils.GlobalConstants; + +/** + * Unit test for {@link ProtocolService}. + */ +public class ProtocolServiceTest { + private static final Logger LOG = + LoggerFactory.getLogger(ProtocolServiceTest.class); + + @Test + public void testInstance() { + HashSet> set = new HashSet<>(); + TestService sv1 = new TestService(); + HashMap prop1 = new HashMap<>(); + + ProtocolService ps1 = + new ProtocolService(prop1, sv1); + assertEquals(sv1, ps1.getService()); + // Default priority is 0. + assertEquals(0, ps1.getPriority()); + assertTrue(set.add(ps1)); + assertFalse(set.add(ps1)); + + // Specify the same service and priority. + String priKey = GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(); + prop1.put(priKey, Integer.valueOf(0)); + ProtocolService ps2 = + new ProtocolService(prop1, sv1); + assertEquals(sv1, ps2.getService()); + assertEquals(0, ps2.getPriority()); + assertEquals(ps1, ps2); + assertFalse(set.add(ps1)); + + // Specify different priority. + prop1.put(priKey, Integer.valueOf(Integer.MAX_VALUE)); + ps2 = new ProtocolService(prop1, sv1); + assertEquals(sv1, ps2.getService()); + assertEquals(Integer.MAX_VALUE, ps2.getPriority()); + assertFalse(ps1.equals(ps2)); + assertTrue(set.add(ps2)); + assertFalse(set.add(ps2)); + + // Specify another service. + TestService sv2 = new TestService(); + prop1.put(priKey, Integer.valueOf(0)); + ps2 = new ProtocolService(prop1, sv2); + assertEquals(sv2, ps2.getService()); + assertEquals(0, ps2.getPriority()); + assertFalse(ps1.equals(ps2)); + assertTrue(set.add(ps2)); + assertFalse(set.add(ps2)); + } + + @Test + public void testSetUnsetError() { + ConcurrentMap> services = + new ConcurrentHashMap<>(); + TestService sv = new TestService(); + Map props = new HashMap<>(); + + // null service. + ProtocolService.set(services, props, null, LOG); + assertTrue(services.isEmpty()); + + ProtocolService.unset(services, props, null, LOG); + assertTrue(services.isEmpty()); + + // null service property. + ProtocolService.set(services, null, sv, LOG); + assertTrue(services.isEmpty()); + + ProtocolService.unset(services, null, sv, LOG); + assertTrue(services.isEmpty()); + + // Type is not specified. + ProtocolService.set(services, props, sv, LOG); + assertTrue(services.isEmpty()); + + ProtocolService.unset(services, props, sv, LOG); + assertTrue(services.isEmpty()); + + // null service map. + final String typeKey = GlobalConstants.PROTOCOLPLUGINTYPE.toString(); + assertEquals(null, props.put(typeKey, "OF")); + ProtocolService.set(null, props, sv, LOG); + assertTrue(services.isEmpty()); + + ProtocolService.unset(null, props, sv, LOG); + assertTrue(services.isEmpty()); + } + + @Test + public void testSetUnset() { + ConcurrentMap> serviceMap = + new ConcurrentHashMap<>(); + ConcurrentMap> expected = + new ConcurrentHashMap<>(); + + final String typeKey = GlobalConstants.PROTOCOLPLUGINTYPE.toString(); + final String priKey = GlobalConstants.PROTOCOLPLUGINPRIORITY.toString(); + final String[] protocols = {"OF", "PE", "PK"}; + final int basePri = 0; + final int loop = 5; + + // Should override the service if higher priority is specified. + for (String proto: protocols) { + for (int pri = basePri - loop + 1; pri <= basePri; pri++) { + TestService sv = new TestService(); + Map props = new HashMap<>(); + assertEquals(null, props.put(typeKey, proto)); + assertEquals(null, props.put(priKey, Integer.valueOf(pri))); + ProtocolService.set(serviceMap, props, sv, LOG); + + ProtocolService service = serviceMap.get(proto); + assertNotNull(service); + assertEquals(sv, service.getService()); + assertEquals(pri, service.getPriority()); + + ProtocolService service1 = + new ProtocolService(props, sv); + expected.put(proto, service1); + assertEquals(expected, serviceMap); + + // Unset service request should be ignored if different + // parameters are specified. + TestService another = new TestService(); + ProtocolService.unset(serviceMap, props, another, LOG); + assertEquals(expected, serviceMap); + + props.put(priKey, Integer.valueOf(Integer.MAX_VALUE)); + ProtocolService.unset(serviceMap, props, sv, LOG); + assertEquals(expected, serviceMap); + } + } + + // Should reject the set service request if lower priority is specified. + for (String proto: protocols) { + for (int pri = basePri - loop; pri < basePri; pri++) { + TestService sv = new TestService(); + Map props = new HashMap<>(); + assertEquals(null, props.put(typeKey, proto)); + assertEquals(null, props.put(priKey, Integer.valueOf(pri))); + ProtocolService.set(serviceMap, props, sv, LOG); + assertEquals(expected, serviceMap); + } + } + + // Unset protocol services. + for (String proto: protocols) { + ProtocolService service = expected.remove(proto); + assertNotNull(service); + + ITestService sv = service.getService(); + Map props = new HashMap<>(); + assertEquals(null, props.put(typeKey, proto)); + assertEquals(null, props.put(priKey, Integer.valueOf(basePri))); + ProtocolService.unset(serviceMap, props, sv, LOG); + assertEquals(expected, serviceMap); + + // Should be ignored if the specified service does not exist. + ProtocolService.unset(serviceMap, props, sv, LOG); + assertEquals(expected, serviceMap); + } + + assertTrue(serviceMap.isEmpty()); + } +} + +interface ITestService { +} + +class TestService implements ITestService { +} diff --git a/pom.xml b/pom.xml index b81378e33f..10c05e254f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ opendaylight/forwardingrulesmanager/implementation opendaylight/hosttracker/api opendaylight/hosttracker/implementation + opendaylight/hosttracker/shell opendaylight/hosttracker_new/api opendaylight/hosttracker_new/implementation opendaylight/containermanager/api @@ -135,6 +136,9 @@ opendaylight/distribution/opendaylight-karaf opendaylight/distribution/opendaylight-karaf-resources features + + + opendaylight/archetypes scm:git:ssh://git.opendaylight.org:29418/controller.git