From: Tony Tkacik Date: Tue, 26 Aug 2014 07:24:43 +0000 (+0000) Subject: Merge "BUG-650: remove unneeded sort()" X-Git-Tag: release/helium~207 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=a2a56c27c18eeedff28796034be220ac049d6a26;hp=21b7ff575b3fd9edd30a3367be3e250325754f98 Merge "BUG-650: remove unneeded sort()" --- diff --git a/features/adsal/pom.xml b/features/adsal/pom.xml index 213e500458..0ce976e2ef 100644 --- a/features/adsal/pom.xml +++ b/features/adsal/pom.xml @@ -34,6 +34,59 @@ 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 + diff --git a/features/base/pom.xml b/features/base/pom.xml index 5dabfe5a44..ed8e2a8c20 100644 --- a/features/base/pom.xml +++ b/features/base/pom.xml @@ -23,42 +23,46 @@ 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 diff --git a/features/nsf/pom.xml b/features/nsf/pom.xml index 62b790b0da..5be411caae 100644 --- a/features/nsf/pom.xml +++ b/features/nsf/pom.xml @@ -28,6 +28,227 @@ 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 + diff --git a/features/nsf/src/main/resources/features.xml b/features/nsf/src/main/resources/features.xml index e48bfc1410..8dc51f1644 100644 --- a/features/nsf/src/main/resources/features.xml +++ b/features/nsf/src/main/resources/features.xml @@ -45,10 +45,10 @@ 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} @@ -63,6 +63,7 @@ mvn:org.opendaylight.controller/bundlescanner/${bundlescanner.api.version} mvn:org.opendaylight.controller/bundlescanner.implementation/${bundlescanner.implementation.version} mvn:org.opendaylight.controller/commons.northbound/${northbound.commons.version} + mvn:org.opendaylight.controller/connectionmanager.northbound/${connectionmanager.version} mvn:org.opendaylight.controller/flowprogrammer.northbound/${flowprogrammer.northbound.version} mvn:org.opendaylight.controller/hosttracker.northbound/${hosttracker.northbound.version} mvn:org.opendaylight.controller/networkconfig.bridgedomain.northbound/${networkconfig.bridgedomain.northbound.version} diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml b/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml new file mode 100644 index 0000000000..38c86164e9 --- /dev/null +++ b/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + org.opendaylight.controller + opendaylight-configfile-archetype + 1.1-SNAPSHOT + maven-archetype + + + + + + org.apache.maven.archetype + archetype-packaging + 2.2 + + + + + + + maven-archetype-plugin + 2.2 + + + + + + Configuration files for md-sal + + + scm:git:ssh://git.opendaylight.org:29418/controller.git/md-sal-config + scm:git:ssh://git.opendaylight.org:29418/controller.git/md-sal-config + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL/md-sal-config + + + + + opendaylight-release + http://nexus.opendaylight.org/content/repositories/opendaylight.release/ + + + opendaylight-snapshot + http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + + website + dav:http://nexus.opendaylight.org/content/sites/site/sal-parent + + + diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..d404f99c7a --- /dev/null +++ b/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,16 @@ + + + + + + + + src/main/resources + + **/*.xml + + + + diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/archetype-resources/pom.xml b/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..e217b9abfa --- /dev/null +++ b/opendaylight/archetypes/opendaylight-configfile-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,60 @@ + + + + 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 873ad7a9b7..b9a6f38412 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -1015,6 +1015,11 @@ hosttracker.northbound ${hosttracker.northbound.version} + + org.opendaylight.controller + hosttracker.shell + ${hosttracker.shell.version} + org.opendaylight.controller hosttracker_new @@ -1052,6 +1057,11 @@ logging.bridge ${logging.bridge.version} + + org.opendaylight.controller + dummy-console + ${dummy-console.version} + @@ -1407,6 +1417,11 @@ security ${security.version} + + org.opendaylight.controller + karaf-tomcat-security + ${karaf.security.version} + org.opendaylight.controller @@ -1480,6 +1495,11 @@ topologymanager ${topologymanager.version} + + org.opendaylight.controller + topologymanager.shell + ${topologymanager.shell.version} + org.opendaylight.controller troubleshoot.web diff --git a/opendaylight/md-sal/sal-akka-raft/pom.xml b/opendaylight/md-sal/sal-akka-raft/pom.xml index 3dcc546426..084ef16f57 100644 --- a/opendaylight/md-sal/sal-akka-raft/pom.xml +++ b/opendaylight/md-sal/sal-akka-raft/pom.xml @@ -55,7 +55,18 @@ scala-library - + + commons-io + commons-io + + + + com.typesafe.akka + akka-slf4j_${scala.version} + + + + junit junit @@ -110,8 +121,12 @@ jacoco-maven-plugin - org.opendaylight.controller.* + org/opendaylight/controller/cluster/**/* + + org/opendaylight/controller/cluster/raft/protobuff/**/* + org/opendaylight/controller/cluster/example/**/* + false diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java index ae8b6fe8e3..988789b401 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java @@ -168,8 +168,7 @@ public abstract class RaftActor extends UntypedPersistentActor { } else if (message instanceof FindLeader) { getSender().tell( - new FindLeaderReply( - context.getPeerAddress(currentBehavior.getLeaderId())), + new FindLeaderReply(getLeaderAddress()), getSelf() ); @@ -183,12 +182,6 @@ public abstract class RaftActor extends UntypedPersistentActor { // TODO: Handle failure in saving the snapshot - } else if (message instanceof FindLeader){ - - getSender().tell(new FindLeaderReply( - context.getPeerAddress(currentBehavior.getLeaderId())), - getSelf()); - } else if (message instanceof AddRaftPeer){ // FIXME : Do not add raft peers like this. @@ -269,18 +262,9 @@ public abstract class RaftActor extends UntypedPersistentActor { * @return A reference to the leader if known, null otherwise */ protected ActorSelection getLeader(){ - String leaderId = currentBehavior.getLeaderId(); - if (leaderId == null) { - return null; - } - String peerAddress = context.getPeerAddress(leaderId); - LOG.debug("getLeader leaderId = " + leaderId + " peerAddress = " - + peerAddress); + String leaderAddress = getLeaderAddress(); - if(peerAddress == null){ - return null; - } - return context.actorSelection(peerAddress); + return context.actorSelection(leaderAddress); } /** @@ -424,6 +408,21 @@ public abstract class RaftActor extends UntypedPersistentActor { deleteMessages(sequenceNumber); } + private String getLeaderAddress(){ + if(isLeader()){ + return getSelf().path().toString(); + } + String leaderId = currentBehavior.getLeaderId(); + if (leaderId == null) { + return null; + } + String peerAddress = context.getPeerAddress(leaderId); + LOG.debug("getLeaderAddress leaderId = " + leaderId + " peerAddress = " + + peerAddress); + + return peerAddress; + } + private class ReplicatedLogImpl extends AbstractReplicatedLogImpl { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeader.java index a60aea46e8..98dd0d4653 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeader.java @@ -8,6 +8,8 @@ package org.opendaylight.controller.cluster.raft.client.messages; -public class FindLeader { +import java.io.Serializable; + +public class FindLeader implements Serializable{ } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java index b36ef112b3..64c7350896 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java @@ -8,7 +8,9 @@ package org.opendaylight.controller.cluster.raft.client.messages; -public class FindLeaderReply { +import java.io.Serializable; + +public class FindLeaderReply implements Serializable { private final String leaderActor; public FindLeaderReply(String leaderActor) { diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java index 1971432fb9..ec53815469 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java @@ -10,20 +10,26 @@ package org.opendaylight.controller.cluster.raft; import akka.actor.ActorSystem; import akka.testkit.JavaTestKit; +import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.BeforeClass; +import java.io.File; +import java.io.IOException; + public abstract class AbstractActorTest { private static ActorSystem system; @BeforeClass - public static void setUpClass() { + public static void setUpClass() throws Exception{ + deleteJournal(); System.setProperty("shard.persistent", "false"); system = ActorSystem.create("test"); } @AfterClass - public static void tearDownClass() { + public static void tearDownClass() throws Exception{ + deleteJournal(); JavaTestKit.shutdownActorSystem(system); system = null; } @@ -32,4 +38,12 @@ public abstract class AbstractActorTest { return system; } + protected static void deleteJournal() throws IOException { + File journal = new File("journal"); + + if(journal.exists()) { + FileUtils.deleteDirectory(journal); + } + } + } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java new file mode 100644 index 0000000000..ff0ffeb271 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java @@ -0,0 +1,137 @@ +package org.opendaylight.controller.cluster.raft; + +import akka.actor.ActorRef; +import akka.actor.ActorSystem; +import akka.actor.Props; +import akka.event.Logging; +import akka.japi.Creator; +import akka.testkit.JavaTestKit; +import org.junit.Test; +import org.opendaylight.controller.cluster.raft.client.messages.FindLeader; +import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply; + +import java.util.Collections; +import java.util.Map; + +import static junit.framework.TestCase.assertEquals; + +public class RaftActorTest extends AbstractActorTest { + + + public static class MockRaftActor extends RaftActor { + + public MockRaftActor(String id, + Map peerAddresses) { + super(id, peerAddresses); + } + + public static Props props(final String id, final Map peerAddresses){ + return Props.create(new Creator(){ + + @Override public MockRaftActor create() throws Exception { + return new MockRaftActor(id, peerAddresses); + } + }); + } + + @Override protected void applyState(ActorRef clientActor, + String identifier, + Object data) { + } + + @Override protected Object createSnapshot() { + throw new UnsupportedOperationException("createSnapshot"); + } + + @Override protected void applySnapshot(Object snapshot) { + throw new UnsupportedOperationException("applySnapshot"); + } + + @Override protected void onStateChanged() { + } + + @Override public String persistenceId() { + return this.getId(); + } + + } + + + private static class RaftActorTestKit extends JavaTestKit { + private final ActorRef raftActor; + + public RaftActorTestKit(ActorSystem actorSystem, String actorName) { + super(actorSystem); + + raftActor = this.getSystem() + .actorOf(MockRaftActor.props(actorName, + Collections.EMPTY_MAP), actorName); + + } + + + public boolean waitForStartup(){ + // Wait for a specific log message to show up + return + new JavaTestKit.EventFilter(Logging.Info.class + ) { + protected Boolean run() { + return true; + } + }.from(raftActor.path().toString()) + .message("Switching from state Candidate to Leader") + .occurrences(1).exec(); + + + } + + public void findLeader(final String expectedLeader){ + + + new Within(duration("1 seconds")) { + protected void run() { + + raftActor.tell(new FindLeader(), getRef()); + + String s = new ExpectMsg(duration("1 seconds"), + "findLeader") { + // do not put code outside this method, will run afterwards + protected String match(Object in) { + if (in instanceof FindLeaderReply) { + return ((FindLeaderReply) in).getLeaderActor(); + } else { + throw noMatch(); + } + } + }.get();// this extracts the received message + + assertEquals(expectedLeader, s); + + } + + + }; + } + + public ActorRef getRaftActor() { + return raftActor; + } + + } + + + @Test + public void testConstruction() { + boolean started = new RaftActorTestKit(getSystem(), "testConstruction").waitForStartup(); + assertEquals(true, started); + } + + @Test + public void testFindLeaderWhenLeaderIsSelf(){ + RaftActorTestKit kit = new RaftActorTestKit(getSystem(), "testFindLeader"); + kit.waitForStartup(); + kit.findLeader(kit.getRaftActor().path().toString()); + } + + +} diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf b/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf index dbe7508cc8..2b753004c4 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf @@ -1,6 +1,6 @@ akka { - loglevel = "DEBUG" + loggers = ["akka.testkit.TestEventListener", "akka.event.slf4j.Slf4jLogger"] actor { # enable to test serialization only. @@ -12,6 +12,7 @@ akka { } serialization-bindings { + "org.opendaylight.controller.cluster.raft.client.messages.FindLeader" = java "org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry" = java "com.google.protobuf.Message" = proto "com.google.protobuf.GeneratedMessage" = proto diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java index f584467ee9..f5a6a34841 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java @@ -9,14 +9,13 @@ package org.opendaylight.controller.cluster.datastore.messages; import com.google.common.base.Preconditions; -import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; /** * The FindPrimary message is used to locate the primary of any given shard * */ public class FindPrimary implements SerializableMessage{ - public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.FindPrimary.class; + public static final Class SERIALIZABLE_CLASS = FindPrimary.class; private final String shardName; public FindPrimary(String shardName){ @@ -32,10 +31,10 @@ public class FindPrimary implements SerializableMessage{ @Override public Object toSerializable() { - return ShardManagerMessages.FindPrimary.newBuilder().setShardName(shardName).build(); + return this; } public static FindPrimary fromSerializable(Object message){ - return new FindPrimary(((ShardManagerMessages.FindPrimary)message).getShardName()); + return (FindPrimary) message; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java index 69502837bc..a2f6701524 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java @@ -8,10 +8,9 @@ package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; public class PrimaryFound implements SerializableMessage { - public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryFound.class; + public static final Class SERIALIZABLE_CLASS = PrimaryFound.class; private final String primaryPath; public PrimaryFound(String primaryPath) { @@ -49,10 +48,10 @@ public class PrimaryFound implements SerializableMessage { @Override public Object toSerializable() { - return ShardManagerMessages.PrimaryFound.newBuilder().setPrimaryPath(primaryPath).build(); + return this; } public static PrimaryFound fromSerializable(Object message){ - return new PrimaryFound(((ShardManagerMessages.PrimaryFound)message).getPrimaryPath()); + return (PrimaryFound) message; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java index 057028c469..731a5364db 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryNotFound.java @@ -9,10 +9,9 @@ package org.opendaylight.controller.cluster.datastore.messages; import com.google.common.base.Preconditions; -import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; public class PrimaryNotFound implements SerializableMessage { - public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryNotFound.class; + public static final Class SERIALIZABLE_CLASS = PrimaryNotFound.class; private final String shardName; @@ -42,10 +41,10 @@ public class PrimaryNotFound implements SerializableMessage { @Override public Object toSerializable() { - return ShardManagerMessages.PrimaryNotFound.newBuilder().setShardName(shardName).build(); + return this; } public static PrimaryNotFound fromSerializable(Object message){ - return new PrimaryNotFound(((ShardManagerMessages.PrimaryNotFound)message).getShardName()); + return (PrimaryNotFound) message; } } 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/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronLoadBalancerPoolMemberAware.java b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronLoadBalancerPoolMemberAware.java index 0a1da77604..69a57748dd 100644 --- a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronLoadBalancerPoolMemberAware.java +++ b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronLoadBalancerPoolMemberAware.java @@ -75,5 +75,5 @@ public interface INeutronLoadBalancerPoolMemberAware { * instance of deleted LoadBalancerPool object * @return void */ - public void NeutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember loadBalancerPoolMember); + public void neutronLoadBalancerPoolMemberDeleted(NeutronLoadBalancerPoolMember loadBalancerPoolMember); } 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/action/ActionType.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/ActionType.java index b491c5fcea..8b6d3c4a1c 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/ActionType.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/ActionType.java @@ -1,11 +1,10 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.sal.action; /** @@ -34,8 +33,8 @@ public enum ActionType { SET_NW_SRC("setNwSrc", 0, 0), SET_NW_DST("setNwDst", 0, 0), SET_NW_TOS("setNwTos", 0, 0x3f), - SET_TP_SRC("setTpSrc", 1, 0xffff), - SET_TP_DST("setTpDst", 1, 0xffff), + SET_TP_SRC("setTpSrc", 0, 0xffff), // Set transport source port + SET_TP_DST("setTpDst", 0, 0xffff), // Set transport destination port SET_NEXT_HOP("setNextHop", 0, 0); private String id; 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/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java index 5c09a43fed..3fe9a18b3f 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java @@ -1,12 +1,10 @@ - /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.sal.action; import org.opendaylight.controller.sal.core.ConstructionException; @@ -176,8 +174,11 @@ public class ActionTest { action = new SetTpDst(65535); Assert.assertTrue(action.isValid()); + action = new SetTpSrc(0); + Assert.assertTrue(action.isValid()); + action = new SetTpDst(0); - Assert.assertFalse(action.isValid()); + Assert.assertTrue(action.isValid()); action = new SetTpSrc(-1); Assert.assertFalse(action.isValid()); 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/opendaylight/web/flows/src/main/resources/js/page.js b/opendaylight/web/flows/src/main/resources/js/page.js index 6e7fd25e04..5e638cf9cc 100644 --- a/opendaylight/web/flows/src/main/resources/js/page.js +++ b/opendaylight/web/flows/src/main/resources/js/page.js @@ -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, @@ -1191,7 +1191,7 @@ one.f.flows = { var h3 = "Set Transport Source Port"; var placeholder = "Transport Source Port"; var id = one.f.flows.id.modal.action.modifyTransportSourcePort; - var help = "Range: 1 - 65535"; + var help = "Range: 0 - 65535"; var action = 'SET_TP_SRC'; var name = "Source Port"; var body = function() { @@ -1207,7 +1207,7 @@ one.f.flows = { var h3 = "Set Transport Destination Port"; var placeholder = "Transport Destination Port"; var id = one.f.flows.id.modal.action.modifyTransportDestinationPort; - var help = "Range: 1 - 65535"; + var help = "Range: 0 - 65535"; var action = 'SET_TP_DST'; var name = "Destination Port"; var body = function() { diff --git a/pom.xml b/pom.xml index 22c03ac7ac..10c05e254f 100644 --- a/pom.xml +++ b/pom.xml @@ -136,6 +136,9 @@ opendaylight/distribution/opendaylight-karaf opendaylight/distribution/opendaylight-karaf-resources features + + + opendaylight/archetypes scm:git:ssh://git.opendaylight.org:29418/controller.git