From: Tony Tkacik Date: Mon, 4 May 2015 12:04:58 +0000 (+0000) Subject: Merge "BUG 3057 - notify added event source by topics created before" X-Git-Tag: release/beryllium~617 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=1447e0132075bbd3013aa41b98384a373bd82d1a;hp=08d14bd2821233d6f2eb6f03e143745393f530bc Merge "BUG 3057 - notify added event source by topics created before" --- diff --git a/features/akka/pom.xml b/features/akka/pom.xml index 20f71402c3..743babf589 100644 --- a/features/akka/pom.xml +++ b/features/akka/pom.xml @@ -10,7 +10,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../opendaylight/commons/opendaylight features-akka @@ -20,11 +20,11 @@ features.xml - 1.1.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.2.0-SNAPSHOT + 1.6.0-SNAPSHOT 3.0.3 - 0.7.0-SNAPSHOT - 1.5.0-SNAPSHOT + 0.8.0-SNAPSHOT + 1.6.0-SNAPSHOT 2.16 @@ -42,21 +42,21 @@ org.opendaylight.yangtools features-yangtools - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT features xml org.opendaylight.controller features-mdsal - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT features xml org.opendaylight.openflowplugin features-openflowplugin - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT features xml diff --git a/features/akka/src/main/resources/features.xml b/features/akka/src/main/resources/features.xml index 8a3b4a2e25..cc62e36f07 100644 --- a/features/akka/src/main/resources/features.xml +++ b/features/akka/src/main/resources/features.xml @@ -18,9 +18,9 @@ Necessary TODO: Add repo entries for the repositories of features you refer to in this feature file but do not define here. Examples: - mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features - mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features - mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features + mvn:org.opendaylight.yangtools/features-yangtools/0.8.0-SNAPSHOT/xml/features + mvn:org.opendaylight.controller/features-mdsal/1.3.0-SNAPSHOT/xml/features + mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.2.0-SNAPSHOT/xml/features --> - 1.1.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.2.0-SNAPSHOT + 1.6.0-SNAPSHOT 3.0.3 - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT 2.16 diff --git a/features/mdsal/pom.xml b/features/mdsal/pom.xml index 9222e13ebb..661438ab14 100644 --- a/features/mdsal/pom.xml +++ b/features/mdsal/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT ../../opendaylight/md-sal features-mdsal diff --git a/features/mdsal/src/main/resources/features.xml b/features/mdsal/src/main/resources/features.xml index f8bbfeca49..cd45f09f12 100644 --- a/features/mdsal/src/main/resources/features.xml +++ b/features/mdsal/src/main/resources/features.xml @@ -27,10 +27,8 @@ odl-config-all odl-netconf-all - - odl-yangtools-models - mvn:org.opendaylight.controller/sal-netconf-connector/${project.version} - mvn:org.opendaylight.controller.model/model-inventory/${project.version} + odl-config-netty + mvn:org.opendaylight.controller/netconf-tcp/${netconf.version} mvn:org.opendaylight.controller/netconf-ssh/${netconf.version} odl-mdsal-broker mvn:org.opendaylight.controller/mdsal-netconf-connector/${netconf.version} diff --git a/features/netconf-connector/pom.xml b/features/netconf-connector/pom.xml index b98f839979..b974ce2cee 100644 --- a/features/netconf-connector/pom.xml +++ b/features/netconf-connector/pom.xml @@ -10,7 +10,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT ../../opendaylight/md-sal features-netconf-connector jar @@ -42,21 +42,21 @@ org.opendaylight.yangtools features-yangtools - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT features xml org.opendaylight.controller features-mdsal - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT features xml org.opendaylight.openflowplugin features-openflowplugin - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT features xml @@ -82,13 +82,13 @@ features xml - + mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features @@ -28,7 +28,7 @@ - mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features + - odl-aaa-netconf-plugin + mvn:org.opendaylight.controller/netconf-ssh/${netconf.version} - + odl-netconf-impl + odl-config-netty mvn:org.opendaylight.controller/netconf-tcp/${netconf.version} - + odl-netconf-connector diff --git a/features/netconf/pom.xml b/features/netconf/pom.xml index 8af3706706..373f0095ce 100644 --- a/features/netconf/pom.xml +++ b/features/netconf/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../../opendaylight/netconf features-netconf diff --git a/features/netconf/src/main/resources/features.xml b/features/netconf/src/main/resources/features.xml index 80b2e36211..4c3136f0a2 100644 --- a/features/netconf/src/main/resources/features.xml +++ b/features/netconf/src/main/resources/features.xml @@ -27,7 +27,7 @@ mvn:org.opendaylight.controller/ietf-netconf-monitoring-extension/${project.version} mvn:org.opendaylight.yangtools.model/ietf-inet-types/${ietf-inet-types.version} mvn:org.opendaylight.yangtools.model/ietf-yang-types/${ietf-yang-types.version} - mvn:org.opendaylight.yangtools.model/ietf-yang-types-20130715/2013.07.15.7-SNAPSHOT + mvn:org.opendaylight.yangtools.model/ietf-yang-types-20130715/2013.07.15.8-SNAPSHOT odl-netconf-api diff --git a/features/pom.xml b/features/pom.xml index 5aa9edc669..99b54d0619 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../opendaylight/commons/opendaylight features-controller diff --git a/features/protocol-framework/pom.xml b/features/protocol-framework/pom.xml index f663c1ce3e..7da19c58b5 100644 --- a/features/protocol-framework/pom.xml +++ b/features/protocol-framework/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../opendaylight/commons/opendaylight features-protocol-framework diff --git a/features/restconf/pom.xml b/features/restconf/pom.xml index 347a19a75a..05fea9d259 100644 --- a/features/restconf/pom.xml +++ b/features/restconf/pom.xml @@ -10,7 +10,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT ../../opendaylight/md-sal jar @@ -43,21 +43,21 @@ org.opendaylight.yangtools features-yangtools - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT features xml org.opendaylight.controller features-mdsal - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT features xml org.opendaylight.openflowplugin features-openflowplugin - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT features xml @@ -109,13 +109,13 @@ features xml - + org.opendaylight.controller diff --git a/features/restconf/src/main/resources/features.xml b/features/restconf/src/main/resources/features.xml index 8060206b53..87cab842d9 100644 --- a/features/restconf/src/main/resources/features.xml +++ b/features/restconf/src/main/resources/features.xml @@ -18,13 +18,13 @@ Necessary TODO: Add repo entries for the repositories of features you refer to in this feature file but do not define here. Examples: - mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features - mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features - mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features + mvn:org.opendaylight.yangtools/features-yangtools/0.8.0-SNAPSHOT/xml/features + mvn:org.opendaylight.controller/features-mdsal/1.3.0-SNAPSHOT/xml/features + mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.2.0-SNAPSHOT/xml/features --> mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features - mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features + - odl-aaa-authn + odl-restconf-noauth diff --git a/itests/base-features-it/pom.xml b/itests/base-features-it/pom.xml index dfb622eb7c..a948ec78dd 100644 --- a/itests/base-features-it/pom.xml +++ b/itests/base-features-it/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.controller itests-controller - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../pom.xml base-features-it diff --git a/itests/pom.xml b/itests/pom.xml index 9021e634ea..06ff0e5799 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../opendaylight/commons/opendaylight itests-controller diff --git a/karaf/karaf-branding/pom.xml b/karaf/karaf-branding/pom.xml index 7b2bd864f2..759fd618df 100644 --- a/karaf/karaf-branding/pom.xml +++ b/karaf/karaf-branding/pom.xml @@ -5,11 +5,11 @@ org.opendaylight.controller releasepom - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT ../.. karaf.branding - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT bundle OpenDaylight :: Karaf :: Branding diff --git a/karaf/karaf-parent/pom.xml b/karaf/karaf-parent/pom.xml index 85e0c265b1..f613a9af45 100644 --- a/karaf/karaf-parent/pom.xml +++ b/karaf/karaf-parent/pom.xml @@ -11,7 +11,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent odlparent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT 4.0.0 @@ -21,8 +21,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html pom - 1.1.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.2.0-SNAPSHOT + 1.6.0-SNAPSHOT standard diff --git a/opendaylight/adsal/clustering/services/pom.xml b/opendaylight/adsal/clustering/services/pom.xml index 550f580ebd..ebe8436da8 100644 --- a/opendaylight/adsal/clustering/services/pom.xml +++ b/opendaylight/adsal/clustering/services/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight clustering.services - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/clustering/services_implementation/pom.xml b/opendaylight/adsal/clustering/services_implementation/pom.xml index 36cd35d891..d3b0578084 100644 --- a/opendaylight/adsal/clustering/services_implementation/pom.xml +++ b/opendaylight/adsal/clustering/services_implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight clustering.services-implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/clustering/stub/pom.xml b/opendaylight/adsal/clustering/stub/pom.xml index 7ab30110f3..b2e845f418 100644 --- a/opendaylight/adsal/clustering/stub/pom.xml +++ b/opendaylight/adsal/clustering/stub/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight clustering.stub - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/clustering/test/pom.xml b/opendaylight/adsal/clustering/test/pom.xml index 93407ea3d7..6e2c6dc0f9 100644 --- a/opendaylight/adsal/clustering/test/pom.xml +++ b/opendaylight/adsal/clustering/test/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight clustering.test - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/commons/httpclient/pom.xml b/opendaylight/adsal/commons/httpclient/pom.xml index 93a537c00c..16f05e0f38 100644 --- a/opendaylight/adsal/commons/httpclient/pom.xml +++ b/opendaylight/adsal/commons/httpclient/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight commons.httpclient - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT bundle @@ -70,7 +70,7 @@ org.opendaylight.controller checkstyle - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/opendaylight/adsal/commons/integrationtest/pom.xml b/opendaylight/adsal/commons/integrationtest/pom.xml index e4d795d563..fbb1d0ea1d 100644 --- a/opendaylight/adsal/commons/integrationtest/pom.xml +++ b/opendaylight/adsal/commons/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT pom @@ -88,7 +88,7 @@ org.opendaylight.controller checkstyle - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/opendaylight/adsal/configuration/api/pom.xml b/opendaylight/adsal/configuration/api/pom.xml index dec934bf6e..00591e0fdd 100644 --- a/opendaylight/adsal/configuration/api/pom.xml +++ b/opendaylight/adsal/configuration/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight configuration - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/configuration/implementation/pom.xml b/opendaylight/adsal/configuration/implementation/pom.xml index a35d2e9406..8ea8997004 100644 --- a/opendaylight/adsal/configuration/implementation/pom.xml +++ b/opendaylight/adsal/configuration/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight configuration.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/configuration/integrationtest/pom.xml b/opendaylight/adsal/configuration/integrationtest/pom.xml index 238ff12249..5ae64e75d7 100644 --- a/opendaylight/adsal/configuration/integrationtest/pom.xml +++ b/opendaylight/adsal/configuration/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest configuration.integrationtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT ch.qos.logback diff --git a/opendaylight/adsal/connectionmanager/api/pom.xml b/opendaylight/adsal/connectionmanager/api/pom.xml index aee485419c..21f4df1f9e 100644 --- a/opendaylight/adsal/connectionmanager/api/pom.xml +++ b/opendaylight/adsal/connectionmanager/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight connectionmanager - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/connectionmanager/implementation/pom.xml b/opendaylight/adsal/connectionmanager/implementation/pom.xml index b8293609a2..0ae29a7a2d 100644 --- a/opendaylight/adsal/connectionmanager/implementation/pom.xml +++ b/opendaylight/adsal/connectionmanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight connectionmanager.implementation - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/containermanager/api/pom.xml b/opendaylight/adsal/containermanager/api/pom.xml index 31b209410d..20687edb60 100644 --- a/opendaylight/adsal/containermanager/api/pom.xml +++ b/opendaylight/adsal/containermanager/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight containermanager - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/containermanager/implementation/pom.xml b/opendaylight/adsal/containermanager/implementation/pom.xml index b096ba6c01..288977973f 100644 --- a/opendaylight/adsal/containermanager/implementation/pom.xml +++ b/opendaylight/adsal/containermanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight containermanager.implementation - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/containermanager/it.implementation/pom.xml b/opendaylight/adsal/containermanager/it.implementation/pom.xml index e5ad7a7508..241d9fbb87 100644 --- a/opendaylight/adsal/containermanager/it.implementation/pom.xml +++ b/opendaylight/adsal/containermanager/it.implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight containermanager.it.implementation - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/containermanager/shell/pom.xml b/opendaylight/adsal/containermanager/shell/pom.xml index 065df2c829..aa3c457694 100644 --- a/opendaylight/adsal/containermanager/shell/pom.xml +++ b/opendaylight/adsal/containermanager/shell/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight containermanager.shell diff --git a/opendaylight/adsal/dummy-console/pom.xml b/opendaylight/adsal/dummy-console/pom.xml index c8a1a22ae7..76aa58f058 100644 --- a/opendaylight/adsal/dummy-console/pom.xml +++ b/opendaylight/adsal/dummy-console/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../commons/opendaylight dummy-console - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT bundle Dummy Console Interfaces for Equinox-specific CLI diff --git a/opendaylight/adsal/features/adsal/pom.xml b/opendaylight/adsal/features/adsal/pom.xml index 3bc35caa34..9ae56739b3 100644 --- a/opendaylight/adsal/features/adsal/pom.xml +++ b/opendaylight/adsal/features/adsal/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../opendaylight/commons/opendaylight features-adsal @@ -31,7 +31,7 @@ org.opendaylight.controller opendaylight-karaf-empty - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT zip diff --git a/opendaylight/adsal/features/base/pom.xml b/opendaylight/adsal/features/base/pom.xml index 86c9450b92..3042b6abe3 100644 --- a/opendaylight/adsal/features/base/pom.xml +++ b/opendaylight/adsal/features/base/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../opendaylight/commons/opendaylight features-base @@ -448,7 +448,7 @@ org.opendaylight.controller opendaylight-karaf-empty - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT zip diff --git a/opendaylight/adsal/features/base/src/main/resources/features.xml b/opendaylight/adsal/features/base/src/main/resources/features.xml index d6802acd0e..182c047595 100644 --- a/opendaylight/adsal/features/base/src/main/resources/features.xml +++ b/opendaylight/adsal/features/base/src/main/resources/features.xml @@ -16,8 +16,8 @@ odl-base-jackson odl-base-spring-security - - mvn:org.opendaylight.controller/dummy-console/1.2.0-SNAPSHOT + + mvn:org.opendaylight.controller/dummy-console/1.3.0-SNAPSHOT mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version} diff --git a/opendaylight/adsal/features/controller/pom.xml b/opendaylight/adsal/features/controller/pom.xml index 9e41561a78..c92e0bc69e 100644 --- a/opendaylight/adsal/features/controller/pom.xml +++ b/opendaylight/adsal/features/controller/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../opendaylight/commons/opendaylight controller-features diff --git a/opendaylight/adsal/features/extras/pom.xml b/opendaylight/adsal/features/extras/pom.xml index b86b0e28c3..f8e04d1e1a 100644 --- a/opendaylight/adsal/features/extras/pom.xml +++ b/opendaylight/adsal/features/extras/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../opendaylight/commons/opendaylight extras-features diff --git a/opendaylight/adsal/features/nsf/pom.xml b/opendaylight/adsal/features/nsf/pom.xml index 1c18b60120..150196f4fc 100644 --- a/opendaylight/adsal/features/nsf/pom.xml +++ b/opendaylight/adsal/features/nsf/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../opendaylight/commons/opendaylight features-nsf @@ -25,7 +25,7 @@ org.opendaylight.controller opendaylight-karaf-empty - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT zip diff --git a/opendaylight/adsal/forwarding/staticrouting/pom.xml b/opendaylight/adsal/forwarding/staticrouting/pom.xml index 526c384750..d14b31235a 100644 --- a/opendaylight/adsal/forwarding/staticrouting/pom.xml +++ b/opendaylight/adsal/forwarding/staticrouting/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight forwarding.staticrouting - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/forwardingrulesmanager/api/pom.xml b/opendaylight/adsal/forwardingrulesmanager/api/pom.xml index fc3549a597..b9a46f52a0 100644 --- a/opendaylight/adsal/forwardingrulesmanager/api/pom.xml +++ b/opendaylight/adsal/forwardingrulesmanager/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight forwardingrulesmanager - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/forwardingrulesmanager/implementation/pom.xml b/opendaylight/adsal/forwardingrulesmanager/implementation/pom.xml index 80a275c03c..d51b98bfe7 100644 --- a/opendaylight/adsal/forwardingrulesmanager/implementation/pom.xml +++ b/opendaylight/adsal/forwardingrulesmanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight forwardingrulesmanager.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/forwardingrulesmanager/integrationtest/pom.xml b/opendaylight/adsal/forwardingrulesmanager/integrationtest/pom.xml index 0f9b3caea9..361506ac27 100644 --- a/opendaylight/adsal/forwardingrulesmanager/integrationtest/pom.xml +++ b/opendaylight/adsal/forwardingrulesmanager/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest forwardingrulesmanager.integrationtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT ../../implementation/target/jacoco-it.exec diff --git a/opendaylight/adsal/hosttracker/api/pom.xml b/opendaylight/adsal/hosttracker/api/pom.xml index 6bc28f03c3..8e5a18df85 100644 --- a/opendaylight/adsal/hosttracker/api/pom.xml +++ b/opendaylight/adsal/hosttracker/api/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight hosttracker - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/hosttracker/implementation/pom.xml b/opendaylight/adsal/hosttracker/implementation/pom.xml index 64254e8b92..50bb26783a 100644 --- a/opendaylight/adsal/hosttracker/implementation/pom.xml +++ b/opendaylight/adsal/hosttracker/implementation/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight hosttracker.implementation - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/hosttracker/integrationtest/pom.xml b/opendaylight/adsal/hosttracker/integrationtest/pom.xml index 63610cc3e3..a6a39e8fe7 100644 --- a/opendaylight/adsal/hosttracker/integrationtest/pom.xml +++ b/opendaylight/adsal/hosttracker/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest hosttracker.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../implementaiton/target/jacoco-it.exec diff --git a/opendaylight/adsal/hosttracker/shell/pom.xml b/opendaylight/adsal/hosttracker/shell/pom.xml index f336d654ac..2d5039cc10 100644 --- a/opendaylight/adsal/hosttracker/shell/pom.xml +++ b/opendaylight/adsal/hosttracker/shell/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight hosttracker.shell diff --git a/opendaylight/adsal/hosttracker_new/api/pom.xml b/opendaylight/adsal/hosttracker_new/api/pom.xml index cdb3fd95b6..8bb1612300 100644 --- a/opendaylight/adsal/hosttracker_new/api/pom.xml +++ b/opendaylight/adsal/hosttracker_new/api/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight hosttracker_new - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/hosttracker_new/implementation/pom.xml b/opendaylight/adsal/hosttracker_new/implementation/pom.xml index 268465eed3..1b03fc4902 100644 --- a/opendaylight/adsal/hosttracker_new/implementation/pom.xml +++ b/opendaylight/adsal/hosttracker_new/implementation/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight hosttracker_new.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/karaf-tomcat-security/pom.xml b/opendaylight/adsal/karaf-tomcat-security/pom.xml index d2dc040bba..d40b7f5f7f 100644 --- a/opendaylight/adsal/karaf-tomcat-security/pom.xml +++ b/opendaylight/adsal/karaf-tomcat-security/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../commons/opendaylight karaf-tomcat-security - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/logging/bridge/pom.xml b/opendaylight/adsal/logging/bridge/pom.xml index 5ebbe4564b..c9caabec6a 100644 --- a/opendaylight/adsal/logging/bridge/pom.xml +++ b/opendaylight/adsal/logging/bridge/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight logging.bridge - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/archetype-app-northbound/pom.xml b/opendaylight/adsal/northbound/archetype-app-northbound/pom.xml index 67c111f94d..cc49fc9ca4 100644 --- a/opendaylight/adsal/northbound/archetype-app-northbound/pom.xml +++ b/opendaylight/adsal/northbound/archetype-app-northbound/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller app-northbound - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT maven-archetype app-northbound diff --git a/opendaylight/adsal/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml b/opendaylight/adsal/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml index 73bdf0921b..521584605a 100644 --- a/opendaylight/adsal/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml +++ b/opendaylight/adsal/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight diff --git a/opendaylight/adsal/northbound/bundlescanner/api/pom.xml b/opendaylight/adsal/northbound/bundlescanner/api/pom.xml index d94272b342..c0acffddbe 100644 --- a/opendaylight/adsal/northbound/bundlescanner/api/pom.xml +++ b/opendaylight/adsal/northbound/bundlescanner/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../commons/opendaylight bundlescanner - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/bundlescanner/implementation/pom.xml b/opendaylight/adsal/northbound/bundlescanner/implementation/pom.xml index d4d57a1be9..dbf2f9e742 100644 --- a/opendaylight/adsal/northbound/bundlescanner/implementation/pom.xml +++ b/opendaylight/adsal/northbound/bundlescanner/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../commons/opendaylight bundlescanner.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/commons/pom.xml b/opendaylight/adsal/northbound/commons/pom.xml index 8290bcdf38..6dfcff24e1 100644 --- a/opendaylight/adsal/northbound/commons/pom.xml +++ b/opendaylight/adsal/northbound/commons/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight commons.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/connectionmanager/pom.xml b/opendaylight/adsal/northbound/connectionmanager/pom.xml index 7cc12484f2..e1789bde4d 100644 --- a/opendaylight/adsal/northbound/connectionmanager/pom.xml +++ b/opendaylight/adsal/northbound/connectionmanager/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent connectionmanager.northbound - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/containermanager/pom.xml b/opendaylight/adsal/northbound/containermanager/pom.xml index 1bc170a679..4c3cea1f57 100644 --- a/opendaylight/adsal/northbound/containermanager/pom.xml +++ b/opendaylight/adsal/northbound/containermanager/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/enunciate-parent containermanager.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/controllermanager/pom.xml b/opendaylight/adsal/northbound/controllermanager/pom.xml index 20cff42b82..20c0886dc3 100644 --- a/opendaylight/adsal/northbound/controllermanager/pom.xml +++ b/opendaylight/adsal/northbound/controllermanager/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent controllermanager.northbound - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/flowprogrammer/pom.xml b/opendaylight/adsal/northbound/flowprogrammer/pom.xml index 3c2aed1310..e97816f4ca 100644 --- a/opendaylight/adsal/northbound/flowprogrammer/pom.xml +++ b/opendaylight/adsal/northbound/flowprogrammer/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent flowprogrammer.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/hosttracker/pom.xml b/opendaylight/adsal/northbound/hosttracker/pom.xml index 4dea525e0b..9acd6649fb 100644 --- a/opendaylight/adsal/northbound/hosttracker/pom.xml +++ b/opendaylight/adsal/northbound/hosttracker/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent hosttracker.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/httpservice-bridge/pom.xml b/opendaylight/adsal/northbound/httpservice-bridge/pom.xml index 12ee95c983..edd6964366 100644 --- a/opendaylight/adsal/northbound/httpservice-bridge/pom.xml +++ b/opendaylight/adsal/northbound/httpservice-bridge/pom.xml @@ -5,12 +5,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight httpservice-bridge - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle HttpService bridge web application diff --git a/opendaylight/adsal/northbound/integrationtest/pom.xml b/opendaylight/adsal/northbound/integrationtest/pom.xml index df0d1139af..59eec0eba5 100644 --- a/opendaylight/adsal/northbound/integrationtest/pom.xml +++ b/opendaylight/adsal/northbound/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest northbound.integrationtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT ch.qos.logback diff --git a/opendaylight/adsal/northbound/java-client/pom.xml b/opendaylight/adsal/northbound/java-client/pom.xml index bf6a55afbb..46f8e9006a 100644 --- a/opendaylight/adsal/northbound/java-client/pom.xml +++ b/opendaylight/adsal/northbound/java-client/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/enunciate-parent northbound.client - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT pom diff --git a/opendaylight/adsal/northbound/jolokia/pom.xml b/opendaylight/adsal/northbound/jolokia/pom.xml index b078e486a8..158003a403 100644 --- a/opendaylight/adsal/northbound/jolokia/pom.xml +++ b/opendaylight/adsal/northbound/jolokia/pom.xml @@ -5,12 +5,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight jolokia-bridge - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle Jolokia bridge web application diff --git a/opendaylight/adsal/northbound/networkconfiguration/bridgedomain/pom.xml b/opendaylight/adsal/northbound/networkconfiguration/bridgedomain/pom.xml index 659bfe9030..df2ba4e8ce 100644 --- a/opendaylight/adsal/northbound/networkconfiguration/bridgedomain/pom.xml +++ b/opendaylight/adsal/northbound/networkconfiguration/bridgedomain/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../adsal-enunciate-parent networkconfig.bridgedomain.northbound - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/staticrouting/pom.xml b/opendaylight/adsal/northbound/staticrouting/pom.xml index be84c61814..c65f0369ba 100644 --- a/opendaylight/adsal/northbound/staticrouting/pom.xml +++ b/opendaylight/adsal/northbound/staticrouting/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent forwarding.staticrouting.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/statistics/pom.xml b/opendaylight/adsal/northbound/statistics/pom.xml index 9e98a75c44..8b54a9847c 100644 --- a/opendaylight/adsal/northbound/statistics/pom.xml +++ b/opendaylight/adsal/northbound/statistics/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent statistics.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/subnets/pom.xml b/opendaylight/adsal/northbound/subnets/pom.xml index 7a96bdc1ea..5c3228b51e 100644 --- a/opendaylight/adsal/northbound/subnets/pom.xml +++ b/opendaylight/adsal/northbound/subnets/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent subnets.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/swagger-ui/pom.xml b/opendaylight/adsal/northbound/swagger-ui/pom.xml index 8c1c8a1bdd..e25a28c0f0 100644 --- a/opendaylight/adsal/northbound/swagger-ui/pom.xml +++ b/opendaylight/adsal/northbound/swagger-ui/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight swagger-ui - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/switchmanager/pom.xml b/opendaylight/adsal/northbound/switchmanager/pom.xml index c3c380444c..4710fea1f5 100644 --- a/opendaylight/adsal/northbound/switchmanager/pom.xml +++ b/opendaylight/adsal/northbound/switchmanager/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent switchmanager.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/topology/pom.xml b/opendaylight/adsal/northbound/topology/pom.xml index 62399c5f04..21f73d53fb 100644 --- a/opendaylight/adsal/northbound/topology/pom.xml +++ b/opendaylight/adsal/northbound/topology/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../adsal-enunciate-parent topology.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northbound/usermanager/pom.xml b/opendaylight/adsal/northbound/usermanager/pom.xml index b08995f560..b13b746148 100644 --- a/opendaylight/adsal/northbound/usermanager/pom.xml +++ b/opendaylight/adsal/northbound/usermanager/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/enunciate-parent usermanager.northbound - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/northboundtest/unit_test_suite/pom.xml b/opendaylight/adsal/northboundtest/unit_test_suite/pom.xml index 9f33a4db5d..3047bdd072 100644 --- a/opendaylight/adsal/northboundtest/unit_test_suite/pom.xml +++ b/opendaylight/adsal/northboundtest/unit_test_suite/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../opendaylight/commons/opendaylight @@ -16,7 +16,7 @@ org.opendaylight.controller northboundtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/pom.xml b/opendaylight/adsal/pom.xml index 0a0f66a607..91f4ddd36c 100644 --- a/opendaylight/adsal/pom.xml +++ b/opendaylight/adsal/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller commons.parent - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT ../commons/parent diff --git a/opendaylight/adsal/protocol_plugins/openflow/pom.xml b/opendaylight/adsal/protocol_plugins/openflow/pom.xml index 7cb7602d4f..91cf49a873 100644 --- a/opendaylight/adsal/protocol_plugins/openflow/pom.xml +++ b/opendaylight/adsal/protocol_plugins/openflow/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight protocol_plugins.openflow - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/protocol_plugins/stub/pom.xml b/opendaylight/adsal/protocol_plugins/stub/pom.xml index 1fb84a51ed..801368ad6d 100644 --- a/opendaylight/adsal/protocol_plugins/stub/pom.xml +++ b/opendaylight/adsal/protocol_plugins/stub/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight protocol_plugins.stub - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/routing/dijkstra_implementation/pom.xml b/opendaylight/adsal/routing/dijkstra_implementation/pom.xml index 7f429ff967..8df6db5bbf 100644 --- a/opendaylight/adsal/routing/dijkstra_implementation/pom.xml +++ b/opendaylight/adsal/routing/dijkstra_implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight routing.dijkstra_implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/sal/api/pom.xml b/opendaylight/adsal/sal/api/pom.xml index d5d6256bc9..2a618535b3 100644 --- a/opendaylight/adsal/sal/api/pom.xml +++ b/opendaylight/adsal/sal/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight sal - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/sal/connection/api/pom.xml b/opendaylight/adsal/sal/connection/api/pom.xml index fe07526960..f9f52584c8 100644 --- a/opendaylight/adsal/sal/connection/api/pom.xml +++ b/opendaylight/adsal/sal/connection/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../commons/opendaylight sal.connection - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/sal/connection/implementation/pom.xml b/opendaylight/adsal/sal/connection/implementation/pom.xml index b3c99daee3..b09a51733b 100644 --- a/opendaylight/adsal/sal/connection/implementation/pom.xml +++ b/opendaylight/adsal/sal/connection/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../commons/opendaylight sal.connection.implementation - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/sal/implementation/pom.xml b/opendaylight/adsal/sal/implementation/pom.xml index bce6e3b547..61c6acfc60 100644 --- a/opendaylight/adsal/sal/implementation/pom.xml +++ b/opendaylight/adsal/sal/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight sal.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/sal/networkconfiguration/api/pom.xml b/opendaylight/adsal/sal/networkconfiguration/api/pom.xml index bbeb2969d6..36706f02f6 100644 --- a/opendaylight/adsal/sal/networkconfiguration/api/pom.xml +++ b/opendaylight/adsal/sal/networkconfiguration/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../commons/opendaylight sal.networkconfiguration - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/sal/networkconfiguration/implementation/pom.xml b/opendaylight/adsal/sal/networkconfiguration/implementation/pom.xml index df8c6d2169..da2bc97e0c 100644 --- a/opendaylight/adsal/sal/networkconfiguration/implementation/pom.xml +++ b/opendaylight/adsal/sal/networkconfiguration/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../../commons/opendaylight sal.networkconfiguration.implementation - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/samples/clustersession/pom.xml b/opendaylight/adsal/samples/clustersession/pom.xml index 2a5e07af84..977a324569 100644 --- a/opendaylight/adsal/samples/clustersession/pom.xml +++ b/opendaylight/adsal/samples/clustersession/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight org.opendaylight.controller clustersession - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT bundle @@ -43,7 +43,7 @@ org.opendaylight.controller clustering.services - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT org.slf4j diff --git a/opendaylight/adsal/samples/loadbalancer/pom.xml b/opendaylight/adsal/samples/loadbalancer/pom.xml index e1b480771b..d8d72a2da8 100644 --- a/opendaylight/adsal/samples/loadbalancer/pom.xml +++ b/opendaylight/adsal/samples/loadbalancer/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight samples.loadbalancer - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/samples/northbound/loadbalancer/pom.xml b/opendaylight/adsal/samples/northbound/loadbalancer/pom.xml index b5ca85ee7d..5c4322f856 100644 --- a/opendaylight/adsal/samples/northbound/loadbalancer/pom.xml +++ b/opendaylight/adsal/samples/northbound/loadbalancer/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller adsal-enunciate-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../adsal-enunciate-parent samples.loadbalancer.northbound - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/samples/simpleforwarding/pom.xml b/opendaylight/adsal/samples/simpleforwarding/pom.xml index 4d7af2b8fd..a90fd6947f 100644 --- a/opendaylight/adsal/samples/simpleforwarding/pom.xml +++ b/opendaylight/adsal/samples/simpleforwarding/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight samples.simpleforwarding - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/security/pom.xml b/opendaylight/adsal/security/pom.xml index 436fda24da..4467aafa17 100644 --- a/opendaylight/adsal/security/pom.xml +++ b/opendaylight/adsal/security/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../commons/opendaylight security - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/statisticsmanager/api/pom.xml b/opendaylight/adsal/statisticsmanager/api/pom.xml index 00e23e0f5a..a7c59df22f 100644 --- a/opendaylight/adsal/statisticsmanager/api/pom.xml +++ b/opendaylight/adsal/statisticsmanager/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight statisticsmanager - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/statisticsmanager/implementation/pom.xml b/opendaylight/adsal/statisticsmanager/implementation/pom.xml index aa009fbf23..f4334f3878 100644 --- a/opendaylight/adsal/statisticsmanager/implementation/pom.xml +++ b/opendaylight/adsal/statisticsmanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight statisticsmanager.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/statisticsmanager/integrationtest/pom.xml b/opendaylight/adsal/statisticsmanager/integrationtest/pom.xml index 857921f14b..00670cdf25 100644 --- a/opendaylight/adsal/statisticsmanager/integrationtest/pom.xml +++ b/opendaylight/adsal/statisticsmanager/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest statisticsmanager.integrationtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT ../../implementation/target/jacoco-it.exec diff --git a/opendaylight/adsal/switchmanager/api/pom.xml b/opendaylight/adsal/switchmanager/api/pom.xml index 3c23e29131..a0824ce86f 100644 --- a/opendaylight/adsal/switchmanager/api/pom.xml +++ b/opendaylight/adsal/switchmanager/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight switchmanager - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/switchmanager/implementation/pom.xml b/opendaylight/adsal/switchmanager/implementation/pom.xml index 911d5dd71f..4aa92e6216 100644 --- a/opendaylight/adsal/switchmanager/implementation/pom.xml +++ b/opendaylight/adsal/switchmanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight switchmanager.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/switchmanager/integrationtest/pom.xml b/opendaylight/adsal/switchmanager/integrationtest/pom.xml index 158cd2ca82..bfaf52c8a8 100644 --- a/opendaylight/adsal/switchmanager/integrationtest/pom.xml +++ b/opendaylight/adsal/switchmanager/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest switchmanager.integrationtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT ../../implementation/target/jacoco-it.exec diff --git a/opendaylight/adsal/topologymanager/implementation/pom.xml b/opendaylight/adsal/topologymanager/implementation/pom.xml index c7a6444e1e..9a056df439 100644 --- a/opendaylight/adsal/topologymanager/implementation/pom.xml +++ b/opendaylight/adsal/topologymanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight topologymanager - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java b/opendaylight/adsal/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java index a361285db5..2c5727070c 100644 --- a/opendaylight/adsal/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java +++ b/opendaylight/adsal/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java @@ -8,8 +8,18 @@ package org.opendaylight.controller.topologymanager.internal; -import org.junit.Assert; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentMap; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.sal.core.Bandwidth; @@ -40,17 +50,6 @@ import org.opendaylight.controller.switchmanager.Switch; import org.opendaylight.controller.switchmanager.SwitchConfig; import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; - public class TopologyManagerImplTest { private TopologyManagerImpl topoManagerImpl; @@ -783,15 +782,26 @@ public class TopologyManagerImplTest { } Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000)); - // Give TopologyManger time to update its edges DB. - Thread.sleep(1000); - Assert.assertEquals(1, topoManagerImpl.getEdges().size()); + verifyEdgesSize(1); Assert.assertNotNull(topoManagerImpl.getEdges().get(edge)); } + private void verifyEdgesSize(int expSize) throws InterruptedException { + int timeout = 5000; + for(int i = 0; i < timeout / 50; i++) { + if(topoManagerImpl.getEdges().size() == expSize) { + return; + } + + Thread.sleep(50); + } + + Assert.fail(String.format("Expected edges size %d. Actual was %d", + topoManagerImpl.getEdges().size(), expSize)); + } + @Test - public void testNotifyNodeConnector() throws ConstructionException, - InterruptedException { + public void testNotifyNodeConnector() throws Exception { TestSwitchManager swMgr = new TestSwitchManager(); topoManagerImpl.setSwitchManager(swMgr); topoManagerImpl.nonClusterObjectCreate(); @@ -803,14 +813,14 @@ public class TopologyManagerImplTest { Map propMap = new HashMap<>(); swMgr.addNodeConnectors(nc1); topoManagerImpl.notifyNodeConnector(nc1, UpdateType.ADDED, propMap); - Assert.assertEquals(0, topoManagerImpl.getEdges().size()); + verifyEdgesSize(0); topoManagerImpl.notifyNodeConnector(nc1, UpdateType.CHANGED, propMap); - Assert.assertEquals(0, topoManagerImpl.getEdges().size()); + verifyEdgesSize(0); swMgr.clear(); topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap); - Assert.assertEquals(0, topoManagerImpl.getEdges().size()); + verifyEdgesSize(0); // Test NodeConnector notification in the case that there is a related // edge update just before the notification. @@ -830,9 +840,7 @@ public class TopologyManagerImplTest { swMgr.addNodeConnectors(nc2); topoManagerImpl.notifyNodeConnector(nc2, UpdateType.CHANGED, propMap); Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000)); - // Give TopologyManger time to update its edges DB. - Thread.sleep(1000); - Assert.assertEquals(2, topoManagerImpl.getEdges().size()); + verifyEdgesSize(2); teu1 = new TopoEdgeUpdate(edge1, props, UpdateType.REMOVED); teu2 = new TopoEdgeUpdate(edge2, props, UpdateType.REMOVED); @@ -841,9 +849,7 @@ public class TopologyManagerImplTest { topoedgeupdateList.add(teu2); topoManagerImpl.edgeUpdate(topoedgeupdateList); Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000)); - // Give TopologyManger time to update its edges DB. - Thread.sleep(1000); - Assert.assertEquals(0, topoManagerImpl.getEdges().size()); + verifyEdgesSize(0); topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap); topoManagerImpl.notifyNodeConnector(nc2, UpdateType.REMOVED, propMap); @@ -870,14 +876,10 @@ public class TopologyManagerImplTest { swMgr.addNodeConnectors(nc2); topoManagerImpl.notifyNodeConnector(nc2, UpdateType.CHANGED, propMap); Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000)); - // Give TopologyManger time to update its edges DB. - Thread.sleep(1000); - Assert.assertEquals(0, topoManagerImpl.getEdges().size()); + verifyEdgesSize(0); topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap); topoManagerImpl.notifyNodeConnector(nc2, UpdateType.REMOVED, propMap); Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000)); - // Give TopologyManger time to update its edges DB. - Thread.sleep(1000); - Assert.assertEquals(0, topoManagerImpl.getEdges().size()); + verifyEdgesSize(0); } } diff --git a/opendaylight/adsal/topologymanager/integrationtest/pom.xml b/opendaylight/adsal/topologymanager/integrationtest/pom.xml index 028e775ee0..20fdc0b1ae 100644 --- a/opendaylight/adsal/topologymanager/integrationtest/pom.xml +++ b/opendaylight/adsal/topologymanager/integrationtest/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.integrationtest - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT ../../commons/integrationtest topologymanager.integrationtest - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT ../../implementaiton/target/jacoco-it.exec diff --git a/opendaylight/adsal/topologymanager/shell/pom.xml b/opendaylight/adsal/topologymanager/shell/pom.xml index a5b21f6224..bc9d63078c 100644 --- a/opendaylight/adsal/topologymanager/shell/pom.xml +++ b/opendaylight/adsal/topologymanager/shell/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight topologymanager.shell diff --git a/opendaylight/adsal/usermanager/api/pom.xml b/opendaylight/adsal/usermanager/api/pom.xml index 76f293b197..a1dcca44ac 100644 --- a/opendaylight/adsal/usermanager/api/pom.xml +++ b/opendaylight/adsal/usermanager/api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight usermanager - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/usermanager/implementation/pom.xml b/opendaylight/adsal/usermanager/implementation/pom.xml index fd8a397837..f272482af5 100644 --- a/opendaylight/adsal/usermanager/implementation/pom.xml +++ b/opendaylight/adsal/usermanager/implementation/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight usermanager.implementation - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/web/brandfragment/pom.xml b/opendaylight/adsal/web/brandfragment/pom.xml index 0c76146c50..171ac3f47f 100644 --- a/opendaylight/adsal/web/brandfragment/pom.xml +++ b/opendaylight/adsal/web/brandfragment/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight @@ -17,7 +17,7 @@ org.opendaylight.controller web.brandfragment - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/web/devices/pom.xml b/opendaylight/adsal/web/devices/pom.xml index 062812b867..56ad7e7a39 100644 --- a/opendaylight/adsal/web/devices/pom.xml +++ b/opendaylight/adsal/web/devices/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight devices.web - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/web/flows/pom.xml b/opendaylight/adsal/web/flows/pom.xml index 4b1d54781a..14fe753a2f 100644 --- a/opendaylight/adsal/web/flows/pom.xml +++ b/opendaylight/adsal/web/flows/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight flows.web - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/web/osgi-brandfragment/pom.xml b/opendaylight/adsal/web/osgi-brandfragment/pom.xml index 78ad3f24c7..31e1bf805e 100644 --- a/opendaylight/adsal/web/osgi-brandfragment/pom.xml +++ b/opendaylight/adsal/web/osgi-brandfragment/pom.xml @@ -5,12 +5,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight osgi-brandfragment.web - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT bundle OSGi management web application brand fragment diff --git a/opendaylight/adsal/web/root/pom.xml b/opendaylight/adsal/web/root/pom.xml index 3d633b6c65..992f9b3dc5 100644 --- a/opendaylight/adsal/web/root/pom.xml +++ b/opendaylight/adsal/web/root/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight web - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/web/topology/pom.xml b/opendaylight/adsal/web/topology/pom.xml index 0afe038086..70fa5993dc 100644 --- a/opendaylight/adsal/web/topology/pom.xml +++ b/opendaylight/adsal/web/topology/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight topology.web - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/adsal/web/troubleshoot/pom.xml b/opendaylight/adsal/web/troubleshoot/pom.xml index 1ef5de11c4..2ee231d6ae 100644 --- a/opendaylight/adsal/web/troubleshoot/pom.xml +++ b/opendaylight/adsal/web/troubleshoot/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../../commons/opendaylight troubleshoot.web - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/opendaylight/archetypes/odl-model-project/pom.xml b/opendaylight/archetypes/odl-model-project/pom.xml index 4945eb2a66..d15ea8853a 100644 --- a/opendaylight/archetypes/odl-model-project/pom.xml +++ b/opendaylight/archetypes/odl-model-project/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller.archetypes odl-model-project - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT maven-archetype diff --git a/opendaylight/archetypes/odl-model-project/src/main/resources/archetype-resources/pom.xml b/opendaylight/archetypes/odl-model-project/src/main/resources/archetype-resources/pom.xml index 0786b366cd..f6f4a8756f 100644 --- a/opendaylight/archetypes/odl-model-project/src/main/resources/archetype-resources/pom.xml +++ b/opendaylight/archetypes/odl-model-project/src/main/resources/archetype-resources/pom.xml @@ -11,8 +11,8 @@ http://nexus.opendaylight.org/content opendaylight.release opendaylight.release - 0.7.0-SNAPSHOT - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT + 0.8.0-SNAPSHOT 2.3.7 diff --git a/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml b/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml index 45ec9ac717..0a984de6b4 100644 --- a/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml +++ b/opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller opendaylight-configfile-archetype - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT maven-archetype diff --git a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml index ff2384fb27..18e8ba13a4 100644 --- a/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml +++ b/opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller.archetypes archetypes-parent - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT org.opendaylight.controller opendaylight-karaf-distro-archetype - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT maven-archetype distribution-karaf-archetype 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 index 3836906a20..3607e1fcdd 100644 --- 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 @@ -19,8 +19,8 @@ - 1.1.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.2.0-SNAPSHOT + 1.6.0-SNAPSHOT 3.0.3 @@ -81,7 +81,7 @@ org.opendaylight.openflowplugin features-openflowplugin - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT features xml runtime diff --git a/opendaylight/archetypes/opendaylight-karaf-features/pom.xml b/opendaylight/archetypes/opendaylight-karaf-features/pom.xml index 12861604e8..7403d692d1 100644 --- a/opendaylight/archetypes/opendaylight-karaf-features/pom.xml +++ b/opendaylight/archetypes/opendaylight-karaf-features/pom.xml @@ -5,11 +5,11 @@ org.opendaylight.controller.archetypes archetypes-parent - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT org.opendaylight.controller opendaylight-karaf-features-archetype - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT maven-archetype opendaylight-karaf-features-archetype 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 index 5355e66945..8b8bc25849 100644 --- 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 @@ -24,11 +24,11 @@ features.xml - 1.1.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.2.0-SNAPSHOT + 1.6.0-SNAPSHOT 3.0.3 - 1.5.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT + 1.6.0-SNAPSHOT 2.16 @@ -46,21 +46,21 @@ org.opendaylight.yangtools features-yangtools - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT features xml org.opendaylight.controller features-mdsal - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT features xml org.opendaylight.openflowplugin features-openflowplugin - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT features xml 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 index 2acf5d15e0..1a1eb03d53 100644 --- 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 @@ -21,9 +21,9 @@ Necessary TODO: Add repo entries for the repositories of features you refer to in this feature file but do not define here. Examples: - mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features - mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features - mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features + mvn:org.opendaylight.yangtools/features-yangtools/0.8.0-SNAPSHOT/xml/features + mvn:org.opendaylight.controller/features-mdsal/1.3.0-SNAPSHOT/xml/features + mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.2.0-SNAPSHOT/xml/features --> diff --git a/opendaylight/commons/checkstyle/pom.xml b/opendaylight/commons/checkstyle/pom.xml index fee517f08b..4009aaa5fd 100644 --- a/opendaylight/commons/checkstyle/pom.xml +++ b/opendaylight/commons/checkstyle/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.opendaylight.controller checkstyle - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT scm:git:ssh://git.opendaylight.org:29418/controller.git scm:git:ssh://git.opendaylight.org:29418/controller.git diff --git a/opendaylight/commons/concepts/pom.xml b/opendaylight/commons/concepts/pom.xml index fa97e5fcac..c1045a0955 100644 --- a/opendaylight/commons/concepts/pom.xml +++ b/opendaylight/commons/concepts/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../commons/opendaylight concepts - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle @@ -43,7 +43,7 @@ org.opendaylight.controller checkstyle - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/opendaylight/commons/enunciate-parent/pom.xml b/opendaylight/commons/enunciate-parent/pom.xml index 2b89137733..48a90e6f3c 100644 --- a/opendaylight/commons/enunciate-parent/pom.xml +++ b/opendaylight/commons/enunciate-parent/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../opendaylight diff --git a/opendaylight/commons/filter-valve/pom.xml b/opendaylight/commons/filter-valve/pom.xml index 012b4a2529..b86904109f 100644 --- a/opendaylight/commons/filter-valve/pom.xml +++ b/opendaylight/commons/filter-valve/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../opendaylight filter-valve diff --git a/opendaylight/commons/liblldp/pom.xml b/opendaylight/commons/liblldp/pom.xml index 148a4f3792..1d9cbe3cd0 100644 --- a/opendaylight/commons/liblldp/pom.xml +++ b/opendaylight/commons/liblldp/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../opendaylight liblldp - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT bundle diff --git a/opendaylight/commons/logback_settings/pom.xml b/opendaylight/commons/logback_settings/pom.xml index f98b7a3a7a..f2f03d761b 100644 --- a/opendaylight/commons/logback_settings/pom.xml +++ b/opendaylight/commons/logback_settings/pom.xml @@ -4,11 +4,11 @@ org.opendaylight.controller commons.parent - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT ../parent commons.logback_settings - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT scm:git:ssh://git.opendaylight.org:29418/controller.git scm:git:ssh://git.opendaylight.org:29418/controller.git diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 5865c84b1f..885d9fdb53 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -4,30 +4,30 @@ org.opendaylight.odlparent odlparent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT pom - 2.3.9 - 0.5.0-SNAPSHOT - 0.1.0-SNAPSHOT - 0.6.0-SNAPSHOT + 2.3.10 + 0.6.0-SNAPSHOT + 0.2.0-SNAPSHOT + 0.7.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT 3.0.1 @@ -41,19 +41,19 @@ 7.0.53.v201406060720 7.0.53.v201406070630 - 0.1.0-SNAPSHOT - 0.2.0-SNAPSHOT - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT + 0.2.0-SNAPSHOT 3.0.1 - 0.2.0-SNAPSHOT - 0.6.0-SNAPSHOT - 1.5.0-SNAPSHOT - 1.1.0-SNAPSHOT - 0.2.0-SNAPSHOT - 0.6.0-SNAPSHOT + 0.3.0-SNAPSHOT + 0.7.0-SNAPSHOT + 1.6.0-SNAPSHOT + 1.2.0-SNAPSHOT + 0.3.0-SNAPSHOT + 0.7.0-SNAPSHOT 1.4 - 0.3.0-SNAPSHOT - 0.2.0-SNAPSHOT + 0.4.0-SNAPSHOT + 0.3.0-SNAPSHOT etc/opendaylight/karaf 05-clustering.xml 00-netty.xml @@ -64,88 +64,87 @@ 08-mdsal-netconf.xml 10-rest-connector.xml 99-netconf-connector.xml - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.2.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.1.0-SNAPSHOT - 0.5.0-SNAPSHOT - 1.2.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.3.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.2.0-SNAPSHOT + 0.6.0-SNAPSHOT + 1.3.0-SNAPSHOT 30-statistics-manager.xml - 2.5.0 3.8.0.I20120518-2145 0000.0002.0038.0 1.6.0 - 1.5.0-SNAPSHOT - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT + 1.6.0-SNAPSHOT 2.4.0 - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.7.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT - 1.1.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.1.0-SNAPSHOT - 2010.09.24.7-SNAPSHOT - 2013.10.19.7-SNAPSHOT - 2013.10.21.7-SNAPSHOT - 2010.09.24.7-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.8.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 1.2.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.2.0-SNAPSHOT + 2010.09.24.8-SNAPSHOT + 2013.10.19.8-SNAPSHOT + 2013.10.21.8-SNAPSHOT + 2010.09.24.8-SNAPSHOT 2.0-beta-2 src/main/yang-gen-config - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT 1.1.4 1.1.1 2.0 - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT ${karaf.version} 0.7 1.8 1.0.0 - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT 3.0.5 1.9.4 - 1.2.0-SNAPSHOT - 0.3.0-SNAPSHOT - 0.1.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.4.0-SNAPSHOT + 0.2.0-SNAPSHOT http://nexus.opendaylight.org/content - 0.5.0-SNAPSHOT - 1.5.0-SNAPSHOT - 1.5.0-SNAPSHOT - 2013.08.27.7-SNAPSHOT - 0.1.0-SNAPSHOT + 0.6.0-SNAPSHOT + 1.6.0-SNAPSHOT + 1.6.0-SNAPSHOT + 2013.08.27.8-SNAPSHOT + 0.2.0-SNAPSHOT 1.1.6 1.1.6 1.0-alpha-2 2.5.0 - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.2.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.1.0-SNAPSHOT - 0.9.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.3.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.2.0-SNAPSHOT + 0.10.0-SNAPSHOT src/main/yang-gen-sal - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT 2.10 4 - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT 1.2.4 dav:http://nexus.opendaylight.org/content/sites/site ${user.name}-private-view @@ -162,30 +161,30 @@ 3.1.4.RELEASE 3.1.3.RELEASE 3.1.3.RELEASE - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.6.0-SNAPSHOT - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT 2.15 - 0.8.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT + 0.9.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT -Xmx1024m -XX:MaxPermSize=256m - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 1.1.0-SNAPSHOT - 0.5.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 1.2.0-SNAPSHOT + 0.6.0-SNAPSHOT 1.2.0 1.2.2a - 0.5.0-SNAPSHOT - 0.1.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 0.5.0-SNAPSHOT - 2013.09.07.7-SNAPSHOT - 1.1.0-SNAPSHOT - 0.7.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.2.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT + 2013.09.07.8-SNAPSHOT + 1.2.0-SNAPSHOT + 0.8.0-SNAPSHOT 0.14.0 0.9.7 3.3.0 @@ -951,12 +950,12 @@ org.opendaylight.controller httpservice-bridge - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT org.opendaylight.controller jolokia-bridge - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT @@ -1260,7 +1259,7 @@ org.opendaylight.controller commons.logback_settings - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT test @@ -1427,7 +1426,7 @@ org.opendaylight.controller commons.logback_settings - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT @@ -1661,7 +1660,7 @@ org.opendaylight.controller checkstyle - 0.1.0-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/opendaylight/commons/parent/pom.xml b/opendaylight/commons/parent/pom.xml index f8364ca535..2ade034ade 100644 --- a/opendaylight/commons/parent/pom.xml +++ b/opendaylight/commons/parent/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.opendaylight.controller commons.parent - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT pom diff --git a/opendaylight/commons/protocol-framework/pom.xml b/opendaylight/commons/protocol-framework/pom.xml index 38b9d175f2..c56de0c8a4 100644 --- a/opendaylight/commons/protocol-framework/pom.xml +++ b/opendaylight/commons/protocol-framework/pom.xml @@ -6,12 +6,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../../commons/opendaylight protocol-framework - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle ${project.artifactId} Common protocol framework diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java index 7b8816bd1b..17663d982c 100644 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java +++ b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractDispatcher.java @@ -114,6 +114,7 @@ public abstract class AbstractDispatcher, L extends if (LocalServerChannel.class.equals(channelClass) == false) { // makes no sense for LocalServer and produces warning b.childOption(ChannelOption.SO_KEEPALIVE, true); + b.childOption(ChannelOption.TCP_NODELAY , true); } b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); customizeBootstrap(b); diff --git a/opendaylight/config/config-api/pom.xml b/opendaylight/config/config-api/pom.xml index d76bd50a3d..433c13238f 100644 --- a/opendaylight/config/config-api/pom.xml +++ b/opendaylight/config/config-api/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT config-api diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java index 3b724e8ebe..3fb0604f20 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java @@ -16,7 +16,7 @@ import javax.management.ObjectName; @Immutable public class CommitStatus { private final List newInstances, reusedInstances, - recreatedInstances; + recreatedInstances; /** * @param newInstances newly created instances diff --git a/opendaylight/config/config-artifacts/pom.xml b/opendaylight/config/config-artifacts/pom.xml index 430d6b41bc..7e1475baa2 100644 --- a/opendaylight/config/config-artifacts/pom.xml +++ b/opendaylight/config/config-artifacts/pom.xml @@ -12,7 +12,7 @@ 4.0.0 org.opendaylight.controller config-artifacts - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT pom diff --git a/opendaylight/config/config-manager/pom.xml b/opendaylight/config/config-manager/pom.xml index 71f2cabb63..0bc068083f 100644 --- a/opendaylight/config/config-manager/pom.xml +++ b/opendaylight/config/config-manager/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. config-manager diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsTest.java index 9391378fbb..853f8c090d 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsTest.java @@ -95,7 +95,7 @@ public class AnnotationsTest { static final String SUBCLASS2 = "subclass2"; @ServiceInterfaceAnnotation(value = SIMPLE, osgiRegistrationType = Executor.class, - namespace = "ns", revision = "rev", localName = SIMPLE) + namespace = "ns", revision = "rev", localName = SIMPLE) static interface SimpleSI extends AbstractServiceInterface { } @@ -160,7 +160,7 @@ public class AnnotationsTest { } @ServiceInterfaceAnnotation(value = SUBCLASS2, osgiRegistrationType = ExecutorService.class, - namespace = "ns", revision = "rev", localName = SUBCLASS2) + namespace = "ns", revision = "rev", localName = SUBCLASS2) static interface SubSI2 extends SubSI { diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/TestingParallelAPSPConfigMXBean.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/TestingParallelAPSPConfigMXBean.java index 830c67ca64..d838e7b93e 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/TestingParallelAPSPConfigMXBean.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/TestingParallelAPSPConfigMXBean.java @@ -11,7 +11,7 @@ import javax.management.ObjectName; import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation; @ServiceInterfaceAnnotation(value = TestingParallelAPSPConfigMXBean.NAME, osgiRegistrationType = TestingAPSP.class, -namespace = "namespace", revision = "rev", localName = TestingParallelAPSPConfigMXBean.NAME) + namespace = "namespace", revision = "rev", localName = TestingParallelAPSPConfigMXBean.NAME) public interface TestingParallelAPSPConfigMXBean { static final String NAME = "apsp"; diff --git a/opendaylight/config/config-module-archetype/pom.xml b/opendaylight/config/config-module-archetype/pom.xml index 3e9162eb36..92ff18129b 100644 --- a/opendaylight/config/config-module-archetype/pom.xml +++ b/opendaylight/config/config-module-archetype/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT config-module-archetype diff --git a/opendaylight/config/config-netty-config/pom.xml b/opendaylight/config/config-netty-config/pom.xml index 1e7a027b5b..3802011286 100644 --- a/opendaylight/config/config-netty-config/pom.xml +++ b/opendaylight/config/config-netty-config/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT config-netty-config Configuration files for sal-rest-connector diff --git a/opendaylight/config/config-parent/pom.xml b/opendaylight/config/config-parent/pom.xml index e6e2bb8478..fa8a4385e3 100644 --- a/opendaylight/config/config-parent/pom.xml +++ b/opendaylight/config/config-parent/pom.xml @@ -11,20 +11,20 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.yangtools binding-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT 4.0.0 org.opendaylight.controller config-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT pom - 0.3.0-SNAPSHOT - 1.2.0-SNAPSHOT - 0.7.0-SNAPSHOT + 0.4.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT src/main/yang-gen-config src/main/config/default-config.xml diff --git a/opendaylight/config/config-persister-api/pom.xml b/opendaylight/config/config-persister-api/pom.xml index f83beb0c8b..d8969ef3d0 100644 --- a/opendaylight/config/config-persister-api/pom.xml +++ b/opendaylight/config/config-persister-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. config-persister-api diff --git a/opendaylight/config/config-persister-directory-xml-adapter/pom.xml b/opendaylight/config/config-persister-directory-xml-adapter/pom.xml index 302b13fdf9..accf9600b4 100644 --- a/opendaylight/config/config-persister-directory-xml-adapter/pom.xml +++ b/opendaylight/config/config-persister-directory-xml-adapter/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. config-persister-directory-xml-adapter diff --git a/opendaylight/config/config-persister-feature-adapter/pom.xml b/opendaylight/config/config-persister-feature-adapter/pom.xml index d7d7889bf9..2bc25a3978 100644 --- a/opendaylight/config/config-persister-feature-adapter/pom.xml +++ b/opendaylight/config/config-persister-feature-adapter/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. diff --git a/opendaylight/config/config-persister-file-xml-adapter/pom.xml b/opendaylight/config/config-persister-file-xml-adapter/pom.xml index 35df9e1999..afd5e406f7 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/pom.xml +++ b/opendaylight/config/config-persister-file-xml-adapter/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. config-persister-file-xml-adapter diff --git a/opendaylight/config/config-plugin-parent/pom.xml b/opendaylight/config/config-plugin-parent/pom.xml index 081df0c52d..2663aa5ebd 100644 --- a/opendaylight/config/config-plugin-parent/pom.xml +++ b/opendaylight/config/config-plugin-parent/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ config-plugin-parent diff --git a/opendaylight/config/config-util/pom.xml b/opendaylight/config/config-util/pom.xml index 6a5950dc7e..fa83b43de2 100644 --- a/opendaylight/config/config-util/pom.xml +++ b/opendaylight/config/config-util/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. config-util diff --git a/opendaylight/config/logback-config-loader/pom.xml b/opendaylight/config/logback-config-loader/pom.xml index 94f7f8fc49..40adc0cffa 100644 --- a/opendaylight/config/logback-config-loader/pom.xml +++ b/opendaylight/config/logback-config-loader/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent logback-config-loader diff --git a/opendaylight/config/logback-config/pom.xml b/opendaylight/config/logback-config/pom.xml index d4537387aa..82e1fa8ea3 100644 --- a/opendaylight/config/logback-config/pom.xml +++ b/opendaylight/config/logback-config/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent logback-config diff --git a/opendaylight/config/netconf-config-dispatcher/pom.xml b/opendaylight/config/netconf-config-dispatcher/pom.xml index 0e0ec9372c..e91d6c3fc2 100644 --- a/opendaylight/config/netconf-config-dispatcher/pom.xml +++ b/opendaylight/config/netconf-config-dispatcher/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent diff --git a/opendaylight/config/netty-config-api/pom.xml b/opendaylight/config/netty-config-api/pom.xml index 2d8145723d..440ca0f926 100644 --- a/opendaylight/config/netty-config-api/pom.xml +++ b/opendaylight/config/netty-config-api/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent netty-config-api diff --git a/opendaylight/config/netty-event-executor-config/pom.xml b/opendaylight/config/netty-event-executor-config/pom.xml index 31940b91fe..1876690f30 100644 --- a/opendaylight/config/netty-event-executor-config/pom.xml +++ b/opendaylight/config/netty-event-executor-config/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent netty-event-executor-config diff --git a/opendaylight/config/netty-threadgroup-config/pom.xml b/opendaylight/config/netty-threadgroup-config/pom.xml index 0f645015e1..7ee7bccec7 100644 --- a/opendaylight/config/netty-threadgroup-config/pom.xml +++ b/opendaylight/config/netty-threadgroup-config/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent netty-threadgroup-config diff --git a/opendaylight/config/netty-timer-config/pom.xml b/opendaylight/config/netty-timer-config/pom.xml index 181c1d0151..95cbbd5448 100644 --- a/opendaylight/config/netty-timer-config/pom.xml +++ b/opendaylight/config/netty-timer-config/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent netty-timer-config diff --git a/opendaylight/config/pom.xml b/opendaylight/config/pom.xml index 6d14ad3957..7601f765f3 100644 --- a/opendaylight/config/pom.xml +++ b/opendaylight/config/pom.xml @@ -5,12 +5,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../commons/opendaylight config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT pom ${project.artifactId} diff --git a/opendaylight/config/shutdown-api/pom.xml b/opendaylight/config/shutdown-api/pom.xml index 659052e570..3b55070277 100644 --- a/opendaylight/config/shutdown-api/pom.xml +++ b/opendaylight/config/shutdown-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent shutdown-api diff --git a/opendaylight/config/shutdown-impl/pom.xml b/opendaylight/config/shutdown-impl/pom.xml index f14c285323..4a1ce2c35e 100644 --- a/opendaylight/config/shutdown-impl/pom.xml +++ b/opendaylight/config/shutdown-impl/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent shutdown-impl diff --git a/opendaylight/config/threadpool-config-api/pom.xml b/opendaylight/config/threadpool-config-api/pom.xml index 9dc7bf5976..7c10031a48 100644 --- a/opendaylight/config/threadpool-config-api/pom.xml +++ b/opendaylight/config/threadpool-config-api/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent threadpool-config-api diff --git a/opendaylight/config/threadpool-config-impl/pom.xml b/opendaylight/config/threadpool-config-impl/pom.xml index b875f5f3e4..3d08bfff96 100644 --- a/opendaylight/config/threadpool-config-impl/pom.xml +++ b/opendaylight/config/threadpool-config-impl/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent threadpool-config-impl diff --git a/opendaylight/config/yang-jmx-generator-it/pom.xml b/opendaylight/config/yang-jmx-generator-it/pom.xml index 6d2663ced5..02f3c09348 100644 --- a/opendaylight/config/yang-jmx-generator-it/pom.xml +++ b/opendaylight/config/yang-jmx-generator-it/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT yang-jmx-generator-it diff --git a/opendaylight/config/yang-jmx-generator-plugin/pom.xml b/opendaylight/config/yang-jmx-generator-plugin/pom.xml index ae190848c9..0b08ba3f5d 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/pom.xml +++ b/opendaylight/config/yang-jmx-generator-plugin/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT .. yang-jmx-generator-plugin diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java b/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java index 3dae004161..56cd615a39 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java @@ -561,7 +561,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest { private static class SieASTVisitor extends ASTVisitor { protected String packageName, descriptionAnotValue, sieAnnotValue, - sieAnnotOsgiRegistrationType, type, extnds, javadoc; + sieAnnotOsgiRegistrationType, type, extnds, javadoc; protected Map methodDescriptions = Maps.newHashMap(); @Override diff --git a/opendaylight/config/yang-jmx-generator/pom.xml b/opendaylight/config/yang-jmx-generator/pom.xml index bfeb3f0f7a..1b3397dbd3 100644 --- a/opendaylight/config/yang-jmx-generator/pom.xml +++ b/opendaylight/config/yang-jmx-generator/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractAttribute.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractAttribute.java index e6b69fb17d..d9a6dd0452 100644 --- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractAttribute.java +++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractAttribute.java @@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; public abstract class AbstractAttribute implements AttributeIfc { private final String attributeYangName, upperCaseCammelCase, - lowerCaseCammelCase; + lowerCaseCammelCase; protected final DataSchemaNode node; private static String getLocalName(DataSchemaNode attrNode) { diff --git a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java index a937af9a5e..c62e1a7deb 100644 --- a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java +++ b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java @@ -34,8 +34,8 @@ public abstract class AbstractYangTest { protected Map namesToModules; // are module names globally // unique? protected Module configModule, rpcContextModule, threadsModule, - threadsJavaModule, bgpListenerJavaModule, ietfInetTypesModule, - jmxModule, jmxImplModule, testFilesModule, testFiles1Module; + threadsJavaModule, bgpListenerJavaModule, ietfInetTypesModule, + jmxModule, jmxImplModule, testFilesModule, testFiles1Module; public static final String EVENTBUS_MXB_NAME = "eventbus"; public static final String ASYNC_EVENTBUS_MXB_NAME = "async-eventbus"; diff --git a/opendaylight/config/yang-test-plugin/pom.xml b/opendaylight/config/yang-test-plugin/pom.xml index 690f8d24e6..b437e77b9d 100644 --- a/opendaylight/config/yang-test-plugin/pom.xml +++ b/opendaylight/config/yang-test-plugin/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent yang-test-plugin diff --git a/opendaylight/config/yang-test/pom.xml b/opendaylight/config/yang-test/pom.xml index f5c966d5a6..687e35fb25 100644 --- a/opendaylight/config/yang-test/pom.xml +++ b/opendaylight/config/yang-test/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller config-plugin-parent - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../config-plugin-parent diff --git a/opendaylight/md-sal/benchmark-data-store/pom.xml b/opendaylight/md-sal/benchmark-data-store/pom.xml index b196c3180f..2a340d363a 100644 --- a/opendaylight/md-sal/benchmark-data-store/pom.xml +++ b/opendaylight/md-sal/benchmark-data-store/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html sal-parent org.opendaylight.controller - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT 4.0.0 diff --git a/opendaylight/md-sal/md-sal-config/pom.xml b/opendaylight/md-sal/md-sal-config/pom.xml index bd1586054d..9f815bc46c 100644 --- a/opendaylight/md-sal/md-sal-config/pom.xml +++ b/opendaylight/md-sal/md-sal-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT md-sal-config Configuration files for md-sal diff --git a/opendaylight/md-sal/mdsal-artifacts/pom.xml b/opendaylight/md-sal/mdsal-artifacts/pom.xml index d0b9f48873..6b0a7329f6 100644 --- a/opendaylight/md-sal/mdsal-artifacts/pom.xml +++ b/opendaylight/md-sal/mdsal-artifacts/pom.xml @@ -12,7 +12,7 @@ 4.0.0 org.opendaylight.controller mdsal-artifacts - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT pom diff --git a/opendaylight/md-sal/messagebus-api/pom.xml b/opendaylight/md-sal/messagebus-api/pom.xml index dda7af4f18..d3586fb8ed 100644 --- a/opendaylight/md-sal/messagebus-api/pom.xml +++ b/opendaylight/md-sal/messagebus-api/pom.xml @@ -14,7 +14,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT messagebus-api diff --git a/opendaylight/md-sal/messagebus-config/pom.xml b/opendaylight/md-sal/messagebus-config/pom.xml index 262a53e4ec..bbd334f75e 100644 --- a/opendaylight/md-sal/messagebus-config/pom.xml +++ b/opendaylight/md-sal/messagebus-config/pom.xml @@ -13,7 +13,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT messagebus-config diff --git a/opendaylight/md-sal/messagebus-impl/pom.xml b/opendaylight/md-sal/messagebus-impl/pom.xml index d43210d7c4..472617ceb9 100644 --- a/opendaylight/md-sal/messagebus-impl/pom.xml +++ b/opendaylight/md-sal/messagebus-impl/pom.xml @@ -14,7 +14,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT messagebus-impl @@ -54,12 +54,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.controller messagebus-api - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.opendaylight.controller messagebus-spi - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.opendaylight.controller diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java index 13e50b5ce5..c60562d3d4 100644 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java +++ b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java @@ -39,10 +39,7 @@ public class EventSourceTopic implements DataChangeListener { public EventSourceTopic(final NotificationPattern notificationPattern, final String nodeIdPattern, final EventSourceService eventSource) { this.notificationPattern = Preconditions.checkNotNull(notificationPattern); this.sourceService = eventSource; - - // FIXME: regex should be the language of nodeIdPattern - final String regex = Util.wildcardToRegex(nodeIdPattern); - this.nodeIdPattern = Pattern.compile(regex); + this.nodeIdPattern = Pattern.compile(nodeIdPattern); this.topicId = new TopicId(Util.getUUIDIdent()); } diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java index 7771b82491..6140a78ba5 100644 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java +++ b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java @@ -168,7 +168,7 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR final NotificationPattern notificationPattern = new NotificationPattern(input.getNotificationPattern()); final String nodeIdPattern = input.getNodeIdPattern().getValue(); - final Pattern nodeIdPatternRegex = Pattern.compile(Util.wildcardToRegex(nodeIdPattern)); + final Pattern nodeIdPatternRegex = Pattern.compile(nodeIdPattern); final EventSourceTopic eventSourceTopic = new EventSourceTopic(notificationPattern, nodeIdPattern, eventSourceService); registerTopic(eventSourceTopic); diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java index a88c609a26..7aebb8fbdd 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java @@ -25,30 +25,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; */ public class UtilTest { - @Test - public void testWildcardToRegex() throws Exception { - // empty wildcard string - createAndAssertRegex("", "^$"); - - // wildcard string is a char to be replaced - createAndAssertRegex("*", "^.*$"); - createAndAssertRegex("?", "^.$"); - final String relevantChars = "()[]$^.{}|\\"; - for (final char c : relevantChars.toCharArray()) { - final char oneChar[] = {c}; - final String wildcardStr = new String(oneChar); - final String expectedRegex = "^\\" + c + "$"; - createAndAssertRegex(wildcardStr, expectedRegex); - } - - // wildcard string consists of more chars - createAndAssertRegex("a", "^a$"); - createAndAssertRegex("aBc", "^aBc$"); - createAndAssertRegex("a1b2C34", "^a1b2C34$"); - createAndAssertRegex("*?()[]$^.{}|\\X", "^.*.\\(\\)\\[\\]\\$\\^\\.\\{\\}\\|\\\\X$"); - createAndAssertRegex("a*BB?37|42$", "^a.*BB.37\\|42\\$$"); - } - @Test public void testResultFor() throws Exception { { @@ -105,10 +81,6 @@ public class UtilTest { } } - private static void createAndAssertRegex(final String wildcardStr, final String expectedRegex) { - assertEquals("Incorrect regex string.", expectedRegex, Util.wildcardToRegex(wildcardStr)); - } - private static List createSchemaPathList() { final QName qname1 = QName.create("urn:odl:xxx", "2015-01-01", "localName"); final QName qname2 = QName.create("urn:odl:yyy", "2015-01-01", "localName"); diff --git a/opendaylight/md-sal/messagebus-spi/pom.xml b/opendaylight/md-sal/messagebus-spi/pom.xml index f31b37f6ed..c63c627e0c 100644 --- a/opendaylight/md-sal/messagebus-spi/pom.xml +++ b/opendaylight/md-sal/messagebus-spi/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT messagebus-spi diff --git a/opendaylight/md-sal/model/model-inventory/pom.xml b/opendaylight/md-sal/model/model-inventory/pom.xml index 00aa7761b9..7043ed0523 100644 --- a/opendaylight/md-sal/model/model-inventory/pom.xml +++ b/opendaylight/md-sal/model/model-inventory/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.controller.model model-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT model-inventory bundle diff --git a/opendaylight/md-sal/model/model-topology/pom.xml b/opendaylight/md-sal/model/model-topology/pom.xml index 09a063e887..4fd0dd43bc 100644 --- a/opendaylight/md-sal/model/model-topology/pom.xml +++ b/opendaylight/md-sal/model/model-topology/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.controller.model model-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT model-topology bundle diff --git a/opendaylight/md-sal/model/pom.xml b/opendaylight/md-sal/model/pom.xml index ffedadc770..cc6d15a713 100644 --- a/opendaylight/md-sal/model/pom.xml +++ b/opendaylight/md-sal/model/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.opendaylight.controller.model model-parent diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index bf0a082362..4610c4f59f 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -5,12 +5,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../commons/opendaylight sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT pom diff --git a/opendaylight/md-sal/sal-akka-raft-example/pom.xml b/opendaylight/md-sal/sal-akka-raft-example/pom.xml index 46fae5533e..8eb798b3c7 100644 --- a/opendaylight/md-sal/sal-akka-raft-example/pom.xml +++ b/opendaylight/md-sal/sal-akka-raft-example/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-akka-raft-example bundle diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ClientActor.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ClientActor.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ClientActor.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ClientActor.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ExampleActor.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ExampleActor.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ExampleConfigParamsImpl.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleConfigParamsImpl.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ExampleConfigParamsImpl.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleConfigParamsImpl.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ExampleRoleChangeListener.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleRoleChangeListener.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/ExampleRoleChangeListener.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleRoleChangeListener.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/LogGenerator.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/LogGenerator.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/LogGenerator.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/LogGenerator.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/Main.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/Main.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/Main.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/Main.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/TestDriver.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/TestDriver.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/KeyValue.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/KeyValue.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValue.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/KeyValueSaved.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValueSaved.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/KeyValueSaved.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/KeyValueSaved.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/PrintRole.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintRole.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/PrintRole.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintRole.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/PrintState.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintState.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/PrintState.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/PrintState.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/RegisterListener.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/RegisterListener.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/RegisterListener.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/RegisterListener.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/SetNotifiers.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/SetNotifiers.java similarity index 100% rename from opendaylight/md-sal/sal-akka-raft-example/src/main/java/opendaylight/controller/cluster/example/messages/SetNotifiers.java rename to opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/messages/SetNotifiers.java diff --git a/opendaylight/md-sal/sal-akka-raft/pom.xml b/opendaylight/md-sal/sal-akka-raft/pom.xml index 0ec83c86b3..768bdbc9e0 100644 --- a/opendaylight/md-sal/sal-akka-raft/pom.xml +++ b/opendaylight/md-sal/sal-akka-raft/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-akka-raft bundle 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 4485f3b144..d82528c48a 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 @@ -16,10 +16,10 @@ import akka.persistence.SnapshotSelectionCriteria; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Objects; import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import java.io.Serializable; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -259,7 +259,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { .snapshotIndex(replicatedLog().getSnapshotIndex()) .snapshotTerm(replicatedLog().getSnapshotTerm()) .votedFor(context.getTermInformation().getVotedFor()) - .peerAddresses(ImmutableMap.copyOf(context.getPeerAddresses())); + .peerAddresses(new HashMap<>(context.getPeerAddresses())); ReplicatedLogEntry lastLogEntry = getLastLogEntry(); if (lastLogEntry != null) { @@ -298,7 +298,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { Optional roleChangeNotifier = getRoleChangeNotifier(); if(!Objects.equal(oldBehaviorLeaderId, currentBehavior.getLeaderId())) { if(roleChangeNotifier.isPresent()) { - roleChangeNotifier.get().tell(new LeaderStateChanged(getId(), currentBehavior.getLeaderId()), getSelf()); + roleChangeNotifier.get().tell(newLeaderStateChanged(getId(), currentBehavior.getLeaderId()), getSelf()); } onLeaderChanged(oldBehaviorLeaderId, currentBehavior.getLeaderId()); @@ -311,6 +311,10 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } } + protected LeaderStateChanged newLeaderStateChanged(String memberId, String leaderId) { + return new LeaderStateChanged(memberId, leaderId); + } + /** * When a derived RaftActor needs to persist something it must call * persistData. diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java index 977cf0ef5e..579dea2638 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.raft; import static org.junit.Assert.assertEquals; import akka.actor.ActorRef; +import akka.actor.InvalidActorNameException; import akka.actor.PoisonPill; import akka.actor.Props; import akka.actor.Terminated; @@ -19,6 +20,7 @@ import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; +import com.google.common.util.concurrent.Uninterruptibles; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -186,9 +188,20 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest TestActorRef collectorActor = factory.createTestActor( MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()), factory.generateActorId(id + "-collector")); - return factory.createTestActor(TestRaftActor.props(id, - peerAddresses != null ? peerAddresses : Collections.emptyMap(), - configParams, collectorActor), id); + + InvalidActorNameException lastEx = null; + for(int i = 0; i < 10; i++) { + try { + return factory.createTestActor(TestRaftActor.props(id, + peerAddresses != null ? peerAddresses : Collections.emptyMap(), + configParams, collectorActor), id); + } catch (InvalidActorNameException e) { + lastEx = e; + Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); + } + } + + throw lastEx; } protected void killActor(TestActorRef leaderActor) { diff --git a/opendaylight/md-sal/sal-binding-api/pom.xml b/opendaylight/md-sal/sal-binding-api/pom.xml index 690957ed0b..dd1de8c146 100644 --- a/opendaylight/md-sal/sal-binding-api/pom.xml +++ b/opendaylight/md-sal/sal-binding-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-binding-api bundle diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java index be8e0cefc1..e5a0a2bd6d 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java @@ -8,7 +8,6 @@ package org.opendaylight.controller.sal.binding.api; import java.util.EventListener; - import org.opendaylight.yangtools.yang.binding.Notification; /** @@ -17,7 +16,9 @@ import org.opendaylight.yangtools.yang.binding.Notification; * capture of this interface. * * @param the interested notification type + * @deprecated Deprecated unused API. */ +@Deprecated public interface NotificationListener extends EventListener { /** * Invoked to deliver a notification. diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java index 00db80c19f..4b06e77c44 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.sal.binding.api; import java.util.EventListener; import java.util.concurrent.ExecutorService; - import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.Notification; @@ -18,7 +17,10 @@ import org.opendaylight.yangtools.yang.binding.Notification; * Interface for a notification service that provides publish/subscribe capabilities for YANG * modeled notifications. This interface is a combination of the {@link NotificationService} and * {@link NotificationPublishService} interfaces. + * + * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.NotificationPublishService}. */ +@Deprecated public interface NotificationProviderService extends NotificationService, NotificationPublishService { /** diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java index 335f55bcbb..dd66aa67f8 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java @@ -91,7 +91,10 @@ import org.opendaylight.yangtools.yang.binding.Notification; * * The onStart method will be invoked when someone publishes a Start notification and * the onStop method will be invoked when someone publishes a Stop notification. + * + * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.NotificationService} instead. */ +@Deprecated public interface NotificationService extends BindingAwareService { /** * Registers a generic listener implementation for a specified notification type. diff --git a/opendaylight/md-sal/sal-binding-broker/pom.xml b/opendaylight/md-sal/sal-binding-broker/pom.xml index b392eb2402..eebd7b13f8 100644 --- a/opendaylight/md-sal/sal-binding-broker/pom.xml +++ b/opendaylight/md-sal/sal-binding-broker/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-binding-broker-impl bundle diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java index 151439945e..e93109d576 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java @@ -7,11 +7,10 @@ */ package org.opendaylight.controller.md.sal.binding.compat; +import com.google.common.base.Preconditions; import org.opendaylight.controller.sal.binding.api.NotificationListener; import org.opendaylight.yangtools.yang.binding.Notification; -import com.google.common.base.Preconditions; - /** * An aggregated listener registration. This is a result of registering an invoker which can handle multiple * interfaces at the same time. In order to support correct delivery, we need to maintain per-type registrations diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenNotificationBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenNotificationBrokerImpl.java index c50c4cb599..b746020e0a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenNotificationBrokerImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenNotificationBrokerImpl.java @@ -7,16 +7,15 @@ */ package org.opendaylight.controller.md.sal.binding.compat; +import com.google.common.base.Preconditions; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicReference; - import javax.annotation.concurrent.GuardedBy; - import org.opendaylight.controller.sal.binding.api.NotificationListener; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.util.ListenerRegistry; @@ -24,10 +23,7 @@ import org.opendaylight.yangtools.yang.binding.Notification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - +@Deprecated public class HydrogenNotificationBrokerImpl implements NotificationProviderService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(HydrogenNotificationBrokerImpl.class); @@ -47,7 +43,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi @Override public void publish(final Notification notification, final ExecutorService service) { - for (NotificationListenerRegistration r : listeners.get().listenersFor(notification)) { + for (final NotificationListenerRegistration r : listeners.get().listenersFor(notification)) { service.submit(new NotifyTask(r, notification)); } } @@ -61,7 +57,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi synchronized (this) { final Multimap, NotificationListenerRegistration> newListeners = mutableListeners(); - for (NotificationListenerRegistration reg : registrations) { + for (final NotificationListenerRegistration reg : registrations) { newListeners.put(reg.getType(), reg); } @@ -69,7 +65,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi } // Notifications are dispatched out of lock... - for (NotificationListenerRegistration reg : registrations) { + for (final NotificationListenerRegistration reg : registrations) { announceNotificationSubscription(reg.getType()); } } @@ -78,7 +74,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi final Multimap, NotificationListenerRegistration> newListeners = mutableListeners(); - for (NotificationListenerRegistration reg : registrations) { + for (final NotificationListenerRegistration reg : registrations) { newListeners.remove(reg.getType(), reg); } @@ -89,7 +85,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi for (final ListenerRegistration listener : interestListeners) { try { listener.getInstance().onNotificationSubscribtion(notification); - } catch (Exception e) { + } catch (final Exception e) { LOG.warn("Listener {} reported unexpected error on notification {}", listener.getInstance(), notification, e); } @@ -121,14 +117,14 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi @Override public ListenerRegistration registerNotificationListener(final org.opendaylight.yangtools.yang.binding.NotificationListener listener) { - final NotificationInvoker invoker = SingletonHolder.INVOKER_FACTORY.invokerFor(listener); + final NotificationInvoker invoker = NotificationInvoker.invokerFor(listener); final Set> types = invoker.getSupportedNotifications(); final NotificationListenerRegistration[] regs = new NotificationListenerRegistration[types.size()]; // Populate the registrations... int i = 0; - for (Class type : types) { - regs[i] = new AggregatedNotificationListenerRegistration(type, invoker.getInvocationProxy(), regs) { + for (final Class type : types) { + regs[i] = new AggregatedNotificationListenerRegistration(type, invoker, regs) { @Override protected void removeRegistration() { // Nothing to do, will be cleaned up by parent (below) @@ -145,7 +141,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi @Override protected void removeRegistration() { removeRegistrations(regs); - for (ListenerRegistration reg : regs) { + for (final ListenerRegistration reg : regs) { reg.close(); } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java new file mode 100644 index 0000000000..cdc6315e49 --- /dev/null +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.binding.compat; + +import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.opendaylight.yangtools.yang.binding.Notification; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.binding.util.BindingReflections; +import org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker; +import org.opendaylight.yangtools.yang.common.QName; + +final class NotificationInvoker implements org.opendaylight.controller.sal.binding.api.NotificationListener { + + private final NotificationListener delegate; + private final Map,InvokerContext> invokers; + + + private NotificationInvoker(final NotificationListener listener) { + delegate = listener; + final Map, InvokerContext> builder = new HashMap<>(); + for(final TypeToken ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) { + Class iface = ifaceToken.getRawType(); + if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) { + @SuppressWarnings("unchecked") + final Class listenerType = (Class) iface; + final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType); + for(final Class type : getNotificationTypes(listenerType)) { + builder.put(type, new InvokerContext(BindingReflections.findQName(type) , invoker)); + } + } + } + invokers = ImmutableMap.copyOf(builder); + } + + public static NotificationInvoker invokerFor(final NotificationListener listener) { + return new NotificationInvoker(listener); + } + + public Set> getSupportedNotifications() { + return invokers.keySet(); + } + + @Override + public void onNotification(final Notification notification) { + getContext(notification.getImplementedInterface()).invoke(notification); + }; + + private InvokerContext getContext(final Class type) { + return invokers.get(type); + } + + @SuppressWarnings("unchecked") + private static Set> getNotificationTypes(final Class type) { + // TODO: Investigate possibility and performance impact if we cache this or expose + // it from NotificationListenerInvoker + final Set> ret = new HashSet<>(); + for(final Method method : type.getMethods()) { + if(BindingReflections.isNotificationCallback(method)) { + final Class notification = (Class) method.getParameterTypes()[0]; + ret.add(notification); + } + } + return ret; + } + + private class InvokerContext { + + private final QName name; + private final NotificationListenerInvoker invoker; + + private InvokerContext(final QName name, final NotificationListenerInvoker invoker) { + this.name = name; + this.invoker = invoker; + } + + public void invoke(final Notification notification) { + invoker.invokeNotification(delegate, name, notification); + } + + } + +} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java index 668030e1a6..cd3220e755 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.md.sal.binding.impl; import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; @@ -58,9 +59,10 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener { return invokers.keySet(); } - private static Map createInvokerMapFor(final Class implClz) { + public static Map createInvokerMapFor(final Class implClz) { final Map builder = new HashMap<>(); - for(final Class iface : implClz.getInterfaces()) { + for(final TypeToken ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) { + Class iface = ifaceToken.getRawType(); if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) { @SuppressWarnings("unchecked") final Class listenerType = (Class) iface; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RpcIsNotRoutedException.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RpcIsNotRoutedException.java deleted file mode 100644 index 5317324ee5..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RpcIsNotRoutedException.java +++ /dev/null @@ -1,29 +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.sal.binding.codegen; - -import com.google.common.base.Preconditions; - -/** - * Exception is raised when supplied Bidning Aware - * RPCService class is not routed and was used in context - * where routed RPCs should only be used. - * - */ -public class RpcIsNotRoutedException extends IllegalStateException { - - private static final long serialVersionUID = 1L; - - public RpcIsNotRoutedException(final String message, final Throwable cause) { - super(Preconditions.checkNotNull(message), cause); - } - - public RpcIsNotRoutedException(final String message) { - super(Preconditions.checkNotNull(message)); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java deleted file mode 100644 index c7c5f10f71..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java +++ /dev/null @@ -1,92 +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.sal.binding.codegen; - -import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; -import org.opendaylight.yangtools.yang.binding.RpcService; - -public interface RuntimeCodeGenerator { - - /** - * Returns an instance of provided RpcService type which delegates all calls - * to the delegate. - * - *

- * Returned instance: - *

    - *
  • implements provided subclass of RpcService type and - * {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy} interface. - *
  • - *

    - * delegates all invocations of methods, which are defined in RpcService - * subtype to delegate which is defined by - * {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy#setDelegate(Object)}. - *

    - * If delegate is not defined (getDelegate() == null) - * implementation throws {@link IllegalStateException} - *

  • {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy#getDelegate()} - returns the delegate to which - * all calls are delegated. - *
  • {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy#setDelegate(Object)} - sets the delegate for - * particular instance - * - *
- * - * @param serviceType - * - Subclass of RpcService for which direct proxy is to be - * generated. - * @return Instance of RpcService of provided serviceType which implements - * and {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy} - * @throws IllegalArgumentException - * - */ - T getDirectProxyFor(Class serviceType) throws IllegalArgumentException; - - /** - * Returns an instance of provided RpcService type which routes all calls to - * other instances selected on particular input field. - * - *

- * Returned instance: - *

    - *
  • Implements: - *
      - *
    • {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy} - *
    • {@link RpcRouter} - *
    - *
  • - * routes all invocations of methods, which are defined in RpcService - * subtype based on method arguments and routing information defined in the - * RpcRoutingTables for this instance - * {@link RpcRouter#getRoutingTable(Class)}. - *
      - *
    • - * Implementation uses - * {@link RpcRouter#getService(Class, org.opendaylight.yangtools.yang.binding.InstanceIdentifier)} method to - * retrieve particular instance to which call will be routed. - *
    • - * Instance of {@link org.opendaylight.yangtools.yang.binding.InstanceIdentifier} is determined by first argument of - * method and is retrieved via method which is annotated with - * {@link org.opendaylight.yangtools.yang.binding.annotations.RoutingContext}. - * Class representing Routing Context Identifier is retrieved by a - * {@link org.opendaylight.yangtools.yang.binding.annotations.RoutingContext}. - *
    • If first argument is not defined / {@link org.opendaylight.yangtools.yang.binding.annotations.RoutingContext} annotation - * is not present on any field invocation will be delegated to default - * service {@link RpcRouter#getDefaultService()}. - *
    - * - * @param serviceType - * - Subclass of RpcService for which Router is to be generated. - * @return Instance of RpcService of provided serviceType which implements - * also {@link RpcRouter} and {@link org.opendaylight.controller.sal.binding.spi.DelegateProxy} - * @throws RpcIsNotRoutedException - */ - RpcRouter getRouterFor(Class serviceType,String name) throws IllegalArgumentException, RpcIsNotRoutedException; - - NotificationInvokerFactory getInvokerFactory(); -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java deleted file mode 100644 index ae90a7739e..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java +++ /dev/null @@ -1,95 +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.sal.binding.codegen; - -import java.lang.reflect.Field; -import java.util.Map; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -public final class RuntimeCodeHelper { - private RuntimeCodeHelper() { - throw new UnsupportedOperationException("Utility class should never be instantiated"); - } - - private static Field getField(final Class cls, final String name) { - try { - return cls.getField(name); - } catch (NoSuchFieldException e) { - throw new IllegalArgumentException( - String.format("Class %s is missing field %s", cls, name), e); - } catch (SecurityException e) { - throw new IllegalStateException(String.format("Failed to examine class %s", cls), e); - } - } - - private static Field getDelegateField(final Class cls) { - return getField(cls, RuntimeCodeSpecification.DELEGATE_FIELD); - } - - private static Object getFieldValue(final Field field, final Object obj) { - try { - return field.get(obj); - } catch (IllegalAccessException e) { - throw new IllegalStateException(String.format("Failed to get field %s of object %s", field, obj), e); - } - } - - private static void setFieldValue(final Field field, final Object obj, final Object value) { - try { - field.set(obj, value); - } catch (IllegalAccessException e) { - throw new IllegalStateException(String.format("Failed to set field %s to %s", field, value), e); - } - } - - /** - * Helper method to return delegate from ManagedDirectedProxy with use of reflection. - * - * Note: This method uses reflection, but access to delegate field should be - * avoided and called only if necessary. - */ - @SuppressWarnings("unchecked") - public static T getDelegate(final RpcService proxy) { - return (T)getFieldValue(getDelegateField(proxy.getClass()), proxy); - } - - /** - * Helper method to set delegate to ManagedDirectedProxy with use of reflection. - * - * Note: This method uses reflection, but setting delegate field should not occur too much - * to introduce any significant performance hits. - */ - public static void setDelegate(final Object proxy, final Object delegate) { - final Field field = getDelegateField(proxy.getClass()); - - if (delegate != null) { - final Class ft = field.getType(); - if (!ft.isAssignableFrom(delegate.getClass())) { - throw new IllegalArgumentException( - String.format("Field %s type %s is not compatible with delegate type %s", - field, ft, delegate.getClass())); - } - } - - setFieldValue(field, proxy, delegate); - } - - @SuppressWarnings("unchecked") - public static Map,? extends RpcService> getRoutingTable(final RpcService target, final Class tableClass) { - final Field field = getField(target.getClass(), RuntimeCodeSpecification.getRoutingTableField(tableClass)); - return (Map,? extends RpcService>) getFieldValue(field, target); - } - - public static void setRoutingTable(final RpcService target, final Class tableClass, final Map,? extends RpcService> routingTable) { - final Field field = getField(target.getClass(), RuntimeCodeSpecification.getRoutingTableField(tableClass)); - setFieldValue(field, target, routingTable); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.java deleted file mode 100644 index 22b6f6f1c7..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.java +++ /dev/null @@ -1,57 +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.sal.binding.codegen; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.binding.RpcService; - -public final class RuntimeCodeSpecification { - public final static String DIRECT_PROXY_SUFFIX = "DirectProxy"; - public final static String INVOKER_SUFFIX = "ListenerInvoker"; - public final static String ROUTER_SUFFIX = "Router"; - - public final static String DELEGATE_FIELD = "_delegate"; - public final static String ROUTING_TABLE_FIELD_PREFIX = "_routes_"; - - private RuntimeCodeSpecification() { - throw new UnsupportedOperationException("Utility class"); - } - - /** - * Returns a name for generated interface - */ - private static String getGeneratedName(final Class cls, final String suffix) { - return cls.getName() + "$$Broker$" + suffix; - } - - public static String getInvokerName(final Class listener) { - return getGeneratedName(listener, RuntimeCodeSpecification.INVOKER_SUFFIX); - } - - /** - * Returns a name for DirectProxy implementation - */ - public static String getDirectProxyName(final Class base) { - return getGeneratedName(base, RuntimeCodeSpecification.DIRECT_PROXY_SUFFIX); - } - - /** - * Returns a name for Router implementation - */ - public static String getRouterName(final Class base) { - return getGeneratedName(base, RuntimeCodeSpecification.ROUTER_SUFFIX); - } - - /** - * Returns a field name for specified routing context - */ - public static String getRoutingTableField(final Class routingContext) { - return "_routes_" + routingContext.getSimpleName(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/AbstractRuntimeCodeGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/AbstractRuntimeCodeGenerator.java deleted file mode 100644 index 6c02001fec..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/AbstractRuntimeCodeGenerator.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.codegen.impl; - -import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; -import java.util.Map; -import java.util.WeakHashMap; -import javassist.ClassPool; -import javassist.CtClass; -import javassist.CtMethod; -import javassist.NotFoundException; -import javax.annotation.concurrent.GuardedBy; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; -import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; -import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; -import org.opendaylight.yangtools.util.ClassLoaderUtils; -import org.opendaylight.yangtools.yang.binding.BindingMapping; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; - -abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory { - @GuardedBy("this") - private final Map, RuntimeGeneratedInvokerPrototype> invokerClasses = new WeakHashMap<>(); - private final CtClass brokerNotificationListener; - protected final JavassistUtils utils; - - protected AbstractRuntimeCodeGenerator(final ClassPool pool) { - utils = JavassistUtils.forClassPool(pool); - - /* - * Make sure Javassist ClassPool sees the classloader of RpcService - */ - utils.ensureClassLoader(RpcService.class); - - brokerNotificationListener = utils.asCtClass(org.opendaylight.controller.sal.binding.api.NotificationListener.class); - } - - protected final CtClass getBrokerNotificationListener() { - return brokerNotificationListener; - } - - protected abstract RuntimeGeneratedInvokerPrototype generateListenerInvoker(Class cls); - protected abstract Supplier directProxySupplier(final Class serviceType); - protected abstract Supplier routerSupplier(final Class serviceType, RpcServiceMetadata metadata); - - private RpcServiceMetadata getRpcMetadata(final CtClass iface) throws ClassNotFoundException, NotFoundException, RpcIsNotRoutedException { - final RpcServiceMetadata metadata = new RpcServiceMetadata(); - - for (CtMethod method : iface.getMethods()) { - if (isRpcMethodWithInput(iface, method)) { - final RpcMetadata routingPair = getRpcMetadata(method); - if (routingPair != null) { - metadata.addContext(routingPair.getContext()); - metadata.addRpcMethod(method.getName(), routingPair); - - /* - * Force-load the RPC class representing the "input" of this RPC. - * - * FIXME: this is pre-existing side-effect of the original code, which - * kept a reference to the loaded class, but it did not use it. - * - * There was no explanation as to why forcing this load was - * necessary. As far as I can tell now is that it forces the - * resolution of method arguments, which would (according to - * my reading of JLS) occur only when the method is invoked via - * binding-aware class action, not when coming from - * binding-independent world. Whether that makes sense or not, - * remains to be investigated. - */ - Thread.currentThread().getContextClassLoader().loadClass(routingPair.getInputType().getName()); - } else { - throw new RpcIsNotRoutedException(String.format("RPC %s from %s is not routed", method.getName(), iface.getName())); - } - } - } - - return metadata; - } - - - private boolean isRpcMethodWithInput(final CtClass iface, final CtMethod method) throws NotFoundException { - if(iface.equals(method.getDeclaringClass()) - && method.getParameterTypes().length == 1) { - final CtClass onlyArg = method.getParameterTypes()[0]; - if(onlyArg.isInterface() && onlyArg.getName().endsWith(BindingMapping.RPC_INPUT_SUFFIX)) { - return true; - } - } - return false; - } - - private RpcMetadata getRpcMetadata(final CtMethod method) throws NotFoundException { - final CtClass inputClass = method.getParameterTypes()[0]; - return rpcMethodMetadata(inputClass, inputClass, method.getName()); - } - - private RpcMetadata rpcMethodMetadata(final CtClass dataClass, final CtClass inputClass, final String rpcMethod) throws NotFoundException { - for (CtMethod method : dataClass.getMethods()) { - if (method.getName().startsWith("get") && method.getParameterTypes().length == 0) { - for (Object annotation : method.getAvailableAnnotations()) { - if (annotation instanceof RoutingContext) { - boolean encapsulated = !method.getReturnType().equals(utils.asCtClass(InstanceIdentifier.class)); - return new RpcMetadata(rpcMethod, ((RoutingContext)annotation).value(), method, encapsulated, inputClass); - } - } - } - } - - for (CtClass iface : dataClass.getInterfaces()) { - final RpcMetadata ret = rpcMethodMetadata(iface, inputClass, rpcMethod); - if(ret != null) { - return ret; - } - } - return null; - } - - private synchronized RuntimeGeneratedInvokerPrototype resolveInvokerClass(final Class cls) { - RuntimeGeneratedInvokerPrototype invoker = invokerClasses.get(cls); - if (invoker != null) { - return invoker; - } - - synchronized (utils) { - invoker = ClassLoaderUtils.withClassLoader(cls.getClassLoader(), new Supplier() { - @Override - public RuntimeGeneratedInvokerPrototype get() { - return generateListenerInvoker(cls); - } - }); - } - - invokerClasses.put(cls, invoker); - return invoker; - } - - @Override - public final NotificationInvokerFactory getInvokerFactory() { - return this; - } - - @Override - public final T getDirectProxyFor(final Class serviceType) { - synchronized (utils) { - return ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), directProxySupplier(serviceType)); - } - } - - @Override - public final RpcRouter getRouterFor(final Class serviceType, final String name) throws RpcIsNotRoutedException { - final RpcServiceMetadata metadata = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), new Supplier() { - @Override - public RpcServiceMetadata get() { - try { - return getRpcMetadata(utils.asCtClass(serviceType)); - } catch (ClassNotFoundException | NotFoundException e) { - throw new IllegalStateException(String.format("Failed to load metadata for class %s", serviceType), e); - } - } - }); - - if (Iterables.isEmpty(metadata.getContexts())) { - throw new RpcIsNotRoutedException("Service doesn't have routing context associated."); - } - - synchronized (utils) { - final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata)); - return new RpcRouterCodegenInstance(name, serviceType, instance, metadata.getContexts()); - } - } - - @Override - public NotificationInvoker invokerFor(final NotificationListener instance) { - final Class cls = instance.getClass(); - final RuntimeGeneratedInvokerPrototype prototype = resolveInvokerClass(cls); - - try { - return RuntimeGeneratedInvoker.create(instance, prototype); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException(String.format("Failed to create invoker for %s", instance), e); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/DefaultRuntimeCodeGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/DefaultRuntimeCodeGenerator.java deleted file mode 100644 index dfa164b485..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/DefaultRuntimeCodeGenerator.java +++ /dev/null @@ -1,286 +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.sal.binding.codegen.impl; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import java.lang.reflect.Method; -import java.util.Map; -import javassist.CannotCompileException; -import javassist.ClassPool; -import javassist.CtClass; -import javassist.CtMethod; -import javassist.NotFoundException; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification; -import org.opendaylight.yangtools.sal.binding.generator.util.ClassGenerator; -import org.opendaylight.yangtools.sal.binding.generator.util.MethodGenerator; -import org.opendaylight.yangtools.util.ClassLoaderUtils; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.binding.RpcImplementation; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; - -final class DefaultRuntimeCodeGenerator extends AbstractRuntimeCodeGenerator { - - DefaultRuntimeCodeGenerator(final ClassPool pool) { - super(pool); - } - - @Override - protected Supplier directProxySupplier(final Class serviceType) { - return new Supplier() { - @SuppressWarnings("unchecked") - @Override - public T get() { - final String proxyName = RuntimeCodeSpecification.getDirectProxyName(serviceType); - - final Class potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName); - if (potentialClass != null) { - try { - return (T)potentialClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException("Failed to instantiate class " + potentialClass.getName(), e); - } - } - - final CtClass supertype = utils.asCtClass(serviceType); - final String directProxyName = RuntimeCodeSpecification.getDirectProxyName(serviceType); - - final CtClass createdCls; - try { - createdCls = utils.createClass(directProxyName, supertype, new ClassGenerator() { - @Override - public void process(final CtClass cls) throws CannotCompileException { - utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, serviceType); - utils.implementsType(cls, utils.asCtClass(RpcImplementation.class)); - utils.implementMethodsFrom(cls, supertype, new MethodGenerator() { - @Override - public void process(final CtMethod method) throws CannotCompileException { - final StringBuilder sb = new StringBuilder("\n"); - sb.append("{\n"); - sb.append(" if (").append(RuntimeCodeSpecification.DELEGATE_FIELD).append(" == null) {\n"); - sb.append(" throw new java.lang.IllegalStateException(\"No default provider is available\");\n"); - sb.append(" }\n"); - sb.append(" return ($r) ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(method.getName()).append("($$);\n"); - sb.append("}\n"); - method.setBody(sb.toString()); - } - }); - - // FIXME: copy this one... - utils.implementMethodsFrom(cls, utils.asCtClass(RpcImplementation.class), new MethodGenerator() { - @Override - public void process(final CtMethod method) throws CannotCompileException { - final StringBuilder sb = new StringBuilder("\n"); - sb.append("{\n"); - sb.append(" throw new java.lang.IllegalStateException(\"No provider is processing supplied message\");\n"); - sb.append(" return ($r) null;\n"); - sb.append("}\n"); - method.setBody(sb.toString()); - } - }); - } - }); - } catch (CannotCompileException e) { - throw new IllegalStateException("Failed to create class " + directProxyName, e); - } - - final Class c; - try { - c = createdCls.toClass(serviceType.getClassLoader(), serviceType.getProtectionDomain()); - } catch (CannotCompileException e) { - throw new IllegalStateException(String.format("Failed to create class %s", createdCls), e); - } - - try { - return (T) c.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException(String.format("Failed to instantiated class %s", c), e); - } - } - }; - } - - @Override - protected Supplier routerSupplier(final Class serviceType, final RpcServiceMetadata metadata) { - return new Supplier() { - @SuppressWarnings("unchecked") - @Override - public T get() { - final CtClass supertype = utils.asCtClass(serviceType); - final String routerName = RuntimeCodeSpecification.getRouterName(serviceType); - final Class potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(routerName); - if (potentialClass != null) { - try { - return (T)potentialClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException("Failed to instantiate class", e); - } - } - - final CtClass targetCls; - try { - targetCls = utils.createClass(routerName, supertype, new ClassGenerator() { - @Override - public void process(final CtClass cls) throws CannotCompileException { - utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, serviceType); - //utils.field(cls, REMOTE_INVOKER_FIELD,iface); - utils.implementsType(cls, utils.asCtClass(RpcImplementation.class)); - - for (final Class ctx : metadata.getContexts()) { - utils.field(cls, RuntimeCodeSpecification.getRoutingTableField(ctx), Map.class); - } - - utils.implementMethodsFrom(cls, supertype, new MethodGenerator() { - @Override - public void process(final CtMethod method) throws CannotCompileException { - final int ptl; - try { - ptl = method.getParameterTypes().length; - } catch (NotFoundException e) { - throw new CannotCompileException(e); - } - final StringBuilder sb = new StringBuilder(); - - switch (ptl) { - case 0: - sb.append("return ($r) ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(method.getName()).append("($$);"); - break; - case 1: - final RpcMetadata rpcMeta = metadata.getRpcMethod(method.getName()); - final String rtGetter = rpcMeta.getInputRouteGetter().getName(); - final String stName = supertype.getName(); - - sb.append('\n'); - sb.append("{\n"); - sb.append(" if ($1 == null) {\n"); - sb.append(" throw new IllegalArgumentException(\"RPC input must not be null and must contain a value for field ").append(rtGetter).append("\");\n"); - sb.append(" }\n"); - sb.append(" if ($1.").append(rtGetter).append("() == null) {\n"); - sb.append(" throw new IllegalArgumentException(\"Field ").append(rtGetter).append(" must not be null\");\n"); - sb.append(" }\n"); - - sb.append(" final org.opendaylight.yangtools.yang.binding.InstanceIdentifier identifier = $1.").append(rtGetter).append("()"); - if (rpcMeta.isRouteEncapsulated()) { - sb.append(".getValue()"); - } - sb.append(";\n"); - - sb.append(" ").append(supertype.getName()).append(" instance = (").append(stName).append(") ").append(RuntimeCodeSpecification.getRoutingTableField(rpcMeta.getContext())).append(".get(identifier);\n"); - sb.append(" if (instance == null) {\n"); - sb.append(" instance = ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append(";\n"); - sb.append(" }\n"); - - sb.append(" if (instance == null) {\n"); - sb.append(" throw new java.lang.IllegalStateException(\"No routable provider is processing routed message for \" + String.valueOf(identifier));\n"); - sb.append(" }\n"); - sb.append(" return ($r) instance.").append(method.getName()).append("($$);\n"); - sb.append('}'); - break; - default: - throw new CannotCompileException(String.format("Unsupported parameters length %s", ptl)); - } - - method.setBody(sb.toString()); - } - }); - - // FIXME: move this into a template class - utils.implementMethodsFrom(cls, utils.asCtClass(RpcImplementation.class), new MethodGenerator() { - @Override - public void process(final CtMethod method) throws CannotCompileException { - final StringBuilder sb = new StringBuilder("\n"); - sb.append("{\n"); - sb.append(" throw new java.lang.IllegalStateException(\"No provider is processing supplied message\");\n"); - sb.append(" return ($r) null;\n"); - sb.append("}\n"); - - method.setBody(sb.toString()); - } - }); - } - }); - } catch (CannotCompileException e) { - throw new IllegalStateException("Failed to create class " + routerName, e); - } - - final Class c; - try { - c = targetCls.toClass(serviceType.getClassLoader(), serviceType.getProtectionDomain()); - } catch (CannotCompileException e) { - throw new IllegalStateException(String.format("Failed to compile class %s", targetCls), e); - } - - try { - return (T)c.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException(String.format("Failed to instantiate class %s", c), e); - } - } - }; - } - - @SuppressWarnings("unchecked") - @Override - protected RuntimeGeneratedInvokerPrototype generateListenerInvoker(final Class listenerType) { - final String invokerName = RuntimeCodeSpecification.getInvokerName(listenerType); - final CtClass targetCls; - - // Builder for a set of supported types. Filled while the target class is being generated - final Builder> b = ImmutableSet.builder(); - - try { - targetCls = utils.createClass(invokerName, getBrokerNotificationListener(), new ClassGenerator() { - @Override - public void process(final CtClass cls) throws CannotCompileException { - utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, listenerType); - utils.implementMethodsFrom(cls, getBrokerNotificationListener(), new MethodGenerator() { - @Override - public void process(final CtMethod method) throws CannotCompileException { - final StringBuilder sb = new StringBuilder("\n"); - - sb.append("{\n"); - - for (Method m : listenerType.getMethods()) { - if (BindingReflections.isNotificationCallback(m)) { - final Class argType = m.getParameterTypes()[0]; - - // populates builder above - b.add((Class) argType); - - sb.append(" if ($1 instanceof ").append(argType.getName()).append(") {\n"); - sb.append(" ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(m.getName()).append("((").append(argType.getName()).append(") $1);\n"); - sb.append(" return null;\n"); - sb.append(" } else "); - } - } - - sb.append(" return null;\n"); - sb.append("}\n"); - method.setBody(sb.toString()); - } - }); - } - }); - } catch (CannotCompileException e) { - throw new IllegalStateException("Failed to create class " + invokerName, e); - } - - final Class finalClass; - try { - finalClass = targetCls.toClass(listenerType.getClassLoader(), listenerType.getProtectionDomain()); - } catch (CannotCompileException e) { - throw new IllegalStateException(String.format("Failed to compile class %s", targetCls), e); - } - - return new RuntimeGeneratedInvokerPrototype(b.build(), (Class>) finalClass); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcMetadata.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcMetadata.java deleted file mode 100644 index 6f9f85f58a..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcMetadata.java +++ /dev/null @@ -1,95 +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.sal.binding.codegen.impl; - -import javassist.CtClass; -import javassist.CtMethod; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; - -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; - -final class RpcMetadata { - private final Class context; - private final CtMethod inputRouteGetter; - private final Boolean routeEncapsulated; - private final CtClass inputType; - private final String methodName; - - public Class getContext() { - return context; - } - - public CtMethod getInputRouteGetter() { - return inputRouteGetter; - } - - public CtClass getInputType() { - return inputType; - } - - public boolean isRouteEncapsulated() { - return routeEncapsulated; - } - - public RpcMetadata(final String methodName, final Class context, final CtMethod inputRouteGetter, final boolean routeEncapsulated, final CtClass inputType) { - this.inputRouteGetter = Preconditions.checkNotNull(inputRouteGetter); - this.methodName = Preconditions.checkNotNull(methodName); - this.inputType = Preconditions.checkNotNull(inputType); - this.context = Preconditions.checkNotNull(context); - this.routeEncapsulated = routeEncapsulated; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + methodName.hashCode(); - result = prime * result + context.hashCode(); - result = prime * result + inputRouteGetter.hashCode(); - result = prime * result + routeEncapsulated.hashCode(); - result = prime * result + inputType.hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof RpcMetadata)) { - return false; - } - final RpcMetadata other = (RpcMetadata) obj; - if (!methodName.equals(other.methodName)) { - return false; - } - if (!context.equals(other.context)) { - return false; - } - if (!inputRouteGetter.equals(other.inputRouteGetter)) { - return false; - } - if (!routeEncapsulated.equals(other.routeEncapsulated)) { - return false; - } - return inputType.equals(other.inputType); - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("context", context) - .add("inputRouteGetter", inputRouteGetter) - .add("inputType", inputType) - .add("methodName", methodName) - .add("routeEncapsulated", routeEncapsulated) - .toString(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java deleted file mode 100644 index d69aeed352..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java +++ /dev/null @@ -1,216 +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.sal.binding.codegen.impl; - -import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.setRoutingTable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import javax.annotation.concurrent.GuardedBy; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChange; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RpcRouterCodegenInstance implements // -RpcRouter, RouteChangeListener, InstanceIdentifier> { - - private static final Logger LOG = LoggerFactory.getLogger(RpcRouterCodegenInstance.class); - - private final Class serviceType; - - private final T invocationProxy; - - private final Set> contexts; - - private final ListenerRegistry, InstanceIdentifier>> listeners; - - private final Map, RpcRoutingTableImpl> routingTables; - - @SuppressWarnings("unchecked") - public RpcRouterCodegenInstance(final String name,final Class type, final T routerImpl, final Iterable> contexts) { - this.listeners = ListenerRegistry.create(); - this.serviceType = type; - this.invocationProxy = routerImpl; - this.contexts = ImmutableSet.copyOf(contexts); - Map, RpcRoutingTableImpl> mutableRoutingTables = new HashMap<>(); - for (Class ctx : contexts) { - RpcRoutingTableImpl table = new RpcRoutingTableImpl<>(name,ctx,type); - - @SuppressWarnings("rawtypes") - Map invokerView = table.getRoutes(); - - setRoutingTable(invocationProxy, ctx, invokerView); - mutableRoutingTables.put(ctx, table); - table.registerRouteChangeListener(this); - } - this.routingTables = ImmutableMap.copyOf(mutableRoutingTables); - } - - @Override - public Class getServiceType() { - return serviceType; - } - - @Override - public T getInvocationProxy() { - return invocationProxy; - } - - @Override - @SuppressWarnings("unchecked") - public RpcRoutingTable getRoutingTable(final Class routeContext) { - return (RpcRoutingTable) routingTables.get(routeContext); - } - - @Override - public T getDefaultService() { - return RuntimeCodeHelper.getDelegate(invocationProxy); - } - - @Override - public Set> getContexts() { - return contexts; - } - - @Override - public , InstanceIdentifier>> ListenerRegistration registerRouteChangeListener( - final L listener) { - return listeners.registerWithType(listener); - } - - @Override - public void onRouteChange(final RouteChange, InstanceIdentifier> change) { - for (ListenerRegistration, InstanceIdentifier>> listener : listeners) { - try { - listener.getInstance().onRouteChange(change); - } catch (Exception e) { - LOG.error("Error occured during invoker listener {}", listener.getInstance(), e); - } - } - } - - @Override - public T getService(final Class context, final InstanceIdentifier path) { - return routingTables.get(context).getRoute(path); - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final T service) { - return new RoutedRpcRegistrationImpl(service); - } - - public void removeDefaultImplementation(final T instance) { - RpcService current = RuntimeCodeHelper.getDelegate(invocationProxy); - if(instance == current) { - RuntimeCodeHelper.setDelegate(invocationProxy, null); - } - } - - @Override - public RpcRegistration registerDefaultService(final T service) { - RuntimeCodeHelper.setDelegate(invocationProxy, service); - return new DefaultRpcImplementationRegistration(service); - } - - private final class RoutedRpcRegistrationImpl extends AbstractObjectRegistration implements RoutedRpcRegistration { - /* - * FIXME: retaining this collection is not completely efficient. We really should be storing - * a reference to this registration, as a particular listener may be registered multiple - * times -- and then this goes kaboom in various aspects. - */ - @GuardedBy("this") - private final Collection> contexts = new ArrayList<>(1); - - public RoutedRpcRegistrationImpl(final T instance) { - super(instance); - } - - @Override - public Class getServiceType() { - return serviceType; - } - - @Override - public synchronized void registerPath(final Class context, final InstanceIdentifier path) { - if (isClosed()) { - LOG.debug("Closed registration of {} ignoring new path {}", getInstance(), path); - return; - } - - routingTables.get(context).updateRoute(path, getInstance()); - contexts.add(context); - } - - @Override - public synchronized void unregisterPath(final Class context, final InstanceIdentifier path) { - if (isClosed()) { - LOG.debug("Closed unregistration of {} ignoring new path {}", getInstance(), path); - return; - } - - routingTables.get(context).removeRoute(path, getInstance()); - contexts.remove(context); - } - - @Deprecated - @Override - public void registerInstance(final Class context, final InstanceIdentifier instance) { - registerPath(context, instance); - } - - @Deprecated - @Override - public void unregisterInstance(final Class context, final InstanceIdentifier instance) { - unregisterPath(context, instance); - } - - @Override - protected synchronized void removeRegistration() { - for (Class ctx : contexts) { - routingTables.get(ctx).removeAllReferences(getInstance()); - } - contexts.clear(); - } - } - - private final class DefaultRpcImplementationRegistration extends AbstractObjectRegistration implements RpcRegistration { - - - protected DefaultRpcImplementationRegistration(final T instance) { - super(instance); - } - - @Override - protected void removeRegistration() { - removeDefaultImplementation(this.getInstance()); - } - - @Override - public Class getServiceType() { - return serviceType; - } - } - - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRoutingTableImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRoutingTableImpl.java deleted file mode 100644 index 78fa88bb1b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRoutingTableImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.codegen.impl; - -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher; -import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.Mutable; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -final class RpcRoutingTableImpl implements - Mutable, // - RpcRoutingTable, // - RouteChangePublisher, InstanceIdentifier> { - - private static final Logger LOGGER = LoggerFactory.getLogger(RpcRoutingTableImpl.class); - private final String routerName; - private final Class serviceType; - - private final Class contextType; - private final ConcurrentMap, S> routes; - private final Map, S> unmodifiableRoutes; - - private RouteChangeListener, InstanceIdentifier> listener; - private S defaultRoute; - - public RpcRoutingTableImpl(final String routerName,final Class contextType, final Class serviceType) { - super(); - this.routerName = routerName; - this.serviceType = serviceType; - this.contextType = contextType; - this.routes = new ConcurrentHashMap<>(); - this.unmodifiableRoutes = Collections.unmodifiableMap(routes); - } - - @Override - public void setDefaultRoute(final S target) { - defaultRoute = target; - } - - @Override - public S getDefaultRoute() { - return defaultRoute; - } - - @Override - public , InstanceIdentifier>> ListenerRegistration registerRouteChangeListener( - final L listener) { - return new SingletonListenerRegistration(listener); - } - - @Override - public Class getIdentifier() { - return contextType; - } - - @Override - @SuppressWarnings("unchecked") - public void updateRoute(final InstanceIdentifier path, final S service) { - S previous = this.routes.put(path, service); - - LOGGER.debug("Route {} updated to {} in routing table {}",path,service,this); - @SuppressWarnings("rawtypes") - RouteChangeListener listenerCapture = listener; - if (previous == null && listenerCapture != null) { - listenerCapture.onRouteChange(RoutingUtils.announcementChange(contextType, path)); - } - } - - - @Override - @SuppressWarnings("unchecked") - public void removeRoute(final InstanceIdentifier path) { - S previous = this.routes.remove(path); - LOGGER.debug("Route {} to {} removed in routing table {}",path,previous,this); - @SuppressWarnings("rawtypes") - RouteChangeListener listenerCapture = listener; - if (previous != null && listenerCapture != null) { - listenerCapture.onRouteChange(RoutingUtils.removalChange(contextType, path)); - } - } - - void removeRoute(final InstanceIdentifier path, final S service) { - @SuppressWarnings("rawtypes") - RouteChangeListener listenerCapture = listener; - if (routes.remove(path, service) && listenerCapture != null) { - LOGGER.debug("Route {} to {} removed in routing table {}",path,service,this); - listenerCapture.onRouteChange(RoutingUtils.removalChange(contextType, path)); - } - } - - @Override - public S getRoute(final InstanceIdentifier nodeInstance) { - S route = routes.get(nodeInstance); - if (route != null) { - return route; - } - return getDefaultRoute(); - } - - @Override - public Map, S> getRoutes() { - return unmodifiableRoutes; - } - - void removeAllReferences(final S service) { - // FIXME: replace this via properly-synchronized BiMap (or something) - final Iterator it = routes.values().iterator(); - while (it.hasNext()) { - final S s = it.next(); - if (service.equals(s)) { - it.remove(); - } - } - } - - @Override - public String toString() { - return "RpcRoutingTableImpl [router=" + routerName + ", service=" + serviceType.getSimpleName() + ", context=" - + contextType.getSimpleName() + "]"; - } - - private class SingletonListenerRegistration, InstanceIdentifier>> extends - AbstractObjectRegistration - implements ListenerRegistration { - - public SingletonListenerRegistration(final L instance) { - super(instance); - listener = instance; - } - - @Override - protected void removeRegistration() { - listener = null; - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcServiceMetadata.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcServiceMetadata.java deleted file mode 100644 index 430b7a7e31..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcServiceMetadata.java +++ /dev/null @@ -1,39 +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.sal.binding.codegen.impl; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.opendaylight.yangtools.yang.binding.BaseIdentity; - -import com.google.common.collect.Iterables; - -final class RpcServiceMetadata { - private final Set> contexts = new HashSet<>(); - private final Map rpcMethods = new HashMap<>(); - private final Iterable> roContexts = Iterables.unmodifiableIterable(contexts); - - public Iterable> getContexts() { - return roContexts; - } - - public RpcMetadata getRpcMethod(final String name) { - return rpcMethods.get(name); - } - - public void addContext(final Class context) { - contexts.add(context); - } - - public void addRpcMethod(final String name, final RpcMetadata routingPair) { - rpcMethods.put(name, routingPair); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeGeneratedInvoker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeGeneratedInvoker.java deleted file mode 100644 index 9302e4925e..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeGeneratedInvoker.java +++ /dev/null @@ -1,88 +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.sal.binding.codegen.impl; - -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; -import java.util.Set; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.NotificationListener; - -final class RuntimeGeneratedInvoker implements NotificationInvoker { - private final org.opendaylight.controller.sal.binding.api.NotificationListener invocationProxy; - private final RuntimeGeneratedInvokerPrototype prototype; - private final NotificationListener delegate; - - @SuppressWarnings("unchecked") - private RuntimeGeneratedInvoker(final NotificationListener delegate, final RuntimeGeneratedInvokerPrototype prototype, final org.opendaylight.controller.sal.binding.api.NotificationListener proxy) { - this.invocationProxy = (org.opendaylight.controller.sal.binding.api.NotificationListener) proxy; - this.delegate = Preconditions.checkNotNull(delegate); - this.prototype = prototype; - } - - public static RuntimeGeneratedInvoker create(final NotificationListener delegate, final RuntimeGeneratedInvokerPrototype prototype) throws InstantiationException, IllegalAccessException { - final org.opendaylight.controller.sal.binding.api.NotificationListener proxy = Preconditions.checkNotNull(prototype.getProtoClass().newInstance()); - RuntimeCodeHelper.setDelegate(proxy, delegate); - return new RuntimeGeneratedInvoker(delegate, prototype, proxy); - } - - @Override - public NotificationListener getDelegate() { - return delegate; - } - - @Override - public org.opendaylight.controller.sal.binding.api.NotificationListener getInvocationProxy() { - return invocationProxy; - } - - @Override - public Set> getSupportedNotifications() { - return prototype.getSupportedNotifications(); - } - - @Override - public void close() { - // Nothing to do - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + delegate.hashCode(); - result = prime * result + invocationProxy.hashCode(); - result = prime * result + prototype.hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof RuntimeGeneratedInvoker)) { - return false; - } - final RuntimeGeneratedInvoker other = (RuntimeGeneratedInvoker) obj; - if (!delegate.equals(other.delegate)) { - return false; - } - if (!invocationProxy.equals(other.invocationProxy)) { - return false; - } - return prototype.equals(other.prototype); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).toString(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeGeneratedInvokerPrototype.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeGeneratedInvokerPrototype.java deleted file mode 100644 index 317268420f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeGeneratedInvokerPrototype.java +++ /dev/null @@ -1,66 +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.sal.binding.codegen.impl; - -import java.util.Set; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.yangtools.yang.binding.Notification; - -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; - -final class RuntimeGeneratedInvokerPrototype { - private final Set> supportedNotifications; - private final Class> protoClass; - - public RuntimeGeneratedInvokerPrototype(final Set> supportedNotifications, final Class> protoClass) { - this.supportedNotifications = Preconditions.checkNotNull(supportedNotifications); - this.protoClass = Preconditions.checkNotNull(protoClass); - } - - public Set> getSupportedNotifications() { - return supportedNotifications; - } - - public Class> getProtoClass() { - return protoClass; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + supportedNotifications.hashCode(); - result = prime * result + protoClass.hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof RuntimeGeneratedInvokerPrototype)) { - return false; - } - final RuntimeGeneratedInvokerPrototype other = (RuntimeGeneratedInvokerPrototype) obj; - if (!protoClass.equals(other.protoClass)) { - return false; - } - return supportedNotifications.equals(other.supportedNotifications); - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("protoClass", protoClass) - .add("supportedNotifications", supportedNotifications) - .toString(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java index 4664b58d2a..6bcd74d213 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java @@ -22,8 +22,6 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javassist.ClassPool; import org.apache.commons.lang3.StringUtils; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,10 +31,6 @@ public class SingletonHolder { public static final ClassPool CLASS_POOL = ClassPool.getDefault(); public static final JavassistUtils JAVASSIST = JavassistUtils.forClassPool(CLASS_POOL); - public static final org.opendaylight.controller.sal.binding.codegen.impl.DefaultRuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.DefaultRuntimeCodeGenerator( - CLASS_POOL); - public static final RuntimeCodeGenerator RPC_GENERATOR = RPC_GENERATOR_IMPL; - public static final NotificationInvokerFactory INVOKER_FACTORY = RPC_GENERATOR_IMPL.getInvokerFactory(); public static final int CORE_NOTIFICATION_THREADS = 4; public static final int MAX_NOTIFICATION_THREADS = 32; @@ -58,12 +52,12 @@ public class SingletonHolder { if (NOTIFICATION_EXECUTOR == null) { int queueSize = MAX_NOTIFICATION_QUEUE_SIZE; - String queueValue = System.getProperty(NOTIFICATION_QUEUE_SIZE_PROPERTY); + final String queueValue = System.getProperty(NOTIFICATION_QUEUE_SIZE_PROPERTY); if (StringUtils.isNotBlank(queueValue)) { try { queueSize = Integer.parseInt(queueValue); logger.trace("Queue size was set to {}", queueSize); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { logger.warn("Cannot parse {} as set by {}, using default {}", queueValue, NOTIFICATION_QUEUE_SIZE_PROPERTY, queueSize); } @@ -101,7 +95,7 @@ public class SingletonHolder { public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) { try { executor.getQueue().put(r); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RejectedExecutionException("Interrupted while waiting on the queue", e); } } @@ -120,7 +114,7 @@ public class SingletonHolder { @Deprecated public static synchronized ListeningExecutorService getDefaultCommitExecutor() { if (COMMIT_EXECUTOR == null) { - ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-commit-%d").build(); + final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-commit-%d").build(); /* * FIXME: this used to be newCacheThreadPool(), but MD-SAL does not have transaction * ordering guarantees, which means that using a concurrent threadpool results @@ -128,7 +122,7 @@ public class SingletonHolder { * in inconsistent data being present. Once proper primitives are introduced, * concurrency can be reintroduced. */ - ExecutorService executor = Executors.newSingleThreadExecutor(factory); + final ExecutorService executor = Executors.newSingleThreadExecutor(factory); COMMIT_EXECUTOR = MoreExecutors.listeningDecorator(executor); } @@ -137,7 +131,7 @@ public class SingletonHolder { public static ExecutorService getDefaultChangeEventExecutor() { if (CHANGE_EVENT_EXECUTOR == null) { - ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-change-%d").build(); + final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-change-%d").build(); /* * FIXME: this used to be newCacheThreadPool(), but MD-SAL does not have transaction * ordering guarantees, which means that using a concurrent threadpool results @@ -145,7 +139,7 @@ public class SingletonHolder { * in inconsistent data being present. Once proper primitives are introduced, * concurrency can be reintroduced. */ - ExecutorService executor = Executors.newSingleThreadExecutor(factory); + final ExecutorService executor = Executors.newSingleThreadExecutor(factory); CHANGE_EVENT_EXECUTOR = MoreExecutors.listeningDecorator(executor); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.java deleted file mode 100644 index 4ed0ce9b40..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.impl; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; - -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter; -import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker; -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; -import org.opendaylight.controller.sal.binding.api.data.DataProviderService; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.util.DataObjectReadingUtil; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.Maps; - -@Deprecated -public class DataBrokerImpl extends - AbstractDataBroker, DataObject, DataChangeListener> // - implements DataProviderService, AutoCloseable { - - private final static class ContainsWildcarded implements Predicate> { - - private final InstanceIdentifier key; - - public ContainsWildcarded(final InstanceIdentifier key) { - this.key = key; - } - - @Override - public boolean apply(final InstanceIdentifier input) { - return key.containsWildcarded(input); - } - } - - private final static class IsContainedWildcarded implements Predicate> { - - private final InstanceIdentifier key; - - public IsContainedWildcarded(final InstanceIdentifier key) { - this.key = key; - } - - @Override - public boolean apply(final InstanceIdentifier input) { - return input.containsWildcarded(key); - } - } - - private final AtomicLong nextTransaction = new AtomicLong(); - private final AtomicLong createdTransactionsCount = new AtomicLong(); - private final DelegatingDataReadRouter router = new DelegatingDataReadRouter(); - private DataCommitHandler, DataObject> rootCommitHandler; - - public DataBrokerImpl() { - setDataReadRouter(router); - } - - public void setDataReadDelegate(final DataReader, DataObject> delegate) { - router.setDelegate(delegate); - } - - public AtomicLong getCreatedTransactionsCount() { - return createdTransactionsCount; - } - - @Override - public DataTransactionImpl beginTransaction() { - String transactionId = "BA-" + nextTransaction.getAndIncrement(); - createdTransactionsCount.getAndIncrement(); - return new DataTransactionImpl(transactionId, this); - } - - @Override - public void close() { - - } - - @Override - protected Predicate> createContainsPredicate( - final InstanceIdentifier key) { - return new ContainsWildcarded(key); - } - - @Override - protected Predicate> createIsContainedPredicate( - final InstanceIdentifier key) { - return new IsContainedWildcarded(key); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - protected Map, DataObject> deepGetBySubpath( - final Map, DataObject> dataSet, - final InstanceIdentifier path) { - Builder, DataObject> builder = ImmutableMap.builder(); - Map, DataObject> potential = Maps.filterKeys(dataSet, - createIsContainedPredicate(path)); - for (Entry, DataObject> entry : potential.entrySet()) { - try { - builder.putAll(DataObjectReadingUtil.readData(entry.getValue(), (InstanceIdentifier) entry.getKey(), - path)); - } catch (Exception e) { - // FIXME : Log exception; - } - } - return builder.build(); - - } - - public class DelegatingDataReadRouter extends - AbstractDataReadRouter, DataObject> { - - private DataReader, DataObject> delegate; - - @Override - public DataObject readConfigurationData(final InstanceIdentifier path) { - return delegate.readConfigurationData(path); - } - - public void setDelegate(final DataReader, DataObject> delegate) { - this.delegate = delegate; - } - - @Override - public DataObject readOperationalData(final InstanceIdentifier path) { - return delegate.readOperationalData(path); - } - - @Override - protected DataObject merge(final InstanceIdentifier path, final Iterable data) { - throw new UnsupportedOperationException("Not supported"); - } - - @Override - public Registration registerConfigurationReader( - final InstanceIdentifier path, - final DataReader, DataObject> reader) { - throw new UnsupportedOperationException("Not supported"); - } - - @Override - public Registration registerOperationalReader( - final InstanceIdentifier path, - final DataReader, DataObject> reader) { - throw new UnsupportedOperationException("Not supported"); - } - } - - @Override - protected ImmutableList, DataObject>> affectedCommitHandlers( - final Set> paths) { - ImmutableList.Builder, DataObject>> handlersBuilder = ImmutableList.builder(); - return handlersBuilder // - .add(rootCommitHandler) // - .addAll(super.affectedCommitHandlers(paths)) // - .build(); - } - - public void setRootCommitHandler(final DataCommitHandler, DataObject> commitHandler) { - rootCommitHandler = commitHandler; - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java deleted file mode 100644 index 4020232bf4..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.impl; - -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Deprecated -public class DataTransactionImpl extends AbstractDataTransaction, DataObject> - implements DataModificationTransaction { - private final ListenerRegistry listeners = new ListenerRegistry(); - - - - public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) { - super(identifier,dataBroker); - } - - @Override - public ListenerRegistration registerListener(DataTransactionListener listener) { - return listeners.register(listener); - } - - @Override - protected void onStatusChange(TransactionStatus status) { - for (ListenerRegistration listenerRegistration : listeners) { - listenerRegistration.getInstance().onStatusUpdated(this, status); - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java deleted file mode 100644 index 0949d3d761..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java +++ /dev/null @@ -1,279 +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.sal.binding.impl; - -import static com.google.common.base.Preconditions.checkState; -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.util.concurrent.UncheckedExecutionException; -import java.util.EventListener; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicBoolean; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChange; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher; -import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; -import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; -import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RpcProviderRegistryImpl implements RpcProviderRegistry, RouteChangePublisher> { - - private RuntimeCodeGenerator rpcFactory = SingletonHolder.RPC_GENERATOR_IMPL; - - // cache of proxy objects where each value in the map corresponds to a specific RpcService - private final LoadingCache, RpcService> publicProxies = CacheBuilder.newBuilder().weakKeys(). - build(new CacheLoader, RpcService>() { - @Override - public RpcService load(final Class type) { - final RpcService proxy = rpcFactory.getDirectProxyFor(type); - LOG.debug("Created {} as public proxy for {} in {}", proxy, type.getSimpleName(), this); - return proxy; - } - }); - - private final Cache, RpcRouter> rpcRouters = CacheBuilder.newBuilder().weakKeys() - .build(); - - private final ListenerRegistry>> routeChangeListeners = ListenerRegistry - .create(); - private final ListenerRegistry routerInstantiationListener = ListenerRegistry.create(); - - private final static Logger LOG = LoggerFactory.getLogger(RpcProviderRegistryImpl.class); - - private final String name; - - private final ListenerRegistry globalRpcListeners = ListenerRegistry.create(); - - public String getName() { - return name; - } - - public RpcProviderRegistryImpl(final String name) { - super(); - this.name = name; - } - - @Override - public final RoutedRpcRegistration addRoutedRpcImplementation(final Class type, - final T implementation) throws IllegalStateException { - return getRpcRouter(type).addRoutedRpcImplementation(implementation); - } - - @Override - public final RpcRegistration addRpcImplementation(final Class type, final T implementation) { - - // FIXME: This should be well documented - addRpcImplementation for - // routed RPCs - try { - // Note: If RPC is really global, expected count of registrations - // of this method is really low. - RpcRouter potentialRouter = getRpcRouter(type); - checkState(potentialRouter.getDefaultService() == null, - "Default service for routed RPC already registered."); - return potentialRouter.registerDefaultService(implementation); - } catch (RpcIsNotRoutedException e) { - // NOOP - we could safely continue, since RPC is not routed - // so we fallback to global routing. - LOG.debug("RPC is not routed. Using global registration.",e); - } - T publicProxy = getRpcService(type); - RpcService currentDelegate = RuntimeCodeHelper.getDelegate(publicProxy); - checkState(currentDelegate == null, "Rpc service is already registered"); - LOG.debug("Registering {} as global implementation of {} in {}", implementation, type.getSimpleName(), this); - RuntimeCodeHelper.setDelegate(publicProxy, implementation); - notifyGlobalRpcAdded(type); - return new RpcProxyRegistration(type, implementation, this); - } - - @SuppressWarnings("unchecked") - @Override - public final T getRpcService(final Class type) { - return (T) publicProxies.getUnchecked(type); - } - - - public RpcRouter getRpcRouter(final Class type) { - try { - final AtomicBoolean created = new AtomicBoolean(false); - @SuppressWarnings( "unchecked") - // LoadingCache is unsuitable for RpcRouter since we need to distinguish - // first creation of RPC Router, so that is why - // we are using normal cache with load API and shared AtomicBoolean - // for this call, which will be set to true if router was created. - RpcRouter router = (RpcRouter) rpcRouters.get(type,new Callable>() { - - @Override - public org.opendaylight.controller.sal.binding.api.rpc.RpcRouter call() { - RpcRouter router = rpcFactory.getRouterFor(type, name); - router.registerRouteChangeListener(new RouteChangeForwarder(type)); - LOG.debug("Registering router {} as global implementation of {} in {}", router, type.getSimpleName(), this); - RuntimeCodeHelper.setDelegate(getRpcService(type), router.getInvocationProxy()); - created.set(true); - return router; - } - }); - if(created.get()) { - notifyListenersRoutedCreated(router); - } - return router; - } catch (ExecutionException | UncheckedExecutionException e) { - // We rethrow Runtime Exceptions which were wrapped by - // Execution Exceptions - // otherwise we throw IllegalStateException with original - Throwables.propagateIfPossible(e.getCause()); - throw new IllegalStateException("Could not load RPC Router for "+type.getName(),e); - } - } - - private void notifyGlobalRpcAdded(final Class type) { - for(ListenerRegistration listener : globalRpcListeners) { - try { - listener.getInstance().onGlobalRpcRegistered(type); - } catch (Exception e) { - LOG.error("Unhandled exception during invoking listener {}", e); - } - } - - } - - private void notifyListenersRoutedCreated(final RpcRouter router) { - - for (ListenerRegistration listener : routerInstantiationListener) { - try { - listener.getInstance().onRpcRouterCreated(router); - } catch (Exception e) { - LOG.error("Unhandled exception during invoking listener {}", e); - } - } - - } - - public ListenerRegistration registerRouterInstantiationListener( - final RouterInstantiationListener listener) { - ListenerRegistration reg = routerInstantiationListener.register(listener); - try { - for (RpcRouter router : rpcRouters.asMap().values()) { - listener.onRpcRouterCreated(router); - } - } catch (Exception e) { - LOG.error("Unhandled exception during invoking listener {}", e); - } - return reg; - } - - @SuppressWarnings("unchecked") - @Override - public >> ListenerRegistration registerRouteChangeListener( - final L listener) { - return (ListenerRegistration) routeChangeListeners.register(listener); - } - - public RuntimeCodeGenerator getRpcFactory() { - return rpcFactory; - } - - public void setRpcFactory(final RuntimeCodeGenerator rpcFactory) { - this.rpcFactory = rpcFactory; - } - - public interface RouterInstantiationListener extends EventListener { - void onRpcRouterCreated(RpcRouter router); - } - - public ListenerRegistration registerGlobalRpcRegistrationListener(final GlobalRpcRegistrationListener listener) { - return globalRpcListeners.register(listener); - } - - public interface GlobalRpcRegistrationListener extends EventListener { - void onGlobalRpcRegistered(Class cls); - void onGlobalRpcUnregistered(Class cls); - - } - - private final class RouteChangeForwarder implements RouteChangeListener, InstanceIdentifier> { - private final Class type; - - RouteChangeForwarder(final Class type) { - this.type = type; - } - - @Override - public void onRouteChange(final RouteChange, InstanceIdentifier> change) { - Map>> announcements = new HashMap<>(); - for (Entry, Set>> entry : change.getAnnouncements() - .entrySet()) { - RpcContextIdentifier key = RpcContextIdentifier.contextFor(type, entry.getKey()); - announcements.put(key, entry.getValue()); - } - Map>> removals = new HashMap<>(); - for (Entry, Set>> entry : change.getRemovals() - .entrySet()) { - RpcContextIdentifier key = RpcContextIdentifier.contextFor(type, entry.getKey()); - removals.put(key, entry.getValue()); - } - RouteChange> toPublish = RoutingUtils - .> change(announcements, removals); - for (ListenerRegistration>> listener : routeChangeListeners) { - try { - listener.getInstance().onRouteChange(toPublish); - } catch (Exception e) { - LOG.error("Unhandled exception during invoking listener",listener.getInstance(),e); - } - } - } - } - - private static final class RpcProxyRegistration extends AbstractObjectRegistration implements RpcRegistration { - private final RpcProviderRegistryImpl registry; - private final Class serviceType; - - RpcProxyRegistration(final Class type, final T service, final RpcProviderRegistryImpl registry) { - super(service); - this.registry = Preconditions.checkNotNull(registry); - this.serviceType = type; - } - - @Override - public Class getServiceType() { - return serviceType; - } - - @Override - protected void removeRegistration() { - T publicProxy = registry.getRpcService(serviceType); - RpcService currentDelegate = RuntimeCodeHelper.getDelegate(publicProxy); - if (currentDelegate == getInstance()) { - RuntimeCodeHelper.setDelegate(publicProxy, null); - } - } - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.java deleted file mode 100644 index 3b6a2539de..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.java +++ /dev/null @@ -1,41 +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.sal.binding.impl; - -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.osgi.framework.ServiceRegistration; - -@SuppressWarnings("all") -public class RpcProxyContext { - public RpcProxyContext(final Class proxyClass) { - this.proxyClass = proxyClass; - } - - protected final Class proxyClass; - - protected RpcService _proxy; - - public RpcService getProxy() { - return this._proxy; - } - - public void setProxy(final RpcService proxy) { - this._proxy = proxy; - } - - protected ServiceRegistration _registration; - - public ServiceRegistration getRegistration() { - return this._registration; - } - - public void setRegistration(final ServiceRegistration registration) { - this._registration = registration; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/BindingAwareDataReaderRouter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/BindingAwareDataReaderRouter.java deleted file mode 100644 index 97f74ff6f3..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/BindingAwareDataReaderRouter.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.impl.util; - -import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class BindingAwareDataReaderRouter extends AbstractDataReadRouter,DataObject> { - @Override - protected DataObject merge(final InstanceIdentifier path, final Iterable data) { - return data.iterator().next(); - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/NotificationInvokerFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/NotificationInvokerFactory.java deleted file mode 100644 index 28e552eed7..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/NotificationInvokerFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.spi; - -import java.util.Set; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.yangtools.yang.binding.Notification; - -public interface NotificationInvokerFactory { - - NotificationInvoker invokerFor(org.opendaylight.yangtools.yang.binding.NotificationListener instance); - - public interface NotificationInvoker { - - Set> getSupportedNotifications(); - - NotificationListener getInvocationProxy(); - - public abstract void close(); - - org.opendaylight.yangtools.yang.binding.NotificationListener getDelegate(); - - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java index 6a8dc5fde9..f43352d101 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.md.sal.binding.impl.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.util.concurrent.TimeUnit; import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter; import com.google.common.collect.ImmutableList; @@ -52,17 +53,23 @@ public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificat final CountDownLatch latch = new CountDownLatch(1); final TwoLevelListChanged testData = createTestData(); - final NotifTestListener testNotifListener = new NotifTestListener(latch); + final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch); final ListenerRegistration listenerRegistration = notificationProviderService.registerNotificationListener(testNotifListener); notificationProviderService.publish(testData); - latch.await(); + latch.await(500L, TimeUnit.MILLISECONDS); assertTrue(testNotifListener.getReceivedNotifications().size() == 1); assertEquals(testData, testNotifListener.getReceivedNotifications().get(0)); listenerRegistration.close(); } + private static class NotifTestListenerChild extends NotifTestListener { + + public NotifTestListenerChild(final CountDownLatch latch) { + super(latch); + } + } private static class NotifTestListener implements OpendaylightMdsalListTestListener { private List receivedNotifications = new ArrayList<>(); private CountDownLatch latch; diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/RpcProviderRegistryTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/RpcProviderRegistryTest.java deleted file mode 100644 index de5f3ca46f..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/RpcProviderRegistryTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.opendaylight.controller.md.sal.binding.impl.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_BAR_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; -import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; - -import com.google.common.base.Throwables; -import java.util.Arrays; -import javassist.ClassPool; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext; -import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator; -import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; -import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - - -public class RpcProviderRegistryTest extends AbstractSchemaAwareTest { - - private static InstanceIdentifier FOO_PATH = path(TOP_FOO_KEY); - private static InstanceIdentifier BAR_PATH = path(TOP_BAR_KEY); - private static RpcContextIdentifier ROUTING_CONTEXT = RpcContextIdentifier.contextFor(OpendaylightTestRoutedRpcService.class, TestContext.class); - - private RpcProviderRegistry rpcRegistry; - - - @Override - protected Iterable getModuleInfos() { - try { - return Arrays.asList( - BindingReflections.getModuleInfo(TopLevelList.class), - BindingReflections.getModuleInfo(OpendaylightTestRoutedRpcService.class), - BindingReflections.getModuleInfo(OpendaylightTestRpcServiceService.class)); - } catch (final Exception e) { - throw Throwables.propagate(e); - } - } - - @Override - protected void setupWithSchema(final SchemaContext context) { - final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault())); - final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator); - final GeneratedClassLoadingStrategy classLoadingStrategy = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(); - final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry); - final DOMRpcRouter domRpcRegistry = new DOMRpcRouter(); - domRpcRegistry.onGlobalContextUpdated(context); - codec.onGlobalContextUpdated(context); - final RpcConsumerRegistry consumer = new BindingDOMRpcServiceAdapter(domRpcRegistry, codec); - final BindingDOMRpcProviderServiceAdapter provider = new BindingDOMRpcProviderServiceAdapter( domRpcRegistry,codec); - rpcRegistry = new HeliumRpcProviderRegistry(consumer,provider); - } - - @Test - public void testGlobalRpcRegistrations() throws Exception { - final OpendaylightTestRpcServiceService one = Mockito.mock(OpendaylightTestRpcServiceService.class); - final OpendaylightTestRpcServiceService two = Mockito.mock(OpendaylightTestRpcServiceService.class); - - final RpcRegistration regOne = rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, one); - assertNotNull(regOne); - rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, two); - regOne.close(); - final RpcRegistration regTwo = rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, two); - assertNotNull(regTwo); - } - - - @Test - @Ignore - public void nonRoutedRegisteredAsRouted() { - final OpendaylightTestRpcServiceService one = Mockito.mock(OpendaylightTestRpcServiceService.class); - try { - final RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(OpendaylightTestRpcServiceService.class, one); - reg.registerPath(null, BAR_PATH); - fail("RpcIsNotRoutedException should be thrown"); - } catch (final RpcIsNotRoutedException e) { - assertNotNull(e.getMessage()); - } catch (final Exception e) { - fail("RpcIsNotRoutedException should be thrown"); - } - - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/codegen/impl/DefaultRuntimeCodeGeneratorTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/codegen/impl/DefaultRuntimeCodeGeneratorTest.java deleted file mode 100644 index 7a15619e95..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/codegen/impl/DefaultRuntimeCodeGeneratorTest.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.binding.codegen.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import java.util.ArrayList; -import java.util.List; -import javassist.ClassPool; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; -import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker; -import org.opendaylight.controller.sal.binding.test.mock.BarListener; -import org.opendaylight.controller.sal.binding.test.mock.BarUpdate; -import org.opendaylight.controller.sal.binding.test.mock.FlowDelete; -import org.opendaylight.controller.sal.binding.test.mock.FooListener; -import org.opendaylight.controller.sal.binding.test.mock.FooService; -import org.opendaylight.controller.sal.binding.test.mock.FooUpdate; -import org.opendaylight.controller.sal.binding.test.mock.ReferencableObject; -import org.opendaylight.controller.sal.binding.test.mock.ReferencableObjectKey; -import org.opendaylight.controller.sal.binding.test.mock.SimpleInput; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class DefaultRuntimeCodeGeneratorTest { - - private RuntimeCodeGenerator codeGenerator; - private NotificationInvokerFactory invokerFactory; - - @Before - public void initialize() { - this.codeGenerator = new DefaultRuntimeCodeGenerator(ClassPool.getDefault()); - this.invokerFactory = codeGenerator.getInvokerFactory(); - } - - @Test - public void testGenerateDirectProxy() { - FooService product = codeGenerator.getDirectProxyFor(FooService.class); - assertNotNull(product); - } - - @Test - public void testGenerateRouter() throws Exception { - RpcRouter product = codeGenerator.getRouterFor(FooService.class,"test"); - assertNotNull(product); - assertNotNull(product.getInvocationProxy()); - - assertEquals("2 fields should be generated.", 2, product.getInvocationProxy().getClass().getFields().length); - - verifyRouting(product); - } - - @Test - public void testInvoker() throws Exception { - - FooListenerImpl fooListener = new FooListenerImpl(); - - NotificationInvoker invokerFoo = invokerFactory.invokerFor(fooListener); - - - assertSame(fooListener,invokerFoo.getDelegate()); - assertNotNull(invokerFoo.getSupportedNotifications()); - assertEquals(1, invokerFoo.getSupportedNotifications().size()); - assertNotNull(invokerFoo.getInvocationProxy()); - - FooUpdateImpl fooOne = new FooUpdateImpl(); - invokerFoo.getInvocationProxy().onNotification(fooOne); - - assertEquals(1, fooListener.receivedFoos.size()); - assertSame(fooOne, fooListener.receivedFoos.get(0)); - - CompositeListenerImpl composite = new CompositeListenerImpl(); - - NotificationInvoker invokerComposite = invokerFactory.invokerFor(composite); - - assertNotNull(invokerComposite.getSupportedNotifications()); - assertEquals(3, invokerComposite.getSupportedNotifications().size()); - assertNotNull(invokerComposite.getInvocationProxy()); - - invokerComposite.getInvocationProxy().onNotification(fooOne); - - assertEquals(1, composite.receivedFoos.size()); - assertSame(fooOne, composite.receivedFoos.get(0)); - - assertEquals(0, composite.receivedBars.size()); - - BarUpdateImpl barOne = new BarUpdateImpl(); - - invokerComposite.getInvocationProxy().onNotification(barOne); - - assertEquals(1, composite.receivedFoos.size()); - assertEquals(1, composite.receivedBars.size()); - assertSame(barOne, composite.receivedBars.get(0)); - - } - - private void verifyRouting(final RpcRouter product) { - assertNotNull("Routing table should be initialized", product.getRoutingTable(BaseIdentity.class)); - - RpcRoutingTable routingTable = product.getRoutingTable(BaseIdentity.class); - - int servicesCount = 2; - int instancesPerService = 3; - - InstanceIdentifier[][] identifiers = identifiers(servicesCount, instancesPerService); - FooService service[] = new FooService[] { mock(FooService.class, "Instance 0"), - mock(FooService.class, "Instance 1") }; - - for (int i = 0; i < service.length; i++) { - for (InstanceIdentifier instance : identifiers[i]) { - routingTable.updateRoute(instance, service[i]); - } - } - - assertEquals("All instances should be registered.", servicesCount * instancesPerService, routingTable - .getRoutes().size()); - - SimpleInput[] instance_0_input = new SimpleInputImpl[] { new SimpleInputImpl(identifiers[0][0]), - new SimpleInputImpl(identifiers[0][1]), new SimpleInputImpl(identifiers[0][2]) }; - - SimpleInput[] instance_1_input = new SimpleInputImpl[] { new SimpleInputImpl(identifiers[1][0]), - new SimpleInputImpl(identifiers[1][1]), new SimpleInputImpl(identifiers[1][2]) }; - - // We test sending mock messages - - product.getInvocationProxy().simple(instance_0_input[0]); - verify(service[0]).simple(instance_0_input[0]); - - product.getInvocationProxy().simple(instance_0_input[1]); - product.getInvocationProxy().simple(instance_0_input[2]); - - verify(service[0]).simple(instance_0_input[1]); - verify(service[0]).simple(instance_0_input[2]); - - product.getInvocationProxy().simple(instance_1_input[0]); - - // We should have call to instance 1 - verify(service[1]).simple(instance_1_input[0]); - - /* - * Generated RPC service should throw illegalArgumentException - * with message if rpc input is null. - */ - try { - product.getInvocationProxy().simple(null); - fail("Generated RPC router should throw IllegalArgumentException on null input"); - } catch (IllegalArgumentException e){ - assertNotNull(e.getMessage()); - } - - - /* - * Generated RPC service should throw illegalArgumentException - * with message if rpc route is null. - */ - try { - SimpleInput withoutValue = new SimpleInputImpl(null); - product.getInvocationProxy().simple(withoutValue); - fail("Generated RPC router should throw IllegalArgumentException on null value for route"); - } catch (IllegalArgumentException e){ - assertNotNull(e.getMessage()); - } - - } - - private InstanceIdentifier[][] identifiers(final int serviceSize, final int instancesPerService) { - InstanceIdentifier[][] ret = new InstanceIdentifier[serviceSize][]; - int service = 0; - for (int i = 0; i < serviceSize; i++) { - - InstanceIdentifier[] instanceIdentifiers = new InstanceIdentifier[instancesPerService]; - ret[i] = instanceIdentifiers; - for (int id = 0; id < instancesPerService; id++) { - instanceIdentifiers[id] = referencableIdentifier(service * instancesPerService + id); - } - service++; - } - - return ret; - } - - private InstanceIdentifier referencableIdentifier(final int i) { - return InstanceIdentifier.builder(ReferencableObject.class, new ReferencableObjectKey(i)).build(); - } - - private static class SimpleInputImpl implements SimpleInput { - private final InstanceIdentifier identifier; - - public SimpleInputImpl(final InstanceIdentifier _identifier) { - this.identifier = _identifier; - } - - @Override - public > E getAugmentation(final Class augmentationType) { - return null; - } - - @Override - public InstanceIdentifier getIdentifier() { - return this.identifier; - } - - @Override - public Class getImplementedInterface() { - return SimpleInput.class; - } - } - - private static class FooUpdateImpl implements FooUpdate { - @Override - public Class getImplementedInterface() { - return FooUpdate.class; - } - } - - private static class BarUpdateImpl implements BarUpdate { - @Override - public Class getImplementedInterface() { - return BarUpdate.class; - } - - @Override - public InstanceIdentifier getInheritedIdentifier() { - return null; - } - } - - private static class FooListenerImpl implements FooListener { - - List receivedFoos = new ArrayList<>(); - - @Override - public void onFooUpdate(final FooUpdate notification) { - receivedFoos.add(notification); - } - - } - - private static class CompositeListenerImpl extends FooListenerImpl implements BarListener { - - List receivedBars = new ArrayList<>(); - List receivedDeletes = new ArrayList<>(); - - @Override - public void onBarUpdate(final BarUpdate notification) { - receivedBars.add(notification); - } - - @Override - public void onFlowDelete(final FlowDelete notification) { - receivedDeletes.add(notification); - } - - } -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolderTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolderTest.java deleted file mode 100644 index 0e4c5ccb84..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolderTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.binding.codegen.impl; - -import com.google.common.util.concurrent.ListeningExecutorService; -import java.lang.reflect.Field; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Ignore -public class SingletonHolderTest { - private static final Logger logger = LoggerFactory.getLogger(SingletonHolderTest.class); - - @Test - public void testNotificationExecutor() throws Exception { - ListeningExecutorService executor = SingletonHolder.getDefaultNotificationExecutor(); - ThreadPoolExecutor tpExecutor = (ThreadPoolExecutor) setAccessible(executor.getClass().getDeclaredField("delegate")).get(executor); - BlockingQueue queue = tpExecutor.getQueue(); - - for (int idx = 0; idx < 100; idx++) { - final int idx2 = idx; - logger.info("Adding {}\t{}\t{}", idx, queue.size(), tpExecutor.getActiveCount()); - executor.execute(new Runnable() { - - @Override - public void run() { - logger.info("in {}", idx2); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - logger.info("out {}", idx2); - } - }); - } - executor.shutdown(); - executor.awaitTermination(10, TimeUnit.SECONDS); - } - - private static Field setAccessible(Field field) { - field.setAccessible(true); - return field; - } -} diff --git a/opendaylight/md-sal/sal-binding-config/pom.xml b/opendaylight/md-sal/sal-binding-config/pom.xml index 39aece4233..d28faaeaf2 100644 --- a/opendaylight/md-sal/sal-binding-config/pom.xml +++ b/opendaylight/md-sal/sal-binding-config/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-binding-config bundle diff --git a/opendaylight/md-sal/sal-binding-dom-it/pom.xml b/opendaylight/md-sal/sal-binding-dom-it/pom.xml index d6a5e498b6..f7b03eadfd 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-dom-it/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-binding-dom-it jar diff --git a/opendaylight/md-sal/sal-binding-it/pom.xml b/opendaylight/md-sal/sal-binding-it/pom.xml index 7c6710fdbb..31bcbfd008 100644 --- a/opendaylight/md-sal/sal-binding-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-it/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-binding-it diff --git a/opendaylight/md-sal/sal-binding-util/pom.xml b/opendaylight/md-sal/sal-binding-util/pom.xml index efe2e84507..efa17a10a8 100644 --- a/opendaylight/md-sal/sal-binding-util/pom.xml +++ b/opendaylight/md-sal/sal-binding-util/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-binding-util bundle diff --git a/opendaylight/md-sal/sal-clustering-commons/pom.xml b/opendaylight/md-sal/sal-clustering-commons/pom.xml index 35fa535da6..6c6dd9d362 100644 --- a/opendaylight/md-sal/sal-clustering-commons/pom.xml +++ b/opendaylight/md-sal/sal-clustering-commons/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-clustering-commons diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java index ec35b03b0a..23c95ecc99 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java @@ -7,29 +7,30 @@ */ package org.opendaylight.controller.cluster.notifications; -import java.io.Serializable; +import com.google.common.base.Preconditions; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** - * A message initiated internally from the RaftActor when some state of a leader has changed + * A local message initiated internally from the RaftActor when some state of a leader has changed. * * @author Thomas Pantelis */ -public class LeaderStateChanged implements Serializable { - private static final long serialVersionUID = 1L; - +public class LeaderStateChanged { private final String memberId; private final String leaderId; - public LeaderStateChanged(String memberId, String leaderId) { - this.memberId = memberId; + public LeaderStateChanged(@Nonnull String memberId, @Nullable String leaderId) { + this.memberId = Preconditions.checkNotNull(memberId); this.leaderId = leaderId; } - public String getMemberId() { + public @Nonnull String getMemberId() { return memberId; } - public String getLeaderId() { + public @Nullable String getLeaderId() { return leaderId; } diff --git a/opendaylight/md-sal/sal-clustering-config/pom.xml b/opendaylight/md-sal/sal-clustering-config/pom.xml index 57da717daf..29d8ae41df 100644 --- a/opendaylight/md-sal/sal-clustering-config/pom.xml +++ b/opendaylight/md-sal/sal-clustering-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-clustering-config Configuration files for md-sal clustering diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf index e72f4b2675..8d65e59dfe 100644 --- a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf @@ -56,6 +56,16 @@ odl-cluster-data { ] } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + } } } diff --git a/opendaylight/md-sal/sal-common-api/pom.xml b/opendaylight/md-sal/sal-common-api/pom.xml index 6af20c0fb8..bd3df42c38 100644 --- a/opendaylight/md-sal/sal-common-api/pom.xml +++ b/opendaylight/md-sal/sal-common-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-common-api diff --git a/opendaylight/md-sal/sal-common-impl/pom.xml b/opendaylight/md-sal/sal-common-impl/pom.xml index 542a1f3905..56392dd922 100644 --- a/opendaylight/md-sal/sal-common-impl/pom.xml +++ b/opendaylight/md-sal/sal-common-impl/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-common-impl bundle diff --git a/opendaylight/md-sal/sal-common-util/pom.xml b/opendaylight/md-sal/sal-common-util/pom.xml index b285c991e5..da0b47025a 100644 --- a/opendaylight/md-sal/sal-common-util/pom.xml +++ b/opendaylight/md-sal/sal-common-util/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-common-util diff --git a/opendaylight/md-sal/sal-common/pom.xml b/opendaylight/md-sal/sal-common/pom.xml index e5450b2487..119ae52a63 100644 --- a/opendaylight/md-sal/sal-common/pom.xml +++ b/opendaylight/md-sal/sal-common/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-common diff --git a/opendaylight/md-sal/sal-connector-api/pom.xml b/opendaylight/md-sal/sal-connector-api/pom.xml index e45e24dd56..4a6d74e9eb 100644 --- a/opendaylight/md-sal/sal-connector-api/pom.xml +++ b/opendaylight/md-sal/sal-connector-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-connector-api diff --git a/opendaylight/md-sal/sal-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-distributed-datastore/pom.xml index 27788fc2ee..91526eb3cd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/pom.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-distributed-datastore bundle diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java new file mode 100644 index 0000000000..833cb49462 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +import static com.google.common.base.Preconditions.checkState; +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.EnumMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; +import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; +import org.opendaylight.controller.sal.core.spi.data.DOMStore; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory + implements DOMDataBroker, AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMBroker.class); + + private final AtomicLong txNum = new AtomicLong(); + private final AtomicLong chainNum = new AtomicLong(); + private final Map, DOMDataBrokerExtension> extensions; + private volatile AutoCloseable closeable; + + protected AbstractDOMBroker(final Map datastores) { + super(datastores); + + boolean treeChange = true; + for (DOMStore ds : datastores.values()) { + if (!(ds instanceof DOMStoreTreeChangePublisher)) { + treeChange = false; + break; + } + } + + if (treeChange) { + extensions = ImmutableMap., DOMDataBrokerExtension>of(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { + @Override + public ListenerRegistration registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) { + DOMStore publisher = getTxFactories().get(treeId.getDatastoreType()); + checkState(publisher != null, "Requested logical data store is not available."); + + return ((DOMStoreTreeChangePublisher) publisher).registerTreeChangeListener(treeId.getRootIdentifier(), listener); + } + }); + } else { + extensions = Collections.emptyMap(); + } + } + + public void setCloseable(final AutoCloseable closeable) { + this.closeable = closeable; + } + + @Override + public void close() { + super.close(); + + if (closeable != null) { + try { + closeable.close(); + } catch (Exception e) { + LOG.debug("Error closing instance", e); + } + } + } + + @Override + protected Object newTransactionIdentifier() { + return "DOM-" + txNum.getAndIncrement(); + } + + @Override + public ListenerRegistration registerDataChangeListener(final LogicalDatastoreType store, + final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) { + + DOMStore potentialStore = getTxFactories().get(store); + checkState(potentialStore != null, "Requested logical data store is not available."); + return potentialStore.registerChangeListener(path, listener, triggeringScope); + } + + @Override + public Map, DOMDataBrokerExtension> getSupportedExtensions() { + return extensions; + } + + @Override + public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { + checkNotClosed(); + + final Map backingChains = new EnumMap<>(LogicalDatastoreType.class); + for (Map.Entry entry : getTxFactories().entrySet()) { + backingChains.put(entry.getKey(), entry.getValue().createTransactionChain()); + } + + final long chainId = chainNum.getAndIncrement(); + LOG.debug("Transaction chain {} created with listener {}, backing store chains {}", chainId, listener, + backingChains); + return new DOMBrokerTransactionChain(chainId, backingChains, this, listener); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java new file mode 100644 index 0000000000..98fea88f63 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +import com.google.common.base.Preconditions; +import java.util.Collection; +import java.util.EnumMap; +import java.util.Map; +import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public abstract class AbstractDOMBrokerTransaction implements + AsyncTransaction> { + + private Map backingTxs; + private final Object identifier; + private final Map storeTxFactories; + + /** + * + * Creates new composite Transactions. + * + * @param identifier + * Identifier of transaction. + */ + protected AbstractDOMBrokerTransaction(final Object identifier, Map storeTxFactories) { + this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null"); + this.storeTxFactories = Preconditions.checkNotNull(storeTxFactories, "Store Transaction Factories should not be null"); + this.backingTxs = new EnumMap(LogicalDatastoreType.class); + } + + /** + * Returns subtransaction associated with supplied key. + * + * @param key + * @return + * @throws NullPointerException + * if key is null + * @throws IllegalArgumentException + * if no subtransaction is associated with key. + */ + protected final T getSubtransaction(final K key) { + Preconditions.checkNotNull(key, "key must not be null."); + + T ret = backingTxs.get(key); + if(ret == null){ + ret = createTransaction(key); + backingTxs.put(key, ret); + } + Preconditions.checkArgument(ret != null, "No subtransaction associated with %s", key); + return ret; + } + + protected abstract T createTransaction(final K key); + + /** + * Returns immutable Iterable of all subtransactions. + * + */ + protected Collection getSubtransactions() { + return backingTxs.values(); + } + + @Override + public Object getIdentifier() { + return identifier; + } + + protected void closeSubtransactions() { + /* + * We share one exception for all failures, which are added + * as supressedExceptions to it. + */ + IllegalStateException failure = null; + for (T subtransaction : backingTxs.values()) { + try { + subtransaction.close(); + } catch (Exception e) { + // If we did not allocated failure we allocate it + if (failure == null) { + failure = new IllegalStateException("Uncaught exception occured during closing transaction", e); + } else { + // We update it with additional exceptions, which occurred during error. + failure.addSuppressed(e); + } + } + } + // If we have failure, we throw it at after all attempts to close. + if (failure != null) { + throw failure; + } + } + + protected DOMStoreTransactionFactory getTxFactory(K type){ + return storeTxFactories.get(type); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java new file mode 100644 index 0000000000..2187c6e0f9 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.CheckedFuture; +import java.util.Collection; +import java.util.EnumMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory; + +public abstract class AbstractDOMTransactionFactory implements AutoCloseable { + private static final AtomicIntegerFieldUpdater UPDATER = + AtomicIntegerFieldUpdater.newUpdater(AbstractDOMTransactionFactory.class, "closed"); + private final Map storeTxFactories; + private volatile int closed = 0; + + protected AbstractDOMTransactionFactory(final Map txFactories) { + this.storeTxFactories = new EnumMap<>(txFactories); + } + + /** + * Implementations must return unique identifier for each and every call of + * this method; + * + * @return new Unique transaction identifier. + */ + protected abstract Object newTransactionIdentifier(); + + /** + * + * @param transaction + * @param cohorts + * @return + */ + protected abstract CheckedFuture submit(final DOMDataWriteTransaction transaction, + final Collection cohorts); + + /** + * + * @return + */ + public final DOMDataReadOnlyTransaction newReadOnlyTransaction() { + checkNotClosed(); + + return new DOMBrokerReadOnlyTransaction(newTransactionIdentifier(), storeTxFactories); + } + + + /** + * + * @return + */ + public final DOMDataWriteTransaction newWriteOnlyTransaction() { + checkNotClosed(); + + return new DOMBrokerWriteOnlyTransaction(newTransactionIdentifier(), storeTxFactories, this); + } + + + /** + * + * @return + */ + public final DOMDataReadWriteTransaction newReadWriteTransaction() { + checkNotClosed(); + + return new DOMBrokerReadWriteTransaction<>(newTransactionIdentifier(), storeTxFactories, this); + } + + /** + * Convenience accessor of backing factories intended to be used only by + * finalization of this class. + * + * Note: + * Finalization of this class may want to access other functionality of + * supplied Transaction factories. + * + * @return Map of backing transaction factories. + */ + protected final Map getTxFactories() { + return storeTxFactories; + } + + /** + * Checks if instance is not closed. + * + * @throws IllegalStateException If instance of this class was closed. + * + */ + protected final void checkNotClosed() { + Preconditions.checkState(closed == 0, "Transaction factory was closed. No further operations allowed."); + } + + @Override + public void close() { + final boolean success = UPDATER.compareAndSet(this, 0, 1); + Preconditions.checkState(success, "Transaction factory was already closed"); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java new file mode 100644 index 0000000000..656ced37c1 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.CheckedFuture; +import java.util.Map; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class DOMBrokerReadOnlyTransaction + extends AbstractDOMBrokerTransaction + implements DOMDataReadOnlyTransaction { + /** + * Creates new composite Transactions. + * + * @param identifier Identifier of transaction. + */ + protected DOMBrokerReadOnlyTransaction(Object identifier, Map storeTxFactories) { + super(identifier, storeTxFactories); + } + + @Override + public CheckedFuture>, ReadFailedException> read( + final LogicalDatastoreType store, final YangInstanceIdentifier path) { + return getSubtransaction(store).read(path); + } + + @Override + public CheckedFuture exists( + final LogicalDatastoreType store, + final YangInstanceIdentifier path) { + return getSubtransaction(store).exists(path); + } + + @Override + public void close() { + closeSubtransactions(); + } + + @Override + protected T createTransaction(LogicalDatastoreType key) { + return (T) getTxFactory(key).newReadOnlyTransaction(); + } + + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java new file mode 100644 index 0000000000..efa7226219 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.CheckedFuture; +import java.util.Map; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class DOMBrokerReadWriteTransaction + extends DOMBrokerWriteOnlyTransaction implements DOMDataReadWriteTransaction { + /** + * Creates new composite Transactions. + * + * @param identifier Identifier of transaction. + * @param storeTxFactories + */ + protected DOMBrokerReadWriteTransaction(Object identifier, Map storeTxFactories, final AbstractDOMTransactionFactory commitImpl) { + super(identifier, storeTxFactories, commitImpl); + } + + @Override + public CheckedFuture>, ReadFailedException> read( + final LogicalDatastoreType store, final YangInstanceIdentifier path) { + return getSubtransaction(store).read(path); + } + + @Override + public CheckedFuture exists( + final LogicalDatastoreType store, + final YangInstanceIdentifier path) { + return getSubtransaction(store).exists(path); + } + + @Override + protected DOMStoreReadWriteTransaction createTransaction(LogicalDatastoreType key) { + return getTxFactory(key).newReadWriteTransaction(); + } + + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java new file mode 100644 index 0000000000..9610647fff --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +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.Collection; +import java.util.Map; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory + implements DOMTransactionChain { + private static enum State { + RUNNING, + CLOSING, + CLOSED, + FAILED, + } + + private static final AtomicIntegerFieldUpdater COUNTER_UPDATER = + AtomicIntegerFieldUpdater.newUpdater(DOMBrokerTransactionChain.class, "counter"); + private static final AtomicReferenceFieldUpdater STATE_UPDATER = + AtomicReferenceFieldUpdater.newUpdater(DOMBrokerTransactionChain.class, State.class, "state"); + private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerTransactionChain.class); + private final AtomicLong txNum = new AtomicLong(); + private final AbstractDOMBroker broker; + private final TransactionChainListener listener; + private final long chainId; + + private volatile State state = State.RUNNING; + private volatile int counter = 0; + + /** + * + * @param chainId + * ID of transaction chain + * @param chains + * Backing {@link DOMStoreTransactionChain}s. + * @param listener + * Listener, which listens on transaction chain events. + * @throws NullPointerException + * If any of arguments is null. + */ + public DOMBrokerTransactionChain(final long chainId, + final Map chains, + AbstractDOMBroker broker, final TransactionChainListener listener) { + super(chains); + this.chainId = chainId; + this.broker = Preconditions.checkNotNull(broker); + this.listener = Preconditions.checkNotNull(listener); + } + + private void checkNotFailed() { + Preconditions.checkState(state != State.FAILED, "Transaction chain has failed"); + } + + @Override + protected Object newTransactionIdentifier() { + return "DOM-CHAIN-" + chainId + "-" + txNum.getAndIncrement(); + } + + @Override + public CheckedFuture submit( + final DOMDataWriteTransaction transaction, final Collection cohorts) { + checkNotFailed(); + checkNotClosed(); + + final CheckedFuture ret = broker.submit(transaction, cohorts); + + COUNTER_UPDATER.incrementAndGet(this); + Futures.addCallback(ret, new FutureCallback() { + @Override + public void onSuccess(final Void result) { + transactionCompleted(); + } + + @Override + public void onFailure(final Throwable t) { + transactionFailed(transaction, t); + } + }); + + return ret; + } + + @Override + public void close() { + final boolean success = STATE_UPDATER.compareAndSet(this, State.RUNNING, State.CLOSING); + if (!success) { + LOG.debug("Chain {} is no longer running", this); + return; + } + + super.close(); + for (DOMStoreTransactionChain subChain : getTxFactories().values()) { + subChain.close(); + } + + if (counter == 0) { + finishClose(); + } + } + + private void finishClose() { + state = State.CLOSED; + listener.onTransactionChainSuccessful(this); + } + + private void transactionCompleted() { + if (COUNTER_UPDATER.decrementAndGet(this) == 0 && state == State.CLOSING) { + finishClose(); + } + } + + private void transactionFailed(final DOMDataWriteTransaction tx, final Throwable cause) { + state = State.FAILED; + LOG.debug("Transaction chain {} failed.", this, cause); + listener.onTransactionChainFailed(this, tx, cause); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerWriteOnlyTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerWriteOnlyTransaction.java new file mode 100644 index 0000000000..6d00210629 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerWriteOnlyTransaction.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.cluster.databroker; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DOMBrokerWriteOnlyTransaction + extends AbstractDOMBrokerTransaction implements DOMDataWriteTransaction { + + private static final AtomicReferenceFieldUpdater IMPL_UPDATER = + AtomicReferenceFieldUpdater.newUpdater(DOMBrokerWriteOnlyTransaction.class, AbstractDOMTransactionFactory.class, "commitImpl"); + @SuppressWarnings("rawtypes") + private static final AtomicReferenceFieldUpdater FUTURE_UPDATER = + AtomicReferenceFieldUpdater.newUpdater(DOMBrokerWriteOnlyTransaction.class, Future.class, "commitFuture"); + private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerWriteOnlyTransaction.class); + private static final Future CANCELLED_FUTURE = Futures.immediateCancelledFuture(); + + /** + * Implementation of real commit. It also acts as an indication that + * the transaction is running -- which we flip atomically using + * {@link #IMPL_UPDATER}. + */ + private volatile AbstractDOMTransactionFactory commitImpl; + + /** + * Future task of transaction commit. It starts off as null, but is + * set appropriately on {@link #submit()} and {@link #cancel()} via + * {@link AtomicReferenceFieldUpdater#lazySet(Object, Object)}. + * + * Lazy set is safe for use because it is only referenced to in the + * {@link #cancel()} slow path, where we will busy-wait for it. The + * fast path gets the benefit of a store-store barrier instead of the + * usual store-load barrier. + */ + private volatile Future commitFuture; + + protected DOMBrokerWriteOnlyTransaction(final Object identifier, + Map storeTxFactories, final AbstractDOMTransactionFactory commitImpl) { + super(identifier, storeTxFactories); + this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null."); + } + + @Override + protected T createTransaction(LogicalDatastoreType key) { + // FIXME : Casting shouldn't be necessary here + return (T) getTxFactory(key).newWriteOnlyTransaction(); + } + + @Override + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + checkRunning(commitImpl); + getSubtransaction(store).write(path, data); + } + + @Override + public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { + checkRunning(commitImpl); + getSubtransaction(store).delete(path); + } + + @Override + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + checkRunning(commitImpl); + getSubtransaction(store).merge(path, data); + } + + @Override + public boolean cancel() { + final AbstractDOMTransactionFactory impl = IMPL_UPDATER.getAndSet(this, null); + if (impl != null) { + LOG.trace("Transaction {} cancelled before submit", getIdentifier()); + FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE); + closeSubtransactions(); + return true; + } + + // The transaction is in process of being submitted or cancelled. Busy-wait + // for the corresponding future. + Future future; + do { + future = commitFuture; + } while (future == null); + + return future.cancel(false); + } + + @Deprecated + @Override + public ListenableFuture> commit() { + return AbstractDataTransaction.convertToLegacyCommitFuture(submit()); + } + + @Override + public CheckedFuture submit() { + final AbstractDOMTransactionFactory impl = IMPL_UPDATER.getAndSet(this, null); + checkRunning(impl); + + final Collection txns = getSubtransactions(); + final Collection cohorts = new ArrayList<>(txns.size()); + + // FIXME: deal with errors thrown by backed (ready and submit can fail in theory) + for (DOMStoreWriteTransaction txn : txns) { + cohorts.add(txn.ready()); + } + + final CheckedFuture ret = impl.submit(this, cohorts); + FUTURE_UPDATER.lazySet(this, ret); + return ret; + } + + private void checkRunning(final AbstractDOMTransactionFactory impl) { + Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier()); + } + +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ChainedTransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ChainedTransactionProxy.java index f1f33bfc93..9a800c1659 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ChainedTransactionProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ChainedTransactionProxy.java @@ -7,9 +7,9 @@ */ package org.opendaylight.controller.cluster.datastore; -import akka.actor.ActorSelection; import akka.dispatch.OnComplete; import java.util.List; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +59,7 @@ final class ChainedTransactionProxy extends TransactionProxy { * previous Tx's ready operations haven't completed yet. */ @Override - protected Future sendFindPrimaryShardAsync(final String shardName) { + protected Future sendFindPrimaryShardAsync(final String shardName) { // Check if there are any previous ready Futures, otherwise let the super class handle it. if(previousReadyFutures.isEmpty()) { return super.sendFindPrimaryShardAsync(shardName); @@ -75,7 +75,7 @@ final class ChainedTransactionProxy extends TransactionProxy { previousReadyFutures, getActorContext().getClientDispatcher()); // Add a callback for completion of the combined Futures. - final Promise returnPromise = akka.dispatch.Futures.promise(); + final Promise returnPromise = akka.dispatch.Futures.promise(); OnComplete> onComplete = new OnComplete>() { @Override public void onComplete(Throwable failure, Iterable notUsed) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBroker.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBroker.java index 538f2981da..b48e5946da 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBroker.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBroker.java @@ -21,10 +21,10 @@ import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; +import org.opendaylight.controller.cluster.databroker.AbstractDOMBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.broker.impl.AbstractDOMDataBroker; import org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper; import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; @@ -34,13 +34,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implementation of DOMDataCommitExecutor that coordinates transaction commits concurrently. The 3 + * ConcurrentDOMDataBroker commits transactions concurrently. The 3 * commit phases (canCommit, preCommit, and commit) are performed serially and non-blocking * (ie async) per transaction but multiple transaction commits can run concurrent. * * @author Thomas Pantelis */ -public class ConcurrentDOMDataBroker extends AbstractDOMDataBroker { +public class ConcurrentDOMDataBroker extends AbstractDOMBroker { private static final Logger LOG = LoggerFactory.getLogger(ConcurrentDOMDataBroker.class); private static final String CAN_COMMIT = "CAN_COMMIT"; private static final String PRE_COMMIT = "PRE_COMMIT"; @@ -76,6 +76,10 @@ public class ConcurrentDOMDataBroker extends AbstractDOMDataBroker { Preconditions.checkArgument(cohorts != null, "Cohorts must not be null."); LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier()); + if(cohorts.isEmpty()){ + return Futures.immediateCheckedFuture(null); + } + final AsyncNotifyingSettableFuture clientSubmitFuture = new AsyncNotifyingSettableFuture(clientFutureCallbackExecutor); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java index 124724b9c2..1a27f2e4fc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java @@ -11,6 +11,7 @@ import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.PoisonPill; import akka.dispatch.OnComplete; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException; @@ -106,9 +107,19 @@ final class DataTreeChangeListenerProxy ext } else { RegisterDataTreeChangeListenerReply reply = (RegisterDataTreeChangeListenerReply) result; setListenerRegistrationActor(actorContext.actorSelection( - reply.getListenerRegistrationPath().path())); + reply.getListenerRegistrationPath())); } } }, actorContext.getClientDispatcher()); } + + @VisibleForTesting + ActorSelection getListenerRegistrationActor() { + return listenerRegistrationActor; + } + + @VisibleForTesting + ActorRef getDataChangeListenerActor() { + return dataChangeListenerActor; + } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index 62d3259a71..e62e918e5e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -48,12 +48,14 @@ import org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTran import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener; +import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; import org.opendaylight.controller.cluster.datastore.modification.Modification; import org.opendaylight.controller.cluster.datastore.modification.ModificationPayload; import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; import org.opendaylight.controller.cluster.datastore.utils.MessageTracker; +import org.opendaylight.controller.cluster.notifications.LeaderStateChanged; import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener; import org.opendaylight.controller.cluster.notifications.RoleChangeNotifier; import org.opendaylight.controller.cluster.raft.RaftActor; @@ -63,6 +65,7 @@ import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyn import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; @@ -265,6 +268,12 @@ public class Shard extends RaftActor { return roleChangeNotifier; } + @Override + protected LeaderStateChanged newLeaderStateChanged(String memberId, String leaderId) { + return new ShardLeaderStateChanged(memberId, leaderId, + isLeader() ? Optional.of(store.getDataTree()) : Optional.absent()); + } + private void onDatastoreContext(DatastoreContext context) { datastoreContext = context; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java index fbe699223c..56c5eb65bf 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java @@ -115,7 +115,7 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { if (chain != null) { chain.close(); } else { - LOG.warn("Closing non-existent transaction chain {}", transactionChainId); + LOG.debug("Closing non-existent transaction chain {}", transactionChainId); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java index cff44b13cb..f4fa7b3a97 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java @@ -24,6 +24,7 @@ import akka.persistence.RecoveryFailure; import akka.serialization.Serialization; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Objects; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.base.Supplier; @@ -54,17 +55,20 @@ import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shardmanager.Sha import org.opendaylight.controller.cluster.datastore.messages.ActorInitialized; import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved; -import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; +import org.opendaylight.controller.cluster.datastore.messages.RemoteFindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound; +import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; -import org.opendaylight.controller.cluster.notifications.LeaderStateChanged; import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener; import org.opendaylight.controller.cluster.notifications.RoleChangeNotification; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; @@ -185,27 +189,31 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { onFollowerInitialSyncStatus((FollowerInitialSyncUpStatus) message); } else if(message instanceof ShardNotInitializedTimeout) { onShardNotInitializedTimeout((ShardNotInitializedTimeout)message); - } else if(message instanceof LeaderStateChanged) { - onLeaderStateChanged((LeaderStateChanged)message); + } else if(message instanceof ShardLeaderStateChanged) { + onLeaderStateChanged((ShardLeaderStateChanged)message); } else { unknownMessage(message); } } - private void onLeaderStateChanged(LeaderStateChanged leaderStateChanged) { + private void checkReady(){ + if (isReadyWithLeaderId()) { + LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}", + persistenceId(), type, waitTillReadyCountdownLatch.getCount()); + + waitTillReadyCountdownLatch.countDown(); + } + } + + private void onLeaderStateChanged(ShardLeaderStateChanged leaderStateChanged) { LOG.info("{}: Received LeaderStateChanged message: {}", persistenceId(), leaderStateChanged); ShardInformation shardInformation = findShardInformation(leaderStateChanged.getMemberId()); if(shardInformation != null) { + shardInformation.setLocalDataTree(leaderStateChanged.getLocalShardDataTree()); shardInformation.setLeaderId(leaderStateChanged.getLeaderId()); - if (isReadyWithLeaderId()) { - LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}", - persistenceId(), type, waitTillReadyCountdownLatch.getCount()); - - waitTillReadyCountdownLatch.countDown(); - } - + checkReady(); } else { LOG.debug("No shard found with member Id {}", leaderStateChanged.getMemberId()); } @@ -249,14 +257,7 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { ShardInformation shardInformation = findShardInformation(roleChanged.getMemberId()); if(shardInformation != null) { shardInformation.setRole(roleChanged.getNewRole()); - - if (isReadyWithLeaderId()) { - LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}", - persistenceId(), type, waitTillReadyCountdownLatch.getCount()); - - waitTillReadyCountdownLatch.countDown(); - } - + checkReady(); mBean.setSyncStatus(isInSync()); } } @@ -439,6 +440,8 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { info.updatePeerAddress(getShardIdentifier(memberName, shardName).toString(), getShardActorPath(shardName, memberName), getSelf()); } + + checkReady(); } private void onDatastoreContext(DatastoreContext context) { @@ -510,6 +513,7 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { LOG.debug("{}: In findPrimary: {}", persistenceId(), message); final String shardName = message.getShardName(); + final boolean canReturnLocalShardState = !(message instanceof RemoteFindPrimary); // First see if the there is a local replica for the shard final ShardInformation info = localShards.get(shardName); @@ -517,7 +521,10 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { sendResponse(info, message.isWaitUntilReady(), true, new Supplier() { @Override public Object get() { - Object found = new PrimaryFound(info.getSerializedLeaderActor()); + String primaryPath = info.getSerializedLeaderActor(); + Object found = canReturnLocalShardState && info.isLeader() ? + new LocalPrimaryShardFound(primaryPath, info.getLocalShardDataTree().get()) : + new RemotePrimaryShardFound(primaryPath); if(LOG.isDebugEnabled()) { LOG.debug("{}: Found primary for {}: {}", persistenceId(), shardName, found); @@ -537,7 +544,8 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { LOG.debug("{}: findPrimary for {} forwarding to remote ShardManager {}", persistenceId(), shardName, path); - getContext().actorSelection(path).forward(message, getContext()); + getContext().actorSelection(path).forward(new RemoteFindPrimary(shardName, + message.isWaitUntilReady()), getContext()); return; } } @@ -665,6 +673,7 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { private ActorRef actor; private ActorPath actorPath; private final Map peerAddresses; + private Optional localShardDataTree; // flag that determines if the actor is ready for business private boolean actorInitialized = false; @@ -703,6 +712,14 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { return shardId; } + void setLocalDataTree(Optional localShardDataTree) { + this.localShardDataTree = localShardDataTree; + } + + Optional getLocalShardDataTree() { + return localShardDataTree; + } + Map getPeerAddresses() { return peerAddresses; } @@ -731,7 +748,7 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering { } boolean isShardReadyWithLeaderId() { - return isShardReady() && (isLeader() || peerAddresses.containsKey(leaderId)); + return isShardReady() && (isLeader() || peerAddresses.get(leaderId) != null); } boolean isShardInitialized() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java index 5531b5f540..cf261cbd2a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java @@ -112,7 +112,7 @@ public class TransactionChainProxy implements DOMStoreTransactionChain { currentState = CLOSED_STATE; // Send a close transaction chain request to each and every shard - actorContext.broadcast(new CloseTransactionChain(transactionChainId)); + actorContext.broadcast(new CloseTransactionChain(transactionChainId).toSerializable()); } private ChainedTransactionProxy allocateWriteTransaction(TransactionProxy.TransactionType type) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java index 361a221dd5..e397ab501c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java @@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.controller.cluster.datastore.compat.PreLithiumTransactionContextImpl; import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; import org.opendaylight.controller.cluster.datastore.utils.NormalizedNodeAggregator; @@ -477,7 +478,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction sendFindPrimaryShardAsync(String shardName) { + protected Future sendFindPrimaryShardAsync(String shardName) { return actorContext.findPrimaryShardAsync(shardName); } @@ -497,20 +498,20 @@ public class TransactionProxy extends AbstractDOMStoreTransaction findPrimaryFuture = sendFindPrimaryShardAsync(shardName); + Future findPrimaryFuture = sendFindPrimaryShardAsync(shardName); final TransactionFutureCallback newTxFutureCallback = new TransactionFutureCallback(this, shardName); txFutureCallback = newTxFutureCallback; txFutureCallbackMap.put(shardName, txFutureCallback); - findPrimaryFuture.onComplete(new OnComplete() { + findPrimaryFuture.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, ActorSelection primaryShard) { + public void onComplete(Throwable failure, PrimaryShardInfo primaryShardInfo) { if(failure != null) { newTxFutureCallback.createTransactionContext(failure, null); } else { - newTxFutureCallback.setPrimaryShard(primaryShard); + newTxFutureCallback.setPrimaryShard(primaryShardInfo.getPrimaryShardActor()); } } }, actorContext.getClientDispatcher()); 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 2c18eaa86f..0b7fcf0ed5 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 @@ -21,7 +21,7 @@ public class FindPrimary implements Serializable { private final String shardName; private final boolean waitUntilReady; - public FindPrimary(String shardName, boolean waitUntilReady){ + public FindPrimary(String shardName, boolean waitUntilReady) { Preconditions.checkNotNull(shardName, "shardName should not be null"); @@ -40,8 +40,8 @@ public class FindPrimary implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("FindPrimary [shardName=").append(shardName).append(", waitUntilReady=").append(waitUntilReady) - .append("]"); + builder.append(getClass().getName()).append(" [shardName=").append(shardName).append(", waitUntilReady=") + .append(waitUntilReady).append("]"); return builder.toString(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalPrimaryShardFound.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalPrimaryShardFound.java new file mode 100644 index 0000000000..e19dcd65b3 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/LocalPrimaryShardFound.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.messages; + +import com.google.common.base.Preconditions; +import javax.annotation.Nonnull; +import org.apache.commons.lang3.ObjectUtils; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; + +/** + * Local message sent in reply to FindPrimaryShard to indicate the primary shard is local to the caller. + * + * @author Thomas Pantelis + */ +public class LocalPrimaryShardFound { + + private final String primaryPath; + private final DataTree localShardDataTree; + + public LocalPrimaryShardFound(@Nonnull String primaryPath, @Nonnull DataTree localShardDataTree) { + this.primaryPath = Preconditions.checkNotNull(primaryPath); + this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree); + } + + public @Nonnull String getPrimaryPath() { + return primaryPath; + } + + public @Nonnull DataTree getLocalShardDataTree() { + return localShardDataTree; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("LocalPrimaryShardFound [primaryPath=").append(primaryPath).append(", localShardDataTree=") + .append(ObjectUtils.identityToString(localShardDataTree)).append("]"); + return builder.toString(); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java new file mode 100644 index 0000000000..bbeb1aa84b --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.messages; + +import akka.actor.ActorSelection; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import javax.annotation.Nonnull; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; + +/** + * Local message DTO that contains information about the primary shard. + * + * @author Thomas Pantelis + */ +public class PrimaryShardInfo { + private final ActorSelection primaryShardActor; + private final Optional localShardDataTree; + + public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, @Nonnull Optional localShardDataTree) { + this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor); + this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree); + } + + /** + * Returns an ActorSelection representing the primary shard actor. + */ + public @Nonnull ActorSelection getPrimaryShardActor() { + return primaryShardActor; + } + + /** + * Returns an Optional whose value contains the primary shard's DataTree if the primary shard is local + * to the caller. Otherwise the Optional value is absent. + */ + public @Nonnull Optional getLocalShardDataTree() { + return localShardDataTree; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListenerReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListenerReply.java index 88682ae7f3..4c950ce1f1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListenerReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListenerReply.java @@ -7,8 +7,10 @@ */ package org.opendaylight.controller.cluster.datastore.messages; +import akka.actor.ActorPath; import akka.actor.ActorRef; import com.google.common.base.Preconditions; + import java.io.Serializable; /** @@ -22,7 +24,7 @@ public final class RegisterDataTreeChangeListenerReply implements Serializable { this.listenerRegistrationPath = Preconditions.checkNotNull(listenerRegistrationPath); } - public ActorRef getListenerRegistrationPath() { - return listenerRegistrationPath; + public ActorPath getListenerRegistrationPath() { + return listenerRegistrationPath.path(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoteFindPrimary.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoteFindPrimary.java new file mode 100644 index 0000000000..820512e096 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemoteFindPrimary.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.messages; + +/** + * A remote message sent to locate the primary shard. + * + * @author Thomas Pantelis + */ +public class RemoteFindPrimary extends FindPrimary { + private static final long serialVersionUID = 1L; + + public RemoteFindPrimary(String shardName, boolean waitUntilReady) { + super(shardName, waitUntilReady); + } +} 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/RemotePrimaryShardFound.java similarity index 53% rename from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java rename to opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RemotePrimaryShardFound.java index 4c154d43ae..662eefd9d1 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/RemotePrimaryShardFound.java @@ -10,12 +10,15 @@ package org.opendaylight.controller.cluster.datastore.messages; import java.io.Serializable; -public class PrimaryFound implements Serializable { +/** + * Local or remote message sent in reply to FindPrimaryShard to indicate the primary shard is remote to the caller. + */ +public class RemotePrimaryShardFound implements Serializable { private static final long serialVersionUID = 1L; private final String primaryPath; - public PrimaryFound(final String primaryPath) { + public RemotePrimaryShardFound(final String primaryPath) { this.primaryPath = primaryPath; } @@ -23,33 +26,10 @@ public class PrimaryFound implements Serializable { return primaryPath; } - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - PrimaryFound that = (PrimaryFound) o; - - if (!primaryPath.equals(that.primaryPath)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - return primaryPath.hashCode(); - } - @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("PrimaryFound [primaryPath=").append(primaryPath).append("]"); + builder.append("RemotePrimaryShardFound [primaryPath=").append(primaryPath).append("]"); return builder.toString(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ShardLeaderStateChanged.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ShardLeaderStateChanged.java new file mode 100644 index 0000000000..d9a55ab1e9 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ShardLeaderStateChanged.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.messages; + +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import javax.annotation.Nonnull; +import org.opendaylight.controller.cluster.notifications.LeaderStateChanged; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; + +/** + * A local message derived from LeaderStateChanged containing additional Shard-specific info that is sent + * when some state of the shard leader has changed. This message is used by the ShardManager to maintain + * current Shard information. + * + * @author Thomas Pantelis + */ +public class ShardLeaderStateChanged extends LeaderStateChanged { + + private final Optional localShardDataTree; + + public ShardLeaderStateChanged(@Nonnull String memberId, @Nonnull String leaderId, + @Nonnull Optional localShardDataTree) { + super(memberId, leaderId); + this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree); + } + + public @Nonnull Optional getLocalShardDataTree() { + return localShardDataTree; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java index 17d988005f..73f1a8f328 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java @@ -42,11 +42,14 @@ import org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException; import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; -import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; +import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; import org.opendaylight.controller.cluster.reporting.MetricsReporter; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,7 +99,7 @@ public class ActorContext { private Timeout transactionCommitOperationTimeout; private Timeout shardInitializationTimeout; private final Dispatchers dispatchers; - private Cache> primaryShardActorSelectionCache; + private Cache> primaryShardInfoCache; private volatile SchemaContext schemaContext; private volatile boolean updated; @@ -141,7 +144,7 @@ public class ActorContext { shardInitializationTimeout = new Timeout(datastoreContext.getShardInitializationTimeout().duration().$times(2)); - primaryShardActorSelectionCache = CacheBuilder.newBuilder() + primaryShardInfoCache = CacheBuilder.newBuilder() .expireAfterWrite(datastoreContext.getShardLeaderElectionTimeout().duration().toMillis(), TimeUnit.MILLISECONDS) .build(); } @@ -196,24 +199,24 @@ public class ActorContext { return schemaContext; } - public Future findPrimaryShardAsync(final String shardName) { - Future ret = primaryShardActorSelectionCache.getIfPresent(shardName); + public Future findPrimaryShardAsync(final String shardName) { + Future ret = primaryShardInfoCache.getIfPresent(shardName); if(ret != null){ return ret; } Future future = executeOperationAsync(shardManager, new FindPrimary(shardName, true), shardInitializationTimeout); - return future.transform(new Mapper() { + return future.transform(new Mapper() { @Override - public ActorSelection checkedApply(Object response) throws Exception { - if(response instanceof PrimaryFound) { - PrimaryFound found = (PrimaryFound)response; - - LOG.debug("Primary found {}", found.getPrimaryPath()); - ActorSelection actorSelection = actorSystem.actorSelection(found.getPrimaryPath()); - primaryShardActorSelectionCache.put(shardName, Futures.successful(actorSelection)); - return actorSelection; + public PrimaryShardInfo checkedApply(Object response) throws Exception { + if(response instanceof RemotePrimaryShardFound) { + LOG.debug("findPrimaryShardAsync received: {}", response); + return onPrimaryShardFound(shardName, ((RemotePrimaryShardFound)response).getPrimaryPath(), null); + } else if(response instanceof LocalPrimaryShardFound) { + LOG.debug("findPrimaryShardAsync received: {}", response); + LocalPrimaryShardFound found = (LocalPrimaryShardFound)response; + return onPrimaryShardFound(shardName, found.getPrimaryPath(), found.getLocalShardDataTree()); } else if(response instanceof NotInitializedException) { throw (NotInitializedException)response; } else if(response instanceof PrimaryNotFoundException) { @@ -228,6 +231,14 @@ public class ActorContext { }, FIND_PRIMARY_FAILURE_TRANSFORMER, getClientDispatcher()); } + private PrimaryShardInfo onPrimaryShardFound(String shardName, String primaryActorPath, + DataTree localShardDataTree) { + ActorSelection actorSelection = actorSystem.actorSelection(primaryActorPath); + PrimaryShardInfo info = new PrimaryShardInfo(actorSelection, Optional.fromNullable(localShardDataTree)); + primaryShardInfoCache.put(shardName, Futures.successful(info)); + return info; + } + /** * Finds a local shard given its shard name and return it's ActorRef * @@ -387,15 +398,15 @@ public class ActorContext { public void broadcast(final Object message){ for(final String shardName : configuration.getAllShardNames()){ - Future primaryFuture = findPrimaryShardAsync(shardName); - primaryFuture.onComplete(new OnComplete() { + Future primaryFuture = findPrimaryShardAsync(shardName); + primaryFuture.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, ActorSelection primaryShard) { + public void onComplete(Throwable failure, PrimaryShardInfo primaryShardInfo) { if(failure != null) { LOG.warn("broadcast failed to send message {} to shard {}: {}", message.getClass().getSimpleName(), shardName, failure); } else { - primaryShard.tell(message, ActorRef.noSender()); + primaryShardInfo.getPrimaryShardActor().tell(message, ActorRef.noSender()); } } }, getClientDispatcher()); @@ -553,7 +564,7 @@ public class ActorContext { } @VisibleForTesting - Cache> getPrimaryShardActorSelectionCache() { - return primaryShardActorSelectionCache; + Cache> getPrimaryShardInfoCache() { + return primaryShardInfoCache; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java index abe7f7678c..a64a5802b8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java @@ -54,6 +54,7 @@ import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionR import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.DataExists; import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; import org.opendaylight.controller.cluster.datastore.messages.ReadData; import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply; import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply; @@ -71,6 +72,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -309,6 +311,11 @@ public abstract class AbstractTransactionProxyTest { return setupActorContextWithoutInitialCreateTransaction(actorSystem, DefaultShardStrategy.DEFAULT_SHARD); } + protected Future primaryShardInfoReply(ActorSystem actorSystem, ActorRef actorRef) { + return Futures.successful(new PrimaryShardInfo(actorSystem.actorSelection(actorRef.path()), + Optional.absent())); + } + protected ActorRef setupActorContextWithoutInitialCreateTransaction(ActorSystem actorSystem, String shardName) { ActorRef actorRef = actorSystem.actorOf(Props.create(DoNothingActor.class)); log.info("Created mock shard actor {}", actorRef); @@ -316,7 +323,7 @@ public abstract class AbstractTransactionProxyTest { doReturn(actorSystem.actorSelection(actorRef.path())). when(mockActorContext).actorSelection(actorRef.path().toString()); - doReturn(Futures.successful(actorSystem.actorSelection(actorRef.path()))). + doReturn(primaryShardInfoReply(actorSystem, actorRef)). when(mockActorContext).findPrimaryShardAsync(eq(shardName)); doReturn(false).when(mockActorContext).isPathLocal(actorRef.path().toString()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java index 0b166f5ac8..f2536bfc2c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBrokerTest.java @@ -8,12 +8,17 @@ package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; @@ -22,8 +27,12 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.Uninterruptibles; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -36,11 +45,21 @@ import org.mockito.InOrder; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.sal.core.spi.data.DOMStore; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** * Unit tests for DOMConcurrentDataCommitCoordinator. @@ -266,4 +285,248 @@ public class ConcurrentDOMDataBrokerTest { assertFailure(future, cause, mockCohort1, mockCohort2); } + + @Test + public void testCreateReadWriteTransaction(){ + DOMStore domStore = mock(DOMStore.class); + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor); + dataBroker.newReadWriteTransaction(); + + verify(domStore, never()).newReadWriteTransaction(); + } + + + @Test + public void testCreateWriteOnlyTransaction(){ + DOMStore domStore = mock(DOMStore.class); + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor); + dataBroker.newWriteOnlyTransaction(); + + verify(domStore, never()).newWriteOnlyTransaction(); + } + + @Test + public void testCreateReadOnlyTransaction(){ + DOMStore domStore = mock(DOMStore.class); + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor); + dataBroker.newReadOnlyTransaction(); + + verify(domStore, never()).newReadOnlyTransaction(); + } + + @Test + public void testLazySubTransactionCreationForReadWriteTransactions(){ + DOMStore configDomStore = mock(DOMStore.class); + DOMStore operationalDomStore = mock(DOMStore.class); + DOMStoreReadWriteTransaction storeTxn = mock(DOMStoreReadWriteTransaction.class); + + doReturn(storeTxn).when(operationalDomStore).newReadWriteTransaction(); + doReturn(storeTxn).when(configDomStore).newReadWriteTransaction(); + + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor); + DOMDataReadWriteTransaction dataTxn = dataBroker.newReadWriteTransaction(); + + dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build()); + + verify(configDomStore, never()).newReadWriteTransaction(); + verify(operationalDomStore, times(1)).newReadWriteTransaction(); + + dataTxn.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + + verify(configDomStore, times(1)).newReadWriteTransaction(); + verify(operationalDomStore, times(1)).newReadWriteTransaction(); + + } + + @Test + public void testLazySubTransactionCreationForWriteOnlyTransactions(){ + DOMStore configDomStore = mock(DOMStore.class); + DOMStore operationalDomStore = mock(DOMStore.class); + DOMStoreWriteTransaction storeTxn = mock(DOMStoreWriteTransaction.class); + + doReturn(storeTxn).when(operationalDomStore).newWriteOnlyTransaction(); + doReturn(storeTxn).when(configDomStore).newWriteOnlyTransaction(); + + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor); + DOMDataWriteTransaction dataTxn = dataBroker.newWriteOnlyTransaction(); + + dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + + verify(configDomStore, never()).newWriteOnlyTransaction(); + verify(operationalDomStore, times(1)).newWriteOnlyTransaction(); + + dataTxn.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + + verify(configDomStore, times(1)).newWriteOnlyTransaction(); + verify(operationalDomStore, times(1)).newWriteOnlyTransaction(); + + } + + + @Test + public void testLazySubTransactionCreationForReadOnlyTransactions(){ + DOMStore configDomStore = mock(DOMStore.class); + DOMStore operationalDomStore = mock(DOMStore.class); + DOMStoreReadTransaction storeTxn = mock(DOMStoreReadTransaction.class); + + doReturn(storeTxn).when(operationalDomStore).newReadOnlyTransaction(); + doReturn(storeTxn).when(configDomStore).newReadOnlyTransaction(); + + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor); + DOMDataReadOnlyTransaction dataTxn = dataBroker.newReadOnlyTransaction(); + + dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build()); + dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build()); + + verify(configDomStore, never()).newReadOnlyTransaction(); + verify(operationalDomStore, times(1)).newReadOnlyTransaction(); + + dataTxn.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.builder().build()); + + verify(configDomStore, times(1)).newReadOnlyTransaction(); + verify(operationalDomStore, times(1)).newReadOnlyTransaction(); + + } + + @Test + public void testSubmitWithOnlyOneSubTransaction() throws InterruptedException { + DOMStore configDomStore = mock(DOMStore.class); + DOMStore operationalDomStore = mock(DOMStore.class); + DOMStoreReadWriteTransaction mockStoreReadWriteTransaction = mock(DOMStoreReadWriteTransaction.class); + DOMStoreThreePhaseCommitCohort mockCohort = mock(DOMStoreThreePhaseCommitCohort.class); + + doReturn(mockStoreReadWriteTransaction).when(operationalDomStore).newReadWriteTransaction(); + doReturn(mockCohort).when(mockStoreReadWriteTransaction).ready(); + doReturn(Futures.immediateFuture(false)).when(mockCohort).canCommit(); + doReturn(Futures.immediateFuture(null)).when(mockCohort).abort(); + + final CountDownLatch latch = new CountDownLatch(1); + final List commitCohorts = new ArrayList(); + + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor) { + @Override + public CheckedFuture submit(DOMDataWriteTransaction transaction, Collection cohorts) { + commitCohorts.addAll(cohorts); + latch.countDown(); + return super.submit(transaction, cohorts); + } + }; + DOMDataReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction(); + + domDataReadWriteTransaction.delete(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build()); + + domDataReadWriteTransaction.submit(); + + latch.await(10, TimeUnit.SECONDS); + + assertTrue(commitCohorts.size() == 1); + } + + @Test + public void testSubmitWithOnlyTwoSubTransactions() throws InterruptedException { + DOMStore configDomStore = mock(DOMStore.class); + DOMStore operationalDomStore = mock(DOMStore.class); + DOMStoreReadWriteTransaction operationalTransaction = mock(DOMStoreReadWriteTransaction.class); + DOMStoreReadWriteTransaction configTransaction = mock(DOMStoreReadWriteTransaction.class); + DOMStoreThreePhaseCommitCohort mockCohortOperational = mock(DOMStoreThreePhaseCommitCohort.class); + DOMStoreThreePhaseCommitCohort mockCohortConfig = mock(DOMStoreThreePhaseCommitCohort.class); + + doReturn(operationalTransaction).when(operationalDomStore).newReadWriteTransaction(); + doReturn(configTransaction).when(configDomStore).newReadWriteTransaction(); + + doReturn(mockCohortOperational).when(operationalTransaction).ready(); + doReturn(Futures.immediateFuture(false)).when(mockCohortOperational).canCommit(); + doReturn(Futures.immediateFuture(null)).when(mockCohortOperational).abort(); + + doReturn(mockCohortConfig).when(configTransaction).ready(); + doReturn(Futures.immediateFuture(false)).when(mockCohortConfig).canCommit(); + doReturn(Futures.immediateFuture(null)).when(mockCohortConfig).abort(); + + + final CountDownLatch latch = new CountDownLatch(1); + final List commitCohorts = new ArrayList(); + + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor) { + @Override + public CheckedFuture submit(DOMDataWriteTransaction transaction, Collection cohorts) { + commitCohorts.addAll(cohorts); + latch.countDown(); + return super.submit(transaction, cohorts); + } + }; + DOMDataReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction(); + + domDataReadWriteTransaction.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + domDataReadWriteTransaction.merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + + domDataReadWriteTransaction.submit(); + + latch.await(10, TimeUnit.SECONDS); + + assertTrue(commitCohorts.size() == 2); + } + + @Test + public void testCreateTransactionChain(){ + DOMStore domStore = mock(DOMStore.class); + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor); + + dataBroker.createTransactionChain(mock(TransactionChainListener.class)); + + verify(domStore, times(2)).createTransactionChain(); + + } + + @Test + public void testCreateTransactionOnChain(){ + DOMStore domStore = mock(DOMStore.class); + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor); + + DOMStoreReadWriteTransaction operationalTransaction = mock(DOMStoreReadWriteTransaction.class); + DOMStoreTransactionChain mockChain = mock(DOMStoreTransactionChain.class); + + doReturn(mockChain).when(domStore).createTransactionChain(); + doReturn(operationalTransaction).when(mockChain).newWriteOnlyTransaction(); + + DOMTransactionChain transactionChain = dataBroker.createTransactionChain(mock(TransactionChainListener.class)); + + DOMDataWriteTransaction domDataWriteTransaction = transactionChain.newWriteOnlyTransaction(); + + verify(mockChain, never()).newWriteOnlyTransaction(); + + domDataWriteTransaction.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().build(), mock(NormalizedNode.class)); + } + + @Test + public void testEmptyTransactionSubmitSucceeds() throws ExecutionException, InterruptedException { + DOMStore domStore = mock(DOMStore.class); + ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, + domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor); + + CheckedFuture submit1 = dataBroker.newWriteOnlyTransaction().submit(); + + assertNotNull(submit1); + + submit1.get(); + + CheckedFuture submit2 = dataBroker.newReadWriteTransaction().submit(); + + assertNotNull(submit2); + + submit2.get(); + } + } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java new file mode 100644 index 0000000000..37a6197dd8 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore; + +import akka.actor.ActorRef; +import akka.actor.DeadLetter; +import akka.actor.Props; +import akka.testkit.JavaTestKit; +import com.google.common.collect.ImmutableList; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged; +import org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply; +import org.opendaylight.controller.cluster.datastore.messages.EnableNotification; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; + +public class DataTreeChangeListenerActorTest extends AbstractActorTest { + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testDataChangedWhenNotificationsAreEnabled(){ + new JavaTestKit(getSystem()) {{ + final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class); + final ImmutableList mockCandidates = ImmutableList.of(mockTreeCandidate); + final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class); + final Props props = DataTreeChangeListenerActor.props(mockListener); + final ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedNotificationsEnabled"); + + // Let the DataChangeListener know that notifications should be enabled + subject.tell(new EnableNotification(true), getRef()); + + subject.tell(new DataTreeChanged(mockCandidates), + getRef()); + + expectMsgClass(DataTreeChangedReply.class); + + Mockito.verify(mockListener).onDataTreeChanged(mockCandidates); + }}; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testDataChangedWhenNotificationsAreDisabled(){ + new JavaTestKit(getSystem()) {{ + final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class); + final ImmutableList mockCandidates = ImmutableList.of(mockTreeCandidate); + final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class); + final Props props = DataTreeChangeListenerActor.props(mockListener); + final ActorRef subject = + getSystem().actorOf(props, "testDataTreeChangedNotificationsDisabled"); + + subject.tell(new DataTreeChanged(mockCandidates), + getRef()); + + new Within(duration("1 seconds")) { + @Override + protected void run() { + expectNoMsg(); + + Mockito.verify(mockListener, Mockito.never()).onDataTreeChanged( + Matchers.anyCollectionOf(DataTreeCandidate.class)); + } + }; + }}; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testDataChangedWithNoSender(){ + new JavaTestKit(getSystem()) {{ + final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class); + final ImmutableList mockCandidates = ImmutableList.of(mockTreeCandidate); + final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class); + final Props props = DataTreeChangeListenerActor.props(mockListener); + final ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedWithNoSender"); + + getSystem().eventStream().subscribe(getRef(), DeadLetter.class); + + subject.tell(new DataTreeChanged(mockCandidates), ActorRef.noSender()); + + // Make sure no DataChangedReply is sent to DeadLetters. + while(true) { + DeadLetter deadLetter; + try { + deadLetter = expectMsgClass(duration("1 seconds"), DeadLetter.class); + } catch (AssertionError e) { + // Timed out - got no DeadLetter - this is good + break; + } + + // We may get DeadLetters for other messages we don't care about. + Assert.assertFalse("Unexpected DataTreeChangedReply", + deadLetter.message() instanceof DataTreeChangedReply); + } + }}; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testDataChangedWithListenerRuntimeEx(){ + new JavaTestKit(getSystem()) {{ + final DataTreeCandidate mockTreeCandidate1 = Mockito.mock(DataTreeCandidate.class); + final ImmutableList mockCandidates1 = ImmutableList.of(mockTreeCandidate1); + final DataTreeCandidate mockTreeCandidate2 = Mockito.mock(DataTreeCandidate.class); + final ImmutableList mockCandidates2 = ImmutableList.of(mockTreeCandidate2); + final DataTreeCandidate mockTreeCandidate3 = Mockito.mock(DataTreeCandidate.class); + final ImmutableList mockCandidates3 = ImmutableList.of(mockTreeCandidate3); + + final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class); + Mockito.doThrow(new RuntimeException("mock")).when(mockListener).onDataTreeChanged(mockCandidates2); + + Props props = DataTreeChangeListenerActor.props(mockListener); + ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedWithListenerRuntimeEx"); + + // Let the DataChangeListener know that notifications should be enabled + subject.tell(new EnableNotification(true), getRef()); + + subject.tell(new DataTreeChanged(mockCandidates1),getRef()); + expectMsgClass(DataTreeChangedReply.class); + + subject.tell(new DataTreeChanged(mockCandidates2),getRef()); + expectMsgClass(DataTreeChangedReply.class); + + subject.tell(new DataTreeChanged(mockCandidates3),getRef()); + expectMsgClass(DataTreeChangedReply.class); + + Mockito.verify(mockListener).onDataTreeChanged(mockCandidates1); + Mockito.verify(mockListener).onDataTreeChanged(mockCandidates2); + Mockito.verify(mockListener).onDataTreeChanged(mockCandidates3); + }}; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java new file mode 100644 index 0000000000..0dc0706a24 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import akka.actor.ActorRef; +import akka.actor.ActorSystem; +import akka.actor.Props; +import akka.actor.Terminated; +import akka.dispatch.ExecutionContexts; +import akka.dispatch.Futures; +import akka.testkit.JavaTestKit; +import akka.util.Timeout; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.common.util.concurrent.Uninterruptibles; +import java.util.concurrent.TimeUnit; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException; +import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeChangeListenerRegistration; +import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard; +import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound; +import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; +import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener; +import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListenerReply; +import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; +import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor; +import org.opendaylight.controller.md.cluster.datastore.model.TestModel; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import scala.concurrent.ExecutionContextExecutor; +import scala.concurrent.Future; +import scala.concurrent.duration.FiniteDuration; + +public class DataTreeChangeListenerProxyTest extends AbstractActorTest { + @SuppressWarnings("unchecked") + private final DOMDataTreeChangeListener mockListener = mock(DOMDataTreeChangeListener.class); + + @Test(timeout=10000) + public void testSuccessfulRegistration() { + new JavaTestKit(getSystem()) {{ + ActorContext actorContext = new ActorContext(getSystem(), getRef(), + mock(ClusterWrapper.class), mock(Configuration.class)); + + final DataTreeChangeListenerProxy proxy = + new DataTreeChangeListenerProxy<>(actorContext, mockListener); + + final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME); + new Thread() { + @Override + public void run() { + proxy.init("shard-1", path); + } + + }.start(); + + FiniteDuration timeout = duration("5 seconds"); + FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class); + Assert.assertEquals("getShardName", "shard-1", findLocalShard.getShardName()); + + reply(new LocalShardFound(getRef())); + + RegisterDataTreeChangeListener registerMsg = expectMsgClass(timeout, RegisterDataTreeChangeListener.class); + Assert.assertEquals("getPath", path, registerMsg.getPath()); + + reply(new RegisterDataTreeChangeListenerReply(getRef())); + + + for(int i = 0; (i < 20 * 5) && proxy.getListenerRegistrationActor() == null; i++) { + Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); + } + + Assert.assertEquals("getListenerRegistrationActor", getSystem().actorSelection(getRef().path()), + proxy.getListenerRegistrationActor()); + + watch(proxy.getDataChangeListenerActor()); + + proxy.close(); + + // The listener registration actor should get a Close message + expectMsgClass(timeout, CloseDataTreeChangeListenerRegistration.class); + + // The DataChangeListener actor should be terminated + expectMsgClass(timeout, Terminated.class); + + proxy.close(); + + expectNoMsg(); + }}; + } + + @Test(timeout=10000) + public void testLocalShardNotFound() { + new JavaTestKit(getSystem()) {{ + ActorContext actorContext = new ActorContext(getSystem(), getRef(), + mock(ClusterWrapper.class), mock(Configuration.class)); + + final DataTreeChangeListenerProxy proxy = + new DataTreeChangeListenerProxy<>(actorContext, mockListener); + + final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME); + new Thread() { + @Override + public void run() { + proxy.init("shard-1", path); + } + + }.start(); + + FiniteDuration timeout = duration("5 seconds"); + FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class); + Assert.assertEquals("getShardName", "shard-1", findLocalShard.getShardName()); + + reply(new LocalShardNotFound("shard-1")); + + expectNoMsg(duration("1 seconds")); + }}; + } + + @Test(timeout=10000) + public void testLocalShardNotInitialized() { + new JavaTestKit(getSystem()) {{ + ActorContext actorContext = new ActorContext(getSystem(), getRef(), + mock(ClusterWrapper.class), mock(Configuration.class)); + + final DataTreeChangeListenerProxy proxy = + new DataTreeChangeListenerProxy<>(actorContext, mockListener); + + final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME); + new Thread() { + @Override + public void run() { + proxy.init("shard-1", path); + } + + }.start(); + + FiniteDuration timeout = duration("5 seconds"); + FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class); + Assert.assertEquals("getShardName", "shard-1", findLocalShard.getShardName()); + + reply(new NotInitializedException("not initialized")); + + new Within(duration("1 seconds")) { + @Override + protected void run() { + expectNoMsg(); + } + }; + }}; + } + + @Test + public void testFailedRegistration() { + new JavaTestKit(getSystem()) {{ + ActorSystem mockActorSystem = mock(ActorSystem.class); + + ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class), + "testFailedRegistration"); + doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class)); + ExecutionContextExecutor executor = ExecutionContexts.fromExecutor( + MoreExecutors.sameThreadExecutor()); + + + ActorContext actorContext = mock(ActorContext.class); + final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME); + + doReturn(executor).when(actorContext).getClientDispatcher(); + doReturn(mockActorSystem).when(actorContext).getActorSystem(); + + String shardName = "shard-1"; + final DataTreeChangeListenerProxy proxy = + new DataTreeChangeListenerProxy<>(actorContext, mockListener); + + doReturn(duration("5 seconds")).when(actorContext).getOperationDuration(); + doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName)); + doReturn(Futures.failed(new RuntimeException("mock"))). + when(actorContext).executeOperationAsync(any(ActorRef.class), + any(Object.class), any(Timeout.class)); + doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext(); + + proxy.init("shard-1", path); + + Assert.assertEquals("getListenerRegistrationActor", null, + proxy.getListenerRegistrationActor()); + }}; + } + + @Test + public void testCloseBeforeRegistration() { + new JavaTestKit(getSystem()) {{ + ActorContext actorContext = mock(ActorContext.class); + + String shardName = "shard-1"; + + doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext(); + doReturn(getSystem().dispatchers().defaultGlobalDispatcher()).when(actorContext).getClientDispatcher(); + doReturn(getSystem()).when(actorContext).getActorSystem(); + doReturn(Dispatchers.DEFAULT_DISPATCHER_PATH).when(actorContext).getNotificationDispatcherPath(); + doReturn(getSystem().actorSelection(getRef().path())). + when(actorContext).actorSelection(getRef().path()); + doReturn(duration("5 seconds")).when(actorContext).getOperationDuration(); + doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName)); + + final DataTreeChangeListenerProxy proxy = + new DataTreeChangeListenerProxy<>(actorContext, mockListener); + + + Answer> answer = new Answer>() { + @Override + public Future answer(InvocationOnMock invocation) { + proxy.close(); + return Futures.successful((Object)new RegisterDataTreeChangeListenerReply(getRef())); + } + }; + + doAnswer(answer).when(actorContext).executeOperationAsync(any(ActorRef.class), + any(Object.class), any(Timeout.class)); + + proxy.init(shardName, YangInstanceIdentifier.of(TestModel.TEST_QNAME)); + + expectMsgClass(duration("5 seconds"), CloseDataTreeChangeListenerRegistration.class); + + Assert.assertEquals("getListenerRegistrationActor", null, + proxy.getListenerRegistrationActor()); + }}; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerRegistrationActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerRegistrationActorTest.java new file mode 100644 index 0000000000..5695911798 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerRegistrationActorTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore; + +import akka.actor.ActorRef; +import akka.actor.Props; +import akka.testkit.JavaTestKit; +import com.google.common.util.concurrent.MoreExecutors; +import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeChangeListenerRegistration; +import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeChangeListenerRegistrationReply; +import org.opendaylight.controller.md.cluster.datastore.model.TestModel; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; +import org.opendaylight.yangtools.concepts.ListenerRegistration; + +public class DataTreeChangeListenerRegistrationActorTest extends AbstractActorTest { + private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor()); + + static { + store.onGlobalContextUpdated(TestModel.createTestContext()); + } + + @SuppressWarnings("rawtypes") + @Test + public void testOnReceiveCloseListenerRegistration() throws Exception { + new JavaTestKit(getSystem()) {{ + final ListenerRegistration mockListenerReg = Mockito.mock(ListenerRegistration.class); + final Props props = DataTreeChangeListenerRegistrationActor.props(mockListenerReg); + final ActorRef subject = getSystem().actorOf(props, "testCloseListenerRegistration"); + + subject.tell(CloseDataTreeChangeListenerRegistration.getInstance(), getRef()); + + expectMsgClass(duration("1 second"), CloseDataTreeChangeListenerRegistrationReply.class); + + Mockito.verify(mockListenerReg).close(); + }}; + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListenerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListenerTest.java new file mode 100644 index 0000000000..fb8baf159f --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListenerTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore; + +import akka.actor.ActorRef; +import akka.actor.Props; +import java.util.Arrays; +import java.util.Collection; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged; +import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; + +public class ForwardingDataTreeChangeListenerTest extends AbstractActorTest { + + @Test + public void testOnDataChanged() throws Exception { + final Props props = Props.create(MessageCollectorActor.class); + final ActorRef actorRef = getSystem().actorOf(props); + + ForwardingDataTreeChangeListener forwardingListener = new ForwardingDataTreeChangeListener( + getSystem().actorSelection(actorRef.path())); + + Collection expected = Arrays.asList(Mockito.mock(DataTreeCandidate.class)); + forwardingListener.onDataTreeChanged(expected); + + DataTreeChanged actual = MessageCollectorActor.expectFirstMatching(actorRef, DataTreeChanged.class); + Assert.assertSame(expected, actual.getChanges()); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java index b676cf225c..645890dcb9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java @@ -2,6 +2,7 @@ package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -21,6 +22,7 @@ import akka.persistence.RecoveryCompleted; import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; import akka.util.Timeout; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -49,9 +51,11 @@ import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIde import org.opendaylight.controller.cluster.datastore.messages.ActorInitialized; import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; -import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; +import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound; +import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor; import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; @@ -63,6 +67,7 @@ import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import scala.concurrent.Await; @@ -154,7 +159,8 @@ public class ShardManagerTest extends AbstractActorTest { shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); shardManager.tell(new ActorInitialized(), mockShardActor); - shardManager.tell(new LeaderStateChanged(memberId, memberId), getRef()); + DataTree mockDataTree = mock(DataTree.class); + shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mockDataTree)), getRef()); MessageCollectorActor.expectFirstMatching(mockShardActor, RegisterRoleChangeListener.class); shardManager.tell((new RoleChangeNotification(memberId, RaftState.Candidate.name(), @@ -162,9 +168,30 @@ public class ShardManagerTest extends AbstractActorTest { shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef()); - PrimaryFound primaryFound = expectMsgClass(duration("5 seconds"), PrimaryFound.class); + LocalPrimaryShardFound primaryFound = expectMsgClass(duration("5 seconds"), LocalPrimaryShardFound.class); assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(), primaryFound.getPrimaryPath().contains("member-1-shard-default")); + assertSame("getLocalShardDataTree", mockDataTree, primaryFound.getLocalShardDataTree() ); + }}; + } + + @Test + public void testOnReceiveFindPrimaryForNonLocalLeaderShardBeforeMemberUp() throws Exception { + new JavaTestKit(getSystem()) {{ + final ActorRef shardManager = getSystem().actorOf(newPropsShardMgrWithMockShardActor()); + + shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); + shardManager.tell(new ActorInitialized(), mockShardActor); + + String memberId2 = "member-2-shard-default-" + shardMrgIDSuffix; + String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix; + shardManager.tell(new RoleChangeNotification(memberId1, + RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor); + shardManager.tell(new LeaderStateChanged(memberId1, memberId2), mockShardActor); + + shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef()); + + expectMsgClass(duration("5 seconds"), NoShardLeaderException.class); }}; } @@ -182,11 +209,11 @@ public class ShardManagerTest extends AbstractActorTest { String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix; shardManager.tell(new RoleChangeNotification(memberId1, RaftState.Candidate.name(), RaftState.Follower.name()), mockShardActor); - shardManager.tell(new LeaderStateChanged(memberId1, memberId2), mockShardActor); + shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId2, Optional.absent()), mockShardActor); shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef()); - PrimaryFound primaryFound = expectMsgClass(duration("5 seconds"), PrimaryFound.class); + RemotePrimaryShardFound primaryFound = expectMsgClass(duration("5 seconds"), RemotePrimaryShardFound.class); assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(), primaryFound.getPrimaryPath().contains("member-2-shard-default")); }}; @@ -233,13 +260,15 @@ public class ShardManagerTest extends AbstractActorTest { expectMsgClass(duration("5 seconds"), NoShardLeaderException.class); - shardManager.tell(new LeaderStateChanged(memberId, memberId), mockShardActor); + DataTree mockDataTree = mock(DataTree.class); + shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mockDataTree)), mockShardActor); shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef()); - PrimaryFound primaryFound = expectMsgClass(duration("5 seconds"), PrimaryFound.class); + LocalPrimaryShardFound primaryFound = expectMsgClass(duration("5 seconds"), LocalPrimaryShardFound.class); assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(), primaryFound.getPrimaryPath().contains("member-1-shard-default")); + assertSame("getLocalShardDataTree", mockDataTree, primaryFound.getLocalShardDataTree() ); }}; } @@ -266,11 +295,13 @@ public class ShardManagerTest extends AbstractActorTest { expectNoMsg(FiniteDuration.create(150, TimeUnit.MILLISECONDS)); - shardManager.tell(new LeaderStateChanged(memberId, memberId), mockShardActor); + DataTree mockDataTree = mock(DataTree.class); + shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, Optional.of(mockDataTree)), mockShardActor); - PrimaryFound primaryFound = expectMsgClass(duration("5 seconds"), PrimaryFound.class); + LocalPrimaryShardFound primaryFound = expectMsgClass(duration("5 seconds"), LocalPrimaryShardFound.class); assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(), primaryFound.getPrimaryPath().contains("member-1-shard-default")); + assertSame("getLocalShardDataTree", mockDataTree, primaryFound.getLocalShardDataTree() ); expectNoMsg(FiniteDuration.create(200, TimeUnit.MILLISECONDS)); }}; @@ -362,7 +393,8 @@ public class ShardManagerTest extends AbstractActorTest { shardManager2.tell(new ActorInitialized(), mockShardActor2); String memberId2 = "member-2-shard-astronauts-" + shardMrgIDSuffix; - shardManager2.tell(new LeaderStateChanged(memberId2, memberId2), mockShardActor2); + shardManager2.tell(new ShardLeaderStateChanged(memberId2, memberId2, + Optional.of(mock(DataTree.class))), mockShardActor2); shardManager2.tell(new RoleChangeNotification(memberId2, RaftState.Candidate.name(), RaftState.Leader.name()), mockShardActor2); @@ -370,7 +402,7 @@ public class ShardManagerTest extends AbstractActorTest { shardManager1.tell(new FindPrimary("astronauts", false), getRef()); - PrimaryFound found = expectMsgClass(duration("5 seconds"), PrimaryFound.class); + RemotePrimaryShardFound found = expectMsgClass(duration("5 seconds"), RemotePrimaryShardFound.class); String path = found.getPrimaryPath(); assertTrue("Unexpected primary path " + path, path.contains("member-2-shard-astronauts-config")); @@ -639,7 +671,7 @@ public class ShardManagerTest extends AbstractActorTest { } @Test - public void testRoleChangeNotificationAndLeaderStateChangedReleaseReady() throws Exception { + public void testRoleChangeNotificationAndShardLeaderStateChangedReleaseReady() throws Exception { new JavaTestKit(getSystem()) { { TestActorRef shardManager = TestActorRef.create(getSystem(), newShardMgrProps()); @@ -650,7 +682,8 @@ public class ShardManagerTest extends AbstractActorTest { verify(ready, never()).countDown(); - shardManager.underlyingActor().onReceiveCommand(new LeaderStateChanged(memberId, memberId)); + shardManager.underlyingActor().onReceiveCommand(new ShardLeaderStateChanged(memberId, memberId, + Optional.of(mock(DataTree.class)))); verify(ready, times(1)).countDown(); @@ -658,7 +691,7 @@ public class ShardManagerTest extends AbstractActorTest { } @Test - public void testRoleChangeNotificationToFollowerWithLeaderStateChangedReleaseReady() throws Exception { + public void testRoleChangeNotificationToFollowerWithShardLeaderStateChangedReleaseReady() throws Exception { new JavaTestKit(getSystem()) { { TestActorRef shardManager = TestActorRef.create(getSystem(), newShardMgrProps()); @@ -669,13 +702,37 @@ public class ShardManagerTest extends AbstractActorTest { verify(ready, never()).countDown(); - shardManager.underlyingActor().onReceiveCommand(new LeaderStateChanged(memberId, "member-2-shard-default-" + shardMrgIDSuffix)); + shardManager.underlyingActor().onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString())); + + shardManager.underlyingActor().onReceiveCommand(new ShardLeaderStateChanged(memberId, + "member-2-shard-default-" + shardMrgIDSuffix, Optional.of(mock(DataTree.class)))); verify(ready, times(1)).countDown(); }}; } + @Test + public void testReadyCountDownForMemberUpAfterLeaderStateChanged() throws Exception { + new JavaTestKit(getSystem()) { + { + TestActorRef shardManager = TestActorRef.create(getSystem(), newShardMgrProps()); + + String memberId = "member-1-shard-default-" + shardMrgIDSuffix; + shardManager.underlyingActor().onReceiveCommand(new RoleChangeNotification( + memberId, null, RaftState.Follower.name())); + + verify(ready, never()).countDown(); + + shardManager.underlyingActor().onReceiveCommand(new ShardLeaderStateChanged(memberId, + "member-2-shard-default-" + shardMrgIDSuffix, Optional.of(mock(DataTree.class)))); + + shardManager.underlyingActor().onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString())); + + verify(ready, times(1)).countDown(); + + }}; + } @Test public void testRoleChangeNotificationDoNothingForUnknownShard() throws Exception { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index 3d28672c9f..1ecf0971c1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.inOrder; @@ -29,7 +30,6 @@ import com.google.common.util.concurrent.Uninterruptibles; import java.io.IOException; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -57,6 +57,9 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply; import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener; import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; +import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener; +import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListenerReply; +import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; import org.opendaylight.controller.cluster.datastore.modification.DeleteModification; import org.opendaylight.controller.cluster.datastore.modification.MergeModification; @@ -64,8 +67,8 @@ import org.opendaylight.controller.cluster.datastore.modification.Modification; import org.opendaylight.controller.cluster.datastore.modification.ModificationPayload; import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; -import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor; import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener; +import org.opendaylight.controller.cluster.datastore.utils.MockDataTreeChangeListener; import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils; import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener; import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListenerReply; @@ -80,8 +83,10 @@ import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout; import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus; import org.opendaylight.controller.cluster.raft.client.messages.FindLeader; import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply; +import org.opendaylight.controller.cluster.raft.messages.RequestVote; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore; +import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; @@ -246,6 +251,110 @@ public class ShardTest extends AbstractShardTest { }}; } + @Test + public void testRegisterDataTreeChangeListener() throws Exception { + new ShardTestKit(getSystem()) {{ + TestActorRef shard = TestActorRef.create(getSystem(), + newShardProps(), "testRegisterDataTreeChangeListener"); + + waitUntilLeader(shard); + + shard.tell(new UpdateSchemaContext(SchemaContextHelper.full()), ActorRef.noSender()); + + MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1); + ActorRef dclActor = getSystem().actorOf(DataTreeChangeListenerActor.props(listener), + "testRegisterDataTreeChangeListener-DataTreeChangeListener"); + + shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor), getRef()); + + RegisterDataTreeChangeListenerReply reply = expectMsgClass(duration("3 seconds"), + RegisterDataTreeChangeListenerReply.class); + String replyPath = reply.getListenerRegistrationPath().toString(); + assertTrue("Incorrect reply path: " + replyPath, replyPath.matches( + "akka:\\/\\/test\\/user\\/testRegisterDataTreeChangeListener\\/\\$.*")); + + YangInstanceIdentifier path = TestModel.TEST_PATH; + writeToStore(shard, path, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + + listener.waitForChangeEvents(); + + dclActor.tell(PoisonPill.getInstance(), ActorRef.noSender()); + shard.tell(PoisonPill.getInstance(), ActorRef.noSender()); + }}; + } + + @SuppressWarnings("serial") + @Test + public void testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration() throws Exception { + new ShardTestKit(getSystem()) {{ + final CountDownLatch onFirstElectionTimeout = new CountDownLatch(1); + final CountDownLatch onChangeListenerRegistered = new CountDownLatch(1); + Creator creator = new Creator() { + boolean firstElectionTimeout = true; + + @Override + public Shard create() throws Exception { + return new Shard(shardID, Collections.emptyMap(), + dataStoreContextBuilder.persistent(false).build(), SCHEMA_CONTEXT) { + @Override + public void onReceiveCommand(final Object message) throws Exception { + if(message instanceof ElectionTimeout && firstElectionTimeout) { + firstElectionTimeout = false; + final ActorRef self = getSelf(); + new Thread() { + @Override + public void run() { + Uninterruptibles.awaitUninterruptibly( + onChangeListenerRegistered, 5, TimeUnit.SECONDS); + self.tell(message, self); + } + }.start(); + + onFirstElectionTimeout.countDown(); + } else { + super.onReceiveCommand(message); + } + } + }; + } + }; + + MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1); + ActorRef dclActor = getSystem().actorOf(DataTreeChangeListenerActor.props(listener), + "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration-DataChangeListener"); + + TestActorRef shard = TestActorRef.create(getSystem(), + Props.create(new DelegatingShardCreator(creator)), + "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration"); + + YangInstanceIdentifier path = TestModel.TEST_PATH; + writeToStore(shard, path, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + + assertEquals("Got first ElectionTimeout", true, + onFirstElectionTimeout.await(5, TimeUnit.SECONDS)); + + shard.tell(new RegisterDataTreeChangeListener(path, dclActor), getRef()); + RegisterDataTreeChangeListenerReply reply = expectMsgClass(duration("5 seconds"), + RegisterDataTreeChangeListenerReply.class); + assertNotNull("getListenerRegistratioznPath", reply.getListenerRegistrationPath()); + + shard.tell(new FindLeader(), getRef()); + FindLeaderReply findLeadeReply = + expectMsgClass(duration("5 seconds"), FindLeaderReply.class); + assertNull("Expected the shard not to be the leader", findLeadeReply.getLeaderActor()); + + writeToStore(shard, path, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + + onChangeListenerRegistered.countDown(); + + // TODO: investigate why we do not receive data chage events + listener.waitForChangeEvents(); + + dclActor.tell(PoisonPill.getInstance(), ActorRef.noSender()); + shard.tell(PoisonPill.getInstance(), ActorRef.noSender()); + }}; + } + @Test public void testCreateTransaction(){ new ShardTestKit(getSystem()) {{ @@ -1985,14 +2094,27 @@ public class ShardTest extends AbstractShardTest { shard.tell(new RegisterRoleChangeListener(), listener); - // TODO: MessageCollectorActor exists as a test util in both the akka-raft and distributed-datastore - // projects. Need to move it to commons as a regular utility and then we can get rid of this arbitrary - // sleep. - Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); + MessageCollectorActor.expectFirstMatching(listener, RegisterRoleChangeListenerReply.class); - List allMatching = MessageCollectorActor.getAllMatching(listener, RegisterRoleChangeListenerReply.class); + ShardLeaderStateChanged leaderStateChanged = MessageCollectorActor.expectFirstMatching(listener, + ShardLeaderStateChanged.class); + assertEquals("getLocalShardDataTree present", true, + leaderStateChanged.getLocalShardDataTree().isPresent()); + assertSame("getLocalShardDataTree", shard.underlyingActor().getDataStore().getDataTree(), + leaderStateChanged.getLocalShardDataTree().get()); - assertEquals(1, allMatching.size()); + MessageCollectorActor.clearMessages(listener); + + // Force a leader change + + shard.tell(new RequestVote(10000, "member2", 50, 50), getRef()); + + leaderStateChanged = MessageCollectorActor.expectFirstMatching(listener, + ShardLeaderStateChanged.class); + assertEquals("getLocalShardDataTree present", false, + leaderStateChanged.getLocalShardDataTree().isPresent()); + + shard.tell(PoisonPill.getInstance(), ActorRef.noSender()); } }; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java index 93c6ddbe73..844feb2f47 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java @@ -130,7 +130,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { if (exToThrow instanceof PrimaryNotFoundException) { doReturn(Futures.failed(exToThrow)).when(mockActorContext).findPrimaryShardAsync(anyString()); } else { - doReturn(Futures.successful(getSystem().actorSelection(actorRef.path()))). + doReturn(primaryShardInfoReply(getSystem(), actorRef)). when(mockActorContext).findPrimaryShardAsync(anyString()); } @@ -209,7 +209,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { doReturn(getSystem().actorSelection(actorRef.path())).when(mockActorContext). actorSelection(actorRef.path().toString()); - doReturn(Futures.successful(getSystem().actorSelection(actorRef.path()))). + doReturn(primaryShardInfoReply(getSystem(), actorRef)). when(mockActorContext).findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD)); doReturn(Futures.successful(new Object())).when(mockActorContext).executeOperationAsync( @@ -834,7 +834,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { when(mockActorContext).actorSelection(shardActorRef.path().toString()); if(shardFound) { - doReturn(Futures.successful(actorSystem.actorSelection(shardActorRef.path()))). + doReturn(primaryShardInfoReply(actorSystem, shardActorRef)). when(mockActorContext).findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD)); } else { doReturn(Futures.failed(new PrimaryNotFoundException("test"))) @@ -1399,7 +1399,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest { doReturn(getSystem().actorSelection(shardActorRef.path())). when(mockActorContext).actorSelection(shardActorRef.path().toString()); - doReturn(Futures.successful(getSystem().actorSelection(shardActorRef.path()))). + doReturn(primaryShardInfoReply(getSystem(), shardActorRef)). when(mockActorContext).findPrimaryShardAsync(eq(shardName)); doReturn(true).when(mockActorContext).isPathLocal(shardActorRef.path().toString()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java index 6b4f633778..031463b2b9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.doReturn; @@ -30,6 +31,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang.time.StopWatch; import org.junit.Assert; import org.junit.Test; +import org.mockito.Mockito; import org.opendaylight.controller.cluster.datastore.AbstractActorTest; import org.opendaylight.controller.cluster.datastore.ClusterWrapper; import org.opendaylight.controller.cluster.datastore.Configuration; @@ -39,9 +41,12 @@ import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedEx import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException; import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound; import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; -import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; +import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Await; @@ -403,7 +408,7 @@ public class ActorContextTest extends AbstractActorTest{ } @Test - public void testFindPrimaryShardAsyncPrimaryFound() throws Exception { + public void testFindPrimaryShardAsyncRemotePrimaryFound() throws Exception { TestActorRef shardManager = TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class)); @@ -411,35 +416,81 @@ public class ActorContextTest extends AbstractActorTest{ DatastoreContext dataStoreContext = DatastoreContext.newBuilder().dataStoreType("config"). shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build(); + final String expPrimaryPath = "akka://test-system/find-primary-shard"; ActorContext actorContext = new ActorContext(getSystem(), shardManager, mock(ClusterWrapper.class), mock(Configuration.class), dataStoreContext) { @Override protected Future doAsk(ActorRef actorRef, Object message, Timeout timeout) { - return Futures.successful((Object) new PrimaryFound("akka://test-system/test")); + return Futures.successful((Object) new RemotePrimaryShardFound(expPrimaryPath)); } }; - - Future foobar = actorContext.findPrimaryShardAsync("foobar"); - ActorSelection actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS)); + Future foobar = actorContext.findPrimaryShardAsync("foobar"); + PrimaryShardInfo actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS)); assertNotNull(actual); + assertEquals("LocalShardDataTree present", false, actual.getLocalShardDataTree().isPresent()); + assertTrue("Unexpected PrimaryShardActor path " + actual.getPrimaryShardActor().path(), + expPrimaryPath.endsWith(actual.getPrimaryShardActor().pathString())); - Future cached = actorContext.getPrimaryShardActorSelectionCache().getIfPresent("foobar"); + Future cached = actorContext.getPrimaryShardInfoCache().getIfPresent("foobar"); - ActorSelection cachedSelection = Await.result(cached, FiniteDuration.apply(1, TimeUnit.MILLISECONDS)); + PrimaryShardInfo cachedInfo = Await.result(cached, FiniteDuration.apply(1, TimeUnit.MILLISECONDS)); - assertEquals(cachedSelection, actual); + assertEquals(cachedInfo, actual); // Wait for 200 Milliseconds. The cached entry should have been removed. Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS); - cached = actorContext.getPrimaryShardActorSelectionCache().getIfPresent("foobar"); + cached = actorContext.getPrimaryShardInfoCache().getIfPresent("foobar"); assertNull(cached); + } + + @Test + public void testFindPrimaryShardAsyncLocalPrimaryFound() throws Exception { + + TestActorRef shardManager = + TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class)); + + DatastoreContext dataStoreContext = DatastoreContext.newBuilder().dataStoreType("config"). + shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build(); + + final DataTree mockDataTree = Mockito.mock(DataTree.class); + final String expPrimaryPath = "akka://test-system/find-primary-shard"; + ActorContext actorContext = + new ActorContext(getSystem(), shardManager, mock(ClusterWrapper.class), + mock(Configuration.class), dataStoreContext) { + @Override + protected Future doAsk(ActorRef actorRef, Object message, Timeout timeout) { + return Futures.successful((Object) new LocalPrimaryShardFound(expPrimaryPath, mockDataTree)); + } + }; + + Future foobar = actorContext.findPrimaryShardAsync("foobar"); + PrimaryShardInfo actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS)); + + assertNotNull(actual); + assertEquals("LocalShardDataTree present", true, actual.getLocalShardDataTree().isPresent()); + assertSame("LocalShardDataTree", mockDataTree, actual.getLocalShardDataTree().get()); + assertTrue("Unexpected PrimaryShardActor path " + actual.getPrimaryShardActor().path(), + expPrimaryPath.endsWith(actual.getPrimaryShardActor().pathString())); + + Future cached = actorContext.getPrimaryShardInfoCache().getIfPresent("foobar"); + + PrimaryShardInfo cachedInfo = Await.result(cached, FiniteDuration.apply(1, TimeUnit.MILLISECONDS)); + assertEquals(cachedInfo, actual); + + // Wait for 200 Milliseconds. The cached entry should have been removed. + + Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS); + + cached = actorContext.getPrimaryShardInfoCache().getIfPresent("foobar"); + + assertNull(cached); } @Test @@ -461,7 +512,7 @@ public class ActorContextTest extends AbstractActorTest{ }; - Future foobar = actorContext.findPrimaryShardAsync("foobar"); + Future foobar = actorContext.findPrimaryShardAsync("foobar"); try { Await.result(foobar, Duration.apply(100, TimeUnit.MILLISECONDS)); @@ -470,7 +521,7 @@ public class ActorContextTest extends AbstractActorTest{ } - Future cached = actorContext.getPrimaryShardActorSelectionCache().getIfPresent("foobar"); + Future cached = actorContext.getPrimaryShardInfoCache().getIfPresent("foobar"); assertNull(cached); } @@ -494,7 +545,7 @@ public class ActorContextTest extends AbstractActorTest{ }; - Future foobar = actorContext.findPrimaryShardAsync("foobar"); + Future foobar = actorContext.findPrimaryShardAsync("foobar"); try { Await.result(foobar, Duration.apply(100, TimeUnit.MILLISECONDS)); @@ -503,7 +554,7 @@ public class ActorContextTest extends AbstractActorTest{ } - Future cached = actorContext.getPrimaryShardActorSelectionCache().getIfPresent("foobar"); + Future cached = actorContext.getPrimaryShardInfoCache().getIfPresent("foobar"); assertNull(cached); } @@ -516,8 +567,8 @@ public class ActorContextTest extends AbstractActorTest{ TestActorRef shardManagerActorRef = TestActorRef.create(getSystem(), MockShardManager.props()); MockShardManager shardManagerActor = shardManagerActorRef.underlyingActor(); - shardManagerActor.addFindPrimaryResp("shard1", new PrimaryFound(shardActorRef1.path().toString())); - shardManagerActor.addFindPrimaryResp("shard2", new PrimaryFound(shardActorRef2.path().toString())); + shardManagerActor.addFindPrimaryResp("shard1", new RemotePrimaryShardFound(shardActorRef1.path().toString())); + shardManagerActor.addFindPrimaryResp("shard2", new RemotePrimaryShardFound(shardActorRef2.path().toString())); shardManagerActor.addFindPrimaryResp("shard3", new NoShardLeaderException("not found")); Configuration mockConfig = mock(Configuration.class); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java index 810b270cfc..5d44033cd6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockClusterWrapper.java @@ -74,7 +74,7 @@ public class MockClusterWrapper implements ClusterWrapper{ } - private static ClusterEvent.MemberUp createMemberUp(String memberName, String address) { + public static ClusterEvent.MemberUp createMemberUp(String memberName, String address) { akka.cluster.UniqueAddress uniqueAddress = new UniqueAddress( AddressFromURIString.parse(address), 55); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java new file mode 100644 index 0000000000..d06fc43572 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.utils; + +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.Uninterruptibles; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; + +import javax.annotation.Nonnull; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class MockDataTreeChangeListener implements DOMDataTreeChangeListener { + + private final List> changeList = + Collections.synchronizedList(Lists.>newArrayList()); + + private volatile CountDownLatch changeLatch; + private int expChangeEventCount; + + public MockDataTreeChangeListener(int expChangeEventCount) { + reset(expChangeEventCount); + } + + public void reset(int expChangeEventCount) { + changeLatch = new CountDownLatch(expChangeEventCount); + this.expChangeEventCount = expChangeEventCount; + changeList.clear(); + } + + @Override + public void onDataTreeChanged(@Nonnull final Collection changes) { + changeList.add(changes); + changeLatch.countDown(); + } + + public void waitForChangeEvents() { + boolean done = Uninterruptibles.awaitUninterruptibly(changeLatch, 5, TimeUnit.SECONDS); + if(!done) { + fail(String.format("Missing change notifications. Expected: %d. Actual: %d", + expChangeEventCount, (expChangeEventCount - changeLatch.getCount()))); + } + } + + public void expectNoMoreChanges(String assertMsg) { + Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); + assertEquals(assertMsg, expChangeEventCount, changeList.size()); + } +} diff --git a/opendaylight/md-sal/sal-dom-api/pom.xml b/opendaylight/md-sal/sal-dom-api/pom.xml index 89fca50354..ef3b792975 100644 --- a/opendaylight/md-sal/sal-dom-api/pom.xml +++ b/opendaylight/md-sal/sal-dom-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-core-api bundle diff --git a/opendaylight/md-sal/sal-dom-broker/pom.xml b/opendaylight/md-sal/sal-dom-broker/pom.xml index 477ddeabdf..2dafbe8c67 100644 --- a/opendaylight/md-sal/sal-dom-broker/pom.xml +++ b/opendaylight/md-sal/sal-dom-broker/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-broker-impl bundle diff --git a/opendaylight/md-sal/sal-dom-spi/pom.xml b/opendaylight/md-sal/sal-dom-spi/pom.xml index 6cc721e68d..2bb4a99b90 100644 --- a/opendaylight/md-sal/sal-dom-spi/pom.xml +++ b/opendaylight/md-sal/sal-dom-spi/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-core-spi bundle diff --git a/opendaylight/md-sal/sal-dom-xsql-config/pom.xml b/opendaylight/md-sal/sal-dom-xsql-config/pom.xml index d2d864cd4f..3f22aced20 100644 --- a/opendaylight/md-sal/sal-dom-xsql-config/pom.xml +++ b/opendaylight/md-sal/sal-dom-xsql-config/pom.xml @@ -12,7 +12,7 @@ sal-parent org.opendaylight.controller - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-dom-xsql-config Configuration files for md-sal diff --git a/opendaylight/md-sal/sal-dom-xsql/pom.xml b/opendaylight/md-sal/sal-dom-xsql/pom.xml index f0e27cf2ac..1543cd99ac 100644 --- a/opendaylight/md-sal/sal-dom-xsql/pom.xml +++ b/opendaylight/md-sal/sal-dom-xsql/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-dom-xsql bundle diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml index 4a17273232..01de2b6f2a 100644 --- a/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-dummy-distributed-datastore bundle diff --git a/opendaylight/md-sal/sal-inmemory-datastore/pom.xml b/opendaylight/md-sal/sal-inmemory-datastore/pom.xml index 473b065b59..a19cbb7eeb 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/pom.xml +++ b/opendaylight/md-sal/sal-inmemory-datastore/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-inmemory-datastore diff --git a/opendaylight/md-sal/sal-karaf-xsql/pom.xml b/opendaylight/md-sal/sal-karaf-xsql/pom.xml index 14a87a23f7..f06e8449c4 100644 --- a/opendaylight/md-sal/sal-karaf-xsql/pom.xml +++ b/opendaylight/md-sal/sal-karaf-xsql/pom.xml @@ -23,7 +23,7 @@ sal-parent org.opendaylight.controller - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.opendaylight.controller @@ -63,7 +63,7 @@ org.opendaylight.controller sal-dom-xsql - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT diff --git a/opendaylight/md-sal/sal-netconf-connector/pom.xml b/opendaylight/md-sal/sal-netconf-connector/pom.xml index 40cf5a3955..fd4d38a111 100644 --- a/opendaylight/md-sal/sal-netconf-connector/pom.xml +++ b/opendaylight/md-sal/sal-netconf-connector/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-netconf-connector diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java index db9b702fed..c0b57de9a0 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java @@ -118,7 +118,7 @@ public final class NetconfDevice implements RemoteDevice stripMissingSource(final Collection requiredSources, final SourceIdentifier sIdToRemove) { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java index 303f3e6923..819edce320 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java @@ -101,10 +101,10 @@ public class NetconfMessageTransformer implements MessageTransformer mappedNotifications; private final DomToNormalizedNodeParserFactory parserFactory; - public NetconfMessageTransformer(final SchemaContext schemaContext) { + public NetconfMessageTransformer(final SchemaContext schemaContext, final boolean strictParsing) { this.counter = new MessageCounter(); this.schemaContext = schemaContext; - parserFactory = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, schemaContext); + parserFactory = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, schemaContext, strictParsing); mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), QNAME_FUNCTION); mappedNotifications = Multimaps.index(schemaContext.getNotifications(), QNAME_NOREV_FUNCTION); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/InstanceIdToNodes.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/InstanceIdToNodes.java deleted file mode 100644 index d0b9efc8c0..0000000000 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/InstanceIdToNodes.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.connect.netconf.util; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import javax.xml.transform.dom.DOMSource; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.ModifyAction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.AttributesBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder; -import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; -import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; -import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * Transforms an instance of yang instance identifier to a filter like structure in normalized node format. Can be also used to nest the edit-config rpc content. - * For each argument of the id, a specific normalized node is created to ensure schema context conformance. - */ -public abstract class InstanceIdToNodes implements Identifiable { - - private final T identifier; - - @Override - public T getIdentifier() { - return identifier; - } - - protected InstanceIdToNodes(final T identifier) { - this.identifier = identifier; - } - - abstract InstanceIdToNodes getChild(final PathArgument child) throws DataNormalizationException; - - public abstract NormalizedNode create(YangInstanceIdentifier legacyData, Optional> deepestChild, Optional operation); - - private static abstract class SimpleTypeNormalization extends InstanceIdToNodes { - - protected SimpleTypeNormalization(final T identifier) { - super(identifier); - } - - @Override - public NormalizedNode create(final YangInstanceIdentifier id, final Optional> deepestChild, final Optional operation) { - checkNotNull(id); - final PathArgument pathArgument = Iterables.get(id.getPathArguments(), 0); - final NormalizedNodeAttrBuilder> builder = getBuilder(pathArgument); - - if(deepestChild.isPresent()) { - builder.withValue(deepestChild.get().getValue()); - } - - addModifyOpIfPresent(operation, builder); - return builder.build(); - } - - protected abstract NormalizedNodeAttrBuilder> getBuilder(PathArgument node); - - @Override - public InstanceIdToNodes getChild(final PathArgument child) { - return null; - } - } - - - public void addModifyOpIfPresent(final Optional operation, final AttributesBuilder builder) { - if(operation.isPresent()) { - builder.withAttributes(Collections.singletonMap(NetconfMessageTransformUtil.NETCONF_OPERATION_QNAME, NetconfMessageTransformUtil.modifyOperationToXmlString(operation.get()))); - } - } - - private static final class LeafNormalization extends SimpleTypeNormalization { - - protected LeafNormalization(final LeafSchemaNode potential) { - super(new NodeIdentifier(potential.getQName())); - } - - @Override - protected NormalizedNodeAttrBuilder> getBuilder(final PathArgument node) { - return Builders.leafBuilder().withNodeIdentifier(getIdentifier()); - } - } - - private static final class LeafListEntryNormalization extends SimpleTypeNormalization { - - public LeafListEntryNormalization(final LeafListSchemaNode potential) { - super(new NodeWithValue(potential.getQName(), null)); - } - - @Override - protected NormalizedNodeAttrBuilder> getBuilder(final PathArgument node) { - Preconditions.checkArgument(node instanceof NodeWithValue); - return Builders.leafSetEntryBuilder().withNodeIdentifier((NodeWithValue) node).withValue(((NodeWithValue) node).getValue()); - } - - } - - private static abstract class CompositeNodeNormalizationOperation extends - InstanceIdToNodes { - - protected CompositeNodeNormalizationOperation(final T identifier) { - super(identifier); - } - - @Override - @SuppressWarnings("unchecked") - public final NormalizedNode create(final YangInstanceIdentifier id, final Optional> lastChild, final Optional operation) { - checkNotNull(id); - final Iterator iterator = id.getPathArguments().iterator(); - final PathArgument legacyData = iterator.next(); - - if (!isMixin(this) && getIdentifier().getNodeType() != null) { - checkArgument(getIdentifier().getNodeType().equals(legacyData.getNodeType()), - "Node QName must be %s was %s", getIdentifier().getNodeType(), legacyData.getNodeType()); - } - final NormalizedNodeContainerBuilder builder = createBuilder(legacyData); - - if (iterator.hasNext()) { - final PathArgument childPath = iterator.next(); - final InstanceIdToNodes childOp = getChildOperation(childPath); - - final YangInstanceIdentifier childId = YangInstanceIdentifier.create(Iterables.skip(id.getPathArguments(), 1)); - builder.addChild(childOp.create(childId, lastChild, operation)); - } else { - if(lastChild.isPresent()) { - builder.withValue(Lists.newArrayList((Collection) lastChild.get().getValue())); - } - if(operation.isPresent()) { - Preconditions.checkArgument(builder instanceof AttributesBuilder); - addModifyOpIfPresent(operation, ((AttributesBuilder) builder)); - } - } - - return builder.build(); - } - - private InstanceIdToNodes getChildOperation(final PathArgument childPath) { - final InstanceIdToNodes childOp; - try { - childOp = getChild(childPath); - } catch (final DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Failed to process child node %s", childPath), e); - } - checkArgument(childOp != null, "Node %s is not allowed inside %s", childPath, getIdentifier()); - return childOp; - } - - @SuppressWarnings("rawtypes") - protected abstract NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode); - } - - static boolean isMixin(final InstanceIdToNodes op) { - return op instanceof MixinNormalizationOp; - } - - private static abstract class DataContainerNormalizationOperation extends - CompositeNodeNormalizationOperation { - - private final DataNodeContainer schema; - private final Map> byArg; - - protected DataContainerNormalizationOperation(final T identifier, final DataNodeContainer schema) { - super(identifier); - this.schema = schema; - this.byArg = new ConcurrentHashMap<>(); - } - - @Override - public InstanceIdToNodes getChild(final PathArgument child) throws DataNormalizationException { - InstanceIdToNodes potential = byArg.get(child); - if (potential != null) { - return potential; - } - potential = fromLocalSchema(child); - return register(potential); - } - - private InstanceIdToNodes fromLocalSchema(final PathArgument child) throws DataNormalizationException { - if (child instanceof AugmentationIdentifier) { - return fromSchemaAndQNameChecked(schema, ((AugmentationIdentifier) child).getPossibleChildNames() - .iterator().next()); - } - return fromSchemaAndQNameChecked(schema, child.getNodeType()); - } - - private InstanceIdToNodes register(final InstanceIdToNodes potential) { - if (potential != null) { - byArg.put(potential.getIdentifier(), potential); - } - return potential; - } - } - - private static final class ListItemNormalization extends - DataContainerNormalizationOperation { - - protected ListItemNormalization(final NodeIdentifierWithPredicates identifier, final ListSchemaNode schema) { - super(identifier, schema); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument currentArg) { - final DataContainerNodeAttrBuilder builder = Builders - .mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates) currentArg); - for (final Entry keyValue : ((NodeIdentifierWithPredicates) currentArg).getKeyValues().entrySet()) { - builder.addChild(Builders.leafBuilder() - // - .withNodeIdentifier(new NodeIdentifier(keyValue.getKey())).withValue(keyValue.getValue()) - .build()); - } - return builder; - } - - } - - private static final class UnkeyedListItemNormalization extends DataContainerNormalizationOperation { - - protected UnkeyedListItemNormalization(final ListSchemaNode schema) { - super(new NodeIdentifier(schema.getQName()), schema); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.unkeyedListEntryBuilder().withNodeIdentifier(getIdentifier()); - } - - } - - private static final class ContainerTransformation extends DataContainerNormalizationOperation { - - protected ContainerTransformation(final ContainerSchemaNode schema) { - super(new NodeIdentifier(schema.getQName()), schema); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.containerBuilder().withNodeIdentifier(getIdentifier()); - } - } - - /** - * Marker interface for Mixin nodes normalization operations - */ - private interface MixinNormalizationOp {} - - - private static final class OrderedLeafListMixinNormalization extends UnorderedLeafListMixinNormalization { - - - public OrderedLeafListMixinNormalization(final LeafListSchemaNode potential) { - super(potential); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.orderedLeafSetBuilder().withNodeIdentifier(getIdentifier()); - } - } - - private static class UnorderedLeafListMixinNormalization extends CompositeNodeNormalizationOperation implements MixinNormalizationOp { - - private final InstanceIdToNodes innerOp; - - public UnorderedLeafListMixinNormalization(final LeafListSchemaNode potential) { - super(new NodeIdentifier(potential.getQName())); - innerOp = new LeafListEntryNormalization(potential); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier()); - } - - @Override - public InstanceIdToNodes getChild(final PathArgument child) { - if (child instanceof NodeWithValue) { - return innerOp; - } - return null; - } - } - - private static final class AugmentationNormalization extends DataContainerNormalizationOperation implements MixinNormalizationOp { - - public AugmentationNormalization(final AugmentationSchema augmentation, final DataNodeContainer schema) { - //super(); - super(augmentationIdentifierFrom(augmentation), augmentationProxy(augmentation, schema)); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.augmentationBuilder().withNodeIdentifier(getIdentifier()); - } - } - - private static class UnorderedMapMixinNormalization extends CompositeNodeNormalizationOperation implements MixinNormalizationOp { - - private final ListItemNormalization innerNode; - - public UnorderedMapMixinNormalization(final ListSchemaNode list) { - super(new NodeIdentifier(list.getQName())); - this.innerNode = new ListItemNormalization(new NodeIdentifierWithPredicates(list.getQName(), - Collections.emptyMap()), list); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.mapBuilder().withNodeIdentifier(getIdentifier()); - } - - @Override - public InstanceIdToNodes getChild(final PathArgument child) { - if (child.getNodeType().equals(getIdentifier().getNodeType())) { - return innerNode; - } - return null; - } - } - - private static class UnkeyedListMixinNormalization extends CompositeNodeNormalizationOperation implements MixinNormalizationOp { - - private final UnkeyedListItemNormalization innerNode; - - public UnkeyedListMixinNormalization(final ListSchemaNode list) { - super(new NodeIdentifier(list.getQName())); - this.innerNode = new UnkeyedListItemNormalization(list); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.unkeyedListBuilder().withNodeIdentifier(getIdentifier()); - } - - @Override - public InstanceIdToNodes getChild(final PathArgument child) { - if (child.getNodeType().equals(getIdentifier().getNodeType())) { - return innerNode; - } - return null; - } - - } - - private static final class OrderedMapMixinNormalization extends UnorderedMapMixinNormalization { - - public OrderedMapMixinNormalization(final ListSchemaNode list) { - super(list); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.orderedMapBuilder().withNodeIdentifier(getIdentifier()); - } - - } - - private static class ChoiceNodeNormalization extends CompositeNodeNormalizationOperation implements MixinNormalizationOp { - - private final ImmutableMap> byArg; - - protected ChoiceNodeNormalization(final ChoiceSchemaNode schema) { - super(new NodeIdentifier(schema.getQName())); - final ImmutableMap.Builder> byArgBuilder = ImmutableMap.builder(); - - for (final ChoiceCaseNode caze : schema.getCases()) { - for (final DataSchemaNode cazeChild : caze.getChildNodes()) { - final InstanceIdToNodes childOp = fromDataSchemaNode(cazeChild); - byArgBuilder.put(childOp.getIdentifier(), childOp); - } - } - byArg = byArgBuilder.build(); - } - - @Override - public InstanceIdToNodes getChild(final PathArgument child) { - return byArg.get(child); - } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument compositeNode) { - return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()); - } - } - - private static class AnyXmlNormalization extends InstanceIdToNodes { - - protected AnyXmlNormalization(final AnyXmlSchemaNode schema) { - super(new NodeIdentifier(schema.getQName())); - } - - @Override - public InstanceIdToNodes getChild(final PathArgument child) throws DataNormalizationException { - return null; - } - - @Override - public NormalizedNode create(final YangInstanceIdentifier legacyData, final Optional> deepestChild, final Optional operation) { - if(deepestChild.isPresent()) { - Preconditions.checkState(deepestChild instanceof AnyXmlNode); - final NormalizedNodeAttrBuilder anyXmlBuilder = - Builders.anyXmlBuilder().withNodeIdentifier(getIdentifier()).withValue(((AnyXmlNode) deepestChild).getValue()); - addModifyOpIfPresent(operation, anyXmlBuilder); - return anyXmlBuilder.build(); - } - - final NormalizedNodeAttrBuilder builder = - Builders.anyXmlBuilder().withNodeIdentifier(getIdentifier()); - addModifyOpIfPresent(operation, builder); - return builder.build(); - } - - } - - private static Optional findChildSchemaNode(final DataNodeContainer parent, final QName child) { - DataSchemaNode potential = parent.getDataChildByName(child); - if (potential == null) { - final Iterable choices = FluentIterable.from(parent.getChildNodes()).filter(ChoiceSchemaNode.class); - potential = findChoice(choices, child); - } - return Optional.fromNullable(potential); - } - - private static InstanceIdToNodes fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) throws DataNormalizationException { - final Optional potential = findChildSchemaNode(schema, child); - if (!potential.isPresent()) { - throw new DataNormalizationException(String.format("Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, schema.getChildNodes())); - } - - final DataSchemaNode result = potential.get(); - // We try to look up if this node was added by augmentation - if ((schema instanceof DataSchemaNode) && result.isAugmenting()) { - return fromAugmentation(schema, (AugmentationTarget) schema, result); - } - return fromDataSchemaNode(result); - } - - private static ChoiceSchemaNode findChoice(final Iterable choices, final QName child) { - org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode foundChoice = null; - choiceLoop: - for (final ChoiceSchemaNode choice : choices) { - for (final ChoiceCaseNode caze : choice.getCases()) { - if (findChildSchemaNode(caze, child).isPresent()) { - foundChoice = choice; - break choiceLoop; - } - } - } - return foundChoice; - } - - private static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchema augmentation) { - final ImmutableSet.Builder potentialChildren = ImmutableSet.builder(); - for (final DataSchemaNode child : augmentation.getChildNodes()) { - potentialChildren.add(child.getQName()); - } - return new AugmentationIdentifier(potentialChildren.build()); - } - - private static DataNodeContainer augmentationProxy(final AugmentationSchema augmentation, final DataNodeContainer schema) { - final Set children = new HashSet<>(); - for (final DataSchemaNode augNode : augmentation.getChildNodes()) { - children.add(schema.getDataChildByName(augNode.getQName())); - } - return new NodeContainerProxy(null, children); - } - - /** - * Returns a SchemaPathUtil for provided child node - *

    - * If supplied child is added by Augmentation this operation returns - * a SchemaPathUtil for augmentation, - * otherwise returns a SchemaPathUtil for child as - * call for {@link #fromDataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode)}. - */ - private static InstanceIdToNodes fromAugmentation(final DataNodeContainer parent, - final AugmentationTarget parentAug, final DataSchemaNode child) { - AugmentationSchema augmentation = null; - for (final AugmentationSchema aug : parentAug.getAvailableAugmentations()) { - final DataSchemaNode potential = aug.getDataChildByName(child.getQName()); - if (potential != null) { - augmentation = aug; - break; - } - - } - if (augmentation != null) { - return new AugmentationNormalization(augmentation, parent); - } else { - return fromDataSchemaNode(child); - } - } - - private static InstanceIdToNodes fromDataSchemaNode(final DataSchemaNode potential) { - if (potential instanceof ContainerSchemaNode) { - return new ContainerTransformation((ContainerSchemaNode) potential); - } else if (potential instanceof ListSchemaNode) { - return fromListSchemaNode((ListSchemaNode) potential); - } else if (potential instanceof LeafSchemaNode) { - return new LeafNormalization((LeafSchemaNode) potential); - } else if (potential instanceof ChoiceSchemaNode) { - return new ChoiceNodeNormalization((ChoiceSchemaNode) potential); - } else if (potential instanceof LeafListSchemaNode) { - return fromLeafListSchemaNode((LeafListSchemaNode) potential); - } else if (potential instanceof AnyXmlSchemaNode) { - return new AnyXmlNormalization((AnyXmlSchemaNode) potential); - } - return null; - } - - private static InstanceIdToNodes fromListSchemaNode(final ListSchemaNode potential) { - final List keyDefinition = potential.getKeyDefinition(); - if (keyDefinition == null || keyDefinition.isEmpty()) { - return new UnkeyedListMixinNormalization(potential); - } - if (potential.isUserOrdered()) { - return new OrderedMapMixinNormalization(potential); - } - return new UnorderedMapMixinNormalization(potential); - } - - private static InstanceIdToNodes fromLeafListSchemaNode(final LeafListSchemaNode potential) { - if (potential.isUserOrdered()) { - return new OrderedLeafListMixinNormalization(potential); - } - return new UnorderedLeafListMixinNormalization(potential); - } - - public static NormalizedNode serialize(final SchemaContext ctx, final YangInstanceIdentifier id) { - return serialize(ctx, id, Optional.>absent(), Optional.absent()); - } - - public static NormalizedNode serialize(final SchemaContext ctx, final YangInstanceIdentifier id, final NormalizedNode deepestElement) { - return serialize(ctx, id, Optional.>of(deepestElement), Optional.absent()); - } - - public static NormalizedNode serialize(final SchemaContext ctx, final YangInstanceIdentifier id, final Optional> deepestElement, final Optional operation) { - Preconditions.checkNotNull(ctx); - Preconditions.checkNotNull(id); - final PathArgument topLevelElement = id.getPathArguments().iterator().next(); - final DataSchemaNode dataChildByName = ctx.getDataChildByName(topLevelElement.getNodeType()); - Preconditions.checkNotNull(dataChildByName, "Cannot find %s node in schema context. Instance identifier has to start from root", topLevelElement); - try { - final InstanceIdToNodes instanceIdToNodes = fromSchemaAndQNameChecked(ctx, topLevelElement.getNodeType()); - return instanceIdToNodes.create(id, deepestElement, operation); - } catch (final DataNormalizationException e) { - throw new IllegalArgumentException("Unable to serialize: " + id, e); - } - } -} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfBaseOps.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfBaseOps.java index c19bb48408..bf432d3860 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfBaseOps.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfBaseOps.java @@ -235,7 +235,8 @@ public final class NetconfBaseOps { // Default operation if(defaultOperation.isPresent()) { - editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(toId(NETCONF_DEFAULT_OPERATION_QNAME)).withValue(NetconfMessageTransformUtil.modifyOperationToXmlString(defaultOperation.get())).build()); + final String opString = defaultOperation.get().name().toLowerCase(); + editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(toId(NETCONF_DEFAULT_OPERATION_QNAME)).withValue(opString).build()); } // Error option diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java index dc1c8c7c40..1da39cf751 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java @@ -14,6 +14,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.io.IOException; import java.net.URI; +import java.util.AbstractMap; import java.util.Collections; import java.util.Map; import java.util.Map.Entry; @@ -44,6 +45,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; @@ -145,7 +147,7 @@ public class NetconfMessageTransformUtil { final NormalizedNodeAttrBuilder anyXmlBuilder = Builders.anyXmlBuilder().withNodeIdentifier(toId(NETCONF_FILTER_QNAME)); anyXmlBuilder.withAttributes(Collections.singletonMap(NETCONF_TYPE_QNAME, SUBTREE)); - final NormalizedNode filterContent = InstanceIdToNodes.serialize(ctx, identifier); + final NormalizedNode filterContent = ImmutableNodes.fromInstanceId(ctx, identifier); final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_FILTER_QNAME.getLocalName(), Optional.of(NETCONF_FILTER_QNAME.getNamespace().toString())); element.setAttributeNS(NETCONF_FILTER_QNAME.getNamespace().toString(), NETCONF_TYPE_QNAME.getLocalName(), "subtree"); @@ -268,7 +270,9 @@ public class NetconfMessageTransformUtil { "Data has to be either container or a list node when creating structure for top level element, but was: %s", lastChildOverride.get()); configContent = lastChildOverride.get(); } else { - configContent = InstanceIdToNodes.serialize(ctx, dataPath, lastChildOverride, operation); + final Entry modifyOperation = + operation.isPresent() ? new AbstractMap.SimpleEntry<>(NETCONF_OPERATION_QNAME, operation.get()) : null; + configContent = ImmutableNodes.fromInstanceId(ctx, dataPath, lastChildOverride, Optional.fromNullable(modifyOperation)); } final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_CONFIG_QNAME.getLocalName(), Optional.of(NETCONF_CONFIG_QNAME.getNamespace().toString())); @@ -287,10 +291,6 @@ public class NetconfMessageTransformUtil { return SchemaPath.create(true, rpc); } - public static String modifyOperationToXmlString(final ModifyAction operation) { - return operation.name().toLowerCase(); - } - // FIXME similar code is in netconf-notifications-impl , DRY public static void writeNormalizedNode(final NormalizedNode normalized, final DOMResult result, final SchemaPath schemaPath, final SchemaContext context) throws IOException, XMLStreamException { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NodeContainerProxy.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NodeContainerProxy.java index b499bd8f6f..23e2137026 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NodeContainerProxy.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NodeContainerProxy.java @@ -28,7 +28,10 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.UsesNode; -class NodeContainerProxy implements ContainerSchemaNode { +/** + * Simple proxy for container like schema nodes, where user provides a collection of children schema nodes + */ +public final class NodeContainerProxy implements ContainerSchemaNode { private final Map childNodes; private final QName qName; @@ -146,4 +149,4 @@ class NodeContainerProxy implements ContainerSchemaNode { public List getUnknownSchemaNodes() { return Collections.emptyList(); } -} +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java index e4f7fab6f0..7f867a8997 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfStateSchemasTest.java @@ -27,7 +27,7 @@ public class NetconfStateSchemasTest { final DataSchemaNode schemasNode = ((ContainerSchemaNode) NetconfDevice.INIT_SCHEMA_CTX.getDataChildByName("netconf-state")).getDataChildByName("schemas"); final Document schemasXml = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/netconf-state.schemas.payload.xml")); - final ToNormalizedNodeParser containerNodeParser = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, NetconfDevice.INIT_SCHEMA_CTX).getContainerNodeParser(); + final ToNormalizedNodeParser containerNodeParser = DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, NetconfDevice.INIT_SCHEMA_CTX, false).getContainerNodeParser(); final ContainerNode compositeNodeSchemas = containerNodeParser.parse(Collections.singleton(schemasXml.getDocumentElement()), (ContainerSchemaNode) schemasNode); final NetconfStateSchemas schemas = NetconfStateSchemas.create(new RemoteDeviceId("device", new InetSocketAddress(99)), compositeNodeSchemas); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToNotificationTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToNotificationTest.java index 157a3b719e..294efadc6f 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToNotificationTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToNotificationTest.java @@ -36,7 +36,7 @@ public class NetconfToNotificationTest { public void setup() throws Exception { final SchemaContext schemaContext = getNotificationSchemaContext(getClass()); - messageTransformer = new NetconfMessageTransformer(schemaContext); + messageTransformer = new NetconfMessageTransformer(schemaContext, true); final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToRpcRequestTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToRpcRequestTest.java index 49f0abafc7..aa5f59be8d 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToRpcRequestTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfToRpcRequestTest.java @@ -69,7 +69,7 @@ public class NetconfToRpcRequestTest { cfgCtx = parser.resolveSchemaContext(Sets.union(configModules, notifModules)); assertNotNull(cfgCtx); - messageTransformer = new NetconfMessageTransformer(cfgCtx); + messageTransformer = new NetconfMessageTransformer(cfgCtx, true); } private LeafNode buildLeaf(final QName running, final Object value) { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java index 86385c3e91..a43f807e0f 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java @@ -285,7 +285,7 @@ public class NetconfMessageTransformerTest { } private NetconfMessageTransformer getTransformer(final SchemaContext schema) { - return new NetconfMessageTransformer(schema); + return new NetconfMessageTransformer(schema, true); } @Test diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/util/InstanceIdToNodesTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/util/InstanceIdToNodesTest.java deleted file mode 100644 index 39a8f42f49..0000000000 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/util/InstanceIdToNodesTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html. - */ -package org.opendaylight.controller.sal.connect.netconf.util; - -import static org.junit.Assert.assertEquals; - -import com.google.common.base.Function; -import com.google.common.collect.Collections2; -import com.google.common.io.ByteSource; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; - -public class InstanceIdToNodesTest { - - private static final String NS = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test"; - private static final String REVISION = "2014-03-13"; - private static final QName ID = QName.create(NS, REVISION, "id"); - private SchemaContext ctx; - - private final YangInstanceIdentifier.NodeIdentifier rootContainer = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "test")); - private final YangInstanceIdentifier.NodeIdentifier outerContainer = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "outer-container")); - private final YangInstanceIdentifier.NodeIdentifier augmentedLeaf = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "augmented-leaf")); - private final YangInstanceIdentifier.AugmentationIdentifier augmentation = new YangInstanceIdentifier.AugmentationIdentifier(Collections.singleton(augmentedLeaf.getNodeType())); - - private final YangInstanceIdentifier.NodeIdentifier outerList = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "outer-list")); - private final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListWithKey = new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(NS, REVISION, "outer-list"), ID, 1); - private final YangInstanceIdentifier.NodeIdentifier choice = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "outer-choice")); - private final YangInstanceIdentifier.NodeIdentifier leafFromCase = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "one")); - - private final YangInstanceIdentifier.NodeIdentifier leafList = new YangInstanceIdentifier.NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list")); - private final YangInstanceIdentifier.NodeWithValue leafListWithValue = new YangInstanceIdentifier.NodeWithValue(leafList.getNodeType(), "abcd"); - - static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException { - final YangParserImpl parser = new YangParserImpl(); - return parser.parseSources(Collections2.transform(Collections.singletonList("/schemas/filter-test.yang"), new Function() { - @Override - public ByteSource apply(final String input) { - return new ByteSource() { - @Override - public InputStream openStream() throws IOException { - return InstanceIdToNodesTest.class.getResourceAsStream(input); - } - }; - } - })); - } - - @Before - public void setUp() throws Exception { - ctx = createTestContext(); - - } - - @Test - public void testInAugment() throws Exception { - final ContainerNode expectedFilter = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( - Builders.containerBuilder().withNodeIdentifier(outerContainer).withChild( - Builders.augmentationBuilder().withNodeIdentifier(augmentation).withChild( - Builders.leafBuilder().withNodeIdentifier(augmentedLeaf).build() - ).build() - ).build() - ).build(); - - final NormalizedNode filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer, outerContainer, augmentation, augmentedLeaf)); - assertEquals(expectedFilter, filter); - } - - @Test - public void testInAugmentLeafOverride() throws Exception { - final LeafNode lastLeaf = Builders.leafBuilder().withNodeIdentifier(augmentedLeaf).withValue("randomValue").build(); - - final ContainerNode expectedFilter = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( - Builders.containerBuilder().withNodeIdentifier(outerContainer).withChild( - Builders.augmentationBuilder().withNodeIdentifier(augmentation).withChild( - lastLeaf - ).build() - ).build() - ).build(); - - final NormalizedNode filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer, outerContainer, augmentation, augmentedLeaf), lastLeaf); - assertEquals(expectedFilter, filter); - } - - @Test - public void testListChoice() throws Exception { - final ContainerNode expectedFilter = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( - Builders.mapBuilder().withNodeIdentifier(outerList).withChild( - Builders.mapEntryBuilder().withNodeIdentifier(outerListWithKey).withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)).withValue(1).build() - ).withChild( - Builders.choiceBuilder().withNodeIdentifier(choice).withChild( - Builders.leafBuilder().withNodeIdentifier(leafFromCase).build() - ).build() - ).build() - ).build() - ).build(); - - final NormalizedNode filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer, outerList, outerListWithKey, choice, leafFromCase)); - assertEquals(expectedFilter, filter); - } - - @Test - public void testTopContainerLastChildOverride() throws Exception { - final ContainerNode expectedStructure = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( - Builders.mapBuilder().withNodeIdentifier(outerList).withChild( - Builders.mapEntryBuilder().withNodeIdentifier(outerListWithKey).withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)).withValue(1).build() - ).withChild( - Builders.choiceBuilder().withNodeIdentifier(choice).withChild( - Builders.leafBuilder().withNodeIdentifier(leafFromCase).build() - ).build() - ).build() - ).build() - ).build(); - - final NormalizedNode filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer), expectedStructure); - assertEquals(expectedStructure, filter); - } - - @Test - public void testListLastChildOverride() throws Exception { - final MapEntryNode outerListEntry = Builders.mapEntryBuilder().withNodeIdentifier(outerListWithKey).withChild( - Builders.leafBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID)).withValue(1).build() - ).build(); - final MapNode lastChild = Builders.mapBuilder().withNodeIdentifier(this.outerList).withChild( - outerListEntry - ).build(); - final ContainerNode expectedStructure = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( - lastChild - ).build(); - - NormalizedNode filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer, outerList, outerListWithKey), outerListEntry); - assertEquals(expectedStructure, filter); - filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer, outerList, outerListWithKey)); - assertEquals(expectedStructure, filter); - } - - @Test - public void testLeafList() throws Exception { - final ContainerNode expectedFilter = Builders.containerBuilder().withNodeIdentifier(rootContainer).withChild( - Builders.orderedLeafSetBuilder().withNodeIdentifier(leafList).withChild( - Builders.leafSetEntryBuilder().withNodeIdentifier(leafListWithValue).withValue(leafListWithValue.getValue()).build() - ).build() - ).build(); - - final NormalizedNode filter = InstanceIdToNodes.serialize(ctx, YangInstanceIdentifier.create(rootContainer, leafList, leafListWithValue)); - assertEquals(expectedFilter, filter); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/resources/schemas/filter-test.yang b/opendaylight/md-sal/sal-netconf-connector/src/test/resources/schemas/filter-test.yang deleted file mode 100644 index 6df5306850..0000000000 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/resources/schemas/filter-test.yang +++ /dev/null @@ -1,74 +0,0 @@ -module normalization-test { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test"; - prefix "norm-test"; - - revision "2014-03-13" { - description "Initial revision."; - } - - grouping outer-grouping { - } - - container test { - list outer-list { - key id; - leaf id { - type uint16; - } - choice outer-choice { - case one { - leaf one { - type string; - } - } - case two-three { - leaf two { - type string; - } - leaf three { - type string; - } - } - } - list inner-list { - key name; - ordered-by user; - - leaf name { - type string; - } - leaf value { - type string; - } - } - } - - list unkeyed-list { - leaf name { - type string; - } - } - - leaf-list unordered-leaf-list { - type string; - } - - leaf-list ordered-leaf-list { - ordered-by user; - type string; - } - - container outer-container { - } - - anyxml any-xml-data; - } - - augment /norm-test:test/norm-test:outer-container { - - leaf augmented-leaf { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-remote/pom.xml b/opendaylight/md-sal/sal-remote/pom.xml index d47cf4ca07..eb4b34ee39 100644 --- a/opendaylight/md-sal/sal-remote/pom.xml +++ b/opendaylight/md-sal/sal-remote/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-remote bundle diff --git a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml index ec5bb215bf..c41cd7c7f7 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-remoterpc-connector bundle diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java index f12fda0aa1..f3cb78a301 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java @@ -75,7 +75,7 @@ public class RpcManager extends AbstractUntypedActor { LOG.debug("Create rpc registry and broker actors"); rpcRegistry = - getContext().actorOf(Props.create(RpcRegistry.class). + getContext().actorOf(RpcRegistry.props(). withMailbox(config.getMailBoxName()), config.getRpcRegistryName()); rpcBroker = diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java index f67657f692..fa93a3b83f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java @@ -13,6 +13,8 @@ import akka.japi.Pair; import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Set; + import org.opendaylight.controller.remote.rpc.registry.gossip.Copier; import org.opendaylight.controller.sal.connector.api.RpcRouter; @@ -41,6 +43,10 @@ public class RoutingTable implements Copier, Serializable { } } + public Set> getRoutes() { + return table.keySet(); + } + public void addRoute(RpcRouter.RouteIdentifier routeId){ table.put(routeId, System.currentTimeMillis()); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java index 219646d847..1dcc4e1405 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java @@ -8,6 +8,8 @@ package org.opendaylight.controller.remote.rpc.registry; import akka.actor.ActorRef; +import akka.actor.Props; +import akka.japi.Creator; import akka.japi.Option; import akka.japi.Pair; import com.google.common.base.Preconditions; @@ -19,6 +21,8 @@ import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.Remo import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter; import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket; import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore; +import org.opendaylight.controller.remote.rpc.registry.mbeans.RemoteRpcRegistryMXBean; +import org.opendaylight.controller.remote.rpc.registry.mbeans.RemoteRpcRegistryMXBeanImpl; import org.opendaylight.controller.sal.connector.api.RpcRouter; import org.opendaylight.controller.sal.connector.api.RpcRouter.RouteIdentifier; @@ -34,6 +38,10 @@ public class RpcRegistry extends BucketStore { getLocalBucket().setData(new RoutingTable()); } + public static Props props() { + return Props.create(new RpcRegistryCreator()); + } + @Override protected void handleReceive(Object message) throws Exception { //TODO: if sender is remote, reject message @@ -220,4 +228,15 @@ public class RpcRegistry extends BucketStore { } } } + + private static class RpcRegistryCreator implements Creator { + private static final long serialVersionUID = 1L; + + @Override + public RpcRegistry create() throws Exception { + RpcRegistry registry = new RpcRegistry(); + RemoteRpcRegistryMXBean mxBean = new RemoteRpcRegistryMXBeanImpl(registry); + return registry; + } + } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java index 628deb4311..febff0bc92 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java @@ -13,7 +13,6 @@ import akka.actor.ActorRefProvider; import akka.actor.Address; import akka.actor.Props; import akka.cluster.ClusterActorRefProvider; -import com.google.common.annotations.VisibleForTesting; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -230,7 +229,7 @@ public class BucketStore> extends AbstractUntypedActorWithMe } } - protected BucketImpl getLocalBucket() { + public BucketImpl getLocalBucket() { return localBucket; } @@ -239,12 +238,11 @@ public class BucketStore> extends AbstractUntypedActorWithMe versions.put(selfAddress, localBucket.getVersion()); } - protected Map> getRemoteBuckets() { + public Map> getRemoteBuckets() { return remoteBuckets; } - @VisibleForTesting - Map getVersions() { + public Map getVersions() { return versions; } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBean.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBean.java new file mode 100644 index 0000000000..ddd33336ed --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBean.java @@ -0,0 +1,22 @@ +package org.opendaylight.controller.remote.rpc.registry.mbeans; + + +import java.util.Map; +import java.util.Set; + +/** + * JMX bean to check remote rpc registry + */ + +public interface RemoteRpcRegistryMXBean { + + Set getGlobalRpc(); + + String getBucketVersions(); + + Set getLocalRegisteredRoutedRpc(); + + Map findRpcByName(String name); + + Map findRpcByRoute(String route); +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java new file mode 100644 index 0000000000..c7d9b9955d --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java @@ -0,0 +1,156 @@ +package org.opendaylight.controller.remote.rpc.registry.mbeans; + +import akka.actor.Address; +import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean; +import org.opendaylight.controller.remote.rpc.registry.RoutingTable; +import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; +import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket; +import org.opendaylight.controller.sal.connector.api.RpcRouter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements RemoteRpcRegistryMXBean { + + protected final Logger log = LoggerFactory.getLogger(getClass()); + + private final String NULL_CONSTANT = "null"; + + private final String LOCAL_CONSTANT = "local"; + + private final String ROUTE_CONSTANT = "route:"; + + private final String NAME_CONSTANT = " | name:"; + + private final RpcRegistry rpcRegistry; + + public RemoteRpcRegistryMXBeanImpl(final RpcRegistry rpcRegistry) { + super("RemoteRpcRegistry", "RemoteRpcBroker", null); + this.rpcRegistry = rpcRegistry; + registerMBean(); + } + + @Override + public Set getGlobalRpc() { + RoutingTable table = rpcRegistry.getLocalBucket().getData(); + Set globalRpc = new HashSet<>(table.getRoutes().size()); + for(RpcRouter.RouteIdentifier route : table.getRoutes()){ + if(route.getRoute() == null) { + globalRpc.add(route.getType() != null ? route.getType().toString() : NULL_CONSTANT); + } + } + if(log.isDebugEnabled()) { + log.debug("Locally registered global RPCs {}", globalRpc); + } + return globalRpc; + } + + @Override + public Set getLocalRegisteredRoutedRpc() { + RoutingTable table = rpcRegistry.getLocalBucket().getData(); + Set routedRpc = new HashSet<>(table.getRoutes().size()); + for(RpcRouter.RouteIdentifier route : table.getRoutes()){ + if(route.getRoute() != null) { + StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); + builder.append(route.getRoute().toString()).append(NAME_CONSTANT).append(route.getType() != null ? + route.getType().toString() : NULL_CONSTANT); + routedRpc.add(builder.toString()); + } + } + if(log.isDebugEnabled()) { + log.debug("Locally registered routed RPCs {}", routedRpc); + } + return routedRpc; + } + + @Override + public Map findRpcByName(final String name) { + RoutingTable localTable = rpcRegistry.getLocalBucket().getData(); + // Get all RPCs from local bucket + Map rpcMap = new HashMap<>(getRpcMemberMapByName(localTable, name, LOCAL_CONSTANT)); + + // Get all RPCs from remote bucket + Map> buckets = rpcRegistry.getRemoteBuckets(); + for(Address address : buckets.keySet()) { + RoutingTable table = buckets.get(address).getData(); + rpcMap.putAll(getRpcMemberMapByName(table, name, address.toString())); + } + if(log.isDebugEnabled()) { + log.debug("list of RPCs {} searched by name {}", rpcMap, name); + } + return rpcMap; + } + + @Override + public Map findRpcByRoute(String routeId) { + RoutingTable localTable = rpcRegistry.getLocalBucket().getData(); + Map rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT)); + + Map> buckets = rpcRegistry.getRemoteBuckets(); + for(Address address : buckets.keySet()) { + RoutingTable table = buckets.get(address).getData(); + rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, address.toString())); + + } + if(log.isDebugEnabled()) { + log.debug("list of RPCs {} searched by route {}", rpcMap, routeId); + } + return rpcMap; + } + + /** + * Search if the routing table route String contains routeName + */ + + private Map getRpcMemberMapByRoute(final RoutingTable table, final String routeName, + final String address) { + Set> routes = table.getRoutes(); + Map rpcMap = new HashMap<>(routes.size()); + for(RpcRouter.RouteIdentifier route : table.getRoutes()){ + if(route.getRoute() != null) { + String routeString = route.getRoute().toString(); + if(routeString.contains(routeName)) { + StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); + builder.append(routeString).append(NAME_CONSTANT).append(route.getType() != null ? + route.getType().toString() : NULL_CONSTANT); + rpcMap.put(builder.toString(), address); + } + } + } + return rpcMap; + } + + /** + * Search if the routing table route type contains name + */ + private Map getRpcMemberMapByName(final RoutingTable table, final String name, + final String address) { + Set> routes = table.getRoutes(); + Map rpcMap = new HashMap<>(routes.size()); + for(RpcRouter.RouteIdentifier route : routes){ + if(route.getType() != null) { + String type = route.getType().toString(); + if(type.contains(name)) { + StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); + builder.append(route.getRoute() != null ? route.getRoute().toString(): NULL_CONSTANT) + .append(NAME_CONSTANT).append(type); + rpcMap.put(builder.toString(), address); + } + } + } + return rpcMap; + } + + + + @Override + public String getBucketVersions() { + return rpcRegistry.getVersions().toString(); + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector-config/pom.xml b/opendaylight/md-sal/sal-rest-connector-config/pom.xml index dc3dd8e476..7be6cecc8c 100644 --- a/opendaylight/md-sal/sal-rest-connector-config/pom.xml +++ b/opendaylight/md-sal/sal-rest-connector-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-rest-connector-config Configuration files for sal-rest-connector diff --git a/opendaylight/md-sal/sal-rest-connector/pom.xml b/opendaylight/md-sal/sal-rest-connector/pom.xml index 3fcecfd929..4e50fdf99c 100644 --- a/opendaylight/md-sal/sal-rest-connector/pom.xml +++ b/opendaylight/md-sal/sal-rest-connector/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-rest-connector bundle @@ -99,7 +99,7 @@ org.opendaylight.yangtools yang-model-export - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java index 10399ffeff..3be247a3bb 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java @@ -90,7 +90,7 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr NormalizedNode partialResult = resultHolder.getResult(); final NormalizedNode result; - // unwrap result from augmentation and choice nodes on PUT + // FIXME: Also II should be updated unwrap result from augmentation and choice nodes on PUT if (!isPost()) { while (partialResult instanceof AugmentationNode || partialResult instanceof ChoiceNode) { final Object childNode = ((DataContainerNode) partialResult).getValue().iterator().next(); @@ -98,12 +98,14 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr } } - if (partialResult instanceof MapNode) { + if (partialResult instanceof MapNode && !isPost()) { result = Iterables.getOnlyElement(((MapNode) partialResult).getValue()); } else { result = partialResult; } return new NormalizedNodeContext(path,result); + } catch (final RestconfDocumentedException e) { + throw e; } catch (final Exception e) { LOG.debug("Error parsing json input", e); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java index 74a9bd2d31..2a9c5bf190 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java @@ -104,6 +104,8 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro final NormalizedNode result = parse(path,doc); return new NormalizedNodeContext(path,result); + } catch (final RestconfDocumentedException e){ + throw e; } catch (final Exception e) { LOG.debug("Error parsing xml input", e); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java index 346d54a773..6a3adcccd6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java @@ -11,6 +11,7 @@ import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastor import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; 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.ListenableFuture; import java.util.ArrayList; @@ -20,11 +21,7 @@ import java.util.concurrent.ExecutionException; import javax.ws.rs.core.Response.Status; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; @@ -42,7 +39,10 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,38 +106,34 @@ public class BrokerFacade { // PUT configuration public CheckedFuture commitConfigurationDataPut( - final YangInstanceIdentifier path, final NormalizedNode payload) { + final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode payload) { checkPreconditions(); - final DataNormalizationOperation rootOp = ControllerContext.getInstance().getRootOperation(); - return putDataViaTransaction(domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, rootOp); + return putDataViaTransaction(domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, globalSchema); } public CheckedFuture commitConfigurationDataPut( final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode payload) { final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { - final DataNormalizationOperation rootOp = new DataNormalizer(mountPoint.getSchemaContext()).getRootOperation(); return putDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path, - payload, rootOp); + payload, mountPoint.getSchemaContext()); } throw new RestconfDocumentedException("DOM data broker service isn't available for mount point."); } // POST configuration public CheckedFuture commitConfigurationDataPost( - final YangInstanceIdentifier path, final NormalizedNode payload) { + final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode payload) { checkPreconditions(); - final DataNormalizationOperation rootOp = ControllerContext.getInstance().getRootOperation(); - return postDataViaTransaction(domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, rootOp); + return postDataViaTransaction(domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, globalSchema); } public CheckedFuture commitConfigurationDataPost( final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode payload) { final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { - final DataNormalizationOperation rootOp = new DataNormalizer(mountPoint.getSchemaContext()).getRootOperation(); return postDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path, - payload, rootOp); + payload, mountPoint.getSchemaContext()); } throw new RestconfDocumentedException("DOM data broker service isn't available for mount point."); } @@ -206,22 +202,39 @@ public class BrokerFacade { private CheckedFuture postDataViaTransaction( final DOMDataReadWriteTransaction rWTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier parentPath, final NormalizedNode payload, final DataNormalizationOperation root) { + final YangInstanceIdentifier parentPath, final NormalizedNode payload, final SchemaContext schemaContext) { // FIXME: This is doing correct post for container and list children // not sure if this will work for choice case - final YangInstanceIdentifier path; - if(payload instanceof MapEntryNode) { - path = parentPath.node(payload.getNodeType()).node(payload.getIdentifier()); + if(payload instanceof MapNode) { + final YangInstanceIdentifier mapPath = parentPath.node(payload.getIdentifier()); + final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, mapPath); + rWTransaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree); + ensureParentsByMerge(datastore, mapPath, rWTransaction, schemaContext); + for(final MapEntryNode child : ((MapNode) payload).getValue()) { + final YangInstanceIdentifier childPath = mapPath.node(child.getIdentifier()); + checkItemDoesNotExists(rWTransaction, datastore, childPath); + rWTransaction.put(datastore, childPath, child); + } } else { - path = parentPath.node(payload.getIdentifier()); + final YangInstanceIdentifier path; + if(payload instanceof MapEntryNode) { + path = parentPath.node(payload.getNodeType()).node(payload.getIdentifier()); + } else { + path = parentPath.node(payload.getIdentifier()); + } + checkItemDoesNotExists(rWTransaction,datastore, path); + ensureParentsByMerge(datastore, path, rWTransaction, schemaContext); + rWTransaction.put(datastore, path, payload); } + return rWTransaction.submit(); + } - final ListenableFuture>> futureDatastoreData = rWTransaction.read(datastore, path); + private void checkItemDoesNotExists(final DOMDataReadWriteTransaction rWTransaction,final LogicalDatastoreType store, final YangInstanceIdentifier path) { + final ListenableFuture futureDatastoreData = rWTransaction.exists(store, path); try { - final Optional> optionalDatastoreData = futureDatastoreData.get(); - if (optionalDatastoreData.isPresent() && payload.equals(optionalDatastoreData.get())) { + if (futureDatastoreData.get()) { final String errMsg = "Post Configuration via Restconf was not executed because data already exists"; - LOG.trace(errMsg + ":{}", path); + LOG.debug(errMsg + ":{}", path); rWTransaction.cancel(); throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS); @@ -230,17 +243,13 @@ public class BrokerFacade { LOG.trace("It wasn't possible to get data loaded from datastore at path " + path); } - ensureParentsByMerge(datastore, path, rWTransaction, root); - rWTransaction.merge(datastore, path, payload); - LOG.trace("Post " + datastore.name() + " via Restconf: {}", path); - return rWTransaction.submit(); } private CheckedFuture putDataViaTransaction( final DOMDataReadWriteTransaction writeTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final DataNormalizationOperation root) { + final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext) { LOG.trace("Put " + datastore.name() + " via Restconf: {}", path); - ensureParentsByMerge(datastore, path, writeTransaction, root); + ensureParentsByMerge(datastore, path, writeTransaction, schemaContext); writeTransaction.put(datastore, path, payload); return writeTransaction.submit(); } @@ -257,39 +266,34 @@ public class BrokerFacade { this.domDataBroker = domDataBroker; } - private final void ensureParentsByMerge(final LogicalDatastoreType store, - final YangInstanceIdentifier normalizedPath, final DOMDataReadWriteTransaction rwTx, - final DataNormalizationOperation root) { - final List currentArguments = new ArrayList<>(); - final Iterator iterator = normalizedPath.getPathArguments().iterator(); - DataNormalizationOperation currentOp = root; - while (iterator.hasNext()) { - final PathArgument currentArg = iterator.next(); - try { - currentOp = currentOp.getChild(currentArg); - } catch (final DataNormalizationException e) { - rwTx.cancel(); - throw new IllegalArgumentException( - String.format("Invalid child encountered in path %s", normalizedPath), e); - } - currentArguments.add(currentArg); - final YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(currentArguments); - - final Boolean exists; + private void ensureParentsByMerge(final LogicalDatastoreType store, + final YangInstanceIdentifier normalizedPath, final DOMDataReadWriteTransaction rwTx, final SchemaContext schemaContext) { + final List normalizedPathWithoutChildArgs = new ArrayList<>(); + YangInstanceIdentifier rootNormalizedPath = null; - try { + final Iterator it = normalizedPath.getPathArguments().iterator(); - final CheckedFuture future = rwTx.exists(store, currentPath); - exists = future.checkedGet(); - } catch (final ReadFailedException e) { - LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e); - rwTx.cancel(); - throw new IllegalStateException("Failed to read pre-existing data", e); + while(it.hasNext()) { + final PathArgument pathArgument = it.next(); + if(rootNormalizedPath == null) { + rootNormalizedPath = YangInstanceIdentifier.create(pathArgument); } - if (!exists && iterator.hasNext()) { - rwTx.merge(store, currentPath, currentOp.createDefault(currentArg)); + // Skip last element, its not a parent + if(it.hasNext()) { + normalizedPathWithoutChildArgs.add(pathArgument); } } + + // No parent structure involved, no need to ensure parents + if(normalizedPathWithoutChildArgs.isEmpty()) { + return; + } + + Preconditions.checkArgument(rootNormalizedPath != null, "Empty path received"); + + final NormalizedNode parentStructure = + ImmutableNodes.fromInstanceId(schemaContext, YangInstanceIdentifier.create(normalizedPathWithoutChildArgs)); + rwTx.merge(store, rootNormalizedPath, parentStructure); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java index 2da58a3820..6cc62e859c 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java @@ -153,6 +153,11 @@ public class ControllerContext implements SchemaContextListener { final InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder(); final Module latestModule = globalSchema.findModuleByName(startModule, null); + + if (latestModule == null) { + throw new RestconfDocumentedException("The module named '" + startModule + "' does not exist.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); + } + final InstanceIdentifierContext iiWithSchemaNode = collectPathArguments(builder, pathArgs, latestModule, null, toMountPointIdentifier); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index 8e88be6f50..5e9ab7b9d0 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -417,18 +417,13 @@ public class RestconfImpl implements RestconfService { return retValue; } throw new RestconfDocumentedException("RpcError message", null, retValue.getErrors()); - } - catch (final InterruptedException e) { + } catch (final InterruptedException e) { throw new RestconfDocumentedException( "The operation was interrupted while executing and did not complete.", ErrorType.RPC, ErrorTag.PARTIAL_OPERATION); - } - catch (final ExecutionException e) { + } catch (final ExecutionException e) { Throwable cause = e.getCause(); - if (cause instanceof CancellationException) { - throw new RestconfDocumentedException("The operation was cancelled while executing.", ErrorType.RPC, - ErrorTag.PARTIAL_OPERATION); - } else if (cause != null) { + if (cause != null) { while (cause.getCause() != null) { cause = cause.getCause(); } @@ -444,6 +439,9 @@ public class RestconfImpl implements RestconfService { throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.", e); } + } catch (final CancellationException e) { + throw new RestconfDocumentedException("The operation was cancelled while executing.", ErrorType.RPC, + ErrorTag.PARTIAL_OPERATION); } } @@ -697,7 +695,7 @@ public class RestconfImpl implements RestconfService { if (mountPoint != null) { broker.commitConfigurationDataPut(mountPoint, normalizedII, payload.getData()).checkedGet(); } else { - broker.commitConfigurationDataPut(normalizedII, payload.getData()).checkedGet(); + broker.commitConfigurationDataPut(controllerContext.getGlobalSchema(), normalizedII, payload.getData()).checkedGet(); } break; @@ -843,7 +841,7 @@ public class RestconfImpl implements RestconfService { if (mountPoint != null) { broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData()).checkedGet(); } else { - broker.commitConfigurationDataPost(normalizedII, payload.getData()).checkedGet(); + broker.commitConfigurationDataPost(controllerContext.getGlobalSchema(), normalizedII, payload.getData()).checkedGet(); } } catch(final RestconfDocumentedException e) { throw e; diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java index 84b092e10e..624d709c60 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java @@ -11,6 +11,7 @@ import java.math.BigInteger; import java.util.Collection; import java.util.Collections; import org.opendaylight.controller.config.yang.md.sal.rest.connector.Config; +import org.opendaylight.controller.config.yang.md.sal.rest.connector.Delete; import org.opendaylight.controller.config.yang.md.sal.rest.connector.Get; import org.opendaylight.controller.config.yang.md.sal.rest.connector.Operational; import org.opendaylight.controller.config.yang.md.sal.rest.connector.Post; @@ -78,15 +79,31 @@ public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnec @Override public Config getConfig() { final Config config = new Config(); + final Get get = new Get(); get.setReceivedRequests(stats.getConfigGet()); + get.setSuccessfulResponses(stats.getSuccessGetConfig()); + get.setFailedResponses(stats.getFailureGetConfig()); config.setGet(get); + final Post post = new Post(); post.setReceivedRequests(stats.getConfigPost()); + post.setSuccessfulResponses(stats.getSuccessPost()); + post.setFailedResponses(stats.getFailurePost()); config.setPost(post); + final Put put = new Put(); put.setReceivedRequests(stats.getConfigPut()); + put.setSuccessfulResponses(stats.getSuccessPut()); + put.setFailedResponses(stats.getFailurePut()); config.setPut(put); + + final Delete delete = new Delete(); + delete.setReceivedRequests(stats.getConfigDelete()); + delete.setSuccessfulResponses(stats.getSuccessDelete()); + delete.setFailedResponses(stats.getFailureDelete()); + config.setDelete(delete); + return config; } @@ -96,6 +113,8 @@ public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnec final Operational operational = new Operational(); final Get get = new Get(); get.setReceivedRequests(opGet); + get.setSuccessfulResponses(stats.getSuccessGetOperational()); + get.setFailedResponses(stats.getFailureGetOperational()); operational.setGet(get); return operational; } @@ -105,6 +124,6 @@ public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnec final BigInteger rpcInvoke = stats.getRpc(); final Rpcs rpcs = new Rpcs(); rpcs.setReceivedRequests(rpcInvoke); - return rpcs ; + return rpcs; } -} +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java index 07178f5379..f4a5fbc926 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.restconf.impl; import java.math.BigInteger; import java.util.concurrent.atomic.AtomicLong; import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import org.opendaylight.controller.sal.rest.api.RestconfService; @@ -21,6 +22,16 @@ public class StatisticsRestconfServiceWrapper implements RestconfService { AtomicLong configPost = new AtomicLong(); AtomicLong configPut = new AtomicLong(); AtomicLong configDelete = new AtomicLong(); + AtomicLong successGetConfig = new AtomicLong(); + AtomicLong successGetOperational = new AtomicLong(); + AtomicLong successPost = new AtomicLong(); + AtomicLong successPut = new AtomicLong(); + AtomicLong successDelete = new AtomicLong(); + AtomicLong failureGetConfig = new AtomicLong(); + AtomicLong failureGetOperational = new AtomicLong(); + AtomicLong failurePost = new AtomicLong(); + AtomicLong failurePut = new AtomicLong(); + AtomicLong failureDelete = new AtomicLong(); private static final StatisticsRestconfServiceWrapper INSTANCE = new StatisticsRestconfServiceWrapper(RestconfImpl.getInstance()); @@ -79,36 +90,115 @@ public class StatisticsRestconfServiceWrapper implements RestconfService { @Override public NormalizedNodeContext readConfigurationData(final String identifier, final UriInfo uriInfo) { configGet.incrementAndGet(); - return delegate.readConfigurationData(identifier, uriInfo); + NormalizedNodeContext normalizedNodeContext = null; + try { + normalizedNodeContext = delegate.readConfigurationData(identifier, uriInfo); + if (normalizedNodeContext.getData() != null) { + successGetConfig.incrementAndGet(); + } + else { + failureGetConfig.incrementAndGet(); + } + } catch (Exception e) { + failureGetConfig.incrementAndGet(); + throw e; + } + return normalizedNodeContext; } @Override public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) { operationalGet.incrementAndGet(); - return delegate.readOperationalData(identifier, uriInfo); + NormalizedNodeContext normalizedNodeContext = null; + try { + normalizedNodeContext = delegate.readOperationalData(identifier, uriInfo); + if (normalizedNodeContext.getData() != null) { + successGetOperational.incrementAndGet(); + } + else { + failureGetOperational.incrementAndGet(); + } + } catch (Exception e) { + failureGetOperational.incrementAndGet(); + throw e; + } + return normalizedNodeContext; } @Override public Response updateConfigurationData(final String identifier, final NormalizedNodeContext payload) { configPut.incrementAndGet(); - return delegate.updateConfigurationData(identifier, payload); + Response response = null; + try { + response = delegate.updateConfigurationData(identifier, payload); + if (response.getStatus() == Status.OK.getStatusCode()) { + successPut.incrementAndGet(); + } + else { + failurePut.incrementAndGet(); + } + } catch (Exception e) { + failurePut.incrementAndGet(); + throw e; + } + return response; } @Override public Response createConfigurationData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { configPost.incrementAndGet(); - return delegate.createConfigurationData(identifier, payload, uriInfo); + Response response = null; + try { + response = delegate.createConfigurationData(identifier, payload, uriInfo); + if (response.getStatus() == Status.OK.getStatusCode()) { + successPost.incrementAndGet(); + } + else { + failurePost.incrementAndGet(); + } + } catch (Exception e) { + failurePost.incrementAndGet(); + throw e; + } + return response; } @Override public Response createConfigurationData(final NormalizedNodeContext payload, final UriInfo uriInfo) { configPost.incrementAndGet(); - return delegate.createConfigurationData(payload, uriInfo); + Response response = null; + try { + response = delegate.createConfigurationData(payload, uriInfo); + if (response.getStatus() == Status.OK.getStatusCode()) { + successPost.incrementAndGet(); + } + else { + failurePost.incrementAndGet(); + } + }catch (Exception e) { + failurePost.incrementAndGet(); + throw e; + } + return response; } @Override public Response deleteConfigurationData(final String identifier) { - return delegate.deleteConfigurationData(identifier); + configDelete.incrementAndGet(); + Response response = null; + try { + response = delegate.deleteConfigurationData(identifier); + if (response.getStatus() == Status.OK.getStatusCode()) { + successDelete.incrementAndGet(); + } + else { + failureDelete.incrementAndGet(); + } + } catch (Exception e) { + failureDelete.incrementAndGet(); + throw e; + } + return response; } @Override @@ -144,4 +234,44 @@ public class StatisticsRestconfServiceWrapper implements RestconfService { public BigInteger getRpc() { return BigInteger.valueOf(rpc.get()); } -} + + public BigInteger getSuccessGetConfig() { + return BigInteger.valueOf(successGetConfig.get()); + } + + public BigInteger getSuccessGetOperational() { + return BigInteger.valueOf(successGetOperational.get()); + } + + public BigInteger getSuccessPost() { + return BigInteger.valueOf(successPost.get()); + } + + public BigInteger getSuccessPut() { + return BigInteger.valueOf(successPut.get()); + } + + public BigInteger getSuccessDelete() { + return BigInteger.valueOf(successDelete.get()); + } + + public BigInteger getFailureGetConfig() { + return BigInteger.valueOf(failureGetConfig.get()); + } + + public BigInteger getFailureGetOperational() { + return BigInteger.valueOf(failureGetOperational.get()); + } + + public BigInteger getFailurePost() { + return BigInteger.valueOf(failurePost.get()); + } + + public BigInteger getFailurePut() { + return BigInteger.valueOf(failurePut.get()); + } + + public BigInteger getFailureDelete() { + return BigInteger.valueOf(failureDelete.get()); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang b/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang index 6d2add6ff1..6fa9c86ec1 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang +++ b/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang @@ -31,6 +31,14 @@ module opendaylight-rest-connector { leaf received-requests { type uint64; } + + leaf successful-responses { + type uint64; + } + + leaf failed-responses { + type uint64; + } } augment "/config:modules/config:module/config:configuration" { @@ -70,6 +78,10 @@ module opendaylight-rest-connector { container put { uses statistics; } + + container delete { + uses statistics; + } } container operational { diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java index b696854dbb..8ccd4a1f41 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java @@ -71,7 +71,7 @@ public class RestPutListDataTest { restconfImpl = RestconfImpl.getInstance(); restconfImpl.setBroker(brokerFacade); restconfImpl.setControllerContext(controllerContext); - when(brokerFacade.commitConfigurationDataPut(any(YangInstanceIdentifier.class), any(NormalizedNode.class))) + when(brokerFacade.commitConfigurationDataPut(any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class))) .thenReturn(mock(CheckedFuture.class)); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java index dc1f968805..9c5de08c5c 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java @@ -55,6 +55,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; /** @@ -181,7 +182,7 @@ public class BrokerFacadeTest { when(wTransaction.submit()).thenReturn(expFuture); - final Future actualFuture = brokerFacade.commitConfigurationDataPut(instanceID, dummyNode); + final Future actualFuture = brokerFacade.commitConfigurationDataPut((SchemaContext)null, instanceID, dummyNode); assertSame("commitConfigurationDataPut", expFuture, actualFuture); @@ -196,34 +197,32 @@ public class BrokerFacadeTest { @SuppressWarnings("unchecked") final CheckedFuture expFuture = mock(CheckedFuture.class); - final NormalizedNode dummyNode2 = createDummyNode("dummy:namespace2", "2014-07-01", "dummy local name2"); - - when(rwTransaction.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn( - wrapDummyNode(dummyNode2)); - when(rwTransaction.exists(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn( - wrapExistence(true)); + wrapExistence(false)); when(rwTransaction.submit()).thenReturn(expFuture); final CheckedFuture actualFuture = brokerFacade.commitConfigurationDataPost( - YangInstanceIdentifier.builder().build(), dummyNode); + (SchemaContext)null, YangInstanceIdentifier.builder().build(), dummyNode); assertSame("commitConfigurationDataPost", expFuture, actualFuture); final InOrder inOrder = inOrder(domDataBroker, rwTransaction); inOrder.verify(domDataBroker).newReadWriteTransaction(); - inOrder.verify(rwTransaction).merge(LogicalDatastoreType.CONFIGURATION, instanceID, dummyNode); + inOrder.verify(rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, instanceID); + inOrder.verify(rwTransaction).put(LogicalDatastoreType.CONFIGURATION, instanceID, dummyNode); inOrder.verify(rwTransaction).submit(); } @Test(expected = RestconfDocumentedException.class) public void testCommitConfigurationDataPostAlreadyExists() { - when(rwTransaction.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn( - dummyNodeInFuture); + final CheckedFuture successFuture = Futures.immediateCheckedFuture(Boolean.TRUE); + when(rwTransaction.exists(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn( + successFuture); try { - brokerFacade.commitConfigurationDataPost(instanceID, dummyNode); + // Schema context is only necessary for ensuring parent structure + brokerFacade.commitConfigurationDataPost((SchemaContext)null, instanceID, dummyNode); } catch (final RestconfDocumentedException e) { assertEquals("getErrorTag", RestconfError.ErrorTag.DATA_EXISTS, e.getErrors().get(0).getErrorTag()); throw e; diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index 62a37ed147..bb731a32d0 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -137,7 +137,7 @@ public class RestPostOperationTest extends JerseyTest { final RpcResult rpcResult = new DummyRpcResult.Builder().result( TransactionStatus.COMMITED).build(); - when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class), any(NormalizedNode.class))) + when(brokerFacade.commitConfigurationDataPost((SchemaContext)null, any(YangInstanceIdentifier.class), any(NormalizedNode.class))) .thenReturn(mock(CheckedFuture.class)); final ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(YangInstanceIdentifier.class); @@ -157,7 +157,7 @@ public class RestPostOperationTest extends JerseyTest { // FIXME : NEVER test a nr. of call some service in complex test suite // verify(brokerFacade, times(2)) verify(brokerFacade, times(1)) - .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture()); + .commitConfigurationDataPost((SchemaContext)null, instanceIdCaptor.capture(), compNodeCaptor.capture()); // identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)block]"; assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString()); } @@ -166,7 +166,7 @@ public class RestPostOperationTest extends JerseyTest { public void createConfigurationDataNullTest() throws UnsupportedEncodingException { initMocking(); - when(brokerFacade.commitConfigurationDataPost(any(YangInstanceIdentifier.class),any(NormalizedNode.class))) + when(brokerFacade.commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),any(NormalizedNode.class))) .thenReturn(Futures.immediateCheckedFuture(null)); //FIXME : find who is set schemaContext diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java index 39646f3ffd..f70af4e4f6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java @@ -171,13 +171,13 @@ public class RestPutOperationTest extends JerseyTest { doThrow(OptimisticLockFailedException.class). when(brokerFacade).commitConfigurationDataPut( - any(YangInstanceIdentifier.class), any(NormalizedNode.class)); + any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); doThrow(OptimisticLockFailedException.class).doReturn(mock(CheckedFuture.class)). when(brokerFacade).commitConfigurationDataPut( - any(YangInstanceIdentifier.class), any(NormalizedNode.class)); + any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData)); } @@ -190,7 +190,7 @@ public class RestPutOperationTest extends JerseyTest { doThrow(TransactionCommitFailedException.class). when(brokerFacade).commitConfigurationDataPut( - any(YangInstanceIdentifier.class), any(NormalizedNode.class)); + (SchemaContext)null, any(YangInstanceIdentifier.class), any(NormalizedNode.class)); assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); } @@ -202,10 +202,10 @@ public class RestPutOperationTest extends JerseyTest { private void mockCommitConfigurationDataPutMethod(final boolean noErrors) { if (noErrors) { doReturn(mock(CheckedFuture.class)).when(brokerFacade).commitConfigurationDataPut( - any(YangInstanceIdentifier.class), any(NormalizedNode.class)); + any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); } else { doThrow(RestconfDocumentedException.class).when(brokerFacade).commitConfigurationDataPut( - any(YangInstanceIdentifier.class), any(NormalizedNode.class)); + any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); } } diff --git a/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml b/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml index f559572768..c7d0f69fb9 100644 --- a/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml +++ b/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-rest-docgen-maven diff --git a/opendaylight/md-sal/sal-rest-docgen/pom.xml b/opendaylight/md-sal/sal-rest-docgen/pom.xml index 22a128c1b7..4e371a5b42 100644 --- a/opendaylight/md-sal/sal-rest-docgen/pom.xml +++ b/opendaylight/md-sal/sal-rest-docgen/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-rest-docgen diff --git a/opendaylight/md-sal/sal-restconf-broker/pom.xml b/opendaylight/md-sal/sal-restconf-broker/pom.xml index db2b06e714..b2fcc57447 100644 --- a/opendaylight/md-sal/sal-restconf-broker/pom.xml +++ b/opendaylight/md-sal/sal-restconf-broker/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sal-restconf-broker bundle diff --git a/opendaylight/md-sal/sal-test-model/pom.xml b/opendaylight/md-sal/sal-test-model/pom.xml index 852e99e146..a09ad9cc8c 100644 --- a/opendaylight/md-sal/sal-test-model/pom.xml +++ b/opendaylight/md-sal/sal-test-model/pom.xml @@ -5,7 +5,7 @@ sal-parent org.opendaylight.controller - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT 4.0.0 diff --git a/opendaylight/md-sal/samples/clustering-test-app/configuration/pom.xml b/opendaylight/md-sal/samples/clustering-test-app/configuration/pom.xml index 33a8a92f9f..d6bd4886c7 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/configuration/pom.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/configuration/pom.xml @@ -12,7 +12,7 @@ clustering-it org.opendaylight.controller.samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT clustering-it-config jar diff --git a/opendaylight/md-sal/samples/clustering-test-app/model/pom.xml b/opendaylight/md-sal/samples/clustering-test-app/model/pom.xml index 60eeba64c7..7fbff152e6 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/model/pom.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/model/pom.xml @@ -4,7 +4,7 @@ clustering-it org.opendaylight.controller.samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT clustering-it-model bundle diff --git a/opendaylight/md-sal/samples/clustering-test-app/pom.xml b/opendaylight/md-sal/samples/clustering-test-app/pom.xml index 5824621331..8fbca8e4a7 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/pom.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller.samples sal-samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT clustering-it pom diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml b/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml index 31a1237a5b..424def29ce 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml @@ -4,7 +4,7 @@ clustering-it org.opendaylight.controller.samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT clustering-it-provider bundle diff --git a/opendaylight/md-sal/samples/pom.xml b/opendaylight/md-sal/samples/pom.xml index 378b03318a..7a8232372c 100644 --- a/opendaylight/md-sal/samples/pom.xml +++ b/opendaylight/md-sal/samples/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller sal-parent - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.opendaylight.controller.samples diff --git a/opendaylight/md-sal/samples/toaster-config/pom.xml b/opendaylight/md-sal/samples/toaster-config/pom.xml index b0592b654d..915aa0c2c1 100644 --- a/opendaylight/md-sal/samples/toaster-config/pom.xml +++ b/opendaylight/md-sal/samples/toaster-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller.samples sal-samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT toaster-config Configuration files for toaster diff --git a/opendaylight/md-sal/samples/toaster-consumer/pom.xml b/opendaylight/md-sal/samples/toaster-consumer/pom.xml index fb6828a250..0fde7cb028 100644 --- a/opendaylight/md-sal/samples/toaster-consumer/pom.xml +++ b/opendaylight/md-sal/samples/toaster-consumer/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.controller.samples sal-samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sample-toaster-consumer bundle - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT diff --git a/opendaylight/md-sal/samples/toaster-it/pom.xml b/opendaylight/md-sal/samples/toaster-it/pom.xml index eb40d73bd1..8acf4dbbe9 100644 --- a/opendaylight/md-sal/samples/toaster-it/pom.xml +++ b/opendaylight/md-sal/samples/toaster-it/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller.samples sal-samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sample-toaster-it diff --git a/opendaylight/md-sal/samples/toaster-provider/pom.xml b/opendaylight/md-sal/samples/toaster-provider/pom.xml index dd9810388d..95ae60fab1 100644 --- a/opendaylight/md-sal/samples/toaster-provider/pom.xml +++ b/opendaylight/md-sal/samples/toaster-provider/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.controller.samples sal-samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sample-toaster-provider bundle - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT diff --git a/opendaylight/md-sal/samples/toaster/pom.xml b/opendaylight/md-sal/samples/toaster/pom.xml index ab761fd6bf..777270f416 100644 --- a/opendaylight/md-sal/samples/toaster/pom.xml +++ b/opendaylight/md-sal/samples/toaster/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller.samples sal-samples - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT sample-toaster bundle diff --git a/opendaylight/netconf/config-netconf-connector/pom.xml b/opendaylight/netconf/config-netconf-connector/pom.xml index 3a949697e9..2093ace97a 100644 --- a/opendaylight/netconf/config-netconf-connector/pom.xml +++ b/opendaylight/netconf/config-netconf-connector/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT config-netconf-connector bundle diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java index 50676c57c1..8b31a59768 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java @@ -260,9 +260,9 @@ public class EditConfig extends AbstractConfigNetconfOperation { } public static Map> transformMbeToModuleConfigs - (final BeanReader configRegistryClient, Map> mBeanEntries) { + Map> transformMbeToModuleConfigs ( + final BeanReader configRegistryClient, Map> mBeanEntries) { Map> namespaceToModuleNameToModuleConfig = Maps.newHashMap(); diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java index cb035161b4..ac3873e6b8 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java @@ -137,12 +137,15 @@ public class YangStoreService implements YangStoreContext { } public AutoCloseable registerCapabilityListener(final CapabilityListener listener) { - if(ref.get() == null || ref.get().get() == null) { - getYangStoreSnapshot(); + + YangStoreContext context = ref.get().get(); + + if(context == null) { + context = getYangStoreSnapshot(); } this.listeners.add(listener); - listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(ref.get().get())); + listener.onCapabilitiesAdded(NetconfOperationServiceFactoryImpl.setupCapabilities(context)); return new AutoCloseable() { @Override diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java index 283ec424ba..5da5322e0d 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java @@ -37,7 +37,7 @@ final class YangStoreSnapshot implements YangStoreContext { private final Map> moduleMXBeanEntryMap; + Map> moduleMXBeanEntryMap; private final Map> qNamesToIdentitiesToModuleMXBeanEntries; diff --git a/opendaylight/netconf/config-persister-impl/pom.xml b/opendaylight/netconf/config-persister-impl/pom.xml index 9d0fdc0e87..5691e04b8f 100644 --- a/opendaylight/netconf/config-persister-impl/pom.xml +++ b/opendaylight/netconf/config-persister-impl/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ config-persister-impl diff --git a/opendaylight/netconf/ietf-netconf-monitoring-extension/pom.xml b/opendaylight/netconf/ietf-netconf-monitoring-extension/pom.xml index edd711171f..760261b1e4 100644 --- a/opendaylight/netconf/ietf-netconf-monitoring-extension/pom.xml +++ b/opendaylight/netconf/ietf-netconf-monitoring-extension/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ietf-netconf-monitoring-extension bundle diff --git a/opendaylight/netconf/ietf-netconf-monitoring/pom.xml b/opendaylight/netconf/ietf-netconf-monitoring/pom.xml index 2abed1bfe3..e4819c0a44 100644 --- a/opendaylight/netconf/ietf-netconf-monitoring/pom.xml +++ b/opendaylight/netconf/ietf-netconf-monitoring/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ietf-netconf-monitoring bundle diff --git a/opendaylight/netconf/ietf-netconf-notifications/pom.xml b/opendaylight/netconf/ietf-netconf-notifications/pom.xml index 1ce3b031b7..763cb82c36 100644 --- a/opendaylight/netconf/ietf-netconf-notifications/pom.xml +++ b/opendaylight/netconf/ietf-netconf-notifications/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ietf-netconf-notifications bundle diff --git a/opendaylight/netconf/ietf-netconf/pom.xml b/opendaylight/netconf/ietf-netconf/pom.xml index 6ed7a5f130..43ba3b17aa 100644 --- a/opendaylight/netconf/ietf-netconf/pom.xml +++ b/opendaylight/netconf/ietf-netconf/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ietf-netconf bundle diff --git a/opendaylight/netconf/mdsal-netconf-connector/pom.xml b/opendaylight/netconf/mdsal-netconf-connector/pom.xml index 878c37846b..34cc5c4442 100644 --- a/opendaylight/netconf/mdsal-netconf-connector/pom.xml +++ b/opendaylight/netconf/mdsal-netconf-connector/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT mdsal-netconf-connector bundle @@ -92,13 +92,6 @@ xmlunit test - - - org.opendaylight.controller - sal-netconf-connector - - diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java index bf41f190e6..71a424ba48 100644 --- a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java +++ b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java @@ -27,13 +27,13 @@ public class NetconfMdsalMapperModule extends org.opendaylight.controller.config @Override public java.lang.AutoCloseable createInstance() { final MdsalNetconfOperationServiceFactory mdsalNetconfOperationServiceFactory = - new MdsalNetconfOperationServiceFactory(getRootSchemaServiceDependency()) { - @Override - public void close() throws Exception { - super.close(); - getMapperAggregatorDependency().onRemoveNetconfOperationServiceFactory(this); - } - }; + new MdsalNetconfOperationServiceFactory(getRootSchemaServiceDependency()) { + @Override + public void close() throws Exception { + super.close(); + getMapperAggregatorDependency().onRemoveNetconfOperationServiceFactory(this); + } + }; getDomBrokerDependency().registerConsumer(mdsalNetconfOperationServiceFactory); getMapperAggregatorDependency().onAddNetconfOperationServiceFactory(mdsalNetconfOperationServiceFactory); return mdsalNetconfOperationServiceFactory; diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java index 9a66ceb5bc..d028a89e36 100644 --- a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java +++ b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java @@ -31,7 +31,6 @@ import org.opendaylight.controller.netconf.mdsal.connector.CurrentSchemaContext; import org.opendaylight.controller.netconf.mdsal.connector.ops.Datastore; import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation; import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.sal.connect.netconf.util.InstanceIdToNodes; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -42,6 +41,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils; import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; @@ -151,7 +151,7 @@ public abstract class AbstractGet extends AbstractSingletonNetconfOperation { protected Element serializeNodeWithParentStructure(Document document, YangInstanceIdentifier dataRoot, NormalizedNode node) { if (!dataRoot.equals(ROOT)) { return (Element) transformNormalizedNode(document, - InstanceIdToNodes.serialize(schemaContext.getCurrentContext(), dataRoot, node), + ImmutableNodes.fromInstanceId(schemaContext.getCurrentContext(), dataRoot, node), ROOT); } return (Element) transformNormalizedNode(document, node, ROOT); diff --git a/opendaylight/netconf/mdsal-netconf-monitoring/pom.xml b/opendaylight/netconf/mdsal-netconf-monitoring/pom.xml index 3e78dd19e3..04585e1833 100644 --- a/opendaylight/netconf/mdsal-netconf-monitoring/pom.xml +++ b/opendaylight/netconf/mdsal-netconf-monitoring/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT mdsal-netconf-monitoring bundle diff --git a/opendaylight/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java b/opendaylight/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java index 50958e423f..3dbcc53822 100644 --- a/opendaylight/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java +++ b/opendaylight/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java @@ -61,19 +61,12 @@ final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMonitoringS tx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(NetconfState.class), state); // FIXME first attempt (right after we register to binding broker) always fails // Is it due to the fact that we are writing from the onSessionInitiated callback ? - final CheckedFuture submit = tx.submit(); - - Futures.addCallback(submit, new FutureCallback() { - @Override - public void onSuccess(final Void aVoid) { - LOG.debug("Netconf state updated successfully"); - } - - @Override - public void onFailure(final Throwable throwable) { - LOG.warn("Unable to update netconf state", throwable); - } - }); + try { + tx.submit().checkedGet(); + LOG.debug("Netconf state updated successfully"); + } catch (TransactionCommitFailedException e) { + LOG.warn("Unable to update netconf state", e); + } } @Override diff --git a/opendaylight/netconf/netconf-api/pom.xml b/opendaylight/netconf/netconf-api/pom.xml index 965747c2ea..d1c2af36ff 100644 --- a/opendaylight/netconf/netconf-api/pom.xml +++ b/opendaylight/netconf/netconf-api/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-api bundle diff --git a/opendaylight/netconf/netconf-artifacts/pom.xml b/opendaylight/netconf/netconf-artifacts/pom.xml index d27ea55812..4cf8b0a550 100644 --- a/opendaylight/netconf/netconf-artifacts/pom.xml +++ b/opendaylight/netconf/netconf-artifacts/pom.xml @@ -12,7 +12,7 @@ 4.0.0 org.opendaylight.controller netconf-artifacts - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT pom diff --git a/opendaylight/netconf/netconf-auth/pom.xml b/opendaylight/netconf/netconf-auth/pom.xml index 6f1fafff40..ac5198a325 100644 --- a/opendaylight/netconf/netconf-auth/pom.xml +++ b/opendaylight/netconf/netconf-auth/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ netconf-auth diff --git a/opendaylight/netconf/netconf-cli/pom.xml b/opendaylight/netconf/netconf-cli/pom.xml index 27c9bd8d2c..c968f73973 100644 --- a/opendaylight/netconf/netconf-cli/pom.xml +++ b/opendaylight/netconf/netconf-cli/pom.xml @@ -10,7 +10,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-cli jar diff --git a/opendaylight/netconf/netconf-client/pom.xml b/opendaylight/netconf/netconf-client/pom.xml index 4f79b9f7b6..223ae0e6a4 100644 --- a/opendaylight/netconf/netconf-client/pom.xml +++ b/opendaylight/netconf/netconf-client/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-client bundle diff --git a/opendaylight/netconf/netconf-config/pom.xml b/opendaylight/netconf/netconf-config/pom.xml index 77551f7080..d8cef8b74e 100644 --- a/opendaylight/netconf/netconf-config/pom.xml +++ b/opendaylight/netconf/netconf-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-config Configuration files for netconf diff --git a/opendaylight/netconf/netconf-connector-config/pom.xml b/opendaylight/netconf/netconf-connector-config/pom.xml index f4e6e99ea0..b3065da28d 100644 --- a/opendaylight/netconf/netconf-connector-config/pom.xml +++ b/opendaylight/netconf/netconf-connector-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-connector-config Configuration files for netconf-connector diff --git a/opendaylight/netconf/netconf-impl/pom.xml b/opendaylight/netconf/netconf-impl/pom.xml index 5d880c52c9..5bb624e38c 100644 --- a/opendaylight/netconf/netconf-impl/pom.xml +++ b/opendaylight/netconf/netconf-impl/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-impl bundle diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java index 2e7accad45..566dfde7c3 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java @@ -31,14 +31,6 @@ public class SubtreeFilter { private static final Logger LOG = LoggerFactory.getLogger(SubtreeFilter.class); static Document applySubtreeFilter(Document requestDocument, Document rpcReply) throws NetconfDocumentedException { - // FIXME: rpcReply document must be reread otherwise some nodes do not inherit namespaces. (services/service) - try { - rpcReply = XmlUtil.readXmlToDocument(XmlUtil.toString(rpcReply, true)); - } catch (SAXException | IOException e) { - LOG.error("Cannot transform document", e); - throw new NetconfDocumentedException("Cannot transform document"); - } - OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument); if (XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(operationNameAndNamespace.getNamespace()) && XmlNetconfConstants.GET.equals(operationNameAndNamespace.getOperationName()) || @@ -47,16 +39,26 @@ public class SubtreeFilter { // not implement filtering. Optional maybeFilter = operationNameAndNamespace.getOperationElement().getOnlyChildElementOptionally( XmlNetconfConstants.FILTER, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); - if (maybeFilter.isPresent() && ( - "subtree".equals(maybeFilter.get().getAttribute("type"))|| - "subtree".equals(maybeFilter.get().getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))) - ) { + if (!maybeFilter.isPresent()) { + return rpcReply; + } + // FIXME: rpcReply document must be reread otherwise some nodes do not inherit namespaces. (services/service) + try { + rpcReply = XmlUtil.readXmlToDocument(XmlUtil.toString(rpcReply, true)); + } catch (SAXException | IOException e) { + LOG.error("Cannot transform document", e); + throw new NetconfDocumentedException("Cannot transform document" + e); + } + XmlElement filter = maybeFilter.get(); + if ("subtree".equals(filter.getAttribute("type"))|| + "subtree".equals(filter.getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))) { // do return filtered(maybeFilter.get(), rpcReply); } } + return rpcReply; // return identical document } diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index 90c3e2fbdd..4f722f4db4 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-it diff --git a/opendaylight/netconf/netconf-mapping-api/pom.xml b/opendaylight/netconf/netconf-mapping-api/pom.xml index 21e50cd2ea..ab8635b62d 100644 --- a/opendaylight/netconf/netconf-mapping-api/pom.xml +++ b/opendaylight/netconf/netconf-mapping-api/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-mapping-api diff --git a/opendaylight/netconf/netconf-mdsal-config/pom.xml b/opendaylight/netconf/netconf-mdsal-config/pom.xml index f3c931345f..923b69a61a 100644 --- a/opendaylight/netconf/netconf-mdsal-config/pom.xml +++ b/opendaylight/netconf/netconf-mdsal-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-mdsal-config Configuration files for netconf for mdsal diff --git a/opendaylight/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml b/opendaylight/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml index 1982615173..72a3dcf388 100644 --- a/opendaylight/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml +++ b/opendaylight/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml @@ -112,6 +112,17 @@ admin + + + + + + + + + + + @@ -158,6 +169,7 @@ urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper?module=netconf-mdsal-mapper&revision=2015-01-14 urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring?module=netconf-mdsal-monitoring&revision=2015-02-18 urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh?module=netconf-northbound-ssh&revision=2015-01-14 + urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp?module=netconf-northbound-tcp&revision=2015-04-23 urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl?module=netconf-northbound-impl&revision=2015-01-12 urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled?module=threadpool-impl-scheduled&revision=2013-12-01 diff --git a/opendaylight/netconf/netconf-monitoring/pom.xml b/opendaylight/netconf/netconf-monitoring/pom.xml index abaf1acddf..8071caff89 100644 --- a/opendaylight/netconf/netconf-monitoring/pom.xml +++ b/opendaylight/netconf/netconf-monitoring/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-monitoring bundle diff --git a/opendaylight/netconf/netconf-netty-util/pom.xml b/opendaylight/netconf/netconf-netty-util/pom.xml index 55a5630bed..90b39f4d45 100644 --- a/opendaylight/netconf/netconf-netty-util/pom.xml +++ b/opendaylight/netconf/netconf-netty-util/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-netty-util bundle diff --git a/opendaylight/netconf/netconf-notifications-api/pom.xml b/opendaylight/netconf/netconf-notifications-api/pom.xml index a1fbe150ae..3023a2d30e 100644 --- a/opendaylight/netconf/netconf-notifications-api/pom.xml +++ b/opendaylight/netconf/netconf-notifications-api/pom.xml @@ -13,7 +13,7 @@ netconf-subsystem org.opendaylight.controller - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT 4.0.0 bundle diff --git a/opendaylight/netconf/netconf-notifications-impl/pom.xml b/opendaylight/netconf/netconf-notifications-impl/pom.xml index 510d9f07e3..64255edc81 100644 --- a/opendaylight/netconf/netconf-notifications-impl/pom.xml +++ b/opendaylight/netconf/netconf-notifications-impl/pom.xml @@ -13,7 +13,7 @@ netconf-subsystem org.opendaylight.controller - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT 4.0.0 bundle diff --git a/opendaylight/netconf/netconf-ssh/pom.xml b/opendaylight/netconf/netconf-ssh/pom.xml index 03f7a2fac2..b506a1e3c7 100644 --- a/opendaylight/netconf/netconf-ssh/pom.xml +++ b/opendaylight/netconf/netconf-ssh/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ netconf-ssh @@ -39,7 +39,7 @@ org.opendaylight.controller netty-config-api - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT diff --git a/opendaylight/netconf/netconf-tcp/pom.xml b/opendaylight/netconf/netconf-tcp/pom.xml index 0a3ea5485d..e1e650b4da 100644 --- a/opendaylight/netconf/netconf-tcp/pom.xml +++ b/opendaylight/netconf/netconf-tcp/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ netconf-tcp @@ -27,6 +27,14 @@ ${project.groupId} netconf-util + + org.opendaylight.controller + threadpool-config-api + + + org.opendaylight.controller + netty-config-api + org.slf4j slf4j-api @@ -49,6 +57,41 @@ + + org.opendaylight.yangtools + yang-maven-plugin + + + config + + generate-sources + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + ${jmxGeneratorPath} + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${config.version} + + + diff --git a/opendaylight/netconf/netconf-tcp/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/tcp/NetconfNorthboundTcpModule.java b/opendaylight/netconf/netconf-tcp/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/tcp/NetconfNorthboundTcpModule.java new file mode 100644 index 0000000000..b5492a8139 --- /dev/null +++ b/opendaylight/netconf/netconf-tcp/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/tcp/NetconfNorthboundTcpModule.java @@ -0,0 +1,76 @@ +package org.opendaylight.controller.config.yang.netconf.northbound.tcp; + +import io.netty.channel.ChannelFuture; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.UnknownHostException; +import org.opendaylight.controller.netconf.api.NetconfServerDispatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NetconfNorthboundTcpModule extends org.opendaylight.controller.config.yang.netconf.northbound.tcp.AbstractNetconfNorthboundTcpModule { + + private static final Logger LOG = LoggerFactory.getLogger(NetconfNorthboundTcpModule.class); + + + public NetconfNorthboundTcpModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NetconfNorthboundTcpModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.northbound.tcp.NetconfNorthboundTcpModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + final NetconfServerDispatcher dispatch = getDispatcherDependency(); + final ChannelFuture tcpServer = dispatch.createServer(getInetAddress()); + + tcpServer.addListener(new GenericFutureListener() { + @Override + public void operationComplete(ChannelFuture future) throws Exception { + if (future.isDone() && future.isSuccess()) { + LOG.info("Netconf TCP endpoint started successfully at {}", getInetAddress()); + } else { + LOG.warn("Unable to start TCP netconf server at {}", getInetAddress(), future.cause()); + throw new RuntimeException("Unable to start TCP netconf server", future.cause()); + } + } + }); + + return new NetconfServerCloseable(tcpServer); + } + + private InetSocketAddress getInetAddress() { + try { + final InetAddress inetAd = InetAddress.getByName(getBindingAddress().getIpv4Address() == null ? getBindingAddress().getIpv6Address().getValue() : getBindingAddress().getIpv4Address().getValue()); + return new InetSocketAddress(inetAd, getPort().getValue()); + } catch (final UnknownHostException e) { + throw new IllegalArgumentException("Unable to bind netconf endpoint to address " + getBindingAddress(), e); + } + } + + private static final class NetconfServerCloseable implements AutoCloseable { + private final ChannelFuture localServer; + + public NetconfServerCloseable(final ChannelFuture localServer) { + this.localServer = localServer; + } + + @Override + public void close() throws Exception { + if(localServer.isDone()) { + localServer.channel().close(); + } else { + localServer.cancel(true); + } + } + } + +} diff --git a/opendaylight/netconf/netconf-tcp/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/tcp/NetconfNorthboundTcpModuleFactory.java b/opendaylight/netconf/netconf-tcp/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/tcp/NetconfNorthboundTcpModuleFactory.java new file mode 100644 index 0000000000..081486ecf4 --- /dev/null +++ b/opendaylight/netconf/netconf-tcp/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/tcp/NetconfNorthboundTcpModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: netconf-northbound-tcp yang module local name: netconf-northbound-tcp +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Apr 23 16:34:55 CEST 2015 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.netconf.northbound.tcp; +public class NetconfNorthboundTcpModuleFactory extends org.opendaylight.controller.config.yang.netconf.northbound.tcp.AbstractNetconfNorthboundTcpModuleFactory { + +} diff --git a/opendaylight/netconf/netconf-tcp/src/main/yang/netconf-northbound-tcp.yang b/opendaylight/netconf/netconf-tcp/src/main/yang/netconf-northbound-tcp.yang new file mode 100644 index 0000000000..a42fcad147 --- /dev/null +++ b/opendaylight/netconf/netconf-tcp/src/main/yang/netconf-northbound-tcp.yang @@ -0,0 +1,53 @@ +module netconf-northbound-tcp { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp"; + prefix "nni"; + + import netconf-northbound-mapper { prefix nnm; revision-date 2015-01-14; } + import netconf-northbound { prefix nn; revision-date 2015-01-14; } + import config { prefix config; revision-date 2013-04-05; } + import threadpool {prefix th;} + import netty {prefix netty;} + import ietf-inet-types { prefix inet; revision-date 2010-09-24; } + + organization "Cisco Systems, Inc."; + + description + "This module contains the base YANG definitions for + a default implementation of netconf northbound tcp server"; + + revision "2015-04-23" { + description + "Initial revision."; + } + + identity netconf-northbound-tcp { + base config:module-type; + config:java-name-prefix NetconfNorthboundTcp; + } + + augment "/config:modules/config:module/config:configuration" { + case netconf-northbound-tcp { + when "/config:modules/config:module/config:type = 'netconf-northbound-tcp'"; + + leaf port { + type inet:port-number; + default 2831; + } + + leaf binding-address { + type inet:ip-address; + default "0.0.0.0"; + } + + container dispatcher { + uses config:service-ref { + refine type { + config:required-identity nn:netconf-server-dispatcher; + } + } + } + } + } + +} \ No newline at end of file diff --git a/opendaylight/netconf/netconf-testtool/pom.xml b/opendaylight/netconf/netconf-testtool/pom.xml index f15dcc3417..0d98fcac77 100644 --- a/opendaylight/netconf/netconf-testtool/pom.xml +++ b/opendaylight/netconf/netconf-testtool/pom.xml @@ -14,7 +14,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-testtool diff --git a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/AsyncExecutionStrategy.java b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/AsyncExecutionStrategy.java index 7b60a17827..af352b1c2e 100644 --- a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/AsyncExecutionStrategy.java +++ b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/AsyncExecutionStrategy.java @@ -30,24 +30,26 @@ class AsyncExecutionStrategy implements ExecutionStrategy { private final List preparedMessages; private final NetconfDeviceCommunicator sessionListener; private final List editBatches; + private final int editAmount; public AsyncExecutionStrategy(final Parameters params, final List editConfigMsgs, final NetconfDeviceCommunicator sessionListener) { this.params = params; this.preparedMessages = editConfigMsgs; this.sessionListener = sessionListener; - this.editBatches = countEditBatchSizes(params); + this.editBatches = countEditBatchSizes(params, editConfigMsgs.size()); + editAmount = editConfigMsgs.size(); } - private static List countEditBatchSizes(final Parameters params) { + private static List countEditBatchSizes(final Parameters params, final int amount) { final List editBatches = Lists.newArrayList(); - if (params.editBatchSize != params.editCount) { - final int fullBatches = params.editCount / params.editBatchSize; + if (params.editBatchSize != amount) { + final int fullBatches = amount / params.editBatchSize; for (int i = 0; i < fullBatches; i++) { editBatches.add(params.editBatchSize); } - if (params.editCount % params.editBatchSize != 0) { - editBatches.add(params.editCount % params.editBatchSize); + if (amount % params.editBatchSize != 0) { + editBatches.add(amount % params.editBatchSize); } } else { editBatches.add(params.editBatchSize); @@ -96,6 +98,6 @@ class AsyncExecutionStrategy implements ExecutionStrategy { } } - Preconditions.checkState(responseCounter.get() == params.editCount + editBatches.size(), "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size()); + Preconditions.checkState(responseCounter.get() == editAmount + editBatches.size(), "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size()); } } diff --git a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/Parameters.java b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/Parameters.java index 6648bd4b52..8a9a915a08 100644 --- a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/Parameters.java +++ b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/Parameters.java @@ -52,6 +52,12 @@ public class Parameters { @Arg(dest = "msg-timeout") public long msgTimeout; + @Arg(dest = "tcp-header") + public String tcpHeader; + + @Arg(dest = "thread-amount") + public int threadAmount; + static ArgumentParser getParser() { final ArgumentParser parser = ArgumentParsers.newArgumentParser("netconf stress client"); @@ -122,6 +128,16 @@ public class Parameters { .setDefault(false) .dest("ssh"); + parser.addArgument("--tcp-header") + .type(String.class) + .required(false) + .dest("tcp-header"); + + parser.addArgument("--thread-amount") + .type(Integer.class) + .setDefault(1) + .dest("thread-amount"); + // TODO add get-config option instead of edit + commit // TODO different edit config content diff --git a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClient.java b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClient.java index fe0a0bcd52..2916ec52f7 100644 --- a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClient.java +++ b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClient.java @@ -11,31 +11,27 @@ package org.opendaylight.controller.netconf.test.tool.client.stress; import ch.qos.logback.classic.Level; import com.google.common.base.Charsets; import com.google.common.base.Stopwatch; -import com.google.common.collect.Lists; import com.google.common.io.Files; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.util.HashedWheelTimer; import io.netty.util.Timer; -import io.netty.util.concurrent.GlobalEventExecutor; import java.io.IOException; -import java.net.InetSocketAddress; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; -import org.opendaylight.controller.netconf.client.NetconfClientSession; -import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; -import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.controller.sal.connect.api.RemoteDevice; import org.opendaylight.controller.sal.connect.netconf.listener.NetconfDeviceCommunicator; import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionPreferences; -import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; -import org.opendaylight.protocol.framework.NeverReconnectStrategy; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CommitInput; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditConfigInput; import org.opendaylight.yangtools.yang.common.QName; @@ -74,6 +70,7 @@ public final class StressClient { " \n" + " \n" + " \n" + + " none" + " \n" + " \n" + ""); @@ -82,92 +79,90 @@ public final class StressClient { } } - private static final String MSG_ID_PLACEHOLDER = "{MSG_ID}"; private static final String MSG_ID_PLACEHOLDER_REGEX = "\\{MSG_ID\\}"; + private static final String PHYS_ADDR_PLACEHOLDER = "{PHYS_ADDR}"; + + private static long macStart = 0xAABBCCDD0000L; public static void main(final String[] args) { final Parameters params = parseArgs(args, Parameters.getParser()); params.validate(); - // TODO remove - try { - Thread.sleep(10000); - } catch (final InterruptedException e) { -// e.printStackTrace(); - } - final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(params.debug ? Level.DEBUG : Level.INFO); + final int threadAmount = params.threadAmount; + LOG.info("thread amount: " + threadAmount); + final int requestsPerThread = params.editCount / params.threadAmount; + LOG.info("requestsPerThread: " + requestsPerThread); + final int leftoverRequests = params.editCount % params.threadAmount; + LOG.info("leftoverRequests: " + leftoverRequests); + + LOG.info("Preparing messages"); // Prepare all msgs up front - final List preparedMessages = Lists.newArrayListWithCapacity(params.editCount); + final List> allPreparedMessages = new ArrayList<>(threadAmount); + for (int i = 0; i < threadAmount; i++) { + if (i != threadAmount - 1) { + allPreparedMessages.add(new ArrayList(requestsPerThread)); + } else { + allPreparedMessages.add(new ArrayList(requestsPerThread + leftoverRequests)); + } + } + final String editContentString; - boolean needsModification = false; try { editContentString = Files.toString(params.editContent, Charsets.UTF_8); - if(editContentString.contains(MSG_ID_PLACEHOLDER)) { - needsModification = true; - }; - } catch (IOException e) { + } catch (final IOException e) { throw new IllegalArgumentException("Cannot read content of " + params.editContent); } - for (int i = 0; i < params.editCount; i++) { - final Document msg = XmlUtil.createDocumentCopy(editBlueprint); - msg.getDocumentElement().setAttribute("message-id", Integer.toString(i)); - final NetconfMessage netconfMessage = new NetconfMessage(msg); - - final Element editContentElement; - try { - // Insert message id where needed - final String specificEditContent = needsModification ? - editContentString.replaceAll(MSG_ID_PLACEHOLDER_REGEX, Integer.toString(i)) : - editContentString; - - editContentElement = XmlUtil.readXmlToElement(specificEditContent); - final Node config = ((Element) msg.getDocumentElement().getElementsByTagName("edit-config").item(0)). - getElementsByTagName("config").item(0); - config.appendChild(msg.importNode(editContentElement, true)); - } catch (final IOException | SAXException e) { - throw new IllegalArgumentException("Edit content file is unreadable", e); + for (int i = 0; i < threadAmount; i++) { + final List preparedMessages = allPreparedMessages.get(i); + int padding = 0; + if (i == threadAmount - 1) { + padding = leftoverRequests; + } + for (int j = 0; j < requestsPerThread + padding; j++) { + LOG.debug("id: " + (i * requestsPerThread + j)); + preparedMessages.add(prepareMessage(i * requestsPerThread + j, editContentString)); } - - preparedMessages.add(netconfMessage); - } - final NioEventLoopGroup nioGroup = new NioEventLoopGroup(); final Timer timer = new HashedWheelTimer(); final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(params, nioGroup, timer); - final NetconfDeviceCommunicator sessionListener = getSessionListener(params.getInetAddress()); + final List callables = new ArrayList<>(threadAmount); + for (final List messages : allPreparedMessages) { + callables.add(new StressClientCallable(params, netconfClientDispatcher, messages)); + } - final NetconfClientConfiguration cfg = getNetconfClientConfiguration(params, sessionListener); + final ExecutorService executorService = Executors.newFixedThreadPool(threadAmount); - LOG.info("Connecting to netconf server {}:{}", params.ip, params.port); - final NetconfClientSession netconfClientSession; + LOG.info("Starting stress test"); + final Stopwatch started = Stopwatch.createStarted(); try { - netconfClientSession = netconfClientDispatcher.createClient(cfg).get(); + final List> futures = executorService.invokeAll(callables); + for (final Future future : futures) { + try { + future.get(4L, TimeUnit.MINUTES); + } catch (ExecutionException | TimeoutException e) { + throw new RuntimeException(e); + } + } + executorService.shutdownNow(); } catch (final InterruptedException e) { - throw new RuntimeException(e); - } catch (final ExecutionException e) { - throw new RuntimeException("Unable to connect", e); + throw new RuntimeException("Unable to execute requests", e); } - - LOG.info("Starting stress test"); - final Stopwatch started = Stopwatch.createStarted(); - getExecutionStrategy(params, preparedMessages, sessionListener).invoke(); started.stop(); LOG.info("FINISHED. Execution time: {}", started); LOG.info("Requests per second: {}", (params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS))); // Cleanup - netconfClientSession.close(); timer.stop(); try { nioGroup.shutdownGracefully().get(20L, TimeUnit.SECONDS); @@ -176,12 +171,33 @@ public final class StressClient { } } - private static ExecutionStrategy getExecutionStrategy(final Parameters params, final List preparedMessages, final NetconfDeviceCommunicator sessionListener) { - if(params.async) { - return new AsyncExecutionStrategy(params, preparedMessages, sessionListener); - } else { - return new SyncExecutionStrategy(params, preparedMessages, sessionListener); + static NetconfMessage prepareMessage(final int id, final String editContentString) { + final Document msg = XmlUtil.createDocumentCopy(editBlueprint); + msg.getDocumentElement().setAttribute("message-id", Integer.toString(id)); + final NetconfMessage netconfMessage = new NetconfMessage(msg); + + final Element editContentElement; + try { + // Insert message id where needed + String specificEditContent = editContentString.replaceAll(MSG_ID_PLACEHOLDER_REGEX, Integer.toString(id)); + + final StringBuilder stringBuilder = new StringBuilder(specificEditContent); + int idx = stringBuilder.indexOf(PHYS_ADDR_PLACEHOLDER); + while (idx!= -1) { + stringBuilder.replace(idx, idx + PHYS_ADDR_PLACEHOLDER.length(), getMac(macStart++)); + idx = stringBuilder.indexOf(PHYS_ADDR_PLACEHOLDER); + } + specificEditContent = stringBuilder.toString(); + + editContentElement = XmlUtil.readXmlToElement(specificEditContent); + final Node config = ((Element) msg.getDocumentElement().getElementsByTagName("edit-config").item(0)). + getElementsByTagName("config").item(0); + config.appendChild(msg.importNode(editContentElement, true)); + } catch (final IOException | SAXException e) { + throw new IllegalArgumentException("Edit content file is unreadable", e); } + + return netconfMessage; } private static NetconfClientDispatcherImpl configureClientDispatcher(final Parameters params, final NioEventLoopGroup nioGroup, final Timer timer) { @@ -202,19 +218,18 @@ public final class StressClient { return netconfClientDispatcher; } - private static NetconfClientConfiguration getNetconfClientConfiguration(final Parameters params, final NetconfDeviceCommunicator sessionListener) { - final NetconfClientConfigurationBuilder netconfClientConfigurationBuilder = NetconfClientConfigurationBuilder.create(); - netconfClientConfigurationBuilder.withSessionListener(sessionListener); - netconfClientConfigurationBuilder.withAddress(params.getInetAddress()); - netconfClientConfigurationBuilder.withProtocol(params.ssh ? NetconfClientConfiguration.NetconfClientProtocol.SSH : NetconfClientConfiguration.NetconfClientProtocol.TCP); - netconfClientConfigurationBuilder.withConnectionTimeoutMillis(20000L); - netconfClientConfigurationBuilder.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000)); - return netconfClientConfigurationBuilder.build(); - } + public static String getMac(long mac) { + StringBuilder m = new StringBuilder(Long.toString(mac, 16)); + + for (int i = m.length(); i < 12; i++) { + m.insert(0, "0"); + } + + for (int j = m.length() - 2; j >= 2; j-=2) { + m.insert(j, ":"); + } - static NetconfDeviceCommunicator getSessionListener(final InetSocketAddress inetAddress) { - final RemoteDevice loggingRemoteDevice = new LoggingRemoteDevice(); - return new NetconfDeviceCommunicator(new RemoteDeviceId("secure-test", inetAddress), loggingRemoteDevice); + return m.toString(); } private static Parameters parseArgs(final String[] args, final ArgumentParser parser) { @@ -231,7 +246,7 @@ public final class StressClient { } - private static class LoggingRemoteDevice implements RemoteDevice { + static class LoggingRemoteDevice implements RemoteDevice { @Override public void onRemoteSessionUp(final NetconfSessionPreferences remoteSessionCapabilities, final NetconfDeviceCommunicator netconfDeviceCommunicator) { LOG.info("Session established"); diff --git a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClientCallable.java b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClientCallable.java new file mode 100644 index 0000000000..a4c5c5702d --- /dev/null +++ b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/StressClientCallable.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2015 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.test.tool.client.stress; + +import io.netty.util.concurrent.GlobalEventExecutor; +import java.net.InetSocketAddress; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import org.opendaylight.controller.netconf.api.NetconfMessage; +import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; +import org.opendaylight.controller.netconf.client.NetconfClientSession; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; +import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader; +import org.opendaylight.controller.sal.connect.api.RemoteDevice; +import org.opendaylight.controller.sal.connect.netconf.listener.NetconfDeviceCommunicator; +import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionPreferences; +import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; +import org.opendaylight.protocol.framework.NeverReconnectStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class StressClientCallable implements Callable{ + + private static final Logger LOG = LoggerFactory.getLogger(StressClientCallable.class); + + private Parameters params; + private final NetconfDeviceCommunicator sessionListener; + private final NetconfClientDispatcherImpl netconfClientDispatcher; + private final NetconfClientConfiguration cfg; + private final NetconfClientSession netconfClientSession; + private final ExecutionStrategy executionStrategy; + + public StressClientCallable(final Parameters params, + final NetconfClientDispatcherImpl netconfClientDispatcher, + final List preparedMessages) { + this.params = params; + this.sessionListener = getSessionListener(params.getInetAddress()); + this.netconfClientDispatcher = netconfClientDispatcher; + cfg = getNetconfClientConfiguration(this.params, this.sessionListener); + + LOG.info("Connecting to netconf server {}:{}", params.ip, params.port); + try { + netconfClientSession = netconfClientDispatcher.createClient(cfg).get(); + } catch (final InterruptedException e) { + throw new RuntimeException(e); + } catch (final ExecutionException e) { + throw new RuntimeException("Unable to connect", e); + } + executionStrategy = getExecutionStrategy(params, preparedMessages, sessionListener); + } + + @Override + public Boolean call() throws Exception { + executionStrategy.invoke(); + netconfClientSession.close(); + return true; + } + + private static ExecutionStrategy getExecutionStrategy(final Parameters params, final List preparedMessages, final NetconfDeviceCommunicator sessionListener) { + if(params.async) { + return new AsyncExecutionStrategy(params, preparedMessages, sessionListener); + } else { + return new SyncExecutionStrategy(params, preparedMessages, sessionListener); + } + } + + private static NetconfDeviceCommunicator getSessionListener(final InetSocketAddress inetAddress) { + final RemoteDevice loggingRemoteDevice = new StressClient.LoggingRemoteDevice(); + return new NetconfDeviceCommunicator(new RemoteDeviceId("secure-test", inetAddress), loggingRemoteDevice); + } + + private static NetconfClientConfiguration getNetconfClientConfiguration(final Parameters params, final NetconfDeviceCommunicator sessionListener) { + final NetconfClientConfigurationBuilder netconfClientConfigurationBuilder = NetconfClientConfigurationBuilder.create(); + netconfClientConfigurationBuilder.withSessionListener(sessionListener); + netconfClientConfigurationBuilder.withAddress(params.getInetAddress()); + if(params.tcpHeader != null) { + final String header = params.tcpHeader.replaceAll("\"", "").trim() + "\n"; + netconfClientConfigurationBuilder.withAdditionalHeader(new NetconfHelloMessageAdditionalHeader(null, null, null, null, null) { + @Override + public String toFormattedString() { + LOG.debug("Sending TCP header {}", header); + return header; + } + }); + } + netconfClientConfigurationBuilder.withProtocol(params.ssh ? NetconfClientConfiguration.NetconfClientProtocol.SSH : NetconfClientConfiguration.NetconfClientProtocol.TCP); + netconfClientConfigurationBuilder.withConnectionTimeoutMillis(20000L); + netconfClientConfigurationBuilder.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000)); + return netconfClientConfigurationBuilder.build(); + } +} diff --git a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/SyncExecutionStrategy.java b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/SyncExecutionStrategy.java index 34142a7f2a..40f39022e6 100644 --- a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/SyncExecutionStrategy.java +++ b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/client/stress/SyncExecutionStrategy.java @@ -31,24 +31,26 @@ class SyncExecutionStrategy implements ExecutionStrategy { private final List preparedMessages; private final NetconfDeviceCommunicator sessionListener; private final List editBatches; + private final int editAmount; public SyncExecutionStrategy(final Parameters params, final List preparedMessages, final NetconfDeviceCommunicator sessionListener) { this.params = params; this.preparedMessages = preparedMessages; this.sessionListener = sessionListener; - editBatches = countEditBatchSizes(params); + this.editBatches = countEditBatchSizes(params, preparedMessages.size()); + editAmount = preparedMessages.size(); } - private static List countEditBatchSizes(final Parameters params) { + private static List countEditBatchSizes(final Parameters params, final int amount) { final List editBatches = Lists.newArrayList(); - if (params.editBatchSize != params.editCount) { - final int fullBatches = params.editCount / params.editBatchSize; + if (params.editBatchSize != amount) { + final int fullBatches = amount / params.editBatchSize; for (int i = 0; i < fullBatches; i++) { editBatches.add(params.editBatchSize); } - if (params.editCount % params.editBatchSize != 0) { - editBatches.add(params.editCount % params.editBatchSize); + if (amount % params.editBatchSize != 0) { + editBatches.add(amount % params.editBatchSize); } } else { editBatches.add(params.editBatchSize); @@ -82,7 +84,7 @@ class SyncExecutionStrategy implements ExecutionStrategy { sessionListener.sendRequest(StressClient.COMMIT_MSG, StressClient.COMMIT_QNAME)); } - Preconditions.checkState(responseCounter.get() == params.editCount + editBatches.size(), "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size()); + Preconditions.checkState(responseCounter.get() == editAmount + editBatches.size(), "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size()); } private void waitForResponse(AtomicInteger responseCounter, final ListenableFuture> netconfMessageFuture) { diff --git a/opendaylight/netconf/netconf-usermanager/pom.xml b/opendaylight/netconf/netconf-usermanager/pom.xml index 44e6c61472..8f8059ae19 100644 --- a/opendaylight/netconf/netconf-usermanager/pom.xml +++ b/opendaylight/netconf/netconf-usermanager/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT ../ netconf-usermanager diff --git a/opendaylight/netconf/netconf-util/pom.xml b/opendaylight/netconf/netconf-util/pom.xml index 5d82cf1ccd..b629e28618 100644 --- a/opendaylight/netconf/netconf-util/pom.xml +++ b/opendaylight/netconf/netconf-util/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.controller netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT netconf-util bundle diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java index 4529f81e57..3d46bf6ab4 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java @@ -143,8 +143,9 @@ public final class XmlElement { } public String getName() { - if (element.getLocalName()!=null && !element.getLocalName().equals(DEFAULT_NAMESPACE_PREFIX)){ - return element.getLocalName(); + final String localName = element.getLocalName(); + if (!Strings.isNullOrEmpty(localName)){ + return localName; } return element.getTagName(); } diff --git a/opendaylight/netconf/pom.xml b/opendaylight/netconf/pom.xml index ab92128dbd..e2d834fee8 100644 --- a/opendaylight/netconf/pom.xml +++ b/opendaylight/netconf/pom.xml @@ -5,12 +5,12 @@ org.opendaylight.controller commons.opendaylight - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ../commons/opendaylight netconf-subsystem - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT pom ${project.artifactId} diff --git a/pom.xml b/pom.xml index 068be09dcb..bde0e73a20 100644 --- a/pom.xml +++ b/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.controller commons.parent - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT opendaylight/commons/parent releasepom - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT pom controller