Merge changes I879118ce,I664b391e
authorTony Tkacik <ttkacik@cisco.com>
Thu, 16 Oct 2014 10:09:05 +0000 (10:09 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 16 Oct 2014 10:09:05 +0000 (10:09 +0000)
* changes:
  BUG-2017 Fix possible concurrent modification ex in config subsystem
  BUG-1520 Set correct factory in ImmediateEventExecutorModuleTest

453 files changed:
features/adsal-compatibility/pom.xml
features/adsal/pom.xml
features/adsal/src/main/resources/features.xml
features/akka/pom.xml
features/akka/src/main/resources/features.xml
features/base/pom.xml
features/base/src/main/resources/features.xml
features/config-netty/pom.xml
features/config-persister/pom.xml
features/config/pom.xml
features/controller/pom.xml
features/extras/pom.xml
features/flow/pom.xml
features/mdsal/pom.xml
features/mdsal/src/main/resources/features.xml
features/netconf-connector/pom.xml
features/netconf-connector/src/main/resources/features.xml
features/netconf/pom.xml
features/nsf/pom.xml
features/pom.xml
features/protocol-framework/pom.xml
features/restconf/pom.xml [new file with mode: 0644]
features/restconf/src/main/resources/features.xml [new file with mode: 0644]
itests/base-features-it/pom.xml
itests/pom.xml
opendaylight/appauth/pom.xml
opendaylight/archetypes/odl-model-project/pom.xml
opendaylight/archetypes/odl-model-project/src/main/resources/archetype-resources/pom.xml
opendaylight/archetypes/opendaylight-configfile-archetype/pom.xml
opendaylight/archetypes/opendaylight-karaf-distro-archetype/pom.xml
opendaylight/archetypes/opendaylight-karaf-distro-archetype/src/main/resources/archetype-resources/pom.xml
opendaylight/archetypes/opendaylight-karaf-features/pom.xml
opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/pom.xml
opendaylight/archetypes/opendaylight-karaf-features/src/main/resources/archetype-resources/src/main/resources/features.xml
opendaylight/archetypes/pom.xml
opendaylight/arphandler/pom.xml
opendaylight/clustering/integrationtest/pom.xml
opendaylight/clustering/services/pom.xml
opendaylight/clustering/services_implementation/pom.xml
opendaylight/clustering/stub/pom.xml
opendaylight/clustering/test/pom.xml
opendaylight/commons/checkstyle/pom.xml
opendaylight/commons/concepts/pom.xml
opendaylight/commons/filter-valve/pom.xml
opendaylight/commons/httpclient/pom.xml
opendaylight/commons/integrationtest/pom.xml
opendaylight/commons/liblldp/pom.xml
opendaylight/commons/logback_settings/pom.xml
opendaylight/commons/opendaylight/pom.xml
opendaylight/commons/parent/pom.xml
opendaylight/commons/protocol-framework/pom.xml
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java
opendaylight/config/config-api/pom.xml
opendaylight/config/config-api/src/main/yang/config.yang
opendaylight/config/config-manager/pom.xml
opendaylight/config/config-module-archetype/pom.xml
opendaylight/config/config-netty-config/pom.xml
opendaylight/config/config-persister-api/pom.xml
opendaylight/config/config-persister-directory-xml-adapter/pom.xml
opendaylight/config/config-persister-feature-adapter/pom.xml
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ConfigFeaturesListener.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java
opendaylight/config/config-persister-file-xml-adapter/pom.xml
opendaylight/config/config-plugin-parent/pom.xml
opendaylight/config/config-util/pom.xml
opendaylight/config/logback-config-loader/pom.xml
opendaylight/config/logback-config/pom.xml
opendaylight/config/netconf-config-dispatcher/pom.xml
opendaylight/config/netty-config-api/pom.xml
opendaylight/config/netty-event-executor-config/pom.xml
opendaylight/config/netty-threadgroup-config/pom.xml
opendaylight/config/netty-timer-config/pom.xml
opendaylight/config/pom.xml
opendaylight/config/shutdown-api/pom.xml
opendaylight/config/shutdown-impl/pom.xml
opendaylight/config/threadpool-config-api/pom.xml
opendaylight/config/threadpool-config-impl/pom.xml
opendaylight/config/yang-jmx-generator-it/pom.xml
opendaylight/config/yang-jmx-generator-plugin/pom.xml
opendaylight/config/yang-jmx-generator/pom.xml
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryNameConflictTest.java
opendaylight/config/yang-jmx-generator/src/test/resources/config-jmx-it-impl.yang
opendaylight/config/yang-jmx-generator/src/test/resources/duplicates/config-test-duplicate-attribute-in-list.yang
opendaylight/config/yang-jmx-generator/src/test/resources/duplicates/config-test-duplicate-attribute.yang
opendaylight/config/yang-jmx-generator/src/test/resources/test-config-files.yang
opendaylight/config/yang-jmx-generator/src/test/resources/test-config-files1.yang
opendaylight/config/yang-test-plugin/pom.xml
opendaylight/config/yang-test/pom.xml
opendaylight/configuration/api/pom.xml
opendaylight/configuration/implementation/pom.xml
opendaylight/configuration/integrationtest/pom.xml
opendaylight/connectionmanager/api/pom.xml
opendaylight/connectionmanager/implementation/pom.xml
opendaylight/containermanager/api/pom.xml
opendaylight/containermanager/implementation/pom.xml
opendaylight/containermanager/it.implementation/pom.xml
opendaylight/containermanager/shell/pom.xml
opendaylight/distribution/opendaylight-karaf-empty/pom.xml
opendaylight/distribution/opendaylight-karaf-resources/pom.xml
opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/bin/setenv.bat [new file with mode: 0644]
opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/etc/custom.properties
opendaylight/distribution/opendaylight-karaf/pom.xml
opendaylight/distribution/opendaylight/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/distribution/p2site/pom.xml
opendaylight/distribution/sanitytest/pom.xml
opendaylight/dummy-console/pom.xml
opendaylight/forwarding/staticrouting/pom.xml
opendaylight/forwardingrulesmanager/api/pom.xml
opendaylight/forwardingrulesmanager/implementation/pom.xml
opendaylight/forwardingrulesmanager/integrationtest/pom.xml
opendaylight/hosttracker/api/pom.xml
opendaylight/hosttracker/implementation/pom.xml
opendaylight/hosttracker/integrationtest/pom.xml
opendaylight/hosttracker/shell/pom.xml
opendaylight/hosttracker_new/api/pom.xml
opendaylight/hosttracker_new/implementation/pom.xml
opendaylight/karaf-branding/.gitignore [new file with mode: 0644]
opendaylight/karaf-branding/pom.xml
opendaylight/karaf-tomcat-security/pom.xml
opendaylight/logging/bridge/pom.xml
opendaylight/md-sal/benchmark-data-store/pom.xml
opendaylight/md-sal/compatibility/pom.xml
opendaylight/md-sal/compatibility/sal-compatibility/pom.xml
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/AbstractDataChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NCDataChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeDataChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/SalCompatibilityProvider.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java
opendaylight/md-sal/forwardingrules-manager/pom.xml
opendaylight/md-sal/inventory-manager/pom.xml
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.java
opendaylight/md-sal/md-sal-config/pom.xml
opendaylight/md-sal/model/model-flow-base/pom.xml
opendaylight/md-sal/model/model-flow-service/pom.xml
opendaylight/md-sal/model/model-flow-service/src/main/yang/flow-node-inventory.yang
opendaylight/md-sal/model/model-flow-statistics/pom.xml
opendaylight/md-sal/model/model-inventory/pom.xml
opendaylight/md-sal/model/model-topology/pom.xml
opendaylight/md-sal/model/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-akka-raft/pom.xml
opendaylight/md-sal/sal-binding-api/pom.xml
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-config/pom.xml
opendaylight/md-sal/sal-binding-dom-it/pom.xml
opendaylight/md-sal/sal-binding-it/pom.xml
opendaylight/md-sal/sal-binding-util/pom.xml
opendaylight/md-sal/sal-clustering-commons/pom.xml
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActorWithMetering.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/NormalizedNodeSerializationContext.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/NormalizedNodeSerializer.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/NormalizedNodeType.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/PathArgumentSerializer.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/PathArgumentType.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameDeSerializationContext.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameDeSerializationContextImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameSerializationContext.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameSerializationContextImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java
opendaylight/md-sal/sal-clustering-commons/src/main/resources/Common.proto
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/PathArgumentSerializerTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializerTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java
opendaylight/md-sal/sal-clustering-config/pom.xml
opendaylight/md-sal/sal-common-api/pom.xml
opendaylight/md-sal/sal-common-impl/pom.xml
opendaylight/md-sal/sal-common-util/pom.xml
opendaylight/md-sal/sal-common/pom.xml
opendaylight/md-sal/sal-connector-api/pom.xml
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ActorInitialized.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ActorNotInitialized.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DeleteData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/MergeData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/WriteData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifierTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/MergeDataTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TestUtils.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SampleModelsTest.java
opendaylight/md-sal/sal-dom-api/pom.xml
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerTransactionChainImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitCoordinatorImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitErrorInvoker.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitErrorListener.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitExecutor.java
opendaylight/md-sal/sal-dom-spi/pom.xml
opendaylight/md-sal/sal-dom-xsql-config/pom.xml
opendaylight/md-sal/sal-dom-xsql/pom.xml
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/odl/xsql/JDBCDriver.java [moved from opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCDriver.java with 84% similarity]
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrintNode.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLColumn.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCCommand.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCConnection.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCServer.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCStatement.java
opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-xsql/src/test/resources/BluePrintCache.dat [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/pom.xml
opendaylight/md-sal/sal-karaf-xsql/pom.xml
opendaylight/md-sal/sal-karaf-xsql/src/main/java/org/opendaylight/controller/xsql/xsql.java
opendaylight/md-sal/sal-netconf-connector/pom.xml
opendaylight/md-sal/sal-remote/pom.xml
opendaylight/md-sal/sal-remoterpc-connector/pom.xml
opendaylight/md-sal/sal-rest-connector-config/pom.xml
opendaylight/md-sal/sal-rest-connector/pom.xml
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonToCompositeNodeReader.java
opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml
opendaylight/md-sal/sal-rest-connector/src/main/yang/sal-remote-augment.yang
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java
opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-cnsn/invalid-uri-character-in-value.json [new file with mode: 0644]
opendaylight/md-sal/sal-rest-docgen/pom.xml
opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java
opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml
opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGeneratorTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-docgen/src/test/resources/yang/opflex.yang [new file with mode: 0644]
opendaylight/md-sal/sal-rest-docgen/src/test/resources/yang/toaster.yang
opendaylight/md-sal/sal-restconf-broker/pom.xml
opendaylight/md-sal/sal-test-model/pom.xml
opendaylight/md-sal/samples/clustering-test-app/configuration/pom.xml
opendaylight/md-sal/samples/clustering-test-app/model/pom.xml
opendaylight/md-sal/samples/clustering-test-app/pom.xml
opendaylight/md-sal/samples/clustering-test-app/provider/pom.xml
opendaylight/md-sal/samples/l2switch/implementation/pom.xml
opendaylight/md-sal/samples/l2switch/model/pom.xml
opendaylight/md-sal/samples/l2switch/pom.xml
opendaylight/md-sal/samples/pom.xml
opendaylight/md-sal/samples/toaster-config/pom.xml
opendaylight/md-sal/samples/toaster-consumer/pom.xml
opendaylight/md-sal/samples/toaster-it/pom.xml
opendaylight/md-sal/samples/toaster-provider/pom.xml
opendaylight/md-sal/samples/toaster/pom.xml
opendaylight/md-sal/statistics-manager/pom.xml
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractListeningStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowCapableContext.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowCapableTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsEntry.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowTableStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MultipartMessageManager.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeConnectorStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsEntry.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatListeningCommiter.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatNodeRegistration.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatNotifyCommiter.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatPermCollector.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatRpcMsgManager.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsListener.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManager.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerActivator.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatAbstractListenCommit.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatAbstractNotifyCommit.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitFlow.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitGroup.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitMeter.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitQueue.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNodeRegistrationImpl.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNotifyCommitPort.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNotifyCommitTable.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatPermCollectorImpl.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatRPCFailedException.java [moved from opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/RPCFailedException.java with 75% similarity]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatRpcMsgManagerImpl.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerImpl.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/helper/FlowComparator.java [moved from opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowComparator.java with 80% similarity]
opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerProvider.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/impl/helper/StatisticsUpdateCommiterTest.java [moved from opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiterTest.java with 81% similarity]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/GroupStatisticsTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/MeterStatisticsTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/NodeRegistrationTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/PortStatisticsTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/QueueStatisticsTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/TableStatisticsTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/AbstractDataBrokerTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/AbstractSchemaAwareTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/BundleContextMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/DataBrokerTestCustomizer.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/FlowMockGenerator.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/GroupMockGenerator.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MatchMockGenerator.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MeterMockGenerator.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MockSchemaService.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/NotificationProviderServiceHelper.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowStatisticsServiceMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowTableStatisticsServiceMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightGroupStatisticsServiceMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightMeterStatisticsServiceMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightPortStatisticsServiceMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightQueueStatisticsServiceMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/PortMockGenerator.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/ProviderContextMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/QueueMockGenerator.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/StatisticsManagerTest.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/TestUtils.java [new file with mode: 0644]
opendaylight/md-sal/topology-lldp-discovery/pom.xml
opendaylight/md-sal/topology-manager/pom.xml
opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java
opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/OperationProcessor.java
opendaylight/md-sal/topology-manager/src/test/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporterTest.java
opendaylight/netconf/config-netconf-connector/pom.xml
opendaylight/netconf/config-persister-impl/pom.xml
opendaylight/netconf/ietf-netconf-monitoring-extension/pom.xml
opendaylight/netconf/ietf-netconf-monitoring/pom.xml
opendaylight/netconf/netconf-api/pom.xml
opendaylight/netconf/netconf-auth/pom.xml
opendaylight/netconf/netconf-cli/pom.xml
opendaylight/netconf/netconf-client/pom.xml
opendaylight/netconf/netconf-config/pom.xml
opendaylight/netconf/netconf-connector-config/pom.xml
opendaylight/netconf/netconf-impl/pom.xml
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfMonitoringServiceImplTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSessionTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommitTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchemaTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExiTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivatorTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryTrackerTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/util/DeserializerExceptionHandlerTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-it/pom.xml
opendaylight/netconf/netconf-mapping-api/pom.xml
opendaylight/netconf/netconf-monitoring/pom.xml
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringActivatorTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringOperationServiceTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringServiceTrackerTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-netty-util/pom.xml
opendaylight/netconf/netconf-ssh/pom.xml
opendaylight/netconf/netconf-tcp/pom.xml
opendaylight/netconf/netconf-testtool/pom.xml
opendaylight/netconf/netconf-usermanager/pom.xml
opendaylight/netconf/netconf-util/pom.xml
opendaylight/netconf/pom.xml
opendaylight/networkconfiguration/neutron/implementation/pom.xml
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronPortInterface.java
opendaylight/networkconfiguration/neutron/pom.xml
opendaylight/northbound/archetype-app-northbound/pom.xml
opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml
opendaylight/northbound/bundlescanner/api/pom.xml
opendaylight/northbound/bundlescanner/implementation/pom.xml
opendaylight/northbound/commons/pom.xml
opendaylight/northbound/connectionmanager/pom.xml
opendaylight/northbound/containermanager/pom.xml
opendaylight/northbound/controllermanager/pom.xml
opendaylight/northbound/flowprogrammer/pom.xml
opendaylight/northbound/hosttracker/pom.xml
opendaylight/northbound/httpservice-bridge/pom.xml
opendaylight/northbound/integrationtest/pom.xml
opendaylight/northbound/java-client/pom.xml
opendaylight/northbound/jolokia/pom.xml
opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml
opendaylight/northbound/networkconfiguration/neutron/pom.xml
opendaylight/northbound/staticrouting/pom.xml
opendaylight/northbound/statistics/pom.xml
opendaylight/northbound/subnets/pom.xml
opendaylight/northbound/swagger-ui/pom.xml
opendaylight/northbound/switchmanager/pom.xml
opendaylight/northbound/topology/pom.xml
opendaylight/northbound/usermanager/pom.xml
opendaylight/northboundtest/unit_test_suite/pom.xml
opendaylight/protocol_plugins/openflow/pom.xml
opendaylight/protocol_plugins/stub/pom.xml
opendaylight/routing/dijkstra_implementation/pom.xml
opendaylight/sal/api/pom.xml
opendaylight/sal/connection/api/pom.xml
opendaylight/sal/connection/implementation/pom.xml
opendaylight/sal/implementation/pom.xml
opendaylight/sal/networkconfiguration/api/pom.xml
opendaylight/sal/networkconfiguration/implementation/pom.xml
opendaylight/samples/clustersession/pom.xml
opendaylight/samples/loadbalancer/pom.xml
opendaylight/samples/northbound/loadbalancer/pom.xml
opendaylight/samples/simpleforwarding/pom.xml
opendaylight/security/pom.xml
opendaylight/statisticsmanager/api/pom.xml
opendaylight/statisticsmanager/implementation/pom.xml
opendaylight/statisticsmanager/integrationtest/pom.xml
opendaylight/switchmanager/api/pom.xml
opendaylight/switchmanager/implementation/pom.xml
opendaylight/switchmanager/integrationtest/pom.xml
opendaylight/topologymanager/implementation/pom.xml
opendaylight/topologymanager/integrationtest/pom.xml
opendaylight/topologymanager/shell/pom.xml
opendaylight/usermanager/api/pom.xml
opendaylight/usermanager/implementation/pom.xml
opendaylight/web/brandfragment/pom.xml
opendaylight/web/devices/pom.xml
opendaylight/web/flows/pom.xml
opendaylight/web/osgi-brandfragment/pom.xml
opendaylight/web/root/pom.xml
opendaylight/web/topology/pom.xml
opendaylight/web/troubleshoot/pom.xml
pom.xml
third-party/commons/thirdparty/pom.xml
third-party/ganymed/pom.xml
third-party/jersey-servlet/pom.xml
third-party/net.sf.jung2/pom.xml
third-party/openflowj/pom.xml
third-party/org.apache.catalina.filters.CorsFilter/pom.xml

index 44b9b0900c0b01538c78592b8746c6de4d4a1e77..7b8af644450d396aef145cda4efab903657f2011 100644 (file)
    <parent>\r
      <groupId>org.opendaylight.controller</groupId>\r
      <artifactId>commons.opendaylight</artifactId>\r
-     <version>1.4.2-SNAPSHOT</version>\r
+     <version>1.5.0-SNAPSHOT</version>\r
      <relativePath>../../opendaylight/commons/opendaylight</relativePath>\r
    </parent>\r
    <artifactId>features-adsal-compatibility</artifactId>\r
    <packaging>jar</packaging>\r
    <properties>\r
       <features.file>features.xml</features.file>\r
-      <feature.test.version>0.6.2-SNAPSHOT</feature.test.version>\r
+      <feature.test.version>0.7.0-SNAPSHOT</feature.test.version>\r
    </properties>\r
    <dependencies>\r
     <!--\r
         <dependency>\r
           <groupId>org.opendaylight.yangtools</groupId>\r
           <artifactId>features-yangtools</artifactId>\r
-          <version>0.6.2-SNAPSHOT</version>\r
+          <version>0.7.0-SNAPSHOT</version>\r
           <classifier>features</classifier>\r
           <type>xml</type>\r
         </dependency>\r
         <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>features-mdsal</artifactId>\r
-          <version>1.1-SNAPSHOT</version>\r
+          <version>1.2.0-SNAPSHOT</version>\r
           <classifier>features</classifier>\r
           <type>xml</type>\r
         </dependency>\r
         <dependency>\r
           <groupId>org.opendaylight.openflowplugin</groupId>\r
           <artifactId>features-openflowplugin</artifactId>\r
-          <version>0.0.3-SNAPSHOT</version>\r
+          <version>0.1.0-SNAPSHOT</version>\r
           <classifier>features</classifier>\r
           <type>xml</type>\r
         </dependency>\r
index 0ce976e2ef3beed38a8019cfc63074d04989a674..429edf828fe5b613c1722af9c632409368d74315 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>features-adsal</artifactId>
@@ -31,7 +31,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>opendaylight-karaf-empty</artifactId>
-      <version>1.4.2-SNAPSHOT</version>
+      <version>1.5.0-SNAPSHOT</version>
       <type>zip</type>
     </dependency>
     <!-- Bundle dependencies -->
index e12ca8e5e990acc860dc9e56e4eed57ed9c2a0e0..a665657ba7bb5130a54c10964dc643e6fb50792e 100644 (file)
@@ -35,7 +35,6 @@
       <feature version="${sal.version}">odl-adsal-core</feature>
       <bundle>mvn:org.opendaylight.controller/clustering.services/${clustering.services.version}</bundle>
       <bundle>mvn:org.opendaylight.controller/clustering.services-implementation/${clustering.services_implementation.version}</bundle>
-      <bundle>mvn:org.opendaylight.controller/clustering.stub/${clustering.stub.version}</bundle>
    </feature>
    <feature name="odl-adsal-configuration" description="OpenDaylight :: AD-SAL :: Configuration" version="${configuration.version}">
       <feature version="${sal.version}">odl-adsal-core</feature>
index f1f3017c208704f05c7133e13342d2fbb53bfac3..f804505c64d2c57ef8d95fc0091a2b0b74285ed6 100644 (file)
@@ -10,7 +10,7 @@
    <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
    </parent>
    <artifactId>features-akka</artifactId>
       <features.file>features.xml</features.file>
       <!-- Optional TODO: Move these properties to your parent pom and possibly
             DependencyManagement section of your parent pom -->
-      <branding.version>1.0.0-SNAPSHOT</branding.version>
-      <karaf.resources.version>1.4.2-SNAPSHOT</karaf.resources.version>
+      <branding.version>1.1.0-SNAPSHOT</branding.version>
+      <karaf.resources.version>1.5.0-SNAPSHOT</karaf.resources.version>
       <karaf.version>3.0.1</karaf.version>
-      <feature.test.version>0.6.2-SNAPSHOT</feature.test.version>
-      <karaf.empty.version>1.4.2-SNAPSHOT</karaf.empty.version>
+      <feature.test.version>0.7.0-SNAPSHOT</feature.test.version>
+      <karaf.empty.version>1.5.0-SNAPSHOT</karaf.empty.version>
       <surefire.version>2.16</surefire.version>
    </properties>
    <dependencies>
         <dependency>
           <groupId>org.opendaylight.yangtools</groupId>
           <artifactId>features-yangtools</artifactId>
-          <version>0.6.2-SNAPSHOT</version>
+          <version>0.7.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>features-mdsal</artifactId>
-          <version>1.1-SNAPSHOT</version>
+          <version>1.2.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.openflowplugin</groupId>
           <artifactId>features-openflowplugin</artifactId>
-          <version>0.0.3-SNAPSHOT</version>
+          <version>0.1.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
index 182ff766e6f8a05066e95157480f0e8994013642..8a3b4a2e25d038884c2d34e23b2bacbe94aec489 100644 (file)
@@ -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:
-            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.6.2-SNAPSHOT/xml/features</repository>
-            <repository>mvn:org.opendaylight.controller/features-mdsal/1.1-SNAPSHOT/xml/features</repository>
-            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.0.3-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features</repository>
     -->
     <feature name='odl-akka-all' version='${project.version}' description='OpenDaylight :: Akka :: All'>
         <!--
@@ -53,7 +53,7 @@
 
         * Basic MD-SAL Provider
         <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider '>
-            <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
             <feature version='${project.version}'>odl-controller-model</feature>
             <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
             ... whatever other bundles you need
 
         * Basic MD-SAL Model feature
         <feature name='odl-controller-model' version='${project.version}' description='OpenDaylight :: controller :: Model'>
-            <feature version='0.6.2-SNAPSHOT'>odl-yangtools-binding</feature>
-            <feature version='0.6.2-SNAPSHOT'>odl-yangtools-models</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-binding</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-models</feature>
             <bundle>mvn:org.opendaylight.controller/controller-model/${project.version}</bundle>
             ... whatever other bundles you need
         </feature>
 
         * Config Subsystem example - the config file is your config subsystem configuration
         <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
-            <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
             <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
             <configfile finalname="etc/opendaylight/karaf/80-controller.xml">mvn:org.opendaylight.controller/controller-config/${project.version}/xml/config</configfile>
             ... whatever other bundles you need
@@ -77,7 +77,7 @@
 
         * Basic MD-SAL Provider that uses openflowplugin-flow-services (which brings along odl-mdsal-broker)
         <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
-            <feature version='0.0.3-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
+            <feature version='0.1.0-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
             <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
             ... whatever other bundles you need
         </feature>
index 8fec90fd9dc3ddc9ef3c3e80ecb040b617c44515..b7ab3ca75774c0c4e8875893adf418c619267b55 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>features-base</artifactId>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>features-test</artifactId>
-      <version>0.6.2-SNAPSHOT</version>
+      <version>0.7.0-SNAPSHOT</version>
     </dependency>
     <!-- dependency for opendaylight-karaf-empty for use by testing -->
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>opendaylight-karaf-empty</artifactId>
-      <version>1.4.2-SNAPSHOT</version>
+      <version>1.5.0-SNAPSHOT</version>
       <type>zip</type>
     </dependency>
   </dependencies>
index e4c455ccca6a7078fb0f319274b4af07b02a3853..c324f6cea65cc4d9fb9e6883f43ff93d854c03c8 100644 (file)
@@ -16,8 +16,8 @@
       <feature>odl-base-jackson</feature>
       <feature>odl-base-spring-security</feature>
    </feature>
-   <feature name="odl-base-dummy-console" description="Temporary Dummy Console" version="1.1.0-SNAPSHOT">
-      <bundle>mvn:org.opendaylight.controller/dummy-console/1.1.0-SNAPSHOT</bundle>
+   <feature name="odl-base-dummy-console" description="Temporary Dummy Console" version="1.2.0-SNAPSHOT">
+      <bundle>mvn:org.opendaylight.controller/dummy-console/1.2.0-SNAPSHOT</bundle>
    </feature>
    <feature name="odl-base-felix-dm" description="Felix Dependency Manager" version="${felix.dependencymanager.version}">
       <bundle>mvn:org.osgi/org.osgi.compendium/${osgi.compendium.version}</bundle>
@@ -36,7 +36,7 @@
       <bundle>wrap:mvn:io.netty/netty-common/${netty.version}</bundle>
       <bundle>wrap:mvn:io.netty/netty-handler/${netty.version}</bundle>
       <bundle>wrap:mvn:io.netty/netty-codec-http/${netty.version}</bundle>
-      <bundle>mvn:org.opendaylight.controller.thirdparty/ganymed/1.1-SNAPSHOT</bundle>
+      <bundle>mvn:org.opendaylight.controller.thirdparty/ganymed/1.2.0-SNAPSHOT</bundle>
    </feature>
    <feature name="odl-base-jersey" description="Jersey" version="${jersey.version}">
       <feature>odl-base-gemini-web</feature>
index bf036979cfa1a8394517a710b0af1c9212d34995..0057fc05c71fe915868058d2eaca20936075a604 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/config/</relativePath>
   </parent>
   <artifactId>features-config-netty</artifactId>
index 3346c754d628f8fbb03add426db0026bc4af0615..f3b42ca143785607fa635c2856d0810286ba7177 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/config/</relativePath>
   </parent>
   <artifactId>features-config-persister</artifactId>
index 20feceb3601bff99936858b994ea073e60576609..461427c7cee08e1c0ff67f4cbcdf292c64585d13 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/config/</relativePath>
   </parent>
   <artifactId>features-config</artifactId>
@@ -20,7 +20,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>opendaylight-karaf-empty</artifactId>
-      <version>1.4.2-SNAPSHOT</version>
+      <version>1.5.0-SNAPSHOT</version>
       <type>zip</type>
     </dependency>
     <dependency>
index ddaf77315188b84d72085f60dde48ab58dfab8a6..5dd2bd4a2a416af11c3ce2fb796e2602f6aeb120 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>controller-features</artifactId>
index 4563190b9f4c2eb3ba09f4d42b90ea2da9289b7f..e4356e6b4994dbd5cbee154e2c7441bb6b745d8c 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>extras-features</artifactId>
index ac189737d937cd0fb36186847327acff27a74c18..ab30b0b61fd11ca2dcc25f45b2843582eba7b330 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/md-sal</relativePath>
   </parent>
   <artifactId>features-flow</artifactId>
index 299e5b6707184ffacde75bf0d3fc246d5ecde07d..036d18fb859adb534507efe6c789694ffd3c2cc4 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/md-sal</relativePath>
   </parent>
   <artifactId>features-mdsal</artifactId>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>features-test</artifactId>
-      <version>0.6.2-SNAPSHOT</version>
+      <version>0.7.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
 
index 2a988ced05f805b5faf3b6ca31fea09255924883..fb524081e7b0ac44f8382058810ba7ac2272b639 100644 (file)
@@ -11,7 +11,6 @@
     <feature name='odl-mdsal-all' version='${project.version}' description="OpenDaylight :: MDSAL :: All">
         <feature version='${project.version}'>odl-mdsal-broker</feature>
         <feature version='${project.version}'>odl-mdsal-clustering</feature>
-        <feature version='${project.version}'>odl-restconf</feature>
         <feature version='${project.version}'>odl-mdsal-xsql</feature>
         <feature version='${project.version}'>odl-toaster</feature>
     </feature>
         <bundle>mvn:org.opendaylight.controller/sal-inmemory-datastore/${project.version}</bundle>
         <configfile finalname="${config.configfile.directory}/${config.mdsal.configfile}">mvn:org.opendaylight.controller/md-sal-config/${mdsal.version}/xml/config</configfile>
     </feature>
-    <feature name='odl-restconf' version='${project.version}' description="OpenDaylight :: Restconf">
-        <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
-        <feature>war</feature>
-        <!-- presently we need sal-remote to be listed BEFORE sal-rest-connector because sal-rest-connector
-             has a yang file which augments a yang file in sal-remote, and order seems to matter -->
-        <bundle>mvn:org.opendaylight.controller/sal-remote/${project.version}</bundle>
-        <bundle>mvn:org.opendaylight.controller/sal-rest-connector/${project.version}</bundle>
-        <bundle>mvn:com.google.code.gson/gson/${gson.version}</bundle>
-        <bundle>mvn:org.opendaylight.yangtools/yang-data-codec-gson/${yangtools.version}</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
-        <bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
-        <bundle>mvn:io.netty/netty-codec/${netty.version}</bundle>
-        <bundle>mvn:io.netty/netty-codec-http/${netty.version}</bundle>
-        <bundle>mvn:io.netty/netty-common/${netty.version}</bundle>
-        <bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
-        <bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
-        <configfile finalname="${config.configfile.directory}/${config.restconf.configfile}">mvn:org.opendaylight.controller/sal-rest-connector-config/${mdsal.version}/xml/config</configfile>
-    </feature>
     <feature name='odl-toaster' version='${project.version}' description="OpenDaylight :: Toaster">
         <feature version='${yangtools.version}'>odl-yangtools-common</feature>
         <feature version='${yangtools.version}'>odl-yangtools-binding</feature>
         <bundle>mvn:org.opendaylight.controller/sal-karaf-xsql/${project.version}</bundle>
         <configfile finalname="${config.configfile.directory}/${config.xsql.configfile}">mvn:org.opendaylight.controller/sal-dom-xsql-config/${project.version}/xml/config</configfile>
     </feature>
-    <feature name ='odl-mdsal-apidocs' version='${project.version}'>
-        <feature version='${project.version}'>odl-restconf</feature>
-        <bundle>mvn:org.opendaylight.controller/sal-rest-docgen/${project.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.datatype/jackson-datatype-json-org/${jackson.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version}</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
-        <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
-        <bundle>wrap:mvn:org.json/json/${org.json.version}</bundle>
-    </feature>
     <feature name ='odl-mdsal-clustering-commons' version='${project.version}'>
         <feature version='${project.version}'>odl-mdsal-broker</feature>
         <feature version='${akka.version}'>odl-akka-system</feature>
         <configfile finalname="configuration/initial/module-shards.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/moduleshardconf</configfile>
         <configfile finalname="configuration/initial/modules.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/moduleconf</configfile>
     </feature>
-
-    <feature name='odl-clustering-test-app' version='${project.version}'>
-        <feature version='${project.version}'>odl-mdsal-clustering</feature>
-        <feature version='${project.version}'>odl-restconf</feature>
-        <feature version='${yangtools.version}'>odl-yangtools-models</feature>
-        <bundle>mvn:org.opendaylight.controller.samples/clustering-it-model/${project.version}</bundle>
-        <bundle>mvn:org.opendaylight.controller.samples/clustering-it-provider/${project.version}</bundle>
-        <configfile finalname="${config.configfile.directory}/20-clustering-test-app.xml">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/config</configfile>
-        <configfile finalname="configuration/initial/module-shards.conf" override="true" >mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/testmoduleshardconf</configfile>
-        <configfile finalname="configuration/initial/modules.conf" override="true">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/testmoduleconf</configfile>
-    </feature>
 </features>
index 8b19d200a3df5b9a6cedf0ac6d81aff726f2f112..03d6fed6055d74ba4845a93be457fd3761720aa9 100644 (file)
@@ -10,7 +10,7 @@
    <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/md-sal</relativePath>
    </parent>
    <!--
@@ -21,7 +21,7 @@
   -->
    <artifactId>features-netconf-connector</artifactId>
    <!-- Optional TODO: Uncomment version if you are not using a parent pom.xml
-   <version>1.0-SNAPSHOT</version>
+   <version>1.1.0-SNAPSHOT</version>
    -->
    <packaging>jar</packaging>
    <properties>
         <dependency>
           <groupId>org.opendaylight.yangtools</groupId>
           <artifactId>features-yangtools</artifactId>
-          <version>0.6.2-SNAPSHOT</version>
+          <version>0.7.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>features-mdsal</artifactId>
-          <version>1.1-SNAPSHOT</version>
+          <version>1.2.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.openflowplugin</groupId>
           <artifactId>features-openflowplugin</artifactId>
-          <version>0.0.3-SNAPSHOT</version>
+          <version>0.1.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
index 3e576e47f1f8350aa639c72c8657dd12785a2e41..6ae308eb0c8c1ca763d4bbdcbdf5ae9e7cd50c19 100644 (file)
@@ -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:
-            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.6.2-SNAPSHOT/xml/features</repository>
-            <repository>mvn:org.opendaylight.controller/features-mdsal/1.1-SNAPSHOT/xml/features</repository>
-            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.0.3-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features</repository>
     -->
     <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
@@ -54,7 +54,7 @@
 
         * Basic MD-SAL Provider
         <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider '>
-            <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
             <feature version='${project.version}'>odl-controller-model</feature>
             <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
             ... whatever other bundles you need
 
         * Basic MD-SAL Model feature
         <feature name='odl-controller-model' version='${project.version}' description='OpenDaylight :: controller :: Model'>
-            <feature version='0.6.2-SNAPSHOT'>odl-yangtools-binding</feature>
-            <feature version='0.6.2-SNAPSHOT'>odl-yangtools-models</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-binding</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-models</feature>
             <bundle>mvn:org.opendaylight.controller/controller-model/${project.version}</bundle>
             ... whatever other bundles you need
         </feature>
 
         * Config Subsystem example - the config file is your config subsystem configuration
         <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
-            <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
             <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
             <configfile finalname="etc/opendaylight/karaf/80-controller.xml">mvn:org.opendaylight.controller/controller-config/${project.version}/xml/config</configfile>
             ... whatever other bundles you need
@@ -78,7 +78,7 @@
 
         * Basic MD-SAL Provider that uses openflowplugin-flow-services (which brings along odl-mdsal-broker)
         <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
-            <feature version='0.0.3-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
+            <feature version='0.1.0-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
             <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
             ... whatever other bundles you need
         </feature>
index 1061f4a37de7fd1088f4e333b67e9d2860a02467..a944bb4dec86f3175ccb2ff6f501d8afb947af81 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/netconf</relativePath>
   </parent>
   <artifactId>features-netconf</artifactId>
index e677d491bc1a226fce9d0ca55e2754c993d57d7e..00dc219b39b354b9900ca0b78826c1ce6412fa73 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>features-nsf</artifactId>
@@ -25,7 +25,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>opendaylight-karaf-empty</artifactId>
-      <version>1.4.2-SNAPSHOT</version>
+      <version>1.5.0-SNAPSHOT</version>
       <type>zip</type>
     </dependency>
     <!-- Feature Dependencies -->
index 9f10b5908b38579d88e03bb8ba38672b96384f34..5270e3f5cdf702110d7c4028c9099873dc0b1bab 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>features-controller</artifactId>
@@ -28,5 +28,6 @@
     <module>adsal-compatibility</module>
     <module>akka</module>
     <module>netconf-connector</module>
+    <module>restconf</module>
   </modules>
 </project>
\ No newline at end of file
index dcd24d62169ee16d8e21d24d0469af5a9ba4bbbb..d5387b43c3ee7c0bfd56de52e466297828074eb1 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>features-protocol-framework</artifactId>
diff --git a/features/restconf/pom.xml b/features/restconf/pom.xml
new file mode 100644 (file)
index 0000000..632b4cd
--- /dev/null
@@ -0,0 +1,346 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Necessary TODO: Put your copyright here.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+   <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>sal-parent</artifactId>
+    <version>1.2.0-SNAPSHOT</version>
+    <relativePath>../../opendaylight/md-sal</relativePath>
+   </parent>
+   <!--
+    Necessary TODO: Hookup your parent pom here, else you will not get necessary versions,
+    maven repos etc.  If you run this archetype in a subdirectory of your project, it
+    will pick the pom.xml from the parent directory as the parent pom, which may or may
+    not be correct.
+  -->
+   <artifactId>features-restconf</artifactId>
+   <groupId>org.opendaylight.controller</groupId>
+   <!-- Optional TODO: Uncomment version if you are not using a parent pom.xml
+   <version>1.1.0-SNAPSHOT</version>
+   -->
+   <packaging>jar</packaging>
+   <properties>
+      <features.file>features.xml</features.file>
+   </properties>
+   <dependencies>
+    <!--
+      Necessary TODO: Put dependencies on any feature repos
+      you use in your features.xml file.
+
+      Note: they will need to be <type>xml</xml>
+      and <classifier>features</classifier>.
+      One other thing to watch for is to make sure they are
+      <scope>compile</compile>, which they should be by default,
+      but be cautious lest they be at a different scope in a parent pom.
+
+      Examples:
+        <dependency>
+          <groupId>org.opendaylight.yangtools</groupId>
+          <artifactId>features-yangtools</artifactId>
+          <version>0.7.0-SNAPSHOT</version>
+          <classifier>features</classifier>
+          <type>xml</type>
+        </dependency>
+        <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>features-mdsal</artifactId>
+          <version>1.2.0-SNAPSHOT</version>
+          <classifier>features</classifier>
+          <type>xml</type>
+        </dependency>
+        <dependency>
+          <groupId>org.opendaylight.openflowplugin</groupId>
+          <artifactId>features-openflowplugin</artifactId>
+          <version>0.1.0-SNAPSHOT</version>
+          <classifier>features</classifier>
+          <type>xml</type>
+        </dependency>
+    -->
+
+    <!--
+      Necessary TODO: Put dependencies for bundles directly referenced
+      in your features.xml file.  For every <bundle> reference in your
+      features.xml file, you need a corresponding dependency here.
+
+      Examples:
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>controller-provider</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>controller-model</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+    -->
+
+    <!--
+      Necessary TODO: Put dependencies for configfiles directly referenced
+      in your features.xml file.  For every <configfile> reference in your
+      features.xml file, you need a corresponding dependency here.
+
+      Example (presuming here version is coming from the parent pom):
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>controller-config</artifactId>
+        <version>${project.version}</version>
+        <type>xml</type>
+        <classifier>config</classifier>
+      </dependency>
+    -->
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>features-yangtools</artifactId>
+      <version>${yangtools.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>features-mdsal</artifactId>
+      <version>${mdsal.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.aaa</groupId>
+      <artifactId>features-aaa</artifactId>
+      <version>${aaa.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-remote</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-rest-connector</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-buffer</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-codec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-codec-http</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-handler</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-transport</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-rest-connector-config</artifactId>
+      <version>${mdsal.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
+
+        <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.datatype</groupId>
+      <artifactId>jackson-datatype-json-org</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.module</groupId>
+      <artifactId>jackson-module-jaxb-annotations</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.jaxrs</groupId>
+      <artifactId>jackson-jaxrs-base</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.jaxrs</groupId>
+      <artifactId>jackson-jaxrs-json-provider</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+    </dependency>
+
+    <dependency>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yang-data-codec-gson</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.controller.samples</groupId>
+      <artifactId>clustering-it-model</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.samples</groupId>
+      <artifactId>clustering-it-provider</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.samples</groupId>
+      <artifactId>clustering-it-config</artifactId>
+      <version>${mdsal.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.samples</groupId>
+      <artifactId>clustering-it-config</artifactId>
+      <version>${mdsal.version}</version>
+      <type>xml</type>
+      <classifier>testmoduleshardconf</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.samples</groupId>
+      <artifactId>clustering-it-config</artifactId>
+      <version>${mdsal.version}</version>
+      <type>xml</type>
+      <classifier>testmoduleconf</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-rest-docgen</artifactId>
+    </dependency>
+
+    <!--
+      Optional TODO: Remove TODO comments.
+    -->
+    <!-- test to validate features.xml -->
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>features-test</artifactId>
+      <version>${yangtools.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- dependency for opendaylight-karaf-empty for use by testing -->
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>opendaylight-karaf-empty</artifactId>
+      <version>${commons.opendaylight.version}</version>
+      <type>zip</type>
+    </dependency>
+    <!-- Uncomment this if you get an error : java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>1.7.2</version>
+    </dependency>
+    -->
+
+   </dependencies>
+   <build>
+      <resources>
+         <resource>
+            <directory>src/main/resources</directory>
+            <filtering>true</filtering>
+         </resource>
+      </resources>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-resources-plugin</artifactId>
+            <executions>
+               <execution>
+                  <id>filter</id>
+                  <phase>generate-resources</phase>
+                  <goals>
+                     <goal>resources</goal>
+                  </goals>
+               </execution>
+            </executions>
+         </plugin>
+         <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>build-helper-maven-plugin</artifactId>
+            <executions>
+               <execution>
+                  <id>attach-artifacts</id>
+                  <phase>package</phase>
+                  <goals>
+                     <goal>attach-artifact</goal>
+                  </goals>
+                  <configuration>
+                     <artifacts>
+                        <artifact>
+                           <file>${project.build.directory}/classes/${features.file}</file>
+                           <type>xml</type>
+                           <classifier>features</classifier>
+                        </artifact>
+                     </artifacts>
+                  </configuration>
+               </execution>
+            </executions>
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <version>${surefire.version}</version>
+            <configuration>
+              <systemPropertyVariables>
+                <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+                <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+                <karaf.distro.version>${commons.opendaylight.version}</karaf.distro.version>
+              </systemPropertyVariables>
+              <dependenciesToScan>
+               <dependency>org.opendaylight.yangtools:features-test</dependency>
+              </dependenciesToScan>
+            </configuration>
+          </plugin>
+      </plugins>
+   </build>
+   <scm>
+      <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+      <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+      <tag>HEAD</tag>
+      <url>https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=summary</url>
+   </scm>
+</project>
diff --git a/features/restconf/src/main/resources/features.xml b/features/restconf/src/main/resources/features.xml
new file mode 100644 (file)
index 0000000..ab42330
--- /dev/null
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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
+-->
+<features name="odl-controller-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+    <!--
+        Necessary TODO: Please read the features guidelines:
+        https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Feature_Best_Practices
+    -->
+    <!--
+    Necessary TODO: Add repo entries for the repositories of features you refer to
+        in this feature file but do not define here.
+        Examples:
+            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features</repository>
+    -->
+    <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
+    <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
+    <repository>mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features</repository>
+    <feature name='odl-restconf-all' version='${project.version}' description='OpenDaylight :: Restconf :: All'>
+        <!--
+            Necessary TODO:
+            List all of the user consumable features you define in this feature file here.
+            Generally you would *not* list individual bundles here, but only features defined in *this* file.
+            It is useful to list them in the same order they occur in the file.
+
+            Examples:
+            <feature version='${project.version}'>odl-controller-provider</feature>
+            <feature version='${project.version}'>odl-controller-model</feature>
+        -->
+        <feature version='${project.version}'>odl-restconf</feature>
+        <feature version='${project.version}'>odl-mdsal-apidocs</feature>
+        <feature version='${project.version}'>odl-clustering-test-app</feature>
+    </feature>
+    <!--
+        Necessary TODO: Define your features.  It is useful to list then in order of dependency.  So if A depends on B, list A first.
+        When naming your features please be mindful of the guidelines:
+            https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines
+        Particularly:
+            a) Prefixing names with 'odl-': https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Feature_Naming
+            b) Descriptions: https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Description
+            c) Avoid start-levels: https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Avoid_start-levels
+
+        It's also nice to list inside a feature, first the features it needs, then the bundles it needs, then the configfiles.
+        Examples:
+
+        * Basic MD-SAL Provider
+        <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider '>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='${project.version}'>odl-controller-model</feature>
+            <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
+            ... whatever other bundles you need
+        </feature>
+
+        * Basic MD-SAL Model feature
+        <feature name='odl-controller-model' version='${project.version}' description='OpenDaylight :: controller :: Model'>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-binding</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-models</feature>
+            <bundle>mvn:org.opendaylight.controller/controller-model/${project.version}</bundle>
+            ... whatever other bundles you need
+        </feature>
+
+        * Config Subsystem example - the config file is your config subsystem configuration
+        <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
+            <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
+            <configfile finalname="etc/opendaylight/karaf/80-controller.xml">mvn:org.opendaylight.controller/controller-config/${project.version}/xml/config</configfile>
+            ... whatever other bundles you need
+        </feature>
+
+        * Basic MD-SAL Provider that uses openflowplugin-flow-services (which brings along odl-mdsal-broker)
+        <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
+            <feature version='0.1.0-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
+            <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
+            ... whatever other bundles you need
+        </feature>
+
+    -->
+
+    <feature name='odl-restconf' version='${project.version}' description="OpenDaylight :: Restconf">
+        <feature version='${aaa.version}'>odl-aaa-authn</feature>
+        <feature version='${mdsal.version}'>odl-restconf-noauth</feature>
+    </feature>
+    <feature name='odl-restconf-noauth' version='${project.version}' description="OpenDaylight :: Restconf">
+        <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
+        <feature>war</feature>
+        <!-- presently we need sal-remote to be listed BEFORE sal-rest-connector because sal-rest-connector
+             has a yang file which augments a yang file in sal-remote, and order seems to matter -->
+        <bundle>mvn:org.opendaylight.controller/sal-remote/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.controller/sal-rest-connector/${project.version}</bundle>
+        <bundle>mvn:com.google.code.gson/gson/${gson.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/yang-data-codec-gson/${yangtools.version}</bundle>
+        <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
+        <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
+        <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
+        <bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
+        <bundle>mvn:io.netty/netty-codec/${netty.version}</bundle>
+        <bundle>mvn:io.netty/netty-codec-http/${netty.version}</bundle>
+        <bundle>mvn:io.netty/netty-common/${netty.version}</bundle>
+        <bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
+        <bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
+        <configfile finalname="${config.configfile.directory}/${config.restconf.configfile}">mvn:org.opendaylight.controller/sal-rest-connector-config/${mdsal.version}/xml/config</configfile>
+    </feature>
+    <feature name ='odl-mdsal-apidocs' version='${project.version}' description="OpenDaylight :: MDSAL :: APIDOCS">
+        <feature version='${project.version}'>odl-restconf</feature>
+        <bundle>mvn:org.opendaylight.controller/sal-rest-docgen/${project.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.datatype/jackson-datatype-json-org/${jackson.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version}</bundle>
+        <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
+        <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
+        <bundle>mvn:com.sun.jersey/jersey-servlet/${jersey.version}</bundle>
+        <bundle>wrap:mvn:org.json/json/${org.json.version}</bundle>
+    </feature>
+
+    <feature name='odl-clustering-test-app' version='${project.version}'>
+        <feature version='${project.version}'>odl-mdsal-clustering</feature>
+        <feature version='${project.version}'>odl-restconf</feature>
+        <feature version='${yangtools.version}'>odl-yangtools-models</feature>
+        <bundle>mvn:org.opendaylight.controller.samples/clustering-it-model/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.controller.samples/clustering-it-provider/${project.version}</bundle>
+        <configfile finalname="${config.configfile.directory}/20-clustering-test-app.xml">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/config</configfile>
+        <configfile finalname="configuration/initial/module-shards.conf" override="true" >mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/testmoduleshardconf</configfile>
+        <configfile finalname="configuration/initial/modules.conf" override="true">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/testmoduleconf</configfile>
+    </feature>
+
+    <feature name='odl-toaster-rest' version='${project.version}'>
+        <feature version='${project.version}'>odl-restconf</feature>
+        <feature version='${project.version}'>odl-toaster</feature>
+    </feature>
+
+    <feature name='odl-toaster-ui' version='${project.version}'>
+        <feature version='${project.version}'>odl-mdsal-apidocs</feature>
+        <feature version='${project.version}'>odl-mdsal-xsql</feature>
+        <feature version='${project.version}'>odl-toaster-rest</feature>
+    </feature>
+    <!-- Optional TODO: Remove TODO Comments -->
+
+</features>
index 8f737790090ae3d039ed25e593b55fba97ab2e22..d05e9a515bed4c84480d83900b3b7cde42805c37 100644 (file)
@@ -3,7 +3,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>itests-controller</artifactId>
-        <version>1.4.2-SNAPSHOT</version>
+        <version>1.5.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>base-features-it</artifactId>
index 19836a2ad6cf0721503f502b5344dc8b937706a6..c7221491451582fd099844e179daa16540a09434 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <artifactId>itests-controller</artifactId>
index e74e3cb9156e4fd128b4bc97e9697fc3cbf83f32..8a035510bf5426e21cf7ce3993563cf91c5c9263 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
   <artifactId>appauth</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index d2896027fb330edc255739d740847cd7fb10b00a..4945eb2a66239ea9bcf5ddcab8bb846c3276459b 100644 (file)
@@ -4,7 +4,7 @@
 
   <groupId>org.opendaylight.controller.archetypes</groupId>
   <artifactId>odl-model-project</artifactId>
-  <version>1.1-SNAPSHOT</version>
+  <version>1.2.0-SNAPSHOT</version>
   <packaging>maven-archetype</packaging>
 
   <properties>
index 016c30d787bde6a7871f012fb40d3df7c52c85b3..6b41485e7b4d74ed476c450a9deac9f6664cd8b2 100644 (file)
@@ -11,8 +11,8 @@
     <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>\r
     <nexus.repository.release>opendaylight.release</nexus.repository.release>
     <nexus.repository.snapshot>opendaylight.release</nexus.repository.snaphot>
-    <yang.version>0.6.2-SNAPSHOT</yang.version>\r
-    <yang.codegen.version>0.6.2-SNAPSHOT</yang.codegen.version>\r
+    <yang.version>0.7.0-SNAPSHOT</yang.version>\r
+    <yang.codegen.version>0.7.0-SNAPSHOT</yang.codegen.version>\r
     <bundle.plugin.version>2.3.7</bundle.plugin.version>\r
   </properties>\r
   <scm>\r
index 56342218a0b8205555961832f60d3fca4846a809..45ec9ac717a26fca391a65bb4b2a89587e280296 100644 (file)
@@ -4,7 +4,7 @@
 
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>opendaylight-configfile-archetype</artifactId>
-  <version>1.1-SNAPSHOT</version>
+  <version>1.2.0-SNAPSHOT</version>
   <packaging>maven-archetype</packaging>
 
 
index 9081ce797b177729018e53e9a5bcd930796ab330..ff2384fb27e5c3f3c05521fcfd6dc3c1ab025190 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
      <groupId>org.opendaylight.controller.archetypes</groupId>
      <artifactId>archetypes-parent</artifactId>
-     <version>0.1.1-SNAPSHOT</version>
+     <version>0.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>opendaylight-karaf-distro-archetype</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
+  <version>1.1.0-SNAPSHOT</version>
   <packaging>maven-archetype</packaging>
 
   <name>distribution-karaf-archetype</name>
index fdc60625c85536a4c22ab52836bed884aa4e8696..c2e399b370f4ebbd41952189bb58114a802c588a 100644 (file)
@@ -19,8 +19,8 @@
   <properties>
     <!-- Optional TODO: Move these properties to your parent pom and possibly
             DependencyManagement section of your parent pom -->
-    <branding.version>1.0.0-SNAPSHOT</branding.version>
-    <karaf.resources.version>1.4.2-SNAPSHOT</karaf.resources.version>
+    <branding.version>1.1.0-SNAPSHOT</branding.version>
+    <karaf.resources.version>1.5.0-SNAPSHOT</karaf.resources.version>
     <karaf.version>3.0.1</karaf.version>
   </properties>
 
@@ -81,7 +81,7 @@
       <dependency>
         <groupId>org.opendaylight.openflowplugin</groupId>
         <artifactId>features-openflowplugin</artifactId>
-        <version>0.0.3-SNAPSHOT</version>
+        <version>0.1.0-SNAPSHOT</version>
         <classifier>features</classifier>
         <type>xml</type>
         <scope>runtime</scope>
index 264402a3b1740c892efe51569c33af9ebbd39829..12861604e86d336f6fe0a8ec92887123c18028d9 100644 (file)
@@ -5,11 +5,11 @@
   <parent>
      <groupId>org.opendaylight.controller.archetypes</groupId>
      <artifactId>archetypes-parent</artifactId>
-     <version>0.1.1-SNAPSHOT</version>
+     <version>0.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>opendaylight-karaf-features-archetype</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
+  <version>1.1.0-SNAPSHOT</version>
   <packaging>maven-archetype</packaging>
 
   <name>opendaylight-karaf-features-archetype</name>
index e135e6b656df4cff84e19c28408d76ab6a14a9ee..df35831a90709ea359982b36fb9086ed9da54f63 100644 (file)
       <features.file>features.xml</features.file>
       <!-- Optional TODO: Move these properties to your parent pom and possibly
             DependencyManagement section of your parent pom -->
-      <branding.version>1.0.0-SNAPSHOT</branding.version>
-      <karaf.resources.version>1.4.2-SNAPSHOT</karaf.resources.version>
+      <branding.version>1.1.0-SNAPSHOT</branding.version>
+      <karaf.resources.version>1.5.0-SNAPSHOT</karaf.resources.version>
       <karaf.version>3.0.1</karaf.version>
-      <feature.test.version>0.6.2-SNAPSHOT</feature.test.version>
-      <karaf.empty.version>1.4.2-SNAPSHOT</karaf.empty.version>
+      <feature.test.version>0.7.0-SNAPSHOT</feature.test.version>
+      <karaf.empty.version>1.5.0-SNAPSHOT</karaf.empty.version>
       <surefire.version>2.16</surefire.version>
    </properties>
    <dependencies>
         <dependency>
           <groupId>org.opendaylight.yangtools</groupId>
           <artifactId>features-yangtools</artifactId>
-          <version>0.6.2-SNAPSHOT</version>
+          <version>0.7.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>features-mdsal</artifactId>
-          <version>1.1-SNAPSHOT</version>
+          <version>1.2.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.openflowplugin</groupId>
           <artifactId>features-openflowplugin</artifactId>
-          <version>0.0.3-SNAPSHOT</version>
+          <version>0.1.0-SNAPSHOT</version>
           <classifier>features</classifier>
           <type>xml</type>
         </dependency>
index 4a59657431d95fa7555aeef4f18ee5e2f3451d70..54bbfe45fc54cd22844ee517113081380be78346 100644 (file)
@@ -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:
-            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.6.2-SNAPSHOT/xml/features</repository>
-            <repository>mvn:org.opendaylight.controller/features-mdsal/1.1-SNAPSHOT/xml/features</repository>
-            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.0.3-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.7.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.controller/features-mdsal/1.2.0-SNAPSHOT/xml/features</repository>
+            <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.1.0-SNAPSHOT/xml/features</repository>
     -->
     <feature name='odl-${repoName}-all' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: All'>
         <!--
@@ -51,7 +51,7 @@
 
         * Basic MD-SAL Provider
         <feature name='odl-${repoName}-provider' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Provider '>
-            <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
             <feature version='${symbol_dollar}{project.version}'>odl-${repoName}-model</feature>
             <bundle>mvn:${groupId}/${repoName}-provider/${symbol_dollar}{project.version}</bundle>
             ... whatever other bundles you need
 
         * Basic MD-SAL Model feature
         <feature name='odl-${repoName}-model' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Model'>
-            <feature version='0.6.2-SNAPSHOT'>odl-yangtools-binding</feature>
-            <feature version='0.6.2-SNAPSHOT'>odl-yangtools-models</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-binding</feature>
+            <feature version='0.7.0-SNAPSHOT'>odl-yangtools-models</feature>
             <bundle>mvn:${groupId}/${repoName}-model/${symbol_dollar}{project.version}</bundle>
             ... whatever other bundles you need
         </feature>
 
         * Config Subsystem example - the config file is your config subsystem configuration
         <feature name='odl-${repoName}-provider' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Provider'>
-            <feature version='1.1-SNAPSHOT'>odl-mdsal-broker</feature>
+            <feature version='1.2.0-SNAPSHOT'>odl-mdsal-broker</feature>
             <bundle>mvn:${groupId}/${repoName}-provider/${symbol_dollar}{project.version}</bundle>
             <configfile finalname="etc/opendaylight/karaf/80-${repoName}.xml">mvn:${groupId}/${repoName}-config/${symbol_dollar}{project.version}/xml/config</configfile>
             ... whatever other bundles you need
@@ -75,7 +75,7 @@
 
         * Basic MD-SAL Provider that uses openflowplugin-flow-services (which brings along odl-mdsal-broker)
         <feature name='odl-${repoName}-provider' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${repoName} :: Provider'>
-            <feature version='0.0.3-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
+            <feature version='0.1.0-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
             <bundle>mvn:${groupId}/${repoName}-provider/${symbol_dollar}{project.version}</bundle>
             ... whatever other bundles you need
         </feature>
index cb597c10bd09fe4375053ced97449e25a3b68dc0..33c2548091bdb5feb79b93319029b677d1606924 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
   <scm>
@@ -18,7 +18,7 @@
   </scm>
   <groupId>org.opendaylight.controller.archetypes</groupId>
   <artifactId>archetypes-parent</artifactId>
-  <version>0.1.1-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
     <distributionManagement>
     <!-- OpenDayLight Released artifact -->
index 064d04c25c1bb4143ca72470cef30337449ad670..ffd528beb0c161dfcf68c43ba5f82a9f83163e25 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
   <artifactId>arphandler</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 62c182c3b9bc1641b417830ae875044ec54e3518..fecf4f8034ac359a3b0499b3e882612102c52f44 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>clustering.services.integrationtest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <properties>
     <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <!-- Sonar jacoco plugin to get integration test coverage info -->
index 3ff6bac21f4d3e54ae4018daf46826fdd115e5b3..8c66e70cbe8bb30e93c30720bdaf46c6c99b57eb 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>clustering.services</artifactId>
-  <version>0.5.1-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index 8d3f53b6c44bfff0b4bef7d38aa89758edb90d09..f11f7a14c0631db619ea5d3f0e532e95cfc22cdc 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>clustering.services-implementation</artifactId>
-  <version>0.4.3-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <properties>
     <!-- Sonar properties using jacoco to retrieve integration test results -->
index 6a0b3082fb4e90aa98fbf23f95cf232b351e1127..211dcc29d02d32b700b2cff077f16121193a75cf 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>clustering.stub</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 9021c9419e66257da8d140ee5d895adb8e84e075..93294f229092537745bf4b45864e57ec772749b2 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>clustering.test</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 55567af43783a229118086be282c898b753f38fa..fee517f08b8c37725ffc71167afe0893e0634b23 100644 (file)
@@ -2,7 +2,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>checkstyle</artifactId>
-  <version>0.0.3-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
     <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
index 01dd61a1cb619a6115222a9759d005650e68a7d7..fa97e5fcac45668c3d727a2328a878a8a1111415 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>concepts</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
@@ -43,7 +43,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>checkstyle</artifactId>
-            <version>0.0.3-SNAPSHOT</version>
+            <version>0.1.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>
index 7b5be02514215002ffe6e89ab4fdbf5945392815..012b4a2529b49fcd365f7251dfd053f48dc73d65 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../opendaylight</relativePath>
   </parent>
   <artifactId>filter-valve</artifactId>
index 07d3cdda96a00c24316b1939b37f27985576b6b1..39364cbcbaee86d2fdf238b1825c5092d79beafa 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>commons.httpclient</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
@@ -71,7 +71,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>checkstyle</artifactId>
-            <version>0.0.3-SNAPSHOT</version>
+            <version>0.1.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>
index 315611f647c8f9c6ff890a0a23925ea55bd71307..ad4e166cbd492fbd2279a8fe3e4fa10545ac7e2e 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>commons.integrationtest</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <dependencies>
@@ -89,7 +89,7 @@
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>checkstyle</artifactId>
-            <version>0.0.3-SNAPSHOT</version>
+            <version>0.1.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
       </plugin>
index 1551041edbd28417e87f4c231ada388a9c3ca4c6..148a4f3792a70eb77028b0af1f8c82c3af8cf6cb 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../opendaylight</relativePath>
   </parent>
 
   <artifactId>liblldp</artifactId>
-  <version>0.8.1-SNAPSHOT</version>
+  <version>0.9.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 11a7ffbd0e7a151bb4e1cc95cb7c193d89d12147..f98b7a3a7ae645915834fa9662885d65578f48b7 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.parent</artifactId>
-    <version>1.0.2-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <relativePath>../parent</relativePath>
   </parent>
   <artifactId>commons.logback_settings</artifactId>
-  <version>0.0.2-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
     <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
index a98afc8d19cd78597f978f370dfbb9e3cdd48054..77fad0a9f75ba76ab57863e7dcb3f7fa43b3e0bb 100644 (file)
@@ -4,13 +4,13 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath></relativePath>
   </parent>
 
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>commons.opendaylight</artifactId>
-  <version>1.4.2-SNAPSHOT</version>
+  <version>1.5.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <prerequisites>
     <maven>3.0</maven>
 
     <akka.version>2.3.4</akka.version>
     <aopalliance.version>1.0.0</aopalliance.version>
-    <appauth.version>0.4.2-SNAPSHOT</appauth.version>
-    <archetype-app-northbound>0.0.1-SNAPSHOT</archetype-app-northbound>
+    <appauth.version>0.5.0-SNAPSHOT</appauth.version>
+    <archetype-app-northbound>0.1.0-SNAPSHOT</archetype-app-northbound>
     <aries.util.version>1.1.0</aries.util.version>
-    <arphandler.version>0.5.2-SNAPSHOT</arphandler.version>
+    <arphandler.version>0.6.0-SNAPSHOT</arphandler.version>
     <!-- Controller Modules Versions -->
     <asm.version>4.1</asm.version>
     <!-- Plugin Versions -->
     <bouncycastle.version>1.50</bouncycastle.version>
     <bundle.plugin.version>2.4.0</bundle.plugin.version>
-    <bundlescanner.api.version>0.4.2-SNAPSHOT</bundlescanner.api.version>
-    <bundlescanner.implementation.version>0.4.2-SNAPSHOT</bundlescanner.implementation.version>
-    <bundlescanner.version>0.4.2-SNAPSHOT</bundlescanner.version>
+    <bundlescanner.api.version>0.5.0-SNAPSHOT</bundlescanner.api.version>
+    <bundlescanner.implementation.version>0.5.0-SNAPSHOT</bundlescanner.implementation.version>
+    <bundlescanner.version>0.5.0-SNAPSHOT</bundlescanner.version>
     <checkstyle.version>2.12</checkstyle.version>
-    <clustering.services.version>0.5.1-SNAPSHOT</clustering.services.version>
-    <clustering.services_implementation.version>0.4.3-SNAPSHOT</clustering.services_implementation.version>
-    <clustering.stub.version>0.4.2-SNAPSHOT</clustering.stub.version>
-    <clustering.test.version>0.4.2-SNAPSHOT</clustering.test.version>
-    <commmons.northbound.version>0.4.2-SNAPSHOT</commmons.northbound.version>
+    <clustering.services.version>0.6.0-SNAPSHOT</clustering.services.version>
+    <clustering.services_implementation.version>0.5.0-SNAPSHOT</clustering.services_implementation.version>
+    <clustering.stub.version>0.5.0-SNAPSHOT</clustering.stub.version>
+    <clustering.test.version>0.5.0-SNAPSHOT</clustering.test.version>
+    <commmons.northbound.version>0.5.0-SNAPSHOT</commmons.northbound.version>
     <!-- Third Party Versions -->
     <codahale.metrics.version>3.0.1</codahale.metrics.version>
 
     <commons.tomcat.api>7.0.53.v201406060720</commons.tomcat.api>
     <commons.tomcat.util>7.0.53.v201406070630</commons.tomcat.util>
 
-    <commons.checkstyle.version>0.0.3-SNAPSHOT</commons.checkstyle.version>
+    <commons.checkstyle.version>0.1.0-SNAPSHOT</commons.checkstyle.version>
     <commons.fileupload.version>1.2.2</commons.fileupload.version>
-    <commons.httpclient.version>0.1.2-SNAPSHOT</commons.httpclient.version>
+    <commons.httpclient.version>0.2.0-SNAPSHOT</commons.httpclient.version>
     <commons.io.version>2.4</commons.io.version>
     <commons.lang3.version>3.1</commons.lang3.version>
-    <commons.logback_settings.version>0.0.2-SNAPSHOT</commons.logback_settings.version>
+    <commons.logback_settings.version>0.1.0-SNAPSHOT</commons.logback_settings.version>
     <commons.net.version>3.0.1</commons.net.version>
-    <commons.opendaylight.commons.httpclient>0.1.2-SNAPSHOT</commons.opendaylight.commons.httpclient>
-    <commons.opendaylight.concepts.version>0.5.2-SNAPSHOT</commons.opendaylight.concepts.version>
-    <commons.opendaylight.version>1.4.2-SNAPSHOT</commons.opendaylight.version>
-    <commons.parent.version>1.0.2-SNAPSHOT</commons.parent.version>
+    <commons.opendaylight.commons.httpclient>0.2.0-SNAPSHOT</commons.opendaylight.commons.httpclient>
+    <commons.opendaylight.concepts.version>0.6.0-SNAPSHOT</commons.opendaylight.concepts.version>
+    <commons.opendaylight.version>1.5.0-SNAPSHOT</commons.opendaylight.version>
+    <commons.parent.version>1.1.0-SNAPSHOT</commons.parent.version>
     <compiler.version>2.3.2</compiler.version>
-    <commons.httpclient.version>0.1.2-SNAPSHOT</commons.httpclient.version>
-    <concepts.version>0.5.2-SNAPSHOT</concepts.version>
+    <commons.httpclient.version>0.2.0-SNAPSHOT</commons.httpclient.version>
+    <concepts.version>0.6.0-SNAPSHOT</concepts.version>
     <concurrentlinkedhashmap.version>1.4</concurrentlinkedhashmap.version>
-    <config.version>0.2.5-SNAPSHOT</config.version>
-    <aaa.version>0.1.0-SNAPSHOT</aaa.version>
+    <config.version>0.3.0-SNAPSHOT</config.version>
+    <aaa.version>0.2.0-SNAPSHOT</aaa.version>
     <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
     <config.clustering.configfile>05-clustering.xml</config.clustering.configfile>
     <config.netty.configfile>00-netty.xml</config.netty.configfile>
     <config.toaster.configfile>03-toaster-sample.xml</config.toaster.configfile>
     <config.restconf.configfile>10-rest-connector.xml</config.restconf.configfile>
     <config.netconf.connector.configfile>99-netconf-connector.xml</config.netconf.connector.configfile>
-    <configuration.implementation.version>0.4.3-SNAPSHOT</configuration.implementation.version>
-    <configuration.version>0.4.3-SNAPSHOT</configuration.version>
-    <connectionmanager.version>0.1.2-SNAPSHOT</connectionmanager.version>
-    <containermanager.it.version>0.5.2-SNAPSHOT</containermanager.it.version>
-    <containermanager.northbound.version>0.4.2-SNAPSHOT</containermanager.northbound.version>
-    <containermanager.shell.version>0.5.2-SNAPSHOT</containermanager.shell.version>
-    <containermanager.version>0.5.2-SNAPSHOT</containermanager.version>
-    <controllermanager.northbound.version>0.0.2-SNAPSHOT</controllermanager.northbound.version>
-    <devices.web.version>0.4.2-SNAPSHOT</devices.web.version>
-    <dummy-console.version>1.1.0-SNAPSHOT</dummy-console.version>
+    <configuration.implementation.version>0.5.0-SNAPSHOT</configuration.implementation.version>
+    <configuration.version>0.5.0-SNAPSHOT</configuration.version>
+    <connectionmanager.version>0.2.0-SNAPSHOT</connectionmanager.version>
+    <containermanager.it.version>0.6.0-SNAPSHOT</containermanager.it.version>
+    <containermanager.northbound.version>0.5.0-SNAPSHOT</containermanager.northbound.version>
+    <containermanager.shell.version>0.6.0-SNAPSHOT</containermanager.shell.version>
+    <containermanager.version>0.6.0-SNAPSHOT</containermanager.version>
+    <controllermanager.northbound.version>0.1.0-SNAPSHOT</controllermanager.northbound.version>
+    <devices.web.version>0.5.0-SNAPSHOT</devices.web.version>
+    <dummy-console.version>1.2.0-SNAPSHOT</dummy-console.version>
     <eclipse.persistence.version>2.5.0</eclipse.persistence.version>
     <eclipse.jdt.core.compiler.batch.version>3.8.0.I20120518-2145</eclipse.jdt.core.compiler.batch.version>
     <!-- enforcer version -->
 
     <exi.nagasena.version>0000.0002.0038.0</exi.nagasena.version>
     <felix.util.version>1.6.0</felix.util.version>
-    <filtervalve.version>1.4.2-SNAPSHOT</filtervalve.version>
+    <filtervalve.version>1.5.0-SNAPSHOT</filtervalve.version>
     <findbugs.maven.plugin.version>2.4.0</findbugs.maven.plugin.version>
-    <flowprogrammer.northbound.version>0.4.2-SNAPSHOT</flowprogrammer.northbound.version>
-    <flows.web.version>0.4.2-SNAPSHOT</flows.web.version>
-    <forwarding.staticrouting>0.5.2-SNAPSHOT</forwarding.staticrouting>
-    <forwarding.staticrouting.northbound.version>0.4.2-SNAPSHOT</forwarding.staticrouting.northbound.version>
-    <forwardingrulesmanager.implementation.version>0.4.2-SNAPSHOT</forwardingrulesmanager.implementation.version>
-    <forwardingrulesmanager.version>0.6.0-SNAPSHOT</forwardingrulesmanager.version>
-    <ganymed.version>1.1-SNAPSHOT</ganymed.version>
-    <hosttracker.api.version>0.5.2-SNAPSHOT</hosttracker.api.version>
-    <hosttracker.implementation.version>0.5.2-SNAPSHOT</hosttracker.implementation.version>
-    <hosttracker.northbound.version>0.4.2-SNAPSHOT</hosttracker.northbound.version>
-    <hosttracker.shell.version>1.0.0-SNAPSHOT</hosttracker.shell.version>
-    <hosttracker_new.api.version>0.4.2-SNAPSHOT</hosttracker_new.api.version>
-    <hosttracker_new.implementation.version>0.4.2-SNAPSHOT</hosttracker_new.implementation.version>
-    <httpservice-bridge.northbound.version>0.0.2-SNAPSHOT</httpservice-bridge.northbound.version>
-    <ietf-inet-types.version>2010.09.24.4-SNAPSHOT</ietf-inet-types.version>
-    <ietf-restconf.version>2013.10.19.1-SNAPSHOT</ietf-restconf.version>
-    <ietf-topology.version>2013.10.21.2-SNAPSHOT</ietf-topology.version>
-    <ietf-yang-types.version>2010.09.24.4-SNAPSHOT</ietf-yang-types.version>
+    <flowprogrammer.northbound.version>0.5.0-SNAPSHOT</flowprogrammer.northbound.version>
+    <flows.web.version>0.5.0-SNAPSHOT</flows.web.version>
+    <forwarding.staticrouting>0.6.0-SNAPSHOT</forwarding.staticrouting>
+    <forwarding.staticrouting.northbound.version>0.5.0-SNAPSHOT</forwarding.staticrouting.northbound.version>
+    <forwardingrulesmanager.implementation.version>0.5.0-SNAPSHOT</forwardingrulesmanager.implementation.version>
+    <forwardingrulesmanager.version>0.7.0-SNAPSHOT</forwardingrulesmanager.version>
+    <ganymed.version>1.2.0-SNAPSHOT</ganymed.version>
+    <hosttracker.api.version>0.6.0-SNAPSHOT</hosttracker.api.version>
+    <hosttracker.implementation.version>0.6.0-SNAPSHOT</hosttracker.implementation.version>
+    <hosttracker.northbound.version>0.5.0-SNAPSHOT</hosttracker.northbound.version>
+    <hosttracker.shell.version>1.1.0-SNAPSHOT</hosttracker.shell.version>
+    <hosttracker_new.api.version>0.5.0-SNAPSHOT</hosttracker_new.api.version>
+    <hosttracker_new.implementation.version>0.5.0-SNAPSHOT</hosttracker_new.implementation.version>
+    <httpservice-bridge.northbound.version>0.1.0-SNAPSHOT</httpservice-bridge.northbound.version>
+    <ietf-inet-types.version>2010.09.24.7-SNAPSHOT</ietf-inet-types.version>
+    <ietf-restconf.version>2013.10.19.7-SNAPSHOT</ietf-restconf.version>
+    <ietf-topology.version>2013.10.21.7-SNAPSHOT</ietf-topology.version>
+    <ietf-yang-types.version>2010.09.24.7-SNAPSHOT</ietf-yang-types.version>
     <jdepend.maven.plugin.version>2.0-beta-2</jdepend.maven.plugin.version>
     <jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>
-    <jolokia-bridge.version>0.0.2-SNAPSHOT</jolokia-bridge.version>
+    <jolokia-bridge.version>0.1.0-SNAPSHOT</jolokia-bridge.version>
     <jolokia.version>1.1.4</jolokia.version>
     <jsr305.api.version>2.0.1</jsr305.api.version>
     <jsr311.api.version>1.1.1</jsr311.api.version>
     <jsr311.v2.api.version>2.0</jsr311.v2.api.version>
-    <karaf.branding.version>1.0.0-SNAPSHOT</karaf.branding.version>
+    <karaf.branding.version>1.1.0-SNAPSHOT</karaf.branding.version>
     <karaf.shell.version>3.0.0</karaf.shell.version>
     <karaf.version>3.0.1</karaf.version>
     <leveldb.version>0.7</leveldb.version>
     <leveldbjni.version>1.8</leveldbjni.version>
     <lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
     <logback.version>1.0.9</logback.version>
-    <logging.bridge.version>0.4.2-SNAPSHOT</logging.bridge.version>
+    <logging.bridge.version>0.5.0-SNAPSHOT</logging.bridge.version>
     <maven.plugin.api.version>3.0.5</maven.plugin.api.version>
     <mimepull.version>1.9.4</mimepull.version>
-    <mdsal.version>1.1-SNAPSHOT</mdsal.version>
-    <netconf.version>0.2.5-SNAPSHOT</netconf.version>
-    <networkconfig.bridgedomain.northbound.version>0.0.3-SNAPSHOT</networkconfig.bridgedomain.northbound.version>
-    <networkconfig.neutron.implementation.version>0.4.2-SNAPSHOT</networkconfig.neutron.implementation.version>
-    <networkconfig.neutron.northbound.version>0.4.2-SNAPSHOT</networkconfig.neutron.northbound.version>
-    <networkconfig.neutron.version>0.4.2-SNAPSHOT</networkconfig.neutron.version>
+    <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+    <netconf.version>0.3.0-SNAPSHOT</netconf.version>
+    <networkconfig.bridgedomain.northbound.version>0.1.0-SNAPSHOT</networkconfig.bridgedomain.northbound.version>
+    <networkconfig.neutron.implementation.version>0.5.0-SNAPSHOT</networkconfig.neutron.implementation.version>
+    <networkconfig.neutron.northbound.version>0.5.0-SNAPSHOT</networkconfig.neutron.northbound.version>
+    <networkconfig.neutron.version>0.5.0-SNAPSHOT</networkconfig.neutron.version>
     <!-- ODL repository / plugin repository -->
     <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
-    <northbound.commons.version>0.4.2-SNAPSHOT</northbound.commons.version>
-    <northbound.hosttracker.version>1.4.2-SNAPSHOT</northbound.hosttracker.version>
-    <northbound.jolokia.version>1.4.2-SNAPSHOT</northbound.jolokia.version>
-    <opendaylight-l2-types.version>2013.08.27.4-SNAPSHOT</opendaylight-l2-types.version>
-    <osgi-brandfragment.web.version>0.0.2-SNAPSHOT</osgi-brandfragment.web.version>
+    <northbound.commons.version>0.5.0-SNAPSHOT</northbound.commons.version>
+    <northbound.hosttracker.version>1.5.0-SNAPSHOT</northbound.hosttracker.version>
+    <northbound.jolokia.version>1.5.0-SNAPSHOT</northbound.jolokia.version>
+    <opendaylight-l2-types.version>2013.08.27.7-SNAPSHOT</opendaylight-l2-types.version>
+    <osgi-brandfragment.web.version>0.1.0-SNAPSHOT</osgi-brandfragment.web.version>
     <pax.exam.version>4.0.0</pax.exam.version>
     <parboiled.version>1.1.6</parboiled.version>
     <parboiled.scala.version>1.1.6</parboiled.scala.version>
     <propertymavenplugin.version>1.0-alpha-2</propertymavenplugin.version>
     <protobuf.version>2.5.0</protobuf.version>
-    <protocol-framework.version>0.5.0-SNAPSHOT</protocol-framework.version>
-    <protocol_plugins.openflow.version>0.4.2-SNAPSHOT</protocol_plugins.openflow.version>
-    <protocol_plugins.stub.version>0.4.2-SNAPSHOT</protocol_plugins.stub.version>
-    <routing.dijkstra_implementation.version>0.4.2-SNAPSHOT</routing.dijkstra_implementation.version>
-    <sal.connection.version>0.1.2-SNAPSHOT</sal.connection.version>
-    <sal.implementation.version>0.4.2-SNAPSHOT</sal.implementation.version>
-    <sal.networkconfiguration.version>0.0.3-SNAPSHOT</sal.networkconfiguration.version>
-    <sal.version>0.8.1-SNAPSHOT</sal.version>
+    <protocol-framework.version>0.6.0-SNAPSHOT</protocol-framework.version>
+    <protocol_plugins.openflow.version>0.5.0-SNAPSHOT</protocol_plugins.openflow.version>
+    <protocol_plugins.stub.version>0.5.0-SNAPSHOT</protocol_plugins.stub.version>
+    <routing.dijkstra_implementation.version>0.5.0-SNAPSHOT</routing.dijkstra_implementation.version>
+    <sal.connection.version>0.2.0-SNAPSHOT</sal.connection.version>
+    <sal.implementation.version>0.5.0-SNAPSHOT</sal.implementation.version>
+    <sal.networkconfiguration.version>0.1.0-SNAPSHOT</sal.networkconfiguration.version>
+    <sal.version>0.9.0-SNAPSHOT</sal.version>
     <salGeneratorPath>src/main/yang-gen-sal</salGeneratorPath>
-    <samples.loadbalancer>0.5.2-SNAPSHOT</samples.loadbalancer>
-    <samples.loadbalancer.northbound.version>0.4.2-SNAPSHOT</samples.loadbalancer.northbound.version>
-    <samples.simpleforwarding.version>0.4.2-SNAPSHOT</samples.simpleforwarding.version>
-    <sanitytest.version>0.4.2-SNAPSHOT</sanitytest.version>
+    <samples.loadbalancer>0.6.0-SNAPSHOT</samples.loadbalancer>
+    <samples.loadbalancer.northbound.version>0.5.0-SNAPSHOT</samples.loadbalancer.northbound.version>
+    <samples.simpleforwarding.version>0.5.0-SNAPSHOT</samples.simpleforwarding.version>
+    <sanitytest.version>0.5.0-SNAPSHOT</sanitytest.version>
     <scala.version>2.10</scala.version>
     <scala.micro.version>4</scala.micro.version>
-    <security.version>0.4.2-SNAPSHOT</security.version>
-    <karaf.security.version>0.4.2-SNAPSHOT</karaf.security.version>
+    <security.version>0.5.0-SNAPSHOT</security.version>
+    <karaf.security.version>0.5.0-SNAPSHOT</karaf.security.version>
     <shapeless.version>1.2.4</shapeless.version>
     <sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>
     <sonar.branch>${user.name}-private-view</sonar.branch>
     <spring-security-karaf.version>3.1.4.RELEASE</spring-security-karaf.version>
     <spring-security.version>3.1.3.RELEASE</spring-security.version>
     <spring.version>3.1.3.RELEASE</spring.version>
-    <statistics.northbound.version>0.4.2-SNAPSHOT</statistics.northbound.version>
-    <statisticsmanager.implementation.version>0.4.2-SNAPSHOT</statisticsmanager.implementation.version>
-    <statisticsmanager.version>0.5.1-SNAPSHOT</statisticsmanager.version>
-    <subnets.northbound.version>0.4.2-SNAPSHOT</subnets.northbound.version>
+    <statistics.northbound.version>0.5.0-SNAPSHOT</statistics.northbound.version>
+    <statisticsmanager.implementation.version>0.5.0-SNAPSHOT</statisticsmanager.implementation.version>
+    <statisticsmanager.version>0.6.0-SNAPSHOT</statisticsmanager.version>
+    <subnets.northbound.version>0.5.0-SNAPSHOT</subnets.northbound.version>
     <surefire.version>2.15</surefire.version>
-    <switchmanager.api.version>0.7.1-SNAPSHOT</switchmanager.api.version>
-    <switchmanager.implementation.version>0.4.2-SNAPSHOT</switchmanager.implementation.version>
-    <switchmanager.northbound.version>0.4.2-SNAPSHOT</switchmanager.northbound.version>
+    <switchmanager.api.version>0.8.0-SNAPSHOT</switchmanager.api.version>
+    <switchmanager.implementation.version>0.5.0-SNAPSHOT</switchmanager.implementation.version>
+    <switchmanager.northbound.version>0.5.0-SNAPSHOT</switchmanager.northbound.version>
     <testvm.argLine>-Xmx1024m -XX:MaxPermSize=256m</testvm.argLine>
-    <topology.northbound.version>0.4.2-SNAPSHOT</topology.northbound.version>
-    <topology.web.version>0.4.2-SNAPSHOT</topology.web.version>
-    <topologymanager.version>0.4.2-SNAPSHOT</topologymanager.version>
-    <topologymanager.shell.version>1.0.0-SNAPSHOT</topologymanager.shell.version>
-    <troubleshoot.web.version>0.4.2-SNAPSHOT</troubleshoot.web.version>
+    <topology.northbound.version>0.5.0-SNAPSHOT</topology.northbound.version>
+    <topology.web.version>0.5.0-SNAPSHOT</topology.web.version>
+    <topologymanager.version>0.5.0-SNAPSHOT</topologymanager.version>
+    <topologymanager.shell.version>1.1.0-SNAPSHOT</topologymanager.shell.version>
+    <troubleshoot.web.version>0.5.0-SNAPSHOT</troubleshoot.web.version>
     <typesafe.config.version>1.2.0</typesafe.config.version>
     <uncommons.maths.version>1.2.2a</uncommons.maths.version>
-    <usermanager.implementation.version>0.4.2-SNAPSHOT</usermanager.implementation.version>
-    <usermanager.northbound.version>0.0.2-SNAPSHOT</usermanager.northbound.version>
-    <usermanager.version>0.4.2-SNAPSHOT</usermanager.version>
-    <nsf.version>0.4.2-SNAPSHOT</nsf.version>
-    <web.version>0.4.2-SNAPSHOT</web.version>
+    <usermanager.implementation.version>0.5.0-SNAPSHOT</usermanager.implementation.version>
+    <usermanager.northbound.version>0.1.0-SNAPSHOT</usermanager.northbound.version>
+    <usermanager.version>0.5.0-SNAPSHOT</usermanager.version>
+    <nsf.version>0.5.0-SNAPSHOT</nsf.version>
+    <web.version>0.5.0-SNAPSHOT</web.version>
     <xtend.dstdir>src/main/xtend-gen</xtend.dstdir>
-    <yang-ext.version>2013.09.07.4-SNAPSHOT</yang-ext.version>
-    <yang-jmx-generator.version>1.0.0-SNAPSHOT</yang-jmx-generator.version>
-    <yangtools.version>0.6.2-SNAPSHOT</yangtools.version>
+    <yang-ext.version>2013.09.07.7-SNAPSHOT</yang-ext.version>
+    <yang-jmx-generator.version>1.1.0-SNAPSHOT</yang-jmx-generator.version>
+    <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
     <sshd-core.version>0.12.0</sshd-core.version>
     <jmh.version>0.9.7</jmh.version>
   </properties>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>httpservice-bridge</artifactId>
-        <version>0.0.2-SNAPSHOT</version>
+        <version>0.1.0-SNAPSHOT</version>
       </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>jolokia-bridge</artifactId>
-        <version>0.0.2-SNAPSHOT</version>
+        <version>0.1.0-SNAPSHOT</version>
       </dependency>
       <!-- Karaf Dependencies -->
       <dependency>
       <dependency>
         <groupId>org.opendaylight.yangtools.model</groupId>
         <artifactId>ietf-yang-types-20130715</artifactId>
-        <version>2013.07.15.1-SNAPSHOT</version>
+        <version>2013.07.15.7-SNAPSHOT</version>
       </dependency>
       <dependency>
         <groupId>org.opendaylight.yangtools.model</groupId>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>commons.logback_settings</artifactId>
-        <version>0.0.2-SNAPSHOT</version>
+        <version>0.1.0-SNAPSHOT</version>
         <scope>test</scope>
       </dependency>
       <dependency>
             <dependency>
               <groupId>org.opendaylight.controller</groupId>
               <artifactId>commons.logback_settings</artifactId>
-              <version>0.0.2-SNAPSHOT</version>
+              <version>0.1.0-SNAPSHOT</version>
             </dependency>
           </dependencies>
           <executions>
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>checkstyle</artifactId>
-            <version>0.0.3-SNAPSHOT</version>
+            <version>0.1.0-SNAPSHOT</version>
           </dependency>
         </dependencies>
         <executions>
index 67d1cb419bf1c930f50c11052762ddd95cb04e42..cbd6efaef8b287229126ecd502d0f1a029ca96d6 100644 (file)
@@ -3,7 +3,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>commons.parent</artifactId>
-  <version>1.0.2-SNAPSHOT</version>
+  <version>1.1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <prerequisites>
     <maven>3.0</maven>
index 774bc7c23f178b30f26b94d65212a595d5941b4a..00f7b3179b2a0b469eba396689f2838ec1149b19 100644 (file)
@@ -6,12 +6,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>protocol-framework</artifactId>
-  <version>0.5.0-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <name>${project.artifactId}</name>
   <description>Common protocol framework</description>
index cbe923524516077497f806fdad9b74c4d84e9927..2ecd267b9f47b195b406b4ed0d8c8fd3b068937a 100644 (file)
@@ -46,7 +46,7 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
         promise.setSuccess(session);
     }
 
-    protected final void negotiationFailed(final Throwable cause) {
+    protected void negotiationFailed(final Throwable cause) {
         LOG.debug("Negotiation on channel {} failed", channel, cause);
         channel.close();
         promise.setFailure(cause);
index e145bd2db0de394d64492e64aeeeea5ce432bd8f..eff635c17e9f2d80c502b326ef285c8688e85bfe 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>config-api</artifactId>
index a0a4292adf406a597fa120cdbf869c5b4cc0e0c6..5d6c11fbeead51a0652ce151265ca3e50313f7d0 100644 (file)
@@ -122,7 +122,9 @@ module config {
                  the actual service-type which is actually required.";
 
             mandatory true;
-            type service-type-ref;
+            type leafref {
+                path "/config:services/config:service/config:type";
+            }
         }
 
         leaf name {
index c98a47660ee3c92a8ebec0ea586d40af31dca99d..3ebffc65a298444e732c78e571701746ceb919b3 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>config-manager</artifactId>
index 57d18e2f62ef5a1a51d105eac0045e29955febe0..3e9162eb36b721046876c680ca5542ae83212087 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>config-module-archetype</artifactId>
index 8dc31dcc4ebc07f30c026288c18799790daf979e..257c36779c9113a05dfe9fd20f82c8ddc288e84c 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>config-netty-config</artifactId>
   <description>Configuration files for sal-rest-connector</description>
index 2899acf5df45d915d856e66507357514a7809429..f83beb0c8b4463cdd2a24427753e53e811c5426a 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>config-persister-api</artifactId>
index 0cbc0a1db918de95e9a1c3c666bc2d5745527496..302b13fdf933bacb5e3c77a021517046ed0fe4cc 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>config-persister-directory-xml-adapter</artifactId>
index 7412a51425d8a8d7159e34952627d593bd1fe782..d7d7889bf920f0261f8ecd24ac9ec86b14ba79bb 100644 (file)
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>config-subsystem</artifactId>
-        <version>0.2.5-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index f5f1b856acac1647f00da03c194d0925e246d3e4..b8f18960d109f60d5d33e3683035784387ee0a86 100644 (file)
@@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
 
 public class ConfigFeaturesListener implements  FeaturesListener,  AutoCloseable {
     private static final Logger logger = LoggerFactory.getLogger(ConfigFeaturesListener.class);
-    private static final int QUEUE_SIZE = 100;
+    private static final int QUEUE_SIZE = 1000;
     private BlockingQueue<FeatureEvent> queue = new LinkedBlockingQueue<FeatureEvent>(QUEUE_SIZE);
     Thread pushingThread = null;
 
index 1c094ad2dcea5b4def01253d4e6507a1b60a61f1..17099f9d3355d948c877538bc76b0f1f8f21285e 100644 (file)
@@ -26,6 +26,8 @@ import com.google.common.collect.LinkedHashMultimap;
  */
 public class FeatureConfigPusher {
     private static final Logger logger = LoggerFactory.getLogger(FeatureConfigPusher.class);
+    private static final int MAX_RETRIES=100;
+    private static final int RETRY_PAUSE_MILLIS=1;
     private FeaturesService featuresService = null;
     private ConfigPusher pusher = null;
     /*
@@ -82,8 +84,30 @@ public class FeatureConfigPusher {
     }
 
     private boolean isInstalled(Feature feature) {
-        List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
-        return installedFeatures.contains(feature);
+        for(int retries=0;retries<MAX_RETRIES;retries++) {
+            try {
+                List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
+                if(installedFeatures.contains(feature)) {
+                    return true;
+                } else {
+                    logger.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion());
+                }
+            } catch (Exception e) {
+                if(retries < MAX_RETRIES) {
+                    logger.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e);
+                } else {
+                    logger.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e);
+                    throw e;
+                }
+            }
+            try {
+                Thread.sleep(RETRY_PAUSE_MILLIS);
+            } catch (InterruptedException e1) {
+                throw new IllegalStateException(e1);
+            }
+        }
+        logger.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",MAX_RETRIES,feature.getName(),feature.getVersion());
+        return false;
     }
 
     private LinkedHashSet<FeatureConfigSnapshotHolder> pushConfig(LinkedHashSet<FeatureConfigSnapshotHolder> configs) throws InterruptedException {
index d8c81ea971322762511ab4379e068b6112e6eb8c..35df9e1999a497adb7a2f6053c6e903a76df4c65 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>config-persister-file-xml-adapter</artifactId>
index e66a4cfd3fe06b3767d76fdcf5c7952507611753..67370e1e2f345b9a6b20fc72625234a202fd7b50 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
   <artifactId>config-plugin-parent</artifactId>
index 29a5526451f688e3409969f8cb85b041d7496f0a..6a5950dc7e7bc5afef3bd0e257b5a564e7aa9b90 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>config-util</artifactId>
index 03ff65f662cdb94a41071bcff964316e1a31d6f1..0f379fbe21808b351a3f37fd20ea6d578474f9bb 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>logback-config-loader</artifactId>
index 0fd62aa42764e2736b33b7273ab4d04cd8ddfa97..d918fd7ab7ad383796002509d506f8d3e353820a 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>logback-config</artifactId>
index 1e5fcce6093bec286d4fce3e5e40ea3efc4b8834..0e0ec9372c760c7b138f0209747ba9c124a714ab 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
 
index ca1e28e14c5b040c803a5b82d4e23ba3c9955b2d..a5c0831fb82aa16ca7bdb8175a709b7690f8c110 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>netty-config-api</artifactId>
index b001dc76f74677758762cd2fc97b55e770ae33af..6188aed898be9ade5430e01635b01291c6779072 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>netty-event-executor-config</artifactId>
index 8c86ca83547be5946d96aa90e8391b43982f85e0..2f3d26dd2fe3a7379b1fb60422689229a3444c61 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>netty-threadgroup-config</artifactId>
index 6b3ecdbceb1f3360ff26bf28d1e9ba1fc9992249..75b4709da26349014ef4f83923bbcb909a2c8fb5 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>netty-timer-config</artifactId>
index b8ad26116a2915634be51f430d8d5769ce2e949b..ea7b24317932b308bf101df8736a8c514bc16418 100644 (file)
@@ -5,12 +5,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
   <artifactId>config-subsystem</artifactId>
 
-  <version>0.2.5-SNAPSHOT</version>
+  <version>0.3.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>${project.artifactId}</name>
   <prerequisites>
             <configuration>
               <outputDirectory>${project.build.directory}/jacoco</outputDirectory>
               <haltOnFailure>false</haltOnFailure>
-              <check>
-                <classRatio>80</classRatio>
-              </check>
+              <rules>
+                <rule>
+                  <element>CLASS</element>
+                  <excludes>
+                    <exclude>*Test</exclude>
+                  </excludes>
+                  <limits>
+                    <limit>
+                      <counter>LINE</counter>
+                      <value>COVEREDRATIO</value>
+                      <minimum>0.50</minimum>
+                    </limit>
+                  </limits>
+                </rule>
+              </rules>
             </configuration>
           </execution>
         </executions>
index 76c1cfdc542e33c084ffe1cc715bb9c35b1a5fb6..659052e570898f70b2497eef4dfd236c9d666305 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>shutdown-api</artifactId>
index 9895022df6931ee57cc75f82a51984929e3581a3..f14c28532314f71ce7450437e5e338a9e2a52975 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>shutdown-impl</artifactId>
index c9a19515ef043c9dd10e17a31ee4b5dbadfa1014..5f0c941a19a7ed44ba89d792a9eb69ea0c1c68e9 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>threadpool-config-api</artifactId>
index 4fd0d681a11e49f5cf5038afaa6bd6c7a3c8c4de..2787b30df442d98ea0d2ae91aea4ab6eaada34fe 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>threadpool-config-impl</artifactId>
index f9e0c7036a858b60246a7956a8bdc6fc7ba18d44..6d2663ced5b6f56b72e38e2e14ea546ef270e7cc 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>yang-jmx-generator-it</artifactId>
index 5f51980b94b530e3dbdb7e6e87059088c425b61b..6c8a591bb8a7a7db03fb1564c3d7f93c66595995 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>yang-jmx-generator-plugin</artifactId>
index 133b07ff8661f5ce4e8851e7e6de378f4c8740c2..979b39688b04aac10514db6e0b796bfd97b139e4 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
 
index 9032a2c9306ca38f537028984f05812ca24f6e2a..cac0ac705f216cc0838e86d841b9d2e25bc2f769 100644 (file)
@@ -19,6 +19,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
@@ -40,6 +41,7 @@ public class ModuleMXBeanEntryNameConflictTest extends AbstractYangTest {
     Map<File, String> testedFilesToYangModules = new HashMap<>();
     Map<String, String> testedYangModulesToExpectedConflictingName = new HashMap<>();
 
+    @Ignore
     @Test
     public void testNameConflicts() throws Exception {
         prepareSamples();
index 16085efbba2cf334692498f37d6f872ba5d51c0e..0cd0d15ad242044a1cd131e12d83f17aedf4466a 100644 (file)
@@ -49,7 +49,7 @@ module config-jmx-it-impl {
             }
 
 
-            leaf simpleInt {
+            leaf simpleInt1 {
                 type uint32;
                 default 99L;
             }
@@ -87,7 +87,7 @@ module config-jmx-it-impl {
                 }
             }
 
-            leaf simpleInt {
+            leaf simpleInt2 {
                 type uint32;
             }
 
@@ -202,7 +202,7 @@ module config-jmx-it-impl {
         case impl-netconf {
             when "/config:modules/config:module/config:type = 'impl-netconf'";
             // root runtime bean
-            leaf created-sessions {
+            leaf created-sessions-1 {
                 type uint32;
             }
 
index 4901b41157226b8daa468b775d627808b2fced1c..97fca0387792e355b51d0963a2500d5e295e492f 100644 (file)
@@ -75,7 +75,7 @@ module config-test-duplicate-attribute-in-list {
         case netconf {
             when "/config:modules/config:module/config:type = 'netconf'";
             // root runtime bean
-            leaf created-sessions {
+            leaf created-sessions2 {
                 type uint32;
             }
 
index bf081028cc40b7b84e950d198ee273be48061bea..d2d4dc534d0fffa0fe0f2ff5f465ee185a9e0c62 100644 (file)
@@ -56,7 +56,7 @@ module config-test-duplicate-attribute {
         case netconf {
             when "/config:modules/config:module/config:type = 'netconf'";
 
-           container dto-a {
+           container dto-a2 {
                 leaf simple-arg {
                        type uint32;
                    }
@@ -72,7 +72,7 @@ module config-test-duplicate-attribute {
         case netconf {
             when "/config:modules/config:module/config:type = 'netconf'";
             // root runtime bean
-            leaf created-sessions {
+            leaf created-sessions2 {
                 type uint32;
             }
 
index 1db0279506247eae3691eac9960df549258b962f..f6a0b888bd3e81e5ccd2bcedc09b991cdbc370e8 100644 (file)
@@ -62,7 +62,7 @@ module test-config-files {
         case netconf {
             when "/config:modules/config:module/config:type = 'netconf'";
             // root runtime bean
-            leaf created-sessions {
+            leaf created-sessions2 {
                 type uint32;
             }
 
index 0a152e7baae2b94c1aaa9ecfbcdef0dae89dc2db..fc0e0730dfe4a648d518b153a9fc097198888789 100644 (file)
@@ -62,7 +62,7 @@ module test-config-files1 {
         case netconf1 {
             when "/config:modules/config:module/config:type = 'netconf1'";
             // root runtime bean
-            leaf created-sessions {
+            leaf created-sessions2 {
                 type uint32;
             }
 
index c7fb73f3854cf5316c0efc7d3b39972f6978e767..d03cff305b68bc39cddf9f75f7996fd98d3fc5b8 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
   <artifactId>yang-test-plugin</artifactId>
index 247b3c07459ef67531d3085242e38f22c21b770a..5977325574202c3edd39125dc6ca60f4ebd5fd71 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>config-plugin-parent</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../config-plugin-parent</relativePath>
   </parent>
 
index ef27bfd5e453516f904d67fded5d1a208aa2e776..50f19278c6a2df8c1a8fc2ff774d528c68700ab6 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>configuration</artifactId>
-  <version>0.4.3-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index a4a7ba67469d3161e7d93c18eb4ed1d443142af6..4387de70eaf96de3091ceaaf255823b07024b729 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>configuration.implementation</artifactId>
-  <version>0.4.3-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 31b9c0767406c0723ae66b6d1800eb09baf1c131..238ff12249ce421309515441577e559dd912f688 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>configuration.integrationtest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <dependencies>
     <dependency>
       <groupId>ch.qos.logback</groupId>
index c4ced042d022e929ea3f362d873ba9a1c9d2ea1e..2718ed1afea9fb1eb4901fd1c2d4d08f10ad5005 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>connectionmanager</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 8be119d50739d8427feb9769de2516a57333cc17..fe2514e58a0876e692f3a1f945c5899ca44a8e39 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>connectionmanager.implementation</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index a19e27189a2dfcd6e7b344fa0111454800e17607..c9b54a1b6c61dee45ace9536620c2c7559f714e8 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>containermanager</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 3ead8be65a0db92858b8d25e69dd80ab464bfa8b..013cd62576efc0ea1f54e463c77f62b4948cdf59 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>containermanager.implementation</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index a3f140d7e119868737cf11235958e5ce93f80e67..8e0475d4a380ce79c5144746a84a3feb3ba02282 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>containermanager.it.implementation</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 1eedd4bc8756b691fbf478c6d24b6de4caedf792..c1c2d2055be32050f34370edcef5eaa9d23bd917 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>containermanager.shell</artifactId>
index d3dfe19c2b082e6eef41828d6274c8e8a8c57c6d..72eaf005add191a82a08c9f4f81db0b4fc11c0ba 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>opendaylight-karaf-empty</artifactId>
index e34a5d3c2cbd25e888fde5805618bfbf0bc9899d..35aac0933945debbc8fb02806e29be4620e37eb3 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>opendaylight-karaf-resources</artifactId>
diff --git a/opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/bin/setenv.bat b/opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/bin/setenv.bat
new file mode 100644 (file)
index 0000000..7c61920
--- /dev/null
@@ -0,0 +1,64 @@
+@echo off
+rem
+rem
+rem    Licensed to the Apache Software Foundation (ASF) under one or more
+rem    contributor license agreements.  See the NOTICE file distributed with
+rem    this work for additional information regarding copyright ownership.
+rem    The ASF licenses this file to You under the Apache License, Version 2.0
+rem    (the "License"); you may not use this file except in compliance with
+rem    the License.  You may obtain a copy of the License at
+rem
+rem       http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem    Unless required by applicable law or agreed to in writing, software
+rem    distributed under the License is distributed on an "AS IS" BASIS,
+rem    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem    See the License for the specific language governing permissions and
+rem    limitations under the License.
+rem
+
+rem
+rem handle specific scripts; the SCRIPT_NAME is exactly the name of the Karaf
+rem script; for example karaf.bat, start.bat, stop.bat, admin.bat, client.bat, ...
+rem
+rem if "%KARAF_SCRIPT%" == "SCRIPT_NAME" (
+rem   Actions go here...
+rem )
+
+rem
+rem general settings which should be applied for all scripts go here; please keep
+rem in mind that it is possible that scripts might be executed more than once, e.g.
+rem in example of the start script where the start script is executed first and the
+rem karaf script afterwards.
+rem
+
+rem
+rem The following section shows the possible configuration options for the default
+rem karaf scripts
+rem
+rem Window name of the windows console
+rem SET KARAF_TITLE
+rem Location of Java installation
+rem SET JAVA_HOME
+rem Minimum memory for the JVM
+rem SET JAVA_MIN_MEM
+rem Maximum memory for the JVM
+rem SET JAVA_MAX_MEM
+rem Minimum perm memory for the JVM
+rem SET JAVA_PERM_MEM
+rem Maximum perm memory for the JVM
+rem SET JAVA_MAX_PERM_MEM
+rem Karaf home folder
+rem SET KARAF_HOME
+rem Karaf data folder
+rem SET KARAF_DATA
+rem Karaf base folder
+rem SET KARAF_BASE
+rem Karaf etc folder
+rem SET KARAF_ETC
+rem Additional available Karaf options
+rem SET KARAF_OPTS
+rem Enable debug mode
+rem SET KARAF_DEBUG
+IF "%JAVA_MAX_PERM_MEM%"=="" SET JAVA_MAX_PERM_MEM=512m
+IF "%JAVA_MAX_MEM%"=="" SET JAVA_MAX_MEM=2048m
index cdb65420135d1f71ebe1e66eb67dec8efda762dd..4a8f5ae795f7541d38793498f1570227febfd979 100644 (file)
@@ -94,6 +94,10 @@ ovsdb.listenPort=6640
 # default Openflow version = 1.0, we also support 1.3.
 # ovsdb.of.version=1.3
 
+# ovsdb can be configured with ml2 to perform l3 forwarding. The config below enables that functionality, which is
+# disabled by default.
+# ovsdb.l3.fwd.enabled=yes
+
 # ovsdb can be configured with ml2 to perform l3 forwarding. When used in that scenario, the mac address of the default
 # gateway --on the external subnet-- is expected to be resolved from its inet address. The config below overrides that
 # specific arp/neighDiscovery lookup.
index 795f68c397d27265ab97997bd5b34b5d5b4b0c3f..1612f3434382655aa67bf0c732e9ca4eaacc4258 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>distribution.opendaylight-karaf</artifactId>
       <artifactId>features-base</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>features-adsal</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>features-nsf</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
+      <scope>runtime</scope>
     </dependency>
     <!-- MD-SAL Related Features -->
     <dependency>
       <artifactId>features-mdsal</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>features-flow</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>features-restconf</artifactId>
+      <version>1.2.0-SNAPSHOT</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>runtime</scope>
     </dependency>
   </dependencies>
 
index fcb452f42239c98d838d580fbbf9e94ce623f89b..e30ff05bf0fde541c3c55210bed47c5190c1b376 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>distribution.opendaylight</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <prerequisites>
     <maven>3.0</maven>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-inmemory-datastore</artifactId>
-          <version>1.1-SNAPSHOT</version>
+          <version>1.2.0-SNAPSHOT</version>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
         <dependency>
           <groupId>org.opendaylight.controller.model</groupId>
           <artifactId>model-topology</artifactId>
-          <version>1.1-SNAPSHOT</version>
+          <version>1.2.0-SNAPSHOT</version>
         </dependency>
 
         <!-- toaster example I'm pretty sure we should trim -->
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-clustering-config</artifactId>
         </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-servlets</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-client</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-continuation</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-util</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-server</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-io</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
+          <dependency>
+              <groupId>org.eclipse.jetty</groupId>
+              <artifactId>jetty-http</artifactId>
+              <version>8.1.14.v20131031</version>
+          </dependency>
       </dependencies>
     </profile>
     <profile>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>swagger-ui</artifactId>
-          <version>0.0.1-SNAPSHOT</version>
+          <version>0.1.0-SNAPSHOT</version>
         </dependency>
       </dependencies>
     </profile>
index 530e46e14a89e89fedee8657b19849cc9d0cfac4..691d83d45ecff1fc8e4d4fa13f7be7634375434f 100644 (file)
@@ -116,6 +116,10 @@ ovsdb.listenPort=6640
 # default Openflow version = 1.3, we also support 1.0.
 ovsdb.of.version=1.3
 
+# ovsdb can be configured with ml2 to perform l3 forwarding. The config below enables that functionality, which is
+# disabled by default.
+# ovsdb.l3.fwd.enabled=yes
+
 # ovsdb can be configured with ml2 to perform l3 forwarding. When used in that scenario, the mac address of the default
 # gateway --on the external subnet-- is expected to be resolved from its inet address. The config below overrides that
 # specific arp/neighDiscovery lookup.
index 78661d8df29e900b06c1f3bcb8cb8ba82ffdc437..5a66a6191b62fce0cf20989bc42682959837fa79 100644 (file)
@@ -14,7 +14,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.0-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <scm>
@@ -32,7 +32,7 @@
 
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>distribution.p2site</artifactId>
-  <version>0.1.0-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <build>
index 793e8356477476b20d89b92f45788c0b5dcf6a29..9955afa2749a921bfc45b7f2dd20e7c2fbea287b 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sanitytest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 8901c2e0b5777cb22c81e1431f3fa10498c746be..4195e53310a643b5dbf521621928f8a0da5098e0 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
   <artifactId>dummy-console</artifactId>
-  <version>1.1.0-SNAPSHOT</version>
+  <version>1.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <description>Dummy Console Interfaces for Equinox-specific CLI</description>
   <build>
index 37c0a3a09d1990d741ba0d9ea88c3b0a5621332a..b006cece40d6ca0603817c7a3f67beaed3a32f59 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>forwarding.staticrouting</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index b6e1dd68d1cf97a690f6d94d2b55d2a5d13ec327..3f667e16f08f3a1d9558f6af77379434c71124fa 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>forwardingrulesmanager</artifactId>
-  <version>0.6.0-SNAPSHOT</version>
+  <version>0.7.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index f87bed8780e003bf5eb7d70b43d8f848f28c62fe..959b71f855802aa17bc007315ed146b881093ad9 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>forwardingrulesmanager.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index ff0bfcc1ef8c18136ae16df68c48253df207824d..60b934a492f03bc0749cca246b2f346c2d13dadd 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>forwardingrulesmanager.integrationtest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <properties>
     <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <!-- Sonar jacoco plugin to get integration test coverage info -->
index b48d7abd7220323ac16104e6ba393a30e3852f92..10532baa6e2556cff8bba0478d84a19a0abf3a3e 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>hosttracker</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index cb09322b641acc460c4ae1e3a3023a756f50b05c..370f88defa378156eb7ce12780664c293e7d3796 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>hosttracker.implementation</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <properties>
index 65fc23265ae20be609dc2eb0fd6d079195183c54..dabccf3f7119742948c32d479ad22d2b48b465cd 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>hosttracker.integrationtest</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <properties>
     <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <!-- Sonar jacoco plugin to get integration test coverage info -->
index 3f73303180aece88ac15032b79f1cd825a9890e8..9088ae359b610808b2031e685e385639355bf187 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>hosttracker.shell</artifactId>
index 240976b9c8155ab183f158dc4e6a3f99b7cb7dce..db27345d1892601414d7668c5e7b813bd53de18b 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>hosttracker_new</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 036dd5dd3185a71e4f6989c313695d69ea2442d3..d3661a12c8841892675f6badeed8e6a9115525d4 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>hosttracker_new.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <properties>
diff --git a/opendaylight/karaf-branding/.gitignore b/opendaylight/karaf-branding/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
index 444e77057a88b8c32f98a5ecad7d58ffa413f1b2..dfdc3b76cbfd7ba3453e46e675534c5debaf72c6 100644 (file)
@@ -1,39 +1,37 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>releasepom</artifactId>
-      <version>0.1.2-SNAPSHOT</version>
-      <relativePath>../..</relativePath>
-    </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
     <groupId>org.opendaylight.controller</groupId>
-    <artifactId>karaf.branding</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
-    <packaging>bundle</packaging>
-    <name>OpenDaylight :: Karaf :: Branding</name>
+    <artifactId>releasepom</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>karaf.branding</artifactId>
+  <version>1.1.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <name>OpenDaylight :: Karaf :: Branding</name>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <version>2.4.0</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Import-Package>*</Import-Package>
-                        <Private-Package>!*</Private-Package>
-                        <Export-Package>
-                            org.apache.karaf.branding
-                        </Export-Package>
-                        <Spring-Context>*;public-context:=false</Spring-Context>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.4.0</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+            <Import-Package>*</Import-Package>
+            <Private-Package>!*</Private-Package>
+            <Export-Package>org.apache.karaf.branding</Export-Package>
+            <Spring-Context>*;public-context:=false</Spring-Context>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>
index 817e0faeec5942b797fb8cc64458affe4044d053..30d57d048abff4a3baeb922cc6c58544d671321a 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>karaf-tomcat-security</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 82bc6cd9c1eabf251df853848a28e75996ded281..dc37e301791d22137ca359eb336e5430428ae850 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>logging.bridge</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index 1af2287a1015953cd5562c44415cc77b86fa1b06..ac384319b8bb64c90fdf23abebf32df7a70e2de8 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <artifactId>sal-parent</artifactId>
     <groupId>org.opendaylight.controller</groupId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
index b9e9d19b48dce4eed7f5e42cc335588306ad1692..a7da4a1e9c21471e9201985d00cc16c982f08b91 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>compatibility-parent</artifactId>
   <packaging>pom</packaging>
index 168dd14d10e20aa54b08a30a5417ed94737810ff..32014decd51136c70f95ad6d8ff6cb64b10a91a3 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>compatibility-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-compatibility</artifactId>
   <packaging>bundle</packaging>
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/AbstractDataChangeListener.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/AbstractDataChangeListener.java
new file mode 100644 (file)
index 0000000..2306508
--- /dev/null
@@ -0,0 +1,146 @@
+/**
+ * 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.compatibility;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+public abstract class AbstractDataChangeListener <T extends DataObject> implements AutoCloseable,DataChangeListener{
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractDataChangeListener.class);
+    protected InventoryAndReadAdapter adapter;
+    protected final Class<T> clazz;
+    protected ListenerRegistration<DataChangeListener> listenerRegistration;
+
+    public AbstractDataChangeListener(final InventoryAndReadAdapter adapter, DataBroker db, final Class<T> clazz) {
+        this.adapter = Preconditions.checkNotNull(adapter, "InventoryAndReadAdapter can not be null!");
+        this.clazz = Preconditions.checkNotNull(clazz, "Class can not be null!");
+        Preconditions.checkNotNull(db, "DataBroker can not be null!");
+        registrationListener(db, 5);
+    }
+
+    @Override
+    public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+        Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
+        /* All DataObjects for create */
+        final Map<InstanceIdentifier<?>, DataObject> createdData = changeEvent.getCreatedData() != null
+                ? changeEvent.getCreatedData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+        /* All DataObjects for remove */
+        final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
+                ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>> emptySet();
+        /* All DataObjects for updates */
+        final Map<InstanceIdentifier<?>, DataObject> updateData = changeEvent.getUpdatedData() != null
+                ? changeEvent.getUpdatedData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+        /* All Original DataObjects */
+        final Map<InstanceIdentifier<?>, DataObject> originalData = changeEvent.getOriginalData() != null
+                ? changeEvent.getOriginalData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+        this.createData(createdData);
+        this.updateData(updateData, originalData);
+        this.removeData(removeData, originalData);
+    }
+
+    @SuppressWarnings("unchecked")
+    private void createData(final Map<InstanceIdentifier<?>, DataObject> createdData) {
+        final Set<InstanceIdentifier<?>> keys = createdData.keySet() != null
+                ? createdData.keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+        for (InstanceIdentifier<?> key : keys) {
+            if (clazz.equals(key.getTargetType())) {
+                InstanceIdentifier<T> createKeyIdent = key.firstIdentifierOf(clazz);
+                final Optional<DataObject> value = Optional.of(createdData.get(key));
+                if (value.isPresent()) {
+                    this.add(createKeyIdent, (T)value.get());
+                }
+            }
+        }
+    }
+
+    abstract protected void add(InstanceIdentifier<T> createKeyIdent, T node);
+
+    @SuppressWarnings("unchecked")
+    private void updateData(final Map<InstanceIdentifier<?>, DataObject> updateData, final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+        final Set<InstanceIdentifier<?>> keys = updateData.keySet() != null
+                ? updateData.keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+        for (InstanceIdentifier<?> key : keys) {
+            if (clazz.equals(key.getTargetType())) {
+                InstanceIdentifier<T> updateKeyIdent = key.firstIdentifierOf(clazz);
+                final Optional<DataObject> value = Optional.of(updateData.get(key));
+                final Optional<DataObject> original = Optional.of(originalData.get(key));
+                if (value.isPresent() && original.isPresent()) {
+                    this.update(updateKeyIdent, (T)original.get(), (T)value.get());
+                }
+            }
+        }
+    }
+
+    abstract protected void update(InstanceIdentifier<T> updateKeyIdent, T node,
+            T node2);
+
+    @SuppressWarnings("unchecked")
+    private void removeData(final Set<InstanceIdentifier<?>> removeData, final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+        for (InstanceIdentifier<?> key : removeData) {
+            if (clazz.equals(key.getTargetType())) {
+                final InstanceIdentifier<T> ident = key.firstIdentifierOf(clazz);
+                final DataObject removeValue = originalData.get(key);
+                this.remove(ident, (T)removeValue);
+            }
+        }
+    }
+
+    abstract protected void remove(InstanceIdentifier<T> ident, T removeValue);
+
+    protected void registrationListener(final DataBroker db, int i) {
+        try {
+            listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                    getWildCardPath(), this, DataChangeScope.BASE);
+        } catch (final Exception e) {
+            if (i >= 1) {
+                try {
+                    Thread.sleep(100);
+                } catch (InterruptedException e1) {
+                    LOG.error("Thread interrupted '{}'", e1);
+                    Thread.currentThread().interrupt();
+                }
+                registrationListener(db, --i);
+            } else {
+                LOG.error("AbstractDataChangeListener registration fail!", e);
+                throw new IllegalStateException("AbstractDataChangeListener registration Listener fail! System needs restart.", e);
+            }
+        }
+    }
+
+    protected abstract InstanceIdentifier<?> getWildCardPath();
+
+    @Override
+    public void close() {
+        if (listenerRegistration != null) {
+            try {
+                listenerRegistration.close();
+            } catch (final Exception e) {
+                LOG.error("Error by stop AbstractDataChangeListener.", e);
+            }
+            listenerRegistration = null;
+        }
+    }
+}
\ No newline at end of file
index 1530e909ad769ae8b7dcdf808aa47ad5bfe39783..bbb6673a8e04cf25fa2b43a7fe8ba686b8e36690 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.controller.sal.compatibility;
 
-import com.google.common.collect.Iterables;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -70,7 +68,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericStatistics;
@@ -89,7 +86,9 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInInventoryService, OpendaylightInventoryListener, OpendaylightFlowStatisticsListener, OpendaylightFlowTableStatisticsListener, OpendaylightPortStatisticsListener {
+import com.google.common.collect.Iterables;
+
+public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInInventoryService, OpendaylightFlowStatisticsListener, OpendaylightFlowTableStatisticsListener, OpendaylightPortStatisticsListener {
     private static final Logger LOG = LoggerFactory.getLogger(InventoryAndReadAdapter.class);
     private static final short OPENFLOWV10_TABLE_ID = 0;
 
@@ -398,13 +397,11 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI
         return nodeStats;
     }
 
-    @Override
-    public void onNodeConnectorRemoved(final NodeConnectorRemoved update) {
+    public void onNodeConnectorRemovedInternal(final NodeConnectorRemoved update) {
         // Never received
     }
 
-    @Override
-    public void onNodeRemoved(final NodeRemoved notification) {
+    public void onNodeRemovedInternal(final NodeRemoved notification) {
         this.removeNodeConnectors(notification.getNodeRef().getValue());
         try {
             final Node aDNode = NodeMapping.toADNode(notification.getNodeRef());
@@ -414,8 +411,7 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI
         }
     }
 
-    @Override
-    public void onNodeConnectorUpdated(final NodeConnectorUpdated update) {
+    public void onNodeConnectorUpdatedInternal(final NodeConnectorUpdated update) {
         final NodeConnectorRef ref = update.getNodeConnectorRef();
         final UpdateType updateType;
         if (!this.isKnownNodeConnector(ref.getValue())) {
@@ -434,8 +430,7 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI
         }
     }
 
-    @Override
-    public void onNodeUpdated(final NodeUpdated notification) {
+    public void onNodeUpdatedInternal(final NodeUpdated notification) {
         final NodeRef ref = notification.getNodeRef();
 
         final UpdateType updateType;
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NCDataChangeListener.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NCDataChangeListener.java
new file mode 100644 (file)
index 0000000..d93d40d
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+ * 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.compatibility;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NCDataChangeListener extends AbstractDataChangeListener<NodeConnector> {
+    private static final Logger LOG = LoggerFactory.getLogger(NodeDataChangeListener.class);
+    private ListenerRegistration<DataChangeListener> listenerRegistration;
+    public NCDataChangeListener (final InventoryAndReadAdapter adapter, final DataBroker db) {
+        super(adapter,db,NodeConnector.class);
+    }
+
+    @Override
+    protected void add(InstanceIdentifier<NodeConnector> createKeyIdent, NodeConnector node) {
+        FlowCapableNodeConnector fcnc = node.getAugmentation(FlowCapableNodeConnector.class);
+        if(fcnc != null) {
+            FlowCapableNodeConnectorUpdatedBuilder fcncub = new FlowCapableNodeConnectorUpdatedBuilder(fcnc);
+            NodeConnectorUpdatedBuilder builder = new NodeConnectorUpdatedBuilder();
+            builder.setId(node.getId());
+            builder.setNodeConnectorRef(new NodeConnectorRef(createKeyIdent));
+            builder.addAugmentation(FlowCapableNodeConnectorUpdated.class, fcncub.build());
+            adapter.onNodeConnectorUpdatedInternal(builder.build());
+        }
+    }
+
+    @Override
+    protected void update(InstanceIdentifier<NodeConnector> updateKeyIdent, NodeConnector original,
+            NodeConnector update) {
+        add(updateKeyIdent,update);
+    }
+
+    @Override
+    protected void remove(InstanceIdentifier<NodeConnector> ident, NodeConnector removeValue) {
+        NodeConnectorRemovedBuilder builder = new NodeConnectorRemovedBuilder();
+        builder.setNodeConnectorRef(new NodeConnectorRef(ident));
+        adapter.onNodeConnectorRemovedInternal(builder.build());
+    }
+
+    protected InstanceIdentifier<NodeConnector> getWildCardPath() {
+        return InstanceIdentifier.create(Nodes.class).child(Node.class).child(NodeConnector.class);
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeDataChangeListener.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeDataChangeListener.java
new file mode 100644 (file)
index 0000000..cdb2616
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * 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.compatibility;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeDataChangeListener extends AbstractDataChangeListener<Node> {
+    private static final Logger LOG = LoggerFactory.getLogger(NodeDataChangeListener.class);
+
+
+    public NodeDataChangeListener (final InventoryAndReadAdapter adapter, final DataBroker db) {
+        super(adapter,db,Node.class);
+    }
+
+    protected void add(InstanceIdentifier<Node> createKeyIdent, Node node) {
+        FlowCapableNode fcn = node.getAugmentation(FlowCapableNode.class);
+        if(fcn != null) {
+            FlowCapableNodeUpdatedBuilder fcbnu = new FlowCapableNodeUpdatedBuilder(fcn);
+            NodeUpdatedBuilder builder = new NodeUpdatedBuilder();
+            builder.setId(node.getId());
+            builder.setNodeRef(new NodeRef(createKeyIdent));
+            builder.setNodeConnector(node.getNodeConnector());
+            builder.addAugmentation(FlowCapableNodeUpdated.class, fcbnu.build());
+            adapter.onNodeUpdatedInternal(builder.build());
+        }
+    }
+
+    protected void update(InstanceIdentifier<Node> updateKeyIdent, Node original,
+            Node update) {
+        this.add(updateKeyIdent, update);
+    }
+
+    protected void remove(InstanceIdentifier<Node> ident, Node removeValue) {
+        NodeRemovedBuilder builder = new NodeRemovedBuilder();
+        builder.setNodeRef(new NodeRef(ident));
+        adapter.onNodeRemovedInternal(builder.build());
+    }
+
+    protected InstanceIdentifier<Node> getWildCardPath() {
+        return InstanceIdentifier.create(Nodes.class).child(Node.class);
+    }
+
+}
index 0ddbcaa2e0b5032d3b8512e9fb86bd83ecd22d63..f8f2b37819bddc7a0037f3aa8a64deeef2c59c60 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.compatibility;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
@@ -68,6 +69,10 @@ class SalCompatibilityProvider implements BindingAwareProvider {
         inv.setNodeConnectorStatisticsService(session.getRpcService(OpendaylightPortStatisticsService.class));
         inv.setTopologyDiscovery(session.getRpcService(FlowTopologyDiscoveryService.class));
         inv.setDataProviderService(session.getSALService(DataProviderService.class));
+
+        final NodeDataChangeListener ndcl = new NodeDataChangeListener(inv,session.getSALService(DataBroker.class));
+        final NCDataChangeListener ncdcl = new NCDataChangeListener(inv,session.getSALService(DataBroker.class));
+
         // FIXME: remember registration for clean shutdown
         subscribe.registerNotificationListener(inv);
 
index 6bc669f60b17a378369ae837081c43cab38be244..ae723a316524b19a833f880b54132be63ab9701e 100644 (file)
@@ -7,12 +7,8 @@
  */
 package org.opendaylight.controller.sal.compatibility.topology;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
+import com.google.common.base.Function;
+import com.google.common.collect.FluentIterable;
 import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader;
 import org.opendaylight.controller.sal.compatibility.NodeMapping;
 import org.opendaylight.controller.sal.core.ConstructionException;
@@ -33,11 +29,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.regex.Pattern;
+
+import static com.google.common.base.Preconditions.checkNotNull;
 
 public final class TopologyMapping {
     private static final Logger LOG = LoggerFactory.getLogger(TopologyMapping.class);
+    private final static Pattern NUMBERS_ONLY = Pattern.compile("[0-9]+");
 
     private TopologyMapping() {
         throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
@@ -100,7 +101,13 @@ public final class TopologyMapping {
 
     public static NodeConnector toADNodeConnector(final TpId source, final NodeId nodeId) throws ConstructionException {
         checkNotNull(source);
-        return new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf(toADNodeConnectorId(source)), toADNode(nodeId));
+        String nodeConnectorIdStripped = toADNodeConnectorId(source);
+        if (NUMBERS_ONLY.matcher(nodeConnectorIdStripped).matches()) {
+            return new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf(nodeConnectorIdStripped), toADNode(nodeId));
+        }
+        LOG.debug("NodeConnectorId does not match openflow id type, using " + NodeMapping.MD_SAL_TYPE +  "instead");
+        NodeConnectorIDType.registerIDType(NodeMapping.MD_SAL_TYPE, String.class, NodeMapping.MD_SAL_TYPE);
+        return new NodeConnector(NodeMapping.MD_SAL_TYPE, nodeConnectorIdStripped, toADNode(nodeId));
     }
 
     public static String toADNodeConnectorId(final TpId nodeConnectorId) {
@@ -109,6 +116,12 @@ public final class TopologyMapping {
 
     public static Node toADNode(final NodeId nodeId) throws ConstructionException {
         checkNotNull(nodeId);
-        return new Node(NodeIDType.OPENFLOW, Long.valueOf(toADNodeId(nodeId)));
+        String nodeIdStripped = toADNodeId(nodeId);
+        if (NUMBERS_ONLY.matcher(nodeIdStripped).matches()) {
+            return new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeIdStripped));
+        }
+        LOG.debug("NodeId does not match openflow id type, using " + NodeMapping.MD_SAL_TYPE +  "instead");
+        NodeIDType.registerIDType(NodeMapping.MD_SAL_TYPE, String.class);
+        return new Node(NodeMapping.MD_SAL_TYPE, nodeId.getValue());
     }
 }
index b76370a53880428dc8ce451e9ebbdec8cab238c2..9369217d78058c43318f8799c61cdf1c3b70e39a 100644 (file)
@@ -69,4 +69,17 @@ public class TopologyMappingTest {
         Assert.assertEquals("OF|00:00:00:00:00:00:00:01", observedNode.toString());
     }
 
+    /**
+     * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnector(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
+     * @throws ConstructionException
+     */
+    @Test
+    public void bug1309ToADNodeConnector() throws ConstructionException {
+        NodeId nodeId = new NodeId("some_unknown_node");
+        TpId source = new TpId("192.168.0.1");
+        NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId);
+
+        Assert.assertEquals("MD_SAL_DEPRECATED|192.168.0.1@MD_SAL_DEPRECATED|some_unknown_node", observedNodeConnector.toString());
+    }
+
 }
index 5a9b19021945b947e7601fbdaa82dd74676fbdc8..12458f5ab9de4c4defabb63d3ad7b99051a10361 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller.md</groupId>
   <artifactId>forwardingrules-manager</artifactId>
index 1706996ce4a301ef4564ac765032c608c39bea68..77e42032695d106f73d85f7921febb53763f3476 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller.md</groupId>
   <artifactId>inventory-manager</artifactId>
index 3db929b99d9c68065cec7875412901090570530d..618fcfc133abfd8335e491036dc0319d25204741 100644 (file)
@@ -7,24 +7,23 @@
  */
 package org.opendaylight.controller.md.inventory.manager;
 
-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.ArrayList;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingDeque;
+
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Preconditions;
+
 class FlowCapableInventoryProvider implements AutoCloseable, Runnable, TransactionChainListener {
     private static final Logger LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider.class);
     private static final int QUEUE_DEPTH = 500;
@@ -47,7 +46,7 @@ class FlowCapableInventoryProvider implements AutoCloseable, Runnable, Transacti
         final NodeChangeCommiter changeCommiter = new NodeChangeCommiter(FlowCapableInventoryProvider.this);
         this.listenerRegistration = this.notificationService.registerNotificationListener(changeCommiter);
 
-        this.txChain = dataBroker.createTransactionChain(this);
+        this.txChain = (dataBroker.createTransactionChain(this));
         thread = new Thread(this);
         thread.setDaemon(true);
         thread.setName("FlowCapableInventoryProvider");
@@ -59,49 +58,20 @@ class FlowCapableInventoryProvider implements AutoCloseable, Runnable, Transacti
     void enqueue(final InventoryOperation op) {
         try {
             queue.put(op);
-        } catch (InterruptedException e) {
+        } catch (final InterruptedException e) {
             LOG.warn("Failed to enqueue operation {}", op, e);
         }
     }
 
-    @Override
-    public void close() throws InterruptedException {
-        LOG.info("Flow Capable Inventory Provider stopped.");
-        if (this.listenerRegistration != null) {
-            try {
-                this.listenerRegistration.close();
-            } catch (Exception e) {
-                LOG.error("Failed to stop inventory provider", e);
-            }
-            listenerRegistration = null;
-        }
-
-        if (thread != null) {
-            thread.interrupt();
-            thread.join();
-            thread = null;
-        }
-        if (txChain != null) {
-            txChain.close();
-            txChain = null;
-        }
-
-
-    }
-
     @Override
     public void run() {
         try {
             for (; ; ) {
                 InventoryOperation op = queue.take();
-
-                final ReadWriteTransaction tx = txChain.newReadWriteTransaction();
-                LOG.debug("New operations available, starting transaction {}", tx.getIdentifier());
-
                 int ops = 0;
+                final ArrayList<InventoryOperation> opsToApply = new ArrayList<>(MAX_BATCH);
                 do {
-                    op.applyOperation(tx);
-
+                    opsToApply.add(op);
                     ops++;
                     if (ops < MAX_BATCH) {
                         op = queue.poll();
@@ -109,23 +79,9 @@ class FlowCapableInventoryProvider implements AutoCloseable, Runnable, Transacti
                         op = null;
                     }
                 } while (op != null);
-
-                LOG.debug("Processed {} operations, submitting transaction {}", ops, tx.getIdentifier());
-
-                final CheckedFuture<Void, TransactionCommitFailedException> result = tx.submit();
-                Futures.addCallback(result, new FutureCallback<Void>() {
-                    @Override
-                    public void onSuccess(final Void aVoid) {
-                        //NOOP
-                    }
-
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        LOG.error("Transaction {} failed.", tx.getIdentifier(), throwable);
-                    }
-                });
+                submitOperations(opsToApply);
             }
-        } catch (InterruptedException e) {
+        } catch (final InterruptedException e) {
             LOG.info("Processing interrupted, terminating", e);
         }
 
@@ -135,15 +91,131 @@ class FlowCapableInventoryProvider implements AutoCloseable, Runnable, Transacti
         }
     }
 
+    /**
+     * Starts new empty transaction, custimizes it with submitted operations
+     * and submit it to data broker.
+     *
+     * If transaction chain failed during customization of transaction
+     * it allocates new chain and empty transaction and  customizes it
+     * with submitted operations.
+     *
+     * This does not retry failed transaction. It only retries it when
+     * chain failed during customization of transaction chain.
+     *
+     * @param opsToApply
+     */
+    private void submitOperations(final ArrayList<InventoryOperation> opsToApply) {
+        final ReadWriteTransaction tx = createCustomizedTransaction(opsToApply);
+        LOG.debug("Processed {} operations, submitting transaction {}", opsToApply.size(), tx.getIdentifier());
+        try {
+            tx.submit();
+        } catch (final IllegalStateException e) {
+            /*
+             * Transaction chain failed during doing batch, so we need to null
+             * tx chain and continue processing queue.
+             *
+             * We fail current txChain which was allocated with createTransaction.
+             */
+            failCurrentChain(txChain);
+            /*
+             * We will retry transaction once in order to not loose any data.
+             *
+             */
+            final ReadWriteTransaction retryTx = createCustomizedTransaction(opsToApply);
+            retryTx.submit();
+        }
+    }
+
+    /**
+     * Creates new empty ReadWriteTransaction. If transaction chain
+     * was failed, it will allocate new transaction chain
+     * and assign it with this Operation Executor.
+     *
+     * This call is synchronized to prevent reace with {@link #failCurrentChain(TransactionChain)}.
+     *
+     * @return New Empty ReadWrite transaction, which continues this chain or starts new transaction
+     *          chain.
+     */
+    private synchronized ReadWriteTransaction newEmptyTransaction() {
+        try {
+            if(txChain == null) {
+                // Chain was broken so we need to replace it.
+                txChain = dataBroker.createTransactionChain(this);
+            }
+            return txChain.newReadWriteTransaction();
+        } catch (final IllegalStateException e) {
+            LOG.debug("Chain is broken, need to allocate new transaction chain.",e);
+            /*
+             *  Chain was broken by previous transaction,
+             *  but there was race between this.
+             *  Chain will be closed by #onTransactionChainFailed method.
+             */
+            txChain = dataBroker.createTransactionChain(this);
+            return txChain.newReadWriteTransaction();
+        }
+    }
+
+    /**
+     * Creates customized not-submitted transaction, which is ready to be submitted.
+     *
+     * @param opsToApply Operations which are used to customize transaction.
+     * @return Non-empty transaction.
+     */
+    private ReadWriteTransaction createCustomizedTransaction(final ArrayList<InventoryOperation> opsToApply) {
+        final ReadWriteTransaction tx = newEmptyTransaction();
+        for(final InventoryOperation op : opsToApply) {
+            op.applyOperation(tx);
+        }
+        return tx;
+    }
+
+    private synchronized void failCurrentChain(final TransactionChain<?, ?> chain) {
+        if(txChain == chain) {
+            txChain = null;
+        }
+    }
+
     @Override
     public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
                                          final Throwable cause) {
         LOG.error("Failed to export Flow Capable Inventory, Transaction {} failed.", transaction.getIdentifier(), cause);
-
+        chain.close();
+        if(txChain == chain) {
+            // Current chain is broken, so we will null it, in order to not use it.
+            failCurrentChain(chain);
+        }
     }
 
     @Override
     public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
         // NOOP
     }
+
+    @Override
+    public void close() throws InterruptedException {
+        LOG.info("Flow Capable Inventory Provider stopped.");
+        if (this.listenerRegistration != null) {
+            try {
+                this.listenerRegistration.close();
+            } catch (final Exception e) {
+                LOG.error("Failed to stop inventory provider", e);
+            }
+            listenerRegistration = null;
+        }
+
+        if (thread != null) {
+            thread.interrupt();
+            thread.join();
+            thread = null;
+        }
+        if (txChain != null) {
+            try {
+                txChain.close();
+            } catch (final IllegalStateException e) {
+                // It is possible chain failed and was closed by #onTransactionChainFailed
+                LOG.debug("Chain was already closed.");
+            }
+            txChain = null;
+        }
+    }
 }
index 2e19b5a60c46f2d8d8ba5c08f7870a6e45d83558..bd1586054dac5418cfa19c9e7e30bde9c6417087 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>md-sal-config</artifactId>
   <description>Configuration files for md-sal</description>
index eb8d6a8ddbd460cad51efb4136de386181020b35..cad0e9ea93bde70b35430dd371c9c917130369b6 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.opendaylight.controller.model</groupId>
     <artifactId>model-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>model-flow-base</artifactId>
   <packaging>bundle</packaging>
index 0842bb450545e75d0dbed6917ab7d73ba73255f0..0f735d7f43fe4dc323e59e217ce679c963fa68b3 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.opendaylight.controller.model</groupId>
     <artifactId>model-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>model-flow-service</artifactId>
   <packaging>bundle</packaging>
index 5a40022963f9b35520cc47148e0d777f5693c7b7..fc0eb4cf7220c7428a9977f9eb0232e60750f045 100644 (file)
@@ -236,13 +236,17 @@ module flow-node-inventory {
     }
 
     augment "/inv:nodes/inv:node/table" {
-        ext:augment-identifier "flow-cookie-mapping";
-        list flow-cookie-map {
-            key "cookie";
-            leaf cookie {
-                type flow:flow-cookie;
+        ext:augment-identifier "flow-hash-id-mapping";
+    description "Flow is identified by match and priority on device. So Operational/DS
+        has to simulate that behavior and contract between FlowId and match+priority
+        identification should represent Flow hashCode. Flow has to contain only
+        match priority and flowCookie for create a hashCode";
+        list flow-hash-id-map {
+            key "hash";
+            leaf hash {
+                type string;
             }
-            leaf-list flow-ids {
+            leaf flow-id {
                 type flow-id;
             }
         }
index cd26e327819d9fe84cdb7d64262d849e6310bb34..7a53f062d7235ebf1fff214d6a5646c45a7c5c57 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.opendaylight.controller.model</groupId>
     <artifactId>model-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>model-flow-statistics</artifactId>
   <packaging>bundle</packaging>
index c2f4f70c40983e0eabc73642a68666921f75e0b1..00aa7761b9dfa6c10cc74ee501f66211935c94fc 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.opendaylight.controller.model</groupId>
     <artifactId>model-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>model-inventory</artifactId>
   <packaging>bundle</packaging>
index e87e4f180dbf7231a7fa832e2b262d86c7bd990a..09a063e88701c664e140ae3536b53e4cbc8e1a87 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.opendaylight.controller.model</groupId>
     <artifactId>model-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>model-topology</artifactId>
   <packaging>bundle</packaging>
index 5e6a86745c0ae09b9bd200a5d49f495aafeba276..3f389f32989a0d5cd9ef5128e7583a39848d2224 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller.model</groupId>
   <artifactId>model-parent</artifactId>
index a9c81b93536dccd22284debff0feccec7d9b9140..1f646f2bba20086997a8717a07f529ac5ed6c059 100644 (file)
@@ -5,12 +5,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal-parent</artifactId>
-  <version>1.1-SNAPSHOT</version>
+  <version>1.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <modules>
index e68e7815252f5326ba2af41eea0fc43ba826e87a..53353cded17e3abc57f21c3a3737b09cebb9dede 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-akka-raft</artifactId>
   <packaging>bundle</packaging>
@@ -13,7 +13,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-clustering-commons</artifactId>
-      <version>1.1-SNAPSHOT</version>
+      <version>1.2.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>
index 7f45fb458ba0c2cbf5ecadf67173809ab1ca6254..690957ed0ba4d2db27ca27aff18749a2c22eafe0 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-binding-api</artifactId>
   <packaging>bundle</packaging>
index 539f9d45c8b8c30ebfcde9da22229bd4c2a547ab..7482c52fdd005e531cf95a284cff87c5614b796b 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-binding-broker-impl</artifactId>
   <packaging>bundle</packaging>
@@ -70,7 +70,7 @@
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>binding-data-codec</artifactId>
-      <version>0.6.2-SNAPSHOT</version>
+      <version>0.7.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
index 2342745f92830782616920409c744764645da9c5..68af914f579e854014fbb60fe3b98db5f720582b 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-binding-config</artifactId>
   <packaging>bundle</packaging>
index 7a66c411962285efe2de6514b862f10670b9e296..fefd85b44b2888b2edde8108d6f67029c89bb8d8 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-binding-dom-it</artifactId>
   <packaging>jar</packaging>
@@ -52,7 +52,7 @@
       <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-test-model</artifactId>
-          <version>1.1-SNAPSHOT</version>
+          <version>1.2.0-SNAPSHOT</version>
       </dependency>
   </dependencies>
   <build>
index 1912462cf0aa5d081ec56166d16b6256e69f7be8..009adb6d4a5ec20a2bc0c6ff4c2a5259fbabd6f1 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-binding-it</artifactId>
 
index 229c54f557c729d7c008d82a3e6f72b03be8ec96..efe2e845072310ac52c0e818ef2d44d7c66cd3d4 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-binding-util</artifactId>
   <packaging>bundle</packaging>
index d12f867ac5663b7637ecff59110dfbb0303798ec..54a1fe7a95d75ae31c84ed4dec696d886d2692d1 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>sal-clustering-commons</artifactId>
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActorWithMetering.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/AbstractUntypedPersistentActorWithMetering.java
new file mode 100644 (file)
index 0000000..365a5bd
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.common.actor;
+
+/**
+ * Actor with its behaviour metered. Metering is enabled by configuration.
+ */
+public abstract class AbstractUntypedPersistentActorWithMetering extends AbstractUntypedPersistentActor {
+
+    public AbstractUntypedPersistentActorWithMetering() {
+        if (isMetricsCaptureEnabled())
+            getContext().become(new MeteringBehavior(this));
+    }
+
+    private boolean isMetricsCaptureEnabled(){
+        CommonConfig config = new CommonConfig(getContext().system().settings().config());
+        return config.isMetricCaptureEnabled();
+    }
+}
index 4e76e37fa25c179ac3f2b196f97ee389261a8c97..6669e48627b6b782327684fcc9a13818b867816a 100644 (file)
 
 package org.opendaylight.controller.cluster.datastore.node;
 
-import org.opendaylight.controller.cluster.datastore.node.utils.PathUtils;
 import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer.DeSerializer;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer.Serializer;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class NormalizedNodeToNodeCodec {
+    public interface Encoded {
+        NormalizedNodeMessages.Container getEncodedNode();
+
+        NormalizedNodeMessages.InstanceIdentifier getEncodedPath();
+    }
+
+    public interface Decoded {
+        NormalizedNode<?,?> getDecodedNode();
+
+        YangInstanceIdentifier getDecodedPath();
+    }
+
     private final SchemaContext ctx;
-    private static final Logger logger = LoggerFactory.getLogger(NormalizedNodeToNodeCodec.class);
 
     public NormalizedNodeToNodeCodec(final SchemaContext ctx){
         this.ctx = ctx;
+    }
 
+    public NormalizedNodeMessages.Container encode(NormalizedNode<?,?> node){
+        return encode(null, node).getEncodedNode();
     }
 
-    public NormalizedNodeMessages.Container encode(YangInstanceIdentifier id, NormalizedNode node){
+    public Encoded encode(YangInstanceIdentifier path, NormalizedNode<?,?> node) {
+
+        NormalizedNodeMessages.InstanceIdentifier serializedPath = null;
 
         NormalizedNodeMessages.Container.Builder builder = NormalizedNodeMessages.Container.newBuilder();
-        String parentPath = "";
 
-        if(id != null){
-            parentPath = PathUtils.getParentPath(PathUtils.toString(id));
-        }
+        // Note: parent path is no longer used
+        builder.setParentPath("");
 
-        builder.setParentPath(parentPath);
         if(node != null) {
-            builder.setNormalizedNode(NormalizedNodeSerializer.serialize(node));
+            if(path == null) {
+                builder.setNormalizedNode(NormalizedNodeSerializer.serialize(node));
+            } else {
+                Serializer serializer = NormalizedNodeSerializer.newSerializer(node);
+                builder.setNormalizedNode(serializer.serialize(path));
+                serializedPath = serializer.getSerializedPath();
+            }
         }
 
-        return builder.build();
+        return new EncodedImpl(builder.build(), serializedPath);
+    }
+
+
+    public NormalizedNode<?,?> decode(NormalizedNodeMessages.Node node){
+        return decode(null, node).getDecodedNode();
     }
 
-    public NormalizedNode<?,?> decode(YangInstanceIdentifier id, NormalizedNodeMessages.Node node){
+    public Decoded decode(NormalizedNodeMessages.InstanceIdentifier path,
+            NormalizedNodeMessages.Node node) {
         if(node.getIntType() < 0 || node.getSerializedSize() == 0){
-            return null;
+            return new DecodedImpl(null, null);
         }
-        return NormalizedNodeSerializer.deSerialize(node);
+
+        DeSerializer deSerializer = NormalizedNodeSerializer.newDeSerializer(path, node);
+        NormalizedNode<?,?> decodedNode = deSerializer.deSerialize();
+        return new DecodedImpl(decodedNode, deSerializer.getDeserializedPath());
     }
 
+    private static class DecodedImpl implements Decoded {
+
+        private final NormalizedNode<?, ?> decodedNode;
+        private final YangInstanceIdentifier decodedPath;
 
+        public DecodedImpl(NormalizedNode<?, ?> decodedNode, YangInstanceIdentifier decodedPath) {
+            this.decodedNode = decodedNode;
+            this.decodedPath = decodedPath;
+        }
+
+        @Override
+        public NormalizedNode<?, ?> getDecodedNode() {
+            return decodedNode;
+        }
+
+        @Override
+        public YangInstanceIdentifier getDecodedPath() {
+            return decodedPath;
+        }
+    }
+
+    private static class EncodedImpl implements Encoded {
+
+        private final Container encodedNode;
+        private final InstanceIdentifier encodedPath;
+
+        EncodedImpl(Container encodedNode, InstanceIdentifier encodedPath) {
+            this.encodedNode = encodedNode;
+            this.encodedPath = encodedPath;
+        }
+
+        @Override
+        public Container getEncodedNode() {
+            return encodedNode;
+        }
+
+        @Override
+        public InstanceIdentifier getEncodedPath() {
+            return encodedPath;
+        }
+    }
 }
index 25b65f01681ac4b9dcaa6354ec001c85bc531981..6cdddfd2716c1cf0e008f47853877174ba61d4b3 100644 (file)
@@ -20,23 +20,6 @@ import java.util.Set;
 
 public class PathUtils {
 
-    public static String getParentPath(String currentElementPath){
-        StringBuilder parentPath = new StringBuilder();
-
-        if(currentElementPath != null){
-            String[] parentPaths = currentElementPath.split("/");
-            if(parentPaths.length > 2){
-                for(int i=0;i<parentPaths.length-1;i++){
-                    if(parentPaths[i].length() > 0){
-                        parentPath.append("/");
-                        parentPath.append(parentPaths[i]);
-                    }
-                }
-            }
-        }
-        return parentPath.toString();
-    }
-
     /**
      * Given a YangInstanceIdentifier return a serialized version of the same
      * as a String
index 660bc28e6265047bc130a1bd4b117a741de6c2ef..192070252779d5c49df5c944721d9dfb5783d1a7 100644 (file)
@@ -8,15 +8,9 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
-import java.net.URI;
-import java.util.Date;
-
 /**
  * NormalizedNodeSerializationContext provides methods which help in encoding
  * certain components of a NormalizedNode properly
  */
 public interface NormalizedNodeSerializationContext {
-    int addNamespace(URI namespace);
-    int addRevision(Date revision);
-    int addLocalName(String localName);
 }
index 44da4a56683558e9b15b8a1e94d1af8c10d1a3df..15d51e1d80aed557a98279e606aba21d2034fde9 100644 (file)
@@ -9,9 +9,9 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
 import com.google.common.base.Preconditions;
-
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
@@ -33,15 +33,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-
 import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.ANY_XML_NODE_TYPE;
 import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.AUGMENTATION_NODE_TYPE;
 import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeType.CHOICE_NODE_TYPE;
@@ -93,6 +86,10 @@ public class NormalizedNodeSerializer {
         return new Serializer(node).serialize();
     }
 
+    public static Serializer newSerializer(NormalizedNode node) {
+        Preconditions.checkNotNull(node, "node should not be null");
+        return new Serializer(node);
+    }
 
     /**
      * DeSerialize a protocol buffer message back into a NormalizedNode
@@ -100,8 +97,15 @@ public class NormalizedNodeSerializer {
      * @param node
      * @return
      */
-    public static NormalizedNode deSerialize(NormalizedNodeMessages.Node node){
-        return new DeSerializer(node).deSerialize();
+    public static NormalizedNode deSerialize(NormalizedNodeMessages.Node node) {
+        Preconditions.checkNotNull(node, "node should not be null");
+        return new DeSerializer(null, node).deSerialize();
+    }
+
+    public static DeSerializer newDeSerializer(NormalizedNodeMessages.InstanceIdentifier path,
+            NormalizedNodeMessages.Node node) {
+        Preconditions.checkNotNull(node, "node should not be null");
+        return new DeSerializer(path, node);
     }
 
     /**
@@ -117,25 +121,36 @@ public class NormalizedNodeSerializer {
      * @param pathArgument
      * @return
      */
-    public static YangInstanceIdentifier.PathArgument deSerialize(NormalizedNodeMessages.Node node, NormalizedNodeMessages.PathArgument pathArgument){
+    public static YangInstanceIdentifier.PathArgument deSerialize(NormalizedNodeMessages.Node node,
+            NormalizedNodeMessages.PathArgument pathArgument){
         Preconditions.checkNotNull(node, "node should not be null");
         Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
-        return new DeSerializer(node).deSerialize(pathArgument);
+        return new DeSerializer(null, node).deSerialize(pathArgument);
     }
 
-    private static class Serializer implements NormalizedNodeSerializationContext {
+    public static class Serializer extends QNameSerializationContextImpl
+                                   implements NormalizedNodeSerializationContext {
 
         private final NormalizedNode node;
 
-        private final Map<Object, Integer> codeMap = new HashMap<>();
-        private final List<String> codes = new ArrayList<>();
+        private NormalizedNodeMessages.InstanceIdentifier serializedPath;
 
         private Serializer(NormalizedNode node) {
             this.node = node;
         }
 
-        private NormalizedNodeMessages.Node serialize() {
-            return this.serialize(node).addAllCode(codes).build();
+        public NormalizedNodeMessages.InstanceIdentifier getSerializedPath() {
+            return serializedPath;
+        }
+
+        public NormalizedNodeMessages.Node serialize() {
+            return this.serialize(node).addAllCode(getCodes()).build();
+        }
+
+        public NormalizedNodeMessages.Node serialize(YangInstanceIdentifier path) {
+            Builder builder = serialize(node);
+            serializedPath = InstanceIdentifierUtils.toSerializable(path, this);
+            return builder.addAllCode(getCodes()).build();
         }
 
         private NormalizedNodeMessages.Node.Builder serialize(
@@ -183,56 +198,10 @@ public class NormalizedNodeSerializer {
 
             return builder;
         }
-
-
-        @Override public int addNamespace(URI namespace) {
-            int namespaceInt = getCode(namespace);
-
-            if(namespaceInt == -1) {
-                namespaceInt = addCode(namespace, namespace.toString());
-            }
-            return namespaceInt;
-        }
-
-        @Override public int addRevision(Date revision) {
-            if(revision == null){
-                return -1;
-            }
-
-            int revisionInt = getCode(revision);
-            if(revisionInt == -1) {
-                String formattedRevision =
-                    SimpleDateFormatUtil.getRevisionFormat().format(revision);
-                revisionInt = addCode(revision, formattedRevision);
-            }
-            return revisionInt;
-        }
-
-        @Override public int addLocalName(String localName) {
-            int localNameInt = getCode(localName);
-            if(localNameInt == -1) {
-                localNameInt = addCode(localName, localName.toString());
-            }
-            return localNameInt;
-
-        }
-
-        public int addCode(Object code, String codeStr){
-            int count = codes.size();
-            codes.add(codeStr);
-            codeMap.put(code, Integer.valueOf(count));
-            return count;
-        }
-
-        public int getCode(Object code){
-            if(codeMap.containsKey(code)){
-                return codeMap.get(code);
-            }
-            return -1;
-        }
     }
 
-    private static class DeSerializer implements NormalizedNodeDeSerializationContext {
+    public static class DeSerializer extends QNameDeSerializationContextImpl
+                                     implements NormalizedNodeDeSerializationContext {
         private static Map<NormalizedNodeType, DeSerializationFunction>
             deSerializationFunctions = new EnumMap<>(NormalizedNodeType.class);
 
@@ -438,13 +407,27 @@ public class NormalizedNodeSerializer {
         }
 
         private final NormalizedNodeMessages.Node node;
+        private final NormalizedNodeMessages.InstanceIdentifier path;
+        private YangInstanceIdentifier deserializedPath;
 
-        public DeSerializer(NormalizedNodeMessages.Node node){
+        public DeSerializer(NormalizedNodeMessages.InstanceIdentifier path,
+                NormalizedNodeMessages.Node node) {
+            super(node.getCodeList());
+            this.path = path;
             this.node = node;
         }
 
-        public NormalizedNode deSerialize(){
-            return deSerialize(node);
+        public YangInstanceIdentifier getDeserializedPath() {
+            return deserializedPath;
+        }
+
+        public NormalizedNode deSerialize() {
+            NormalizedNode deserializedNode = deSerialize(node);
+            if(path != null) {
+                deserializedPath = InstanceIdentifierUtils.fromSerializable(path, this);
+            }
+
+            return deserializedNode;
         }
 
         private NormalizedNode deSerialize(NormalizedNodeMessages.Node node){
@@ -526,18 +509,6 @@ public class NormalizedNodeSerializer {
                 this, path);
         }
 
-        @Override public String getNamespace(int namespace) {
-            return node.getCode(namespace);
-        }
-
-        @Override public String getRevision(int revision) {
-            return node.getCode(revision);
-        }
-
-        @Override public String getLocalName(int localName) {
-            return node.getCode(localName);
-        }
-
         public YangInstanceIdentifier.PathArgument deSerialize(
             NormalizedNodeMessages.PathArgument pathArgument) {
             return PathArgumentSerializer.deSerialize(this, pathArgument);
index eebd58013ab0ed62897d575b9c82535733a311b8..2d6d738b76b981c2aad11eef308edcfe2d2434e5 100644 (file)
@@ -42,20 +42,20 @@ public enum NormalizedNodeType {
     public static NormalizedNodeType getSerializableNodeType(NormalizedNode node){
         Preconditions.checkNotNull(node, "node should not be null");
 
-        if(node instanceof ContainerNode){
-            return CONTAINER_NODE_TYPE;
-        } else if(node instanceof LeafNode){
+        if(node instanceof LeafNode){
             return LEAF_NODE_TYPE;
-        } else if(node instanceof MapNode){
-            return MAP_NODE_TYPE;
+        } else if(node instanceof LeafSetEntryNode){
+            return LEAF_SET_ENTRY_NODE_TYPE;
         } else if(node instanceof MapEntryNode){
             return MAP_ENTRY_NODE_TYPE;
+        } else if(node instanceof ContainerNode){
+            return CONTAINER_NODE_TYPE;
+        } else if(node instanceof MapNode){
+            return MAP_NODE_TYPE;
         } else if(node instanceof AugmentationNode){
             return AUGMENTATION_NODE_TYPE;
         } else if(node instanceof LeafSetNode){
             return LEAF_SET_NODE_TYPE;
-        } else if(node instanceof LeafSetEntryNode){
-            return LEAF_SET_ENTRY_NODE_TYPE;
         } else if(node instanceof ChoiceNode){
             return CHOICE_NODE_TYPE;
         } else if(node instanceof OrderedLeafSetNode){
@@ -69,6 +69,7 @@ public enum NormalizedNodeType {
         } else if(node instanceof AnyXmlNode){
             return ANY_XML_NODE_TYPE;
         }
+
         throw new IllegalArgumentException("Node type unknown : " + node.getClass().getSimpleName());
     }
 
index 4fb676e5189bcb70158cccd1a563f3e54ba36405..bf10316fd5d8b795154a1caf6d827e1e911d1d5c 100644 (file)
@@ -9,28 +9,28 @@
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
 import com.google.common.base.Preconditions;
-
 import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
 import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
-
 import static org.opendaylight.controller.cluster.datastore.node.utils.serialization.PathArgumentType.getSerializablePathArgumentType;
 
 public class PathArgumentSerializer {
     private static final String REVISION_ARG = "?revision=";
-    private static final Map<Class, PathArgumentAttributesGetter> pathArgumentAttributesGetters = new HashMap<>();
+    private static final Map<Class<?>, PathArgumentAttributesGetter> pathArgumentAttributesGetters = new HashMap<>();
 
-    public static NormalizedNodeMessages.PathArgument serialize(NormalizedNodeSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument){
+    public static NormalizedNodeMessages.PathArgument serialize(QNameSerializationContext context,
+            YangInstanceIdentifier.PathArgument pathArgument){
         Preconditions.checkNotNull(context, "context should not be null");
         Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
 
@@ -53,7 +53,8 @@ public class PathArgumentSerializer {
     }
 
 
-    public static YangInstanceIdentifier.PathArgument deSerialize(NormalizedNodeDeSerializationContext context, NormalizedNodeMessages.PathArgument pathArgument){
+    public static YangInstanceIdentifier.PathArgument deSerialize(QNameDeSerializationContext context,
+            NormalizedNodeMessages.PathArgument pathArgument){
         Preconditions.checkNotNull(context, "context should not be null");
         Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
 
@@ -62,18 +63,15 @@ public class PathArgumentSerializer {
 
 
     private static interface PathArgumentAttributesGetter {
-        Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(NormalizedNodeSerializationContext context,
-            YangInstanceIdentifier.PathArgument pathArgument);
+        Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
+                QNameSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument);
     }
 
     static {
         pathArgumentAttributesGetters.put(YangInstanceIdentifier.NodeWithValue.class, new PathArgumentAttributesGetter() {
             @Override
             public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
-                NormalizedNodeSerializationContext context,
-                YangInstanceIdentifier.PathArgument pathArgument) {
-                List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
-                    new ArrayList<>();
+                    QNameSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument) {
 
                 YangInstanceIdentifier.NodeWithValue identifier
                     = (YangInstanceIdentifier.NodeWithValue) pathArgument;
@@ -81,62 +79,52 @@ public class PathArgumentSerializer {
                 NormalizedNodeMessages.PathArgumentAttribute attribute =
                     buildAttribute(context, null, identifier.getValue());
 
-                attributes.add(attribute);
-
-                return attributes;
-
+                return Arrays.asList(attribute);
             }
         });
 
         pathArgumentAttributesGetters.put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, new PathArgumentAttributesGetter() {
             @Override
             public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
-                NormalizedNodeSerializationContext context,
-                YangInstanceIdentifier.PathArgument pathArgument) {
-
-                List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
-                    new ArrayList<>();
+                    QNameSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument) {
 
                 YangInstanceIdentifier.NodeIdentifierWithPredicates identifier
                     = (YangInstanceIdentifier.NodeIdentifierWithPredicates) pathArgument;
 
-                for (QName key : identifier.getKeyValues().keySet()) {
-                    Object value = identifier.getKeyValues().get(key);
+                Map<QName, Object> keyValues = identifier.getKeyValues();
+                List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
+                        new ArrayList<>(keyValues.size());
+                for (Entry<QName, Object> e : keyValues.entrySet()) {
                     NormalizedNodeMessages.PathArgumentAttribute attribute =
-                        buildAttribute(context, key, value);
+                        buildAttribute(context, e.getKey(), e.getValue());
 
                     attributes.add(attribute);
-
                 }
 
                 return attributes;
-
             }
         });
 
         pathArgumentAttributesGetters.put(YangInstanceIdentifier.AugmentationIdentifier.class, new PathArgumentAttributesGetter() {
             @Override
             public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
-                NormalizedNodeSerializationContext context,
-                YangInstanceIdentifier.PathArgument pathArgument) {
-
-                List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
-                    new ArrayList<>();
+                    QNameSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument) {
 
                 YangInstanceIdentifier.AugmentationIdentifier identifier
                     = (YangInstanceIdentifier.AugmentationIdentifier) pathArgument;
 
-                for (QName key : identifier.getPossibleChildNames()) {
+                Set<QName> possibleChildNames = identifier.getPossibleChildNames();
+                List<NormalizedNodeMessages.PathArgumentAttribute> attributes =
+                        new ArrayList<>(possibleChildNames.size());
+                for (QName key : possibleChildNames) {
                     Object value = key;
                     NormalizedNodeMessages.PathArgumentAttribute attribute =
                         buildAttribute(context, key, value);
 
                     attributes.add(attribute);
-
                 }
 
                 return attributes;
-
             }
         });
 
@@ -144,14 +132,14 @@ public class PathArgumentSerializer {
         pathArgumentAttributesGetters.put(YangInstanceIdentifier.NodeIdentifier.class, new PathArgumentAttributesGetter() {
             @Override
             public Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> get(
-                NormalizedNodeSerializationContext context,
-                YangInstanceIdentifier.PathArgument pathArgument) {
+                    QNameSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument) {
                 return Collections.emptyList();
             }
         });
     }
 
-    private static NormalizedNodeMessages.PathArgumentAttribute buildAttribute(NormalizedNodeSerializationContext context,QName name, Object value){
+    private static NormalizedNodeMessages.PathArgumentAttribute buildAttribute(
+            QNameSerializationContext context, QName name, Object value) {
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder =
             NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
@@ -162,8 +150,9 @@ public class PathArgumentSerializer {
 
     }
 
-    private static NormalizedNodeMessages.QName.Builder encodeQName(NormalizedNodeSerializationContext context, QName qName){
-        if(qName == null){
+    private static NormalizedNodeMessages.QName.Builder encodeQName(QNameSerializationContext context,
+            QName qName) {
+        if(qName == null) {
             return NormalizedNodeMessages.QName.getDefaultInstance().toBuilder();
         }
         NormalizedNodeMessages.QName.Builder qNameBuilder =
@@ -179,15 +168,13 @@ public class PathArgumentSerializer {
     }
 
     private static Iterable<? extends NormalizedNodeMessages.PathArgumentAttribute> getPathArgumentAttributes(
-            NormalizedNodeSerializationContext context,
-            YangInstanceIdentifier.PathArgument pathArgument) {
+            QNameSerializationContext context, YangInstanceIdentifier.PathArgument pathArgument) {
 
         return pathArgumentAttributesGetters.get(pathArgument.getClass()).get(context, pathArgument);
-
     }
 
 
-    private static String qNameToString(NormalizedNodeDeSerializationContext context,
+    private static String qNameToString(QNameDeSerializationContext context,
         NormalizedNodeMessages.QName qName){
         // If this serializer is used qName cannot be null (see encodeQName)
         // adding null check only in case someone tried to deSerialize a protocol buffer node
@@ -219,8 +206,7 @@ public class PathArgumentSerializer {
      * @return MD-SAL PathArgument
      */
     private static YangInstanceIdentifier.PathArgument parsePathArgument(
-        NormalizedNodeDeSerializationContext context,
-        NormalizedNodeMessages.PathArgument pathArgument) {
+            QNameDeSerializationContext context, NormalizedNodeMessages.PathArgument pathArgument) {
 
         switch(PathArgumentType.values()[pathArgument.getIntType()]){
             case NODE_IDENTIFIER_WITH_VALUE : {
@@ -264,8 +250,8 @@ public class PathArgumentSerializer {
     }
 
     private static Map<QName, Object> toAttributesMap(
-        NormalizedNodeDeSerializationContext context,
-        List<NormalizedNodeMessages.PathArgumentAttribute> attributesList) {
+            QNameDeSerializationContext context,
+            List<NormalizedNodeMessages.PathArgumentAttribute> attributesList) {
 
         Map<QName, Object> map;
         if(attributesList.size() == 1) {
@@ -287,7 +273,8 @@ public class PathArgumentSerializer {
         return map;
     }
 
-    private static Object parseAttribute(NormalizedNodeDeSerializationContext context, NormalizedNodeMessages.PathArgumentAttribute attribute){
+    private static Object parseAttribute(QNameDeSerializationContext context,
+            NormalizedNodeMessages.PathArgumentAttribute attribute){
         return ValueSerializer.deSerialize(context, attribute);
     }
 
index 20009d8347564c59d6f98ff537324938f6168a87..58a09ae88599204a4414f9844db1bb57e032be32 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
 
-import com.google.common.base.Preconditions;
+import java.util.Map;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import com.google.common.collect.ImmutableMap;
 
 public enum PathArgumentType {
     AUGMENTATION_IDENTIFIER,
@@ -17,19 +18,21 @@ public enum PathArgumentType {
     NODE_IDENTIFIER_WITH_VALUE,
     NODE_IDENTIFIER_WITH_PREDICATES;
 
+    private static Map<Class<?>, PathArgumentType> CLASS_TO_ENUM_MAP =
+            ImmutableMap.<Class<?>, PathArgumentType>builder().
+                put(YangInstanceIdentifier.AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER).
+                put(YangInstanceIdentifier.NodeIdentifier.class, NODE_IDENTIFIER).
+                put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES).
+                put(YangInstanceIdentifier.NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build();
+
     public static int getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){
-        Preconditions.checkNotNull(pathArgument, "pathArgument should not be null");
-
-        if(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier){
-            return AUGMENTATION_IDENTIFIER.ordinal();
-        } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifier){
-            return NODE_IDENTIFIER.ordinal();
-        } else if(pathArgument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates){
-            return NODE_IDENTIFIER_WITH_PREDICATES.ordinal();
-        } else if(pathArgument instanceof YangInstanceIdentifier.NodeWithValue){
-            return NODE_IDENTIFIER_WITH_VALUE.ordinal();
+
+        PathArgumentType type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());
+        if(type == null) {
+            throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument);
         }
-        throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument.toString());
+
+        return type.ordinal();
     }
 
 }
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameDeSerializationContext.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameDeSerializationContext.java
new file mode 100644 (file)
index 0000000..ca9ead7
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+/**
+ * Interface that provides methods which help in decoding components of a QName.
+ *
+ * @author Thomas Pantelis
+ */
+public interface QNameDeSerializationContext {
+    String getNamespace(int namespace);
+
+    String getRevision(int revision);
+
+    String getLocalName(int localName);
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameDeSerializationContextImpl.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameDeSerializationContextImpl.java
new file mode 100644 (file)
index 0000000..ac3d362
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import java.util.List;
+
+/**
+ * Implementation of the QNameDeSerializationContext interface.
+ *
+ * @author Thomas Pantelis
+ */
+public class QNameDeSerializationContextImpl implements QNameDeSerializationContext {
+
+    private final List<String> codeList;
+
+    public QNameDeSerializationContextImpl(List<String> codeList) {
+        this.codeList = codeList;
+    }
+
+    @Override
+    public String getNamespace(int namespace) {
+        return codeList.get(namespace);
+    }
+
+    @Override
+    public String getRevision(int revision) {
+        return codeList.get(revision);
+    }
+
+    @Override
+    public String getLocalName(int localName) {
+        return codeList.get(localName);
+    }
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameSerializationContext.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameSerializationContext.java
new file mode 100644 (file)
index 0000000..9096add
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import java.net.URI;
+import java.util.Date;
+
+/**
+ * Interface that provides methods which help in encoding components of a QName.
+ *
+ * @author Thomas Pantelis
+ */
+public interface QNameSerializationContext {
+    int addNamespace(URI namespace);
+
+    int addRevision(Date revision);
+
+    int addLocalName(String localName);
+
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameSerializationContextImpl.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/QNameSerializationContextImpl.java
new file mode 100644 (file)
index 0000000..09fe2ef
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.serialization;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+
+/**
+ * Implementation of the QNameSerializationContext interface.
+ *
+ * @author Thomas Pantelis
+ */
+public class QNameSerializationContextImpl implements QNameSerializationContext {
+
+    private final Map<Object, Integer> codeMap = new HashMap<>();
+    private final List<String> codes = new ArrayList<>();
+
+    public List<String> getCodes() {
+        return codes;
+    }
+
+    @Override public int addNamespace(URI namespace) {
+        int namespaceInt = getCode(namespace);
+
+        if(namespaceInt == -1) {
+            namespaceInt = addCode(namespace, namespace.toString());
+        }
+        return namespaceInt;
+    }
+
+    @Override public int addRevision(Date revision) {
+        if(revision == null){
+            return -1;
+        }
+
+        int revisionInt = getCode(revision);
+        if(revisionInt == -1) {
+            String formattedRevision =
+                SimpleDateFormatUtil.getRevisionFormat().format(revision);
+            revisionInt = addCode(revision, formattedRevision);
+        }
+        return revisionInt;
+    }
+
+    @Override public int addLocalName(String localName) {
+        int localNameInt = getCode(localName);
+        if(localNameInt == -1) {
+            localNameInt = addCode(localName, localName);
+        }
+        return localNameInt;
+
+    }
+
+    private int addCode(Object code, String codeStr){
+        int count = codes.size();
+        codes.add(codeStr);
+        codeMap.put(code, Integer.valueOf(count));
+        return count;
+    }
+
+    private int getCode(Object code){
+        Integer value = codeMap.get(code);
+        return value == null ? -1 : value.intValue();
+    }
+}
index 8def754f117792ef8e02f327455a9aa54785cf3f..6a843f57c7718fb76911e90649b7194e3b6db0bb 100644 (file)
@@ -20,12 +20,12 @@ import java.util.Set;
 
 public class ValueSerializer {
     public static void serialize(NormalizedNodeMessages.Node.Builder builder,
-        NormalizedNodeSerializationContext context, Object value){
+            QNameSerializationContext context, Object value) {
         builder.setIntValueType(ValueType.getSerializableType(value).ordinal());
 
         if(value instanceof YangInstanceIdentifier) {
             builder.setInstanceIdentifierValue(
-                InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value));
+                InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
         } else if(value instanceof Set) {
             Set set = (Set) value;
             if(!set.isEmpty()){
@@ -44,26 +44,25 @@ public class ValueSerializer {
     }
 
     public static void serialize(NormalizedNodeMessages.PathArgumentAttribute.Builder builder,
-        NormalizedNodeSerializationContext context, Object value){
+            QNameSerializationContext context, Object value){
 
         builder.setType(ValueType.getSerializableType(value).ordinal());
         builder.setValue(value.toString());
     }
 
-    public static Object deSerialize(
-        NormalizedNodeDeSerializationContext context, NormalizedNodeMessages.Node node) {
+    public static Object deSerialize(QNameDeSerializationContext context,
+            NormalizedNodeMessages.Node node) {
         if(node.getIntValueType() == ValueType.YANG_IDENTIFIER_TYPE.ordinal()){
             return InstanceIdentifierUtils.fromSerializable(
-                node.getInstanceIdentifierValue());
+                    node.getInstanceIdentifierValue(), context);
         } else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
             return new HashSet(node.getBitsValueList());
         }
         return deSerializeBasicTypes(node.getIntValueType(), node.getValue());
     }
 
-    public static Object deSerialize(
-        NormalizedNodeDeSerializationContext context,
-        NormalizedNodeMessages.PathArgumentAttribute attribute) {
+    public static Object deSerialize(QNameDeSerializationContext context,
+            NormalizedNodeMessages.PathArgumentAttribute attribute) {
         return deSerializeBasicTypes(attribute.getType(), attribute.getValue());
     }
 
index 0bb0d4fe8798b8623dc433d659f6ea550096c41e..64a1e3a18a4a89fb2af3c681a93834d9eeb1589d 100644 (file)
@@ -12,12 +12,17 @@ package org.opendaylight.controller.cluster.datastore.util;
 
 import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
 import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.PathArgumentSerializer;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameDeSerializationContext;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameDeSerializationContextImpl;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameSerializationContext;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameSerializationContextImpl;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -41,61 +46,54 @@ public class InstanceIdentifierUtils {
     protected static final Logger logger = LoggerFactory
         .getLogger(InstanceIdentifierUtils.class);
 
-    @Deprecated
-    public static YangInstanceIdentifier from(String path) {
-        String[] ids = path.split("/");
-
-        List<YangInstanceIdentifier.PathArgument> pathArguments =
-            new ArrayList<>();
-        for (String nodeId : ids) {
-            if (!"".equals(nodeId)) {
-                pathArguments
-                    .add(NodeIdentifierFactory.getArgument(nodeId));
-            }
-        }
-        final YangInstanceIdentifier instanceIdentifier =
-            YangInstanceIdentifier.create(pathArguments);
-        return instanceIdentifier;
-    }
-
-
     /**
      * Convert an MD-SAL YangInstanceIdentifier into a protocol buffer version of it
      *
      * @param path an MD-SAL YangInstanceIdentifier
      * @return a protocol buffer version of the MD-SAL YangInstanceIdentifier
      */
-    public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path){
+    public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path) {
+        QNameSerializationContextImpl context = new QNameSerializationContextImpl();
+        Builder builder = toSerializableBuilder(path, context);
+        return builder.addAllCode(context.getCodes()).build();
+    }
+
+    public static NormalizedNodeMessages.InstanceIdentifier toSerializable(
+            YangInstanceIdentifier path, QNameSerializationContext context) {
+        return toSerializableBuilder(path, context).build();
+    }
+
+    private static NormalizedNodeMessages.InstanceIdentifier.Builder toSerializableBuilder(
+            YangInstanceIdentifier path, QNameSerializationContext context) {
         NormalizedNodeMessages.InstanceIdentifier.Builder builder =
             NormalizedNodeMessages.InstanceIdentifier.newBuilder();
 
         try {
-
-            for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument pathArgument : path
-                .getPathArguments()) {
-
-                String nodeType = "";
-                if(!(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier)){
-                    nodeType = pathArgument.getNodeType().toString();
+            for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.
+                                            PathArgument pathArgument : path.getPathArguments()) {
+                NormalizedNodeMessages.PathArgument serializablePathArgument;
+                if(context == null) {
+                    String nodeType = "";
+                    if(!(pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier)){
+                        nodeType = pathArgument.getNodeType().toString();
+                    }
+
+                    serializablePathArgument = NormalizedNodeMessages.PathArgument.newBuilder()
+                            .setValue(pathArgument.toString())
+                            .setType(pathArgument.getClass().getSimpleName())
+                            .setNodeType(NormalizedNodeMessages.QName.newBuilder().setValue(nodeType))
+                            .addAllAttributes(getPathArgumentAttributes(pathArgument)).build();
+                } else {
+                    serializablePathArgument = PathArgumentSerializer.serialize(context, pathArgument);
                 }
 
-                NormalizedNodeMessages.PathArgument serializablePathArgument =
-                    NormalizedNodeMessages.PathArgument.newBuilder()
-                        .setValue(pathArgument.toString())
-                        .setType(pathArgument.getClass().getSimpleName())
-                        .setNodeType(NormalizedNodeMessages.QName.newBuilder()
-                            .setValue(nodeType))
-                        .addAllAttributes(getPathArgumentAttributes(
-                            pathArgument))
-                        .build();
-
                 builder.addArguments(serializablePathArgument);
             }
-
         } catch(Exception e){
             logger.error("An exception occurred", e);
         }
-        return builder.build();
+
+        return builder;
     }
 
 
@@ -106,21 +104,24 @@ public class InstanceIdentifierUtils {
      * @param path a protocol buffer version of the MD-SAL YangInstanceIdentifier
      * @return  an MD-SAL YangInstanceIdentifier
      */
-    public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path){
-
-        List<YangInstanceIdentifier.PathArgument> pathArguments =
-            new ArrayList<>();
+    public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path) {
+        return fromSerializable(path, new QNameDeSerializationContextImpl(path.getCodeList()));
+    }
 
-        for(NormalizedNodeMessages.PathArgument pathArgument : path.getArgumentsList()){
+    public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path,
+            QNameDeSerializationContext context) {
 
-            pathArguments
-                .add(parsePathArgument(pathArgument));
+        List<YangInstanceIdentifier.PathArgument> pathArguments = new ArrayList<>();
 
+        for(NormalizedNodeMessages.PathArgument pathArgument : path.getArgumentsList()) {
+            if(context == null || pathArgument.hasType()) {
+                pathArguments.add(parsePathArgument(pathArgument));
+            } else {
+                pathArguments.add(PathArgumentSerializer.deSerialize(context, pathArgument));
+            }
         }
 
-        final YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier.create(pathArguments);
-
-        return instanceIdentifier;
+        return YangInstanceIdentifier.create(pathArguments);
     }
 
     /**
@@ -218,7 +219,8 @@ public class InstanceIdentifierUtils {
      * @param pathArgument protocol buffer PathArgument
      * @return MD-SAL PathArgument
      */
-    private static YangInstanceIdentifier.PathArgument parsePathArgument(NormalizedNodeMessages.PathArgument pathArgument) {
+    private static YangInstanceIdentifier.PathArgument parsePathArgument(
+            NormalizedNodeMessages.PathArgument pathArgument) {
         if (YangInstanceIdentifier.NodeWithValue.class.getSimpleName().equals(pathArgument.getType())) {
 
             YangInstanceIdentifier.NodeWithValue nodeWithValue =
index 3926bc7dc347d611a67854ab14015734424d749b..e7f2c361aeb0615c52ff44002ee1b35451396b46 100644 (file)
@@ -4176,6 +4176,50 @@ public final class NormalizedNodeMessages {
      */
     org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder getArgumentsOrBuilder(
         int index);
+
+    // repeated string code = 2;
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    java.util.List<java.lang.String>
+    getCodeList();
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    int getCodeCount();
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    java.lang.String getCode(int index);
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    com.google.protobuf.ByteString
+        getCodeBytes(int index);
   }
   /**
    * Protobuf type {@code org.opendaylight.controller.mdsal.InstanceIdentifier}
@@ -4236,6 +4280,14 @@ public final class NormalizedNodeMessages {
               arguments_.add(input.readMessage(org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.PARSER, extensionRegistry));
               break;
             }
+            case 18: {
+              if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
+                code_ = new com.google.protobuf.LazyStringArrayList();
+                mutable_bitField0_ |= 0x00000002;
+              }
+              code_.add(input.readBytes());
+              break;
+            }
           }
         }
       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -4247,6 +4299,9 @@ public final class NormalizedNodeMessages {
         if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
           arguments_ = java.util.Collections.unmodifiableList(arguments_);
         }
+        if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
+          code_ = new com.google.protobuf.UnmodifiableLazyStringList(code_);
+        }
         this.unknownFields = unknownFields.build();
         makeExtensionsImmutable();
       }
@@ -4314,8 +4369,63 @@ public final class NormalizedNodeMessages {
       return arguments_.get(index);
     }
 
+    // repeated string code = 2;
+    public static final int CODE_FIELD_NUMBER = 2;
+    private com.google.protobuf.LazyStringList code_;
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    public java.util.List<java.lang.String>
+        getCodeList() {
+      return code_;
+    }
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    public int getCodeCount() {
+      return code_.size();
+    }
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    public java.lang.String getCode(int index) {
+      return code_.get(index);
+    }
+    /**
+     * <code>repeated string code = 2;</code>
+     *
+     * <pre>
+     * A list of string codes which can be used for any repeated strings in the path args. This is
+     * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+     * that contains the codes.
+     * </pre>
+     */
+    public com.google.protobuf.ByteString
+        getCodeBytes(int index) {
+      return code_.getByteString(index);
+    }
+
     private void initFields() {
       arguments_ = java.util.Collections.emptyList();
+      code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
     }
     private byte memoizedIsInitialized = -1;
     public final boolean isInitialized() {
@@ -4338,6 +4448,9 @@ public final class NormalizedNodeMessages {
       for (int i = 0; i < arguments_.size(); i++) {
         output.writeMessage(1, arguments_.get(i));
       }
+      for (int i = 0; i < code_.size(); i++) {
+        output.writeBytes(2, code_.getByteString(i));
+      }
       getUnknownFields().writeTo(output);
     }
 
@@ -4351,6 +4464,15 @@ public final class NormalizedNodeMessages {
         size += com.google.protobuf.CodedOutputStream
           .computeMessageSize(1, arguments_.get(i));
       }
+      {
+        int dataSize = 0;
+        for (int i = 0; i < code_.size(); i++) {
+          dataSize += com.google.protobuf.CodedOutputStream
+            .computeBytesSizeNoTag(code_.getByteString(i));
+        }
+        size += dataSize;
+        size += 1 * getCodeList().size();
+      }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
@@ -4474,6 +4596,8 @@ public final class NormalizedNodeMessages {
         } else {
           argumentsBuilder_.clear();
         }
+        code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+        bitField0_ = (bitField0_ & ~0x00000002);
         return this;
       }
 
@@ -4510,6 +4634,12 @@ public final class NormalizedNodeMessages {
         } else {
           result.arguments_ = argumentsBuilder_.build();
         }
+        if (((bitField0_ & 0x00000002) == 0x00000002)) {
+          code_ = new com.google.protobuf.UnmodifiableLazyStringList(
+              code_);
+          bitField0_ = (bitField0_ & ~0x00000002);
+        }
+        result.code_ = code_;
         onBuilt();
         return result;
       }
@@ -4551,6 +4681,16 @@ public final class NormalizedNodeMessages {
             }
           }
         }
+        if (!other.code_.isEmpty()) {
+          if (code_.isEmpty()) {
+            code_ = other.code_;
+            bitField0_ = (bitField0_ & ~0x00000002);
+          } else {
+            ensureCodeIsMutable();
+            code_.addAll(other.code_);
+          }
+          onChanged();
+        }
         this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
@@ -4824,6 +4964,153 @@ public final class NormalizedNodeMessages {
         return argumentsBuilder_;
       }
 
+      // repeated string code = 2;
+      private com.google.protobuf.LazyStringList code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+      private void ensureCodeIsMutable() {
+        if (!((bitField0_ & 0x00000002) == 0x00000002)) {
+          code_ = new com.google.protobuf.LazyStringArrayList(code_);
+          bitField0_ |= 0x00000002;
+         }
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public java.util.List<java.lang.String>
+          getCodeList() {
+        return java.util.Collections.unmodifiableList(code_);
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public int getCodeCount() {
+        return code_.size();
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public java.lang.String getCode(int index) {
+        return code_.get(index);
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public com.google.protobuf.ByteString
+          getCodeBytes(int index) {
+        return code_.getByteString(index);
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public Builder setCode(
+          int index, java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  ensureCodeIsMutable();
+        code_.set(index, value);
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public Builder addCode(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  ensureCodeIsMutable();
+        code_.add(value);
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public Builder addAllCode(
+          java.lang.Iterable<java.lang.String> values) {
+        ensureCodeIsMutable();
+        super.addAll(values, code_);
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public Builder clearCode() {
+        code_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+        bitField0_ = (bitField0_ & ~0x00000002);
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>repeated string code = 2;</code>
+       *
+       * <pre>
+       * A list of string codes which can be used for any repeated strings in the path args. This is
+       * optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+       * that contains the codes.
+       * </pre>
+       */
+      public Builder addCodeBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  ensureCodeIsMutable();
+        code_.add(value);
+        onChanged();
+        return this;
+      }
+
       // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.InstanceIdentifier)
     }
 
@@ -9998,30 +10285,30 @@ public final class NormalizedNodeMessages {
       "controller.mdsal.PathArgumentAttribute\022@" +
       "\n\nattributes\030\005 \003(\0132,.org.opendaylight.co" +
       "ntroller.mdsal.Attribute\022\017\n\007intType\030\006 \001(" +
-      "\005\"X\n\022InstanceIdentifier\022B\n\targuments\030\001 \003" +
+      "\005\"f\n\022InstanceIdentifier\022B\n\targuments\030\001 \003" +
       "(\0132/.org.opendaylight.controller.mdsal.P" +
-      "athArgument\"\245\003\n\004Node\022\014\n\004path\030\001 \001(\t\022\014\n\004ty" +
-      "pe\030\002 \001(\t\022E\n\014pathArgument\030\003 \001(\0132/.org.ope" +
-      "ndaylight.controller.mdsal.PathArgument\022" +
-      "\017\n\007intType\030\004 \001(\005\022@\n\nattributes\030\005 \003(\0132,.o",
-      "rg.opendaylight.controller.mdsal.Attribu" +
-      "te\0226\n\005child\030\006 \003(\0132\'.org.opendaylight.con" +
-      "troller.mdsal.Node\022\r\n\005value\030\007 \001(\t\022\021\n\tval" +
-      "ueType\030\010 \001(\t\022\024\n\014intValueType\030\t \001(\005\022V\n\027in" +
-      "stanceIdentifierValue\030\n \001(\01325.org.openda" +
-      "ylight.controller.mdsal.InstanceIdentifi" +
-      "er\022\021\n\tbitsValue\030\013 \003(\t\022\014\n\004code\030\014 \003(\t\"`\n\tC" +
-      "ontainer\022\022\n\nparentPath\030\001 \002(\t\022?\n\016normaliz" +
-      "edNode\030\002 \001(\0132\'.org.opendaylight.controll" +
-      "er.mdsal.Node\"\246\001\n\014NodeMapEntry\022U\n\026instan",
-      "ceIdentifierPath\030\001 \002(\01325.org.opendayligh" +
-      "t.controller.mdsal.InstanceIdentifier\022?\n" +
-      "\016normalizedNode\030\002 \001(\0132\'.org.opendaylight" +
-      ".controller.mdsal.Node\"N\n\007NodeMap\022C\n\nmap" +
-      "Entries\030\001 \003(\0132/.org.opendaylight.control" +
-      "ler.mdsal.NodeMapEntryBO\n5org.opendaylig" +
-      "ht.controller.protobuff.messages.commonB" +
-      "\026NormalizedNodeMessages"
+      "athArgument\022\014\n\004code\030\002 \003(\t\"\245\003\n\004Node\022\014\n\004pa" +
+      "th\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022E\n\014pathArgument\030\003" +
+      " \001(\0132/.org.opendaylight.controller.mdsal" +
+      ".PathArgument\022\017\n\007intType\030\004 \001(\005\022@\n\nattrib",
+      "utes\030\005 \003(\0132,.org.opendaylight.controller" +
+      ".mdsal.Attribute\0226\n\005child\030\006 \003(\0132\'.org.op" +
+      "endaylight.controller.mdsal.Node\022\r\n\005valu" +
+      "e\030\007 \001(\t\022\021\n\tvalueType\030\010 \001(\t\022\024\n\014intValueTy" +
+      "pe\030\t \001(\005\022V\n\027instanceIdentifierValue\030\n \001(" +
+      "\01325.org.opendaylight.controller.mdsal.In" +
+      "stanceIdentifier\022\021\n\tbitsValue\030\013 \003(\t\022\014\n\004c" +
+      "ode\030\014 \003(\t\"`\n\tContainer\022\022\n\nparentPath\030\001 \002" +
+      "(\t\022?\n\016normalizedNode\030\002 \001(\0132\'.org.openday" +
+      "light.controller.mdsal.Node\"\246\001\n\014NodeMapE",
+      "ntry\022U\n\026instanceIdentifierPath\030\001 \002(\01325.o" +
+      "rg.opendaylight.controller.mdsal.Instanc" +
+      "eIdentifier\022?\n\016normalizedNode\030\002 \001(\0132\'.or" +
+      "g.opendaylight.controller.mdsal.Node\"N\n\007" +
+      "NodeMap\022C\n\nmapEntries\030\001 \003(\0132/.org.openda" +
+      "ylight.controller.mdsal.NodeMapEntryBO\n5" +
+      "org.opendaylight.controller.protobuff.me" +
+      "ssages.commonB\026NormalizedNodeMessages"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -10057,7 +10344,7 @@ public final class NormalizedNodeMessages {
           internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_org_opendaylight_controller_mdsal_InstanceIdentifier_descriptor,
-              new java.lang.String[] { "Arguments", });
+              new java.lang.String[] { "Arguments", "Code", });
           internal_static_org_opendaylight_controller_mdsal_Node_descriptor =
             getDescriptor().getMessageTypes().get(5);
           internal_static_org_opendaylight_controller_mdsal_Node_fieldAccessorTable = new
index 0b3ff21eb78737aa58450db900f5877b217718b1..356bfbf684295a0392198dd0b02d92fcf12b4d25 100644 (file)
@@ -37,6 +37,11 @@ message PathArgument {
 
 message InstanceIdentifier {
   repeated PathArgument arguments=1;
+  
+  // A list of string codes which can be used for any repeated strings in the path args. This is
+  // optional - an InstanceIdentifier may be encoded as part of another message, eg NormalizedNode,
+  // that contains the codes. 
+  repeated string code = 2;
 }
 
 message Node{
index a9f9c722deefd942f3259fea3f05a929d42aa827..6de1083cbed63bbbf2f6ccff5f854c57dbc2c00a 100644 (file)
@@ -68,15 +68,12 @@ public class NormalizedNodeToNodeCodecTest {
         new NormalizedNodeToNodeCodec(schemaContext);
     long start = System.currentTimeMillis();
     Container container =
-        codec.encode(instanceIdentifierFromString(id), output);
+        codec.encode(output);
     long end = System.currentTimeMillis();
 
     System.out.println("Timetaken to encode :"+(end-start));
 
     assertNotNull(container);
-    assertEquals(id, container.getParentPath() + "/"
-        + NormalizedNodeSerializer.deSerialize(container.getNormalizedNode(),
-        container.getNormalizedNode().getPathArgument()));
 
     // Decode the normalized node from the ProtocolBuffer form
     // first get the node representation of normalized node
@@ -84,7 +81,7 @@ public class NormalizedNodeToNodeCodecTest {
 
     start = System.currentTimeMillis();
     NormalizedNode<?, ?> normalizedNode =
-        codec.decode(instanceIdentifierFromString(id), node);
+        codec.decode(node);
     end = System.currentTimeMillis();
 
     System.out.println("Timetaken to decode :"+(end-start));
@@ -102,26 +99,18 @@ public class NormalizedNodeToNodeCodecTest {
         new NormalizedNodeToNodeCodec(schemaContext);
 
     Container container =
-        normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder()
-            .build(), documentOne);
+        normalizedNodeToNodeCodec.encode(documentOne);
 
 
     final NormalizedNode<?, ?> decode =
         normalizedNodeToNodeCodec
             .decode(
-                instanceIdentifierFromString("/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"),
                 container.getNormalizedNode());
     assertNotNull(decode);
 
     // let us ensure that the return decode normalized node encode returns same container
     Container containerResult =
-        normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder()
-            .build(), decode);
-
-    assertEquals(container.getParentPath(), containerResult.getParentPath());
-
-    assertEquals(containerResult.getNormalizedNode().getChildCount(),
-        container.getNormalizedNode().getChildCount());
+        normalizedNodeToNodeCodec.encode(decode);
 
     // check first level children are proper
     List<Node> childrenResult =
@@ -174,11 +163,11 @@ public class NormalizedNodeToNodeCodecTest {
     NormalizedNodeToNodeCodec codec =
         new NormalizedNodeToNodeCodec(schemaContext);
 
-    Container encode = codec.encode(identifier, uno);
+    Container encode = codec.encode(uno);
 
     System.out.println(encode.getNormalizedNode());
 
-    codec.decode(identifier, encode.getNormalizedNode());
+    codec.decode(encode.getNormalizedNode());
   }
 
 }
index ffa8a1059eb49d77195f29954c9ead671abd2d68..d1e3eb202f8faefcafeb548cf2b48ca013b42e91 100644 (file)
@@ -14,15 +14,6 @@ import static junit.framework.TestCase.assertEquals;
 
 public class PathUtilsTest {
 
-    @Test
-    public void getParentPath(){
-        assertEquals("", PathUtils.getParentPath("foobar"));
-        assertEquals("", PathUtils.getParentPath("/a"));
-        assertEquals("/a", PathUtils.getParentPath("/a/b"));
-        assertEquals("/a/b", PathUtils.getParentPath("/a/b/c"));
-        assertEquals("/a/b", PathUtils.getParentPath("a/b/c"));
-    }
-
     @Test
     public void toStringNodeIdentifier(){
         YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifier();
index d1f21ee6f419cacd760ef5c140b51552380e99e4..0990cdd4aa5265bcdaff278fd194b4e659eeaa82 100644 (file)
@@ -40,8 +40,7 @@ public class PathArgumentSerializerTest{
         expectedException.expect(NullPointerException.class);
         expectedException.expectMessage("pathArgument should not be null");
 
-        PathArgumentSerializer.serialize(mock(
-            NormalizedNodeSerializationContext.class), null);
+        PathArgumentSerializer.serialize(mock(QNameSerializationContext.class), null);
 
     }
 
@@ -59,14 +58,13 @@ public class PathArgumentSerializerTest{
         expectedException.expect(NullPointerException.class);
         expectedException.expectMessage("pathArgument should not be null");
 
-        PathArgumentSerializer.deSerialize(mock(NormalizedNodeDeSerializationContext.class), null);
+        PathArgumentSerializer.deSerialize(mock(QNameDeSerializationContext.class), null);
 
     }
 
     @Test
     public void testSerializeNodeIdentifier(){
-        NormalizedNodeSerializationContext serializationContext =
-            mock(NormalizedNodeSerializationContext.class);
+        QNameSerializationContext serializationContext = mock(QNameSerializationContext.class);
 
         when(serializationContext.addLocalName(anyString())).thenReturn(5);
         when(serializationContext.addNamespace(any(URI.class))).thenReturn(10);
@@ -87,8 +85,7 @@ public class PathArgumentSerializerTest{
 
     @Test
     public void testSerializeNodeIdentifierWithValue(){
-        NormalizedNodeSerializationContext serializationContext =
-            mock(NormalizedNodeSerializationContext.class);
+        QNameSerializationContext serializationContext = mock(QNameSerializationContext.class);
 
         when(serializationContext.addLocalName(anyString())).thenReturn(5);
         when(serializationContext.addNamespace(any(URI.class))).thenReturn(10);
@@ -110,9 +107,7 @@ public class PathArgumentSerializerTest{
 
     @Test
     public void testSerializeNodeIdentifierWithPredicates(){
-        NormalizedNodeSerializationContext serializationContext =
-            mock(NormalizedNodeSerializationContext.class);
-
+        QNameSerializationContext serializationContext = mock(QNameSerializationContext.class);
 
         when(serializationContext.addLocalName("test")).thenReturn(5);
         when(serializationContext.addLocalName("child-name")).thenReturn(55);
@@ -150,8 +145,7 @@ public class PathArgumentSerializerTest{
 
     @Test
     public void testSerializeAugmentationIdentifier(){
-        NormalizedNodeSerializationContext serializationContext =
-            mock(NormalizedNodeSerializationContext.class);
+        QNameSerializationContext serializationContext = mock(QNameSerializationContext.class);
 
         when(serializationContext.addLocalName(anyString())).thenReturn(55);
         when(serializationContext.addNamespace(any(URI.class))).thenReturn(66);
index af7a385cbbe0876000eb6d8a457ef4e5312f8fa3..88c269507538ab8f55d40cb06eece12c6a39ac0e 100644 (file)
@@ -5,15 +5,14 @@ import com.google.common.collect.ImmutableSet;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.mockito.Mockito;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Set;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
@@ -27,14 +26,15 @@ public class ValueSerializerTest{
     public void testSerializeShort(){
         short v1 = 5;
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.SHORT_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("5", builder.getValue());
 
-        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 =
+                NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.SHORT_TYPE.ordinal(), builder1.getType());
         assertEquals("5", builder.getValue());
@@ -49,16 +49,15 @@ public class ValueSerializerTest{
 
 
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), expected);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), expected);
 
         assertEquals(ValueType.INT_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("243", builder.getValue());
 
-        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 =
+                NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), expected);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), expected);
 
         assertEquals(ValueType.INT_TYPE.ordinal(), builder1.getType());
         assertEquals("243", builder1.getValue());
@@ -71,16 +70,14 @@ public class ValueSerializerTest{
     public void testSerializeLong(){
         long v1 = 5;
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.LONG_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("5", builder.getValue());
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.LONG_TYPE.ordinal(), builder1.getType());
         assertEquals("5", builder1.getValue());
@@ -91,16 +88,14 @@ public class ValueSerializerTest{
     public void testSerializeByte(){
         byte v1 = 5;
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BYTE_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("5", builder.getValue());
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BYTE_TYPE.ordinal(), builder1.getType());
         assertEquals("5", builder1.getValue());
@@ -110,8 +105,7 @@ public class ValueSerializerTest{
     @Test
     public void testSerializeBits(){
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class),
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class),
             ImmutableSet.of("foo", "bar"));
 
         assertEquals(ValueType.BITS_TYPE.ordinal(), builder.getIntValueType());
@@ -120,8 +114,7 @@ public class ValueSerializerTest{
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class),
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class),
             ImmutableSet.of("foo", "bar"));
 
         assertEquals(ValueType.BITS_TYPE.ordinal(), builder1.getType());
@@ -134,8 +127,7 @@ public class ValueSerializerTest{
         expectedException.expect(IllegalArgumentException.class);
         expectedException.expectMessage("Expected value type to be Bits but was :");
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-                NormalizedNodeSerializationContext.class),
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class),
             ImmutableSet.of(1, 2));
 
     }
@@ -143,16 +135,14 @@ public class ValueSerializerTest{
     @Test
     public void testSerializeEmptyString(){
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class),"");
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class),"");
 
         assertEquals(ValueType.STRING_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("", builder.getValue());
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class),"");
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class),"");
 
         assertEquals(ValueType.STRING_TYPE.ordinal(), builder1.getType());
         assertEquals("", builder1.getValue());
@@ -162,16 +152,15 @@ public class ValueSerializerTest{
     @Test
     public void testSerializeString(){
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class),"foo");
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class),"foo");
 
         assertEquals(ValueType.STRING_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("foo", builder.getValue());
 
-        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 =
+                NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class),"foo");
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class),"foo");
 
         assertEquals(ValueType.STRING_TYPE.ordinal(), builder1.getType());
         assertEquals("foo", builder1.getValue());
@@ -183,15 +172,14 @@ public class ValueSerializerTest{
     public void testSerializeBoolean(){
         boolean v1 = true;
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BOOL_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("true", builder.getValue());
 
-        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 =
+                NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BOOL_TYPE.ordinal(), builder1.getType());
         assertEquals("true", builder1.getValue());
@@ -201,16 +189,14 @@ public class ValueSerializerTest{
     public void testSerializeQName(){
         QName v1 = TestModel.TEST_QNAME;
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.QNAME_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test", builder.getValue());
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.QNAME_TYPE.ordinal(), builder1.getType());
         assertEquals("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test", builder1.getValue());
@@ -222,32 +208,30 @@ public class ValueSerializerTest{
         YangInstanceIdentifier v1 = TestModel.TEST_PATH;
 
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
-
+        QNameSerializationContext mockContext = mock(QNameSerializationContext.class);
+        ValueSerializer.serialize(builder, mockContext, v1);
 
         assertEquals(ValueType.YANG_IDENTIFIER_TYPE.ordinal(), builder.getIntValueType());
         NormalizedNodeMessages.InstanceIdentifier serializedYangInstanceIdentifier =
             builder.getInstanceIdentifierValue();
 
         assertEquals(1, serializedYangInstanceIdentifier.getArgumentsCount());
-        assertEquals(TestModel.TEST_QNAME.toString(), serializedYangInstanceIdentifier.getArguments(0).getNodeType().getValue());
+        Mockito.verify(mockContext).addLocalName(TestModel.TEST_QNAME.getLocalName());
+        Mockito.verify(mockContext).addNamespace(TestModel.TEST_QNAME.getNamespace());
     }
 
     @Test
     public void testSerializeBigInteger(){
         BigInteger v1 = new BigInteger("1000000000000000000000000");
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BIG_INTEGER_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("1000000000000000000000000", builder.getValue());
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
 
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BIG_INTEGER_TYPE.ordinal(), builder1.getType());
         assertEquals("1000000000000000000000000", builder1.getValue());
@@ -258,15 +242,13 @@ public class ValueSerializerTest{
     public void testSerializeBigDecimal(){
         BigDecimal v1 = new BigDecimal("1000000000000000000000000.51616");
         NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder();
-        ValueSerializer.serialize(builder, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BIG_DECIMAL_TYPE.ordinal(), builder.getIntValueType());
         assertEquals("1000000000000000000000000.51616", builder.getValue());
 
         NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder();
-        ValueSerializer.serialize(builder1, mock(
-            NormalizedNodeSerializationContext.class), v1);
+        ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class), v1);
 
         assertEquals(ValueType.BIG_DECIMAL_TYPE.ordinal(), builder1.getType());
         assertEquals("1000000000000000000000000.51616", builder1.getValue());
@@ -280,7 +262,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("25");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof Short);
@@ -294,7 +276,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("25");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof Byte);
@@ -309,7 +291,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("25");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof Integer);
@@ -324,7 +306,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("25");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof Long);
@@ -339,7 +321,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("false");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof Boolean);
@@ -354,7 +336,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue(TestModel.TEST_QNAME.toString());
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof QName);
@@ -369,7 +351,7 @@ public class ValueSerializerTest{
         nodeBuilder.addAllBitsValue(ImmutableList.of("foo", "bar"));
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof Set);
@@ -384,7 +366,6 @@ public class ValueSerializerTest{
         NormalizedNodeMessages.InstanceIdentifier.Builder idBuilder = NormalizedNodeMessages.InstanceIdentifier.newBuilder();
         NormalizedNodeMessages.PathArgument.Builder pathBuilder = NormalizedNodeMessages.PathArgument.newBuilder();
 
-        pathBuilder.setValue(TestModel.TEST_QNAME.toString());
         pathBuilder.setIntType(PathArgumentType.NODE_IDENTIFIER.ordinal());
 
         idBuilder.addArguments(pathBuilder);
@@ -392,9 +373,15 @@ public class ValueSerializerTest{
         nodeBuilder.setIntValueType(ValueType.YANG_IDENTIFIER_TYPE.ordinal());
         nodeBuilder.setInstanceIdentifierValue(idBuilder);
 
-        Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
-                nodeBuilder.build());
+        QNameDeSerializationContext mockContext = mock(QNameDeSerializationContext.class);
+        Mockito.doReturn(TestModel.TEST_QNAME.getNamespace().toString()).when(mockContext).
+                getNamespace(Mockito.anyInt());
+        Mockito.doReturn(TestModel.TEST_QNAME.getLocalName()).when(mockContext).
+                getLocalName(Mockito.anyInt());
+        Mockito.doReturn(TestModel.TEST_QNAME.getFormattedRevision()).when(mockContext).
+                getRevision(Mockito.anyInt());
+
+        Object o = ValueSerializer.deSerialize(mockContext, nodeBuilder.build());
 
         assertTrue(o instanceof YangInstanceIdentifier);
         assertEquals(TestModel.TEST_PATH, o);
@@ -407,8 +394,7 @@ public class ValueSerializerTest{
         nodeBuilder.setIntValueType(ValueType.STRING_TYPE.ordinal());
         nodeBuilder.setValue("25");
 
-        Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+        Object o = ValueSerializer.deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof String);
@@ -423,7 +409,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("25");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof BigInteger);
@@ -438,7 +424,7 @@ public class ValueSerializerTest{
         nodeBuilder.setValue("25");
 
         Object o = ValueSerializer
-            .deSerialize(mock(NormalizedNodeDeSerializationContext.class),
+            .deSerialize(mock(QNameDeSerializationContext.class),
                 nodeBuilder.build());
 
         assertTrue(o instanceof BigDecimal);
index 136748e3416ffa176f60d03cf489e20df0967ced..6cd06e9c1cea610edc3b1fa2799513cfa539c72c 100644 (file)
@@ -12,10 +12,12 @@ package org.opendaylight.controller.cluster.datastore.util;
 
 import org.junit.Assert;
 import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameDeSerializationContext;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameDeSerializationContextImpl;
+import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameSerializationContextImpl;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -23,139 +25,137 @@ import java.util.List;
 
 public class InstanceIdentifierUtilsTest {
 
-  private static QName TEST_QNAME =
-      QName
-          .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test");
-  private static QName NODE_WITH_VALUE_QNAME =
-      QName
-          .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)value");
-  private static QName NODE_WITH_PREDICATES_QNAME =
-      QName
-          .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)pred");
-  private static QName NAME_QNAME =
-      QName
-          .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)name");
-
-  @Test
-  public void testSerializationOfNodeIdentifier() {
-    YangInstanceIdentifier.PathArgument p1 =
-        new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME);
-
-    List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
-
-    arguments.add(p1);
+    private static QName TEST_QNAME = QName
+            .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test");
+    private static QName NODE_WITH_VALUE_QNAME = QName
+            .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)value");
+    private static QName NODE_WITH_PREDICATES_QNAME = QName
+            .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)pred");
+    private static QName NAME_QNAME = QName
+            .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)name");
 
-    YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
+    @Test
+    public void testSerializationOfNodeIdentifier() {
+        YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME);
 
-    NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
-        InstanceIdentifierUtils.toSerializable(expected);
+        List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
 
-    YangInstanceIdentifier actual =
-        InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
+        arguments.add(p1);
 
+        YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
 
-    Assert.assertEquals(expected.getLastPathArgument(),
-        actual.getLastPathArgument());
+        NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
+                InstanceIdentifierUtils.toSerializable(expected);
 
+        YangInstanceIdentifier actual = InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
 
-  }
+        Assert.assertEquals(expected.getLastPathArgument(), actual.getLastPathArgument());
+    }
 
-  @Test
-  public void testSerializationOfNodeWithValue() {
+    @Test
+    public void testSerializationOfNodeWithValue() {
 
-    withValue((short) 1);
-    withValue((long) 2);
-    withValue(3);
-    withValue(true);
+        withValue((short) 1);
+        withValue((long) 2);
+        withValue(3);
+        withValue(true);
 
-  }
+    }
 
-  private void withValue(Object value) {
-    YangInstanceIdentifier.PathArgument p1 =
-        new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME);
+    private void withValue(Object value) {
+        YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME);
 
-    YangInstanceIdentifier.PathArgument p2 =
-        new YangInstanceIdentifier.NodeWithValue(NODE_WITH_VALUE_QNAME, value);
+        YangInstanceIdentifier.PathArgument p2 =
+                new YangInstanceIdentifier.NodeWithValue(NODE_WITH_VALUE_QNAME, value);
 
+        List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
 
-    List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
+        arguments.add(p1);
+        arguments.add(p2);
 
-    arguments.add(p1);
-    arguments.add(p2);
+        YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
 
-    YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
+        NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
+                InstanceIdentifierUtils.toSerializable(expected);
 
-    NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
-        InstanceIdentifierUtils.toSerializable(expected);
+        YangInstanceIdentifier actual = InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
 
-    YangInstanceIdentifier actual =
-        InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
+        Assert.assertEquals(expected.getLastPathArgument(), actual.getLastPathArgument());
+    }
 
+    @Test
+    public void testSerializationOfNodeIdentifierWithPredicates() {
 
-    Assert.assertEquals(expected.getLastPathArgument(),
-        actual.getLastPathArgument());
-  }
+        withPredicates((short) 1);
+        withPredicates((long) 2);
+        withPredicates(3);
+        withPredicates(true);
 
+    }
 
-  @Test
-  public void testSerializationOfNodeIdentifierWithPredicates() {
+    private void withPredicates(Object value) {
+        YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME);
 
-    withPredicates((short) 1);
-    withPredicates((long) 2);
-    withPredicates(3);
-    withPredicates(true);
+        YangInstanceIdentifier.PathArgument p2 = new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+                NODE_WITH_PREDICATES_QNAME, NAME_QNAME, value);
 
-  }
+        List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
 
-  private void withPredicates(Object value) {
-    YangInstanceIdentifier.PathArgument p1 =
-        new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME);
+        arguments.add(p1);
+        arguments.add(p2);
 
-    YangInstanceIdentifier.PathArgument p2 =
-        new YangInstanceIdentifier.NodeIdentifierWithPredicates(
-            NODE_WITH_PREDICATES_QNAME, NAME_QNAME, value);
+        YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
 
+        NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
+                InstanceIdentifierUtils.toSerializable(expected);
 
-    List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
+        YangInstanceIdentifier actual = InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
 
-    arguments.add(p1);
-    arguments.add(p2);
+        Assert.assertEquals(expected.getLastPathArgument(), actual.getLastPathArgument());
+    }
 
-    YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
+    @Test
+    public void testAugmentationIdentifier() {
+        YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.AugmentationIdentifier(new HashSet(
+                Arrays.asList(TEST_QNAME)));
 
-    NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
-        InstanceIdentifierUtils.toSerializable(expected);
+        List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
 
-    YangInstanceIdentifier actual =
-        InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
+        arguments.add(p1);
 
+        YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
 
-    Assert.assertEquals(expected.getLastPathArgument(),
-        actual.getLastPathArgument());
-  }
+        NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
+                InstanceIdentifierUtils.toSerializable(expected);
 
-  @Test
-  public void testAugmentationIdentifier() {
-    YangInstanceIdentifier.PathArgument p1 =
-        new YangInstanceIdentifier.AugmentationIdentifier(new HashSet(
-            Arrays.asList(TEST_QNAME)));
+        YangInstanceIdentifier actual = InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
 
-    List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
+        Assert.assertEquals(expected.getLastPathArgument(), actual.getLastPathArgument());
 
-    arguments.add(p1);
+    }
 
-    YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
+    @Test
+    public void testSerializationWithContext() {
+        List<YangInstanceIdentifier.PathArgument> arguments =
+                                                Arrays.<YangInstanceIdentifier.PathArgument>asList(
+                new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME),
+                new YangInstanceIdentifier.NodeWithValue(NODE_WITH_VALUE_QNAME, 1),
+                new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+                        NODE_WITH_PREDICATES_QNAME, NAME_QNAME, 2));
 
-    NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
-        InstanceIdentifierUtils.toSerializable(expected);
+        YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments);
 
-    YangInstanceIdentifier actual =
-        InstanceIdentifierUtils.fromSerializable(instanceIdentifier);
+        QNameSerializationContextImpl serializationContext = new QNameSerializationContextImpl();
 
+        NormalizedNodeMessages.InstanceIdentifier instanceIdentifier =
+                InstanceIdentifierUtils.toSerializable(expected, serializationContext);
 
-    Assert.assertEquals(expected.getLastPathArgument(),
-        actual.getLastPathArgument());
+        QNameDeSerializationContext deserializationContext = new QNameDeSerializationContextImpl(
+                serializationContext.getCodes());
 
-  }
+        YangInstanceIdentifier actual = InstanceIdentifierUtils.fromSerializable(
+                instanceIdentifier, deserializationContext);
 
+        Assert.assertEquals(expected.getLastPathArgument(), actual.getLastPathArgument());
+    }
 }
index 91c0b5caa1ebd0854f44943164d9f9a89aec855d..1c018cade1b01f82a3fa7a8d550ab2c10ed080e5 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-clustering-config</artifactId>
   <description>Configuration files for md-sal clustering</description>
index e46fe1fe78405d912ae8c12ebcfde944abdc4bc8..6af20c0fb886c74c2a03755a4489c1e157e3c43c 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>sal-common-api</artifactId>
index 82bd716c59c69c67a054e3a54cd554a85d9a3eac..542a1f390522a23080fc157e291a81e4854c3613 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-common-impl</artifactId>
   <packaging>bundle</packaging>
index e42c86a993f14dc1362b6c7ac96e1f2a16f81b0a..b285c991e5b53b254e007bf1d39fcb01efaffd6a 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-common-util</artifactId>
 
index f200b5551f22678b9e3cad899cd8121ca40774a8..e5450b24871cf719aee6a1b56912f763d6ad6986 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-common</artifactId>
 
index 4e7d82dad31ee6e7c26d2abb325cf44ae6aeb64a..e45e24dd567038c8401876676a5945d6c19aff63 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-connector-api</artifactId>
 
index 82998226b68e3049093a8be77f96227824db123e..d7e7d56d495d4e66f24d6c85ca12fc9d46b10104 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-distributed-datastore</artifactId>
   <packaging>bundle</packaging>
@@ -80,7 +80,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-inmemory-datastore</artifactId>
-      <version>1.1-SNAPSHOT</version>
+      <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
     <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-clustering-commons</artifactId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-akka-raft</artifactId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </dependency>
 
       <dependency>
index c780881a2ffad1ed50695b7a38111068ec2f8e3f..5195a2f918c6248463e26663b953378948c8e0dc 100644 (file)
@@ -12,6 +12,7 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.dispatch.OnComplete;
 import akka.util.Timeout;
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
@@ -76,44 +77,44 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au
 
         Preconditions.checkNotNull(path, "path should not be null");
         Preconditions.checkNotNull(listener, "listener should not be null");
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("Registering listener: {} for path: {} scope: {}", listener, path, scope);
-        }
-        ActorRef dataChangeListenerActor = actorContext.getActorSystem().actorOf(
-            DataChangeListener.props(listener ));
+
+        LOG.debug("Registering listener: {} for path: {} scope: {}", listener, path, scope);
 
         String shardName = ShardStrategyFactory.getStrategy(path).findShard(path);
 
-        Future future = actorContext.executeLocalShardOperationAsync(shardName,
-            new RegisterChangeListener(path, dataChangeListenerActor.path(), scope),
-            new Timeout(actorContext.getOperationDuration().$times(
-                REGISTER_DATA_CHANGE_LISTENER_TIMEOUT_FACTOR)));
+        Optional<ActorRef> shard = actorContext.findLocalShard(shardName);
 
-        if (future != null) {
-            final DataChangeListenerRegistrationProxy listenerRegistrationProxy =
+        //if shard is NOT local
+        if (!shard.isPresent()) {
+            LOG.debug("No local shard for shardName {} was found so returning a noop registration", shardName);
+            return new NoOpDataChangeListenerRegistration(listener);
+        }
+        //if shard is local
+        ActorRef dataChangeListenerActor = actorContext.getActorSystem().actorOf(DataChangeListener.props(listener));
+        Future future = actorContext.executeOperationAsync(shard.get(),
+                new RegisterChangeListener(path, dataChangeListenerActor.path(), scope),
+                new Timeout(actorContext.getOperationDuration().$times(REGISTER_DATA_CHANGE_LISTENER_TIMEOUT_FACTOR)));
+
+        final DataChangeListenerRegistrationProxy listenerRegistrationProxy =
                 new DataChangeListenerRegistrationProxy(listener, dataChangeListenerActor);
 
-            future.onComplete(new OnComplete(){
+        future.onComplete(new OnComplete() {
 
-                @Override public void onComplete(Throwable failure, Object result)
+            @Override
+            public void onComplete(Throwable failure, Object result)
                     throws Throwable {
-                    if(failure != null){
-                        LOG.error("Failed to register listener at path " + path.toString(), failure);
-                        return;
-                    }
-                    RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result;
-                    listenerRegistrationProxy.setListenerRegistrationActor(actorContext
-                        .actorSelection(reply.getListenerRegistrationPath()));
+                if (failure != null) {
+                    LOG.error("Failed to register listener at path " + path.toString(), failure);
+                    return;
                 }
-            }, actorContext.getActorSystem().dispatcher());
-            return listenerRegistrationProxy;
-        }
-        if(LOG.isDebugEnabled()) {
-            LOG.debug(
-                "No local shard for shardName {} was found so returning a noop registration",
-                shardName);
-        }
-        return new NoOpDataChangeListenerRegistration(listener);
+                RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result;
+                listenerRegistrationProxy.setListenerRegistrationActor(actorContext
+                        .actorSelection(reply.getListenerRegistrationPath()));
+            }
+        }, actorContext.getActorSystem().dispatcher());
+
+        return listenerRegistrationProxy;
+
     }
 
     @Override
index ddb5989f096145cddd3b716afa8dfc1dce3311e3..3934489646530c136d9cc3bfc2e41e8028cbb9ba 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardTransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
+import org.opendaylight.controller.cluster.datastore.messages.ActorInitialized;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
 import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
@@ -222,7 +223,9 @@ public class Shard extends RaftActor {
                 getLeader().forward(message, getContext());
             } else {
                 getSender().tell(new akka.actor.Status.Failure(new IllegalStateException(
-                    "Could not find leader so transaction cannot be created")), getSelf());
+                    "Could not find shard leader so transaction cannot be created. This typically happens" +
+                            " when system is coming up or recovering and a leader is being elected. Try again" +
+                            " later.")), getSelf());
             }
         } else if (message instanceof PeerAddressResolved) {
             PeerAddressResolved resolved = (PeerAddressResolved) message;
@@ -522,6 +525,9 @@ public class Shard extends RaftActor {
         recoveryCoordinator = null;
         currentLogRecoveryBatch = null;
         updateJournalStats();
+
+        //notify shard manager
+        getContext().parent().tell(new ActorInitialized(), getSelf());
     }
 
     @Override
@@ -588,7 +594,7 @@ public class Shard extends RaftActor {
             DOMStoreWriteTransaction transaction = store.newWriteOnlyTransaction();
             NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(snapshot);
             NormalizedNode<?, ?> node = new NormalizedNodeToNodeCodec(schemaContext)
-                .decode(YangInstanceIdentifier.builder().build(), serializedNode);
+                .decode(serializedNode);
 
             // delete everything first
             transaction.delete(YangInstanceIdentifier.builder().build());
index a8a182380911db26f8c9530e363441d2d2b491cc..e68628dbf5c1fc992afb30ae986fff8ed8f6eef1 100644 (file)
@@ -24,11 +24,13 @@ import akka.persistence.RecoveryCompleted;
 import akka.persistence.RecoveryFailure;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.cluster.common.actor.AbstractUntypedPersistentActor;
+import org.opendaylight.controller.cluster.common.actor.AbstractUntypedPersistentActorWithMetering;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shardmanager.ShardManagerInfo;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shardmanager.ShardManagerInfoMBean;
+import org.opendaylight.controller.cluster.datastore.messages.ActorInitialized;
+import org.opendaylight.controller.cluster.datastore.messages.ActorNotInitialized;
 import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
 import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
 import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
@@ -59,7 +61,7 @@ import java.util.Set;
  * <li> Monitor the cluster members and store their addresses
  * <ul>
  */
-public class ShardManager extends AbstractUntypedPersistentActor {
+public class ShardManager extends AbstractUntypedPersistentActorWithMetering {
 
     protected final LoggingAdapter LOG =
         Logging.getLogger(getContext().system(), this);
@@ -127,6 +129,8 @@ public class ShardManager extends AbstractUntypedPersistentActor {
             findLocalShard((FindLocalShard) message);
         } else if (message instanceof UpdateSchemaContext) {
             updateSchemaContext(message);
+        } else if(message instanceof ActorInitialized) {
+            onActorInitialized(message);
         } else if (message instanceof ClusterEvent.MemberUp){
             memberUp((ClusterEvent.MemberUp) message);
         } else if(message instanceof ClusterEvent.MemberRemoved) {
@@ -139,6 +143,31 @@ public class ShardManager extends AbstractUntypedPersistentActor {
 
     }
 
+    private void onActorInitialized(Object message) {
+        final ActorRef sender = getSender();
+
+        if (sender == null) {
+            return; //why is a non-actor sending this message? Just ignore.
+        }
+
+        String actorName = sender.path().name();
+        //find shard name from actor name; actor name is stringified shardId
+        ShardIdentifier shardId = ShardIdentifier.builder().fromShardIdString(actorName).build();
+
+        if (shardId.getShardName() == null) {
+            return;
+        }
+        markShardAsInitialized(shardId.getShardName());
+    }
+
+    @VisibleForTesting protected void markShardAsInitialized(String shardName) {
+        LOG.debug("Initializing shard [{}]", shardName);
+        ShardInformation shardInformation = localShards.get(shardName);
+        if (shardInformation != null) {
+            shardInformation.setShardInitialized(true);
+        }
+    }
+
     @Override protected void handleRecover(Object message) throws Exception {
 
         if(message instanceof SchemaContextModules){
@@ -157,16 +186,23 @@ public class ShardManager extends AbstractUntypedPersistentActor {
     }
 
     private void findLocalShard(FindLocalShard message) {
-        ShardInformation shardInformation =
-            localShards.get(message.getShardName());
+        ShardInformation shardInformation = localShards.get(message.getShardName());
 
-        if(shardInformation != null){
-            getSender().tell(new LocalShardFound(shardInformation.getActor()), getSelf());
+        if(shardInformation == null){
+            getSender().tell(new LocalShardNotFound(message.getShardName()), getSelf());
             return;
         }
 
-        getSender().tell(new LocalShardNotFound(message.getShardName()),
-            getSelf());
+        sendResponse(shardInformation, new LocalShardFound(shardInformation.getActor()));
+    }
+
+    private void sendResponse(ShardInformation shardInformation, Object message) {
+        if (!shardInformation.isShardInitialized()) {
+            getSender().tell(new ActorNotInitialized(), getSelf());
+            return;
+        }
+
+        getSender().tell(message, getSelf());
     }
 
     private void memberRemoved(ClusterEvent.MemberRemoved message) {
@@ -176,7 +212,7 @@ public class ShardManager extends AbstractUntypedPersistentActor {
     private void memberUp(ClusterEvent.MemberUp message) {
         String memberName = message.member().roles().head();
 
-        memberNameToAddress.put(memberName , message.member().address());
+        memberNameToAddress.put(memberName, message.member().address());
 
         for(ShardInformation info : localShards.values()){
             String shardName = info.getShardName();
@@ -229,28 +265,27 @@ public class ShardManager extends AbstractUntypedPersistentActor {
     }
 
     private void findPrimary(FindPrimary message) {
+        final ActorRef sender = getSender();
         String shardName = message.getShardName();
 
         // First see if the there is a local replica for the shard
         ShardInformation info = localShards.get(shardName);
-        if(info != null) {
+        if (info != null) {
             ActorPath shardPath = info.getActorPath();
-            if (shardPath != null) {
-                getSender()
-                    .tell(
-                        new PrimaryFound(shardPath.toString()).toSerializable(),
-                        getSelf());
-                return;
-            }
+            sendResponse(info, new PrimaryFound(shardPath.toString()).toSerializable());
+            return;
         }
 
-        List<String> members =
-            configuration.getMembersFromShardName(shardName);
+        List<String> members = configuration.getMembersFromShardName(shardName);
 
         if(cluster.getCurrentMemberName() != null) {
             members.remove(cluster.getCurrentMemberName());
         }
 
+        /**
+         * FIXME: Instead of sending remote shard actor path back to sender,
+         * forward FindPrimary message to remote shard manager
+         */
         // There is no way for us to figure out the primary (for now) so assume
         // that one of the remote nodes is a primary
         for(String memberName : members) {
@@ -376,6 +411,7 @@ public class ShardManager extends AbstractUntypedPersistentActor {
         private final ActorRef actor;
         private final ActorPath actorPath;
         private final Map<ShardIdentifier, String> peerAddresses;
+        private boolean shardInitialized = false; //flag that determines if the actor is ready for business
 
         private ShardInformation(String shardName, ActorRef actor,
             Map<ShardIdentifier, String> peerAddresses) {
@@ -413,6 +449,14 @@ public class ShardManager extends AbstractUntypedPersistentActor {
 
             }
         }
+
+        public boolean isShardInitialized() {
+            return shardInitialized;
+        }
+
+        public void setShardInitialized(boolean shardInitialized) {
+            this.shardInitialized = shardInitialized;
+        }
     }
 
     private static class ShardManagerCreator implements Creator<ShardManager> {
index 8afdb4c2801d186e0627669bc38ac6da7bdd3df7..94fb5841021ea994e019d946e3e106f7d95256c3 100644 (file)
@@ -142,7 +142,7 @@ class ShardRecoveryCoordinator {
             try {
                 NormalizedNodeMessages.Node serializedNode = NormalizedNodeMessages.Node.parseFrom(snapshot);
                 NormalizedNode<?, ?> node = new NormalizedNodeToNodeCodec(schemaContext).decode(
-                        YangInstanceIdentifier.builder().build(), serializedNode);
+                        serializedNode);
 
                 // delete everything first
                 resultingTx.delete(YangInstanceIdentifier.builder().build());
index a7a5b31b174e4e0d03db192aa367a43ebe67ad62..515be372e8c76b7008b7356a666bbf94e19a1972 100644 (file)
@@ -157,7 +157,7 @@ public class ThreePhaseCommitCohortProxy implements DOMStoreThreePhaseCommitCoho
             }
             ActorSelection cohort = actorContext.actorSelection(actorPath);
 
-            futureList.add(actorContext.executeRemoteOperationAsync(cohort, message));
+            futureList.add(actorContext.executeOperationAsync(cohort, message));
         }
 
         return Futures.sequence(futureList, actorContext.getActorSystem().dispatcher());
index 6cf16b44268c6c16e26e0658632f61994ee33971..19d9a66a528eb417d5bff41948641b68e9c8e481 100644 (file)
@@ -22,6 +22,7 @@ import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.SettableFuture;
 
+import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
@@ -156,7 +157,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             if(remoteTransactionActorsMB.get()) {
                 for(ActorSelection actor : remoteTransactionActors) {
                     LOG.trace("Sending CloseTransaction to {}", actor);
-                    actorContext.sendRemoteOperationAsync(actor,
+                    actorContext.sendOperationAsync(actor,
                             new CloseTransaction().toSerializable());
                 }
             }
@@ -379,9 +380,14 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         }
 
         try {
-            Object response = actorContext.executeShardOperation(shardName,
-                new CreateTransaction(identifier.toString(), this.transactionType.ordinal(),
-                    getTransactionChainId()).toSerializable());
+            Optional<ActorSelection> primaryShard = actorContext.findPrimaryShard(shardName);
+            if (!primaryShard.isPresent()) {
+                throw new PrimaryNotFoundException("Primary could not be found for shard " + shardName);
+            }
+
+            Object response = actorContext.executeOperation(primaryShard.get(),
+                    new CreateTransaction(identifier.toString(), this.transactionType.ordinal(),
+                            getTransactionChainId()).toSerializable());
             if (response.getClass().equals(CreateTransactionReply.SERIALIZABLE_CLASS)) {
                 CreateTransactionReply reply =
                     CreateTransactionReply.fromSerializable(response);
@@ -502,7 +508,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             if(LOG.isDebugEnabled()) {
                 LOG.debug("Tx {} closeTransaction called", identifier);
             }
-            actorContext.sendRemoteOperationAsync(getActor(), new CloseTransaction().toSerializable());
+            actorContext.sendOperationAsync(getActor(), new CloseTransaction().toSerializable());
         }
 
         @Override
@@ -513,7 +519,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             }
             // Send the ReadyTransaction message to the Tx actor.
 
-            final Future<Object> replyFuture = actorContext.executeRemoteOperationAsync(getActor(),
+            final Future<Object> replyFuture = actorContext.executeOperationAsync(getActor(),
                     new ReadyTransaction().toSerializable());
 
             // Combine all the previously recorded put/merge/delete operation reply Futures and the
@@ -576,8 +582,8 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             if(LOG.isDebugEnabled()) {
                 LOG.debug("Tx {} deleteData called path = {}", identifier, path);
             }
-            recordedOperationFutures.add(actorContext.executeRemoteOperationAsync(getActor(),
-                    new DeleteData(path).toSerializable() ));
+            recordedOperationFutures.add(actorContext.executeOperationAsync(getActor(),
+                    new DeleteData(path).toSerializable()));
         }
 
         @Override
@@ -585,7 +591,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             if(LOG.isDebugEnabled()) {
                 LOG.debug("Tx {} mergeData called path = {}", identifier, path);
             }
-            recordedOperationFutures.add(actorContext.executeRemoteOperationAsync(getActor(),
+            recordedOperationFutures.add(actorContext.executeOperationAsync(getActor(),
                     new MergeData(path, data, schemaContext).toSerializable()));
         }
 
@@ -594,7 +600,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
             if(LOG.isDebugEnabled()) {
                 LOG.debug("Tx {} writeData called path = {}", identifier, path);
             }
-            recordedOperationFutures.add(actorContext.executeRemoteOperationAsync(getActor(),
+            recordedOperationFutures.add(actorContext.executeOperationAsync(getActor(),
                     new WriteData(path, data, schemaContext).toSerializable()));
         }
 
@@ -686,7 +692,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
                 }
             };
 
-            Future<Object> readFuture = actorContext.executeRemoteOperationAsync(getActor(),
+            Future<Object> readFuture = actorContext.executeOperationAsync(getActor(),
                     new ReadData(path).toSerializable());
             readFuture.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
         }
@@ -773,7 +779,7 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
                 }
             };
 
-            Future<Object> future = actorContext.executeRemoteOperationAsync(getActor(),
+            Future<Object> future = actorContext.executeOperationAsync(getActor(),
                     new DataExists(path).toSerializable());
             future.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
         }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/exceptions/NotInitializedException.java
new file mode 100644 (file)
index 0000000..302d684
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.exceptions;
+
+public class NotInitializedException extends RuntimeException {
+    public NotInitializedException(String message) {
+        super(message);
+    }
+}
index c6928815938058dbddc7bdb8b920c60fa2e0f7da..d65af61ba3f8a957b6f67bdc355035fa93297431 100644 (file)
@@ -10,11 +10,17 @@ package org.opendaylight.controller.cluster.datastore.identifiers;
 
 import com.google.common.base.Preconditions;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 public class ShardIdentifier {
     private final String shardName;
     private final String memberName;
     private final String type;
 
+    //format and pattern should be in sync
+    private final String format = "%s-shard-%s-%s";
+    private static final Pattern pattern = Pattern.compile("(\\S+)-shard-(\\S+)-(\\S+)");
 
     public ShardIdentifier(String shardName, String memberName, String type) {
 
@@ -60,15 +66,31 @@ public class ShardIdentifier {
     }
 
     @Override public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append(memberName).append("-shard-").append(shardName).append("-").append(type);
-        return builder.toString();
+        //ensure the output of toString matches the pattern above
+        return new StringBuilder(memberName)
+                    .append("-shard-")
+                    .append(shardName)
+                    .append("-")
+                    .append(type)
+                    .toString();
     }
 
     public static Builder builder(){
         return new Builder();
     }
 
+    public String getShardName() {
+        return shardName;
+    }
+
+    public String getMemberName() {
+        return memberName;
+    }
+
+    public String getType() {
+        return type;
+    }
+
     public static class Builder {
         private String shardName;
         private String memberName;
@@ -93,5 +115,15 @@ public class ShardIdentifier {
             return this;
         }
 
+        public Builder fromShardIdString(String shardId){
+            Matcher matcher = pattern.matcher(shardId);
+
+            if (matcher.matches()) {
+                memberName = matcher.group(1);
+                shardName = matcher.group(2);
+                type = matcher.group(3);
+            }
+            return this;
+        }
     }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ActorInitialized.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ActorInitialized.java
new file mode 100644 (file)
index 0000000..b034f87
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.messages;
+
+import java.io.Serializable;
+
+public class ActorInitialized implements Serializable {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ActorNotInitialized.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ActorNotInitialized.java
new file mode 100644 (file)
index 0000000..de25ef9
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.messages;
+
+import java.io.Serializable;
+
+public class ActorNotInitialized implements Serializable {
+}
index a8827bebf4386b1a63918a30cb1b31faa81335a8..5b5f076d43713b48e6245a35a6d21684ecf909cb 100644 (file)
@@ -9,14 +9,13 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.controller.protobuff.messages.datachange.notification.DataChangeListenerMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -26,8 +25,9 @@ import java.util.Map;
 import java.util.Set;
 
 public class DataChanged implements SerializableMessage {
-    public static final Class SERIALIZABLE_CLASS =
+    public static final Class<DataChangeListenerMessages.DataChanged> SERIALIZABLE_CLASS =
         DataChangeListenerMessages.DataChanged.class;
+
     final private SchemaContext schemaContext;
     private final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>
         change;
@@ -50,7 +50,7 @@ public class DataChanged implements SerializableMessage {
         NormalizedNode<?, ?> normalizedNode) {
 
         return new NormalizedNodeToNodeCodec(schemaContext)
-            .encode(YangInstanceIdentifier.builder().build(), normalizedNode)
+            .encode(normalizedNode)
             .getNormalizedNode();
 
     }
@@ -62,6 +62,7 @@ public class DataChanged implements SerializableMessage {
             removedPathInstanceIds.add(InstanceIdentifierUtils.toSerializable(id));
         }
         return new Iterable<NormalizedNodeMessages.InstanceIdentifier>() {
+            @Override
             public Iterator<NormalizedNodeMessages.InstanceIdentifier> iterator() {
                 return removedPathInstanceIds.iterator();
             }
@@ -86,7 +87,7 @@ public class DataChanged implements SerializableMessage {
 
             builder.setInstanceIdentifierPath(instanceIdentifier)
                 .setNormalizedNode(normalizedNodeToNodeCodec
-                    .encode(entry.getKey(), entry.getValue())
+                    .encode(entry.getValue())
                     .getNormalizedNode());
             nodeMapBuilder.addMapEntries(builder.build());
         }
@@ -146,7 +147,6 @@ public class DataChanged implements SerializableMessage {
 
     static class DataChangedEvent implements
         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-        private final SchemaContext schemaContext;
         private Map<YangInstanceIdentifier, NormalizedNode<?, ?>> createdData;
         private final NormalizedNodeToNodeCodec nodeCodec;
         private Map<YangInstanceIdentifier, NormalizedNode<?, ?>> updatedData;
@@ -156,7 +156,6 @@ public class DataChanged implements SerializableMessage {
         private Set<YangInstanceIdentifier> removedPathIds;
 
         DataChangedEvent(SchemaContext schemaContext) {
-            this.schemaContext = schemaContext;
             nodeCodec = new NormalizedNodeToNodeCodec(schemaContext);
         }
 
@@ -183,7 +182,7 @@ public class DataChanged implements SerializableMessage {
                 YangInstanceIdentifier id = InstanceIdentifierUtils
                     .fromSerializable(nodeMapEntry.getInstanceIdentifierPath());
                 mapEntries.put(id,
-                    nodeCodec.decode(id, nodeMapEntry.getNormalizedNode()));
+                    nodeCodec.decode(nodeMapEntry.getNormalizedNode()));
             }
             return mapEntries;
         }
@@ -240,7 +239,7 @@ public class DataChanged implements SerializableMessage {
 
         DataChangedEvent setOriginalSubtree(NormalizedNodeMessages.Node node,
             YangInstanceIdentifier instanceIdentifierPath) {
-            originalSubTree = nodeCodec.decode(instanceIdentifierPath, node);
+            originalSubTree = nodeCodec.decode(node);
             return this;
         }
 
@@ -251,7 +250,7 @@ public class DataChanged implements SerializableMessage {
 
         DataChangedEvent setUpdatedSubtree(NormalizedNodeMessages.Node node,
             YangInstanceIdentifier instanceIdentifierPath) {
-            updatedSubTree = nodeCodec.decode(instanceIdentifierPath, node);
+            updatedSubTree = nodeCodec.decode(node);
             return this;
         }
 
index 9ae851e76c0f4db04776d14e7cfeab1ab20fefaa..6d3051c8c7ab9779ca252082868e95e30f8a962c 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
index ba790816c4aefa72d5db0e97b392af205e979f4b..eb1f3495bdf2c04328ad5336eb44b248149bd242 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Encoded;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -18,31 +18,26 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class MergeData extends ModifyData{
 
-    public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.MergeData.class;
+    public static final Class<ShardTransactionMessages.MergeData> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.MergeData.class;
 
     public MergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data,
         SchemaContext context) {
         super(path, data, context);
     }
 
-    @Override public Object toSerializable() {
-
-        NormalizedNodeMessages.Node normalizedNode =
-            new NormalizedNodeToNodeCodec(schemaContext).encode(path, data)
-                .getNormalizedNode();
+    @Override
+    public Object toSerializable() {
+        Encoded encoded = new NormalizedNodeToNodeCodec(schemaContext).encode(path, data);
         return ShardTransactionMessages.MergeData.newBuilder()
-            .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path))
-            .setNormalizedNode(normalizedNode).build();
+            .setInstanceIdentifierPathArguments(encoded.getEncodedPath())
+            .setNormalizedNode(encoded.getEncodedNode().getNormalizedNode()).build();
     }
 
     public static MergeData fromSerializable(Object serializable, SchemaContext schemaContext){
         ShardTransactionMessages.MergeData o = (ShardTransactionMessages.MergeData) serializable;
-        YangInstanceIdentifier identifier = InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments());
-
-        NormalizedNode<?, ?> normalizedNode =
-            new NormalizedNodeToNodeCodec(schemaContext)
-                .decode(identifier, o.getNormalizedNode());
-
-        return new MergeData(identifier, normalizedNode, schemaContext);
+        Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(
+                o.getInstanceIdentifierPathArguments(), o.getNormalizedNode());
+        return new MergeData(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
     }
 }
index a698f4634797116875871d20bf5d68d90ffb1ff7..d743d99fcc12cee6b4da25d306d9d97a567ede0a 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
index fc6bcff64a3c1afa691abb54650434c9f6af4886..43dd81252c3a52f35da645e6993d716e2a0d7715 100644 (file)
@@ -15,41 +15,44 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class ReadDataReply implements SerializableMessage{
-
-  private final NormalizedNode<?, ?> normalizedNode;
-  private final SchemaContext schemaContext;
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadDataReply.class;
-  public ReadDataReply(SchemaContext context,NormalizedNode<?, ?> normalizedNode){
-
-    this.normalizedNode = normalizedNode;
-    this.schemaContext = context;
-  }
-
-  public NormalizedNode<?, ?> getNormalizedNode() {
-    return normalizedNode;
-  }
-
-  public Object toSerializable(){
-    if(normalizedNode != null) {
-      return ShardTransactionMessages.ReadDataReply.newBuilder()
-          .setNormalizedNode(new NormalizedNodeToNodeCodec(schemaContext)
-                  .encode(YangInstanceIdentifier.builder().build(), normalizedNode).getNormalizedNode()
-          ).build();
-    }else{
-      return ShardTransactionMessages.ReadDataReply.newBuilder().build();
+public class ReadDataReply implements SerializableMessage {
+    public static final Class<ShardTransactionMessages.ReadDataReply> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.ReadDataReply.class;
 
+    private final NormalizedNode<?, ?> normalizedNode;
+    private final SchemaContext schemaContext;
+
+    public ReadDataReply(SchemaContext context,NormalizedNode<?, ?> normalizedNode){
+
+        this.normalizedNode = normalizedNode;
+        this.schemaContext = context;
+    }
+
+    public NormalizedNode<?, ?> getNormalizedNode() {
+        return normalizedNode;
     }
 
-  }
+    @Override
+    public Object toSerializable(){
+        if(normalizedNode != null) {
+            return ShardTransactionMessages.ReadDataReply.newBuilder()
+                    .setNormalizedNode(new NormalizedNodeToNodeCodec(schemaContext)
+                        .encode(normalizedNode).getNormalizedNode()).build();
+        } else {
+            return ShardTransactionMessages.ReadDataReply.newBuilder().build();
 
-  public static ReadDataReply fromSerializable(SchemaContext schemaContext,YangInstanceIdentifier id,Object serializable){
-    ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
-    return new ReadDataReply(schemaContext,new NormalizedNodeToNodeCodec(schemaContext).decode(id, o.getNormalizedNode()));
-  }
+        }
+    }
+
+    public static ReadDataReply fromSerializable(SchemaContext schemaContext,
+            YangInstanceIdentifier id, Object serializable) {
+        ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
+        return new ReadDataReply(schemaContext, new NormalizedNodeToNodeCodec(schemaContext).decode(
+                o.getNormalizedNode()));
+    }
 
-  public static ByteString getNormalizedNodeByteString(Object serializable){
-      ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
-      return ((ShardTransactionMessages.ReadDataReply) serializable).getNormalizedNode().toByteString();
-  }
+    public static ByteString getNormalizedNodeByteString(Object serializable){
+        ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
+        return ((ShardTransactionMessages.ReadDataReply) serializable).getNormalizedNode().toByteString();
+    }
 }
index c1ec0a87cba2c64db745879fa08211cea9821b2c..dea085153bbc202f7da357d71f1bfbe1aaaecd27 100644 (file)
@@ -10,13 +10,15 @@ package org.opendaylight.controller.cluster.datastore.messages;
 
 import akka.actor.ActorPath;
 import akka.actor.ActorSystem;
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.protobuff.messages.registration.ListenerRegistrationMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class RegisterChangeListener implements SerializableMessage {
-  public static final Class SERIALIZABLE_CLASS = ListenerRegistrationMessages.RegisterChangeListener.class;
+    public static final Class<ListenerRegistrationMessages.RegisterChangeListener> SERIALIZABLE_CLASS =
+            ListenerRegistrationMessages.RegisterChangeListener.class;
+
     private final YangInstanceIdentifier path;
     private final ActorPath dataChangeListenerPath;
     private final AsyncDataBroker.DataChangeScope scope;
index 87fa010b373d679eae58ff306a262de406c9c148..8aa63ef262a1366b63de5844979ed0caafb27208 100644 (file)
@@ -9,41 +9,34 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Encoded;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class WriteData extends ModifyData{
+public class WriteData extends ModifyData {
 
-  public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.WriteData.class;
+    public static final Class<ShardTransactionMessages.WriteData> SERIALIZABLE_CLASS =
+            ShardTransactionMessages.WriteData.class;
 
-  public WriteData(YangInstanceIdentifier path, NormalizedNode<?, ?> data, SchemaContext schemaContext) {
-    super(path, data, schemaContext);
-  }
-
-    @Override public Object toSerializable() {
+    public WriteData(YangInstanceIdentifier path, NormalizedNode<?, ?> data, SchemaContext schemaContext) {
+        super(path, data, schemaContext);
+    }
 
-        NormalizedNodeMessages.Node normalizedNode =
-            new NormalizedNodeToNodeCodec(schemaContext).encode(path, data)
-                .getNormalizedNode();
+    @Override
+    public Object toSerializable() {
+        Encoded encoded = new NormalizedNodeToNodeCodec(schemaContext).encode(path, data);
         return ShardTransactionMessages.WriteData.newBuilder()
-            .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path))
-            .setNormalizedNode(normalizedNode).build();
-
+                .setInstanceIdentifierPathArguments(encoded.getEncodedPath())
+                .setNormalizedNode(encoded.getEncodedNode().getNormalizedNode()).build();
     }
 
     public static WriteData fromSerializable(Object serializable, SchemaContext schemaContext){
         ShardTransactionMessages.WriteData o = (ShardTransactionMessages.WriteData) serializable;
-        YangInstanceIdentifier identifier = InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments());
-
-        NormalizedNode<?, ?> normalizedNode =
-            new NormalizedNodeToNodeCodec(schemaContext)
-                .decode(identifier, o.getNormalizedNode());
-
-        return new WriteData(identifier, normalizedNode, schemaContext);
+        Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(
+                o.getInstanceIdentifierPathArguments(), o.getNormalizedNode());
+        return new WriteData(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
     }
-
 }
index 169397bf877168cee54be4fd013870e158c17b0c..4f4f0fb8f17b3baf065c2340e97819ff97f2a43e 100644 (file)
@@ -26,4 +26,8 @@ public abstract class AbstractModification implements Modification,
     protected AbstractModification(YangInstanceIdentifier path) {
         this.path = path;
     }
+
+    public YangInstanceIdentifier getPath() {
+        return path;
+    }
 }
index 593f458afa314f458ad314e6af22701160810c35..056fe756371589c7d055d054b8884f50db5bd60f 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
+import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -17,23 +17,24 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
  * DeleteModification store all the parameters required to delete a path from the data tree
  */
 public class DeleteModification extends AbstractModification {
-  public DeleteModification(YangInstanceIdentifier path) {
-    super(path);
-  }
+    private static final long serialVersionUID = 1L;
 
-  @Override
-  public void apply(DOMStoreWriteTransaction transaction) {
-    transaction.delete(path);
-  }
+    public DeleteModification(YangInstanceIdentifier path) {
+        super(path);
+    }
+
+    @Override
+    public void apply(DOMStoreWriteTransaction transaction) {
+        transaction.delete(path);
+    }
 
-    @Override public Object toSerializable() {
-        return PersistentMessages.Modification.newBuilder()
-            .setType(this.getClass().toString())
-            .setPath(InstanceIdentifierUtils.toSerializable(this.path))
-            .build();
+    @Override
+    public Object toSerializable() {
+        return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString())
+                .setPath(InstanceIdentifierUtils.toSerializable(this.path)).build();
     }
 
-    public static DeleteModification fromSerializable(Object serializable){
+    public static DeleteModification fromSerializable(Object serializable) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
         return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath()));
     }
index f06adcf96f9ff7c16f1842187bbc98119b53152c..24c4c6c50a63fe171ca001bafe25ec7ee62e0970 100644 (file)
@@ -9,8 +9,7 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -20,16 +19,11 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 /**
  * MergeModification stores all the parameters required to merge data into the specified path
  */
-public class MergeModification extends AbstractModification {
-    private final NormalizedNode data;
-    private final SchemaContext schemaContext;
-
+public class MergeModification extends WriteModification {
 
     public MergeModification(YangInstanceIdentifier path, NormalizedNode data,
         SchemaContext schemaContext) {
-        super(path);
-        this.data = data;
-        this.schemaContext = schemaContext;
+        super(path, data, schemaContext);
     }
 
     @Override
@@ -37,29 +31,9 @@ public class MergeModification extends AbstractModification {
         transaction.merge(path, data);
     }
 
-    @Override public Object toSerializable() {
-        NormalizedNodeMessages.Container encode =
-            new NormalizedNodeToNodeCodec(schemaContext).encode(
-                path, data);
-
-        return PersistentMessages.Modification.newBuilder()
-            .setType(this.getClass().toString())
-            .setPath(InstanceIdentifierUtils.toSerializable(this.path))
-            .setData(encode.getNormalizedNode())
-            .build();
-
-    }
-
-    public static MergeModification fromSerializable(
-        Object serializable,
-        SchemaContext schemaContext) {
+    public static MergeModification fromSerializable(Object serializable, SchemaContext schemaContext) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
-
-        YangInstanceIdentifier path = InstanceIdentifierUtils.fromSerializable(o.getPath());
-        NormalizedNode data = new NormalizedNodeToNodeCodec(schemaContext).decode(
-            path, o.getData());
-
-        return new MergeModification(path, data, schemaContext);
+        Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
+        return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
     }
-
 }
index b4a7dd62d00121debd5cde36c358e02f4c264df8..53cc35a88be26f2ba9f9e0fda8994e8fdfb20584 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
+import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Encoded;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -22,43 +22,38 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  */
 public class WriteModification extends AbstractModification {
 
-  private final NormalizedNode data;
+    protected final NormalizedNode data;
     private final SchemaContext schemaContext;
 
     public WriteModification(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext) {
-    super(path);
-    this.data = data;
+        super(path);
+        this.data = data;
         this.schemaContext = schemaContext;
     }
 
-  @Override
-  public void apply(DOMStoreWriteTransaction transaction) {
-    transaction.write(path, data);
-  }
+    @Override
+    public void apply(DOMStoreWriteTransaction transaction) {
+        transaction.write(path, data);
+    }
 
-    @Override public Object toSerializable() {
-        NormalizedNodeMessages.Container encode =
-            new NormalizedNodeToNodeCodec(schemaContext).encode(
-                path, data);
+    public NormalizedNode getData() {
+        return data;
+    }
 
+    @Override
+    public Object toSerializable() {
+        Encoded encoded = new NormalizedNodeToNodeCodec(schemaContext).encode(path, data);
 
         return PersistentMessages.Modification.newBuilder()
-            .setType(this.getClass().toString())
-            .setPath(InstanceIdentifierUtils.toSerializable(this.path))
-            .setData(encode.getNormalizedNode())
-            .build();
-
+                .setType(this.getClass().toString())
+                .setPath(encoded.getEncodedPath())
+                .setData(encoded.getEncodedNode().getNormalizedNode())
+                .build();
     }
 
-    public static WriteModification fromSerializable(
-        Object serializable,
-        SchemaContext schemaContext) {
+    public static WriteModification fromSerializable(Object serializable, SchemaContext schemaContext) {
         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
-
-        YangInstanceIdentifier path = InstanceIdentifierUtils.fromSerializable(o.getPath());
-        NormalizedNode data = new NormalizedNodeToNodeCodec(schemaContext).decode(
-            path, o.getData());
-
-        return new WriteModification(path, data, schemaContext);
+        Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
+        return new WriteModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);
     }
 }
index 8ba333d2799a5177c7b1b8b5b09ab6b4ec87d126..44f4ef77d7ff057dbea32ebfd9d3404f5b30f862 100644 (file)
@@ -13,12 +13,14 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.PoisonPill;
-import akka.pattern.Patterns;
 import akka.util.Timeout;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
 import org.opendaylight.controller.cluster.datastore.Configuration;
-import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException;
+import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
 import org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException;
+import org.opendaylight.controller.cluster.datastore.messages.ActorNotInitialized;
 import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
 import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
 import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
@@ -101,14 +103,17 @@ public class ActorContext {
     }
 
     /**
-     * Finds the primary for a given shard
+     * Finds the primary shard for the given shard name
      *
      * @param shardName
      * @return
      */
-    public ActorSelection findPrimary(String shardName) {
-        String path = findPrimaryPath(shardName);
-        return actorSystem.actorSelection(path);
+    public Optional<ActorSelection> findPrimaryShard(String shardName) {
+        String path = findPrimaryPathOrNull(shardName);
+        if (path == null){
+            return Optional.absent();
+        }
+        return Optional.of(actorSystem.actorSelection(path));
     }
 
     /**
@@ -118,36 +123,36 @@ public class ActorContext {
      * @return a reference to a local shard actor which represents the shard
      *         specified by the shardName
      */
-    public ActorRef findLocalShard(String shardName) {
-        Object result = executeLocalOperation(shardManager,
-            new FindLocalShard(shardName));
+    public Optional<ActorRef> findLocalShard(String shardName) {
+        Object result = executeOperation(shardManager, new FindLocalShard(shardName));
 
         if (result instanceof LocalShardFound) {
             LocalShardFound found = (LocalShardFound) result;
-
-            if(LOG.isDebugEnabled()) {
-                LOG.debug("Local shard found {}", found.getPath());
-            }
-            return found.getPath();
+            LOG.debug("Local shard found {}", found.getPath());
+            return Optional.of(found.getPath());
         }
 
-        return null;
+        return Optional.absent();
     }
 
 
-    public String findPrimaryPath(String shardName) {
-        Object result = executeLocalOperation(shardManager,
-            new FindPrimary(shardName).toSerializable());
+    private String findPrimaryPathOrNull(String shardName) {
+        Object result = executeOperation(shardManager, new FindPrimary(shardName).toSerializable());
 
         if (result.getClass().equals(PrimaryFound.SERIALIZABLE_CLASS)) {
             PrimaryFound found = PrimaryFound.fromSerializable(result);
 
-            if(LOG.isDebugEnabled()) {
-                LOG.debug("Primary found {}", found.getPrimaryPath());
-            }
+            LOG.debug("Primary found {}", found.getPrimaryPath());
             return found.getPrimaryPath();
+
+        } else if (result.getClass().equals(ActorNotInitialized.class)){
+            throw new NotInitializedException(
+                String.format("Found primary shard[%s] but its not initialized yet. Please try again later", shardName)
+            );
+
+        } else {
+            return null;
         }
-        throw new PrimaryNotFoundException("Could not find primary for shardName " + shardName);
     }
 
 
@@ -158,16 +163,25 @@ public class ActorContext {
      * @param message
      * @return The response of the operation
      */
-    public Object executeLocalOperation(ActorRef actor, Object message) {
-        Future<Object> future = ask(actor, message, operationTimeout);
+    public Object executeOperation(ActorRef actor, Object message) {
+        Future<Object> future = executeOperationAsync(actor, message, operationTimeout);
 
         try {
             return Await.result(future, operationDuration);
         } catch (Exception e) {
-            throw new TimeoutException("Sending message " + message.getClass().toString() + " to actor " + actor.toString() + " failed" , e);
+            throw new TimeoutException("Sending message " + message.getClass().toString() +
+                    " to actor " + actor.toString() + " failed. Try again later.", e);
         }
     }
 
+    public Future<Object> executeOperationAsync(ActorRef actor, Object message, Timeout timeout) {
+        Preconditions.checkArgument(actor != null, "actor must not be null");
+        Preconditions.checkArgument(message != null, "message must not be null");
+
+        LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+        return ask(actor, message, timeout);
+    }
+
     /**
      * Execute an operation on a remote actor and wait for it's response
      *
@@ -175,19 +189,14 @@ public class ActorContext {
      * @param message
      * @return
      */
-    public Object executeRemoteOperation(ActorSelection actor, Object message) {
-
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("Sending remote message {} to {}", message.getClass().toString(),
-                actor.toString());
-        }
-        Future<Object> future = ask(actor, message, operationTimeout);
+    public Object executeOperation(ActorSelection actor, Object message) {
+        Future<Object> future = executeOperationAsync(actor, message);
 
         try {
             return Await.result(future, operationDuration);
         } catch (Exception e) {
             throw new TimeoutException("Sending message " + message.getClass().toString() +
-                    " to actor " + actor.toString() + " failed, e);
+                    " to actor " + actor.toString() + " failed. Try again later.", e);
         }
     }
 
@@ -198,11 +207,12 @@ public class ActorContext {
      * @param message the message to send
      * @return a Future containing the eventual result
      */
-    public Future<Object> executeRemoteOperationAsync(ActorSelection actor, Object message) {
+    public Future<Object> executeOperationAsync(ActorSelection actor, Object message) {
+        Preconditions.checkArgument(actor != null, "actor must not be null");
+        Preconditions.checkArgument(message != null, "message must not be null");
+
+        LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
 
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("Sending remote message {} to {}", message.getClass().toString(), actor.toString());
-        }
         return ask(actor, message, operationTimeout);
     }
 
@@ -213,86 +223,15 @@ public class ActorContext {
      * @param actor the ActorSelection
      * @param message the message to send
      */
-    public void sendRemoteOperationAsync(ActorSelection actor, Object message) {
-        actor.tell(message, ActorRef.noSender());
-    }
-
-    public void sendShardOperationAsync(String shardName, Object message) {
-        ActorSelection primary = findPrimary(shardName);
-
-        primary.tell(message, ActorRef.noSender());
-    }
+    public void sendOperationAsync(ActorSelection actor, Object message) {
+        Preconditions.checkArgument(actor != null, "actor must not be null");
+        Preconditions.checkArgument(message != null, "message must not be null");
 
+        LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
 
-    /**
-     * Execute an operation on the primary for a given shard
-     * <p>
-     * This method first finds the primary for a given shard ,then sends
-     * the message to the remote shard and waits for a response
-     * </p>
-     *
-     * @param shardName
-     * @param message
-     * @return
-     * @throws org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException         if the message to the remote shard times out
-     * @throws org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException if the primary shard is not found
-     */
-    public Object executeShardOperation(String shardName, Object message) {
-        ActorSelection primary = findPrimary(shardName);
-
-        return executeRemoteOperation(primary, message);
-    }
-
-    /**
-     * Execute an operation on the the local shard only
-     * <p>
-     *     This method first finds the address of the local shard if any. It then
-     *     executes the operation on it.
-     * </p>
-     *
-     * @param shardName the name of the shard on which the operation needs to be executed
-     * @param message the message that needs to be sent to the shard
-     * @return the message that was returned by the local actor on which the
-     *         the operation was executed. If a local shard was not found then
-     *         null is returned
-     * @throws org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException
-     *         if the operation does not complete in a specified time duration
-     */
-    public Object executeLocalShardOperation(String shardName, Object message) {
-        ActorRef local = findLocalShard(shardName);
-
-        if(local != null) {
-            return executeLocalOperation(local, message);
-        }
-
-        return null;
-    }
-
-
-    /**
-     * Execute an operation on the the local shard only asynchronously
-     *
-     * <p>
-     *     This method first finds the address of the local shard if any. It then
-     *     executes the operation on it.
-     * </p>
-     *
-     * @param shardName the name of the shard on which the operation needs to be executed
-     * @param message the message that needs to be sent to the shard
-     * @param timeout the amount of time that this method should wait for a response before timing out
-     * @return null if the shard could not be located else a future on which the caller can wait
-     *
-     */
-    public Future executeLocalShardOperationAsync(String shardName, Object message, Timeout timeout) {
-        ActorRef local = findLocalShard(shardName);
-        if(local == null){
-            return null;
-        }
-        return Patterns.ask(local, message, timeout);
+        actor.tell(message, ActorRef.noSender());
     }
 
-
-
     public void shutdown() {
         shardManager.tell(PoisonPill.getInstance(), null);
         actorSystem.shutdown();
@@ -337,10 +276,13 @@ public class ActorContext {
      */
     public void broadcast(Object message){
         for(String shardName : configuration.getAllShardNames()){
-            try {
-                sendShardOperationAsync(shardName, message);
-            } catch(Exception e){
-                LOG.warn("broadcast failed to send message " +  message.getClass().getSimpleName() + " to shard " + shardName, e);
+
+            Optional<ActorSelection> primary = findPrimaryShard(shardName);
+            if (primary.isPresent()) {
+                primary.get().tell(message, ActorRef.noSender());
+            } else {
+                LOG.warn("broadcast failed to send message {} to shard {}. Primary not found",
+                        message.getClass().getSimpleName(), shardName);
             }
         }
     }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java
deleted file mode 100644 (file)
index c154b81..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.opendaylight.controller.cluster.datastore.utils;
-
-import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author: syedbahm
- */
-public class InstanceIdentifierUtils {
-
-    protected static final Logger logger = LoggerFactory
-        .getLogger(InstanceIdentifierUtils.class);
-
-    public static String getParentPath(String currentElementPath) {
-
-        StringBuilder parentPath = new StringBuilder();
-
-        if (currentElementPath != null) {
-            String[] parentPaths = currentElementPath.split("/");
-            if (parentPaths.length > 2) {
-                for (int i = 0; i < parentPaths.length - 1; i++) {
-                    if (parentPaths[i].length() > 0) {
-                        parentPath.append( "/");
-                        parentPath.append( parentPaths[i]);
-                    }
-                }
-            }
-        }
-        return parentPath.toString();
-    }
-
-    @Deprecated
-    public static YangInstanceIdentifier from(String path) {
-        String[] ids = path.split("/");
-
-        List<YangInstanceIdentifier.PathArgument> pathArguments =
-            new ArrayList<>();
-        for (String nodeId : ids) {
-            if (!"".equals(nodeId)) {
-                pathArguments
-                    .add(NodeIdentifierFactory.getArgument(nodeId));
-            }
-        }
-        final YangInstanceIdentifier instanceIdentifier =
-            YangInstanceIdentifier.create(pathArguments);
-        return instanceIdentifier;
-    }
-
-    /**
-     * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead
-     * @param path
-     * @return
-     */
-    @Deprecated
-    public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path){
-        return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.toSerializable(path);
-    }
-
-    /**
-     * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead
-     * @param path
-     * @return
-     */
-    @Deprecated
-    public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path){
-        return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.fromSerializable(path);
-    }
-}
index 2ed11cfbda21eff65b3cb6223b671731c891ab67..c79d76203589c51126dbd281adfd7dcaf4712db4 100644 (file)
@@ -82,7 +82,7 @@ public class DataChangeListenerProxyTest extends AbstractActorTest {
         ActorContext
             testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
         Object messages = testContext
-            .executeLocalOperation(actorRef, "messages");
+            .executeOperation(actorRef, "messages");
 
         Assert.assertNotNull(messages);
 
index ab3ff795d3cb4a4e66e3ddd708236a8d15eec365..aaf080bdf7d8d50de4a3f31713143389994872a6 100644 (file)
@@ -66,7 +66,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{
         ActorContext
             testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)),new MockClusterWrapper(), new MockConfiguration());
         Object messages = testContext
-            .executeLocalOperation(actorRef, "messages");
+            .executeOperation(actorRef, "messages");
 
         assertNotNull(messages);
 
@@ -95,7 +95,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{
         ActorContext
             testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)),new MockClusterWrapper(), new MockConfiguration());
         Object messages = testContext
-            .executeLocalOperation(actorRef, "messages");
+            .executeOperation(actorRef, "messages");
 
         assertNotNull(messages);
 
index 08c3ea9602adb9cd891f9e1fe573ded671e5d6d7..d57a5eea4a684c2572376e303f227907426b10ce 100644 (file)
@@ -8,6 +8,7 @@ import akka.actor.Props;
 import akka.dispatch.ExecutionContexts;
 import akka.dispatch.Futures;
 import akka.util.Timeout;
+import com.google.common.base.Optional;
 import com.google.common.util.concurrent.MoreExecutors;
 import org.junit.After;
 import org.junit.Before;
@@ -97,11 +98,11 @@ public class DistributedDataStoreTest extends AbstractActorTest{
 
         ListenerRegistration registration =
                 distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>() {
-            @Override
-            public void onDataChanged(AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
-                throw new UnsupportedOperationException("onDataChanged");
-            }
-        }, AsyncDataBroker.DataChangeScope.BASE);
+                    @Override
+                    public void onDataChanged(AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
+                        throw new UnsupportedOperationException("onDataChanged");
+                    }
+                }, AsyncDataBroker.DataChangeScope.BASE);
 
         // Since we do not expect the shard to be local registration will return a NoOpRegistration
         assertTrue(registration instanceof NoOpDataChangeListenerRegistration);
@@ -119,8 +120,9 @@ public class DistributedDataStoreTest extends AbstractActorTest{
         Future future = mock(Future.class);
         when(actorContext.getOperationDuration()).thenReturn(FiniteDuration.apply(5, TimeUnit.SECONDS));
         when(actorContext.getActorSystem()).thenReturn(getSystem());
+        when(actorContext.findLocalShard(anyString())).thenReturn(Optional.of(doNothingActorRef));
         when(actorContext
-            .executeLocalShardOperationAsync(anyString(), anyObject(), any(Timeout.class))).thenReturn(future);
+                .executeOperationAsync(eq(doNothingActorRef), anyObject(), any(Timeout.class))).thenReturn(future);
 
         ListenerRegistration registration =
             distributedDataStore.registerChangeListener(TestModel.TEST_PATH,
@@ -153,8 +155,9 @@ public class DistributedDataStoreTest extends AbstractActorTest{
         when(actorSystem.dispatcher()).thenReturn(executor);
         when(actorSystem.actorOf(any(Props.class))).thenReturn(doNothingActorRef);
         when(actorContext.getActorSystem()).thenReturn(actorSystem);
+        when(actorContext.findLocalShard(anyString())).thenReturn(Optional.of(doNothingActorRef));
         when(actorContext
-            .executeLocalShardOperationAsync(anyString(), anyObject(), any(Timeout.class))).thenReturn(f);
+            .executeOperationAsync(eq(doNothingActorRef), anyObject(), any(Timeout.class))).thenReturn(f);
         when(actorContext.actorSelection(any(ActorPath.class))).thenReturn(actorSelection);
 
         ListenerRegistration registration =
@@ -195,8 +198,9 @@ public class DistributedDataStoreTest extends AbstractActorTest{
         when(actorSystem.dispatcher()).thenReturn(executor);
         when(actorSystem.actorOf(any(Props.class))).thenReturn(doNothingActorRef);
         when(actorContext.getActorSystem()).thenReturn(actorSystem);
+        when(actorContext.findLocalShard(anyString())).thenReturn(Optional.of(doNothingActorRef));
         when(actorContext
-            .executeLocalShardOperationAsync(anyString(), anyObject(), any(Timeout.class))).thenReturn(f);
+            .executeOperationAsync(eq(doNothingActorRef), anyObject(), any(Timeout.class))).thenReturn(f);
         when(actorContext.actorSelection(any(ActorPath.class))).thenReturn(actorSelection);
 
         ListenerRegistration registration =
index 8a3cdd0c8aa3b9890811c8a52318c8c18051d7b8..ed7b6866bf5fffff21cae1f61379a3126257ea07 100644 (file)
@@ -22,6 +22,8 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
+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.LocalShardFound;
@@ -29,6 +31,7 @@ import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound;
 import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor;
 import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
 import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
@@ -53,6 +56,8 @@ import static org.mockito.Mockito.when;
 
 public class ShardManagerTest {
     private static ActorSystem system;
+    Configuration mockConfig = new MockConfiguration();
+    private static ActorRef defaultShardMockActor;
 
     @BeforeClass
     public static void setUpClass() {
@@ -60,13 +65,18 @@ public class ShardManagerTest {
         myJournal.put("class", "org.opendaylight.controller.cluster.datastore.ShardManagerTest$MyJournal");
         myJournal.put("plugin-dispatcher", "akka.actor.default-dispatcher");
         Config config = ConfigFactory.load()
-            .withValue("akka.persistence.journal.plugin",
-                ConfigValueFactory.fromAnyRef("my-journal"))
-            .withValue("my-journal", ConfigValueFactory.fromMap(myJournal));
+                .withValue("akka.persistence.journal.plugin",
+                        ConfigValueFactory.fromAnyRef("my-journal"))
+                .withValue("my-journal", ConfigValueFactory.fromMap(myJournal));
 
         MyJournal.clear();
 
         system = ActorSystem.create("test", config);
+
+        String name = new ShardIdentifier(Shard.DEFAULT_NAME, "member-1","config").toString();
+        defaultShardMockActor = system.actorOf(Props.create(DoNothingActor.class), name);
+
+
     }
 
     @AfterClass
@@ -86,15 +96,15 @@ public class ShardManagerTest {
         new JavaTestKit(system) {
             {
                 final Props props = ShardManager
-                    .props("config", new MockClusterWrapper(),
-                        new MockConfiguration(), new DatastoreContext());
+                        .props("config", new MockClusterWrapper(),
+                                new MockConfiguration(), new DatastoreContext());
 
                 final ActorRef subject = getSystem().actorOf(props);
 
                 subject.tell(new FindPrimary("inventory").toSerializable(), getRef());
 
                 expectMsgEquals(duration("2 seconds"),
-                    new PrimaryNotFound("inventory").toSerializable());
+                        new PrimaryNotFound("inventory").toSerializable());
             }};
     }
 
@@ -103,17 +113,19 @@ public class ShardManagerTest {
 
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
 
             final ActorRef subject = getSystem().actorOf(props);
 
             subject.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
+            subject.tell(new ActorInitialized(), defaultShardMockActor);
 
             subject.tell(new FindPrimary(Shard.DEFAULT_NAME).toSerializable(), getRef());
 
             expectMsgClass(duration("1 seconds"), PrimaryFound.SERIALIZABLE_CLASS);
-        }};
+        }
+        };
     }
 
     @Test
@@ -121,8 +133,8 @@ public class ShardManagerTest {
 
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
 
             final ActorRef subject = getSystem().actorOf(props);
 
@@ -150,12 +162,13 @@ public class ShardManagerTest {
 
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", mockClusterWrapper,
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", mockClusterWrapper,
+                            new MockConfiguration(), new DatastoreContext());
 
             final ActorRef subject = getSystem().actorOf(props);
 
             subject.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
+            subject.tell(new ActorInitialized(), defaultShardMockActor);
 
             subject.tell(new FindLocalShard(Shard.DEFAULT_NAME), getRef());
 
@@ -171,7 +184,7 @@ public class ShardManagerTest {
             }.get(); // this extracts the received message
 
             assertTrue(out.path().toString(),
-                out.path().toString().contains("member-1-shard-default-config"));
+                    out.path().toString().contains("member-1-shard-default-config"));
         }};
     }
 
@@ -180,8 +193,8 @@ public class ShardManagerTest {
 
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
 
             final ActorRef subject = getSystem().actorOf(props);
 
@@ -211,8 +224,8 @@ public class ShardManagerTest {
 
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
 
             final ActorRef subject = getSystem().actorOf(props);
 
@@ -233,14 +246,14 @@ public class ShardManagerTest {
     @Test
     public void testOnRecoveryJournalIsEmptied(){
         MyJournal.addToJournal(1L, new ShardManager.SchemaContextModules(
-            ImmutableSet.of("foo")));
+                ImmutableSet.of("foo")));
 
         assertEquals(1, MyJournal.get().size());
 
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
 
             final ActorRef subject = getSystem().actorOf(props);
 
@@ -257,10 +270,10 @@ public class ShardManagerTest {
     public void testOnRecoveryPreviouslyKnownModulesAreDiscovered() throws Exception {
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
             final TestActorRef<ShardManager> subject =
-                TestActorRef.create(system, props);
+                    TestActorRef.create(system, props);
 
             subject.underlyingActor().onReceiveRecover(new ShardManager.SchemaContextModules(ImmutableSet.of("foo")));
 
@@ -272,13 +285,13 @@ public class ShardManagerTest {
 
     @Test
     public void testOnUpdateSchemaContextUpdateKnownModulesIfTheyContainASuperSetOfTheKnownModules()
-        throws Exception {
+            throws Exception {
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
             final TestActorRef<ShardManager> subject =
-                TestActorRef.create(system, props);
+                    TestActorRef.create(system, props);
 
             Collection<String> knownModules = subject.underlyingActor().getKnownModules();
 
@@ -318,13 +331,13 @@ public class ShardManagerTest {
 
     @Test
     public void testOnUpdateSchemaContextDoNotUpdateKnownModulesIfTheyDoNotContainASuperSetOfKnownModules()
-        throws Exception {
+            throws Exception {
         new JavaTestKit(system) {{
             final Props props = ShardManager
-                .props("config", new MockClusterWrapper(),
-                    new MockConfiguration(), new DatastoreContext());
+                    .props("config", new MockClusterWrapper(),
+                            new MockConfiguration(), new DatastoreContext());
             final TestActorRef<ShardManager> subject =
-                TestActorRef.create(system, props);
+                    TestActorRef.create(system, props);
 
             Collection<String> knownModules = subject.underlyingActor().getKnownModules();
 
@@ -386,7 +399,7 @@ public class ShardManagerTest {
         }
 
         @Override public Future<Void> doAsyncReplayMessages(final String persistenceId, long fromSequenceNr, long toSequenceNr, long max,
-            final Procedure<PersistentRepr> replayCallback) {
+                                                            final Procedure<PersistentRepr> replayCallback) {
             if(journal.size() == 0){
                 return Futures.successful(null);
             }
@@ -395,8 +408,8 @@ public class ShardManagerTest {
                 public Void call() throws Exception {
                     for (Map.Entry<Long, Object> entry : journal.entrySet()) {
                         PersistentRepr persistentMessage =
-                            new PersistentImpl(entry.getValue(), entry.getKey(), persistenceId,
-                                false, null, null);
+                                new PersistentImpl(entry.getValue(), entry.getKey(), persistenceId,
+                                        false, null, null);
                         replayCallback.apply(persistentMessage);
                     }
                     return null;
@@ -409,7 +422,7 @@ public class ShardManagerTest {
         }
 
         @Override public Future<Void> doAsyncWriteMessages(
-            final Iterable<PersistentRepr> persistentReprs) {
+                final Iterable<PersistentRepr> persistentReprs) {
             return Futures.future(new Callable<Void>() {
                 @Override
                 public Void call() throws Exception {
@@ -424,12 +437,12 @@ public class ShardManagerTest {
         }
 
         @Override public Future<Void> doAsyncWriteConfirmations(
-            Iterable<PersistentConfirmation> persistentConfirmations) {
+                Iterable<PersistentConfirmation> persistentConfirmations) {
             return Futures.successful(null);
         }
 
         @Override public Future<Void> doAsyncDeleteMessages(Iterable<PersistentId> persistentIds,
-            boolean b) {
+                                                            boolean b) {
             clear();
             return Futures.successful(null);
         }
index a3e0b3a07d70993b5c403e7712dfeb1c3ad0c96d..2051c9debe88c69c071663df511fbff130f325ed 100644 (file)
@@ -208,7 +208,7 @@ public class ShardTest extends AbstractActorTest {
         YangInstanceIdentifier root = YangInstanceIdentifier.builder().build();
         NormalizedNode<?,?> expected = ref.underlyingActor().readStore(root);
 
-        NormalizedNodeMessages.Container encode = codec.encode(root, expected);
+        NormalizedNodeMessages.Container encode = codec.encode(expected);
 
         ApplySnapshot applySnapshot = new ApplySnapshot(Snapshot.create(
                 encode.getNormalizedNode().toByteString().toByteArray(),
@@ -260,7 +260,7 @@ public class ShardTest extends AbstractActorTest {
 
         InMemorySnapshotStore.addSnapshot(IDENTIFIER.toString(), Snapshot.create(
                 new NormalizedNodeToNodeCodec(SCHEMA_CONTEXT).encode(
-                        YangInstanceIdentifier.builder().build(), root).
+                        root).
                                 getNormalizedNode().toByteString().toByteArray(),
                                 Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1));
 
index 1cd0f85fa1917057f77144f23009a7edb65c0150..3c9d857fe81db981d341233e2c7249f06273bee6 100644 (file)
@@ -91,12 +91,12 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
                     .successful(((SerializableMessage) responses[i]).toSerializable()));
         }
 
-        stubber.when(actorContext).executeRemoteOperationAsync(any(ActorSelection.class),
+        stubber.when(actorContext).executeOperationAsync(any(ActorSelection.class),
                 isA(requestType));
     }
 
     private void verifyCohortInvocations(int nCohorts, Class<?> requestType) {
-        verify(actorContext, times(nCohorts)).executeRemoteOperationAsync(
+        verify(actorContext, times(nCohorts)).executeOperationAsync(
                 any(ActorSelection.class), isA(requestType));
     }
 
index e5392e025158704f44d152306aaa727b64d460e8..bdcca42d15c45553d6feb8ff6cc9bd7a792795dc 100644 (file)
@@ -1,28 +1,17 @@
 package org.opendaylight.controller.cluster.datastore;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 import akka.actor.ActorPath;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.Props;
 import akka.dispatch.Futures;
-
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentMatcher;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_ONLY;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.WRITE_ONLY;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_WRITE;
-
 import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException;
 import org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException;
@@ -52,22 +41,29 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCoh
 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 scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
+
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.argThat;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.argThat;
 import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.isA;
 import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_ONLY;
+import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_WRITE;
+import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.WRITE_ONLY;
 
 @SuppressWarnings("resource")
 public class TransactionProxyTest extends AbstractActorTest {
@@ -224,11 +220,17 @@ public class TransactionProxyTest extends AbstractActorTest {
         ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
         doReturn(getSystem().actorSelection(actorRef.path())).
                 when(mockActorContext).actorSelection(actorRef.path().toString());
+
+        doReturn(Optional.of(getSystem().actorSelection(actorRef.path()))).
+                when(mockActorContext).findPrimaryShard(eq(DefaultShardStrategy.DEFAULT_SHARD));
+
         doReturn(createTransactionReply(actorRef)).when(mockActorContext).
-                executeShardOperation(eq(DefaultShardStrategy.DEFAULT_SHARD),
+                executeOperation(eq(getSystem().actorSelection(actorRef.path())),
                         eqCreateTransaction(memberName, type));
+
         doReturn(actorRef.path().toString()).when(mockActorContext).resolvePath(
                 anyString(), eq(actorRef.path().toString()));
+
         doReturn(actorRef.path()).when(mockActorContext).actorFor(actorRef.path().toString());
 
         return actorRef;
@@ -252,7 +254,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 READ_ONLY);
 
-        doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqReadData());
 
         Optional<NormalizedNode<?, ?>> readOptional = transactionProxy.read(
@@ -262,7 +264,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> expectedNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(readDataReply(expectedNode)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readDataReply(expectedNode)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqReadData());
 
         readOptional = transactionProxy.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
@@ -277,7 +279,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         setupActorContextWithInitialCreateTransaction(READ_ONLY);
 
         doReturn(Futures.successful(new Object())).when(mockActorContext).
-                executeRemoteOperationAsync(any(ActorSelection.class), any());
+                executeOperationAsync(any(ActorSelection.class), any());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 READ_ONLY);
@@ -290,7 +292,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         setupActorContextWithInitialCreateTransaction(READ_ONLY);
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext).
-                executeRemoteOperationAsync(any(ActorSelection.class), any());
+                executeOperationAsync(any(ActorSelection.class), any());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 READ_ONLY);
@@ -300,12 +302,17 @@ public class TransactionProxyTest extends AbstractActorTest {
 
     private void testExceptionOnInitialCreateTransaction(Exception exToThrow, Invoker invoker)
             throws Throwable {
+        ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
 
-        doThrow(exToThrow).when(mockActorContext).executeShardOperation(
-                anyString(), any());
+        if (exToThrow instanceof PrimaryNotFoundException) {
+            doReturn(Optional.absent()).when(mockActorContext).findPrimaryShard(anyString());
+        } else {
+            doReturn(Optional.of(getSystem().actorSelection(actorRef.path()))).
+                    when(mockActorContext).findPrimaryShard(anyString());
+        }
+        doThrow(exToThrow).when(mockActorContext).executeOperation(any(ActorSelection.class), any());
 
-        TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
-                READ_ONLY);
+        TransactionProxy transactionProxy = new TransactionProxy(mockActorContext, READ_ONLY);
 
         propagateReadFailedExceptionCause(invoker.invoke(transactionProxy));
     }
@@ -341,13 +348,13 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext).
-                executeRemoteOperationAsync(eq(actorSelection(actorRef)), eqDeleteData());
+                executeOperationAsync(eq(actorSelection(actorRef)), eqDeleteData());
 
-        doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqReadData());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -360,7 +367,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         try {
             propagateReadFailedExceptionCause(transactionProxy.read(TestModel.TEST_PATH));
         } finally {
-            verify(mockActorContext, times(0)).executeRemoteOperationAsync(
+            verify(mockActorContext, times(0)).executeOperationAsync(
                     eq(actorSelection(actorRef)), eqReadData());
         }
     }
@@ -371,10 +378,10 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> expectedNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(expectedNode));
 
-        doReturn(readDataReply(expectedNode)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readDataReply(expectedNode)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqReadData());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -406,14 +413,14 @@ public class TransactionProxyTest extends AbstractActorTest {
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 READ_ONLY);
 
-        doReturn(dataExistsReply(false)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(dataExistsReply(false)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDataExists());
 
         Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
 
         assertEquals("Exists response", false, exists);
 
-        doReturn(dataExistsReply(true)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(dataExistsReply(true)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDataExists());
 
         exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
@@ -436,7 +443,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         setupActorContextWithInitialCreateTransaction(READ_ONLY);
 
         doReturn(Futures.successful(new Object())).when(mockActorContext).
-                executeRemoteOperationAsync(any(ActorSelection.class), any());
+                executeOperationAsync(any(ActorSelection.class), any());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 READ_ONLY);
@@ -449,7 +456,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         setupActorContextWithInitialCreateTransaction(READ_ONLY);
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext).
-                executeRemoteOperationAsync(any(ActorSelection.class), any());
+                executeOperationAsync(any(ActorSelection.class), any());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 READ_ONLY);
@@ -463,13 +470,13 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext).
-                executeRemoteOperationAsync(eq(actorSelection(actorRef)), eqDeleteData());
+                executeOperationAsync(eq(actorSelection(actorRef)), eqDeleteData());
 
-        doReturn(dataExistsReply(false)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(dataExistsReply(false)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDataExists());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -482,7 +489,7 @@ public class TransactionProxyTest extends AbstractActorTest {
         try {
             propagateReadFailedExceptionCause(transactionProxy.exists(TestModel.TEST_PATH));
         } finally {
-            verify(mockActorContext, times(0)).executeRemoteOperationAsync(
+            verify(mockActorContext, times(0)).executeOperationAsync(
                     eq(actorSelection(actorRef)), eqDataExists());
         }
     }
@@ -493,10 +500,10 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
-        doReturn(dataExistsReply(true)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(dataExistsReply(true)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDataExists());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -547,7 +554,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -555,7 +562,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
 
-        verify(mockActorContext).executeRemoteOperationAsync(
+        verify(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
         verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
@@ -590,7 +597,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(mergeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(mergeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqMergeData(nodeToWrite));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -598,7 +605,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         transactionProxy.merge(TestModel.TEST_PATH, nodeToWrite);
 
-        verify(mockActorContext).executeRemoteOperationAsync(
+        verify(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqMergeData(nodeToWrite));
 
         verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
@@ -609,7 +616,7 @@ public class TransactionProxyTest extends AbstractActorTest {
     public void testDelete() throws Exception {
         ActorRef actorRef = setupActorContextWithInitialCreateTransaction(WRITE_ONLY);
 
-        doReturn(deleteDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(deleteDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDeleteData());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -617,7 +624,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         transactionProxy.delete(TestModel.TEST_PATH);
 
-        verify(mockActorContext).executeRemoteOperationAsync(
+        verify(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDeleteData());
 
         verifyRecordingOperationFutures(transactionProxy.getRecordedOperationFutures(),
@@ -656,13 +663,13 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqReadData());
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
-        doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), isA(ReadyTransaction.SERIALIZABLE_CLASS));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -691,13 +698,13 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(mergeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(mergeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqMergeData(nodeToWrite));
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext).
-                executeRemoteOperationAsync(eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
+                executeOperationAsync(eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
-        doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readyTxReply(actorRef.path())).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), isA(ReadyTransaction.SERIALIZABLE_CLASS));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -726,11 +733,11 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(mergeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(mergeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqMergeData(nodeToWrite));
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext).
-                executeRemoteOperationAsync(eq(actorSelection(actorRef)),
+                executeOperationAsync(eq(actorSelection(actorRef)),
                         isA(ReadyTransaction.SERIALIZABLE_CLASS));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -753,8 +760,9 @@ public class TransactionProxyTest extends AbstractActorTest {
     @Test
     public void testReadyWithInitialCreateTransactionFailure() throws Exception {
 
-        doThrow(new PrimaryNotFoundException("mock")).when(mockActorContext).executeShardOperation(
-                anyString(), any());
+        doReturn(Optional.absent()).when(mockActorContext).findPrimaryShard(anyString());
+//        doThrow(new PrimaryNotFoundException("mock")).when(mockActorContext).executeShardOperation(
+//                anyString(), any());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
                 WRITE_ONLY);
@@ -783,11 +791,11 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
 
-        doReturn(writeDataReply()).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(writeDataReply()).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqWriteData(nodeToWrite));
 
         doReturn(Futures.successful(new Object())).when(mockActorContext).
-                executeRemoteOperationAsync(eq(actorSelection(actorRef)),
+                executeOperationAsync(eq(actorSelection(actorRef)),
                         isA(ReadyTransaction.SERIALIZABLE_CLASS));
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -820,7 +828,7 @@ public class TransactionProxyTest extends AbstractActorTest {
     public void testClose() throws Exception{
         ActorRef actorRef = setupActorContextWithInitialCreateTransaction(READ_WRITE);
 
-        doReturn(readDataReply(null)).when(mockActorContext).executeRemoteOperationAsync(
+        doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqReadData());
 
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
@@ -830,7 +838,7 @@ public class TransactionProxyTest extends AbstractActorTest {
 
         transactionProxy.close();
 
-        verify(mockActorContext).sendRemoteOperationAsync(
+        verify(mockActorContext).sendOperationAsync(
                 eq(actorSelection(actorRef)), isA(CloseTransaction.SERIALIZABLE_CLASS));
     }
 }
index afcd045434450d4dee2e89a8efb13b7866e77320..0b5e7132c77791cab3e2c4276fe1fb966bb6445e 100644 (file)
@@ -14,5 +14,14 @@ public class ShardIdentifierTest {
         assertEquals("member-1-shard-inventory-config", id.toString());
     }
 
+    @Test
+    public void testFromShardIdString(){
+        String shardIdStr = "member-1-shard-inventory-config";
+
+        ShardIdentifier id = ShardIdentifier.builder().fromShardIdString(shardIdStr).build();
 
+        assertEquals("member-1", id.getMemberName());
+        assertEquals("inventory", id.getShardName());
+        assertEquals("config", id.getType());
+    }
 }
index 75128e6a254633d1a20bfd2174f20a96dc6a1af1..8f3ca9c535a06a1ae5a67f80c16dec2a2c5c2e48 100644 (file)
@@ -1,47 +1,21 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
-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;
 
 public class MergeDataTest {
 
     @Test
-    public void testBasic(){
-        MergeData mergeData = new MergeData(TestModel.TEST_PATH, ImmutableNodes
-            .containerNode(TestModel.TEST_QNAME),
-            TestModel.createTestContext());
-
-        MergeData output = MergeData
-            .fromSerializable(mergeData.toSerializable(),
-                TestModel.createTestContext());
-
-    }
-
-    @Test
-    public void testNormalizedNodeEncodeDecode(){
-        NormalizedNode<?, ?> expected =
-            ImmutableNodes.containerNode(TestModel.TEST_QNAME);
-
-
-        NormalizedNodeMessages.Container node =
-            new NormalizedNodeToNodeCodec(TestModel.createTestContext())
-                .encode(TestModel.TEST_PATH,
-                    expected);
-
-        String parentPath = node.getParentPath();
-
-        NormalizedNodeMessages.Node normalizedNode =
-            node.getNormalizedNode();
-
-        NormalizedNode<?,?> actual = new NormalizedNodeToNodeCodec(TestModel.createTestContext()).decode(TestModel.TEST_PATH,
-            normalizedNode);
-
-
-        Assert.assertEquals(expected, actual);
+    public void testSerialization() {
+        SchemaContext schemaContext = TestModel.createTestContext();
+        MergeData expected = new MergeData(TestModel.TEST_PATH, ImmutableNodes
+            .containerNode(TestModel.TEST_QNAME), schemaContext);
+
+        MergeData actual = MergeData.fromSerializable(expected.toSerializable(), schemaContext);
+        Assert.assertEquals("getPath", expected.getPath(), actual.getPath());
+        Assert.assertEquals("getData", expected.getData(), actual.getData());
     }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/WriteDataTest.java
new file mode 100644 (file)
index 0000000..6a5d65f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.messages;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+/**
+ * Unit tests for WriteData.
+ *
+ * @author Thomas Pantelis
+ */
+public class WriteDataTest {
+
+    @Test
+    public void testSerialization() {
+        SchemaContext schemaContext = TestModel.createTestContext();
+        WriteData expected = new WriteData(TestModel.TEST_PATH, ImmutableNodes
+            .containerNode(TestModel.TEST_QNAME), schemaContext);
+
+        WriteData actual = WriteData.fromSerializable(expected.toSerializable(), schemaContext);
+        Assert.assertEquals("getPath", expected.getPath(), actual.getPath());
+        Assert.assertEquals("getData", expected.getData(), actual.getData());
+    }
+}
index 9af3439ae196d95ca55148465d02b7beb8b9e5a6..5d2021167b52564c76a636fc29dc8c94e2d80e66 100644 (file)
@@ -7,22 +7,38 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 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;
 
 public class MergeModificationTest extends AbstractModificationTest{
 
-  @Test
-  public void testApply() throws Exception {
-    //TODO : Need to write a better test for this
+    @Test
+    public void testApply() throws Exception {
+        //TODO : Need to write a better test for this
 
-    //Write something into the datastore
-    DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-    MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
-    writeModification.apply(writeTransaction);
-    commitTransaction(writeTransaction);
+        //Write something into the datastore
+        DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
+        MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
+        writeModification.apply(writeTransaction);
+        commitTransaction(writeTransaction);
 
-    //Check if it's in the datastore
-    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
-    Assert.assertTrue(data.isPresent());
+        //Check if it's in the datastore
+        Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
+        Assert.assertTrue(data.isPresent());
 
-  }
+    }
+
+    @Test
+    public void testSerialization() {
+        SchemaContext schemaContext = TestModel.createTestContext();
+        NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+        MergeModification mergeModification = new MergeModification(TestModel.TEST_PATH,
+                node, schemaContext);
+
+        Object serialized = mergeModification.toSerializable();
+
+        MergeModification newModification = MergeModification.fromSerializable(serialized, schemaContext);
+
+        Assert.assertEquals("getPath", TestModel.TEST_PATH, newModification.getPath());
+        Assert.assertEquals("getData", node, newModification.getData());
+    }
 }
index 03aaace0e354543f63d8e9f7ed5d74f998fc142c..f8116aa78d72f4b08597cee693d592ca8c32ed87 100644 (file)
@@ -35,8 +35,9 @@ public class MutableCompositeModificationTest extends AbstractModificationTest {
         MutableCompositeModification compositeModification = new MutableCompositeModification();
         compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
             ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
-
-        assertNotEquals(compositeModification.toSerializable(), compositeModification.toSerializable());
-
+        Object one = compositeModification.toSerializable();
+        try{Thread.sleep(10);}catch(Exception err){}
+        Object two = compositeModification.toSerializable();
+        assertNotEquals(one,two);
     }
 }
index 75d8c00db8bb2c54bf7ab433c118d9a867914980..3a82fffccb16ffe9e02b3e85c2106213e749dce1 100644 (file)
@@ -7,20 +7,36 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 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;
 
 public class WriteModificationTest extends AbstractModificationTest{
 
-  @Test
-  public void testApply() throws Exception {
-    //Write something into the datastore
-    DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-    WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
-    writeModification.apply(writeTransaction);
-    commitTransaction(writeTransaction);
+    @Test
+    public void testApply() throws Exception {
+        //Write something into the datastore
+        DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
+        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH,
+                ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext());
+        writeModification.apply(writeTransaction);
+        commitTransaction(writeTransaction);
 
-    //Check if it's in the datastore
-    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
-    Assert.assertTrue(data.isPresent());
+        //Check if it's in the datastore
+        Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
+        Assert.assertTrue(data.isPresent());
+    }
 
-  }
+    @Test
+    public void testSerialization() {
+        SchemaContext schemaContext = TestModel.createTestContext();
+        NormalizedNode<?, ?> node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH,
+                node, schemaContext);
+
+        Object serialized = writeModification.toSerializable();
+
+        WriteModification newModification = WriteModification.fromSerializable(serialized, schemaContext);
+
+        Assert.assertEquals("getPath", TestModel.TEST_PATH, newModification.getPath());
+        Assert.assertEquals("getData", node, newModification.getData());
+    }
 }
index 5d8fb8393d6c4fd773a0a94b6fd156ac02fe1c14..fa6d0b060f222f28ec723f1b4bc52b2f1ade3aa4 100644 (file)
@@ -1,6 +1,5 @@
 package org.opendaylight.controller.cluster.datastore.utils;
 
-import java.util.concurrent.TimeUnit;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
@@ -8,7 +7,7 @@ import akka.actor.Props;
 import akka.actor.UntypedActor;
 import akka.japi.Creator;
 import akka.testkit.JavaTestKit;
-
+import com.google.common.base.Optional;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
@@ -16,12 +15,14 @@ import org.opendaylight.controller.cluster.datastore.Configuration;
 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 scala.concurrent.Await;
 import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
+
+import java.util.concurrent.TimeUnit;
+
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
 public class ActorContextTest extends AbstractActorTest{
@@ -100,63 +101,6 @@ public class ActorContextTest extends AbstractActorTest{
         }
     }
 
-    @Test
-    public void testExecuteLocalShardOperationWithShardFound(){
-        new JavaTestKit(getSystem()) {{
-
-            new Within(duration("1 seconds")) {
-                @Override
-                protected void run() {
-
-                    ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
-
-                    ActorRef shardManagerActorRef = getSystem()
-                        .actorOf(MockShardManager.props(true, shardActorRef));
-
-                    ActorContext actorContext =
-                        new ActorContext(getSystem(), shardManagerActorRef , mock(ClusterWrapper.class),
-                            mock(Configuration.class));
-
-                    Object out = actorContext.executeLocalShardOperation("default", "hello");
-
-                    assertEquals("hello", out);
-
-
-                    expectNoMsg();
-                }
-            };
-        }};
-
-    }
-
-    @Test
-    public void testExecuteLocalShardOperationWithShardNotFound(){
-        new JavaTestKit(getSystem()) {{
-
-            new Within(duration("1 seconds")) {
-                @Override
-                protected void run() {
-
-                    ActorRef shardManagerActorRef = getSystem()
-                        .actorOf(MockShardManager.props(false, null));
-
-                    ActorContext actorContext =
-                        new ActorContext(getSystem(), shardManagerActorRef , mock(ClusterWrapper.class),
-                            mock(Configuration.class));
-
-                    Object out = actorContext.executeLocalShardOperation("default", "hello");
-
-                    assertNull(out);
-
-
-                    expectNoMsg();
-                }
-            };
-        }};
-
-    }
-
-
     @Test
     public void testFindLocalShardWithShardFound(){
         new JavaTestKit(getSystem()) {{
@@ -174,9 +118,9 @@ public class ActorContextTest extends AbstractActorTest{
                         new ActorContext(getSystem(), shardManagerActorRef , mock(ClusterWrapper.class),
                             mock(Configuration.class));
 
-                    Object out = actorContext.findLocalShard("default");
+                    Optional<ActorRef> out = actorContext.findLocalShard("default");
 
-                    assertEquals(shardActorRef, out);
+                    assertEquals(shardActorRef, out.get());
 
 
                     expectNoMsg();
@@ -201,11 +145,8 @@ public class ActorContextTest extends AbstractActorTest{
                         new ActorContext(getSystem(), shardManagerActorRef , mock(ClusterWrapper.class),
                             mock(Configuration.class));
 
-                    Object out = actorContext.findLocalShard("default");
-
-                    assertNull(out);
-
-
+                    Optional<ActorRef> out = actorContext.findLocalShard("default");
+                    assertTrue(!out.isPresent());
                     expectNoMsg();
                 }
             };
@@ -232,7 +173,7 @@ public class ActorContextTest extends AbstractActorTest{
 
                     ActorSelection actor = actorContext.actorSelection(shardActorRef.path());
 
-                    Object out = actorContext.executeRemoteOperation(actor, "hello");
+                    Object out = actorContext.executeOperation(actor, "hello");
 
                     assertEquals("hello", out);
 
@@ -261,7 +202,7 @@ public class ActorContextTest extends AbstractActorTest{
 
                     ActorSelection actor = actorContext.actorSelection(shardActorRef.path());
 
-                    Future<Object> future = actorContext.executeRemoteOperationAsync(actor, "hello");
+                    Future<Object> future = actorContext.executeOperationAsync(actor, "hello");
 
                     try {
                         Object result = Await.result(future, Duration.create(3, TimeUnit.SECONDS));
index 8fa3a17f901541f79be1ec45a373ebe097ba69a1..81b6bccaf08ea0f35b5d4ed8c8a0fea8f3524796 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertNotNull;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
+import com.google.common.base.Optional;
 
 public class MockActorContext extends ActorContext {
 
@@ -30,19 +31,13 @@ public class MockActorContext extends ActorContext {
         super(actorSystem, shardManager, new MockClusterWrapper(), new MockConfiguration());
     }
 
-
-    @Override public Object executeShardOperation(String shardName,
-        Object message) {
-        return executeShardOperationResponse;
-    }
-
-    @Override public Object executeRemoteOperation(ActorSelection actor,
-        Object message) {
+    @Override public Object executeOperation(ActorSelection actor,
+                                             Object message) {
         return executeRemoteOperationResponse;
     }
 
-    @Override public ActorSelection findPrimary(String shardName) {
-        return null;
+    @Override public Optional<ActorSelection> findPrimaryShard(String shardName) {
+        return Optional.absent();
     }
 
     public void setExecuteShardOperationResponse(Object response){
@@ -74,14 +69,9 @@ public class MockActorContext extends ActorContext {
     }
 
     @Override
-    public Object executeLocalOperation(ActorRef actor,
-        Object message) {
+    public Object executeOperation(ActorRef actor,
+                                   Object message) {
         return this.executeLocalOperationResponse;
     }
 
-    @Override
-    public Object executeLocalShardOperation(String shardName,
-        Object message) {
-        return this.executeLocalShardOperationResponse;
-    }
 }
index 4ddba2f1b9d773b3c4783d3e401fa7df43d32a0e..3bad4689506525bf683254534d44036ff8a61d7e 100644 (file)
@@ -21,7 +21,7 @@ public class TestUtils {
         ActorContext testContext = new ActorContext(actorSystem, actorSystem.actorOf(
             Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
         Object messages = testContext
-            .executeLocalOperation(actorRef, "messages");
+            .executeOperation(actorRef, "messages");
 
         Assert.assertNotNull(messages);
 
index be8713c7020c5848e7eec03278a95a9794a095ad..2300f9d130bcea6049326b3e42b2ac3084df6051 100644 (file)
@@ -12,7 +12,6 @@ import junit.framework.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 public class SampleModelsTest {
@@ -23,14 +22,12 @@ public class SampleModelsTest {
 
         final NormalizedNodeMessages.Container node =
             new NormalizedNodeToNodeCodec(SchemaContextHelper.full())
-                .encode(YangInstanceIdentifier.of(PeopleModel.BASE_QNAME),
-                    expected);
+                .encode(expected);
 
         final NormalizedNodeMessages.Node normalizedNode =
             node.getNormalizedNode();
 
-        final NormalizedNode<?,?> actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode(YangInstanceIdentifier.of(PeopleModel.BASE_QNAME),
-            normalizedNode);
+        final NormalizedNode<?,?> actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode(normalizedNode);
 
 
         Assert.assertEquals(expected, actual);
@@ -45,14 +42,12 @@ public class SampleModelsTest {
 
         final NormalizedNodeMessages.Container node =
             new NormalizedNodeToNodeCodec(SchemaContextHelper.full())
-                .encode(YangInstanceIdentifier.of(CarsModel.BASE_QNAME),
-                    expected);
+                .encode(expected);
 
         final NormalizedNodeMessages.Node normalizedNode =
             node.getNormalizedNode();
 
         final NormalizedNode<?,?> actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode(
-            YangInstanceIdentifier.of(CarsModel.BASE_QNAME),
             normalizedNode);
 
 
index ab392a06f852a4ec2794bcf2a3dbe60b0861ac6f..0302a7d920bc248a2566569dbaa7680f286df1fc 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-core-api</artifactId>
   <packaging>bundle</packaging>
index 96e353b80e23c284885a48cf2302e9759cb29386..dc20296ff52d2fe3256507dc90022ab6a7a89918 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-broker-impl</artifactId>
   <packaging>bundle</packaging>
@@ -45,7 +45,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-inmemory-datastore</artifactId>
-      <version>1.1-SNAPSHOT</version>
+      <version>1.2.0-SNAPSHOT</version>
 
     </dependency>
     <dependency>
index 8ed52061328bab92eb9074fabc9df010f7f0a9d7..5fbf1270cc7110133637cdb70016f44356a388a3 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
 import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.util.EnumMap;
@@ -102,6 +101,6 @@ public class DOMDataBrokerImpl extends AbstractDOMForwardedTransactionFactory<DO
     public CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
             final Iterable<DOMStoreThreePhaseCommitCohort> cohorts) {
         LOG.debug("Transaction: {} submitted with cohorts {}.", transaction.getIdentifier(), cohorts);
-        return coordinator.submit(transaction, cohorts, Optional.<DOMDataCommitErrorListener> absent());
+        return coordinator.submit(transaction, cohorts);
     }
 }
index 7cd6afa466e7d57b57f6861ac12aabf30bf90347..0b1dd1c5e0df481773a598ab3d99fa814e448187 100644 (file)
@@ -6,11 +6,14 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
 import java.util.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;
@@ -27,16 +30,27 @@ import org.slf4j.LoggerFactory;
  * {@link org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType} type.
  *
  */
-public class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransactionFactory<DOMStoreTransactionChain>
-        implements DOMTransactionChain, DOMDataCommitErrorListener {
+final class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransactionFactory<DOMStoreTransactionChain>
+        implements DOMTransactionChain {
+    private static enum State {
+        RUNNING,
+        CLOSING,
+        CLOSED,
+        FAILED,
+    }
 
+    private static final AtomicIntegerFieldUpdater<DOMDataBrokerTransactionChainImpl> COUNTER_UPDATER =
+            AtomicIntegerFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, "counter");
+    private static final AtomicReferenceFieldUpdater<DOMDataBrokerTransactionChainImpl, State> STATE_UPDATER =
+            AtomicReferenceFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, State.class, "state");
     private static final Logger LOG = LoggerFactory.getLogger(DOMDataBrokerTransactionChainImpl.class);
     private final AtomicLong txNum = new AtomicLong();
     private final DOMDataCommitExecutor coordinator;
     private final TransactionChainListener listener;
     private final long chainId;
 
-    private volatile boolean failed = false;
+    private volatile State state = State.RUNNING;
+    private volatile int counter = 0;
 
     /**
      *
@@ -62,37 +76,70 @@ public class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTrans
         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<Void,TransactionCommitFailedException> submit(
+    public CheckedFuture<Void, TransactionCommitFailedException> submit(
             final DOMDataWriteTransaction transaction, final Iterable<DOMStoreThreePhaseCommitCohort> cohorts) {
+        checkNotFailed();
         checkNotClosed();
 
-        return coordinator.submit(transaction, cohorts, Optional.<DOMDataCommitErrorListener> of(this));
+        final CheckedFuture<Void, TransactionCommitFailedException> ret = coordinator.submit(transaction, cohorts);
+
+        COUNTER_UPDATER.incrementAndGet(this);
+        Futures.addCallback(ret, new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                transactionCompleted();
+            }
+
+            @Override
+            public void onFailure(final Throwable t) {
+                transactionFailed(transaction, t);
+            }
+        });
+
+        return ret;
     }
 
     @Override
     public void close() {
-        super.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 (!failed) {
-            LOG.debug("Transaction chain {} successfully finished.", this);
-            // FIXME: this event should be emitted once all operations complete
-            listener.onTransactionChainSuccessful(this);
+        if (counter == 0) {
+            finishClose();
         }
     }
 
-    @Override
-    public void onCommitFailed(final DOMDataWriteTransaction tx, final Throwable cause) {
-        failed = true;
+    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);
     }
index 77cf105ed6a6e676819593dd19ccfcdc8580897d..15d7b1d966e1a59e028616bb85f5670f5805860b 100644 (file)
@@ -6,7 +6,6 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Iterables;
@@ -63,16 +62,15 @@ public class DOMDataCommitCoordinatorImpl implements DOMDataCommitExecutor {
 
     @Override
     public CheckedFuture<Void,TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
-            final Iterable<DOMStoreThreePhaseCommitCohort> cohorts, final Optional<DOMDataCommitErrorListener> listener) {
+            final Iterable<DOMStoreThreePhaseCommitCohort> cohorts) {
         Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
         Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
-        Preconditions.checkArgument(listener != null, "Listener must not be null");
         LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
 
         ListenableFuture<Void> commitFuture = null;
         try {
             commitFuture = executor.submit(new CommitCoordinationTask(transaction, cohorts,
-                    listener, commitStatsTracker));
+                    commitStatsTracker));
         } catch(RejectedExecutionException e) {
             LOG.error("The commit executor's queue is full - submit task was rejected. \n" +
                       executor, e);
@@ -81,10 +79,6 @@ public class DOMDataCommitCoordinatorImpl implements DOMDataCommitExecutor {
                         "Could not submit the commit task - the commit queue capacity has been exceeded.", e));
         }
 
-        if (listener.isPresent()) {
-            Futures.addCallback(commitFuture, new DOMDataCommitErrorInvoker(transaction, listener.get()));
-        }
-
         return MappingCheckedFuture.create(commitFuture,
                 TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER);
     }
@@ -141,7 +135,6 @@ public class DOMDataCommitCoordinatorImpl implements DOMDataCommitExecutor {
 
         public CommitCoordinationTask(final DOMDataWriteTransaction transaction,
                 final Iterable<DOMStoreThreePhaseCommitCohort> cohorts,
-                final Optional<DOMDataCommitErrorListener> listener,
                 final DurationStatsTracker commitStatTracker) {
             this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null");
             this.cohorts = Preconditions.checkNotNull(cohorts, "cohorts must not be null");
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitErrorInvoker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitErrorInvoker.java
deleted file mode 100644 (file)
index 5ce9241..0000000
+++ /dev/null
@@ -1,49 +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.md.sal.dom.broker.impl;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.FutureCallback;
-
-/**
- *
- * Utility implemetation of {@link FutureCallback} which is responsible
- * for invoking {@link DOMDataCommitErrorListener} on TransactionCommit failed.
- *
- * When {@link #onFailure(Throwable)} is invoked, supplied {@link DOMDataCommitErrorListener}
- * callback is invoked with associated transaction and throwable is invoked on listener.
- *
- */
-class DOMDataCommitErrorInvoker implements FutureCallback<Void> {
-
-    private final DOMDataWriteTransaction tx;
-    private final DOMDataCommitErrorListener listener;
-
-
-    /**
-     *
-     * Construct new DOMDataCommitErrorInvoker.
-     *
-     * @param transaction Transaction which should be passed as argument to {@link DOMDataCommitErrorListener#onCommitFailed(DOMDataWriteTransaction, Throwable)}
-     * @param listener Listener which should be invoked on error.
-     */
-    public DOMDataCommitErrorInvoker(DOMDataWriteTransaction transaction, DOMDataCommitErrorListener listener) {
-        this.tx = Preconditions.checkNotNull(transaction, "Transaction must not be null");
-        this.listener = Preconditions.checkNotNull(listener, "Listener must not be null");
-    }
-
-    @Override
-    public void onFailure(Throwable t) {
-        listener.onCommitFailed(tx, t);
-    }
-
-    @Override
-    public void onSuccess(Void result) {
-        // NOOP
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitErrorListener.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataCommitErrorListener.java
deleted file mode 100644 (file)
index 80bc669..0000000
+++ /dev/null
@@ -1,45 +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.md.sal.dom.broker.impl;
-
-import java.util.EventListener;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-
-/**
- *
- * Listener on transaction failure which may be passed to
- * {@link DOMDataCommitExecutor}. This listener is notified during transaction
- * processing, before result is delivered to other client code outside MD-SAL.
- * This allows implementors to update their internal state before transaction
- * failure is visible to client code.
- *
- * This is internal API for MD-SAL implementations, for consumer facing error
- * listeners see {@link org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener}.
- *
- */
-interface DOMDataCommitErrorListener extends EventListener {
-
-    /**
-     *
-     * Callback which is invoked on transaction failure during three phase
-     * commit in {@link DOMDataCommitExecutor}.
-     *
-     *
-     * Implementation of this callback MUST NOT do any blocking calls or any
-     * calls to MD-SAL, since this callback is invoked synchronously on MD-SAL
-     * Broker coordination thread.
-     *
-     * @param tx
-     *            Transaction which failed
-     * @param cause
-     *            Failure reason
-     */
-    void onCommitFailed(DOMDataWriteTransaction tx, Throwable cause);
-
-}
index 234758ca75413e3381cf5b71fd67c2e2f41e815a..8aa97e72d1156fb1a8b19d1e3ca62ff715d11a95 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
+import com.google.common.util.concurrent.CheckedFuture;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
 
 /**
  * Executor of Three Phase Commit coordination for
@@ -35,15 +34,13 @@ interface DOMDataCommitExecutor {
      *            Transaction to be used as context for reporting
      * @param cohort
      *            DOM Store cohorts representing provided transaction, its
-     *            subtransactoins.
-     * @param listener
-     *            Error listener which should be notified if transaction failed.
+     *            subtransactions.
      * @return a CheckedFuture. if commit coordination on cohorts finished successfully,
      *         nothing is returned from the Future, On failure,
      *         the Future fails with a {@link TransactionCommitFailedException}.
      *
      */
     CheckedFuture<Void,TransactionCommitFailedException> submit(DOMDataWriteTransaction tx,
-            Iterable<DOMStoreThreePhaseCommitCohort> cohort, Optional<DOMDataCommitErrorListener> listener);
+            Iterable<DOMStoreThreePhaseCommitCohort> cohort);
 
 }
index 88ac86a45e3f6259a53da0e71f4fb5f2f6a8ed50..6cc721e68ddc5f58f172a096fd4336b27504273b 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-core-spi</artifactId>
   <packaging>bundle</packaging>
index 077405fe6ea94cb3827deca2c409b9d6a5645bb1..e8919d0ee1a4c277541d842b6763e9ca18a9f747 100644 (file)
@@ -12,7 +12,7 @@
   <parent>\r
     <artifactId>sal-parent</artifactId>\r
     <groupId>org.opendaylight.controller</groupId>\r
-    <version>1.1-SNAPSHOT</version>\r
+    <version>1.2.0-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>sal-dom-xsql-config</artifactId>\r
   <groupId>org.opendaylight.controller</groupId>\r
index 2ab80daf3bbffc9928a6266af3998a41ebd54262..f5898a2bb9dfe15dd71ee560b2fe5bc8c581a1de 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-dom-xsql</artifactId>
   <packaging>bundle</packaging>
similarity index 84%
rename from opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCDriver.java
rename to opendaylight/md-sal/sal-dom-xsql/src/main/java/org/odl/xsql/JDBCDriver.java
index e4b4e249dfe01b14730e4d4c83210e6ddd3953b9..cc92b48a157abc00a9baf5c80b8b37aa034fcf30 100644 (file)
@@ -1,4 +1,4 @@
-package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+package org.odl.xsql;
 
 import java.sql.Connection;
 import java.sql.Driver;
@@ -9,6 +9,8 @@ import java.sql.SQLFeatureNotSupportedException;
 import java.util.Properties;
 import java.util.logging.Logger;
 
+import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCConnection;
+
 public class JDBCDriver implements Driver {
 
     public static JDBCDriver drv = new JDBCDriver();
@@ -34,11 +36,12 @@ public class JDBCDriver implements Driver {
             if (url.equals("svr")) {
                 return new JDBCConnection(true);
             } else {
-                return new JDBCConnection(url);
+                return new JDBCConnection(url).getProxy();
             }
         } catch (Exception err) {
             err.printStackTrace();
         }
+        System.err.println("Error JDBC Connection");
         return null;
     }
 
@@ -55,7 +58,7 @@ public class JDBCDriver implements Driver {
     @Override
     public DriverPropertyInfo[] getPropertyInfo(String arg0, Properties arg1)
         throws SQLException {
-        DriverPropertyInfo i = new DriverPropertyInfo("NQL", "NQL");
+        DriverPropertyInfo i = new DriverPropertyInfo("OpenDayLight", "OpenDayLight");
         return new DriverPropertyInfo[] {i};
     }
 
index d1f11ba9a36e693e223930b2fb4269e03acf21da..beab6d2fb1a0014e3dece9b1c07f77aa611ee090 100644 (file)
@@ -63,6 +63,18 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
 
     }
 
+    public void loadBluePrint(){
+        try{
+            InputStream in = this.getClass().getClassLoader().getResourceAsStream("BluePrintCache.dat");
+            if(in!=null){
+                this.bluePrint =  XSQLBluePrint.load(in);
+            }
+            in.close();
+        }catch(Exception err){
+            err.printStackTrace();
+        }
+    }
+
     public static XSQLAdapter getInstance() {
         return a;
     }
@@ -164,6 +176,10 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
     }
 
     public void execute(JDBCResultSet rs) {
+        if(this.domDataBroker==null){
+            rs.setFinished(true);
+            return;
+        }
         List<XSQLBluePrintNode> tables = rs.getTables();
         List<Object> roots = collectModuleRoots(tables.get(0),LogicalDatastoreType.OPERATIONAL);
         roots.addAll(collectModuleRoots(tables.get(0),LogicalDatastoreType.CONFIGURATION));
@@ -282,6 +298,8 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
                 sout.close();
             } catch (Exception err) {
             }
+        } else if (input.equals("save")) {
+            XSQLBluePrint.save(this.bluePrint);
         } else if (input.equals("tocsv")) {
             toCsv = !toCsv;
             sout.println("to csv file is " + toCsv);
index 1a31662020e8dc6856e9e68adee83e5a10ac6c71..7b51d03a97aaa6c9a9d1592eb5ba963ec63e6d8c 100644 (file)
@@ -1,5 +1,12 @@
 package org.opendaylight.controller.md.sal.dom.xsql;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
@@ -17,18 +24,20 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-public class XSQLBluePrint implements DatabaseMetaData {
+public class XSQLBluePrint implements DatabaseMetaData, Serializable {
 
-    public static final String CACHE_FILE_NAME = "BluePrintCache.dat";
+    private static final long serialVersionUID = 1L;
+
+    public static final String CACHE_FILE_NAME = "./BluePrintCache.dat";
 
     private Map<String, XSQLBluePrintNode> tableNameToBluePrint = new HashMap<String, XSQLBluePrintNode>();
-    private Map<String, Map<String,XSQLBluePrintNode>> odlNameToBluePrint = new HashMap<String, Map<String,XSQLBluePrintNode>>();
+    private Map<String, Map<String, XSQLBluePrintNode>> odlNameToBluePrint = new HashMap<String, Map<String, XSQLBluePrintNode>>();
 
     private boolean cacheLoadedSuccessfuly = false;
     private DatabaseMetaData myProxy = null;
 
     public static final String replaceAll(String source, String toReplace,
-        String withThis) {
+            String withThis) {
         int index = source.indexOf(toReplace);
         int index2 = 0;
         StringBuffer result = new StringBuffer();
@@ -47,9 +56,41 @@ public class XSQLBluePrint implements DatabaseMetaData {
     public XSQLBluePrint() {
     }
 
+    public static void save(XSQLBluePrint bp) {
+        ObjectOutputStream out = null;
+        try {
+            out = new ObjectOutputStream(new DataOutputStream(
+                    new FileOutputStream(CACHE_FILE_NAME)));
+            out.writeObject(bp);
+        } catch (Exception err) {
+            err.printStackTrace();
+        } finally {
+            try {
+                out.close();
+            } catch (Exception err) {
+            }
+        }
+    }
+
+    public static XSQLBluePrint load(InputStream ins) {
+        ObjectInputStream in = null;
+        try {
+            in = new ObjectInputStream(new DataInputStream(ins));
+            return (XSQLBluePrint) in.readObject();
+        } catch (Exception err) {
+            err.printStackTrace();
+        } finally {
+            try {
+                in.close();
+            } catch (Exception err) {
+            }
+        }
+        return null;
+    }
+
     private class NQLBluePrintProxy implements InvocationHandler {
         public Object invoke(Object proxy, Method method, Object[] args)
-            throws Throwable {
+                throws Throwable {
             System.out.println("Method " + method);
             return method.invoke(XSQLBluePrint.this, args);
         }
@@ -58,9 +99,9 @@ public class XSQLBluePrint implements DatabaseMetaData {
     public DatabaseMetaData getProxy() {
         if (myProxy == null) {
             try {
-                myProxy = (DatabaseMetaData) Proxy
-                    .newProxyInstance(getClass().getClassLoader(),
-                        new Class[] {DatabaseMetaData.class},
+                myProxy = (DatabaseMetaData) Proxy.newProxyInstance(getClass()
+                        .getClassLoader(),
+                        new Class[] { DatabaseMetaData.class },
                         new NQLBluePrintProxy());
             } catch (Exception err) {
                 err.printStackTrace();
@@ -69,22 +110,12 @@ public class XSQLBluePrint implements DatabaseMetaData {
         return myProxy;
     }
 
-    /*
-    public void loadBluePrintCache(String hostName) {
-        try {
-            ObjectInputStream in = new ObjectInputStream(
-                new FileInputStream(hostName + "-" + CACHE_FILE_NAME));
-            cache = (Map) in.readObject();
-            in.close();
-            cacheLoadedSuccessfuly = true;
-        } catch (Exception err) {
-            //err.printStackTrace();
-        }
-    }*/
-
-    public XSQLBluePrintNode[] getBluePrintNodeByODLTableName(String odlTableName) {
-        Map<String,XSQLBluePrintNode> map = this.odlNameToBluePrint.get(odlTableName);
-        if(map==null) return null;
+    public XSQLBluePrintNode[] getBluePrintNodeByODLTableName(
+            String odlTableName) {
+        Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint
+                .get(odlTableName);
+        if (map == null)
+            return null;
         return map.values().toArray(new XSQLBluePrintNode[map.size()]);
     }
 
@@ -106,26 +137,28 @@ public class XSQLBluePrint implements DatabaseMetaData {
         }
 
         for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
-            if (n.getBluePrintNodeName().toLowerCase().endsWith(tableName.toLowerCase())) {
+            if (n.getBluePrintNodeName().toLowerCase()
+                    .endsWith(tableName.toLowerCase())) {
                 return n;
             }
         }
 
         for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
-            if (n.getBluePrintNodeName().toLowerCase().equals(tableName.toLowerCase())) {
+            if (n.getBluePrintNodeName().toLowerCase()
+                    .equals(tableName.toLowerCase())) {
                 return n;
             }
         }
 
         for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
-            if (n.getBluePrintNodeName().toLowerCase().indexOf(tableName.toLowerCase())!= -1) {
+            if (n.getBluePrintNodeName().toLowerCase()
+                    .indexOf(tableName.toLowerCase()) != -1) {
                 return n;
             }
         }
         return null;
     }
 
-
     public boolean isCacheLoaded() {
         return cacheLoadedSuccessfuly;
     }
@@ -133,7 +166,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
     private static Map<Class, Set<Class>> superClassMap = new HashMap<Class, Set<Class>>();
 
     public static Set<Class> getInheritance(Class myObjectClass,
-        Class returnType) {
+            Class returnType) {
 
         if (returnType != null && myObjectClass.equals(returnType)) {
             return new HashSet<Class>();
@@ -171,10 +204,11 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     public void addToBluePrintCache(XSQLBluePrintNode blNode) {
         this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode);
-        Map<String,XSQLBluePrintNode> map = this.odlNameToBluePrint.get(blNode.getODLTableName());
-        if(map==null){
-            map = new HashMap<String,XSQLBluePrintNode>();
-            this.odlNameToBluePrint.put(blNode.getODLTableName(),map);
+        Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint.get(blNode
+                .getODLTableName());
+        if (map == null) {
+            map = new HashMap<String, XSQLBluePrintNode>();
+            this.odlNameToBluePrint.put(blNode.getODLTableName(), map);
         }
         map.put(blNode.getBluePrintNodeName(), blNode);
     }
@@ -265,15 +299,15 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getAttributes(String catalog, String schemaPattern,
-        String typeNamePattern, String attributeNamePattern)
-        throws SQLException {
+            String typeNamePattern, String attributeNamePattern)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getBestRowIdentifier(String catalog, String schema,
-        String table, int scope, boolean nullable) throws SQLException {
+            String table, int scope, boolean nullable) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -304,15 +338,15 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getColumnPrivileges(String catalog, String schema,
-        String table, String columnNamePattern) throws SQLException {
+            String table, String columnNamePattern) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getColumns(String catalog, String schemaPattern,
-        String tableNamePattern, String columnNamePattern)
-        throws SQLException {
+            String tableNamePattern, String columnNamePattern)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -325,8 +359,8 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getCrossReference(String parentCatalog,
-        String parentSchema, String parentTable, String foreignCatalog,
-        String foreignSchema, String foreignTable) throws SQLException {
+            String parentSchema, String parentTable, String foreignCatalog,
+            String foreignSchema, String foreignTable) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -344,7 +378,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public String getDatabaseProductName() throws SQLException {
-        return "VNE Query Language";
+        return "OpenDayLight";
     }
 
     @Override
@@ -383,9 +417,8 @@ public class XSQLBluePrint implements DatabaseMetaData {
     }
 
     @Override
-    public ResultSet getExportedKeys(String catalog, String schema,
-        String table)
-        throws SQLException {
+    public ResultSet getExportedKeys(String catalog, String schema, String table)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -398,15 +431,15 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getFunctionColumns(String catalog, String schemaPattern,
-        String functionNamePattern, String columnNamePattern)
-        throws SQLException {
+            String functionNamePattern, String columnNamePattern)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getFunctions(String catalog, String schemaPattern,
-        String functionNamePattern) throws SQLException {
+            String functionNamePattern) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -418,16 +451,15 @@ public class XSQLBluePrint implements DatabaseMetaData {
     }
 
     @Override
-    public ResultSet getImportedKeys(String catalog, String schema,
-        String table)
-        throws SQLException {
+    public ResultSet getImportedKeys(String catalog, String schema, String table)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getIndexInfo(String catalog, String schema, String table,
-        boolean unique, boolean approximate) throws SQLException {
+            boolean unique, boolean approximate) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -572,22 +604,22 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getPrimaryKeys(String catalog, String schema, String table)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getProcedureColumns(String catalog, String schemaPattern,
-        String procedureNamePattern, String columnNamePattern)
-        throws SQLException {
+            String procedureNamePattern, String columnNamePattern)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getProcedures(String catalog, String schemaPattern,
-        String procedureNamePattern) throws SQLException {
+            String procedureNamePattern) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -618,7 +650,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getSchemas(String catalog, String schemaPattern)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -655,14 +687,14 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getSuperTables(String catalog, String schemaPattern,
-        String tableNamePattern) throws SQLException {
+            String tableNamePattern) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getSuperTypes(String catalog, String schemaPattern,
-        String typeNamePattern) throws SQLException {
+            String typeNamePattern) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -675,14 +707,14 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getTablePrivileges(String catalog, String schemaPattern,
-        String tableNamePattern) throws SQLException {
+            String tableNamePattern) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public ResultSet getTables(String catalog, String schemaPattern,
-        String tableNamePattern, String[] types) throws SQLException {
+            String tableNamePattern, String[] types) throws SQLException {
         return new TablesResultSet(this);
     }
 
@@ -706,7 +738,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getUDTs(String catalog, String schemaPattern,
-        String typeNamePattern, int[] types) throws SQLException {
+            String typeNamePattern, int[] types) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -725,7 +757,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getVersionColumns(String catalog, String schema,
-        String table) throws SQLException {
+            String table) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -905,8 +937,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsCatalogsInPrivilegeDefinitions()
-        throws SQLException {
+    public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -937,7 +968,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public boolean supportsConvert(int fromType, int toType)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -956,21 +987,20 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public boolean supportsDataDefinitionAndDataManipulationTransactions()
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean supportsDataManipulationTransactionsOnly()
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public boolean supportsDifferentTableCorrelationNames()
-        throws SQLException {
+    public boolean supportsDifferentTableCorrelationNames() throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -1133,14 +1163,14 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public boolean supportsResultSetConcurrency(int type, int concurrency)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean supportsResultSetHoldability(int holdability)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -1200,8 +1230,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsStoredFunctionsUsingCallSyntax()
-        throws SQLException {
+    public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -1244,7 +1273,7 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public boolean supportsTransactionIsolationLevel(int level)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -1299,8 +1328,8 @@ public class XSQLBluePrint implements DatabaseMetaData {
 
     @Override
     public ResultSet getPseudoColumns(String catalog, String schemaPattern,
-        String tableNamePattern, String columnNamePattern)
-        throws SQLException {
+            String tableNamePattern, String columnNamePattern)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
index fbd818e63216c40e6c6cb3a053c214584a5bc248..8d905f208132aed258886a58b5c01ab56682e76c 100644 (file)
@@ -3,7 +3,9 @@ package org.opendaylight.controller.md.sal.dom.xsql;
 import java.io.Serializable;
 import java.sql.SQLException;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 public class XSQLBluePrintNode implements Serializable {
@@ -11,10 +13,8 @@ public class XSQLBluePrintNode implements Serializable {
     private static final long serialVersionUID = 1L;
     private Class<?> myInterface = null;
     private String myInterfaceString = null;
-    private Set<XSQLBluePrintRelation> relations =
-        new HashSet<XSQLBluePrintRelation>();
-    private Set<XSQLBluePrintNode> inheritingNodes =
-        new HashSet<XSQLBluePrintNode>();
+    private Set<XSQLBluePrintRelation> relations = new HashSet<XSQLBluePrintRelation>();
+    private Set<XSQLBluePrintNode> inheritingNodes = new HashSet<XSQLBluePrintNode>();
     private Set<XSQLBluePrintNode> children = new HashSet<XSQLBluePrintNode>();
     private XSQLBluePrintNode parent = null;
 
@@ -22,11 +22,20 @@ public class XSQLBluePrintNode implements Serializable {
     private transient Set<String> parentHierarchySet = null;
     private String myInterfaceName = null;
     private Set<XSQLColumn> columns = new HashSet<XSQLColumn>();
+    private Map<String, XSQLColumn> origNameToColumn = new HashMap<String, XSQLColumn>();
 
     private transient Object odlNode = null;
     private boolean module = false;
     private String bluePrintTableName = null;
     private String odlTableName = null;
+    private String origName = null;
+
+    public XSQLBluePrintNode(String name, String _origName, int _level) {
+        this.level = _level;
+        this.odlTableName = name;
+        this.bluePrintTableName = name;
+        this.origName = _origName;
+    }
 
     public XSQLBluePrintNode(Class<?> _myInterface, int _level) {
         this.myInterface = _myInterface;
@@ -35,16 +44,21 @@ public class XSQLBluePrintNode implements Serializable {
         this.level = _level;
     }
 
-    public XSQLBluePrintNode(Object _odlNode, int _level,XSQLBluePrintNode _parent) {
+    public XSQLBluePrintNode(Object _odlNode, int _level,
+            XSQLBluePrintNode _parent) {
         this.odlNode = _odlNode;
         this.level = _level;
         this.module = XSQLODLUtils.isModule(_odlNode);
         this.parent = _parent;
         this.bluePrintTableName = XSQLODLUtils.getBluePrintName(_odlNode);
+        this.odlTableName = XSQLODLUtils.getODLNodeName(this.odlNode);
+    }
 
+    public String getOrigName() {
+        return this.origName;
     }
 
-    public String getBluePrintNodeName(){
+    public String getBluePrintNodeName() {
         return this.bluePrintTableName;
     }
 
@@ -82,10 +96,11 @@ public class XSQLBluePrintNode implements Serializable {
         }
         for (XSQLBluePrintRelation dtr : this.relations) {
             XSQLBluePrintNode parent = dtr.getParent();
-            if (!parent.getInterface().equals(this.getInterface()) && !parent
-                .getInterface().isAssignableFrom(this.getInterface()) &&
-                this.getInterface().isAssignableFrom(parent.getInterface())
-                && parent.isModelChild(p)) {
+            if (!parent.getInterface().equals(this.getInterface())
+                    && !parent.getInterface().isAssignableFrom(
+                            this.getInterface())
+                    && this.getInterface().isAssignableFrom(
+                            parent.getInterface()) && parent.isModelChild(p)) {
                 return true;
             }
         }
@@ -109,8 +124,16 @@ public class XSQLBluePrintNode implements Serializable {
     }
 
     public void addColumn(Object node, String tableName) {
-        XSQLColumn c = new XSQLColumn(node,getBluePrintNodeName(), this);
+        XSQLColumn c = new XSQLColumn(node, getBluePrintNodeName(), this);
+        this.columns.add(c);
+    }
+
+    public XSQLColumn addColumn(String name, String tableName, String origName,
+            String origTableName) {
+        XSQLColumn c = new XSQLColumn(name, tableName, origName, origTableName);
         this.columns.add(c);
+        this.origNameToColumn.put(origName, c);
+        return c;
     }
 
     public void addColumn(String methodName) {
@@ -165,17 +188,16 @@ public class XSQLBluePrintNode implements Serializable {
         throw new SQLException("Unknown field name '" + name + "'");
     }
 
-
     public void addParent(XSQLBluePrintNode parent, String property) {
         try {
             if (property.equals("ContainingTPs")) {
                 return;
             }
-            //Method m = parent.getInterface().getMethod("get"+property, null);
-            //if(!m.getDeclaringClass().equals(parent.getInterface()))
-            //return;
-            XSQLBluePrintRelation rel =
-                new XSQLBluePrintRelation(parent, property, myInterface);
+            // Method m = parent.getInterface().getMethod("get"+property, null);
+            // if(!m.getDeclaringClass().equals(parent.getInterface()))
+            // return;
+            XSQLBluePrintRelation rel = new XSQLBluePrintRelation(parent,
+                    property, myInterface);
             relations.add(rel);
         } catch (Exception err) {
             err.printStackTrace();
@@ -187,8 +209,7 @@ public class XSQLBluePrintNode implements Serializable {
     }
 
     public Set<XSQLBluePrintRelation> getClonedParents() {
-        Set<XSQLBluePrintRelation> result =
-            new HashSet<XSQLBluePrintRelation>();
+        Set<XSQLBluePrintRelation> result = new HashSet<XSQLBluePrintRelation>();
         result.addAll(this.relations);
         return result;
     }
@@ -200,6 +221,9 @@ public class XSQLBluePrintNode implements Serializable {
         if (odlNode != null) {
             return getBluePrintNodeName();
         }
+        if (odlTableName != null) {
+            return odlTableName;
+        }
         return "Unknown";
     }
 
@@ -216,11 +240,12 @@ public class XSQLBluePrintNode implements Serializable {
         XSQLBluePrintNode other = (XSQLBluePrintNode) obj;
         if (odlNode != null) {
             return getBluePrintNodeName().equals(other.getBluePrintNodeName());
-        } else if (this.odlTableName != null) {
+        } else if (this.odlTableName == null && other.odlTableName != null)
+            return false;
+        if (this.odlTableName != null && other.odlTableName == null)
+            return false;
+        else
             return this.odlTableName.equals(other.odlTableName);
-        } else {
-            return other.myInterface.equals(myInterface);
-        }
     }
 
     @Override
index 55ac600f4a3010ccd0b8e63e240fb00b23d31351..4c6cca7fa612d9d00be8bdb47f8f6dd52f339b94 100644 (file)
@@ -8,6 +8,8 @@ public class XSQLColumn implements Serializable, Comparable {
     private int charWidth = -1;
     private Class type = null;
     private transient Object bluePrintNode = null;
+    private String origName = null;
+    private String origTableName = null;
 
     public XSQLColumn(Object odlNode, String _tableName, Object _bluePrintNode) {
         this.name = XSQLODLUtils.getNodeNameFromDSN(odlNode);
@@ -16,6 +18,13 @@ public class XSQLColumn implements Serializable, Comparable {
         this.type = XSQLODLUtils.getTypeForODLColumn(odlNode);
     }
 
+    public XSQLColumn(String _name, String _tableName,String _origName, String _origTableName){
+        this.name = _name;
+        this.tableName = _tableName;
+        this.origName = _origName;
+        this.origTableName = _origTableName;
+    }
+
     public String getName() {
         return name;
     }
index 85ce0e5392b7f249ebe0e095931309fce68ed63f..019711157cc30db5bb7a2e43a6d4f5b2725858f2 100644 (file)
@@ -3,6 +3,8 @@ package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
 import java.io.Serializable;
 import java.util.Map;
 
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
+
 public class JDBCCommand implements Serializable {
     public int type = 0;
     public static final int TYPE_EXECUTE_QUERY = 1;
@@ -10,11 +12,22 @@ public class JDBCCommand implements Serializable {
     public static final int TYPE_QUERY_RECORD = 3;
     public static final int TYPE_QUERY_FINISH = 4;
     public static final int TYPE_QUERY_ERROR = 5;
+    public static final int TYPE_METADATA = 6;
+    public static final int TYPE_METADATA_REPLY = 7;
 
     private JDBCResultSet rs = null;
     private Map record = null;
     private int rsID = -1;
     private Exception err = null;
+    private XSQLBluePrint bluePrint = null;
+
+    public JDBCCommand() {
+
+    }
+
+    public void setType(int t) {
+        this.type = t;
+    }
 
     public JDBCCommand(Exception _err, int _RSID) {
         this.type = TYPE_QUERY_ERROR;
@@ -22,6 +35,11 @@ public class JDBCCommand implements Serializable {
         this.rsID = _RSID;
     }
 
+    public JDBCCommand(XSQLBluePrint bl) {
+        this.type = TYPE_METADATA_REPLY;
+        this.bluePrint = bl;
+    }
+
     public JDBCCommand(JDBCResultSet _rs, int _type) {
         this.type = TYPE_EXECUTE_QUERY;
         this.rs = _rs;
@@ -59,4 +77,8 @@ public class JDBCCommand implements Serializable {
     public Exception getERROR() {
         return this.err;
     }
+
+    public XSQLBluePrint getBluePrint() {
+        return this.bluePrint;
+    }
 }
index 3e72dc95ee83a572d9b45f240afcf5b34468df0c..bf1244f2e3cd90787984105d5395cb7df3c9e853 100644 (file)
@@ -31,38 +31,59 @@ import java.util.Properties;
 import java.util.concurrent.Executor;
 
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
 
-public class JDBCConnection extends Thread implements Connection {
+public class JDBCConnection implements Connection, Runnable {
     private Socket socket = null;
     private DataInputStream in = null;
     private DataOutputStream out = null;
     private LinkedList<byte[]> queue = new LinkedList<byte[]>();
     private XSQLAdapter adapter = null;
+    private XSQLBluePrint metaData = null;
+    private String addr = null;
+    private boolean wasClosed = false;
 
     public JDBCConnection(Socket s, XSQLAdapter _a) {
         this.socket = s;
         this.adapter = _a;
         try {
             in = new DataInputStream(
-                new BufferedInputStream(s.getInputStream()));
-            out = new DataOutputStream(
-                new BufferedOutputStream(s.getOutputStream()));
+                    new BufferedInputStream(s.getInputStream()));
+            out = new DataOutputStream(new BufferedOutputStream(
+                    s.getOutputStream()));
             new JDBCObjectReader();
-            this.start();
+            new Thread(this).start();
         } catch (Exception err) {
             err.printStackTrace();
         }
     }
 
-    public JDBCConnection(String addr) throws Exception {
+    public Connection getProxy() {
+        return this;
+        /*
+        return (Connection) Proxy.newProxyInstance(this.getClass()
+                .getClassLoader(), new Class[] { Connection.class },
+                new JDBCProxy(this));
+                */
+    }
+
+    public JDBCConnection(String _addr) throws Exception {
+        this.addr = _addr;
+        init();
+    }
+
+    private void init() throws Exception {
+        if (addr.startsWith("http://"))
+            addr = addr.substring(7);
+        System.err.print("Address is:" + addr);
         socket = new Socket(addr, 40004);
         try {
-            in = new DataInputStream(
-                new BufferedInputStream(socket.getInputStream()));
-            out = new DataOutputStream(
-                new BufferedOutputStream(socket.getOutputStream()));
+            in = new DataInputStream(new BufferedInputStream(
+                    socket.getInputStream()));
+            out = new DataOutputStream(new BufferedOutputStream(
+                    socket.getOutputStream()));
             new JDBCObjectReader();
-            this.start();
+            new Thread(this).start();
         } catch (Exception err) {
             err.printStackTrace();
         }
@@ -73,12 +94,12 @@ public class JDBCConnection extends Thread implements Connection {
             ServerSocket s = new ServerSocket(50003);
             socket = s.accept();
             try {
-                in = new DataInputStream(
-                    new BufferedInputStream(socket.getInputStream()));
-                out = new DataOutputStream(
-                    new BufferedOutputStream(socket.getOutputStream()));
+                in = new DataInputStream(new BufferedInputStream(
+                        socket.getInputStream()));
+                out = new DataOutputStream(new BufferedOutputStream(
+                        socket.getOutputStream()));
                 new JDBCObjectReader();
-                this.start();
+                new Thread(this).start();
             } catch (Exception err) {
                 err.printStackTrace();
             }
@@ -87,7 +108,6 @@ public class JDBCConnection extends Thread implements Connection {
         }
     }
 
-
     private boolean isStopped() {
         if (adapter != null && adapter.stopped) {
             return true;
@@ -109,11 +129,21 @@ public class JDBCConnection extends Thread implements Connection {
 
             } catch (Exception err) {
                 System.out.println("Connection Lost or Closed.");
+                try {
+                    out.close();
+                } catch (Exception er) {
+                }
+                out = null;
+                try {
+                    in.close();
+                } catch (Exception er) {
+                }
+                in = null;
                 try {
                     socket.close();
                 } catch (Exception err2) {
                 }
-                //err.printStackTrace();
+                socket = null;
             }
         }
     }
@@ -167,38 +197,46 @@ public class JDBCConnection extends Thread implements Connection {
 
     public void processCommand(JDBCCommand cmd) {
         switch (cmd.getType()) {
-            case JDBCCommand.TYPE_EXECUTE_QUERY:
-                try {
-                    JDBCServer.execute(cmd.getRS(), adapter);
-                    send(new JDBCCommand(cmd.getRS(),
-                        JDBCCommand.TYPE_QUERY_REPLY));
-                    QueryUpdater u = new QueryUpdater(cmd.getRS());
-                    new Thread(u).start();
-                } catch (Exception err) {
-                    send(new JDBCCommand(err, cmd.getRSID()));
-                }
-                break;
-            case JDBCCommand.TYPE_QUERY_REPLY:
-                JDBCResultSet rs1 = JDBCStatement.getQuery(cmd.getRS().getID());
-                rs1.updateData(cmd.getRS());
-                break;
-            case JDBCCommand.TYPE_QUERY_RECORD:
-                JDBCResultSet rs2 = JDBCStatement.getQuery(cmd.getRSID());
-                rs2.addRecord(cmd.getRecord());
-                break;
-            case JDBCCommand.TYPE_QUERY_FINISH:
-                JDBCResultSet rs3 = JDBCStatement.removeQuery(cmd.getRSID());
-                rs3.setFinished(true);
-                break;
-            case JDBCCommand.TYPE_QUERY_ERROR:
-                System.err.println("ERROR Executing Query\n");
-                cmd.getERROR().printStackTrace();
-                JDBCResultSet rs4 = JDBCStatement.removeQuery(cmd.getRSID());
-                rs4.setError(cmd.getERROR());
-                rs4.setFinished(true);
-                synchronized (rs4) {
-                    rs4.notifyAll();
-                }
+        case JDBCCommand.TYPE_METADATA_REPLY:
+            this.metaData = cmd.getBluePrint();
+            synchronized (this) {
+                this.notifyAll();
+            }
+            break;
+        case JDBCCommand.TYPE_METADATA:
+            send(new JDBCCommand(this.adapter.getBluePrint()));
+            break;
+        case JDBCCommand.TYPE_EXECUTE_QUERY:
+            try {
+                JDBCServer.execute(cmd.getRS(), adapter);
+                send(new JDBCCommand(cmd.getRS(), JDBCCommand.TYPE_QUERY_REPLY));
+                QueryUpdater u = new QueryUpdater(cmd.getRS());
+                new Thread(u).start();
+            } catch (Exception err) {
+                send(new JDBCCommand(err, cmd.getRSID()));
+            }
+            break;
+        case JDBCCommand.TYPE_QUERY_REPLY:
+            JDBCResultSet rs1 = JDBCStatement.getQuery(cmd.getRS().getID());
+            rs1.updateData(cmd.getRS());
+            break;
+        case JDBCCommand.TYPE_QUERY_RECORD:
+            JDBCResultSet rs2 = JDBCStatement.getQuery(cmd.getRSID());
+            rs2.addRecord(cmd.getRecord());
+            break;
+        case JDBCCommand.TYPE_QUERY_FINISH:
+            JDBCResultSet rs3 = JDBCStatement.removeQuery(cmd.getRSID());
+            rs3.setFinished(true);
+            break;
+        case JDBCCommand.TYPE_QUERY_ERROR:
+            System.err.println("ERROR Executing Query\n");
+            cmd.getERROR().printStackTrace();
+            JDBCResultSet rs4 = JDBCStatement.removeQuery(cmd.getRSID());
+            rs4.setError(cmd.getERROR());
+            rs4.setFinished(true);
+            synchronized (rs4) {
+                rs4.notifyAll();
+            }
         }
     }
 
@@ -221,6 +259,15 @@ public class JDBCConnection extends Thread implements Connection {
     }
 
     public void send(Object o) {
+
+        if (this.socket == null) {
+            try {
+                init();
+            } catch (Exception err) {
+                err.printStackTrace();
+            }
+        }
+
         try {
             ByteArrayOutputStream bout = new ByteArrayOutputStream();
             ObjectOutputStream oout = new ObjectOutputStream(bout);
@@ -256,6 +303,7 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public void close() throws SQLException {
+        wasClosed = true;
         try {
             socket.close();
         } catch (Exception err) {
@@ -271,7 +319,7 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public Array createArrayOf(String typeName, Object[] elements)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -302,28 +350,25 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public Statement createStatement() throws SQLException {
-        return new JDBCStatement(this);
+        return new JDBCStatement(this).getProxy();
     }
 
     @Override
     public Statement createStatement(int resultSetType,
-        int resultSetConcurrency, int resultSetHoldability)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            int resultSetConcurrency, int resultSetHoldability)
+            throws SQLException {
+        return new JDBCStatement(this).getProxy();
     }
 
     @Override
-    public Statement createStatement(int resultSetType,
-        int resultSetConcurrency)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+    public Statement createStatement(int resultSetType, int resultSetConcurrency)
+            throws SQLException {
+        return new JDBCStatement(this).getProxy();
     }
 
     @Override
     public Struct createStruct(String typeName, Object[] attributes)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -360,8 +405,19 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public DatabaseMetaData getMetaData() throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        if (this.metaData == null) {
+            JDBCCommand cmd = new JDBCCommand();
+            cmd.setType(JDBCCommand.TYPE_METADATA);
+            synchronized (this) {
+                send(cmd);
+                try {
+                    this.wait();
+                } catch (Exception err) {
+                    err.printStackTrace();
+                }
+            }
+        }
+        return metaData;
     }
 
     @Override
@@ -384,7 +440,6 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public boolean isClosed() throws SQLException {
-        // TODO Auto-generated method stub
         return false;
     }
 
@@ -408,15 +463,15 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public CallableStatement prepareCall(String sql, int resultSetType,
-        int resultSetConcurrency, int resultSetHoldability)
-        throws SQLException {
+            int resultSetConcurrency, int resultSetHoldability)
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public CallableStatement prepareCall(String sql, int resultSetType,
-        int resultSetConcurrency) throws SQLException {
+            int resultSetConcurrency) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -429,44 +484,44 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public PreparedStatement prepareStatement(String sql, int resultSetType,
-        int resultSetConcurrency, int resultSetHoldability)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            int resultSetConcurrency, int resultSetHoldability)
+            throws SQLException {
+        System.err.println("SQL 1=" + sql);
+        return new JDBCStatement(this, sql).getProxy();
     }
 
     @Override
     public PreparedStatement prepareStatement(String sql, int resultSetType,
-        int resultSetConcurrency) throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            int resultSetConcurrency) throws SQLException {
+        System.err.println("SQL 2=" + sql);
+        return new JDBCStatement(this, sql).getProxy();
     }
 
     @Override
     public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            throws SQLException {
+        System.err.println("SQL 3=" + sql);
+        return new JDBCStatement(this, sql).getProxy();
     }
 
     @Override
     public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            throws SQLException {
+        System.err.println("SQL 4=" + sql);
+        return new JDBCStatement(this, sql).getProxy();
     }
 
     @Override
     public PreparedStatement prepareStatement(String sql, String[] columnNames)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            throws SQLException {
+        System.err.println("SQL 5=" + sql);
+        return new JDBCStatement(this, sql).getProxy();
     }
 
     @Override
     public PreparedStatement prepareStatement(String sql) throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        System.err.println("SQL 6=" + sql);
+        return new JDBCStatement(this, sql).getProxy();
     }
 
     @Override
@@ -501,14 +556,14 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public void setClientInfo(Properties properties)
-        throws SQLClientInfoException {
+            throws SQLClientInfoException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void setClientInfo(String name, String value)
-        throws SQLClientInfoException {
+            throws SQLClientInfoException {
         // TODO Auto-generated method stub
 
     }
@@ -569,7 +624,7 @@ public class JDBCConnection extends Thread implements Connection {
 
     @Override
     public void setNetworkTimeout(Executor executor, int milliseconds)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -579,5 +634,5 @@ public class JDBCConnection extends Thread implements Connection {
         // TODO Auto-generated method stub
         return 0;
     }
-}
 
+}
diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCProxy.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCProxy.java
new file mode 100644 (file)
index 0000000..7e29947
--- /dev/null
@@ -0,0 +1,24 @@
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+public class JDBCProxy implements InvocationHandler {
+
+    private Object myObject = null;
+    private Class<?> myObjectClass = null;
+
+    public JDBCProxy(Object obj) {
+        this.myObject = obj;
+        this.myObjectClass = this.myObject.getClass();
+    }
+
+    @Override
+    public Object invoke(Object proxy, Method method, Object[] args)
+            throws Throwable {
+        System.err.println("Class " + this.myObjectClass.getSimpleName()
+                + " Method " + method.getName());
+        return method.invoke(this.myObject, args);
+    }
+
+}
index 7603a3e9ae34aac783b0f049e8e671d7bbd1a549..021f6ee19b7d0bfdb71cdfc8f954783191e99f4f 100644 (file)
@@ -4,6 +4,7 @@ import java.io.InputStream;
 import java.io.Reader;
 import java.io.Serializable;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.sql.Array;
@@ -37,15 +38,13 @@ import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLODLUtils;
 
-public class JDBCResultSet
-    implements Serializable, ResultSet, ResultSetMetaData {
+public class JDBCResultSet implements Serializable, ResultSet,
+        ResultSetMetaData {
     private static final long serialVersionUID = -7450200738431047057L;
 
     private String sql = null;
-    private List<XSQLBluePrintNode> tablesInQuery =
-        new ArrayList<XSQLBluePrintNode>();
-    private Map<String, XSQLBluePrintNode> tablesInQueryMap =
-        new ConcurrentHashMap<String, XSQLBluePrintNode>();
+    private List<XSQLBluePrintNode> tablesInQuery = new ArrayList<XSQLBluePrintNode>();
+    private Map<String, XSQLBluePrintNode> tablesInQueryMap = new ConcurrentHashMap<String, XSQLBluePrintNode>();
     private List<XSQLColumn> fieldsInQuery = new ArrayList<XSQLColumn>();
     private transient LinkedList<Map> records = new LinkedList<Map>();
     private transient Map currentRecord = null;
@@ -53,10 +52,32 @@ public class JDBCResultSet
     private int id = 0;
     private static Integer nextID = new Integer(0);
     public int numberOfTasks = 0;
-    private Map<String, Map<XSQLColumn, List<XSQLCriteria>>> criteria =
-        new ConcurrentHashMap<String, Map<XSQLColumn, List<XSQLCriteria>>>();
+    private Map<String, Map<XSQLColumn, List<XSQLCriteria>>> criteria = new ConcurrentHashMap<String, Map<XSQLColumn, List<XSQLCriteria>>>();
     private Exception err = null;
     private List<Record> EMPTY_RESULT = new LinkedList<Record>();
+    private transient Map<String,JDBCResultSet> subQueries = new HashMap<String,JDBCResultSet>();
+
+    public ResultSet getProxy() {
+         return (ResultSet) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ResultSet.class }, new JDBCProxy(this));
+    }
+
+    public void setSQL(String _sql) {
+        this.sql = _sql;
+    }
+
+    public JDBCResultSet addSubQuery(String _sql,String logicalName) {
+        if(subQueries == null)
+            subQueries = new HashMap<String,JDBCResultSet>();
+        JDBCResultSet rs = new JDBCResultSet(_sql);
+        this.subQueries.put(logicalName,rs);
+        return rs;
+    }
+
+    public Map<String,JDBCResultSet> getSubQueries() {
+        if(this.subQueries==null)
+            this.subQueries = new HashMap<>();
+        return this.subQueries;
+    }
 
     public JDBCResultSet(String _sql) {
         synchronized (JDBCResultSet.class) {
@@ -88,12 +109,13 @@ public class JDBCResultSet
     }
 
     public int isObjectFitCriteria(Map objValues, String tableName) {
-        Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria.get(tableName);
+        Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria
+                .get(tableName);
         if (tblCriteria == null) {
             return 1;
         }
         for (Map.Entry<XSQLColumn, List<XSQLCriteria>> cc : tblCriteria
-            .entrySet()) {
+                .entrySet()) {
             for (XSQLCriteria c : cc.getValue()) {
                 Object value = objValues.get(cc.getKey().toString());
                 int result = c.checkValue(value);
@@ -106,16 +128,16 @@ public class JDBCResultSet
     }
 
     public int isObjectFitCriteria(Object element, Class cls) {
-        Map<XSQLColumn, List<XSQLCriteria>> tblCriteria =
-            criteria.get(cls.getName());
+        Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria.get(cls
+                .getName());
         if (tblCriteria == null) {
             return 1;
         }
         for (Map.Entry<XSQLColumn, List<XSQLCriteria>> cc : tblCriteria
-            .entrySet()) {
+                .entrySet()) {
             for (XSQLCriteria c : cc.getValue()) {
-                int result =
-                    c.isObjectFitCriteria(element, cc.getKey().getName());
+                int result = c.isObjectFitCriteria(element, cc.getKey()
+                        .getName());
                 if (result == 0) {
                     return 0;
                 }
@@ -185,16 +207,15 @@ public class JDBCResultSet
         }
     }
 
-
     public void addRecord(ArrayList hierarchy) {
         Map rec = new HashMap();
         for (int i = hierarchy.size() - 1; i >= 0; i--) {
             Object element = hierarchy.get(i);
             for (XSQLColumn c : fieldsInQuery) {
-                if (c.getTableName()
-                    .equals(element.getClass().getSimpleName())) {
+                if (c.getTableName().equals(element.getClass().getSimpleName())) {
                     try {
-                        Method m = element.getClass().getMethod(c.getName(), null);
+                        Method m = element.getClass().getMethod(c.getName(),
+                                null);
                         Object value = m.invoke(element, null);
                         rec.put(c.getName(), value);
                     } catch (Exception err) {
@@ -276,18 +297,16 @@ public class JDBCResultSet
         Map subChildren = XSQLODLUtils.getChildren(node);
         Map result = new HashMap();
         for (Object stc : subChildren.values()) {
-            if (stc.getClass().getName()
-                .endsWith("ImmutableAugmentationNode")) {
+            if (stc.getClass().getName().endsWith("ImmutableAugmentationNode")) {
                 Map values = XSQLODLUtils.getChildren(stc);
                 for (Object key : values.keySet()) {
                     Object val = values.get(key);
-                    if (val.getClass().getName()
-                        .endsWith("ImmutableLeafNode")) {
+                    if (val.getClass().getName().endsWith("ImmutableLeafNode")) {
                         Object value = XSQLODLUtils.getValue(val);
                         String k = XSQLODLUtils.getNodeName(val);
                         if (value != null) {
                             result.put(bpn.getBluePrintNodeName() + "." + k,
-                                value.toString());
+                                    value.toString());
                         }
                     }
                 }
@@ -295,20 +314,27 @@ public class JDBCResultSet
                 String k = XSQLODLUtils.getNodeName(stc);
                 Object value = XSQLODLUtils.getValue(stc);
                 if (value != null) {
-                    result.put(bpn.getBluePrintNodeName() + "." + k, value.toString());
+                    result.put(bpn.getBluePrintNodeName() + "." + k,
+                            value.toString());
                 }
             }
         }
         return result;
     }
 
-    private void addToData(Record rec, XSQLBluePrintNode bpn, XSQLBluePrint bluePrint, Map fullRecord) {
-        XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(XSQLODLUtils.getNodeIdentiofier(rec.element));
+    private void addToData(Record rec, XSQLBluePrintNode bpn,
+            XSQLBluePrint bluePrint, Map fullRecord) {
+        XSQLBluePrintNode eNodes[] = bluePrint
+                .getBluePrintNodeByODLTableName(XSQLODLUtils
+                        .getNodeIdentiofier(rec.element));
         if (bpn != null) {
             for (XSQLColumn c : fieldsInQuery) {
-                for(XSQLBluePrintNode eNode:eNodes){
-                    if (((XSQLBluePrintNode) c.getBluePrintNode()).getBluePrintNodeName().equals(eNode.getBluePrintNodeName())) {
-                        //Object value = Criteria.getValue(rec.element, c.getName());
+                for (XSQLBluePrintNode eNode : eNodes) {
+                    if (((XSQLBluePrintNode) c.getBluePrintNode())
+                            .getBluePrintNodeName().equals(
+                                    eNode.getBluePrintNodeName())) {
+                        // Object value = Criteria.getValue(rec.element,
+                        // c.getName());
                         String columnName = c.toString();
                         Object value = fullRecord.get(columnName);
                         if (value != null) {
@@ -346,7 +372,8 @@ public class JDBCResultSet
         return false;
     }
 
-    public List<Object> getChildren(Object node, String tableName,XSQLBluePrint bluePrint) {
+    public List<Object> getChildren(Object node, String tableName,
+            XSQLBluePrint bluePrint) {
 
         List<Object> children = XSQLODLUtils.getMChildren(node);
         List<Object> result = new LinkedList<Object>();
@@ -354,28 +381,33 @@ public class JDBCResultSet
         for (Object child : children) {
 
             String odlNodeName = XSQLODLUtils.getNodeIdentiofier(child);
-            if(odlNodeName==null) continue;
+            if (odlNodeName == null)
+                continue;
 
-            XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(odlNodeName);
-            if(eNodes==null) continue;
+            XSQLBluePrintNode eNodes[] = bluePrint
+                    .getBluePrintNodeByODLTableName(odlNodeName);
+            if (eNodes == null)
+                continue;
 
             boolean match = false;
-            for(XSQLBluePrintNode enode:eNodes){
-                if(tableName.startsWith(enode.toString())){
+            for (XSQLBluePrintNode enode : eNodes) {
+                if (tableName.startsWith(enode.toString())) {
                     match = true;
                     break;
                 }
             }
 
-            if(!match) continue;
+            if (!match)
+                continue;
 
             if (child.getClass().getName().endsWith("ImmutableContainerNode")) {
                 result.add(child);
-            }else
-            if (child.getClass().getName().endsWith("ImmutableAugmentationNode")) {
+            } else if (child.getClass().getName()
+                    .endsWith("ImmutableAugmentationNode")) {
                 List<Object> _children = XSQLODLUtils.getMChildren(child);
                 for (Object c : _children) {
-                    if (c.getClass().getName().endsWith("ImmutableContainerNode")) {
+                    if (c.getClass().getName()
+                            .endsWith("ImmutableContainerNode")) {
                         result.add(c);
                     }
                 }
@@ -386,21 +418,26 @@ public class JDBCResultSet
         return result;
     }
 
-    public List<Record> addRecords(Object element, XSQLBluePrintNode node,boolean root, String tableName,XSQLBluePrint bluePrint) {
+    public List<Record> addRecords(Object element, XSQLBluePrintNode node,
+            boolean root, String tableName, XSQLBluePrint bluePrint) {
 
         List<Record> result = new LinkedList<Record>();
         String nodeID = XSQLODLUtils.getNodeIdentiofier(element);
         if (node.getODLTableName().equals(nodeID)) {
-            XSQLBluePrintNode bluePrintNode = bluePrint.getBluePrintNodeByODLTableName(nodeID)[0];
+            XSQLBluePrintNode bluePrintNode = bluePrint
+                    .getBluePrintNodeByODLTableName(nodeID)[0];
             Record rec = new Record();
             rec.element = element;
-            XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode.getBluePrintNodeName());
-            if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName()) || bpn != null) {
+            XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode
+                    .getBluePrintNodeName());
+            if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName())
+                    || bpn != null) {
                 Map<?, ?> allKeyValues = collectColumnValues(element, bpn);
-                if (!(isObjectFitCriteria(allKeyValues, bpn.getBluePrintNodeName()) == 1)) {
+                if (!(isObjectFitCriteria(allKeyValues,
+                        bpn.getBluePrintNodeName()) == 1)) {
                     return EMPTY_RESULT;
                 }
-                addToData(rec, bpn, bluePrint,allKeyValues);
+                addToData(rec, bpn, bluePrint, allKeyValues);
             }
             if (root) {
                 addRecord(rec.data);
@@ -411,9 +448,11 @@ public class JDBCResultSet
         }
 
         XSQLBluePrintNode parent = node.getParent();
-        List<Record> subRecords = addRecords(element, parent, false, tableName,bluePrint);
+        List<Record> subRecords = addRecords(element, parent, false, tableName,
+                bluePrint);
         for (Record subRec : subRecords) {
-            List<Object> subO = getChildren(subRec.element, tableName,bluePrint);
+            List<Object> subO = getChildren(subRec.element, tableName,
+                    bluePrint);
             if (subO != null) {
                 for (Object subData : subO) {
                     Record rec = new Record();
@@ -421,18 +460,21 @@ public class JDBCResultSet
                     rec.data.putAll(subRec.data);
 
                     String recID = XSQLODLUtils.getNodeIdentiofier(rec.element);
-                    XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(recID);
+                    XSQLBluePrintNode eNodes[] = bluePrint
+                            .getBluePrintNodeByODLTableName(recID);
                     XSQLBluePrintNode bpn = null;
-                    for(XSQLBluePrintNode eNode:eNodes){
-                        bpn = this.tablesInQueryMap.get(eNode.getBluePrintNodeName());
-                        if(bpn!=null)
+                    for (XSQLBluePrintNode eNode : eNodes) {
+                        bpn = this.tablesInQueryMap.get(eNode
+                                .getBluePrintNodeName());
+                        if (bpn != null)
                             break;
                     }
                     boolean isObjectInCriteria = true;
                     if (bpn != null) {
                         Map allKeyValues = collectColumnValues(rec.element, bpn);
-                        if ((isObjectFitCriteria(allKeyValues, bpn.getBluePrintNodeName()) == 1)) {
-                            addToData(rec, bpn,bluePrint,allKeyValues);
+                        if ((isObjectFitCriteria(allKeyValues,
+                                bpn.getBluePrintNodeName()) == 1)) {
+                            addToData(rec, bpn, bluePrint, allKeyValues);
                         } else {
                             isObjectInCriteria = false;
                         }
@@ -440,7 +482,7 @@ public class JDBCResultSet
 
                     if (isObjectInCriteria) {
                         if (root) {
-                            if(!rec.data.isEmpty())
+                            if (!rec.data.isEmpty())
                                 addRecord(rec.data);
                         } else {
                             result.add(rec);
@@ -545,7 +587,7 @@ public class JDBCResultSet
 
     @Override
     public BigDecimal getBigDecimal(int columnIndex, int scale)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -558,7 +600,7 @@ public class JDBCResultSet
 
     @Override
     public BigDecimal getBigDecimal(String columnLabel, int scale)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -798,22 +840,20 @@ public class JDBCResultSet
 
     @Override
     public Object getObject(int columnIndex, Map<String, Class<?>> map)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            throws SQLException {
+        return getObject(columnIndex);
     }
 
     @Override
     public Object getObject(int columnIndex) throws SQLException {
-        return currentRecord
-            .get(this.fieldsInQuery.get(columnIndex - 1).toString());
+        return currentRecord.get(this.fieldsInQuery.get(columnIndex - 1)
+                .toString());
     }
 
     @Override
     public Object getObject(String columnLabel, Map<String, Class<?>> map)
-        throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+            throws SQLException {
+        return getObject(columnLabel);
     }
 
     @Override
@@ -883,14 +923,12 @@ public class JDBCResultSet
 
     @Override
     public String getString(int columnIndex) throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        return "Kuku";
     }
 
     @Override
     public String getString(String columnLabel) throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        return "Kuku";
     }
 
     @Override
@@ -919,7 +957,7 @@ public class JDBCResultSet
 
     @Override
     public Timestamp getTimestamp(int columnIndex, Calendar cal)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -932,7 +970,7 @@ public class JDBCResultSet
 
     @Override
     public Timestamp getTimestamp(String columnLabel, Calendar cal)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -945,8 +983,7 @@ public class JDBCResultSet
 
     @Override
     public int getType() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        return ResultSet.TYPE_FORWARD_ONLY;
     }
 
     @Override
@@ -968,8 +1005,7 @@ public class JDBCResultSet
     }
 
     @Override
-    public InputStream getUnicodeStream(String columnLabel)
-        throws SQLException {
+    public InputStream getUnicodeStream(String columnLabel) throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -1096,100 +1132,98 @@ public class JDBCResultSet
 
     @Override
     public void updateAsciiStream(int columnIndex, InputStream x, int length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateAsciiStream(int columnIndex, InputStream x, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateAsciiStream(int columnIndex, InputStream x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateAsciiStream(String columnLabel, InputStream x, int length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
-    public void updateAsciiStream(String columnLabel, InputStream x,
-        long length)
-        throws SQLException {
+    public void updateAsciiStream(String columnLabel, InputStream x, long length)
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateAsciiStream(String columnLabel, InputStream x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBigDecimal(int columnIndex, BigDecimal x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBigDecimal(String columnLabel, BigDecimal x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBinaryStream(int columnIndex, InputStream x, int length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBinaryStream(int columnIndex, InputStream x, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBinaryStream(int columnIndex, InputStream x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
-    public void updateBinaryStream(String columnLabel, InputStream x,
-        int length)
-        throws SQLException {
+    public void updateBinaryStream(String columnLabel, InputStream x, int length)
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBinaryStream(String columnLabel, InputStream x,
-        long length) throws SQLException {
+            long length) throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBinaryStream(String columnLabel, InputStream x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1201,16 +1235,15 @@ public class JDBCResultSet
     }
 
     @Override
-    public void updateBlob(int columnIndex, InputStream inputStream,
-        long length)
-        throws SQLException {
+    public void updateBlob(int columnIndex, InputStream inputStream, long length)
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBlob(int columnIndex, InputStream inputStream)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1223,14 +1256,14 @@ public class JDBCResultSet
 
     @Override
     public void updateBlob(String columnLabel, InputStream inputStream,
-        long length) throws SQLException {
+            long length) throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateBlob(String columnLabel, InputStream inputStream)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1243,7 +1276,7 @@ public class JDBCResultSet
 
     @Override
     public void updateBoolean(String columnLabel, boolean x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1274,42 +1307,42 @@ public class JDBCResultSet
 
     @Override
     public void updateCharacterStream(int columnIndex, Reader x, int length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateCharacterStream(int columnIndex, Reader x, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateCharacterStream(int columnIndex, Reader x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateCharacterStream(String columnLabel, Reader reader,
-        int length) throws SQLException {
+            int length) throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateCharacterStream(String columnLabel, Reader reader,
-        long length) throws SQLException {
+            long length) throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateCharacterStream(String columnLabel, Reader reader)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1322,7 +1355,7 @@ public class JDBCResultSet
 
     @Override
     public void updateClob(int columnIndex, Reader reader, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1341,14 +1374,14 @@ public class JDBCResultSet
 
     @Override
     public void updateClob(String columnLabel, Reader reader, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateClob(String columnLabel, Reader reader)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1415,28 +1448,28 @@ public class JDBCResultSet
 
     @Override
     public void updateNCharacterStream(int columnIndex, Reader x, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNCharacterStream(int columnIndex, Reader x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNCharacterStream(String columnLabel, Reader reader,
-        long length) throws SQLException {
+            long length) throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNCharacterStream(String columnLabel, Reader reader)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1449,49 +1482,48 @@ public class JDBCResultSet
 
     @Override
     public void updateNClob(int columnIndex, Reader reader, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
-    public void updateNClob(int columnIndex, Reader reader)
-        throws SQLException {
+    public void updateNClob(int columnIndex, Reader reader) throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNClob(String columnLabel, NClob nClob)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNClob(String columnLabel, Reader reader, long length)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNClob(String columnLabel, Reader reader)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNString(int columnIndex, String nString)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateNString(String columnLabel, String nString)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1510,7 +1542,7 @@ public class JDBCResultSet
 
     @Override
     public void updateObject(int columnIndex, Object x, int scaleOrLength)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1523,7 +1555,7 @@ public class JDBCResultSet
 
     @Override
     public void updateObject(String columnLabel, Object x, int scaleOrLength)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1566,14 +1598,14 @@ public class JDBCResultSet
 
     @Override
     public void updateSQLXML(int columnIndex, SQLXML xmlObject)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateSQLXML(String columnLabel, SQLXML xmlObject)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1616,14 +1648,14 @@ public class JDBCResultSet
 
     @Override
     public void updateTimestamp(int columnIndex, Timestamp x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
 
     @Override
     public void updateTimestamp(String columnLabel, Timestamp x)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
 
     }
@@ -1670,8 +1702,7 @@ public class JDBCResultSet
 
     @Override
     public int getColumnType(int column) throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        return 12;
     }
 
     @Override
@@ -1766,15 +1797,11 @@ public class JDBCResultSet
 
     @Override
     public <T> T getObject(String columnLabel, Class<T> type)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return null;
     }
 
-
-
-    ////Metadata
-
-
+    // //Metadata
 
 }
index 26b8c70b8bd82afc1dc2d9c3f9ffa9f268b27fde..5be701f82e64497fea4ef863dfd7a147bd360499 100644 (file)
@@ -1,20 +1,22 @@
 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
 
-import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
-import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
-import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode;
-import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
-import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
-
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
+
 public class JDBCServer extends Thread {
     private ServerSocket socket = null;
     private XSQLAdapter adapter = null;
@@ -47,19 +49,179 @@ public class JDBCServer extends Thread {
     }
 
     public static void execute(JDBCResultSet rs, XSQLAdapter adapter)
-        throws SQLException {
-        parseTables(rs, adapter.getBluePrint());
-        parseFields(rs, adapter.getBluePrint());
-        parseCriteria(rs, adapter.getBluePrint());
+            throws SQLException {
+        if(rs.getSQL().toLowerCase().trim().equals("select 1")){
+            rs.setFinished(true);
+            return;
+        }
+        checkAndBreakSubQueries(rs, adapter);
+        if (rs.getSubQueries().size() == 0) {
+            parseTables(rs, adapter.getBluePrint());
+            parseFields(rs, adapter.getBluePrint());
+            parseCriteria(rs, adapter.getBluePrint());
+            try {
+                adapter.execute(rs);
+            } catch (Exception err) {
+                throw new SQLException("Error", err);
+            }
+        } else {
+            parseExternalQuery(rs);
+        }
+    }
+
+    public static void parseExternalQuery(JDBCResultSet rs) throws SQLException {
+        String sql = rs.getSQL();
+        for (Map.Entry<String, JDBCResultSet> entry : rs.getSubQueries()
+                .entrySet()) {
+            int index = sql.toLowerCase().indexOf(entry.getValue().getSQL());
+            String extSql = sql.substring(0, index);
+            index = extSql.lastIndexOf("(");
+            extSql = extSql.substring(0, index);
+            System.out.println("External SQL=" + extSql);
+            parseLogicalFields(extSql, rs);
+        }
+    }
+
+    public static void parseLogicalFields(String sql, JDBCResultSet rs)
+            throws SQLException {
+        if(sql.trim().toLowerCase().equals("select * from")){
+            for (Map.Entry<String, JDBCResultSet> entry : rs.getSubQueries().entrySet()) {
+                for(XSQLBluePrintNode node:entry.getValue().getTables()){
+                    rs.addTableToQuery(node);
+                }
+                rs.getFields().addAll(entry.getValue().getFields());
+                while (entry.getValue().next()) {
+                    Map rec = entry.getValue().getCurrent();
+                    Map newRec = new HashMap();
+                    newRec.putAll(rec);
+                    rs.addRecord(newRec);
+                }
+            }
+            rs.setFinished(true);
+            return;
+        }
+
+        Map<String, XSQLBluePrintNode> logicalNameToNode = new HashMap<String, XSQLBluePrintNode>();
+        Map<String, String> origNameToName = new HashMap<String, String>();
+        List<XSQLColumn> columnOrder = new ArrayList<>();
+        int nextLogField = addNextLogicalField(sql, 0,
+                logicalNameToNode, origNameToName,columnOrder);
+        int next = sql.toLowerCase().indexOf(" as ", nextLogField);
+        while (next != -1) {
+            nextLogField = addNextLogicalField(sql, nextLogField + 1,
+                    logicalNameToNode, origNameToName,columnOrder);
+            next = sql.toLowerCase().indexOf(" as ", nextLogField + 1);
+        }
+
+        for (XSQLBluePrintNode node : logicalNameToNode.values()) {
+            rs.addTableToQuery(node);
+        }
+        rs.getFields().addAll(columnOrder);
+        for (Map.Entry<String, JDBCResultSet> entry : rs.getSubQueries().entrySet()) {
+            while (entry.getValue().next()) {
+                Map rec = entry.getValue().getCurrent();
+                Map newRec = new HashMap();
+                for (Iterator iter = rec.entrySet().iterator(); iter.hasNext();) {
+                    Map.Entry e = (Map.Entry) iter.next();
+                    String key = (String) e.getKey();
+                    Object value = e.getValue();
+                    String logicalKey = origNameToName.get(key);
+                    if (value != null && logicalKey != null) {
+                        newRec.put(logicalKey, value);
+                    }
+                }
+                rs.addRecord(newRec);
+            }
+        }
+        rs.setFinished(true);
+    }
+
+    public static void main(String args[]) {
+        String sql = "SELECT DISTINCT"
+                + "\"LOGICAL_TABLE_1\".\"nodes/node.id\" AS \"COL0\"\n"
+                + ",\"LOGICAL_TABLE_1\".\"nodes/node.id\" AS \"COL1\"\n"
+                + ",\"LOGICAL_TABLE_1\".\"nodes/node.id\" AS \"COL2\"\n"
+                + "FROM\n"
+                + "(select * from nodes/node;) \"LOGICAL_TABLE_1\"\n";
+        JDBCResultSet rs = new JDBCResultSet(sql);
         try {
-            adapter.execute(rs);
+            parseLogicalFields(sql, rs);
         } catch (Exception err) {
-            throw new SQLException("Error", err);
+            err.printStackTrace();
+        }
+    }
+
+    public static int addNextLogicalField(String sql, int startIndex,
+            Map<String, XSQLBluePrintNode> logicalNameToNode,
+            Map<String, String> origNameToName, List<XSQLColumn> columnOrder) {
+        int index1 = sql.indexOf("\"", startIndex);
+        int index2 = sql.indexOf("\".\"", index1);
+        int index3 = sql.indexOf("\"", index2 + 3);
+        int index4 = sql.toLowerCase().indexOf(" as ", startIndex);
+        int index5 = sql.indexOf("\"", index4);
+        int index6 = sql.indexOf("\"", index5 + 1);
+
+        String tblName = sql.substring(index1 + 1, index2);
+        String origFieldNameFull = sql.substring(index2 + 3, index3);
+        String origTableName = "";
+        String origFieldName = "";
+        if (origFieldNameFull.indexOf(".") != -1) {
+            origTableName = origFieldNameFull.substring(0,origFieldNameFull.indexOf("."));
+            origFieldName = origFieldNameFull.substring(origFieldNameFull.indexOf(".") + 1);
+        }
+        String logicalFieldName = sql.substring(index5 + 1, index6);
+        XSQLBluePrintNode node = logicalNameToNode.get(tblName);
+        if (node == null) {
+            node = new XSQLBluePrintNode(tblName, origTableName, 0);
+            logicalNameToNode.put(tblName, node);
+        }
+        columnOrder.add(node.addColumn(logicalFieldName, tblName, origFieldName, origTableName));
+        origNameToName.put(origFieldNameFull, tblName + "." + logicalFieldName);
+        return index6;
+    }
+
+    public static void checkAndBreakSubQueries(JDBCResultSet rs,XSQLAdapter adapter) throws SQLException {
+        String sql = rs.getSQL().toLowerCase();
+        int index = sql.indexOf("select");
+        if (index == -1)
+            throw new SQLException("Select statement is missing...");
+        int index2 = sql.indexOf("select", index + 6);
+        if (index2 != -1) {
+            int startSubQuery = index2;
+            for (int i = startSubQuery; i >= 0; i--) {
+                if (sql.charAt(i) == '(') {
+                    startSubQuery = i;
+                    break;
+                }
+            }
+            int braketCount = 0;
+            int endSubQuery = startSubQuery;
+            do {
+                if (sql.charAt(endSubQuery) == '(')
+                    braketCount++;
+                else if (sql.charAt(endSubQuery) == ')')
+                    braketCount--;
+                endSubQuery++;
+            } while (braketCount > 0 || endSubQuery == sql.length());
+            String subQuerySQL = sql.substring(startSubQuery + 1,endSubQuery - 1);
+            if(rs.getSQL().toLowerCase().substring(0,startSubQuery).trim().equals("select * from")){
+                rs.setSQL(subQuerySQL);
+                return;
+            }
+            index = sql.indexOf("\"", endSubQuery);
+            index2 = sql.indexOf("\"", index + 1);
+            if(index==-1){
+                index = endSubQuery;
+                index2 = sql.length();
+            }
+            String logicalName = rs.getSQL().substring(index + 1, index2).trim();
+            JDBCResultSet subRS = rs.addSubQuery(subQuerySQL, logicalName);
+            JDBCServer.execute(subRS, adapter);
         }
     }
 
     public static void parseTables(JDBCResultSet rs, XSQLBluePrint bp)
-        throws SQLException {
+            throws SQLException {
         String lowSQL = rs.getSQL().toLowerCase();
         int from = lowSQL.indexOf("from");
         int where = lowSQL.indexOf("where");
@@ -90,20 +252,19 @@ public class JDBCServer extends Thread {
             String tableName = tokens.nextToken().trim();
             XSQLBluePrintNode table = bp.getBluePrintNodeByTableName(tableName);
             if (table == null) {
-                throw new SQLException(
-                    "Unknown table name \"" + tableName + "\"");
+                throw new SQLException("Unknown table name \"" + tableName
+                        + "\"");
             }
             rs.addTableToQuery(table);
         }
     }
 
     public static void addCriteria(XSQLColumn col, XSQLCriteria c,
-        JDBCResultSet rs) {
-        Map<XSQLColumn, List<XSQLCriteria>> tblCriteria =
-            rs.getCriteria().get(col.getTableName());
+            JDBCResultSet rs) {
+        Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = rs.getCriteria().get(
+                col.getTableName());
         if (tblCriteria == null) {
-            tblCriteria =
-                new ConcurrentHashMap<XSQLColumn, List<XSQLCriteria>>();
+            tblCriteria = new ConcurrentHashMap<XSQLColumn, List<XSQLCriteria>>();
             rs.getCriteria().put(col.getTableName(), tblCriteria);
         }
         List<XSQLCriteria> lstCriteria = tblCriteria.get(col);
@@ -115,7 +276,7 @@ public class JDBCServer extends Thread {
     }
 
     public static void parseFields(JDBCResultSet rs, XSQLBluePrint bp)
-        throws SQLException {
+            throws SQLException {
         String lowSQL = rs.getSQL().toLowerCase();
         if (!lowSQL.startsWith("select")) {
             throw new SQLException("Missing 'select' statement.");
@@ -135,8 +296,8 @@ public class JDBCServer extends Thread {
                 return;
             }
             if (token.indexOf(".") != -1) {
-                XSQLBluePrintNode tbl = bp.getBluePrintNodeByTableName(
-                    token.substring(0, token.indexOf(".")).trim());
+                XSQLBluePrintNode tbl = bp.getBluePrintNodeByTableName(token
+                        .substring(0, token.indexOf(".")).trim());
                 String p = token.substring(token.indexOf(".") + 1);
                 if (p.equals("*")) {
                     for (XSQLColumn c : tbl.getColumns()) {
@@ -158,8 +319,8 @@ public class JDBCServer extends Thread {
                     }
                 }
                 if (col == null) {
-                    throw new SQLException(
-                        "Unknown field name '" + token + "'.");
+                    throw new SQLException("Unknown field name '" + token
+                            + "'.");
                 }
 
                 rs.getFields().add(col);
@@ -171,28 +332,21 @@ public class JDBCServer extends Thread {
         String lowSQL = rs.getSQL().toLowerCase();
         int where = lowSQL.indexOf("where");
         int order = lowSQL.indexOf("order");
-        int subQuery = lowSQL.indexOf("select", 2);
         int whereTo = lowSQL.indexOf(";");
 
         if (where == -1) {
             return;
         }
 
-        if (where != -1 && subQuery != -1 && subQuery < where) {
-            return;
-        }
-
-        if (order != -1 && subQuery != -1 && order < subQuery) {
-            whereTo = order;
-        } else if (order != -1 && subQuery != -1 && order > subQuery) {
-            whereTo = subQuery;
-        } else if (order != -1) {
+        if (order != -1) {
             whereTo = order;
-        } else if (subQuery != -1) {
-            whereTo = subQuery;
         }
-        String whereStatement =
-            rs.getSQL().substring(where + 5, whereTo).trim();
+
+        if(whereTo==-1)
+            whereTo=lowSQL.length();
+
+        String whereStatement = rs.getSQL().substring(where + 5, whereTo)
+                .trim();
         XSQLCriteria cr = new XSQLCriteria(whereStatement, -1);
         for (XSQLBluePrintNode tbl : rs.getTables()) {
             for (XSQLColumn col : tbl.getColumns()) {
index a9ce1dd9bfe171059414ec32e19d7f44c9b445e5..b71b0153512ba51051c513564fe3e7594ef7b903 100644 (file)
@@ -1,28 +1,63 @@
 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
 
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
 import java.sql.Connection;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.ParameterMetaData;
+import java.sql.PreparedStatement;
+import java.sql.Ref;
 import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
-import java.sql.Statement;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-public class JDBCStatement implements Statement {
+public class JDBCStatement implements PreparedStatement {
     private JDBCResultSet rs = null;
     private transient JDBCConnection connection = null;
-    private static Map<Integer, JDBCResultSet> queries =
-        new ConcurrentHashMap<Integer, JDBCResultSet>();
+    private static Map<Integer, JDBCResultSet> queries = new ConcurrentHashMap<Integer, JDBCResultSet>();
+    private String sql = null;
+
+    public JDBCStatement(JDBCConnection con,String _sql) {
+        this.connection = con;
+        this.sql = _sql;
+    }
 
     public JDBCStatement(JDBCConnection con) {
         this.connection = con;
     }
 
+    public void setSQL(String _sql){
+        this.sql = _sql;
+    }
+
     public JDBCStatement() {
 
     }
 
+    public PreparedStatement getProxy() {
+        return this;
+        /*
+        return (PreparedStatement) Proxy.newProxyInstance(this.getClass()
+                .getClassLoader(), new Class[] { PreparedStatement.class },
+                new JDBCProxy(this));
+                */
+    }
+
     public static JDBCResultSet getQuery(int id) {
         return queries.get(id);
     }
@@ -36,8 +71,8 @@ public class JDBCStatement implements Statement {
         rs = new JDBCResultSet(_sql);
         queries.put(rs.getID(), rs);
         synchronized (rs) {
-            this.connection
-                .send(new JDBCCommand(rs, JDBCCommand.TYPE_EXECUTE_QUERY));
+            this.connection.send(new JDBCCommand(rs,
+                    JDBCCommand.TYPE_EXECUTE_QUERY));
             try {
                 rs.wait();
             } catch (Exception err) {
@@ -46,7 +81,7 @@ public class JDBCStatement implements Statement {
                 throw ((SQLException) rs.getError());
             }
         }
-        return rs;
+        return rs.getProxy();
     }
 
     @Override
@@ -118,21 +153,20 @@ public class JDBCStatement implements Statement {
 
     @Override
     public boolean execute(String sql, int autoGeneratedKeys)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public boolean execute(String sql, int[] columnIndexes)
-        throws SQLException {
+    public boolean execute(String sql, int[] columnIndexes) throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
     public boolean execute(String sql, String[] columnNames)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return false;
     }
@@ -145,21 +179,21 @@ public class JDBCStatement implements Statement {
 
     @Override
     public int executeUpdate(String sql, int autoGeneratedKeys)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return 0;
     }
 
     @Override
     public int executeUpdate(String sql, int[] columnIndexes)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return 0;
     }
 
     @Override
     public int executeUpdate(String sql, String[] columnNames)
-        throws SQLException {
+            throws SQLException {
         // TODO Auto-generated method stub
         return 0;
     }
@@ -202,8 +236,7 @@ public class JDBCStatement implements Statement {
 
     @Override
     public int getMaxRows() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        return 200;
     }
 
     @Override
@@ -326,5 +359,358 @@ public class JDBCStatement implements Statement {
         return false;
     }
 
+    @Override
+    public ResultSet executeQuery() throws SQLException {
+        return this.executeQuery(this.sql);
+    }
+
+    @Override
+    public int executeUpdate() throws SQLException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setNull(int parameterIndex, int sqlType) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBoolean(int parameterIndex, boolean x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setByte(int parameterIndex, byte x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setShort(int parameterIndex, short x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setInt(int parameterIndex, int x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setLong(int parameterIndex, long x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setFloat(int parameterIndex, float x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setDouble(int parameterIndex, double x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBigDecimal(int parameterIndex, BigDecimal x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setString(int parameterIndex, String x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBytes(int parameterIndex, byte[] x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setDate(int parameterIndex, Date x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setTime(int parameterIndex, Time x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setTimestamp(int parameterIndex, Timestamp x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setAsciiStream(int parameterIndex, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setUnicodeStream(int parameterIndex, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBinaryStream(int parameterIndex, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void clearParameters() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setObject(int parameterIndex, Object x, int targetSqlType)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setObject(int parameterIndex, Object x) throws SQLException {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public boolean execute() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void addBatch() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setCharacterStream(int parameterIndex, Reader reader, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setRef(int parameterIndex, Ref x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBlob(int parameterIndex, Blob x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setClob(int parameterIndex, Clob x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setArray(int parameterIndex, Array x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public ResultSetMetaData getMetaData() throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setDate(int parameterIndex, Date x, Calendar cal)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setTime(int parameterIndex, Time x, Calendar cal)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNull(int parameterIndex, int sqlType, String typeName)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setURL(int parameterIndex, URL x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public ParameterMetaData getParameterMetaData() throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setRowId(int parameterIndex, RowId x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNString(int parameterIndex, String value)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNCharacterStream(int parameterIndex, Reader value,
+            long length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNClob(int parameterIndex, NClob value) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setClob(int parameterIndex, Reader reader, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBlob(int parameterIndex, InputStream inputStream, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNClob(int parameterIndex, Reader reader, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setSQLXML(int parameterIndex, SQLXML xmlObject)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setObject(int parameterIndex, Object x, int targetSqlType,
+            int scaleOrLength) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setAsciiStream(int parameterIndex, InputStream x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBinaryStream(int parameterIndex, InputStream x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setCharacterStream(int parameterIndex, Reader reader,
+            long length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setAsciiStream(int parameterIndex, InputStream x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBinaryStream(int parameterIndex, InputStream x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setCharacterStream(int parameterIndex, Reader reader)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNCharacterStream(int parameterIndex, Reader value)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setClob(int parameterIndex, Reader reader) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setBlob(int parameterIndex, InputStream inputStream)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setNClob(int parameterIndex, Reader reader) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
 
 }
diff --git a/opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java b/opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java
new file mode 100644 (file)
index 0000000..8a6b184
--- /dev/null
@@ -0,0 +1,170 @@
+package org.opendaylight.xsql.test;
+
+import java.io.InputStream;
+import java.sql.SQLException;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
+import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCResultSet;
+import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCServer;
+
+public class XSQLTest {
+
+    XSQLBluePrint bluePrint = null;
+
+    @Before
+    public void before() {
+        try{
+            InputStream in = this.getClass().getClassLoader().getResourceAsStream("BluePrintCache.dat");
+            if(in!=null){
+                bluePrint = XSQLBluePrint.load(in);
+                log("Loaded Blue Print!");
+            }else{
+                log("Can't find Blue Print!");
+            }
+            in.close();
+        }catch(Exception err){
+            err.printStackTrace();
+        }
+    }
+
+    @Test
+    public void testQueryParsingSimpleNoCriteria() {
+        String sql = "select * from nodes/node;";
+        JDBCResultSet rs = new JDBCResultSet(sql);
+        parseTables(sql,bluePrint, rs);
+        parseFields(sql, bluePrint, rs);
+        JDBCServer.parseCriteria(rs, bluePrint);
+        if(rs.getCriteria().isEmpty()){
+            log("Test Criteria parsing of \""+sql+"\" Passed!");
+            Assert.assertEquals(true, true);
+        }else{
+            log("Test Criteria parsing of \""+sql+"\" Failed!");
+            Assert.assertEquals(false, true);
+        }
+    }
+
+    @Test
+    public void testQueryParsingComplexNoCriteria() {
+        String sql = "select nodes/node.id,nodes/node/node-connector.id,nodes/node/node-connector.hardware-address from nodes/node,nodes/node/node-connector;";
+        JDBCResultSet rs = new JDBCResultSet(sql);
+        parseTables(sql,bluePrint, rs);
+        parseFields(sql, bluePrint, rs);
+        JDBCServer.parseCriteria(rs, bluePrint);
+        if(rs.getCriteria().isEmpty()){
+            log("Test Criteria parsing of \""+sql+"\" Passed!");
+            Assert.assertEquals(true, true);
+        }else{
+            log("Test Criteria parsing of \""+sql+"\" Failed!");
+            Assert.assertEquals(false, true);
+        }
+    }
+
+    @Test
+    public void testQueryParsingComplexWithCriteria() {
+        String sql = "select nodes/node.id,nodes/node/node-connector.id,nodes/node/node-connector.hardware-address from nodes/node,nodes/node/node-connector where hardware-address like 'AB';";
+        JDBCResultSet rs = new JDBCResultSet(sql);
+        parseTables(sql,bluePrint, rs);
+        parseFields(sql, bluePrint, rs);
+        JDBCServer.parseCriteria(rs, bluePrint);
+        if(!rs.getCriteria().isEmpty()){
+            log("Test Criteria parsing of \""+sql+"\" Passed!");
+            Assert.assertEquals(true, true);
+        }else{
+            log("Test Criteria parsing of \""+sql+"\" Failed!");
+            Assert.assertEquals(false, true);
+        }
+    }
+
+    @Test
+    public void testQueryParsingSimpleWithCriteria() {
+        String sql = "select * from nodes/node where nodes/node.id like 'something...';";
+        JDBCResultSet rs = new JDBCResultSet(sql);
+        parseTables(sql,bluePrint, rs);
+        parseFields(sql, bluePrint, rs);
+        JDBCServer.parseCriteria(rs, bluePrint);
+        if(!rs.getCriteria().isEmpty()){
+            log("Test Criteria parsing of \""+sql+"\" Passed!");
+            Assert.assertEquals(true, true);
+        }else{
+            log("Test Criteria parsing of \""+sql+"\" Failed!");
+            Assert.assertEquals(false, true);
+        }
+    }
+
+    private static void parseTables(String sql,XSQLBluePrint bp,JDBCResultSet rs){
+        try{
+            JDBCServer.parseTables(rs, bp);
+            log("Test Table parsing of \""+sql+"\" Passed!");
+            Assert.assertEquals(true,true);
+        }catch(SQLException err){
+            log("Test Table parsing of \""+sql+"\" Failed!");
+            err.printStackTrace();
+            Assert.assertEquals(false,true);
+        }
+    }
+
+    @Test
+    public void testQueryParsingComplexWithCriteriaAndGrouping() {
+
+        String sub_sql = "select nodes/node.id,nodes/node/node-connector.id,nodes/node/node-connector.hardware-address from nodes/node,nodes/node/node-connector where hardware-address like 'AB';";
+
+        String sql = "SELECT DISTINCT"
+                + "\"LOGICAL_TABLE_1\".\"nodes/node.id\" AS \"COL0\"\n"
+                + ",\"LOGICAL_TABLE_1\".\"nodes/node.address\" AS \"COL1\"\n"
+                + ",\"LOGICAL_TABLE_1\".\"nodes/node/node-connector.hardware-address\" AS \"COL2\"\n"
+                + "FROM\n"
+                + "("+sub_sql+") \"LOGICAL_TABLE_1\"\n";
+
+
+
+        JDBCResultSet rs = new JDBCResultSet(sql);
+        XSQLAdapter.getInstance().loadBluePrint();
+        try{
+            JDBCServer.checkAndBreakSubQueries(rs, XSQLAdapter.getInstance());
+            if(rs.getSubQueries().isEmpty()){
+                log("Logical table parsing for "+sql+" Failed!");
+            }else{
+                JDBCServer.parseExternalQuery(rs);
+                log("Fields="+rs.getFields().size());
+                Assert.assertEquals(rs.getFields().size(), 3);
+                Assert.assertEquals(rs.getTables().size(), 1);
+                Assert.assertEquals(rs.getTables().get(0).getODLTableName(), "LOGICAL_TABLE_1");
+
+                JDBCResultSet subRS = rs.getSubQueries().values().iterator().next();
+                parseTables(sql,bluePrint, subRS);
+                parseFields(sql, bluePrint, subRS);
+                JDBCServer.parseCriteria(subRS, bluePrint);
+                if(!subRS.getCriteria().isEmpty()){
+                    log("Test Criteria parsing of \""+sql+"\" Passed!");
+                    Assert.assertEquals(true, true);
+                }else{
+                    log("Test Criteria parsing of \""+sql+"\" Failed!");
+                    Assert.assertEquals(false, true);
+                }
+            }
+        }catch(SQLException err){
+            err.printStackTrace();
+        }
+    }
+
+    private static void parseFields(String sql,XSQLBluePrint bp,JDBCResultSet rs){
+        try{
+            JDBCServer.parseFields(rs, bp);
+            log("Test Fields parsing of \""+sql+"\" Passed!");
+            Assert.assertEquals(true,true);
+        }catch(SQLException err){
+            log("Test Fields parsing of \""+sql+"\" Failed!");
+            err.printStackTrace();
+            Assert.assertEquals(false,true);
+        }
+    }
+
+    private static void log(String str) {
+        System.out.print("*** XSQL Tests -");
+        System.out.println(str);
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-xsql/src/test/resources/BluePrintCache.dat b/opendaylight/md-sal/sal-dom-xsql/src/test/resources/BluePrintCache.dat
new file mode 100644 (file)
index 0000000..b6b34ac
Binary files /dev/null and b/opendaylight/md-sal/sal-dom-xsql/src/test/resources/BluePrintCache.dat differ
index 725b24cd9e733c342d26adf5b07076aa7348c49e..473b065b597707a04305d4430e01e4c5fa579def 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>sal-inmemory-datastore</artifactId>
index a1bf2c806e7ad587cf63bc732d1ece972a05229d..9ed3707d3d98a616472c8b2992ed1fb5b8feb2fd 100644 (file)
@@ -23,7 +23,7 @@
     <parent>\r
     <artifactId>sal-parent</artifactId>\r
     <groupId>org.opendaylight.controller</groupId>\r
-    <version>1.1-SNAPSHOT</version>\r
+    <version>1.2.0-SNAPSHOT</version>\r
   </parent>\r
 \r
     <groupId>org.opendaylight.controller</groupId>\r
@@ -63,7 +63,7 @@
         <dependency>\r
             <groupId>org.opendaylight.controller</groupId>\r
             <artifactId>sal-dom-xsql</artifactId>\r
-            <version>1.1-SNAPSHOT</version>\r
+            <version>1.2.0-SNAPSHOT</version>\r
         </dependency>\r
     </dependencies>\r
 \r
index b7994dc1bf317c872bc501ca42f4a6b7b42bd43a..9f0266c19db76b2cc7ea829742eb81b4a605dabf 100644 (file)
@@ -16,6 +16,10 @@ public class xsql extends OsgiCommandSupport {
     private String argument;
 
     protected Object doExecute() throws Exception {
+        if(argument==null){
+            System.out.println("Nothing to do..., please specify a command.");
+            return null;
+        }
         XSQLAdapter.getInstance().processCommand(new StringBuffer(argument),
                 System.out);
         return null;
index 049f8c2e3c7a4e6869d83bff20a8f0dad97c30de..c8836d1b88e136fc4a757d8f4c95f32592d3b5a3 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>sal-netconf-connector</artifactId>
index 31f1f026931b0e7ef2082c36bafa3db7cb64e801..d47cf4ca07609a903bfeb0812fdf9a4283199c22 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-remote</artifactId>
   <packaging>bundle</packaging>
index 0fb468be868be7dfa3081530b5068bdef13882cc..d16f67209f1cb152e9d332525f682c1225b44d91 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-remoterpc-connector</artifactId>
   <packaging>bundle</packaging>
index fa91f0398d75cac155269ab83dd6f804e940acec..dc3dd8e476eb5b632da3d059e3ca5ca4b5ab60e4 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-rest-connector-config</artifactId>
   <description>Configuration files for sal-rest-connector</description>
index fe5c9f39d8251e903c1ed5d9f173ced7df5f0f5b..4a9684717574e8d55741abb62741cdfaf875b305 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-rest-connector</artifactId>
   <packaging>bundle</packaging>
               org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.rest.connector.rev140724.*,
             </Private-Package>
             <Import-Package>*,
-            com.sun.jersey.spi.container.servlet</Import-Package>
+            com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets</Import-Package>
             <Web-ContextPath>/restconf</Web-ContextPath>
           </instructions>
         </configuration>
index 5fbb60555814f11267bba0012a650adf4b040b0d..552e2bbd190d154280e1a8ce7a3bc22d89de908b 100644 (file)
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 class JsonToCompositeNodeReader {
-    private static final Logger LOG = LoggerFactory.getLogger(JsonReader.class);
+    private static final Logger LOG = LoggerFactory.getLogger(JsonToCompositeNodeReader.class);
     private static final Splitter COLON_SPLITTER = Splitter.on(':');
 
     private JsonToCompositeNodeReader() {
@@ -113,14 +113,29 @@ class JsonToCompositeNodeReader {
         }
     }
 
+    /**
+     * Transform input value to URI instance.
+     *
+     * Input string has to be in format moduleName:localName. moduleName part is then transformed to URI instance.
+     * If moduleName part contains character like "<" or ">" then null value is returned because they
+     * aren't valid URI characters.
+     *
+     * @param jsonElementName
+     *  value in format moduleName:localName
+     * @return
+     */
     private static URI getNamespaceFor(final String jsonElementName) {
         final Iterator<String> it = COLON_SPLITTER.split(jsonElementName).iterator();
 
-        // The string needs to me in form "moduleName:localName"
+        // The string needs to be in form "moduleName:localName"
         if (it.hasNext()) {
             final String maybeURI = it.next();
             if (Iterators.size(it) == 1) {
-                return URI.create(maybeURI);
+                try {
+                    return URI.create(maybeURI);
+                } catch (IllegalArgumentException e) {
+                    LOG.debug("Value {} couldn't be interpreted as URI.", maybeURI);
+                }
             }
         }
 
@@ -144,7 +159,7 @@ class JsonToCompositeNodeReader {
             }
         }
 
-        // it could be identityref Built-In Type
+        // it could be identityref Built-In Type therefore it is necessary to look at value as module_name:local_name
         URI namespace = getNamespaceFor(value);
         if (namespace != null) {
             return new IdentityValuesDTO(namespace.toString(), getLocalNameFor(value), null, value);
index 60c3378471f6b0989967c707462c132d7418218f..120a826b32a863b850ee634b563b6bcffe0bc017 100644 (file)
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
 
+    <filter>
+        <filter-name>cross-origin-restconf</filter-name>
+        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
+        <init-param>
+            <param-name>allowedOrigins</param-name>
+            <param-value>*</param-value>
+        </init-param>
+        <init-param>
+            <param-name>allowedMethods</param-name>
+            <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>
+        </init-param>
+        <init-param>
+            <param-name>allowedHeaders</param-name>
+            <param-value>origin, content-type, accept, authorization</param-value>
+        </init-param>
+    </filter>
+    <filter-mapping>
+        <filter-name>cross-origin-restconf</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
     <security-constraint>
         <web-resource-collection>
             <web-resource-name>NB api</web-resource-name>
index 83934568cc05ab1f3fc1fe031a91f228679fb901..cc1d26fb979ddfd708c1651f86eaadf941bcdf94 100644 (file)
@@ -9,7 +9,7 @@ module sal-remote-augment {
     description
         "Added input parameters to rpc create-data-change-event-subscription";
 
-    revision "2014-7-8" {
+    revision "2014-07-08" {
     }
 
     augment "/salrmt:create-data-change-event-subscription/salrmt:input" {
@@ -28,4 +28,4 @@ module sal-remote-augment {
         }
     }
 
-}
\ No newline at end of file
+}
index 3699e4924fe25ca2c8a4b1399fe005376de3a86d..d65cb1bdbfe48bc02d132faab0e2cf82756cb785 100644 (file)
@@ -422,4 +422,36 @@ public class JsonToCnSnTest {
         assertTrue(exceptionMessage.contains("Root element of Json has to be Object"));
     }
 
+    /**
+     * Tests case when JSON input data value is in format string1:string2 and first string contain characters "<" or ">" (invalid URI characters).
+     *
+     * During loading data it is also interpreting as data value in moduleName:localName (potential leafref value).
+     * ModuleName part is transformed to URI which causes exception which is caught and URI value is null which cause that potential value in simple node is
+     * simple string (value from JSON input) and not IdentityValueDTO instance which is used for leaf-ref candidates.
+     */
+    @Test
+    public void invalidUriCharacterInValue() {
+        final Node<?> rootNode = TestUtils.readInputToCnSn("/json-to-cnsn/invalid-uri-character-in-value.json", true,
+                    JsonToCompositeNodeProvider.INSTANCE);
+
+        assertTrue(rootNode instanceof CompositeNode);
+        Node<?> lf1 = null;
+        Node<?> lf2 = null;
+        for(Node<?> child : ((CompositeNode)rootNode).getChildren()) {
+            if (child.getNodeType().getLocalName().equals("lf1")) {
+                lf1 = child;
+            } else if (child.getNodeType().getLocalName().equals("lf2")) {
+                lf2 = child;
+            }
+        }
+
+        assertNotNull(lf1);
+        assertNotNull(lf2);
+        assertTrue(lf1 instanceof SimpleNode<?>);
+        assertTrue(lf2 instanceof SimpleNode<?>);
+
+        assertEquals("module<Name:value lf1", ((SimpleNode<?>) lf1).getValue());
+        assertEquals("module>Name:value lf2", ((SimpleNode<?>) lf2).getValue());
+    }
+
 }
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-cnsn/invalid-uri-character-in-value.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-cnsn/invalid-uri-character-in-value.json
new file mode 100644 (file)
index 0000000..6a78e9f
--- /dev/null
@@ -0,0 +1,6 @@
+{
+    "moduleName:cont":{
+       "lf1":"module<Name:value lf1",
+       "lf2":"module>Name:value lf2"
+       }
+}
\ No newline at end of file
index 1141e1d72e212204ed21ffcf725e4226835e427b..5abb4f891043076d673cc416f867c57470b69f87 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>sal-rest-docgen</artifactId>
           <instructions>
             <Bundle-Name>MD SAL Rest Api Doc Generator</Bundle-Name>
             <Import-Package>*,
-              com.sun.jersey.spi.container.servlet</Import-Package>
+              com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets</Import-Package>
             <Bundle-Activator>org.opendaylight.controller.sal.rest.doc.DocProvider</Bundle-Activator>
             <Web-ContextPath>/apidoc</Web-ContextPath>
           </instructions>
index 5d0f3612e4f3c931c39199a0f180461b8430e0f8..4d567bdef5d2a604e1d9ac71dfc3f1ade8675a37 100644 (file)
@@ -173,12 +173,12 @@ public class BaseYangSwaggerGenerator {
                 resourcePath = getDataStorePath("/operational/", context);
                 addApis(node, apis, resourcePath, pathParams, schemaContext, false);
             }
+        }
 
-            Set<RpcDefinition> rpcs = m.getRpcs();
-            for (RpcDefinition rpcDefinition : rpcs) {
-                String resourcePath = getDataStorePath("/operations/", context);
-                addRpcs(rpcDefinition, apis, resourcePath, schemaContext);
-            }
+        Set<RpcDefinition> rpcs = m.getRpcs();
+        for (RpcDefinition rpcDefinition : rpcs) {
+            String resourcePath = getDataStorePath("/operations/", context);
+            addRpcs(rpcDefinition, apis, resourcePath, schemaContext);
         }
 
         _logger.debug("Number of APIs found [{}]", apis.size());
index f4274870c9305d84f1ee53798bb934f8721748a4..3b503ebba35c016382d390ad695c4bda7c553ef2 100644 (file)
@@ -146,8 +146,10 @@ public class ModelGenerator {
 
         for (DataSchemaNode childNode : module.getChildNodes()) {
             // For every container and list in the module
-            processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, true, schemaContext);
-            processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, false, schemaContext);
+            if (childNode instanceof ContainerSchemaNode || childNode instanceof ListSchemaNode) {
+                processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, true, schemaContext);
+                processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, false, schemaContext);
+            }
         }
 
     }
@@ -306,6 +308,9 @@ public class ModelGenerator {
                 property.put(TYPE_KEY, childNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE);
                 property.put(ITEMS_KEY, items);
                 properties.put(childNode.getQName().getLocalName(), property);
+            } else if (childNode instanceof LeafSchemaNode){
+                JSONObject property = processLeafNode((LeafSchemaNode)childNode);
+                properties.put(childNode.getQName().getLocalName(), property);
             }
         }
         return properties;
index c470b3237ea7fe2dd69f37254cae4b38439c8861..d777942b53ede401e84f340bc2935628770b8550 100644 (file)
         <url-pattern>/apis/*</url-pattern>
     </servlet-mapping>
 
-    <!--filter>
-        <filter-name>CorsFilter</filter-name>
-        <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
+    <filter>
+        <filter-name>cross-origin-api-doc</filter-name>
+        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
         <init-param>
-            <param-name>cors.allowed.origins</param-name>
+            <param-name>allowedOrigins</param-name>
             <param-value>*</param-value>
         </init-param>
         <init-param>
-            <param-name>cors.allowed.methods</param-name>
-            <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
+            <param-name>allowedMethods</param-name>
+            <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>
         </init-param>
         <init-param>
-            <param-name>cors.allowed.headers</param-name>
-            <param-value>Content-Type,X-Requested-With,accept,authorization,
-        origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
-        </init-param>
-        <init-param>
-            <param-name>cors.exposed.headers</param-name>
-            <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
-        </init-param>
-        <init-param>
-            <param-name>cors.support.credentials</param-name>
-            <param-value>true</param-value>
-        </init-param>
-        <init-param>
-            <param-name>cors.preflight.maxage</param-name>
-            <param-value>10</param-value>
+            <param-name>allowedHeaders</param-name>
+            <param-value>origin, content-type, accept, authorization</param-value>
         </init-param>
     </filter>
     <filter-mapping>
-        <filter-name>CorsFilter</filter-name>
-        <url-pattern>/*</url-pattern>
-    </filter-mapping-->
+        <filter-name>cross-origin-api-doc</filter-name>
+        <url-pattern>/apis/*</url-pattern>
+    </filter-mapping>
+
+
     <security-constraint>
       <web-resource-collection>
         <web-resource-name>free access</web-resource-name>
diff --git a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGeneratorTest.java b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGeneratorTest.java
new file mode 100644 (file)
index 0000000..5918a0e
--- /dev/null
@@ -0,0 +1,45 @@
+package org.opendaylight.controller.sal.rest.doc.impl;
+
+import com.google.common.base.Preconditions;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Map;
+
+
+public class ModelGeneratorTest {
+
+    private DocGenTestHelper helper;
+    private SchemaContext schemaContext;
+
+    @Before
+    public void setUp() throws Exception {
+        helper = new DocGenTestHelper();
+        helper.setUp();
+        schemaContext = new YangParserImpl().resolveSchemaContext(new HashSet<Module>(helper.getModules().values()));
+    }
+
+    @Test
+    public void testConvertToJsonSchema() throws Exception {
+
+        Preconditions.checkArgument(helper.getModules() != null, "No modules found");
+
+        ModelGenerator generator = new ModelGenerator();
+
+        for (Map.Entry<File, Module> m : helper.getModules().entrySet()) {
+            if (m.getKey().getAbsolutePath().endsWith("opflex.yang")) {
+
+                JSONObject jsonObject = generator.convertToJsonSchema(m.getValue(), schemaContext);
+                Assert.assertNotNull(jsonObject);
+            }
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-rest-docgen/src/test/resources/yang/opflex.yang b/opendaylight/md-sal/sal-rest-docgen/src/test/resources/yang/opflex.yang
new file mode 100644 (file)
index 0000000..8e598dd
--- /dev/null
@@ -0,0 +1,50 @@
+module opflex {
+    yang-version 1;
+
+    namespace "urn:opendaylight:groupbasedpolicy:opflex";
+    prefix "opflex";
+
+
+
+
+
+    description
+        "This module defines the group-based policy OpFlex renderer model.";
+
+    revision "2014-05-28" {
+        description
+            "Initial revision.";
+    }
+
+    typedef serialization {
+        description
+            "The serialization to use for OpFlex messages.";
+
+        type enumeration {
+            enum json {
+                description
+                "JSON 1.0 serialization.";
+            }
+            enum xml {
+                description
+                "XML serialization.";
+            }
+            enum binary {
+                description
+                "OpFlex binary serialization.";
+            }
+        }
+    }
+
+    // ******************
+    // Configuration Data
+    // ******************
+    leaf domain {
+        description
+            "The OpFlex administrative domain.";
+
+        config true;
+
+        type string;
+    }
+}
\ No newline at end of file
index 20bbd78622eb839d9679e3909769ed188ebd3c22..ffddc8c3daa0f36f8ea51a2e4e39000b44438fe6 100644 (file)
@@ -20,11 +20,19 @@ module toaster {
         "Toaster module in progress.";
     }
 
+    leaf domain {
+        description
+            "Toaster domain.";
+
+        config true;
+
+        type string;
+    }
 
     identity toast-type {
       description
           "Base for all bread types supported by the toaster.
-           New bread types not listed here nay be added in the 
+           New bread types not listed here nay be added in the
            future.";
     }
 
@@ -72,7 +80,7 @@ module toaster {
         "Indicates the toaster service is available";
       description
         "Top-level container for all toaster database objects.";
-        
+
       leaf testToasterBits {
          type bits {
              bit testbit1 {
@@ -84,21 +92,21 @@ module toaster {
          }
          default "testbit2";
      }
-     
+
      leaf testUnion {
         type union {
          type int32;
          type string;
         }
-        
-     } 
-     
+
+     }
+
      leaf-list allow-user  {
           type string;
           description "A list of user name patterns to allow";
-        
+
         }
-        
+
         choice how {
              default interval;
              case interval {
@@ -123,14 +131,14 @@ module toaster {
                      type string;
                  }
              }
-         } 
-        
+         }
+
       leaf toasterManufacturer {
         type DisplayString;
         config false;
         mandatory true;
         description
-          "The name of the toaster's manufacturer. For instance, 
+          "The name of the toaster's manufacturer. For instance,
                 Microsoft Toaster.";
       }
 
@@ -161,7 +169,7 @@ module toaster {
         config false;
         mandatory true;
         description
-          "This variable indicates the current state of 
+          "This variable indicates the current state of
                the toaster.";
       }
     }
@@ -169,11 +177,11 @@ module toaster {
     rpc make-toast {
       description
         "Make some toast.
-           The toastDone notification will be sent when 
+           The toastDone notification will be sent when
            the toast is finished.
            An 'in-use' error will be returned if toast
            is already being made.
-           A 'resource-denied' error will be returned 
+           A 'resource-denied' error will be returned
            if the toaster service is disabled.";
       input {
         leaf toasterDoneness {
@@ -182,10 +190,10 @@ module toaster {
           }
           default '5';
           description
-            "This variable controls how well-done is the 
+            "This variable controls how well-done is the
                    ensuing toast. It should be on a scale of 1 to 10.
-                   Toast made at 10 generally is considered unfit 
-                   for human consumption; toast made at 1 is warmed 
+                   Toast made at 10 generally is considered unfit
+                   for human consumption; toast made at 1 is warmed
                    lightly.";
         }
 
@@ -195,23 +203,23 @@ module toaster {
           }
           default 'wheat-bread';
           description
-            "This variable informs the toaster of the type of 
-                   material that is being toasted. The toaster 
-                   uses this information, combined with 
-                   toasterDoneness, to compute for how 
-                   long the material must be toasted to achieve 
+            "This variable informs the toaster of the type of
+                   material that is being toasted. The toaster
+                   uses this information, combined with
+                   toasterDoneness, to compute for how
+                   long the material must be toasted to achieve
                    the required doneness.";
         }
       }
-    }  
+    }
 
     rpc cancel-toast {
       description
         "Stop making toast, if any is being made.
-           A 'resource-denied' error will be returned 
+           A 'resource-denied' error will be returned
            if the toaster service is disabled.";
-    }  
-    
+    }
+
     notification toastDone {
       description
         "Indicates that the toast in progress has completed.";
@@ -236,5 +244,5 @@ module toaster {
         description
           "Indicates the final toast status";
       }
-    }  
-  }  
+    }
+  }
index 9e64c3aed68acc6903b5434f2d21d85e7f61f174..db2b06e71454b3e3ee4cccd000a021c5b137f845 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sal-restconf-broker</artifactId>
   <packaging>bundle</packaging>
index 11a0ef211ae2cb20eac661ff789acf9c2e1412eb..2a8a80da09131fed382d4daa06e6533d0085c17d 100644 (file)
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>sal-parent</artifactId>
         <groupId>org.opendaylight.controller</groupId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
index 8d4bbbd64ce70591254350431643a8397e4097a2..33a8a92f9f7839a859803a646ad092f273c6074a 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <artifactId>clustering-it</artifactId>
         <groupId>org.opendaylight.controller.samples</groupId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </parent>
     <artifactId>clustering-it-config</artifactId>
   <packaging>jar</packaging>
index a23e32df2b91e0971e154c2c3f599886423bd7db..60eeba64c7d5bf664c68e60a2b32ccd20497c0fe 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>clustering-it</artifactId>
         <groupId>org.opendaylight.controller.samples</groupId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </parent>
     <artifactId>clustering-it-model</artifactId>
     <packaging>bundle</packaging>
index 863bbecdf91922808d646ea9e03c38b753ded320..58246213316c8fb801df0fa25c95f2f6bdfc1e41 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.opendaylight.controller.samples</groupId>
         <artifactId>sal-samples</artifactId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </parent>
     <artifactId>clustering-it</artifactId>
     <packaging>pom</packaging>
index 093b681125d9543697612b9c43e928ca12c0388c..d4d55b04c0bde2ddcc4c883e55af5248d7145c91 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <artifactId>clustering-it</artifactId>
         <groupId>org.opendaylight.controller.samples</groupId>
-        <version>1.1-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
     </parent>
     <artifactId>clustering-it-provider</artifactId>
     <packaging>bundle</packaging>
index 8824284785bccea43ca82615b45ba09b66bcc4b7..a0e119b49c4cce891892feb7fd95d8cadf80d18f 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
   <groupId>org.opendaylight.controller.samples.l2switch.md</groupId>
index 0ccc74d95276361d3fd0d395c592627ca63af805..fa35c1f6cd11ef409f72e9bd29f88fb9beba7716 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
   <groupId>org.opendaylight.controller.samples.l2switch.md</groupId>
index e0a51a8e3c0a7d46cfbda3447d42aa0cba64bc6d..6a715c74ab0a26e179118399c1a5ae62e2fa7360 100644 (file)
@@ -7,12 +7,12 @@
   <parent>
      <groupId>org.opendaylight.controller.samples</groupId>
      <artifactId>sal-samples</artifactId>
-     <version>1.1-SNAPSHOT</version>
+     <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>l2switch.aggregator</artifactId>
   <groupId>org.opendaylight.controller.samples.l2switch</groupId>
-  <version>1.0.0-SNAPSHOT</version>
+  <version>1.1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <modules>
index d13200e4e8c9a12bce5a3a989472c13147b4a75f..6070c72472226dadeabdfd6cc0957c0aeac3df2e 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
 
   <groupId>org.opendaylight.controller.samples</groupId>
index b30c4ba12f1f11bb45b9a1828f5a320ad077cbe2..b0592b654de3159cb5d591426d88bfaaffea363e 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>toaster-config</artifactId>
   <description>Configuration files for toaster</description>
index 6e720299d8364e21d058e9603f86e33544697b1d..fb6828a2507e108ad073f387dc15d1922f98fa81 100644 (file)
@@ -4,13 +4,13 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sample-toaster-consumer</artifactId>
   <packaging>bundle</packaging>
 
   <properties>
-    <sal-binding-api.version>1.1-SNAPSHOT</sal-binding-api.version>
+    <sal-binding-api.version>1.2.0-SNAPSHOT</sal-binding-api.version>
   </properties>
 
   <dependencies>
index 56ed9a07a6481e046e9a39ea9b7bb799cd09faa7..804da597acf77b64ec6a6e0a549578b0bde103c1 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sample-toaster-it</artifactId>
 
index 89dcab2c3da1dfc45857ffe89a76c9e74c56a450..08f0988b5c92cd6db60bd963ae91f743f0e0cceb 100644 (file)
@@ -4,13 +4,13 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sample-toaster-provider</artifactId>
   <packaging>bundle</packaging>
 
   <properties>
-    <sal-binding-api.version>1.1-SNAPSHOT</sal-binding-api.version>
+    <sal-binding-api.version>1.2.0-SNAPSHOT</sal-binding-api.version>
   </properties>
 
   <dependencies>
index 5c8b20a4e36bacdad1c0a5a041d94ee67e87f406..ab761fd6bf383385c4c7401c3459839226cce559 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller.samples</groupId>
     <artifactId>sal-samples</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <artifactId>sample-toaster</artifactId>
   <packaging>bundle</packaging>
index 399d53b67f49e4b99928d367ec0b181030f057e0..1a443177c68a4ef8fa44ee2db7a461ff184ff8c1 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller.md</groupId>
   <artifactId>statistics-manager</artifactId>
@@ -21,8 +21,9 @@
       <artifactId>junit</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.xtend</groupId>
-      <artifactId>org.eclipse.xtend.lib</artifactId>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-broker-impl</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
@@ -57,7 +58,6 @@
         <configuration>
           <instructions>
             <Bundle-Activator>org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator</Bundle-Activator>
-            <Private-Package>org.opendaylight.controller.md.statistics.manager</Private-Package>
           </instructions>
         </configuration>
       </plugin>
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractListeningStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractListeningStatsTracker.java
deleted file mode 100644 (file)
index 167fb21..0000000
+++ /dev/null
@@ -1,48 +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.md.statistics.manager;
-
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-abstract class AbstractListeningStatsTracker<I, K> extends AbstractStatsTracker<I, K> implements AutoCloseable, DataChangeListener {
-    private static final Logger logger = LoggerFactory.getLogger(AbstractListeningStatsTracker.class);
-    private ListenerRegistration<?> reg;
-
-    protected AbstractListeningStatsTracker(FlowCapableContext context) {
-        super(context);
-    }
-
-    protected abstract InstanceIdentifier<?> listenPath();
-    protected abstract String statName();
-
-    public void start(final DataBrokerService dbs) {
-        Preconditions.checkState(reg == null);
-
-        reg = dbs.registerDataChangeListener(listenPath(), this);
-        logger.debug("{} Statistics tracker for node {} started", statName(), getNodeIdentifier());
-    }
-
-    @Override
-    public final void close() {
-        if (reg != null) {
-            try {
-                reg.close();
-            } catch (Exception e) {
-                logger.warn("Failed to stop {} Statistics tracker for node {}", statName(), getNodeIdentifier(), e);
-            }
-            reg = null;
-        }
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java
deleted file mode 100644 (file)
index 838aeb7..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
-
-abstract class AbstractStatsTracker<I, K> {
-    private static final Logger logger = LoggerFactory.getLogger(AbstractStatsTracker.class);
-
-    private static final int WAIT_FOR_REQUEST_CYCLE = 2;
-
-    private final FutureCallback<RpcResult<? extends TransactionAware>> callback =
-            new FutureCallback<RpcResult<? extends TransactionAware>>() {
-        @Override
-        public void onSuccess(RpcResult<? extends TransactionAware> result) {
-            if (result.isSuccessful()) {
-                final TransactionId id = result.getResult().getTransactionId();
-                if (id == null) {
-                    final Throwable t = new UnsupportedOperationException("No protocol support");
-                    t.fillInStackTrace();
-                    onFailure(t);
-                } else {
-                    context.registerTransaction(id);
-                }
-            } else {
-                logger.debug("Statistics request failed: {}", result.getErrors());
-
-                final Throwable t = new RPCFailedException("Failed to send statistics request", result.getErrors());
-                t.fillInStackTrace();
-                onFailure(t);
-            }
-        }
-
-        @Override
-        public void onFailure(Throwable t) {
-            logger.debug("Failed to send statistics request", t);
-        }
-    };
-
-    private final Map<K, Long> trackedItems = new HashMap<>();
-    private final FlowCapableContext context;
-    private long requestCounter;
-
-    protected AbstractStatsTracker(final FlowCapableContext context) {
-        this.context = Preconditions.checkNotNull(context);
-        this.requestCounter = 0;
-    }
-
-    protected final InstanceIdentifierBuilder<Node> getNodeIdentifierBuilder() {
-        return getNodeIdentifier().builder();
-    }
-
-    protected final NodeRef getNodeRef() {
-        return context.getNodeRef();
-    }
-
-    protected final InstanceIdentifier<Node> getNodeIdentifier() {
-        return context.getNodeIdentifier();
-    }
-
-    protected final <T extends TransactionAware> void requestHelper(Future<RpcResult<T>> future) {
-        Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future), callback);
-    }
-
-    protected final DataModificationTransaction startTransaction() {
-        return context.startDataModification();
-    }
-
-    public final synchronized void increaseRequestCounter(){
-        this.requestCounter++;
-    }
-    protected abstract void cleanupSingleStat(DataModificationTransaction trans, K item);
-    protected abstract K updateSingleStat(DataModificationTransaction trans, I item);
-    protected abstract K createInvariantKey(K item);
-    public abstract void request();
-
-    public final synchronized void updateStats(List<I> list) {
-
-        final DataModificationTransaction trans = startTransaction();
-        for (final I item : list) {
-            K key = updateSingleStat(trans, item);
-            trackedItems.put(createInvariantKey(key), requestCounter);
-        }
-
-        trans.commit();
-    }
-
-    /**
-     * Statistics will be cleaned up if not update in last two request cycles.
-     * @param trans
-     */
-    public final synchronized void cleanup(final DataModificationTransaction trans) {
-        for (Iterator<Entry<K, Long>> it = trackedItems.entrySet().iterator();it.hasNext();){
-            Entry<K, Long> e = it.next();
-            if (requestCounter >= e.getValue()+WAIT_FOR_REQUEST_CYCLE) {
-                cleanupSingleStat(trans, e.getKey());
-                it.remove();
-            }
-        }
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowCapableContext.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowCapableContext.java
deleted file mode 100644 (file)
index 520b344..0000000
+++ /dev/null
@@ -1,27 +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.md.statistics.manager;
-
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Interface exposed to AbstractStatsTracker by its parent NodeStatisticsHandler.
- * While we could simply exist without this interface, its purpose is to document
- * the contract between the two classes.
- */
-interface FlowCapableContext {
-    InstanceIdentifier<Node> getNodeIdentifier();
-    NodeRef getNodeRef();
-    DataModificationTransaction startDataModification();
-    void registerTransaction(TransactionId id);
-    void registerTableTransaction(TransactionId id, Short tableId);
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowCapableTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowCapableTracker.java
deleted file mode 100644 (file)
index bb1544c..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.Collection;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Sets;
-
-/**
- * There is a single instance of this class and that instance is responsible for
- * monitoring the operational data store for nodes being created/deleted and
- * notifying StatisticsProvider. These events then control the lifecycle of
- * NodeStatisticsHandler for a particular switch.
- */
-final class FlowCapableTracker implements DataChangeListener {
-    private static final Logger logger = LoggerFactory.getLogger(FlowCapableTracker.class);
-
-    private final InstanceIdentifier<FlowCapableNode> root;
-    private final StatisticsProvider stats;
-
-    private final Predicate<InstanceIdentifier<?>> filterIdentifiers = new Predicate<InstanceIdentifier<?>>() {
-        @Override
-        public boolean apply(final InstanceIdentifier<?> input) {
-            /*
-             * This notification has been triggered either by the ancestor,
-             * descendant or directly for the FlowCapableNode itself. We
-             * are not interested descendants, so let's prune them based
-             * on the depth of their identifier.
-             */
-            if (root.getPath().size() < input.getPath().size()) {
-                logger.debug("Ignoring notification for descendant {}", input);
-                return false;
-            }
-
-            logger.debug("Including notification for {}", input);
-            return true;
-        }
-    };
-
-    public FlowCapableTracker(final StatisticsProvider stats, InstanceIdentifier<FlowCapableNode> root) {
-        this.stats = Preconditions.checkNotNull(stats);
-        this.root = Preconditions.checkNotNull(root);
-    }
-
-    /*
-     * This method is synchronized because we want to make sure to serialize input
-     * from the datastore. Competing add/remove could be problematic otherwise.
-     */
-    @Override
-    public synchronized void onDataChanged(final DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        logger.debug("Tracker at root {} processing notification", root);
-
-        /*
-         * First process all the identifiers which were removed, trying to figure out
-         * whether they constitute removal of FlowCapableNode.
-         */
-        final Collection<NodeKey> removedNodes =
-            Collections2.filter(Collections2.transform(
-                Sets.filter(change.getRemovedOperationalData(), filterIdentifiers),
-                new Function<InstanceIdentifier<?>, NodeKey>() {
-                    @Override
-                    public NodeKey apply(final InstanceIdentifier<?> input) {
-                        final NodeKey key = input.firstKeyOf(Node.class, NodeKey.class);
-                        if (key == null) {
-                            // FIXME: do we have a backup plan?
-                            logger.info("Failed to extract node key from {}", input);
-                        }
-                        return key;
-                    }
-                }), Predicates.notNull());
-        stats.stopNodeHandlers(removedNodes);
-
-        final Collection<NodeKey> addedNodes =
-            Collections2.filter(Collections2.transform(
-                Sets.filter(change.getCreatedOperationalData().keySet(), filterIdentifiers),
-                new Function<InstanceIdentifier<?>, NodeKey>() {
-                    @Override
-                    public NodeKey apply(final InstanceIdentifier<?> input) {
-                        final NodeKey key = input.firstKeyOf(Node.class, NodeKey.class);
-                        if (key == null) {
-                            // FIXME: do we have a backup plan?
-                            logger.info("Failed to extract node key from {}", input);
-                    }
-                    return key;
-                }
-            }), Predicates.notNull());
-        stats.startNodeHandlers(addedNodes);
-
-        logger.debug("Tracker at root {} finished processing notification", root);
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsEntry.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsEntry.java
deleted file mode 100644 (file)
index c43c1eb..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-
-final class FlowStatsEntry {
-    private final Short tableId;
-    private final Flow flow;
-
-    public FlowStatsEntry(Short tableId, Flow flow){
-        this.tableId = tableId;
-        this.flow = flow;
-    }
-
-    public Short getTableId() {
-        return tableId;
-    }
-
-    public Flow getFlow() {
-        return flow;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((flow == null) ? 0 : flow.hashCode());
-        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        FlowStatsEntry other = (FlowStatsEntry) obj;
-        if (flow == null) {
-            if (other.flow != null)
-                return false;
-        } else if (!flow.equals(other.flow))
-            return false;
-        if (tableId == null) {
-            if (other.tableId != null)
-                return false;
-        } else if (!tableId.equals(other.tableId))
-            return false;
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "FlowStatsEntry [tableId=" + tableId + ", flow=" + flow + "]";
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java
deleted file mode 100644 (file)
index d540f11..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.math.BigInteger;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map.Entry;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCookieMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowCookieMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowCookieMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowCookieMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericStatistics;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-
-final class FlowStatsTracker extends AbstractListeningStatsTracker<FlowAndStatisticsMapList, FlowStatsEntry> {
-    private static final Logger LOG = LoggerFactory.getLogger(FlowStatsTracker.class);
-    private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
-    private final OpendaylightFlowStatisticsService flowStatsService;
-    private FlowTableStatsTracker flowTableStats;
-    private int unaccountedFlowsCounter = 1;
-
-
-    FlowStatsTracker(final OpendaylightFlowStatisticsService flowStatsService, final FlowCapableContext context) {
-        super(context);
-        this.flowStatsService = flowStatsService;
-    }
-    FlowStatsTracker(final OpendaylightFlowStatisticsService flowStatsService, final FlowCapableContext context, final FlowTableStatsTracker flowTableStats) {
-        this(flowStatsService, context);
-        this.flowTableStats = flowTableStats;
-    }
-
-    @Override
-    protected void cleanupSingleStat(final DataModificationTransaction trans, final FlowStatsEntry item) {
-        KeyedInstanceIdentifier<Flow, FlowKey> flowRef = getNodeIdentifier()
-                .augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(item.getTableId()))
-                .child(Flow.class, item.getFlow().getKey());
-        trans.removeOperationalData(flowRef);
-    }
-
-    @Override
-    protected FlowStatsEntry updateSingleStat(final DataModificationTransaction trans, final FlowAndStatisticsMapList map) {
-        short tableId = map.getTableId();
-
-        FlowStatisticsDataBuilder flowStatisticsData = new FlowStatisticsDataBuilder();
-
-        FlowBuilder flowBuilder = new FlowBuilder(map);
-        if (map.getFlowId() != null) {
-            flowBuilder.setId(new FlowId(map.getFlowId().getValue()));
-        }
-        if (map.getFlowId() != null) {
-            flowBuilder.setKey(new FlowKey(new FlowId(map.getKey().getFlowId().getValue())));
-        }
-
-        Flow flowRule = flowBuilder.build();
-
-        FlowAndStatisticsMapListBuilder stats = new FlowAndStatisticsMapListBuilder();
-        stats.setByteCount(map.getByteCount());
-        stats.setPacketCount(map.getPacketCount());
-        stats.setDuration(map.getDuration());
-
-        GenericStatistics flowStats = stats.build();
-
-        //Augment the data to the flow node
-
-        FlowStatisticsBuilder flowStatistics = new FlowStatisticsBuilder();
-        flowStatistics.setByteCount(flowStats.getByteCount());
-        flowStatistics.setPacketCount(flowStats.getPacketCount());
-        flowStatistics.setDuration(flowStats.getDuration());
-
-        flowStatisticsData.setFlowStatistics(flowStatistics.build());
-
-        LOG.debug("Flow : {}",flowRule.toString());
-        LOG.debug("Statistics to augment : {}",flowStatistics.build().toString());
-
-        InstanceIdentifier<Table> tableRef = getNodeIdentifierBuilder()
-                .augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(tableId)).toInstance();
-
-        final FlowCookie flowCookie = flowRule.getCookie() != null
-                ? flowRule.getCookie() : new FlowCookie(BigInteger.ZERO);
-        final InstanceIdentifier<FlowCookieMap> flowCookieRef = tableRef
-                .augmentation(FlowCookieMapping.class)
-                .child(FlowCookieMap.class, new FlowCookieMapKey(flowCookie));
-
-        FlowCookieMap cookieMap = (FlowCookieMap) trans.readOperationalData(flowCookieRef);
-
-        /* find flowKey in FlowCookieMap from DataStore/OPERATIONAL */
-        Optional<FlowKey> flowKey = this.getExistFlowKey(flowRule, tableRef, trans, cookieMap);
-        if ( ! flowKey.isPresent()) {
-            /* DataStore/CONFIG For every first statistic needs to be created */
-            flowKey = this.getFlowKeyFromExistFlow(flowRule, tableRef, trans);
-            if ( ! flowKey.isPresent()) {
-                /* Alien flow */
-                flowKey = this.makeAlienFlowKey(flowRule);
-            }
-            cookieMap = applyNewFlowKey(cookieMap, flowKey, flowCookie);
-            trans.putOperationalData(flowCookieRef, cookieMap);
-        }
-
-        InstanceIdentifier<Flow> flowRef = getNodeIdentifierBuilder()
-                .augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(tableId))
-                .child(Flow.class, flowKey.get()).toInstance();
-        flowBuilder.setKey(flowKey.get());
-        flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
-
-        // Update entry with timestamp of latest response
-        flowBuilder.setKey(flowKey.get());
-        FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId, flowBuilder.build());
-        trans.putOperationalData(flowRef, flowBuilder.build());
-        return flowStatsEntry;
-    }
-
-    @Override
-    protected InstanceIdentifier<?> listenPath() {
-        return getNodeIdentifierBuilder().augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class).build();
-    }
-
-    @Override
-    protected String statName() {
-        return "Flow";
-    }
-
-    @Override
-    public void request() {
-        // FIXME: it does not make sense to trigger this before sendAllFlowTablesStatisticsRequest()
-        //        comes back -- we do not have any tables anyway.
-        final Collection<TableKey> tables = flowTableStats.getTables();
-        LOG.debug("Node {} supports {} table(s)", this.getNodeRef(), tables.size());
-        for (final TableKey key : tables) {
-            LOG.debug("Send aggregate stats request for flow table {} to node {}", key.getId(), this.getNodeRef());
-            this.requestAggregateFlows(key);
-        }
-
-        this.requestAllFlowsAllTables();
-
-    }
-    public void requestAllFlowsAllTables() {
-        if (flowStatsService != null) {
-            final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(flowStatsService.getAllFlowsStatisticsFromAllFlowTables(input.build()));
-        }
-    }
-
-    public void requestAggregateFlows(final TableKey key) {
-        if (flowStatsService != null) {
-            GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
-                    new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
-
-            input.setNode(getNodeRef());
-            input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId(key.getId()));
-            requestHelper(flowStatsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()));
-        }
-    }
-
-    public void requestFlow(final Flow flow) {
-        if (flowStatsService != null) {
-            final GetFlowStatisticsFromFlowTableInputBuilder input =
-                    new GetFlowStatisticsFromFlowTableInputBuilder(flow);
-            input.setNode(getNodeRef());
-
-            requestHelper(flowStatsService.getFlowStatisticsFromFlowTable(input.build()));
-        }
-    }
-
-    @Override
-    public void onDataChanged(final DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        for (Entry<InstanceIdentifier<?>, DataObject> e : change.getCreatedConfigurationData().entrySet()) {
-            if (Flow.class.equals(e.getKey().getTargetType())) {
-                final Flow flow = (Flow) e.getValue();
-                LOG.debug("Key {} triggered request for flow {}", e.getKey(), flow);
-                requestFlow(flow);
-            } else {
-                LOG.debug("Ignoring key {}", e.getKey());
-            }
-        }
-
-        final DataModificationTransaction trans = startTransaction();
-        for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
-            if (Flow.class.equals(key.getTargetType())) {
-                @SuppressWarnings("unchecked")
-                final InstanceIdentifier<Flow> flow = (InstanceIdentifier<Flow>)key;
-                LOG.debug("Key {} triggered remove of Flow from operational space.", key);
-                trans.removeOperationalData(flow);
-            }
-        }
-        trans.commit();
-    }
-
-    @Override
-    public void start(final DataBrokerService dbs) {
-        if (flowStatsService == null) {
-            LOG.debug("No Flow Statistics service, not subscribing to flows on node {}", getNodeIdentifier());
-            return;
-        }
-
-        super.start(dbs);
-    }
-
-    /* Returns Exist FlowKey from exist FlowCookieMap identified by cookie
-     * and by switch flow identification (priority and match)*/
-    private Optional<FlowKey> getExistFlowKey(final Flow flowRule, final InstanceIdentifier<Table> tableRef,
-            final DataModificationTransaction trans, final FlowCookieMap cookieMap) {
-
-        if (cookieMap != null) {
-            for (FlowId flowId : cookieMap.getFlowIds()) {
-                InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, new FlowKey(flowId));
-                if (flowId.getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) {
-                    LOG.debug("Search for flow in the operational datastore by flowID: {} ", flowIdent);
-                    Flow readedFlow = (Flow) trans.readOperationalData(flowIdent);
-                    if (FlowComparator.flowEquals(flowRule, readedFlow)) {
-                        return Optional.<FlowKey> of(new FlowKey(flowId));
-                    }
-                } else {
-                    LOG.debug("Search for flow in the configuration datastore by flowID: {} ", flowIdent);
-                    Flow readedFlow = (Flow) trans.readConfigurationData(flowIdent);
-                    if (FlowComparator.flowEquals(flowRule, readedFlow)) {
-                        return Optional.<FlowKey> of(new FlowKey(flowId));
-                    }
-                }
-            }
-            LOG.debug("Flow was not found in the datastore. Flow {} ", flowRule);
-        }
-        return Optional.absent();
-    }
-
-    /* Returns FlowKey from existing Flow in DataStore/CONFIGURATIONAL which is identified by cookie
-     * and by switch flow identification (priority and match) */
-    private Optional<FlowKey> getFlowKeyFromExistFlow(final Flow flowRule, final InstanceIdentifier<Table> tableRef,
-            final DataModificationTransaction trans) {
-
-        /* Try to find it in DataSotre/CONFIG */
-        Table table= (Table)trans.readConfigurationData(tableRef);
-        if(table != null) {
-            for(Flow existingFlow : table.getFlow()) {
-                LOG.debug("Existing flow in data store : {}",existingFlow.toString());
-                if(FlowComparator.flowEquals(flowRule,existingFlow)){
-                    return Optional.<FlowKey> of(new FlowKey(existingFlow.getId()));
-                }
-            }
-        }
-        return Optional.absent();
-    }
-
-    /* Returns FlowKey which doesn't exist in any DataStore for now */
-    private Optional<FlowKey> makeAlienFlowKey(final Flow flowRule) {
-
-        StringBuilder sBuilder = new StringBuilder(ALIEN_SYSTEM_FLOW_ID)
-            .append(flowRule.getTableId()).append("-").append(this.unaccountedFlowsCounter);
-        this.unaccountedFlowsCounter++;
-        final FlowId flowId = new FlowId(sBuilder.toString());
-        return Optional.<FlowKey> of(new FlowKey(flowId));
-    }
-
-    /* Build new whole FlowCookieMap or add new flowKey */
-    private FlowCookieMap applyNewFlowKey(FlowCookieMap flowCookieMap, final Optional<FlowKey> flowKey,
-            final FlowCookie flowCookie) {
-        if (flowCookieMap != null) {
-            flowCookieMap.getFlowIds().add(flowKey.get().getId());
-        } else {
-            final FlowCookieMapBuilder flowCookieMapBuilder = new FlowCookieMapBuilder();
-            flowCookieMapBuilder.setCookie(flowCookie);
-            flowCookieMapBuilder.setFlowIds(Collections.singletonList(flowKey.get().getId()));
-            flowCookieMap = flowCookieMapBuilder.build();
-        }
-        return flowCookieMap;
-    }
-
-    @Override
-    protected FlowStatsEntry createInvariantKey(final FlowStatsEntry item) {
-        FlowBuilder newFlow = new FlowBuilder();
-        newFlow.setId(item.getFlow().getId());
-        newFlow.setKey(item.getFlow().getKey());
-        newFlow.fieldsFrom(item.getFlow());
-        return new FlowStatsEntry(item.getTableId(),newFlow.build());
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowTableStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowTableStatsTracker.java
deleted file mode 100644 (file)
index 2e85058..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ConcurrentSkipListSet;
-
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatisticsBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-final class FlowTableStatsTracker extends AbstractStatsTracker<FlowTableAndStatisticsMap, FlowTableAndStatisticsMap> {
-    private final Set<TableKey> privateTables = new ConcurrentSkipListSet<>();
-    private final Set<TableKey> tables = Collections.unmodifiableSet(privateTables);
-    private final OpendaylightFlowTableStatisticsService flowTableStatsService;
-
-    FlowTableStatsTracker(OpendaylightFlowTableStatisticsService flowTableStatsService, final FlowCapableContext context) {
-        super(context);
-        this.flowTableStatsService = flowTableStatsService;
-    }
-
-    Set<TableKey> getTables() {
-        return tables;
-    }
-
-    @Override
-    protected void cleanupSingleStat(DataModificationTransaction trans, FlowTableAndStatisticsMap item) {
-        // TODO: do we want to do this?
-    }
-
-    @Override
-    protected FlowTableAndStatisticsMap updateSingleStat(DataModificationTransaction trans, FlowTableAndStatisticsMap item) {
-
-        InstanceIdentifier<Table> tableRef = getNodeIdentifierBuilder()
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(item.getTableId().getValue())).build();
-
-        FlowTableStatisticsDataBuilder statisticsDataBuilder = new FlowTableStatisticsDataBuilder();
-        final FlowTableStatistics stats = new FlowTableStatisticsBuilder(item).build();
-        statisticsDataBuilder.setFlowTableStatistics(stats);
-
-        TableBuilder tableBuilder = new TableBuilder();
-        tableBuilder.setKey(new TableKey(item.getTableId().getValue()));
-        tableBuilder.addAugmentation(FlowTableStatisticsData.class, statisticsDataBuilder.build());
-        trans.putOperationalData(tableRef, tableBuilder.build());
-        return item;
-    }
-
-    @Override
-    public void request() {
-        if (flowTableStatsService != null) {
-            final GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(flowTableStatsService.getFlowTablesStatistics(input.build()));
-        }
-    }
-
-    @Override
-    protected FlowTableAndStatisticsMap createInvariantKey(FlowTableAndStatisticsMap item) {
-        FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder();
-        flowTableAndStatisticsMapBuilder.setTableId(item.getTableId());
-        flowTableAndStatisticsMapBuilder.setKey(item.getKey());
-        return flowTableAndStatisticsMapBuilder.build();
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java
deleted file mode 100644 (file)
index 11c6d4c..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.desc.GroupDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class GroupDescStatsTracker extends AbstractListeningStatsTracker<GroupDescStats, GroupDescStats> {
-    private static final Logger logger = LoggerFactory.getLogger(GroupDescStatsTracker.class);
-    private final OpendaylightGroupStatisticsService groupStatsService;
-
-    public GroupDescStatsTracker(OpendaylightGroupStatisticsService groupStatsService, final FlowCapableContext context) {
-        super(context);
-        this.groupStatsService = groupStatsService;
-    }
-
-    @Override
-    protected GroupDescStats updateSingleStat(DataModificationTransaction trans, GroupDescStats item) {
-        GroupBuilder groupBuilder = new GroupBuilder();
-        GroupKey groupKey = new GroupKey(item.getGroupId());
-        groupBuilder.setKey(groupKey);
-
-        InstanceIdentifier<Group> groupRef = getNodeIdentifierBuilder()
-                .augmentation(FlowCapableNode.class).child(Group.class,groupKey).build();
-
-        NodeGroupDescStatsBuilder groupDesc= new NodeGroupDescStatsBuilder();
-        groupDesc.setGroupDesc(new GroupDescBuilder(item).build());
-
-        //Update augmented data
-        groupBuilder.addAugmentation(NodeGroupDescStats.class, groupDesc.build());
-
-        trans.putOperationalData(groupRef, groupBuilder.build());
-        return item;
-    }
-
-    @Override
-    protected void cleanupSingleStat(DataModificationTransaction trans, GroupDescStats item) {
-        InstanceIdentifier<NodeGroupDescStats> groupRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class)
-                .child(Group.class, new GroupKey(item.getGroupId())).augmentation(NodeGroupDescStats.class).build();
-        trans.removeOperationalData(groupRef);
-    }
-
-    @Override
-    protected InstanceIdentifier<?> listenPath() {
-        return getNodeIdentifierBuilder().augmentation(FlowCapableNode.class).child(Group.class).build();
-    }
-
-    @Override
-    protected String statName() {
-        return "Group Descriptor";
-    }
-
-    @Override
-    public void request() {
-        if (groupStatsService != null) {
-            final GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(groupStatsService.getGroupDescription(input.build()));
-        }
-    }
-
-    @Override
-    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        for (InstanceIdentifier<?> key : change.getCreatedConfigurationData().keySet()) {
-            if (Group.class.equals(key.getTargetType())) {
-                logger.debug("Key {} triggered request", key);
-                request();
-            } else {
-                logger.debug("Ignoring key {}", key);
-            }
-        }
-
-        final DataModificationTransaction trans = startTransaction();
-        for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
-            if (Group.class.equals(key.getTargetType())) {
-                @SuppressWarnings("unchecked")
-                InstanceIdentifier<Group> group = (InstanceIdentifier<Group>)key;
-                InstanceIdentifier<?> del = group.augmentation(NodeGroupDescStats.class);
-                logger.debug("Key {} triggered remove of augmentation {}", key, del);
-
-                trans.removeOperationalData(del);
-            }
-        }
-        trans.commit();
-    }
-
-    @Override
-    public void start(final DataBrokerService dbs) {
-        if (groupStatsService == null) {
-            logger.debug("No Group Statistics service, not subscribing to groups on node {}", getNodeIdentifier());
-            return;
-        }
-
-        super.start(dbs);
-    }
-
-    @Override
-    protected GroupDescStats createInvariantKey(GroupDescStats item) {
-        // No invariant data exist in the group description stats.
-        return item;
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java
deleted file mode 100644 (file)
index f3ba456..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-final class GroupStatsTracker extends AbstractListeningStatsTracker<GroupStats, GroupStats> {
-    private static final Logger logger = LoggerFactory.getLogger(GroupStatsTracker.class);
-    private final OpendaylightGroupStatisticsService groupStatsService;
-
-    GroupStatsTracker(OpendaylightGroupStatisticsService groupStatsService, FlowCapableContext context) {
-        super(context);
-        this.groupStatsService = Preconditions.checkNotNull(groupStatsService);
-    }
-
-    @Override
-    protected void cleanupSingleStat(DataModificationTransaction trans, GroupStats item) {
-        InstanceIdentifier<NodeGroupStatistics> groupRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class)
-                .child(Group.class, new GroupKey(item.getGroupId())).augmentation(NodeGroupStatistics.class).build();
-        trans.removeOperationalData(groupRef);
-    }
-
-    @Override
-    protected GroupStats updateSingleStat(DataModificationTransaction trans,
-            GroupStats item) {
-        GroupBuilder groupBuilder = new GroupBuilder();
-        GroupKey groupKey = new GroupKey(item.getGroupId());
-        groupBuilder.setKey(groupKey);
-
-        InstanceIdentifier<Group> groupRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class)
-                .child(Group.class,groupKey).build();
-
-        NodeGroupStatisticsBuilder groupStatisticsBuilder= new NodeGroupStatisticsBuilder();
-        groupStatisticsBuilder.setGroupStatistics(new GroupStatisticsBuilder(item).build());
-
-        //Update augmented data
-        groupBuilder.addAugmentation(NodeGroupStatistics.class, groupStatisticsBuilder.build());
-        trans.putOperationalData(groupRef, groupBuilder.build());
-        return item;
-    }
-
-    @Override
-    protected InstanceIdentifier<?> listenPath() {
-        return getNodeIdentifierBuilder().augmentation(FlowCapableNode.class).child(Group.class).build();
-    }
-
-    @Override
-    protected String statName() {
-        return "Group";
-    }
-
-    @Override
-    public void request() {
-        final GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
-        input.setNode(getNodeRef());
-
-        requestHelper(groupStatsService.getAllGroupStatistics(input.build()));
-    }
-
-    @Override
-    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        final DataModificationTransaction trans = startTransaction();
-        for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
-            if (Group.class.equals(key.getTargetType())) {
-                @SuppressWarnings("unchecked")
-                InstanceIdentifier<Group> group = (InstanceIdentifier<Group>)key;
-                InstanceIdentifier<?> del = group.augmentation(NodeGroupStatistics.class);
-                logger.debug("Key {} triggered remove of augmentation {}", key, del);
-
-                trans.removeOperationalData(del);
-            }
-        }
-        trans.commit();
-    }
-
-    @Override
-    public void start(final DataBrokerService dbs) {
-        if (groupStatsService == null) {
-            logger.debug("No Group Statistics service, not subscribing to groups on node {}", getNodeIdentifier());
-            return;
-        }
-
-        super.start(dbs);
-    }
-
-    @Override
-    protected GroupStats createInvariantKey(GroupStats item) {
-        GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
-        groupStatsBuilder.setKey(item.getKey());
-        groupStatsBuilder.setGroupId(item.getGroupId());
-        return groupStatsBuilder.build();
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java
deleted file mode 100644 (file)
index 88139fc..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterConfigStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class MeterConfigStatsTracker extends AbstractListeningStatsTracker<MeterConfigStats, MeterConfigStats> {
-    private static final Logger logger = LoggerFactory.getLogger(MeterConfigStatsTracker.class);
-    private final OpendaylightMeterStatisticsService meterStatsService;
-
-    protected MeterConfigStatsTracker(OpendaylightMeterStatisticsService meterStatsService, final FlowCapableContext context) {
-        super(context);
-        this.meterStatsService = meterStatsService;
-    }
-
-    @Override
-    protected void cleanupSingleStat(DataModificationTransaction trans, MeterConfigStats item) {
-        InstanceIdentifier<NodeMeterConfigStats> meterRef = getNodeIdentifierBuilder()
-                            .augmentation(FlowCapableNode.class)
-                            .child(Meter.class, new MeterKey(item.getMeterId()))
-                            .augmentation(NodeMeterConfigStats.class).build();
-        trans.removeOperationalData(meterRef);
-    }
-
-    @Override
-    protected MeterConfigStats updateSingleStat(DataModificationTransaction trans, MeterConfigStats item) {
-        MeterBuilder meterBuilder = new MeterBuilder();
-        MeterKey meterKey = new MeterKey(item.getMeterId());
-        meterBuilder.setKey(meterKey);
-
-        InstanceIdentifier<Meter> meterRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class)
-                .child(Meter.class,meterKey).toInstance();
-
-        NodeMeterConfigStatsBuilder meterConfig = new NodeMeterConfigStatsBuilder();
-        meterConfig.setMeterConfigStats(new MeterConfigStatsBuilder(item).build());
-
-        //Update augmented data
-        meterBuilder.addAugmentation(NodeMeterConfigStats.class, meterConfig.build());
-
-        trans.putOperationalData(meterRef, meterBuilder.build());
-        return item;
-    }
-
-    @Override
-    public void request() {
-        if (meterStatsService != null) {
-            GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(meterStatsService.getAllMeterConfigStatistics(input.build()));
-        }
-    }
-
-    @Override
-    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        final DataModificationTransaction trans = startTransaction();
-
-        for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
-            if (Meter.class.equals(key.getTargetType())) {
-                @SuppressWarnings("unchecked")
-                InstanceIdentifier<Meter> meter = (InstanceIdentifier<Meter>)key;
-
-                InstanceIdentifier<?> nodeMeterStatisticsAugmentation =
-                        meter.augmentation(NodeMeterConfigStats.class);
-                trans.removeOperationalData(nodeMeterStatisticsAugmentation);
-            }
-        }
-
-        trans.commit();
-    }
-
-    @Override
-    protected InstanceIdentifier<?> listenPath() {
-        return getNodeIdentifierBuilder().augmentation(FlowCapableNode.class).child(Meter.class).build();
-    }
-
-    @Override
-    protected String statName() {
-        return "Meter Config";
-    }
-
-    @Override
-    public void start(final DataBrokerService dbs) {
-        if (meterStatsService == null) {
-            logger.debug("No Meter Statistics service, not subscribing to meter on node {}", getNodeIdentifier());
-            return;
-        }
-
-        super.start(dbs);
-    }
-
-    @Override
-    protected MeterConfigStats createInvariantKey(MeterConfigStats item) {
-        // No invariant data exist in the meter config stats.
-        return item;
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java
deleted file mode 100644 (file)
index f43ec69..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class MeterStatsTracker extends AbstractListeningStatsTracker<MeterStats, MeterStats> {
-    private static final Logger logger = LoggerFactory.getLogger(MeterStatsTracker.class);
-    private final OpendaylightMeterStatisticsService meterStatsService;
-
-    MeterStatsTracker(OpendaylightMeterStatisticsService meterStatsService, final FlowCapableContext context) {
-        super(context);
-        this.meterStatsService = meterStatsService;
-    }
-
-    @Override
-    protected void cleanupSingleStat(DataModificationTransaction trans, MeterStats item) {
-        InstanceIdentifier<NodeMeterStatistics> meterRef = getNodeIdentifierBuilder()
-                            .augmentation(FlowCapableNode.class)
-                            .child(Meter.class,new MeterKey(item.getMeterId()))
-                            .augmentation(NodeMeterStatistics.class).build();
-        trans.removeOperationalData(meterRef);
-    }
-
-    @Override
-    protected MeterStats updateSingleStat(DataModificationTransaction trans, MeterStats item) {
-        MeterBuilder meterBuilder = new MeterBuilder();
-        MeterKey meterKey = new MeterKey(item.getMeterId());
-        meterBuilder.setKey(meterKey);
-
-        InstanceIdentifier<Meter> meterRef = getNodeIdentifierBuilder()
-                .augmentation(FlowCapableNode.class).child(Meter.class,meterKey).build();
-
-        NodeMeterStatisticsBuilder meterStatsBuilder= new NodeMeterStatisticsBuilder();
-        meterStatsBuilder.setMeterStatistics(new MeterStatisticsBuilder(item).build());
-
-        //Update augmented data
-        meterBuilder.addAugmentation(NodeMeterStatistics.class, meterStatsBuilder.build());
-        trans.putOperationalData(meterRef, meterBuilder.build());
-        return item;
-    }
-
-    @Override
-    public void request() {
-        if (meterStatsService != null) {
-            GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(meterStatsService.getAllMeterStatistics(input.build()));
-        }
-    }
-
-    @Override
-    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        for (InstanceIdentifier<?> key : change.getCreatedConfigurationData().keySet()) {
-            if (Meter.class.equals(key.getTargetType())) {
-                request();
-            }
-        }
-
-        final DataModificationTransaction trans = startTransaction();
-        for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
-            if (Meter.class.equals(key.getTargetType())) {
-                @SuppressWarnings("unchecked")
-                InstanceIdentifier<Meter> meter = (InstanceIdentifier<Meter>)key;
-
-                InstanceIdentifier<?> nodeMeterStatisticsAugmentation =
-                        meter.augmentation(NodeMeterStatistics.class);
-                trans.removeOperationalData(nodeMeterStatisticsAugmentation);
-            }
-        }
-        trans.commit();
-    }
-
-    @Override
-    protected InstanceIdentifier<?> listenPath() {
-        return getNodeIdentifierBuilder().augmentation(FlowCapableNode.class).child(Meter.class).build();
-    }
-
-    @Override
-    protected String statName() {
-        return "Meter";
-    }
-
-    @Override
-    public void start(final DataBrokerService dbs) {
-        if (meterStatsService == null) {
-            logger.debug("No Meter Statistics service, not subscribing to meters on node {}", getNodeIdentifier());
-            return;
-        }
-
-        super.start(dbs);
-    }
-
-    @Override
-    protected MeterStats createInvariantKey(MeterStats item) {
-        MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();
-        meterStatsBuilder.setKey(item.getKey());
-        meterStatsBuilder.setMeterId(item.getMeterId());
-        return meterStatsBuilder.build();
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MultipartMessageManager.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MultipartMessageManager.java
deleted file mode 100644 (file)
index 425a449..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.MultipartTransactionAware;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Main responsibility of the class is to manage multipart response
- * for multipart request. It also handles the flow aggregate request
- * and response mapping.
- * @author avishnoi@in.ibm.com
- *
- */
-class MultipartMessageManager {
-    /*
-     *  Map for tx id and type of request, to keep track of all the request sent
-     *  by Statistics Manager. Statistics Manager won't entertain any multipart
-     *  response for which it didn't send the request.
-     */
-    private final Map<TxIdEntry,Long> txIdToRequestTypeMap = new ConcurrentHashMap<>();
-    /*
-     * Map to keep track of the request tx id for flow table statistics request.
-     * Because flow table statistics multi part response do not contains the table id.
-     */
-    private final Map<TxIdEntry,Short> txIdTotableIdMap = new ConcurrentHashMap<>();
-    private final long lifetimeNanos;
-
-    public MultipartMessageManager(long lifetimeNanos) {
-        this.lifetimeNanos = lifetimeNanos;
-    }
-
-    private static final class TxIdEntry {
-        private final TransactionId txId;
-
-        public TxIdEntry(TransactionId txId) {
-            this.txId = txId;
-        }
-        public TransactionId getTxId() {
-            return txId;
-        }
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((txId == null) ? 0 : txId.hashCode());
-            return result;
-        }
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (!(obj instanceof TxIdEntry)) {
-                return false;
-            }
-            TxIdEntry other = (TxIdEntry) obj;
-
-            if (txId == null) {
-                if (other.txId != null) {
-                    return false;
-                }
-            } else if (!txId.equals(other.txId)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            return "TxIdEntry [txId=" + txId + ']';
-        }
-    }
-
-    public void recordExpectedTableTransaction(TransactionId id, Short tableId) {
-        recordExpectedTransaction(id);
-        txIdTotableIdMap.put(new TxIdEntry(id), Preconditions.checkNotNull(tableId));
-    }
-
-    public Short isExpectedTableTransaction(TransactionAware transaction) {
-        Boolean more = null;
-        if (transaction instanceof MultipartTransactionAware) {
-            more = ((MultipartTransactionAware)transaction).isMoreReplies();
-        }
-
-        if (!isExpectedTransaction(transaction, more)) {
-            return null;
-        }
-
-        final TxIdEntry key = new TxIdEntry(transaction.getTransactionId());
-        if (more != null && more.booleanValue()) {
-            return txIdTotableIdMap.get(key);
-        } else {
-            return txIdTotableIdMap.remove(key);
-        }
-    }
-
-    public void recordExpectedTransaction(TransactionId id) {
-        TxIdEntry entry = new TxIdEntry(Preconditions.checkNotNull(id));
-        txIdToRequestTypeMap.put(entry, getExpiryTime());
-    }
-
-    private boolean isExpectedTransaction(TransactionAware transaction, Boolean more) {
-        final TxIdEntry entry = new TxIdEntry(transaction.getTransactionId());
-        if (more != null && more.booleanValue()) {
-            return txIdToRequestTypeMap.containsKey(entry);
-        } else {
-            return txIdToRequestTypeMap.remove(entry) != null;
-        }
-    }
-
-    public boolean isExpectedTransaction(TransactionAware transaction) {
-        Boolean more = null;
-        if (transaction instanceof MultipartTransactionAware) {
-            more = ((MultipartTransactionAware)transaction).isMoreReplies();
-        }
-
-        return isExpectedTransaction(transaction, more);
-    }
-
-    private Long getExpiryTime() {
-        return System.nanoTime() + lifetimeNanos;
-    }
-
-    public void cleanStaleTransactionIds() {
-        final long now = System.nanoTime();
-
-        for (Iterator<TxIdEntry> it = txIdToRequestTypeMap.keySet().iterator();it.hasNext();){
-            TxIdEntry txIdEntry = it.next();
-
-            Long expiryTime = txIdToRequestTypeMap.get(txIdEntry);
-            if(now > expiryTime){
-                it.remove();
-                txIdTotableIdMap.remove(txIdEntry);
-            }
-        }
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeConnectorStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeConnectorStatsTracker.java
deleted file mode 100644 (file)
index 2e2bf1c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class NodeConnectorStatsTracker extends AbstractStatsTracker<NodeConnectorStatisticsAndPortNumberMap, NodeConnectorStatisticsAndPortNumberMap> {
-    private static final Logger logger = LoggerFactory.getLogger(NodeConnectorStatsTracker.class);
-    private final OpendaylightPortStatisticsService portStatsService;
-
-    NodeConnectorStatsTracker(final OpendaylightPortStatisticsService portStatsService, final FlowCapableContext context) {
-        super(context);
-        this.portStatsService = portStatsService;
-    }
-
-    @Override
-    protected void cleanupSingleStat(final DataModificationTransaction trans, final NodeConnectorStatisticsAndPortNumberMap item) {
-        // TODO Auto-generated method stub
-    }
-
-    @Override
-    protected NodeConnectorStatisticsAndPortNumberMap updateSingleStat(final DataModificationTransaction trans, final NodeConnectorStatisticsAndPortNumberMap item) {
-        FlowCapableNodeConnectorStatisticsBuilder statisticsBuilder
-                                        = new FlowCapableNodeConnectorStatisticsBuilder();
-        statisticsBuilder.setBytes(item.getBytes());
-        statisticsBuilder.setCollisionCount(item.getCollisionCount());
-        statisticsBuilder.setDuration(item.getDuration());
-        statisticsBuilder.setPackets(item.getPackets());
-        statisticsBuilder.setReceiveCrcError(item.getReceiveCrcError());
-        statisticsBuilder.setReceiveDrops(item.getReceiveDrops());
-        statisticsBuilder.setReceiveErrors(item.getReceiveErrors());
-        statisticsBuilder.setReceiveFrameError(item.getReceiveFrameError());
-        statisticsBuilder.setReceiveOverRunError(item.getReceiveOverRunError());
-        statisticsBuilder.setTransmitDrops(item.getTransmitDrops());
-        statisticsBuilder.setTransmitErrors(item.getTransmitErrors());
-
-        //Augment data to the node-connector
-        FlowCapableNodeConnectorStatisticsDataBuilder statisticsDataBuilder =
-                new FlowCapableNodeConnectorStatisticsDataBuilder();
-
-        statisticsDataBuilder.setFlowCapableNodeConnectorStatistics(statisticsBuilder.build());
-
-        final NodeConnectorKey key = new NodeConnectorKey(item.getNodeConnectorId());
-        final InstanceIdentifier<NodeConnector> nodeConnectorRef = getNodeIdentifier().child(NodeConnector.class, key);
-
-        // FIXME: can we bypass this read?
-        NodeConnector nodeConnector = (NodeConnector)trans.readOperationalData(nodeConnectorRef);
-        if(nodeConnector != null){
-            final FlowCapableNodeConnectorStatisticsData stats = statisticsDataBuilder.build();
-            logger.debug("Augmenting port statistics {} to port {}",stats,nodeConnectorRef.toString());
-            NodeConnectorBuilder nodeConnectorBuilder = new NodeConnectorBuilder()
-                .setKey(key).setId(item.getNodeConnectorId())
-                .addAugmentation(FlowCapableNodeConnectorStatisticsData.class, stats);
-            trans.putOperationalData(nodeConnectorRef, nodeConnectorBuilder.build());
-        }
-
-        return item;
-    }
-
-    @Override
-    public void request() {
-        if (portStatsService != null) {
-            final GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(portStatsService.getAllNodeConnectorsStatistics(input.build()));
-        }
-    }
-
-    @Override
-    protected NodeConnectorStatisticsAndPortNumberMap createInvariantKey(NodeConnectorStatisticsAndPortNumberMap item) {
-        NodeConnectorStatisticsAndPortNumberMapBuilder ncStatsBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
-        ncStatsBuilder.setNodeConnectorId(item.getNodeConnectorId());
-        ncStatsBuilder.setKey(item.getKey());
-        return ncStatsBuilder.build();
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java
deleted file mode 100644 (file)
index db21623..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
-
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.aggregate.flow.statistics.AggregateFlowStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.AggregateFlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * This class handles the lifecycle of per-node statistics. It receives data
- * from StatisticsListener, stores it in the data store and keeps track of
- * when the data should be removed.
- *
- * @author avishnoi@in.ibm.com
- */
-public final class NodeStatisticsHandler implements AutoCloseable, FlowCapableContext {
-    private static final Logger logger = LoggerFactory.getLogger(NodeStatisticsHandler.class);
-
-    private static final long STATS_COLLECTION_MILLIS = TimeUnit.SECONDS.toMillis(15);
-    private static final long FIRST_COLLECTION_MILLIS = TimeUnit.SECONDS.toMillis(5);
-    private static final int NUMBER_OF_WAIT_CYCLES = 2;
-
-    private final MultipartMessageManager msgManager;
-    private final StatisticsRequestScheduler srScheduler;
-    private final InstanceIdentifier<Node> targetNodeIdentifier;
-    private final FlowStatsTracker flowStats;
-    private final FlowTableStatsTracker flowTableStats;
-    private final GroupDescStatsTracker groupDescStats;
-    private final GroupStatsTracker groupStats;
-    private final MeterConfigStatsTracker meterConfigStats;
-    private final MeterStatsTracker meterStats;
-    private final NodeConnectorStatsTracker nodeConnectorStats;
-    private final QueueStatsTracker queueStats;
-    private final DataProviderService dps;
-    private final NodeRef targetNodeRef;
-    private final NodeKey targetNodeKey;
-    private final TimerTask task = new TimerTask() {
-        @Override
-        public void run() {
-            try{
-                requestPeriodicStatistics();
-                cleanStaleStatistics();
-            }catch(Exception e){
-                logger.warn("Exception occured while sending statistics request : {}",e);
-            }
-        }
-    };
-
-    public NodeStatisticsHandler(final DataProviderService dps, final NodeKey nodeKey,
-            final OpendaylightFlowStatisticsService flowStatsService,
-            final OpendaylightFlowTableStatisticsService flowTableStatsService,
-            final OpendaylightGroupStatisticsService groupStatsService,
-            final OpendaylightMeterStatisticsService meterStatsService,
-            final OpendaylightPortStatisticsService portStatsService,
-            final OpendaylightQueueStatisticsService queueStatsService,
-            final StatisticsRequestScheduler srScheduler) {
-        this.dps = Preconditions.checkNotNull(dps);
-        this.targetNodeKey = Preconditions.checkNotNull(nodeKey);
-        this.srScheduler = Preconditions.checkNotNull(srScheduler);
-        this.targetNodeIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey).build();
-        this.targetNodeRef = new NodeRef(targetNodeIdentifier);
-
-        final long lifetimeNanos = TimeUnit.MILLISECONDS.toNanos(STATS_COLLECTION_MILLIS * NUMBER_OF_WAIT_CYCLES);
-
-        msgManager = new MultipartMessageManager(lifetimeNanos);
-        flowTableStats = new FlowTableStatsTracker(flowTableStatsService, this);
-        flowStats = new FlowStatsTracker(flowStatsService, this, flowTableStats);
-        groupDescStats = new GroupDescStatsTracker(groupStatsService, this);
-        groupStats = new GroupStatsTracker(groupStatsService, this);
-        meterConfigStats = new MeterConfigStatsTracker(meterStatsService, this);
-        meterStats = new MeterStatsTracker(meterStatsService, this);
-        nodeConnectorStats = new NodeConnectorStatsTracker(portStatsService, this);
-        queueStats = new QueueStatsTracker(queueStatsService, this);
-    }
-
-    public NodeKey getTargetNodeKey() {
-        return targetNodeKey;
-    }
-
-    @Override
-    public InstanceIdentifier<Node> getNodeIdentifier() {
-        return targetNodeIdentifier;
-    }
-
-    @Override
-    public NodeRef getNodeRef() {
-        return targetNodeRef;
-    }
-
-    @Override
-    public DataModificationTransaction startDataModification() {
-        DataModificationTransaction dmt = dps.beginTransaction();
-        dmt.registerListener(this.srScheduler);
-        return dmt;
-    }
-
-    public synchronized void updateGroupDescStats(TransactionAware transaction, List<GroupDescStats> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            groupDescStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateGroupStats(TransactionAware transaction, List<GroupStats> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            groupStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateMeterConfigStats(TransactionAware transaction, List<MeterConfigStats> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            meterConfigStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateMeterStats(TransactionAware transaction, List<MeterStats> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            meterStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateQueueStats(TransactionAware transaction, List<QueueIdAndStatisticsMap> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            queueStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateFlowTableStats(TransactionAware transaction, List<FlowTableAndStatisticsMap> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            flowTableStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateNodeConnectorStats(TransactionAware transaction, List<NodeConnectorStatisticsAndPortNumberMap> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            nodeConnectorStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateAggregateFlowStats(TransactionAware transaction, AggregateFlowStatistics flowStats) {
-        final Short tableId = msgManager.isExpectedTableTransaction(transaction);
-        if (tableId != null) {
-            final DataModificationTransaction trans = this.startDataModification();
-            InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey)
-                    .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)).toInstance();
-
-            AggregateFlowStatisticsDataBuilder aggregateFlowStatisticsDataBuilder = new AggregateFlowStatisticsDataBuilder();
-            AggregateFlowStatisticsBuilder aggregateFlowStatisticsBuilder = new AggregateFlowStatisticsBuilder(flowStats);
-
-            aggregateFlowStatisticsDataBuilder.setAggregateFlowStatistics(aggregateFlowStatisticsBuilder.build());
-
-            logger.debug("Augment aggregate statistics: {} for table {} on Node {}",
-                    aggregateFlowStatisticsBuilder.build().toString(),tableId,targetNodeKey);
-
-            TableBuilder tableBuilder = new TableBuilder();
-            tableBuilder.setKey(new TableKey(tableId));
-            tableBuilder.addAugmentation(AggregateFlowStatisticsData.class, aggregateFlowStatisticsDataBuilder.build());
-            trans.putOperationalData(tableRef, tableBuilder.build());
-
-            trans.commit();
-        }
-    }
-
-    public synchronized void updateFlowStats(TransactionAware transaction, List<FlowAndStatisticsMapList> list) {
-        if (msgManager.isExpectedTransaction(transaction)) {
-            flowStats.updateStats(list);
-        }
-    }
-
-    public synchronized void updateGroupFeatures(GroupFeatures notification) {
-        final DataModificationTransaction trans = this.startDataModification();
-
-        final NodeBuilder nodeData = new NodeBuilder();
-        nodeData.setKey(targetNodeKey);
-
-        NodeGroupFeaturesBuilder nodeGroupFeatures = new NodeGroupFeaturesBuilder();
-        GroupFeaturesBuilder groupFeatures = new GroupFeaturesBuilder(notification);
-        nodeGroupFeatures.setGroupFeatures(groupFeatures.build());
-
-        //Update augmented data
-        nodeData.addAugmentation(NodeGroupFeatures.class, nodeGroupFeatures.build());
-        trans.putOperationalData(targetNodeIdentifier, nodeData.build());
-
-        // FIXME: should we be tracking this data?
-        trans.commit();
-    }
-
-    public synchronized void updateMeterFeatures(MeterFeatures features) {
-        final DataModificationTransaction trans = this.startDataModification();
-
-        final NodeBuilder nodeData = new NodeBuilder();
-        nodeData.setKey(targetNodeKey);
-
-        NodeMeterFeaturesBuilder nodeMeterFeatures = new NodeMeterFeaturesBuilder();
-        MeterFeaturesBuilder meterFeature = new MeterFeaturesBuilder(features);
-        nodeMeterFeatures.setMeterFeatures(meterFeature.build());
-
-        //Update augmented data
-        nodeData.addAugmentation(NodeMeterFeatures.class, nodeMeterFeatures.build());
-        trans.putOperationalData(targetNodeIdentifier, nodeData.build());
-
-        // FIXME: should we be tracking this data?
-        trans.commit();
-    }
-
-    public synchronized void cleanStaleStatistics() {
-        final DataModificationTransaction trans = this.startDataModification();
-
-        flowStats.cleanup(trans);
-        groupDescStats.cleanup(trans);
-        groupStats.cleanup(trans);
-        meterConfigStats.cleanup(trans);
-        meterStats.cleanup(trans);
-        nodeConnectorStats.cleanup(trans);
-        queueStats.cleanup(trans);
-        msgManager.cleanStaleTransactionIds();
-
-        trans.commit();
-    }
-
-    public synchronized void requestPeriodicStatistics() {
-        logger.debug("Send requests for statistics collection to node : {}", targetNodeKey);
-
-        this.srScheduler.addRequestToSchedulerQueue(flowTableStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(flowStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(nodeConnectorStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(groupStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(groupDescStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(meterStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(meterConfigStats);
-
-        this.srScheduler.addRequestToSchedulerQueue(queueStats);
-    }
-
-    public synchronized void start(final Timer timer) {
-        flowStats.start(dps);
-        groupDescStats.start(dps);
-        groupStats.start(dps);
-        meterConfigStats.start(dps);
-        meterStats.start(dps);
-        queueStats.start(dps);
-
-        timer.schedule(task, (long) (Math.random() * FIRST_COLLECTION_MILLIS), STATS_COLLECTION_MILLIS);
-
-        logger.debug("Statistics handler for node started with base interval {}ms", STATS_COLLECTION_MILLIS);
-
-        requestPeriodicStatistics();
-    }
-
-    @Override
-    public synchronized void close() {
-        task.cancel();
-        flowStats.close();
-        groupDescStats.close();
-        groupStats.close();
-        meterConfigStats.close();
-        meterStats.close();
-        queueStats.close();
-
-        //Clean up queued statistics request from scheduler queue
-        srScheduler.removeRequestsFromSchedulerQueue(this.getNodeRef());
-
-        logger.debug("Statistics handler for {} shut down", targetNodeKey.getId());
-    }
-
-    @Override
-    public void registerTransaction(TransactionId id) {
-        msgManager.recordExpectedTransaction(id);
-        logger.debug("Transaction {} for node {} sent successfully", id, targetNodeKey);
-    }
-
-    @Override
-    public void registerTableTransaction(final TransactionId id, final Short table) {
-        msgManager.recordExpectedTableTransaction(id, table);
-        logger.debug("Transaction {} for node {} table {} sent successfully", id, targetNodeKey, table);
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsEntry.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsEntry.java
deleted file mode 100644 (file)
index d1f2529..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-
-final class QueueStatsEntry {
-    private final NodeConnectorId nodeConnectorId;
-    private final QueueId queueId;
-    public QueueStatsEntry(NodeConnectorId ncId, QueueId queueId){
-        this.nodeConnectorId = ncId;
-        this.queueId = queueId;
-    }
-    public NodeConnectorId getNodeConnectorId() {
-        return nodeConnectorId;
-    }
-    public QueueId getQueueId() {
-        return queueId;
-    }
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((nodeConnectorId == null) ? 0 : nodeConnectorId.hashCode());
-        result = prime * result + ((queueId == null) ? 0 : queueId.hashCode());
-        return result;
-    }
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (!(obj instanceof QueueStatsEntry)) {
-            return false;
-        }
-        QueueStatsEntry other = (QueueStatsEntry) obj;
-        if (nodeConnectorId == null) {
-            if (other.nodeConnectorId != null) {
-                return false;
-            }
-        } else if (!nodeConnectorId.equals(other.nodeConnectorId)) {
-            return false;
-        }
-        if (queueId == null) {
-            if (other.queueId != null) {
-                return false;
-            }
-        } else if (!queueId.equals(other.queueId)) {
-            return false;
-        }
-        return true;
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java
deleted file mode 100644 (file)
index 4a58970..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.Map.Entry;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.flow.capable.node.connector.queue.statistics.FlowCapableNodeConnectorQueueStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class QueueStatsTracker extends AbstractListeningStatsTracker<QueueIdAndStatisticsMap, QueueStatsEntry> {
-    private static final Logger logger = LoggerFactory.getLogger(QueueStatsTracker.class);
-    private final OpendaylightQueueStatisticsService queueStatsService;
-
-    QueueStatsTracker(OpendaylightQueueStatisticsService queueStatsService, final FlowCapableContext context) {
-        super(context);
-        this.queueStatsService = queueStatsService;
-    }
-
-    @Override
-    protected void cleanupSingleStat(DataModificationTransaction trans, QueueStatsEntry item) {
-        InstanceIdentifier<?> queueRef
-                            = getNodeIdentifierBuilder().child(NodeConnector.class, new NodeConnectorKey(item.getNodeConnectorId()))
-                                                .augmentation(FlowCapableNodeConnector.class)
-                                                .child(Queue.class, new QueueKey(item.getQueueId()))
-                                                .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class).build();
-        trans.removeOperationalData(queueRef);
-    }
-
-    @Override
-    protected QueueStatsEntry updateSingleStat(DataModificationTransaction trans, QueueIdAndStatisticsMap item) {
-
-        QueueStatsEntry queueEntry = new QueueStatsEntry(item.getNodeConnectorId(), item.getQueueId());
-
-        FlowCapableNodeConnectorQueueStatisticsDataBuilder queueStatisticsDataBuilder = new FlowCapableNodeConnectorQueueStatisticsDataBuilder();
-
-        FlowCapableNodeConnectorQueueStatisticsBuilder queueStatisticsBuilder = new FlowCapableNodeConnectorQueueStatisticsBuilder();
-
-        queueStatisticsBuilder.fieldsFrom(item);
-
-        queueStatisticsDataBuilder.setFlowCapableNodeConnectorQueueStatistics(queueStatisticsBuilder.build());
-
-        InstanceIdentifier<Queue> queueRef = getNodeIdentifierBuilder().child(NodeConnector.class, new NodeConnectorKey(item.getNodeConnectorId()))
-                                    .augmentation(FlowCapableNodeConnector.class)
-                                    .child(Queue.class, new QueueKey(item.getQueueId())).toInstance();
-
-        QueueBuilder queueBuilder = new QueueBuilder();
-        FlowCapableNodeConnectorQueueStatisticsData qsd = queueStatisticsDataBuilder.build();
-        queueBuilder.addAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class, qsd);
-        queueBuilder.setKey(new QueueKey(item.getQueueId()));
-
-        logger.debug("Augmenting queue statistics {} of queue {} to port {}",
-                                    qsd,
-                                    item.getQueueId(),
-                                    item.getNodeConnectorId());
-
-        trans.putOperationalData(queueRef, queueBuilder.build());
-        return queueEntry;
-    }
-
-    @Override
-    public void request() {
-        if (queueStatsService != null) {
-            GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder();
-            input.setNode(getNodeRef());
-
-            requestHelper(queueStatsService.getAllQueuesStatisticsFromAllPorts(input.build()));
-        }
-    }
-
-    public void request(NodeConnectorId nodeConnectorId, QueueId queueId) {
-        if (queueStatsService != null) {
-            GetQueueStatisticsFromGivenPortInputBuilder input = new GetQueueStatisticsFromGivenPortInputBuilder();
-
-            input.setNode(getNodeRef());
-            input.setNodeConnectorId(nodeConnectorId);
-            input.setQueueId(queueId);
-
-            requestHelper(queueStatsService.getQueueStatisticsFromGivenPort(input.build()));
-        }
-    }
-
-    @Override
-    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-        for (Entry<InstanceIdentifier<?>, DataObject> e : change.getCreatedConfigurationData().entrySet()) {
-            if (Queue.class.equals(e.getKey().getTargetType())) {
-                final Queue queue = (Queue) e.getValue();
-                final NodeConnectorKey key = e.getKey().firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
-                logger.debug("Key {} triggered request for connector {} queue {}", key.getId(), queue.getQueueId());
-                request(key.getId(), queue.getQueueId());
-            } else {
-                logger.debug("Ignoring key {}", e.getKey());
-            }
-        }
-
-        final DataModificationTransaction trans = startTransaction();
-        for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
-            if (Queue.class.equals(key.getTargetType())) {
-                @SuppressWarnings("unchecked")
-                final InstanceIdentifier<Queue> queue = (InstanceIdentifier<Queue>)key;
-                final InstanceIdentifier<?> del = queue
-                        .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
-                logger.debug("Key {} triggered remove of augmentation {}", key, del);
-
-                trans.removeOperationalData(del);
-            }
-        }
-        trans.commit();
-    }
-
-    @Override
-    protected InstanceIdentifier<?> listenPath() {
-        return getNodeIdentifierBuilder().child(NodeConnector.class)
-                .augmentation(FlowCapableNodeConnector.class).child(Queue.class).build();
-    }
-
-    @Override
-    protected String statName() {
-        return "Queue";
-    }
-
-    @Override
-    public void start(final DataBrokerService dbs) {
-        if (queueStatsService == null) {
-            logger.debug("No Queue Statistics service, not subscribing to queues on node {}", getNodeIdentifier());
-            return;
-        }
-
-        super.start(dbs);
-    }
-
-    @Override
-    protected QueueStatsEntry createInvariantKey(QueueStatsEntry item) {
-        // No invariant data exist in the group description stats.
-        return item;
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatListeningCommiter.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatListeningCommiter.java
new file mode 100644 (file)
index 0000000..be3d402
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager
+ *
+ * StatListeningCommiter
+ * Definition Interface for {@link DataChangeListener} implementer class rule.
+ * Interface represent a contract between Config/DataStore changes and
+ * Operational/DataStore commits. All Operational/DataStore commit have
+ * to by represent as RPC Device response Notification processing. So
+ * Operational/DS could contains only real mirror of OF Device
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 27, 2014
+ */
+public interface StatListeningCommiter<T extends DataObject, N extends NotificationListener> extends DataChangeListener, StatNotifyCommiter<N> {
+
+
+    /**
+     * All StatListeningCommiter implementer has to clean its actual state
+     * for all cached data related to disconnected node.
+     * Method prevents unwanted dataStore changes.
+     *
+     * @param nodeIdent
+     */
+    void cleanForDisconnect(InstanceIdentifier<Node> nodeIdent);
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatNodeRegistration.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatNodeRegistration.java
new file mode 100644 (file)
index 0000000..80a15a3
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatNodeRegistration
+ * Class represents {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}
+ * {@link org.opendaylight.controller.md.sal.binding.api.DataChangeListener} in Operational/DataStore for ADD / REMOVE
+ * actions which are represented connect / disconnect OF actions. Connect functionality are expecting
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Sep 5, 2014
+ */
+public interface StatNodeRegistration extends OpendaylightInventoryListener, AutoCloseable {
+
+    /**
+     * Method contains {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode} registration to {@link StatisticsManager}
+     * for permanently collecting statistics by {@link StatPermCollector} and
+     * as a prevention to use a validation check to the Operational/DS for identify
+     * connected {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}.
+     *
+     * @param InstanceIdentifier<SwitchFeatures> keyIdent
+     * @param FlowCapableNode data
+     * @param InstanceIdentifier<Node> nodeIdent
+     */
+    void connectFlowCapableNode(InstanceIdentifier<SwitchFeatures> keyIdent,
+            SwitchFeatures data, InstanceIdentifier<Node> nodeIdent);
+
+    /**
+     * Method cut {@link Node} registration for {@link StatPermCollector}
+     *
+     * @param InstanceIdentifier<Node> keyIdent
+     */
+    void disconnectFlowCapableNode(InstanceIdentifier<Node> keyIdent);
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatNotifyCommiter.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatNotifyCommiter.java
new file mode 100644 (file)
index 0000000..0392e47
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager
+ *
+ * StatNotifyCommiter
+ * Definition Interface for notification implementer class rule
+ * Interface represent a contract between RPC Device Notification
+ * and Operational/DataStore commits.
+ *
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 28, 2014
+ */
+public interface StatNotifyCommiter<N extends NotificationListener> extends AutoCloseable, NotificationListener {
+
+
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatPermCollector.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatPermCollector.java
new file mode 100644 (file)
index 0000000..9116e66
--- /dev/null
@@ -0,0 +1,115 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager
+ *
+ * StatPermCollector
+ * Class implement {@link Runnable} and inside is running statistic collecting
+ * process DataObject statistics by DataObject statistics for every {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}.
+ * Every statistics wait to finish previous statistics. Only if all statistics finish,
+ * next {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}
+ * Statistics should be collecting. We are able to set minimal time for start next round cross all Network,
+ * but all depends on network possibility.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 28, 2014
+ */
+public interface StatPermCollector extends Runnable, AutoCloseable {
+
+    /**
+     * StatCapType
+     * Enum class refers ofp_statistics capabilities fields from OF Switch
+     * capabilities specification which have to come as a post HandShake
+     * information from OF Switch and Inventory Manager adds all to the
+     * Operational/DS.
+     * If the capabilities are not add (for any reason) NodeRegistrator
+     * adds all StatCapTypes for the {@link Node}.
+     */
+    public enum StatCapabTypes {
+        /**
+         * OFPC_FLOW_STATS
+         */
+        FLOW_STATS,
+        /**
+         * OFPC_TABLE_STATS
+         */
+        TABLE_STATS,
+        /**
+         * OFPC_PORT_STATS
+         */
+        PORT_STATS,
+        /**
+         * OFPC_GROUP_STATS
+         */
+        GROUP_STATS,
+        /**
+         * OFPC_QUEUE_STATS
+         */
+        QUEUE_STATS,
+        /**
+         * Meter statistics has no support from OF Switch capabilities
+         * so we have to try get statistics for it and wait for response
+         * Error or response package with results.
+         */
+        METER_STATS
+    }
+
+    /**
+     * Add new connected node for permanent statistics collecting process
+     *
+     * @param flowNode
+     * @param statTypes
+     * @param nrOfSwitchTables
+     * @return true/false if the {@link Node} added successful
+     */
+    boolean connectedNodeRegistration(InstanceIdentifier<Node> nodeIdent,
+            List<StatCapabTypes> statTypes, Short nrOfSwitchTables);
+
+    /**
+     * All disconnected Nodes need be removed from stat list Nodes
+     * @param flowNode
+     * @return true/false if the {@link Node} removed successful
+     */
+    boolean disconnectedNodeUnregistration(InstanceIdentifier<Node> nodeIdent);
+
+    /**
+     * Method return true only and only if {@link StatPermCollector} contain
+     * valid node registration in its internal {@link Node} map.
+     * Otherwise return false.
+     *
+     * @param InstanceIdentifier<FlowCapableNode> flowNode
+     * @return
+     */
+    boolean isProvidedFlowNodeActive(InstanceIdentifier<Node> nodeIdent);
+
+    /**
+     * Object notification for continue statistics collecting process.
+     * It is call from collecting allStatistics methods as a future result for
+     * Operational/DS statistic store call (does not matter in the outcome).
+     */
+    void collectNextStatistics();
+
+    /**
+     * Method returns true if collector has registered some active nodes
+     * otherwise return false.
+     *
+     * @return
+     */
+    boolean hasActiveNodes();
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatRpcMsgManager.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatRpcMsgManager.java
new file mode 100644 (file)
index 0000000..0576c2a
--- /dev/null
@@ -0,0 +1,191 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.base.Optional;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager
+ *
+ * StatRpcMsgManager
+ * It represent access point for Device statistics RPC services which are
+ * filtered for needed methods only and they are wrapped in simply way.
+ * Many statistics responses are Multipart messages, so StatRpcMsgManager
+ * provide a functionality to add all multipart msg and provides back whole
+ * stack to listener when listener catch the last Multipart msg.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 29, 2014
+ */
+public interface StatRpcMsgManager extends Runnable, AutoCloseable {
+
+    interface RpcJobsQueue extends Callable<Void> {}
+
+    /**
+     * Transaction container is definition for Multipart transaction
+     * join container for all Multipart msg with same TransactionId
+     * Input {@link DataObject} is a possible light-weight DataObject
+     * which is used for identification (e.g. Flow-> Priority,Match,Cookie,FlowId)
+     *
+     * @param <T> extends TransactionAware -
+     */
+    interface TransactionCacheContainer<T extends TransactionAware> {
+
+        void addNotif(T notification);
+
+        TransactionId getId();
+
+        NodeId getNodeId();
+
+        Optional<? extends DataObject> getConfInput();
+
+        List<T> getNotifications();
+    }
+
+    /**
+     * Method is used for check a transaction registration
+     * for multipart cache holder
+     *
+     * @param TransactionId id
+     * @return true if the transaction has been correctly registered
+     */
+    Future<Boolean> isExpectedStatistics(TransactionId id, NodeId nodeId);
+
+    /**
+     * Method converts {@link java.util.concurrent.Future} object to listenenable future which
+     * is registered for Multipart Notification Statistics Collecting processing.
+     *
+     * @param future - result every Device RPC call
+     */
+    <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(Future<RpcResult<T>> future, D inputObj, NodeRef ref);
+
+    /**
+     * Method adds Notification which is marked as Multipart to the transaction cash
+     * to wait for the last one.
+     *
+     * @param notification
+     */
+    <T extends TransactionAware> void addNotification(T notification, NodeId nodeId);
+
+    /**
+     * The last Multipart should inform code about possibility to take all previous
+     * messages for next processing. The method take all msg and possible input object
+     * and build all to TransactionCacheContainer Object to return. This process clean
+     * all instances in Cache.
+     *
+     * @param TransactionId id
+     * @return TransactionCacheContainer
+     */
+    Future<Optional<TransactionCacheContainer<?>>> getTransactionCacheContainer(TransactionId id, NodeId nodeId);
+
+    /**
+     * Method wraps OpendaylightGroupStatisticsService.getAllGroupStatistics
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllGroupsStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightGroupStatisticsService.getGroupDescription
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllGroupsConfStats(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightMeterStatisticsService.getGroupFeatures
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getGroupFeaturesStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightMeterStatisticsService.getAllMeterStatistics
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllMetersStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightMeterStatisticsService.getAllMeterConfigStatistics
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllMeterConfigStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightMeterStatisticsService.getMeterFeatures
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getMeterFeaturesStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightFlowStatisticsService.getAllFlowsStatisticsFromAllFlowTables
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllFlowsStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightFlowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     * @param TableId tableId
+     */
+    void getAggregateFlowStat(NodeRef nodeRef, TableId tableId);
+
+    /**
+     * Method wraps OpendaylightPortStatisticsService.getAllNodeConnectorsStatistics
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllPortsStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightFlowTableStatisticsService.getFlowTablesStatistics
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllTablesStat(NodeRef nodeRef);
+
+    /**
+     * Method wraps OpendaylightQueueStatisticsService.getAllQueuesStatisticsFromAllPorts
+     * and registers to Transaction Cache
+     *
+     * @param NodeRef nodeRef
+     */
+    void getAllQueueStat(NodeRef nodeRef);
+
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsListener.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsListener.java
deleted file mode 100644 (file)
index a06f7ef..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class is responsible for listening for statistics update notifications and
- * routing them to the appropriate NodeStatisticsHandler.
-
- * TODO: Need to add error message listener and clean-up the associated tx id
- * if it exists in the tx-id cache.
- * @author vishnoianil
- */
-public class StatisticsListener implements OpendaylightGroupStatisticsListener,
-        OpendaylightMeterStatisticsListener,
-        OpendaylightFlowStatisticsListener,
-        OpendaylightPortStatisticsListener,
-        OpendaylightFlowTableStatisticsListener,
-        OpendaylightQueueStatisticsListener{
-
-    private final static Logger sucLogger = LoggerFactory.getLogger(StatisticsListener.class);
-    private final StatisticsProvider statisticsManager;
-
-    /**
-     * default ctor
-     * @param manager
-     */
-    public StatisticsListener(final StatisticsProvider manager){
-        this.statisticsManager = manager;
-    }
-
-    @Override
-    public void onMeterConfigStatsUpdated(final MeterConfigStatsUpdated notification) {
-        final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateMeterConfigStats(notification, notification.getMeterConfigStats());
-        }
-    }
-
-    @Override
-    public void onMeterStatisticsUpdated(MeterStatisticsUpdated notification) {
-        final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateMeterStats(notification, notification.getMeterStats());
-        }
-    }
-
-    @Override
-    public void onGroupDescStatsUpdated(GroupDescStatsUpdated notification) {
-        final NodeStatisticsHandler handler = statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateGroupDescStats(notification, notification.getGroupDescStats());
-        }
-    }
-
-    @Override
-    public void onGroupStatisticsUpdated(GroupStatisticsUpdated notification) {
-        final NodeStatisticsHandler handler = statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateGroupStats(notification, notification.getGroupStats());
-        }
-    }
-
-    @Override
-    public void onMeterFeaturesUpdated(MeterFeaturesUpdated notification) {
-        final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (sna != null) {
-            sna.updateMeterFeatures(notification);
-        }
-    }
-
-    @Override
-    public void onGroupFeaturesUpdated(GroupFeaturesUpdated notification) {
-        final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (sna != null) {
-            sna.updateGroupFeatures(notification);
-        }
-    }
-
-    @Override
-    public void onFlowsStatisticsUpdate(final FlowsStatisticsUpdate notification) {
-        sucLogger.debug("Received flow stats update : {}",notification.toString());
-        final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (sna != null) {
-            sna.updateFlowStats(notification, notification.getFlowAndStatisticsMapList());
-        }
-    }
-
-    @Override
-    public void onAggregateFlowStatisticsUpdate(AggregateFlowStatisticsUpdate notification) {
-        final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateAggregateFlowStats(notification, notification);
-        }
-    }
-
-    @Override
-    public void onNodeConnectorStatisticsUpdate(NodeConnectorStatisticsUpdate notification) {
-        final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateNodeConnectorStats(notification, notification.getNodeConnectorStatisticsAndPortNumberMap());
-        }
-    }
-
-    @Override
-    public void onFlowTableStatisticsUpdate(FlowTableStatisticsUpdate notification) {
-        final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateFlowTableStats(notification, notification.getFlowTableAndStatisticsMap());
-        }
-    }
-
-    @Override
-    public void onQueueStatisticsUpdate(QueueStatisticsUpdate notification) {
-        final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
-        if (handler != null) {
-            handler.updateQueueStats(notification, notification.getQueueIdAndStatisticsMap());
-        }
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManager.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManager.java
new file mode 100644 (file)
index 0000000..b53c54e
--- /dev/null
@@ -0,0 +1,179 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.statistics.manager.StatPermCollector.StatCapabTypes;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager
+ *
+ * StatisticsManager
+ * It represent a central point for whole module. Implementation
+ * StatisticsManager registers all Operation/DS {@link StatNotifyCommiter} and
+ * Config/DS {@StatListeningCommiter}, as well as {@link StatPermCollector}
+ * for statistic collecting and {@link StatRpcMsgManager} as Device RPCs provider.
+ * In next, StatisticsManager provides all DS contact Transaction services.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 27, 2014
+ */
+public interface StatisticsManager extends AutoCloseable, TransactionChainListener {
+
+    /**
+     * StatDataStoreOperation
+     * Interface represent functionality to submit changes to DataStore.
+     * Internal {@link TransactionChainListener} joining all DS commits
+     * to Set of chained changes for prevent often DataStore touches.
+     */
+    public interface StatDataStoreOperation {
+
+        /**
+         * Apply all read / write (put|merge) operation
+         * for DataStore
+         * @param {@link ReadWriteTransaction} tx
+         */
+        void applyOperation(ReadWriteTransaction tx);
+
+    }
+
+    /**
+     * Method starts whole StatisticManager functionality
+     *
+     * @param {@link NotificationProviderService} notifService
+     * @param {@link RpcConsumerRegistry} rpcRegistry
+     * @param minReqNetMonitInt
+     */
+    void start(final NotificationProviderService notifService,
+            final RpcConsumerRegistry rpcRegistry, final long minReqNetMonitInt);
+
+    /**
+     * Method provides read/write DataStore functionality cross applyOperation
+     * defined in {@link StatDataStoreOperation}
+     *
+     * @param inventoryOper - operation for DataStore
+     */
+    void enqueue(final StatDataStoreOperation inventoryOper);
+
+    /**
+     * Method wraps {@link StatisticCollector}.isProvidedFlowNodeActive method
+     * to provide parallel statCollection process for Set of Nodes. So it has to
+     * identify correct Node Set by NodeIdentifier
+     *
+     * @param nodeIdent
+     */
+     boolean isProvidedFlowNodeActive(InstanceIdentifier<Node> nodeIdent);
+
+     /**
+      * Method wraps {@link StatPermCollector}.collectNextStatistics to provide
+      * parallel statCollection process for Set of Nodes. So it has to
+      * identify correct Node Set by NodeIdentifier.
+      *
+      * @param nodeIdent
+      */
+     void collectNextStatistics(InstanceIdentifier<Node> nodeIdent);
+
+     /**
+      * Method wraps {@link StatPermCollector}.connectedNodeRegistration to provide
+      * parallel statCollection process for Set of Nodes. So it has to
+      * connect node to new or not full Node statCollector Set.
+      *
+      * @param nodeIdent
+      * @param statTypes
+      * @param nrOfSwitchTables
+      */
+     void connectedNodeRegistration(InstanceIdentifier<Node> nodeIdent,
+             List<StatCapabTypes> statTypes, Short nrOfSwitchTables);
+
+     /**
+      * Method wraps {@link StatPermCollector}.disconnectedNodeUnregistration to provide
+      * parallel statCollection process for Set of Nodes. So it has to identify
+      * correct collector for disconnect node.
+      *
+      * @param nodeIdent
+      */
+     void disconnectedNodeUnregistration(InstanceIdentifier<Node> nodeIdent);
+
+    /**
+     * Method provides access to Device RPC methods by wrapped
+     * internal method. In next {@link StatRpcMsgManager} is registered all
+     * Multipart device msg response and joining all to be able run all
+     * collected statistics in one time (easy identification Data for delete)
+     *
+     * @return {@link StatRpcMsgManager}
+     */
+    StatRpcMsgManager getRpcMsgManager();
+
+    /**
+     * Define Method : {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}
+     * Operational/DS data change listener -> impl. target -> register FlowCapableNode to Statistic Collecting process
+     * @return {@link StatNodeRegistration}
+     */
+    StatNodeRegistration getNodeRegistrator();
+
+    /**
+     * Define Method : Flow Config/DS data change listener -> impl. target ->
+     * -> make pair between Config/DS FlowId and Device Flow response Hash
+     * @return
+     */
+    StatListeningCommiter<Flow, OpendaylightFlowStatisticsListener> getFlowListenComit();
+
+    /**
+     * Define Method : Meter Config/DS data change listener and Operation/DS notify commit
+     * functionality
+     * @return
+     */
+    StatListeningCommiter<Meter, OpendaylightMeterStatisticsListener> getMeterListenCommit();
+
+    /**
+     * Define Method : Group Config/DS data change listener and Operation/DS notify commit
+     * functionality
+     * @return
+     */
+    StatListeningCommiter<Group, OpendaylightGroupStatisticsListener> getGroupListenCommit();
+
+    /**
+     * Define Method : Queue Config/DS change listener and Operation/DS notify commit functionality
+     * @return
+     */
+    StatListeningCommiter<Queue, OpendaylightQueueStatisticsListener> getQueueNotifyCommit();
+
+    /**
+     * Define Method : Table Operation/DS notify commit functionality
+     * @return
+     */
+    StatNotifyCommiter<OpendaylightFlowTableStatisticsListener> getTableNotifCommit();
+
+    /**
+     * Define Method : Port Operation/DS notify commit functionality
+     * @return
+     */
+    StatNotifyCommiter<OpendaylightPortStatisticsListener> getPortNotifyCommit();
+
+}
+
index 5bcbef119a8c332442d405681dd018dc1368c9c7..c505af49e6d20ec38023aee94c1361feb0a6dc0d 100644 (file)
@@ -8,29 +8,66 @@
 
 package org.opendaylight.controller.md.statistics.manager;
 
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.statistics.manager.impl.StatisticsManagerImpl;
 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * Statistics Manager Activator
+ *
+ * OSGi bundle activator
+ *
+ */
 public class StatisticsManagerActivator extends AbstractBindingAwareProvider {
-    private StatisticsProvider statsProvider;
+
+    private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerActivator.class);
+
+    /* TODO move it to ConfigSubsystem */
+    private static final long DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL = 3000L;
+    private static final int MAX_NODES_FOR_COLLECTOR = 16;
+
+    private StatisticsManager statsProvider;
 
     @Override
-    public void onSessionInitiated(ProviderContext session) {
-        final DataProviderService dps = session.getSALService(DataProviderService.class);
-        final NotificationProviderService nps = session.getSALService(NotificationProviderService.class);
+    public void onSessionInitiated(final ProviderContext session) {
+        LOG.info("StatisticsManagerActivator initialization.");
+        try {
+            final DataBroker dataBroker = session.getSALService(DataBroker.class);
+            final NotificationProviderService notifService =
+                    session.getSALService(NotificationProviderService.class);
+            statsProvider = new StatisticsManagerImpl(dataBroker, MAX_NODES_FOR_COLLECTOR);
+            statsProvider.start(notifService, session, DEFAULT_MIN_REQUEST_NET_MONITOR_INTERVAL);
+            LOG.info("StatisticsManagerActivator started successfully.");
+        }
+        catch (final Exception e) {
+            LOG.error("Unexpected error by initialization of StatisticsManagerActivator", e);
+            stopImpl(null);
+        }
+    }
 
-        statsProvider = new StatisticsProvider(dps);
-        statsProvider.start(nps, session);
+    @VisibleForTesting
+    StatisticsManager getStatisticManager() {
+        return statsProvider;
     }
 
     @Override
-    protected void stopImpl(BundleContext context) {
+    protected void stopImpl(final BundleContext context) {
         if (statsProvider != null) {
-            statsProvider.close();
+            try {
+                statsProvider.close();
+            }
+            catch (final Exception e) {
+                LOG.error("Unexpected error by stopping StatisticsManagerActivator", e);
+            }
             statsProvider = null;
         }
+        LOG.info("StatisticsManagerActivator stoped.");
     }
 }
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java
deleted file mode 100644 (file)
index 8c9b60e..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.Collection;
-import java.util.Timer;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Following are main responsibilities of the class:
- * 1) Invoke statistics request thread to send periodic statistics request to all the
- * flow capable switch connected to the controller. It sends statistics request for
- * Group,Meter,Table,Flow,Queue,Aggregate stats.
- *
- * 2) Invoke statistics ager thread, to clean up all the stale statistics data from
- * operational data store.
- *
- * @author avishnoi@in.ibm.com
- *
- */
-public class StatisticsProvider implements AutoCloseable {
-    private static final Logger spLogger = LoggerFactory.getLogger(StatisticsProvider.class);
-
-    private final ConcurrentMap<NodeId, NodeStatisticsHandler> handlers = new ConcurrentHashMap<>();
-    private final Timer timer = new Timer("statistics-manager", true);
-    private final DataProviderService dps;
-
-    private OpendaylightGroupStatisticsService groupStatsService;
-
-    private OpendaylightMeterStatisticsService meterStatsService;
-
-    private OpendaylightFlowStatisticsService flowStatsService;
-
-    private OpendaylightPortStatisticsService portStatsService;
-
-    private OpendaylightFlowTableStatisticsService flowTableStatsService;
-
-    private OpendaylightQueueStatisticsService queueStatsService;
-
-    private final StatisticsRequestScheduler srScheduler;
-
-    public StatisticsProvider(final DataProviderService dataService) {
-        this.dps = Preconditions.checkNotNull(dataService);
-        this.srScheduler = new StatisticsRequestScheduler();
-    }
-
-    private final StatisticsListener updateCommiter = new StatisticsListener(StatisticsProvider.this);
-
-    private ListenerRegistration<NotificationListener> listenerRegistration;
-
-    private ListenerRegistration<DataChangeListener> flowCapableTrackerRegistration;
-
-    public void start(final NotificationProviderService nps, final RpcConsumerRegistry rpcRegistry) {
-
-        // Get Group/Meter statistics service instances
-        groupStatsService = rpcRegistry.getRpcService(OpendaylightGroupStatisticsService.class);
-        meterStatsService = rpcRegistry.getRpcService(OpendaylightMeterStatisticsService.class);
-        flowStatsService = rpcRegistry.getRpcService(OpendaylightFlowStatisticsService.class);
-        portStatsService = rpcRegistry.getRpcService(OpendaylightPortStatisticsService.class);
-        flowTableStatsService = rpcRegistry.getRpcService(OpendaylightFlowTableStatisticsService.class);
-        queueStatsService = rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class);
-        this.srScheduler.start();
-
-        // Start receiving notifications
-        this.listenerRegistration = nps.registerNotificationListener(this.updateCommiter);
-
-        // Register for switch connect/disconnect notifications
-        final InstanceIdentifier<FlowCapableNode> fcnId = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class).augmentation(FlowCapableNode.class).build();
-        spLogger.debug("Registering FlowCapable tracker to {}", fcnId);
-        this.flowCapableTrackerRegistration = dps.registerDataChangeListener(fcnId,
-                new FlowCapableTracker(this, fcnId));
-
-        spLogger.info("Statistics Provider started.");
-    }
-
-    /**
-     * Get the handler for a particular node.
-     *
-     * @param nodeId source node
-     * @return Node statistics handler for that node. Null if the statistics should
-     *         not handled.
-     */
-    public final NodeStatisticsHandler getStatisticsHandler(final NodeId nodeId) {
-        Preconditions.checkNotNull(nodeId);
-        NodeStatisticsHandler handler = handlers.get(nodeId);
-        if (handler == null) {
-            spLogger.info("Attempted to get non-existing handler for {}", nodeId);
-        }
-        return handler;
-    }
-
-    @Override
-    public void close() {
-        try {
-            if (this.listenerRegistration != null) {
-                this.listenerRegistration.close();
-                this.listenerRegistration = null;
-            }
-            if (this.flowCapableTrackerRegistration != null) {
-                this.flowCapableTrackerRegistration.close();
-                this.flowCapableTrackerRegistration = null;
-            }
-            timer.cancel();
-        } catch (Exception e) {
-            spLogger.warn("Failed to stop Statistics Provider completely", e);
-        } finally {
-            spLogger.info("Statistics Provider stopped.");
-        }
-    }
-
-    void startNodeHandlers(final Collection<NodeKey> addedNodes) {
-        for (NodeKey key : addedNodes) {
-            if (handlers.containsKey(key.getId())) {
-                spLogger.warn("Attempted to start already-existing handler for {}, very strange", key.getId());
-                continue;
-            }
-
-            final NodeStatisticsHandler h = new NodeStatisticsHandler(dps, key,
-                    flowStatsService, flowTableStatsService, groupStatsService,
-                    meterStatsService, portStatsService, queueStatsService,srScheduler);
-            final NodeStatisticsHandler old = handlers.putIfAbsent(key.getId(), h);
-            if (old == null) {
-                spLogger.debug("Started node handler for {}", key.getId());
-                h.start(timer);
-            } else {
-                spLogger.debug("Prevented race on handler for {}", key.getId());
-            }
-        }
-    }
-
-    void stopNodeHandlers(final Collection<NodeKey> removedNodes) {
-        for (NodeKey key : removedNodes) {
-            final NodeStatisticsHandler s = handlers.remove(key.getId());
-            if (s != null) {
-                spLogger.debug("Stopping node handler for {}", key.getId());
-                s.close();
-            } else {
-                spLogger.warn("Attempted to remove non-existing handler for {}, very strange", key.getId());
-            }
-        }
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java
deleted file mode 100644 (file)
index 29a27e2..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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.statistics.manager;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.TimeUnit;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction.DataTransactionListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Main responsibility of the class is to check the MD-SAL data store read/write
- * transaction accumulation level and send statistics request if number of pending
- * read/write transactions are zero.
- * @author avishnoi@in.ibm.com
- *
- */
-@SuppressWarnings("rawtypes")
-public class StatisticsRequestScheduler implements DataTransactionListener {
-
-    private static final Logger srsLogger = LoggerFactory.getLogger(StatisticsRequestScheduler.class);
-    private final Timer timer = new Timer("request-monitor", true);
-
-    // We need ordered retrieval, and O(1) contains operation
-    private final Map<AbstractStatsTracker,Integer> requestQueue =
-            Collections.synchronizedMap(new LinkedHashMap<AbstractStatsTracker,Integer>());
-
-    private Long PendingTransactions;
-
-    private long lastRequestTime = System.nanoTime();
-
-    private static final long REQUEST_MONITOR_INTERVAL = 1000;
-
-    private final TimerTask task = new TimerTask() {
-        @Override
-        public void run() {
-            try{
-                long now = System.nanoTime();
-                if(now > lastRequestTime+TimeUnit.MILLISECONDS.toNanos(REQUEST_MONITOR_INTERVAL)){
-                    requestStatistics();
-                }
-            }catch (IllegalArgumentException | IllegalStateException | NullPointerException e){
-                srsLogger.warn("Exception occured while sending statistics request : {}",e);
-            }
-        }
-    };
-
-    public StatisticsRequestScheduler(){
-        PendingTransactions = (long) 0;
-    }
-
-    public void addRequestToSchedulerQueue(AbstractStatsTracker statsRequest){
-        requestQueue.put(statsRequest, null);
-    }
-
-    public void removeRequestsFromSchedulerQueue(NodeRef node){
-        AbstractStatsTracker stats = null;
-        synchronized(requestQueue){
-            Iterator<Map.Entry<AbstractStatsTracker, Integer>> nodesItr = requestQueue.entrySet().iterator();
-            while(nodesItr.hasNext()){
-                stats = nodesItr.next().getKey();
-                if(stats.getNodeRef().equals(node)){
-                    nodesItr.remove();
-                }
-            }
-        }
-
-    }
-    public AbstractStatsTracker getNextRequestFromSchedulerQueue(){
-        //Remove first element
-        AbstractStatsTracker stats = null;
-        synchronized(requestQueue){
-            Iterator<Map.Entry<AbstractStatsTracker, Integer>> nodesItr = requestQueue.entrySet().iterator();
-            if(nodesItr.hasNext()){
-                stats = nodesItr.next().getKey();
-                srsLogger.debug("{} chosen up for execution",stats.getNodeRef());
-                nodesItr.remove();
-                return stats;
-            }
-        }
-        return stats;
-    }
-
-    private void requestStatistics(){
-        AbstractStatsTracker stats = this.getNextRequestFromSchedulerQueue();
-        sendStatsRequest(stats);
-    }
-    @Override
-    public void onStatusUpdated(DataModificationTransaction transaction, TransactionStatus status) {
-
-        AbstractStatsTracker stats = null;
-        synchronized(PendingTransactions){
-            switch(status){
-            case SUBMITED:
-                this.PendingTransactions++;
-                break;
-            case COMMITED:
-            case FAILED:
-                this.PendingTransactions--;
-                if(PendingTransactions == 0){
-                    lastRequestTime = System.nanoTime();
-                    stats = this.getNextRequestFromSchedulerQueue();
-                }
-                srsLogger.debug("Pending MD-SAL transactions : {} & Scheduler queue size : {}",this.PendingTransactions,this.requestQueue.size());
-                break;
-            default:
-                break;
-            }
-        }
-        sendStatsRequest(stats);
-    }
-
-    private void sendStatsRequest(AbstractStatsTracker stats){
-        if(stats != null){
-            try{
-                stats.request();
-                stats.increaseRequestCounter();
-            }catch(Exception e){
-                srsLogger.warn("Statistics request was not sent successfully. Reason : {}",e.getMessage());
-            }
-        }
-    }
-    public void start(){
-        timer.schedule(task, 0, REQUEST_MONITOR_INTERVAL);
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatAbstractListenCommit.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatAbstractListenCommit.java
new file mode 100644 (file)
index 0000000..6db73d5
--- /dev/null
@@ -0,0 +1,139 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatListeningCommiter;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatAbstractListeneningCommiter
+ * Class is abstract implementation for all Configuration/DataStore DataChange
+ * listenable DataObjects like flows, groups, meters. It is a holder for common
+ * functionality needed by construction/destruction class and for DataChange
+ * event processing.
+ *
+ */
+public abstract class StatAbstractListenCommit<T extends DataObject, N extends NotificationListener>
+                                            extends StatAbstractNotifyCommit<N> implements StatListeningCommiter<T,N> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StatAbstractListenCommit.class);
+
+    private ListenerRegistration<DataChangeListener> listenerRegistration;
+
+    protected final Map<InstanceIdentifier<Node>, Map<InstanceIdentifier<T>, Integer>> mapNodesForDelete = new ConcurrentHashMap<>();
+
+    private final Class<T> clazz;
+
+    private final DataBroker dataBroker;
+
+    private volatile ReadOnlyTransaction currentReadTx;
+
+    /* Constructor has to make a registration */
+    public StatAbstractListenCommit(final StatisticsManager manager, final DataBroker db,
+            final NotificationProviderService nps, final Class<T> clazz) {
+        super(manager,nps);
+        this.clazz = Preconditions.checkNotNull(clazz, "Referenced Class can not be null");
+        Preconditions.checkArgument(db != null, "DataBroker can not be null!");
+        listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+                getWildCardedRegistrationPath(), this, DataChangeScope.BASE);
+        this.dataBroker = db;
+    }
+
+    /**
+     * Method returns WildCarded Path which is used for registration as a listening path changes in
+     * {@link org.opendaylight.controller.md.sal.binding.api.DataChangeListener}
+     * @return
+     */
+    protected abstract InstanceIdentifier<T> getWildCardedRegistrationPath();
+
+    @Override
+    public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+        Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
+        /*
+         * If we have opened read transaction for configuraiton data store,
+         * we will close and null it.
+         *
+         * Latest read transaction will be allocated on another read using readLatestConfiguration
+         */
+        if(currentReadTx != null) {
+            final ReadOnlyTransaction previous = currentReadTx;
+            currentReadTx = null;
+            previous.close();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void removeData(final InstanceIdentifier<?> key, final Integer value) {
+        if (clazz.equals(key.getTargetType())) {
+            final InstanceIdentifier<Node> nodeIdent = key.firstIdentifierOf(Node.class);
+            Map<InstanceIdentifier<T>, Integer> map = null;
+            if (mapNodesForDelete.containsKey(nodeIdent)) {
+                map = mapNodesForDelete.get(nodeIdent);
+            }
+            if (map == null) {
+                map = new ConcurrentHashMap<>();
+                mapNodesForDelete.put(nodeIdent, map);
+            }
+            map.put((InstanceIdentifier<T>) key, value);
+        }
+    }
+
+    @Override
+    public void cleanForDisconnect(final InstanceIdentifier<Node> nodeIdent) {
+        mapNodesForDelete.remove(nodeIdent);
+    }
+
+    @Override
+    public void close() {
+        if (listenerRegistration != null) {
+            try {
+                listenerRegistration.close();
+            } catch (final Exception e) {
+                LOG.error("Error by stop {} DataChange StatListeningCommiter.", clazz.getSimpleName(), e);
+            }
+            listenerRegistration = null;
+        }
+    }
+
+    protected final <K extends DataObject> Optional<K> readLatestConfiguration(final InstanceIdentifier<K> path) {
+        if(currentReadTx == null) {
+             currentReadTx = dataBroker.newReadOnlyTransaction();
+        }
+        try {
+            return currentReadTx.read(LogicalDatastoreType.CONFIGURATION, path).checkedGet();
+        } catch (final ReadFailedException e) {
+            return Optional.absent();
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatAbstractNotifyCommit.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatAbstractNotifyCommit.java
new file mode 100644 (file)
index 0000000..08871e9
--- /dev/null
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.opendaylight.controller.md.statistics.manager.StatNotifyCommiter;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatAbstratNotifiCommiter
+ * Class is abstract implementation for all no Configuration/DataStore DataObjects
+ * and represent common functionality for all DataObject Statistics Commiters.
+ * Class defines contract between DataObject and relevant Statistics NotificationListener.
+ *
+ */
+public abstract class StatAbstractNotifyCommit<N extends NotificationListener> implements StatNotifyCommiter<N> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StatAbstractNotifyCommit.class);
+
+    protected final StatisticsManager manager;
+    private ListenerRegistration<NotificationListener> notifyListenerRegistration;
+
+    public StatAbstractNotifyCommit(final StatisticsManager manager,
+            final NotificationProviderService nps) {
+        Preconditions.checkArgument(nps != null, "NotificationProviderService can not be null!");
+        this.manager = Preconditions.checkNotNull(manager, "StatisticManager can not be null!");
+        notifyListenerRegistration = nps.registerNotificationListener(getStatNotificationListener());
+    }
+
+    @Override
+    public void close() {
+        if (notifyListenerRegistration != null) {
+            try {
+                notifyListenerRegistration.close();
+            }
+            catch (final Exception e) {
+                LOG.error("Error by stop {} StatNotificationListener.", this.getClass().getSimpleName());
+            }
+            notifyListenerRegistration = null;
+        }
+    }
+
+    /**
+     * Method returns Statistics Notification Listener for relevant DataObject implementation,
+     * which is declared for {@link StatNotifyCommiter} interface.
+     *
+     * @return
+     */
+    protected abstract N getStatNotificationListener();
+
+    /**
+     * PreConfigurationCheck - Node identified by input InstanceIdentifier<Node>
+     * has to be registered in {@link org.opendaylight.controller.md.statistics.manager.StatPermCollector}
+     *
+     * @param InstanceIdentifier<Node> nodeIdent
+     */
+    protected boolean preConfigurationCheck(final InstanceIdentifier<Node> nodeIdent) {
+        Preconditions.checkNotNull(nodeIdent, "FlowCapableNode ident can not be null!");
+        return manager.isProvidedFlowNodeActive(nodeIdent);
+    }
+
+    protected void notifyToCollectNextStatistics(final InstanceIdentifier<Node> nodeIdent) {
+        Preconditions.checkNotNull(nodeIdent, "FlowCapableNode ident can not be null!");
+        manager.collectNextStatistics(nodeIdent);
+    }
+
+    /**
+     * Wrapping Future object call for {@link org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager}
+     * getTransactionCacheContainer with 10sec TimeOut.
+     * Method has returned {@link Optional} which could contains a {@link TransactionCacheContainer}
+     *
+     * @param TransactionId transId
+     * @param NodeId nodeId
+     * @return
+     */
+    protected Optional<TransactionCacheContainer<?>> getTransactionCacheContainer(final TransactionId transId, final NodeId nodeId) {
+        Optional<TransactionCacheContainer<?>> txContainer;
+        try {
+            txContainer = manager.getRpcMsgManager().getTransactionCacheContainer(transId, nodeId).get(10, TimeUnit.SECONDS);
+        }
+        catch (InterruptedException | ExecutionException | TimeoutException e) {
+            LOG.warn("Get TransactionCacheContainer fail!", e);
+            txContainer = Optional.absent();
+        }
+        return txContainer;
+    }
+
+    /**
+     * Wrapping Future object call to {@link org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager}
+     * isExpectedStatistics with 10sec TimeOut.
+     * Method has checked registration for provided {@link TransactionId} and {@link NodeId}
+     *
+     * @param TransactionId transId - Transaction identification
+     * @param NodeId nodeId - Node identification
+     * @return boolean
+     */
+    protected boolean isExpectedStatistics(final TransactionId transId, final NodeId nodeId) {
+        Boolean isExpectedStat = Boolean.FALSE;
+        try {
+            isExpectedStat = manager.getRpcMsgManager().isExpectedStatistics(transId, nodeId).get(10, TimeUnit.SECONDS);
+        }
+        catch (InterruptedException | ExecutionException | TimeoutException e) {
+            LOG.warn("Check Transaction registraion {} fail!", transId, e);
+            return false;
+        }
+        return isExpectedStat.booleanValue();
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitFlow.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitFlow.java
new file mode 100644 (file)
index 0000000..2304259
--- /dev/null
@@ -0,0 +1,471 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.md.statistics.manager.impl.helper.FlowComparator;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowHashIdMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowHashIdMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.aggregate.flow.statistics.AggregateFlowStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatListenCommitFlow
+ * Class is a NotifyListener for FlowStatistics and DataChangeListener for Config/DataStore for Flow node.
+ * All expected (registered) FlowStatistics will be builded and commit to Operational/DataStore.
+ * DataChangeEven should call create/delete Flow in Operational/DS create process needs to pair
+ * Device Flow HashCode and FlowId from Config/DS
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatListenCommitFlow extends StatAbstractListenCommit<Flow, OpendaylightFlowStatisticsListener>
+                                            implements OpendaylightFlowStatisticsListener {
+
+    protected static final Logger LOG = LoggerFactory.getLogger(StatListenCommitFlow.class);
+
+    private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
+
+    private static final Integer REMOVE_AFTER_MISSING_COLLECTION = 1;
+
+    private final AtomicInteger unaccountedFlowsCounter = new AtomicInteger(0);
+
+    public StatListenCommitFlow (final StatisticsManager manager, final DataBroker db,
+            final NotificationProviderService nps){
+        super(manager, db, nps, Flow.class);
+    }
+
+    @Override
+    protected OpendaylightFlowStatisticsListener getStatNotificationListener() {
+        return this;
+    }
+
+    @Override
+    protected InstanceIdentifier<Flow> getWildCardedRegistrationPath() {
+        return InstanceIdentifier.create(Nodes.class).child(Node.class)
+                .augmentation(FlowCapableNode.class).child(Table.class).child(Flow.class);
+    }
+
+    @Override
+    public void onAggregateFlowStatisticsUpdate(final AggregateFlowStatisticsUpdate notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - AggregateFlowStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        manager.getRpcMsgManager().addNotification(notification, nodeId);
+        if (notification.isMoreReplies()) {
+            return;
+        }
+        /* check flow Capable Node and write statistics */
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+
+                final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+                if (( ! txContainer.isPresent()) || txContainer.get().getNotifications() == null) {
+                    return;
+                }
+                final Optional<? extends DataObject> inputObj = txContainer.get().getConfInput();
+                if (( ! inputObj.isPresent()) || ( ! (inputObj.get() instanceof Table))) {
+                    return;
+                }
+                final Table table = (Table) inputObj.get();
+                final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
+                for (final TransactionAware notif : cacheNotifs) {
+                    if (notif instanceof AggregateFlowStatisticsUpdate) {
+                        final AggregateFlowStatisticsData stats = new AggregateFlowStatisticsDataBuilder()
+                            .setAggregateFlowStatistics(new AggregateFlowStatisticsBuilder(notification).build()).build();
+                        final InstanceIdentifier<FlowCapableNode> fNodeIdent = InstanceIdentifier.create(Nodes.class)
+                                .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
+                        final InstanceIdentifier<Table> tableRef = fNodeIdent.child(Table.class, table.getKey());
+                        final InstanceIdentifier<AggregateFlowStatisticsData> tableStatRef = tableRef
+                                .augmentation(AggregateFlowStatisticsData.class);
+                        Optional<FlowCapableNode> fNode = Optional.absent();
+                        try {
+                            fNode = tx.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
+                        } catch (final ReadFailedException e) {
+                            LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
+                            return;
+                        }
+                        if (fNode.isPresent()) {
+                            ensureTable(tx, table.getId(), tableRef);
+                            tx.put(LogicalDatastoreType.OPERATIONAL, tableStatRef, stats);
+                        }
+                    }
+                }
+            }
+        });
+    }
+
+    public void ensureTable(final ReadWriteTransaction tx, final Short tableId, final InstanceIdentifier<Table> tableRef) {
+        final Table tableNew = new TableBuilder().setId(tableId).build();
+        tx.merge(LogicalDatastoreType.OPERATIONAL, tableRef, tableNew);
+    }
+
+    @Override
+    public void onFlowsStatisticsUpdate(final FlowsStatisticsUpdate notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - FlowsStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        manager.getRpcMsgManager().addNotification(notification, nodeId);
+        if (notification.isMoreReplies()) {
+            LOG.trace("Next notification for join txId {}", transId);
+            return;
+        }
+        /* add flow's statistics */
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+                if (( ! txContainer.isPresent()) || txContainer.get().getNotifications() == null) {
+                    return;
+                }
+                final List<FlowAndStatisticsMapList> flowStats = new ArrayList<FlowAndStatisticsMapList>(10);
+                final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
+                        .child(Node.class, new NodeKey(nodeId));
+                final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
+                for (final TransactionAware notif : cacheNotifs) {
+                    if (notif instanceof FlowsStatisticsUpdate) {
+                        final List<FlowAndStatisticsMapList> notifList =
+                                ((FlowsStatisticsUpdate) notif).getFlowAndStatisticsMapList();
+                        if (notifList != null) {
+                            flowStats.addAll(notifList);
+                        }
+                    }
+                }
+
+                statsFlowCommitAll(flowStats, nodeIdent, tx);
+                /* cleaning all not cached hash collisions */
+                final Map<InstanceIdentifier<Flow>, Integer> listAliens = mapNodesForDelete.get(nodeIdent);
+                if (listAliens != null) {
+                    for (final Entry<InstanceIdentifier<Flow>, Integer> nodeForDelete : listAliens.entrySet()) {
+                        final Integer lifeIndex = nodeForDelete.getValue();
+                        if (nodeForDelete.getValue() > 0) {
+                            nodeForDelete.setValue(Integer.valueOf(lifeIndex.intValue() - 1));
+                        } else {
+                            final InstanceIdentifier<Flow> flowNodeIdent = nodeForDelete.getKey();
+                            mapNodesForDelete.get(nodeIdent).remove(flowNodeIdent);
+                            tx.delete(LogicalDatastoreType.OPERATIONAL, flowNodeIdent);
+                        }
+                    }
+                }
+                /* Notification for continue collecting statistics */
+                notifyToCollectNextStatistics(nodeIdent);
+            }
+        });
+    }
+
+    private void statsFlowCommitAll(final List<FlowAndStatisticsMapList> list,
+            final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) {
+
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
+
+        final Optional<FlowCapableNode> fNode;
+        try {
+            fNode = tx.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
+        }
+        catch (final ReadFailedException e) {
+            LOG.debug("Read FlowCapableNode {} in Operational/DS fail! Statistic scan not be updated.", nodeIdent, e);
+            return;
+        }
+        if ( ! fNode.isPresent()) {
+            LOG.trace("FlowCapableNode {} is not presented in Operational/DS. Statisticscan not be updated.", nodeIdent);
+            return;
+        }
+
+        final NodeUpdateState nodeState = new NodeUpdateState(fNodeIdent,fNode.get());
+
+        for (final FlowAndStatisticsMapList flowStat : list) {
+            final TableKey tableKey = new TableKey(flowStat.getTableId());
+            final TableFlowUpdateState tableState = nodeState.getTable(tableKey, tx);
+            tableState.reportFlow(flowStat,tx);
+        }
+
+        for (final TableFlowUpdateState table : nodeState.getTables()) {
+            table.removeUnreportedFlows(tx);
+        }
+    }
+
+    /**
+     * Method adds statistics to Flow
+     *
+     * @param flowBuilder
+     * @param deviceFlow
+     */
+    private void addStatistics(final FlowBuilder flowBuilder, final FlowAndStatisticsMapList deviceFlow) {
+        final FlowAndStatisticsMapListBuilder stats = new FlowAndStatisticsMapListBuilder(deviceFlow);
+        final FlowStatisticsBuilder flowStatisticsBuilder = new FlowStatisticsBuilder(stats.build());
+        final FlowStatisticsDataBuilder flowStatisticsData =new FlowStatisticsDataBuilder();
+        flowStatisticsData.setFlowStatistics(flowStatisticsBuilder.build());
+        flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
+    }
+
+    /**
+     * build pseudoUnique hashCode for flow in table
+     * for future easy identification
+     *
+     * FIXME: we expect same version for YANG models for all clusters and that has to be fix
+     * FIXME: CREATE BETTER KEY - for flow (MATCH is the problem)
+     */
+    static String buildFlowIdOperKey(final FlowAndStatisticsMapList deviceFlow) {
+        return new StringBuffer().append(deviceFlow.getMatch())
+                .append(deviceFlow.getPriority()).append(deviceFlow.getCookie().getValue()).toString();
+    }
+
+    private class NodeUpdateState {
+        private final InstanceIdentifier<FlowCapableNode> nodeIdentifier;
+        private final Map<TableKey,TableFlowUpdateState> tables = new HashMap<>();
+
+        public NodeUpdateState(final InstanceIdentifier<FlowCapableNode> fNodeIdent, final FlowCapableNode flowCapableNode) {
+            nodeIdentifier = fNodeIdent;
+            final List<Table> tableList = flowCapableNode.getTable();
+            if(tableList != null) {
+            for (final Table table : tableList) {
+                final TableKey tableKey = table.getKey();
+                    tables.put(tableKey, new TableFlowUpdateState(nodeIdentifier.child(Table.class,tableKey),table));
+                }
+            }
+        }
+
+        public Iterable<TableFlowUpdateState> getTables() {
+            return tables.values();
+        }
+
+        TableFlowUpdateState getTable(final TableKey key,final ReadWriteTransaction tx) {
+            TableFlowUpdateState table = tables.get(key);
+            if(table == null) {
+                table = new TableFlowUpdateState(nodeIdentifier.child(Table.class, key), null);
+                tables.put(key, table);
+            }
+            return table;
+        }
+    }
+
+    private class TableFlowUpdateState {
+
+        private boolean tableEnsured = false;
+        final KeyedInstanceIdentifier<Table, TableKey> tableRef;
+        final TableKey tableKey;
+        final BiMap<FlowHashIdMapKey, FlowId> flowIdByHash;
+        List<Flow> configFlows;
+
+        public TableFlowUpdateState(final KeyedInstanceIdentifier<Table, TableKey> tablePath, final Table table) {
+            tableRef = tablePath;
+            tableKey = tablePath.getKey();
+            flowIdByHash = HashBiMap.create();
+            if(table != null) {
+                final FlowHashIdMapping flowHashMapping = table.getAugmentation(FlowHashIdMapping.class);
+                if (flowHashMapping != null) {
+                    final List<FlowHashIdMap>  flowHashMap = flowHashMapping.getFlowHashIdMap() != null
+                            ? flowHashMapping.getFlowHashIdMap() : Collections.<FlowHashIdMap> emptyList();
+                    for (final FlowHashIdMap flowHashId : flowHashMap) {
+                        try {
+                            flowIdByHash.put(flowHashId.getKey(), flowHashId.getFlowId());
+                        } catch (final Exception e) {
+                            LOG.warn("flow hashing hit a duplicate for {} -> {}", flowHashId.getKey(), flowHashId.getFlowId());
+                        }
+                    }
+                }
+            }
+        }
+
+        private void ensureTableFowHashIdMapping(final ReadWriteTransaction tx) {
+            if( ! tableEnsured) {
+                ensureTable(tx, tableKey.getId(), tableRef);
+                final FlowHashIdMapping emptyMapping = new FlowHashIdMappingBuilder()
+                    .setFlowHashIdMap(Collections.<FlowHashIdMap> emptyList()).build();
+                tx.merge(LogicalDatastoreType.OPERATIONAL, tableRef.augmentation(FlowHashIdMapping.class), emptyMapping);
+                tableEnsured = true;
+            }
+        }
+
+        private FlowKey searchInConfiguration(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) {
+            initConfigFlows(trans);
+            final Iterator<Flow> it = configFlows.iterator();
+            while(it.hasNext()) {
+                final Flow cfgFlow = it.next();
+                final FlowKey cfgKey = cfgFlow.getKey();
+                if(flowIdByHash.inverse().containsKey(cfgKey)) {
+                    it.remove();
+                } else if(FlowComparator.flowEquals(flowStat, cfgFlow)) {
+                    it.remove();
+                    return cfgKey;
+                }
+            }
+            return null;
+        }
+
+        private void initConfigFlows(final ReadWriteTransaction trans) {
+            final Optional<Table> table = readLatestConfiguration(tableRef);
+            List<Flow> localList = null;
+            if(table.isPresent()) {
+                localList = table.get().getFlow();
+            }
+            if(localList == null) {
+                configFlows = Collections.emptyList();
+            } else {
+                configFlows = new LinkedList<>(localList);
+            }
+        }
+
+        private FlowKey getFlowKeyAndRemoveHash(final FlowHashIdMapKey key) {
+            final FlowId ret = flowIdByHash.get(key);
+            if(ret != null) {
+                flowIdByHash.remove(key);
+                return new FlowKey(ret);
+            }
+            return null;
+        }
+
+        /* Returns FlowKey which doesn't exist in any DataStore for now */
+        private FlowKey makeAlienFlowKey() {
+            final StringBuilder sBuilder = new StringBuilder(ALIEN_SYSTEM_FLOW_ID)
+                .append(tableKey.getId()).append("-").append(unaccountedFlowsCounter.incrementAndGet());
+            final FlowId flowId = new FlowId(sBuilder.toString());
+            return new FlowKey(flowId);
+        }
+
+        private Map<FlowHashIdMapKey, FlowId> getRemovalList() {
+            return flowIdByHash;
+        }
+
+        void reportFlow(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) {
+            ensureTableFowHashIdMapping(trans);
+            final FlowHashIdMapKey hashingKey = new FlowHashIdMapKey(buildFlowIdOperKey(flowStat));
+            FlowKey flowKey = getFlowKeyAndRemoveHash(hashingKey);
+            if (flowKey == null) {
+                flowKey = searchInConfiguration(flowStat, trans);
+                if ( flowKey == null) {
+                    flowKey = makeAlienFlowKey();
+                }
+                updateHashCache(trans,flowKey,hashingKey);
+            }
+            final FlowBuilder flowBuilder = new FlowBuilder(flowStat);
+            flowBuilder.setKey(flowKey);
+            addStatistics(flowBuilder, flowStat);
+            final InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, flowKey);
+            trans.put(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
+            /* check life for Alien flows */
+            if (flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) {
+                removeData(flowIdent, REMOVE_AFTER_MISSING_COLLECTION);
+            }
+        }
+
+        /* Build and deploy new FlowHashId map */
+        private void updateHashCache(final ReadWriteTransaction trans, final FlowKey flowKey, final FlowHashIdMapKey hashingKey) {
+            final FlowHashIdMapBuilder flHashIdMap = new FlowHashIdMapBuilder();
+            flHashIdMap.setFlowId(flowKey.getId());
+            flHashIdMap.setKey(hashingKey);
+            final KeyedInstanceIdentifier<FlowHashIdMap, FlowHashIdMapKey> flHashIdent = tableRef
+                    .augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, hashingKey);
+            /* Add new FlowHashIdMap */
+            trans.put(LogicalDatastoreType.OPERATIONAL, flHashIdent, flHashIdMap.build());
+        }
+
+        void removeUnreportedFlows(final ReadWriteTransaction tx) {
+            final InstanceIdentifier<Node> nodeIdent = tableRef.firstIdentifierOf(Node.class);
+            final List<InstanceIdentifier<Flow>> listMissingConfigFlows = notStatReportedConfigFlows();
+            final Map<InstanceIdentifier<Flow>, Integer> nodeDeleteMap = mapNodesForDelete.get(nodeIdent);
+            final Map<FlowHashIdMapKey, FlowId> listForRemove = getRemovalList();
+            for (final Entry<FlowHashIdMapKey, FlowId> entryForRemove : listForRemove.entrySet()) {
+                final FlowKey flowKey = new FlowKey(entryForRemove.getValue());
+                final InstanceIdentifier<Flow> flowRef = tableRef.child(Flow.class, flowKey);
+                if (nodeDeleteMap != null && flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) {
+                    final Integer lifeIndex = nodeDeleteMap.get(flowRef);
+                    if (lifeIndex > 0) {
+                        break;
+                    } else {
+                        nodeDeleteMap.remove(flowRef);
+                    }
+                } else {
+                    if (listMissingConfigFlows.remove(flowRef)) {
+                        break; // we probably lost some multipart msg
+                    }
+                }
+                final InstanceIdentifier<FlowHashIdMap> flHashIdent =
+                        tableRef.augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, entryForRemove.getKey());
+                tx.delete(LogicalDatastoreType.OPERATIONAL, flowRef);
+                tx.delete(LogicalDatastoreType.OPERATIONAL, flHashIdent);
+            }
+        }
+
+        List<InstanceIdentifier<Flow>> notStatReportedConfigFlows() {
+            if (configFlows != null) {
+                final List<InstanceIdentifier<Flow>> returnList = new ArrayList<>(configFlows.size());
+                for (final Flow confFlow : configFlows) {
+                    final InstanceIdentifier<Flow> confFlowIdent = tableRef.child(Flow.class, confFlow.getKey());
+                    returnList.add(confFlowIdent);
+                }
+                return returnList;
+            }
+            return Collections.emptyList();
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitGroup.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitGroup.java
new file mode 100644 (file)
index 0000000..f351132
--- /dev/null
@@ -0,0 +1,296 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.desc.GroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatListenCommitGroup
+ * Class is a NotifyListener for GroupStatistics and DataChangeListener for Config/DataStore for Group node.
+ * All expected (registered) GroupStatistics will be builded and commit to Operational/DataStore.
+ * DataChangeEven should call create/delete Group in Operational/DS
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatListenCommitGroup extends StatAbstractListenCommit<Group, OpendaylightGroupStatisticsListener>
+                                                    implements OpendaylightGroupStatisticsListener {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StatListenCommitMeter.class);
+
+    public StatListenCommitGroup(final StatisticsManager manager,  final DataBroker db,
+            final NotificationProviderService nps) {
+        super(manager, db, nps, Group.class);
+    }
+
+    @Override
+    protected OpendaylightGroupStatisticsListener getStatNotificationListener() {
+        return this;
+    }
+
+    @Override
+    protected InstanceIdentifier<Group> getWildCardedRegistrationPath() {
+        return InstanceIdentifier.create(Nodes.class).child(Node.class)
+                .augmentation(FlowCapableNode.class).child(Group.class);
+    }
+
+    @Override
+    public void onGroupDescStatsUpdated(final GroupDescStatsUpdated notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - GroupDescStatsUpdated: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final List<GroupDescStats> groupStats = notification.getGroupDescStats() != null
+                ? new ArrayList<>(notification.getGroupDescStats()) : new ArrayList<GroupDescStats>(10);
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if (txContainer.isPresent()) {
+            final List<? extends TransactionAware> cacheNotifs =
+                    txContainer.get().getNotifications();
+            for (final TransactionAware notif : cacheNotifs) {
+                if (notif instanceof GroupDescStatsUpdated) {
+                    groupStats.addAll(((GroupDescStatsUpdated) notif).getGroupDescStats());
+                }
+            }
+        }
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier
+                .create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                statGroupDescCommit(groupStats, nodeIdent, tx);
+                /* Notification for continue collecting statistics */
+                notifyToCollectNextStatistics(nodeIdent);
+            }
+        });
+    }
+
+    @Override
+    public void onGroupFeaturesUpdated(final GroupFeaturesUpdated notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - MeterFeaturesUpdated: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if ( ! txContainer.isPresent()) {
+            return;
+        }
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier
+                .create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                notifyToCollectNextStatistics(nodeIdent);
+                final GroupFeatures stats = new GroupFeaturesBuilder(notification).build();
+                final InstanceIdentifier<GroupFeatures> groupFeatureIdent = nodeIdent
+                        .augmentation(NodeGroupFeatures.class).child(GroupFeatures.class);
+                Optional<Node> node = Optional.absent();
+                try {
+                    node = tx.read(LogicalDatastoreType.OPERATIONAL, nodeIdent).checkedGet();
+                }
+                catch (final ReadFailedException e) {
+                    LOG.debug("Read Operational/DS for Node fail! {}", nodeIdent, e);
+                }
+                if (node.isPresent()) {
+                    tx.put(LogicalDatastoreType.OPERATIONAL, groupFeatureIdent, stats);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void onGroupStatisticsUpdated(final GroupStatisticsUpdated notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - GroupStatisticsUpdated: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final List<GroupStats> groupStats = notification.getGroupStats() != null
+                ? new ArrayList<>(notification.getGroupStats()) : new ArrayList<GroupStats>(10);
+        Optional<Group> notifGroup = Optional.absent();
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if (txContainer.isPresent()) {
+            final Optional<? extends DataObject> inputObj = txContainer.get().getConfInput();
+            if (inputObj.isPresent() && inputObj.get() instanceof Group) {
+                notifGroup = Optional.<Group> of((Group)inputObj.get());
+            }
+            final List<? extends TransactionAware> cacheNotifs =
+                    txContainer.get().getNotifications();
+            for (final TransactionAware notif : cacheNotifs) {
+                if (notif instanceof GroupStatisticsUpdated) {
+                    groupStats.addAll(((GroupStatisticsUpdated) notif).getGroupStats());
+                }
+            }
+        }
+        final Optional<Group> group = notifGroup;
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier
+                .create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                /* Notification for continue collecting statistics */
+                if ( ! group.isPresent()) {
+                    notifyToCollectNextStatistics(nodeIdent);
+                }
+                statGroupCommit(groupStats, nodeIdent, group, tx);
+            }
+        });
+    }
+
+    private void statGroupCommit(final List<GroupStats> groupStats, final InstanceIdentifier<Node> nodeIdent,
+            final Optional<Group> group, final ReadWriteTransaction trans) {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
+
+        for (final GroupStats groupStat : groupStats) {
+            final GroupStatistics stats = new GroupStatisticsBuilder(groupStat).build();
+
+            final GroupKey groupKey = new GroupKey(groupStat.getGroupId());
+            final InstanceIdentifier<GroupStatistics> gsIdent = fNodeIdent
+                    .child(Group.class,groupKey).augmentation(NodeGroupStatistics.class)
+                    .child(GroupStatistics.class);
+            /* Statistics Writing */
+            Optional<FlowCapableNode> fNode = Optional.absent();
+            try {
+                fNode = trans.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
+            }
+            catch (final ReadFailedException e) {
+                LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
+            }
+            if (fNode.isPresent()) {
+                trans.put(LogicalDatastoreType.OPERATIONAL, gsIdent, stats);
+            }
+        }
+    }
+
+    private void statGroupDescCommit(final List<GroupDescStats> groupStats, final InstanceIdentifier<Node> nodeIdent,
+            final ReadWriteTransaction trans) {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
+
+        final List<GroupKey> deviceGroupKeys = new ArrayList<>();
+
+        for (final GroupDescStats group : groupStats) {
+            if (group.getGroupId() != null) {
+                final GroupBuilder groupBuilder = new GroupBuilder(group);
+                final GroupKey groupKey = new GroupKey(group.getGroupId());
+                final InstanceIdentifier<Group> groupRef = fNodeIdent.child(Group.class,groupKey);
+
+                final NodeGroupDescStatsBuilder groupDesc= new NodeGroupDescStatsBuilder();
+                groupDesc.setGroupDesc(new GroupDescBuilder(group).build());
+                //Update augmented data
+                groupBuilder.addAugmentation(NodeGroupDescStats.class, groupDesc.build());
+                deviceGroupKeys.add(groupKey);
+                Optional<FlowCapableNode> hashIdUpd = Optional.absent();
+                try {
+                    hashIdUpd = trans.read(LogicalDatastoreType.OPERATIONAL,fNodeIdent).checkedGet();
+                }
+                catch (final ReadFailedException e) {
+                    LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
+                }
+                if (hashIdUpd.isPresent()) {
+                    trans.put(LogicalDatastoreType.OPERATIONAL, groupRef, groupBuilder.build());
+                }
+            }
+        }
+        /* Delete all not presented Group Nodes */
+        deleteAllNotPresentNode(fNodeIdent, trans, deviceGroupKeys);
+    }
+
+    private void deleteAllNotPresentNode(final InstanceIdentifier<FlowCapableNode> fNodeIdent,
+            final ReadWriteTransaction trans, final List<GroupKey> deviceGroupKeys) {
+
+        final Optional<FlowCapableNode> fNode = readLatestConfiguration(fNodeIdent);
+        if ( ! fNode.isPresent()) {
+            LOG.trace("Read Operational/DS for FlowCapableNode fail! Node {} doesn't exist.", fNodeIdent);
+            return;
+        }
+        final List<Group> existGroups = fNode.get().getGroup() != null
+                ? fNode.get().getGroup() : Collections.<Group> emptyList();
+        /* Add all existed groups paths - no updated paths has to be removed */
+        for (final Group group : existGroups) {
+            if (deviceGroupKeys.remove(group.getKey())) {
+                break; // group still exist on device
+            }
+            LOG.trace("Group {} has to removed.", group);
+            final InstanceIdentifier<Group> delGroupIdent = fNodeIdent.child(Group.class, group.getKey());
+            Optional<Group> delGroup = Optional.absent();
+            try {
+                delGroup = trans.read(LogicalDatastoreType.OPERATIONAL, delGroupIdent).checkedGet();
+            }
+            catch (final ReadFailedException e) {
+                // NOOP - probably another transaction delete that node
+            }
+            if (delGroup.isPresent()) {
+                trans.delete(LogicalDatastoreType.OPERATIONAL, delGroupIdent);
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitMeter.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitMeter.java
new file mode 100644 (file)
index 0000000..9c9de59
--- /dev/null
@@ -0,0 +1,283 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatListenCommitMeter
+ * Class is a NotifyListener for MeterStatistics and DataChangeListener for Config/DataStore for Meter node.
+ * All expected (registered) MeterStatistics will be builded and commit to Operational/DataStore.
+ * DataChangeEven should call create/delete Meter in Operational/DS
+ *
+ */
+public class StatListenCommitMeter extends StatAbstractListenCommit<Meter, OpendaylightMeterStatisticsListener>
+                                            implements OpendaylightMeterStatisticsListener {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StatListenCommitMeter.class);
+
+    public StatListenCommitMeter(final StatisticsManager manager, final DataBroker db,
+            final NotificationProviderService nps) {
+        super(manager, db, nps, Meter.class);
+    }
+
+    @Override
+    protected InstanceIdentifier<Meter> getWildCardedRegistrationPath() {
+        return InstanceIdentifier.create(Nodes.class).child(Node.class)
+                .augmentation(FlowCapableNode.class).child(Meter.class);
+    }
+
+    @Override
+    protected OpendaylightMeterStatisticsListener getStatNotificationListener() {
+        return this;
+    }
+
+    @Override
+    public void onMeterConfigStatsUpdated(final MeterConfigStatsUpdated notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - MeterConfigStatsUpdated: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final List<MeterConfigStats> meterConfStat = notification.getMeterConfigStats() != null
+                ? new ArrayList<>(notification.getMeterConfigStats()) : new ArrayList<MeterConfigStats>(10);
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if (txContainer.isPresent()) {
+            final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
+            for (final TransactionAware notif : cacheNotifs) {
+                if (notif instanceof MeterConfigStatsUpdated) {
+                    meterConfStat.addAll(((MeterConfigStatsUpdated) notif).getMeterConfigStats());
+                }
+            }
+        }
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                /* Notification for continue collecting statistics */
+                notifyToCollectNextStatistics(nodeIdent);
+                comitConfMeterStats(meterConfStat, nodeIdent, tx);
+            }
+        });
+    }
+
+    @Override
+    public void onMeterFeaturesUpdated(final MeterFeaturesUpdated notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - MeterFeaturesUpdated: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if ( ! txContainer.isPresent()) {
+            return;
+        }
+        final MeterFeatures stats = new MeterFeaturesBuilder(notification).build();
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier
+                .create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+        final InstanceIdentifier<MeterFeatures> meterFeatureIdent = nodeIdent
+                .augmentation(NodeMeterFeatures.class).child(MeterFeatures.class);
+
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                /* Notification for continue collecting statistics */
+                notifyToCollectNextStatistics(nodeIdent);
+                Optional<Node> node = Optional.absent();
+                try {
+                    node = tx.read(LogicalDatastoreType.OPERATIONAL, nodeIdent).checkedGet();
+                }
+                catch (final ReadFailedException e) {
+                    LOG.debug("Read Operational/DS for Node fail! {}", nodeIdent, e);
+                }
+                if (node.isPresent()) {
+                    tx.put(LogicalDatastoreType.OPERATIONAL, meterFeatureIdent, stats);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void onMeterStatisticsUpdated(final MeterStatisticsUpdated notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - MeterStatisticsUpdated: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final List<MeterStats> meterStat = notification.getMeterStats() != null
+                ? new ArrayList<>(notification.getMeterStats()) : new ArrayList<MeterStats>(10);
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if (txContainer.isPresent()) {
+            final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
+            for (final TransactionAware notif : cacheNotifs) {
+                if (notif instanceof MeterConfigStatsUpdated) {
+                    meterStat.addAll(((MeterStatisticsUpdated) notif).getMeterStats());
+                }
+            }
+        }
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                statMeterCommit(meterStat, nodeIdent, tx);
+                /* Notification for continue collecting statistics */
+                notifyToCollectNextStatistics(nodeIdent);
+            }
+        });
+    }
+
+    private void statMeterCommit(final List<MeterStats> meterStats,
+            final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction trans) {
+
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
+        for (final MeterStats mStat : meterStats) {
+            final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build();
+
+            final MeterKey mKey = new MeterKey(mStat.getMeterId());
+            final InstanceIdentifier<MeterStatistics> msIdent = fNodeIdent
+                    .child(Meter.class, mKey).augmentation(NodeMeterStatistics.class)
+                    .child(MeterStatistics.class);
+            /* Meter Statistics commit */
+            Optional<FlowCapableNode> fNode = Optional.absent();
+            try {
+                fNode = trans.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
+            }
+            catch (final ReadFailedException e) {
+                LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
+            }
+            if (fNode.isPresent()) {
+                trans.put(LogicalDatastoreType.OPERATIONAL, msIdent, stats);
+            }
+        }
+    }
+
+    private void comitConfMeterStats(final List<MeterConfigStats> meterConfStat,
+            final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction trans) {
+
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
+        final List<MeterKey> deviceMeterKeys = new ArrayList<>();
+
+        for (final MeterConfigStats meterConf : meterConfStat) {
+            final MeterBuilder meterBuilder = new MeterBuilder(meterConf);
+            if (meterConf.getMeterId() != null) {
+                final MeterKey meterKey = new MeterKey(meterConf.getMeterId());
+                meterBuilder.setKey(meterKey);
+                final InstanceIdentifier<Meter> meterRef = nodeIdent
+                        .augmentation(FlowCapableNode.class).child(Meter.class,meterKey);
+                final NodeMeterConfigStatsBuilder meterConfig = new NodeMeterConfigStatsBuilder();
+                meterConfig.setMeterConfigStats(new MeterConfigStatsBuilder(meterConf).build());
+                //Update augmented data
+                meterBuilder.addAugmentation(NodeMeterConfigStats.class, meterConfig.build());
+                deviceMeterKeys.add(meterKey);
+                Optional<FlowCapableNode> fNode = Optional.absent();
+                try {
+                    fNode = trans.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
+                }
+                catch (final ReadFailedException e) {
+                    LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
+                }
+                if (fNode.isPresent()) {
+                    trans.put(LogicalDatastoreType.OPERATIONAL, meterRef, meterBuilder.build());
+                }
+            }
+        }
+        /* Delete all not presented Meter Nodes */
+        deleteAllNotPresentedNodes(fNodeIdent, trans, deviceMeterKeys);
+    }
+
+    private void deleteAllNotPresentedNodes(final InstanceIdentifier<FlowCapableNode> fNodeIdent,
+            final ReadWriteTransaction trans, final List<MeterKey> deviceMeterKeys) {
+        /* Delete all not presented meters */
+        final Optional<FlowCapableNode> fNode = readLatestConfiguration(fNodeIdent);
+
+        if ( ! fNode.isPresent()) {
+            LOG.trace("Read Operational/DS for FlowCapableNode fail! Node {} doesn't exist.", fNodeIdent);
+            return;
+        }
+        final List<Meter> existMeters = fNode.get().getMeter() != null
+                ? fNode.get().getMeter() : Collections.<Meter> emptyList();
+        /* Add all existed groups paths - no updated paths has to be removed */
+        for (final Meter meter : existMeters) {
+            if (deviceMeterKeys.remove(meter.getKey())) {
+                break; // Meter still exist on device
+            }
+            final InstanceIdentifier<Meter> delMeterIdent = fNodeIdent.child(Meter.class, meter.getKey());
+            Optional<Meter> delMeter = Optional.absent();
+            try {
+                delMeter = trans.read(LogicalDatastoreType.OPERATIONAL, delMeterIdent).checkedGet();
+            }
+            catch (final ReadFailedException e) {
+                // NOOP - probably another transaction delete that node
+            }
+            if (delMeter.isPresent()) {
+                trans.delete(LogicalDatastoreType.OPERATIONAL, delMeterIdent);
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitQueue.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatListenCommitQueue.java
new file mode 100644 (file)
index 0000000..e336f01
--- /dev/null
@@ -0,0 +1,149 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.flow.capable.node.connector.queue.statistics.FlowCapableNodeConnectorQueueStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.flow.capable.node.connector.queue.statistics.FlowCapableNodeConnectorQueueStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatNotifyCommitQueue
+ * Class is a NotifyListner for Queues Statistics
+ * All expected (registered) queueStatistics will be builded and
+ * commit to Operational/DataStore
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatListenCommitQueue extends StatAbstractListenCommit<Queue, OpendaylightQueueStatisticsListener>
+                                        implements OpendaylightQueueStatisticsListener {
+
+    private final static Logger LOG = LoggerFactory.getLogger(StatListenCommitQueue.class);
+
+    public StatListenCommitQueue(final StatisticsManager manager, final DataBroker db,
+            final NotificationProviderService nps) {
+        super(manager, db, nps, Queue.class);
+    }
+
+    @Override
+    protected OpendaylightQueueStatisticsListener getStatNotificationListener() {
+        return this;
+    }
+
+    @Override
+    protected InstanceIdentifier<Queue> getWildCardedRegistrationPath() {
+        return InstanceIdentifier.create(Nodes.class).child(Node.class).child(NodeConnector.class)
+            .augmentation(FlowCapableNodeConnector.class).child(Queue.class);
+    }
+
+    @Override
+    public void onQueueStatisticsUpdate(final QueueStatisticsUpdate notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - QueueStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        if (notification.isMoreReplies()) {
+            manager.getRpcMsgManager().addNotification(notification, nodeId);
+            return;
+        }
+        final List<QueueIdAndStatisticsMap> queueStats = notification.getQueueIdAndStatisticsMap() != null
+                ? new ArrayList<>(notification.getQueueIdAndStatisticsMap()) : new ArrayList<QueueIdAndStatisticsMap>(10);
+        final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+        if (txContainer.isPresent()) {
+            final List<? extends TransactionAware> cachedNotifs =
+                    txContainer.get().getNotifications();
+            for (final TransactionAware notif : cachedNotifs) {
+                if (notif instanceof QueueStatisticsUpdate) {
+                    queueStats.addAll(((QueueStatisticsUpdate) notif).getQueueIdAndStatisticsMap());
+                }
+            }
+        }
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(nodeId));
+        /* Queue statistics are small size and we are not able to change for OF cross controller
+         * - don't need to make are atomic */
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction trans) {
+                /* Notification for continue */
+                notifyToCollectNextStatistics(nodeIdent);
+                statQueueCommit(queueStats, nodeIdent, trans);
+            }
+        });
+    }
+
+    private void statQueueCommit(final List<QueueIdAndStatisticsMap> queueStats,
+            final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction trans) {
+
+        /* check exist FlowCapableNode and write statistics */
+        Optional<Node> fNode = Optional.absent();
+        try {
+            fNode = trans.read(LogicalDatastoreType.OPERATIONAL, nodeIdent).checkedGet();
+        }
+        catch (final ReadFailedException e) {
+            LOG.debug("Read Operational/DS for Node fail! {}", nodeIdent, e);
+            return;
+        }
+        if ( ! fNode.isPresent()) {
+            LOG.trace("Read Operational/DS for Node fail! Node {} doesn't exist.", nodeIdent);
+            return;
+        }
+
+        for (final QueueIdAndStatisticsMap queueEntry : queueStats) {
+            final FlowCapableNodeConnectorQueueStatistics statChild =
+                    new FlowCapableNodeConnectorQueueStatisticsBuilder(queueEntry).build();
+            final FlowCapableNodeConnectorQueueStatisticsDataBuilder statBuild =
+                    new FlowCapableNodeConnectorQueueStatisticsDataBuilder();
+            statBuild.setFlowCapableNodeConnectorQueueStatistics(statChild);
+            final QueueKey qKey = new QueueKey(queueEntry.getQueueId());
+            final InstanceIdentifier<FlowCapableNodeConnectorQueueStatisticsData> queueStatIdent = nodeIdent
+                    .child(NodeConnector.class, new NodeConnectorKey(queueEntry.getNodeConnectorId()))
+                    .augmentation(FlowCapableNodeConnector.class)
+                    .child(Queue.class, qKey).augmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
+            trans.put(LogicalDatastoreType.OPERATIONAL, queueStatIdent, statBuild.build());
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNodeRegistrationImpl.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNodeRegistrationImpl.java
new file mode 100644 (file)
index 0000000..adb5870
--- /dev/null
@@ -0,0 +1,207 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+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.statistics.manager.StatNodeRegistration;
+import org.opendaylight.controller.md.statistics.manager.StatPermCollector.StatCapabTypes;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityGroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityQueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityTableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatNodeRegistrationImpl
+ * {@link FlowCapableNode} Registration Implementation contains two method for registration/unregistration
+ * {@link FeatureCapability} for every connect/disconnect {@link FlowCapableNode}. Process of connection/disconnection
+ * is substituted by listening Operation/DS for add/delete {@link FeatureCapability}.
+ * All statistic capabilities are reading from new Node directly without contacting device or DS.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Aug 28, 2014
+ */
+public class StatNodeRegistrationImpl implements StatNodeRegistration {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StatNodeRegistrationImpl.class);
+
+    private final StatisticsManager manager;
+    private ListenerRegistration<DataChangeListener> listenerRegistration;
+    private ListenerRegistration<?> notifListenerRegistration;
+
+    public StatNodeRegistrationImpl(final StatisticsManager manager, final DataBroker db,
+            final NotificationProviderService notificationService) {
+        this.manager = Preconditions.checkNotNull(manager, "StatisticManager can not be null!");
+        Preconditions.checkArgument(db != null, "DataBroker can not be null!");
+        Preconditions.checkArgument(notificationService != null, "NotificationProviderService can not be null!");
+        notifListenerRegistration = notificationService.registerNotificationListener(this);
+    }
+
+    @Override
+    public void close() throws Exception {
+
+        if (notifListenerRegistration != null) {
+            try {
+                notifListenerRegistration.close();
+            }
+            catch (final Exception e) {
+                LOG.warn("Error by stop FlowCapableNode Notification StatNodeRegistration.");
+            }
+            notifListenerRegistration = null;
+        }
+
+        if (listenerRegistration != null) {
+            try {
+                listenerRegistration.close();
+            } catch (final Exception e) {
+                LOG.warn("Error by stop FlowCapableNode DataChange StatListeningCommiter.", e);
+            }
+            listenerRegistration = null;
+        }
+    }
+
+    @Override
+    public void connectFlowCapableNode(final InstanceIdentifier<SwitchFeatures> keyIdent,
+            final SwitchFeatures data, final InstanceIdentifier<Node> nodeIdent) {
+        Preconditions.checkNotNull(keyIdent, "InstanceIdentifier can not be null!");
+        Preconditions.checkNotNull(data, "SwitchFeatures data for {} can not be null!", keyIdent);
+        Preconditions.checkArgument(( ! keyIdent.isWildcarded()), "InstanceIdentifier is WildCarded!");
+
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+
+                final List<StatCapabTypes> statCapabTypes = new ArrayList<>();
+                Short maxCapTables = Short.valueOf("1");
+
+                final List<Class<? extends FeatureCapability>> capabilities = data.getCapabilities() != null
+                        ? data.getCapabilities() : Collections.<Class<? extends FeatureCapability>> emptyList();
+                for (final Class<? extends FeatureCapability> capability : capabilities) {
+                    if (capability == FlowFeatureCapabilityTableStats.class) {
+                        statCapabTypes.add(StatCapabTypes.TABLE_STATS);
+                    } else if (capability == FlowFeatureCapabilityFlowStats.class) {
+                        statCapabTypes.add(StatCapabTypes.FLOW_STATS);
+                    } else if (capability == FlowFeatureCapabilityGroupStats.class) {
+                        statCapabTypes.add(StatCapabTypes.GROUP_STATS);
+                    } else if (capability == FlowFeatureCapabilityPortStats.class) {
+                        statCapabTypes.add(StatCapabTypes.PORT_STATS);
+                    } else if (capability == FlowFeatureCapabilityQueueStats.class) {
+                        statCapabTypes.add(StatCapabTypes.QUEUE_STATS);
+                    }
+                }
+                maxCapTables = data.getMaxTables();
+
+                final Optional<Short> maxTables = Optional.<Short> of(maxCapTables);
+
+                /* Meters management */
+                final InstanceIdentifier<NodeMeterFeatures> meterFeaturesIdent = nodeIdent.augmentation(NodeMeterFeatures.class);
+
+
+                Optional<NodeMeterFeatures> meterFeatures = Optional.absent();
+                try {
+                    meterFeatures = tx.read(LogicalDatastoreType.OPERATIONAL, meterFeaturesIdent).checkedGet();
+                }
+                catch (final ReadFailedException e) {
+                    LOG.warn("Read NodeMeterFeatures {} fail!", meterFeaturesIdent, e);
+                }
+                if (meterFeatures.isPresent()) {
+                    statCapabTypes.add(StatCapabTypes.METER_STATS);
+                }
+                manager.connectedNodeRegistration(nodeIdent,
+                        Collections.unmodifiableList(statCapabTypes), maxTables.get());
+            }
+        });
+    }
+
+    @Override
+    public void disconnectFlowCapableNode(final InstanceIdentifier<Node> nodeIdent) {
+        Preconditions.checkArgument(nodeIdent != null, "InstanceIdentifier can not be NULL!");
+        Preconditions.checkArgument(( ! nodeIdent.isWildcarded()),
+                "InstanceIdentifier {} is WildCarded!", nodeIdent);
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction tx) {
+                manager.disconnectedNodeUnregistration(nodeIdent);
+            }
+        });
+    }
+
+
+    @Override
+    public void onNodeConnectorRemoved(final NodeConnectorRemoved notification) {
+        // NOOP
+    }
+
+    @Override
+    public void onNodeConnectorUpdated(final NodeConnectorUpdated notification) {
+        // NOOP
+    }
+
+    @Override
+    public void onNodeRemoved(final NodeRemoved notification) {
+        final NodeRef nodeRef = notification.getNodeRef();
+        final InstanceIdentifier<?> nodeRefIdent = nodeRef.getValue();
+        final InstanceIdentifier<Node> nodeIdent =
+                nodeRefIdent.firstIdentifierOf(Node.class);
+        if (nodeIdent != null) {
+            disconnectFlowCapableNode(nodeIdent);
+        }
+    }
+
+    @Override
+    public void onNodeUpdated(final NodeUpdated notification) {
+        final FlowCapableNodeUpdated newFlowNode =
+                notification.getAugmentation(FlowCapableNodeUpdated.class);
+        if (newFlowNode != null && newFlowNode.getSwitchFeatures() != null) {
+            final NodeRef nodeRef = notification.getNodeRef();
+            final InstanceIdentifier<?> nodeRefIdent = nodeRef.getValue();
+            final InstanceIdentifier<Node> nodeIdent =
+                    nodeRefIdent.firstIdentifierOf(Node.class);
+
+            final InstanceIdentifier<SwitchFeatures> swichFeaturesIdent =
+                    nodeIdent.augmentation(FlowCapableNode.class).child(SwitchFeatures.class);
+            final SwitchFeatures switchFeatures = newFlowNode.getSwitchFeatures();
+            connectFlowCapableNode(swichFeaturesIdent, switchFeatures, nodeIdent);
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNotifyCommitPort.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNotifyCommitPort.java
new file mode 100644 (file)
index 0000000..fb12437
--- /dev/null
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatNotifyCommitPort
+ * Class is a NotifyListener for PortStatistics
+ * All expected (registered) portStatistics will be builded and
+ * commit to Operational/DataStore
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatNotifyCommitPort extends StatAbstractNotifyCommit<OpendaylightPortStatisticsListener>
+                                        implements OpendaylightPortStatisticsListener {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StatNotifyCommitPort.class);
+
+    public StatNotifyCommitPort(final StatisticsManager manager,
+            final NotificationProviderService nps) {
+        super(manager, nps);
+    }
+
+    @Override
+    protected OpendaylightPortStatisticsListener getStatNotificationListener() {
+        return this;
+    }
+
+    @Override
+    public void onNodeConnectorStatisticsUpdate(final NodeConnectorStatisticsUpdate notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - NodeConnectorStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        manager.getRpcMsgManager().addNotification(notification, nodeId);
+        if (notification.isMoreReplies()) {
+            return;
+        }
+        final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(nodeId));
+        /* Don't block RPC Notification thread */
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction trans) {
+                final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+                if (( ! txContainer.isPresent()) || txContainer.get().getNotifications() == null) {
+                    return;
+                }
+                final List<NodeConnectorStatisticsAndPortNumberMap> portStats =
+                        new ArrayList<NodeConnectorStatisticsAndPortNumberMap>(10);
+                final List<? extends TransactionAware> cachedNotifs = txContainer.get().getNotifications();
+                for (final TransactionAware notif : cachedNotifs) {
+                    if (notif instanceof NodeConnectorStatisticsUpdate) {
+                        final List<NodeConnectorStatisticsAndPortNumberMap> notifStat =
+                                ((NodeConnectorStatisticsUpdate) notif).getNodeConnectorStatisticsAndPortNumberMap();
+                        if (notifStat != null) {
+                            portStats.addAll(notifStat);
+                        }
+                    }
+                }
+                /* write stat to trans */
+                statPortCommit(portStats, nodeIdent, trans);
+                /* Notification for continue collecting statistics - Port statistics are still same size
+                 * and they are small - don't need to wait for whole apply operation*/
+                notifyToCollectNextStatistics(nodeIdent);
+            }
+        });
+    }
+
+    private void statPortCommit(final List<NodeConnectorStatisticsAndPortNumberMap> portStats,
+            final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) {
+
+        /* check exist FlowCapableNode and write statistics probable with parent */
+        Optional<Node> fNode = Optional.absent();
+        try {
+            fNode = tx.read(LogicalDatastoreType.OPERATIONAL, nodeIdent).checkedGet();
+        }
+        catch (final ReadFailedException e) {
+            LOG.debug("Read Operational/DS for Node fail! {}", nodeIdent, e);
+            return;
+        }
+        if ( ! fNode.isPresent()) {
+            LOG.trace("Read Operational/DS for Node fail! Node {} doesn't exist.", nodeIdent);
+            return;
+        }
+        for (final NodeConnectorStatisticsAndPortNumberMap nConnectPort : portStats) {
+            final FlowCapableNodeConnectorStatistics stats = new FlowCapableNodeConnectorStatisticsBuilder(nConnectPort).build();
+            final NodeConnectorKey key = new NodeConnectorKey(nConnectPort.getNodeConnectorId());
+            final InstanceIdentifier<NodeConnector> nodeConnectorIdent = nodeIdent.child(NodeConnector.class, key);
+            final InstanceIdentifier<FlowCapableNodeConnectorStatisticsData> nodeConnStatIdent = nodeConnectorIdent
+                    .augmentation(FlowCapableNodeConnectorStatisticsData.class);
+            final InstanceIdentifier<FlowCapableNodeConnectorStatistics> flowCapNodeConnStatIdent =
+                    nodeConnStatIdent.child(FlowCapableNodeConnectorStatistics.class);
+            Optional<NodeConnector> fNodeConector;
+            try {
+                fNodeConector = tx.read(LogicalDatastoreType.OPERATIONAL, nodeConnectorIdent).checkedGet();
+            }
+            catch (final ReadFailedException e) {
+                LOG.debug("Read NodeConnector {} in Operational/DS fail!", nodeConnectorIdent, e);
+                fNodeConector = Optional.absent();
+            }
+            if (fNodeConector.isPresent()) {
+                tx.merge(LogicalDatastoreType.OPERATIONAL, nodeConnectorIdent, new NodeConnectorBuilder().setId(key.getId()).build());
+                tx.merge(LogicalDatastoreType.OPERATIONAL, nodeConnStatIdent, new FlowCapableNodeConnectorStatisticsDataBuilder().build());
+                tx.put(LogicalDatastoreType.OPERATIONAL, flowCapNodeConnStatIdent, stats);
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNotifyCommitTable.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatNotifyCommitTable.java
new file mode 100644 (file)
index 0000000..b41bd49
--- /dev/null
@@ -0,0 +1,144 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager.TransactionCacheContainer;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager.StatDataStoreOperation;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatNotifyCommitTable
+ * Class is a NotifyListener for TableStatistics
+ * All expected (registered) tableStatistics will be builded and
+ * commit to Operational/DataStore
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatNotifyCommitTable extends StatAbstractNotifyCommit<OpendaylightFlowTableStatisticsListener>
+                                        implements OpendaylightFlowTableStatisticsListener {
+
+    private final static Logger LOG = LoggerFactory.getLogger(StatNotifyCommitTable.class);
+
+    public StatNotifyCommitTable(final StatisticsManager manager,
+            final NotificationProviderService nps) {
+        super(manager, nps);
+    }
+
+    @Override
+    protected OpendaylightFlowTableStatisticsListener getStatNotificationListener() {
+        return this;
+    }
+
+    @Override
+    public void onFlowTableStatisticsUpdate(final FlowTableStatisticsUpdate notification) {
+        final TransactionId transId = notification.getTransactionId();
+        final NodeId nodeId = notification.getId();
+        if ( ! isExpectedStatistics(transId, nodeId)) {
+            LOG.debug("STAT-MANAGER - FlowTableStatisticsUpdate: unregistred notification detect TransactionId {}", transId);
+            return;
+        }
+        manager.getRpcMsgManager().addNotification(notification, nodeId);
+        if (notification.isMoreReplies()) {
+            return;
+        }
+        /* Don't block RPC Notification thread */
+        manager.enqueue(new StatDataStoreOperation() {
+            @Override
+            public void applyOperation(final ReadWriteTransaction trans) {
+                final List<FlowTableAndStatisticsMap> tableStats = new ArrayList<FlowTableAndStatisticsMap>(10);
+                final Optional<TransactionCacheContainer<?>> txContainer = getTransactionCacheContainer(transId, nodeId);
+                final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
+                        .child(Node.class, new NodeKey(nodeId));
+                if (( ! txContainer.isPresent()) || txContainer.get().getNodeId() == null) {
+                    return;
+                }
+                final List<? extends TransactionAware> cachedNotifs = txContainer.get().getNotifications();
+                for (final TransactionAware notif : cachedNotifs) {
+                    if (notif instanceof FlowTableStatisticsUpdate) {
+                        final List<FlowTableAndStatisticsMap> statNotif =
+                                ((FlowTableStatisticsUpdate) notif).getFlowTableAndStatisticsMap();
+                        if (statNotif != null) {
+                            tableStats.addAll(statNotif);
+                        }
+                    }
+                }
+                /* write stat to trans */
+                statTableCommit(tableStats, nodeIdent, trans);
+                /* Notification for continue collecting statistics - Tables statistics are still same size
+                 * and they are small - don't need to wait to whole apply operation */
+                notifyToCollectNextStatistics(nodeIdent);
+            }
+        });
+    }
+
+    private void statTableCommit(final List<FlowTableAndStatisticsMap> tableStats, final InstanceIdentifier<Node> nodeIdent,
+            final ReadWriteTransaction trans) {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class);
+        /* check flow Capable Node and write statistics */
+        Optional<FlowCapableNode> fNode = Optional.absent();
+        try {
+            fNode = trans.read(LogicalDatastoreType.OPERATIONAL, fNodeIdent).checkedGet();
+        }
+        catch (final ReadFailedException e) {
+            LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e);
+            return;
+        }
+        if ( ! fNode.isPresent()) {
+            LOG.trace("Read Operational/DS for FlowCapableNode fail! Node {} doesn't exist.", fNodeIdent);
+            return;
+        }
+        for (final FlowTableAndStatisticsMap tableStat : tableStats) {
+            final InstanceIdentifier<Table> tableIdent = fNodeIdent
+                    .child(Table.class, new TableKey(tableStat.getTableId().getValue()));
+            final Table table = new TableBuilder().setId(tableStat.getTableId().getValue()).build();
+            trans.merge(LogicalDatastoreType.OPERATIONAL, tableIdent, table);
+            final InstanceIdentifier<FlowTableStatisticsData> tableStatIdent = tableIdent
+                    .augmentation(FlowTableStatisticsData.class);
+            trans.merge(LogicalDatastoreType.OPERATIONAL, tableStatIdent, new FlowTableStatisticsDataBuilder().build());
+
+            final FlowTableStatistics stats = new FlowTableStatisticsBuilder(tableStat).build();
+            final InstanceIdentifier<FlowTableStatistics> tStatIdent = tableStatIdent.child(FlowTableStatistics.class);
+            trans.put(LogicalDatastoreType.OPERATIONAL, tStatIdent, stats);
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatPermCollectorImpl.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatPermCollectorImpl.java
new file mode 100644 (file)
index 0000000..d008042
--- /dev/null
@@ -0,0 +1,305 @@
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+import org.opendaylight.controller.md.statistics.manager.StatPermCollector;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatPermCollectorImpl
+ * Thread base statistic collector. Class holds internal map for all registered
+ * (means connected) nodes with List of Switch capabilities;
+ * Statistics collecting process get cross whole Network Device by device
+ * and statistic by statistic (follow Switch capabilities to prevent unnecessary
+ * ask) Next statistic start collecting by notification or by timeout.
+ *
+ * @author @author avishnoi@in.ibm.com <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatPermCollectorImpl implements StatPermCollector {
+
+    private final static Logger LOG = LoggerFactory.getLogger(StatPermCollectorImpl.class);
+
+    private final static long STAT_COLLECT_TIME_OUT = 30000L;
+
+    private final ExecutorService statNetCollectorServ;
+    private final StatisticsManager manager;
+
+    private final int maxNodeForCollector;
+    private final long minReqNetInterval;
+    private final String name;
+
+    private final Object statCollectorLock = new Object();
+    private final Object statNodeHolderLock = new Object();
+
+    private Map<InstanceIdentifier<Node>, StatNodeInfoHolder> statNodeHolder =
+            Collections.<InstanceIdentifier<Node>, StatNodeInfoHolder> emptyMap();
+
+    private volatile boolean wakeMe = false;
+    private volatile boolean finishing = false;
+
+    public StatPermCollectorImpl(final StatisticsManager manager, final long minReqNetInterv, final int nr,
+            final int maxNodeForCollectors) {
+        this.manager = Preconditions.checkNotNull(manager, "StatisticsManager can not be null!");
+        name = "odl-stat-collector-" + nr;
+        minReqNetInterval = minReqNetInterv;
+        final ThreadFactory threadFact = new ThreadFactoryBuilder()
+            .setNameFormat(name + "-thread-%d").build();
+        statNetCollectorServ = Executors.newSingleThreadExecutor(threadFact);
+        maxNodeForCollector = maxNodeForCollectors;
+        LOG.trace("StatCollector {} start successfull!", name);
+    }
+
+    /**
+     * finish collecting statistics
+     */
+    @Override
+    public void close() {
+        statNodeHolder = Collections.<InstanceIdentifier<Node>, StatNodeInfoHolder> emptyMap();
+        finishing = true;
+        collectNextStatistics();
+        statNetCollectorServ.shutdown();
+    }
+
+    @Override
+    public boolean isProvidedFlowNodeActive(
+            final InstanceIdentifier<Node> flowNode) {
+        return statNodeHolder.containsKey(flowNode);
+    }
+
+    @Override
+    public boolean connectedNodeRegistration(final InstanceIdentifier<Node> ident,
+            final List<StatCapabTypes> statTypes, final Short nrOfSwitchTables) {
+        if (ident.isWildcarded()) {
+            LOG.warn("FlowCapableNode IstanceIdentifier {} registration can not be wildcarded!", ident);
+        } else {
+            if ( ! statNodeHolder.containsKey(ident)) {
+                synchronized (statNodeHolderLock) {
+                    final boolean startStatCollecting = statNodeHolder.size() == 0;
+                    if ( ! statNodeHolder.containsKey(ident)) {
+                        if (statNodeHolder.size() >= maxNodeForCollector) {
+                            return false;
+                        }
+                        final Map<InstanceIdentifier<Node>, StatNodeInfoHolder> statNode =
+                                new HashMap<>(statNodeHolder);
+                        final NodeRef nodeRef = new NodeRef(ident);
+                        final StatNodeInfoHolder nodeInfoHolder = new StatNodeInfoHolder(nodeRef,
+                                statTypes, nrOfSwitchTables);
+                        statNode.put(ident, nodeInfoHolder);
+                        statNodeHolder = Collections.unmodifiableMap(statNode);
+                    }
+                    if (startStatCollecting) {
+                        finishing = false;
+                        statNetCollectorServ.execute(this);
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean disconnectedNodeUnregistration(final InstanceIdentifier<Node> ident) {
+        if (ident.isWildcarded()) {
+            LOG.warn("FlowCapableNode IstanceIdentifier {} unregistration can not be wildcarded!", ident);
+        } else {
+            if (statNodeHolder.containsKey(ident)) {
+                synchronized (statNodeHolderLock) {
+                    if (statNodeHolder.containsKey(ident)) {
+                        final Map<InstanceIdentifier<Node>, StatNodeInfoHolder> statNode =
+                                new HashMap<>(statNodeHolder);
+                        statNode.remove(ident);
+                        statNodeHolder = Collections.unmodifiableMap(statNode);
+                    }
+                    if (statNodeHolder.isEmpty()) {
+                        finishing = true;
+                        collectNextStatistics();
+                        statNetCollectorServ.shutdown();
+                    }
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void collectNextStatistics() {
+        if (wakeMe) {
+            synchronized (statCollectorLock) {
+                if (wakeMe) {
+                    LOG.trace("STAT-COLLECTOR is notified to conntinue");
+                    statCollectorLock.notify();
+                }
+            }
+        }
+    }
+
+    @Override
+    public void run() {
+        try {
+            Thread.sleep(5000);
+        }
+        catch (final InterruptedException e1) {
+            // NOOP
+        }
+        LOG.debug("StatCollector {} Start collecting!", name);
+         /* Neverending cyle - wait for finishing */
+         while ( ! finishing) {
+            boolean collecting = false;
+            final long startTime = System.currentTimeMillis();
+
+            if ( ! statNodeHolder.isEmpty()) {
+                collecting = true;
+                collectStatCrossNetwork();
+                collecting = false;
+            }
+
+            if ( ! collecting) {
+                final long statFinalTime = System.currentTimeMillis() - startTime;
+                LOG.debug("STAT-MANAGER {}: last all NET statistics collection cost {} ms", name, statFinalTime);
+                if (statFinalTime < minReqNetInterval) {
+                    LOG.trace("statCollector is about to make a collecting sleep");
+                    synchronized (statCollectorLock) {
+                        wakeMe = true;
+                        try {
+                            final long waitTime = minReqNetInterval - statFinalTime;
+                            statCollectorLock.wait(waitTime);
+                            LOG.trace("STAT-MANAGER : statCollector {} is waking up from a collecting sleep for {} ms", name, waitTime);
+                        } catch (final InterruptedException e) {
+                            LOG.warn("statCollector has been interrupted during collecting sleep", e);
+                        } finally {
+                            wakeMe = false;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private void waitingForNotification() {
+        synchronized (statCollectorLock) {
+            wakeMe = true;
+            try {
+                statCollectorLock.wait(STAT_COLLECT_TIME_OUT);
+                LOG.trace("statCollector is waking up from a wait stat Response sleep");
+            } catch (final InterruptedException e) {
+                LOG.warn("statCollector has been interrupted waiting stat Response sleep", e);
+            } finally {
+                wakeMe = false;
+            }
+        }
+    }
+
+
+    private void collectStatCrossNetwork() {
+        for (final Entry<InstanceIdentifier<Node>, StatNodeInfoHolder> nodeEntity : statNodeHolder.entrySet()) {
+            final List<StatCapabTypes> listNeededStat = nodeEntity.getValue().getStatMarkers();
+            final NodeRef actualNodeRef = nodeEntity.getValue().getNodeRef();
+            final Short maxTables = nodeEntity.getValue().getMaxTables();
+            for (final StatCapabTypes statMarker : listNeededStat) {
+                if ( ! isProvidedFlowNodeActive(nodeEntity.getKey())) {
+                    break;
+                }
+                switch (statMarker) {
+                case PORT_STATS:
+                    LOG.trace("STAT-MANAGER-collecting PORT-STATS for NodeRef {}", actualNodeRef);
+                    manager.getRpcMsgManager().getAllPortsStat(actualNodeRef);
+                    waitingForNotification();
+                    break;
+                case QUEUE_STATS:
+                    LOG.trace("STAT-MANAGER-collecting QUEUE-STATS for NodeRef {}", actualNodeRef);
+                    manager.getRpcMsgManager().getAllQueueStat(actualNodeRef);
+                    waitingForNotification();
+                    break;
+                case TABLE_STATS:
+                    LOG.trace("STAT-MANAGER-collecting TABLE-STATS for NodeRef {}", actualNodeRef);
+                    manager.getRpcMsgManager().getAllTablesStat(actualNodeRef);
+                    waitingForNotification();
+                    break;
+                case GROUP_STATS:
+                    LOG.trace("STAT-MANAGER-collecting GROUP-STATS for NodeRef {}", actualNodeRef);
+                    manager.getRpcMsgManager().getGroupFeaturesStat(actualNodeRef);
+                    waitingForNotification();
+                    manager.getRpcMsgManager().getAllGroupsConfStats(actualNodeRef);
+                    waitingForNotification();
+                    manager.getRpcMsgManager().getAllGroupsStat(actualNodeRef);
+                    waitingForNotification();
+                    break;
+                case METER_STATS:
+                    LOG.trace("STAT-MANAGER-collecting METER-STATS for NodeRef {}", actualNodeRef);
+                    manager.getRpcMsgManager().getMeterFeaturesStat(actualNodeRef);
+                    waitingForNotification();
+                    manager.getRpcMsgManager().getAllMeterConfigStat(actualNodeRef);
+                    waitingForNotification();
+                    manager.getRpcMsgManager().getAllMetersStat(actualNodeRef);
+                    waitingForNotification();
+                    break;
+                case FLOW_STATS:
+                    LOG.trace("STAT-MANAGER-collecting FLOW-STATS-ALL_FLOWS for NodeRef {}", actualNodeRef);
+                    manager.getRpcMsgManager().getAllFlowsStat(actualNodeRef);
+                    waitingForNotification();
+                    LOG.trace("STAT-MANAGER-collecting FLOW-AGGREGATE-STATS for NodeRef {}", actualNodeRef);
+                    for (short i = 0; i < maxTables; i++) {
+                        final TableId tableId = new TableId(i);
+                        manager.getRpcMsgManager().getAggregateFlowStat(actualNodeRef, tableId);
+                    }
+                    break;
+                default:
+                    /* Exception for programmers in implementation cycle */
+                    throw new IllegalStateException("Not implemented ASK for " + statMarker);
+                }
+            }
+        }
+    }
+
+    private class StatNodeInfoHolder {
+        private final NodeRef nodeRef;
+        private final List<StatCapabTypes> statMarkers;
+        private final Short maxTables;
+
+        public StatNodeInfoHolder(final NodeRef nodeRef,
+                final List<StatCapabTypes> statMarkers, final Short maxTables) {
+            this.nodeRef = nodeRef;
+            this.maxTables = maxTables;
+            this.statMarkers = statMarkers;
+        }
+
+        public final NodeRef getNodeRef() {
+            return nodeRef;
+        }
+
+        public final List<StatCapabTypes> getStatMarkers() {
+            return statMarkers;
+        }
+
+        public final Short getMaxTables() {
+            return maxTables;
+        }
+    }
+
+    @Override
+    public boolean hasActiveNodes() {
+        return ( ! statNodeHolder.isEmpty());
+    }
+}
+
@@ -5,17 +5,17 @@
  * 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.statistics.manager;
-
-import java.util.Collection;
+package org.opendaylight.controller.md.statistics.manager.impl;
 
 import org.opendaylight.yangtools.yang.common.RpcError;
 
-final class RPCFailedException extends RuntimeException {
+import java.util.Collection;
+
+public final class StatRPCFailedException extends RuntimeException {
     private static final long serialVersionUID = 1L;
     private final Collection<RpcError> errors;
 
-    public RPCFailedException(final String message, final Collection<RpcError> errors) {
+    public StatRPCFailedException(final String message, final Collection<RpcError> errors) {
         super(message);
         this.errors = errors;
     }
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatRpcMsgManagerImpl.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatRpcMsgManagerImpl.java
new file mode 100644 (file)
index 0000000..e53f494
--- /dev/null
@@ -0,0 +1,510 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.SettableFuture;
+
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager.impl
+ *
+ * StatRpcMsgManagerImpl
+ * Class register and provide all RPC Statistics Device Services and implement pre-defined
+ * wrapped methods for prepare easy access to RPC Statistics Device Services like getAllStatisticsFor...
+ *
+ * In next Class implement process for joining multipart messages.
+ * Class internally use two WeakHashMap and GuavaCache for holding values for joining multipart msg.
+ * One Weak map is used for holding all Multipart Messages and second is used for possible input
+ * Config/DS light-weight DataObject (DataObject contains only necessary identification fields as
+ * TableId, GroupId, MeterId or for flow Match, Priority, FlowCookie, TableId and FlowId ...
+ *
+ * @author avishnoi@in.ibm.com <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
+
+    private final static Logger LOG = LoggerFactory.getLogger(StatRpcMsgManagerImpl.class);
+
+    private final Cache<String, TransactionCacheContainer<? super TransactionAware>> txCache;
+
+    private final long maxLifeForRequest = 50; /* 50 second */
+    private final int queueCapacity = 5000;
+
+    private final OpendaylightGroupStatisticsService groupStatsService;
+    private final OpendaylightMeterStatisticsService meterStatsService;
+    private final OpendaylightFlowStatisticsService flowStatsService;
+    private final OpendaylightPortStatisticsService portStatsService;
+    private final OpendaylightFlowTableStatisticsService flowTableStatsService;
+    private final OpendaylightQueueStatisticsService queueStatsService;
+
+    private BlockingQueue<RpcJobsQueue> statsRpcJobQueue;
+
+    private volatile boolean finishing = false;
+
+    public StatRpcMsgManagerImpl (final StatisticsManager manager,
+            final RpcConsumerRegistry rpcRegistry, final long minReqNetMonitInt) {
+        Preconditions.checkArgument(manager != null, "StatisticManager can not be null!");
+        Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
+        groupStatsService = Preconditions.checkNotNull(
+                rpcRegistry.getRpcService(OpendaylightGroupStatisticsService.class),
+                "OpendaylightGroupStatisticsService can not be null!");
+        meterStatsService = Preconditions.checkNotNull(
+                rpcRegistry.getRpcService(OpendaylightMeterStatisticsService.class),
+                "OpendaylightMeterStatisticsService can not be null!");
+        flowStatsService = Preconditions.checkNotNull(
+                rpcRegistry.getRpcService(OpendaylightFlowStatisticsService.class),
+                "OpendaylightFlowStatisticsService can not be null!");
+        portStatsService = Preconditions.checkNotNull(
+                rpcRegistry.getRpcService(OpendaylightPortStatisticsService.class),
+                "OpendaylightPortStatisticsService can not be null!");
+        flowTableStatsService = Preconditions.checkNotNull(
+                rpcRegistry.getRpcService(OpendaylightFlowTableStatisticsService.class),
+                "OpendaylightFlowTableStatisticsService can not be null!");
+        queueStatsService = Preconditions.checkNotNull(
+                rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class),
+                "OpendaylightQueueStatisticsService can not be null!");
+
+        statsRpcJobQueue = new LinkedBlockingQueue<>(queueCapacity);
+        txCache = CacheBuilder.newBuilder().expireAfterWrite(maxLifeForRequest, TimeUnit.SECONDS)
+                .maximumSize(10000).build();
+    }
+
+    @Override
+    public void close() {
+        finishing = true;
+        statsRpcJobQueue = null;
+    }
+
+    @Override
+    public void run() {
+         /* Neverending cyle - wait for finishing */
+        while ( ! finishing) {
+            try {
+                statsRpcJobQueue.take().call();
+            }
+            catch (final Exception e) {
+                LOG.warn("Stat Element RPC executor fail!", e);
+            }
+        }
+        // Drain all rpcCall, making sure any blocked threads are unblocked
+        while ( ! statsRpcJobQueue.isEmpty()) {
+            statsRpcJobQueue.poll();
+        }
+    }
+
+    private void addGetAllStatJob(final RpcJobsQueue getAllStatJob) {
+        final boolean success = statsRpcJobQueue.offer(getAllStatJob);
+        if ( ! success) {
+            LOG.warn("Put RPC request getAllStat fail! Queue is full.");
+        }
+    }
+
+    private void addStatJob(final RpcJobsQueue getStatJob) {
+        final boolean success = statsRpcJobQueue.offer(getStatJob);
+        if ( ! success) {
+            LOG.debug("Put RPC request for getStat fail! Queue is full.");
+        }
+    }
+
+    @Override
+    public <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(
+            final Future<RpcResult<T>> future, final D inputObj, final NodeRef nodeRef) {
+
+        Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),
+                new FutureCallback<RpcResult<? extends TransactionAware>>() {
+
+            @Override
+            public void onSuccess(final RpcResult<? extends TransactionAware> result) {
+                final TransactionId id = result.getResult().getTransactionId();
+                if (id == null) {
+                    LOG.warn("No protocol support");
+                } else {
+                    final NodeKey nodeKey = nodeRef.getValue().firstKeyOf(Node.class, NodeKey.class);
+                    final String cacheKey = buildCacheKey(id, nodeKey.getId());
+                    final TransactionCacheContainer<? super TransactionAware> container =
+                            new TransactionCacheContainerImpl<>(id, inputObj, nodeKey.getId());
+                    txCache.put(cacheKey, container);
+                }
+            }
+
+            @Override
+            public void onFailure(final Throwable t) {
+                LOG.warn("Response Registration for Statistics RPC call fail!", t);
+            }
+
+        });
+    }
+
+    private String buildCacheKey(final TransactionId id, final NodeId nodeId) {
+        return String.valueOf(id.getValue()) + "-" + nodeId.getValue();
+    }
+
+    @Override
+    public Future<Optional<TransactionCacheContainer<?>>> getTransactionCacheContainer(
+            final TransactionId id, final NodeId nodeId) {
+        Preconditions.checkArgument(id != null, "TransactionId can not be null!");
+        Preconditions.checkArgument(nodeId != null, "NodeId can not be null!");
+
+        final String key = buildCacheKey(id, nodeId);
+        final SettableFuture<Optional<TransactionCacheContainer<?>>> result = SettableFuture.create();
+
+        final RpcJobsQueue getTransactionCacheContainer = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final Optional<TransactionCacheContainer<?>> resultContainer =
+                        Optional.<TransactionCacheContainer<?>> fromNullable(txCache.getIfPresent(key));
+                if (resultContainer.isPresent()) {
+                    txCache.invalidate(key);
+                }
+                result.set(resultContainer);
+                return null;
+            }
+        };
+        addStatJob(getTransactionCacheContainer);
+        return result;
+    }
+
+    @Override
+    public Future<Boolean> isExpectedStatistics(final TransactionId id, final NodeId nodeId) {
+        Preconditions.checkArgument(id != null, "TransactionId can not be null!");
+        Preconditions.checkArgument(nodeId != null, "NodeId can not be null!");
+
+        final String key = buildCacheKey(id, nodeId);
+        final SettableFuture<Boolean> checkStatId = SettableFuture.create();
+
+        final RpcJobsQueue isExpecedStatistics = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final Optional<TransactionCacheContainer<?>> result =
+                        Optional.<TransactionCacheContainer<?>> fromNullable(txCache.getIfPresent(key));
+                checkStatId.set(Boolean.valueOf(result.isPresent()));
+                return null;
+            }
+        };
+        addStatJob(isExpecedStatistics);
+        return checkStatId;
+    }
+
+    @Override
+    public void addNotification(final TransactionAware notification, final NodeId nodeId) {
+        Preconditions.checkArgument(notification != null, "TransactionAware can not be null!");
+        Preconditions.checkArgument(nodeId != null, "NodeId can not be null!");
+
+        final RpcJobsQueue addNotification = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final TransactionId txId = notification.getTransactionId();
+                final String key = buildCacheKey(txId, nodeId);
+                final TransactionCacheContainer<? super TransactionAware> container = (txCache.getIfPresent(key));
+                if (container != null) {
+                    container.addNotif(notification);
+                }
+                return null;
+            }
+        };
+        addStatJob(addNotification);
+    }
+
+    @Override
+    public void getAllGroupsStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllGroupStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAllGroupStatisticsInputBuilder builder =
+                        new GetAllGroupStatisticsInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(groupStatsService
+                        .getAllGroupStatistics(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllGroupStat);
+    }
+
+    @Override
+    public void getAllMetersStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllMeterStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAllMeterStatisticsInputBuilder builder =
+                        new GetAllMeterStatisticsInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(meterStatsService
+                        .getAllMeterStatistics(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllMeterStat);
+    }
+
+    @Override
+    public void getAllFlowsStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllFlowStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder builder =
+                        new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(flowStatsService
+                        .getAllFlowsStatisticsFromAllFlowTables(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllFlowStat);
+    }
+
+    @Override
+    public void getAggregateFlowStat(final NodeRef nodeRef, final TableId tableId) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        Preconditions.checkArgument(tableId != null, "TableId can not be null!");
+        final RpcJobsQueue getAggregateFlowStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder builder =
+                        new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
+                builder.setNode(nodeRef);
+                builder.setTableId(tableId);
+
+                final TableBuilder tbuilder = new TableBuilder();
+                tbuilder.setId(tableId.getValue());
+                tbuilder.setKey(new TableKey(tableId.getValue()));
+                registrationRpcFutureCallBack(flowStatsService
+                        .getAggregateFlowStatisticsFromFlowTableForAllFlows(builder.build()), tbuilder.build(), nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAggregateFlowStat);
+    }
+
+    @Override
+    public void getAllPortsStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllPortsStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAllNodeConnectorsStatisticsInputBuilder builder =
+                        new GetAllNodeConnectorsStatisticsInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(portStatsService
+                        .getAllNodeConnectorsStatistics(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllPortsStat);
+    }
+
+    @Override
+    public void getAllTablesStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllTableStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetFlowTablesStatisticsInputBuilder builder =
+                        new GetFlowTablesStatisticsInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(flowTableStatsService
+                        .getFlowTablesStatistics(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllTableStat);
+    }
+
+    @Override
+    public void getAllQueueStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllQueueStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAllQueuesStatisticsFromAllPortsInputBuilder builder =
+                        new GetAllQueuesStatisticsFromAllPortsInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(queueStatsService
+                        .getAllQueuesStatisticsFromAllPorts(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllQueueStat);
+    }
+
+    @Override
+    public void getAllMeterConfigStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue qetAllMeterConfStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                final GetAllMeterConfigStatisticsInputBuilder builder =
+                        new GetAllMeterConfigStatisticsInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(meterStatsService
+                        .getAllMeterConfigStatistics(builder.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addGetAllStatJob(qetAllMeterConfStat);
+    }
+
+    @Override
+    public void getGroupFeaturesStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getGroupFeaturesStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                /* RPC input */
+                final GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
+                input.setNode(nodeRef);
+                registrationRpcFutureCallBack(groupStatsService.getGroupFeatures(input.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addStatJob(getGroupFeaturesStat);
+    }
+
+    @Override
+    public void getMeterFeaturesStat(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getMeterFeaturesStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                /* RPC input */
+                final GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
+                input.setNode(nodeRef);
+                registrationRpcFutureCallBack(meterStatsService.getMeterFeatures(input.build()), null, nodeRef);
+                return null;
+            }
+        };
+        addStatJob(getMeterFeaturesStat);
+    }
+
+    @Override
+    public void getAllGroupsConfStats(final NodeRef nodeRef) {
+        Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+        final RpcJobsQueue getAllGropConfStat = new RpcJobsQueue() {
+
+            @Override
+            public Void call() throws Exception {
+                Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+                final GetGroupDescriptionInputBuilder builder =
+                        new GetGroupDescriptionInputBuilder();
+                builder.setNode(nodeRef);
+                registrationRpcFutureCallBack(groupStatsService
+                        .getGroupDescription(builder.build()), null, nodeRef);
+
+                return null;
+            }
+        };
+        addGetAllStatJob(getAllGropConfStat);
+    }
+
+    public class TransactionCacheContainerImpl<T extends TransactionAware> implements TransactionCacheContainer<T> {
+
+        private final TransactionId id;
+        private final NodeId nId;
+        private final List<T> notifications;
+        private final Optional<? extends DataObject> confInput;
+
+        public <D extends DataObject> TransactionCacheContainerImpl (final TransactionId id, final D input, final NodeId nodeId) {
+            this.id = Preconditions.checkNotNull(id, "TransactionId can not be null!");
+            notifications = new CopyOnWriteArrayList<T>();
+            confInput = Optional.fromNullable(input);
+            nId = nodeId;
+        }
+
+        @Override
+        public void addNotif(final T notif) {
+            notifications.add(notif);
+        }
+
+        @Override
+        public TransactionId getId() {
+            return id;
+        }
+
+        @Override
+        public NodeId getNodeId() {
+            return nId;
+        }
+
+        @Override
+        public List<T> getNotifications() {
+            return notifications;
+        }
+
+        @Override
+        public Optional<? extends DataObject> getConfInput() {
+            return confInput;
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerImpl.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/impl/StatisticsManagerImpl.java
new file mode 100644 (file)
index 0000000..0f8030f
--- /dev/null
@@ -0,0 +1,347 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.ThreadFactory;
+
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.statistics.manager.StatListeningCommiter;
+import org.opendaylight.controller.md.statistics.manager.StatNodeRegistration;
+import org.opendaylight.controller.md.statistics.manager.StatNotifyCommiter;
+import org.opendaylight.controller.md.statistics.manager.StatPermCollector;
+import org.opendaylight.controller.md.statistics.manager.StatPermCollector.StatCapabTypes;
+import org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManager;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+/**
+* statistics-manager
+* org.opendaylight.controller.md.statistics.manager.impl
+*
+* StatisticsManagerImpl
+* It represent a central point for whole module. Implementation
+* {@link StatisticsManager} registers all Operation/DS {@link StatNotifyCommiter} and
+* Config/DS {@StatListeningCommiter}, as well as {@link StatPermCollector}
+* for statistic collecting and {@link StatRpcMsgManager} as Device RPCs provider.
+* In next, StatisticsManager provides all DS contact Transaction services.
+*
+* @author avishnoi@in.ibm.com <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+*
+*/
+public class StatisticsManagerImpl implements StatisticsManager, Runnable {
+
+   private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class);
+
+   private static final int QUEUE_DEPTH = 5000;
+   private static final int MAX_BATCH = 100;
+
+   private final BlockingQueue<StatDataStoreOperation> dataStoreOperQueue = new LinkedBlockingDeque<>(QUEUE_DEPTH);
+
+   private final DataBroker dataBroker;
+   private final int maxNodesForCollectors;
+   private long minReqNetMonitInt;
+   private final ExecutorService statRpcMsgManagerExecutor;
+   private final ExecutorService statDataStoreOperationServ;
+   private StatRpcMsgManager rpcMsgManager;
+   private List<StatPermCollector> statCollectors;
+   private final Object statCollectorLock = new Object();
+   private BindingTransactionChain txChain;
+   private volatile boolean finishing = false;
+
+   private StatNodeRegistration nodeRegistrator;
+   private StatListeningCommiter<Flow, OpendaylightFlowStatisticsListener> flowListeningCommiter;
+   private StatListeningCommiter<Meter, OpendaylightMeterStatisticsListener> meterListeningCommiter;
+   private StatListeningCommiter<Group, OpendaylightGroupStatisticsListener> groupListeningCommiter;
+   private StatListeningCommiter<Queue, OpendaylightQueueStatisticsListener> queueNotifyCommiter;
+   private StatNotifyCommiter<OpendaylightFlowTableStatisticsListener> tableNotifCommiter;
+   private StatNotifyCommiter<OpendaylightPortStatisticsListener> portNotifyCommiter;
+
+   public StatisticsManagerImpl (final DataBroker dataBroker, final int maxNodesForCollector) {
+       this.dataBroker = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
+       ThreadFactory threadFact;
+       threadFact = new ThreadFactoryBuilder().setNameFormat("odl-stat-rpc-oper-thread-%d").build();
+       statRpcMsgManagerExecutor = Executors.newSingleThreadExecutor(threadFact);
+       threadFact = new ThreadFactoryBuilder().setNameFormat("odl-stat-ds-oper-thread-%d").build();
+       statDataStoreOperationServ = Executors.newSingleThreadExecutor(threadFact);
+       maxNodesForCollectors = maxNodesForCollector;
+       txChain =  dataBroker.createTransactionChain(this);
+   }
+
+   @Override
+   public void start(final NotificationProviderService notifService,
+           final RpcConsumerRegistry rpcRegistry, final long minReqNetMonitInt) {
+       Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
+       this.minReqNetMonitInt = minReqNetMonitInt;
+       rpcMsgManager = new StatRpcMsgManagerImpl(this, rpcRegistry, minReqNetMonitInt);
+       statCollectors = Collections.emptyList();
+       nodeRegistrator = new StatNodeRegistrationImpl(this, dataBroker, notifService);
+       flowListeningCommiter = new StatListenCommitFlow(this, dataBroker, notifService);
+       meterListeningCommiter = new StatListenCommitMeter(this, dataBroker, notifService);
+       groupListeningCommiter = new StatListenCommitGroup(this, dataBroker, notifService);
+       tableNotifCommiter = new StatNotifyCommitTable(this, notifService);
+       portNotifyCommiter = new StatNotifyCommitPort(this, notifService);
+       queueNotifyCommiter = new StatListenCommitQueue(this, dataBroker, notifService);
+
+       statRpcMsgManagerExecutor.execute(rpcMsgManager);
+       statDataStoreOperationServ.execute(this);
+       LOG.info("Statistics Manager started successfully!");
+   }
+
+   @Override
+   public void close() throws Exception {
+       finishing = true;
+       if (nodeRegistrator != null) {
+           nodeRegistrator.close();
+           nodeRegistrator = null;
+       }
+       if (flowListeningCommiter != null) {
+           flowListeningCommiter.close();
+           flowListeningCommiter = null;
+       }
+       if (meterListeningCommiter != null) {
+           meterListeningCommiter.close();
+           meterListeningCommiter = null;
+       }
+       if (groupListeningCommiter != null) {
+           groupListeningCommiter.close();
+           groupListeningCommiter = null;
+       }
+       if (tableNotifCommiter != null) {
+           tableNotifCommiter.close();
+           tableNotifCommiter = null;
+       }
+       if (portNotifyCommiter != null) {
+           portNotifyCommiter.close();
+           portNotifyCommiter = null;
+       }
+       if (queueNotifyCommiter != null) {
+           queueNotifyCommiter.close();
+           queueNotifyCommiter = null;
+       }
+       if (statCollectors != null) {
+           for (StatPermCollector collector : statCollectors) {
+               collector.close();
+               collector = null;
+           }
+           statCollectors = null;
+       }
+       if (rpcMsgManager != null) {
+           rpcMsgManager.close();
+           rpcMsgManager = null;
+       }
+       statRpcMsgManagerExecutor.shutdown();
+       statDataStoreOperationServ.shutdown();
+       if (txChain != null) {
+           txChain.close();
+           txChain = null;
+       }
+   }
+
+   @Override
+   public void enqueue(final StatDataStoreOperation op) {
+       // we don't need to block anything - next statistics come soon
+       final boolean success = dataStoreOperQueue.offer(op);
+       if ( ! success) {
+           LOG.debug("Stat DS/Operational submiter Queue is full!");
+       }
+   }
+
+   @Override
+   public void run() {
+       /* Neverending cyle - wait for finishing */
+       while ( ! finishing) {
+           try {
+               StatDataStoreOperation op = dataStoreOperQueue.take();
+               final ReadWriteTransaction tx = txChain.newReadWriteTransaction();
+               LOG.trace("New operations available, starting transaction {}", tx.getIdentifier());
+
+               int ops = 0;
+               do {
+                   op.applyOperation(tx);
+
+                   ops++;
+                   if (ops < MAX_BATCH) {
+                       op = dataStoreOperQueue.poll();
+                   } else {
+                       op = null;
+                   }
+               } while (op != null);
+
+               LOG.trace("Processed {} operations, submitting transaction {}", ops, tx.getIdentifier());
+
+                   tx.submit().checkedGet();
+           } catch (final InterruptedException e) {
+               LOG.warn("Stat Manager DS Operation thread interupted!", e);
+               finishing = true;
+           } catch (final Exception e) {
+               LOG.warn("Unhandled exception during processing statistics. Restarting transaction chain.", e);
+               txChain.close();
+               txChain = dataBroker.createTransactionChain(StatisticsManagerImpl.this);
+               cleanDataStoreOperQueue();
+           }
+       }
+       // Drain all events, making sure any blocked threads are unblocked
+       cleanDataStoreOperQueue();
+   }
+
+   private synchronized void cleanDataStoreOperQueue() {
+       // Drain all events, making sure any blocked threads are unblocked
+       while (! dataStoreOperQueue.isEmpty()) {
+           dataStoreOperQueue.poll();
+       }
+   }
+
+   @Override
+   public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
+           final Throwable cause) {
+       LOG.warn("Failed to export Flow Capable Statistics, Transaction {} failed.",transaction.getIdentifier(),cause);
+   }
+
+   @Override
+   public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+       // NOOP
+   }
+
+   @Override
+   public boolean isProvidedFlowNodeActive(final InstanceIdentifier<Node> nodeIdent) {
+       for (final StatPermCollector collector : statCollectors) {
+           if (collector.isProvidedFlowNodeActive(nodeIdent)) {
+               return true;
+           }
+       }
+       return false;
+   }
+
+   @Override
+   public void collectNextStatistics(final InstanceIdentifier<Node> nodeIdent) {
+       for (final StatPermCollector collector : statCollectors) {
+           if (collector.isProvidedFlowNodeActive(nodeIdent)) {
+               collector.collectNextStatistics();
+           }
+       }
+   }
+
+   @Override
+   public void connectedNodeRegistration(final InstanceIdentifier<Node> nodeIdent,
+           final List<StatCapabTypes> statTypes, final Short nrOfSwitchTables) {
+       for (final StatPermCollector collector : statCollectors) {
+           if (collector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
+               return;
+           }
+       }
+       synchronized (statCollectorLock) {
+           for (final StatPermCollector collector : statCollectors) {
+               if (collector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
+                   return;
+               }
+           }
+           final StatPermCollectorImpl newCollector = new StatPermCollectorImpl(this,
+                   minReqNetMonitInt, statCollectors.size() + 1, maxNodesForCollectors);
+           final List<StatPermCollector> statCollectorsNew = new ArrayList<>(statCollectors);
+           newCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
+           statCollectorsNew.add(newCollector);
+           statCollectors = Collections.unmodifiableList(statCollectorsNew);
+       }
+   }
+
+   @Override
+   public void disconnectedNodeUnregistration(final InstanceIdentifier<Node> nodeIdent) {
+       flowListeningCommiter.cleanForDisconnect(nodeIdent);
+
+       for (final StatPermCollector collector : statCollectors) {
+           if (collector.disconnectedNodeUnregistration(nodeIdent)) {
+               if ( ! collector.hasActiveNodes()) {
+                   synchronized (statCollectorLock) {
+                       if (collector.hasActiveNodes()) {
+                           return;
+                       }
+                       final List<StatPermCollector> newStatColl =
+                               new ArrayList<>(statCollectors);
+                       newStatColl.remove(collector);
+                       statCollectors = Collections.unmodifiableList(newStatColl);
+                   }
+               }
+               return;
+           }
+       }
+       LOG.debug("Node {} has not removed.", nodeIdent);
+   }
+
+   /* Getter internal Statistic Manager Job Classes */
+   @Override
+   public StatRpcMsgManager getRpcMsgManager() {
+       return rpcMsgManager;
+   }
+
+   @Override
+   public StatNodeRegistration getNodeRegistrator() {
+       return nodeRegistrator;
+   }
+
+   @Override
+   public StatListeningCommiter<Flow, OpendaylightFlowStatisticsListener> getFlowListenComit() {
+       return flowListeningCommiter;
+   }
+
+   @Override
+   public StatListeningCommiter<Meter, OpendaylightMeterStatisticsListener> getMeterListenCommit() {
+       return meterListeningCommiter;
+   }
+
+   @Override
+   public StatListeningCommiter<Group, OpendaylightGroupStatisticsListener> getGroupListenCommit() {
+       return groupListeningCommiter;
+   }
+
+   @Override
+   public StatListeningCommiter<Queue, OpendaylightQueueStatisticsListener> getQueueNotifyCommit() {
+       return queueNotifyCommiter;
+   }
+
+
+   @Override
+   public StatNotifyCommiter<OpendaylightFlowTableStatisticsListener> getTableNotifCommit() {
+       return tableNotifCommiter;
+   }
+
+   @Override
+   public StatNotifyCommiter<OpendaylightPortStatisticsListener> getPortNotifyCommit() {
+       return portNotifyCommiter;
+   }
+}
+
@@ -5,15 +5,14 @@
  * 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.statistics.manager;
+package org.opendaylight.controller.md.statistics.manager.impl.helper;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.net.InetAddresses;
 import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.MacAddressFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
@@ -22,19 +21,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
-
 /**
  * Utility class for comparing flows.
  */
-final class FlowComparator {
-    private final static Logger logger = LoggerFactory.getLogger(FlowComparator.class);
+public final class FlowComparator {
+    private final static Logger LOG = LoggerFactory.getLogger(FlowComparator.class);
 
     private FlowComparator() {
-
+        throw new UnsupportedOperationException("Utilities class should not be instantiated");
     }
 
-    public static boolean flowEquals(Flow statsFlow, Flow storedFlow) {
+    public static boolean flowEquals(final Flow statsFlow, final Flow storedFlow) {
         if (statsFlow == null || storedFlow == null) {
             return false;
         }
@@ -93,7 +90,7 @@ final class FlowComparator {
      * @param storedFlow
      * @return
      */
-    public static boolean matchEquals(Match statsFlow, Match storedFlow) {
+    public static boolean matchEquals(final Match statsFlow, final Match storedFlow) {
         if (statsFlow == storedFlow) {
             return true;
         }
@@ -194,9 +191,9 @@ final class FlowComparator {
      * statistic data, openflow driver library returns AA:BB:CC:DD:EE:FF and default eqauls fails here.
      */
     @VisibleForTesting
-    static boolean ethernetMatchEquals(EthernetMatch statsEthernetMatch, EthernetMatch storedEthernetMatch){
+    static boolean ethernetMatchEquals(final EthernetMatch statsEthernetMatch, final EthernetMatch storedEthernetMatch){
         boolean verdict = true;
-        Boolean checkNullValues = checkNullValues(statsEthernetMatch, storedEthernetMatch);
+        final Boolean checkNullValues = checkNullValues(statsEthernetMatch, storedEthernetMatch);
         if (checkNullValues != null) {
             verdict = checkNullValues;
         } else {
@@ -219,10 +216,10 @@ final class FlowComparator {
         return verdict;
     }
 
-    private static boolean ethernetMatchFieldsEquals(MacAddressFilter statsEthernetMatchFields,
-                                                        MacAddressFilter storedEthernetMatchFields){
+    private static boolean ethernetMatchFieldsEquals(final MacAddressFilter statsEthernetMatchFields,
+                                                        final MacAddressFilter storedEthernetMatchFields){
         boolean verdict = true;
-        Boolean checkNullValues = checkNullValues(statsEthernetMatchFields, storedEthernetMatchFields);
+        final Boolean checkNullValues = checkNullValues(statsEthernetMatchFields, storedEthernetMatchFields);
         if (checkNullValues != null) {
             verdict = checkNullValues;
         } else {
@@ -236,9 +233,9 @@ final class FlowComparator {
         return verdict;
     }
 
-    private static boolean macAddressEquals(MacAddress statsMacAddress, MacAddress storedMacAddress){
+    private static boolean macAddressEquals(final MacAddress statsMacAddress, final MacAddress storedMacAddress){
         boolean verdict = true;
-        Boolean checkNullValues = checkNullValues(statsMacAddress, storedMacAddress);
+        final Boolean checkNullValues = checkNullValues(statsMacAddress, storedMacAddress);
         if (checkNullValues != null) {
             verdict = checkNullValues;
         } else {
@@ -248,11 +245,11 @@ final class FlowComparator {
     }
 
     @VisibleForTesting
-    static boolean layer3MatchEquals(Layer3Match statsLayer3Match, Layer3Match storedLayer3Match){
+    static boolean layer3MatchEquals(final Layer3Match statsLayer3Match, final Layer3Match storedLayer3Match){
         boolean verdict = true;
         if(statsLayer3Match instanceof Ipv4Match && storedLayer3Match instanceof Ipv4Match){
-            Ipv4Match statsIpv4Match = (Ipv4Match)statsLayer3Match;
-            Ipv4Match storedIpv4Match = (Ipv4Match)storedLayer3Match;
+            final Ipv4Match statsIpv4Match = (Ipv4Match)statsLayer3Match;
+            final Ipv4Match storedIpv4Match = (Ipv4Match)storedLayer3Match;
 
             if (verdict) {
                 verdict = compareNullSafe(
@@ -263,7 +260,7 @@ final class FlowComparator {
                         statsIpv4Match.getIpv4Source(), storedIpv4Match.getIpv4Source());
             }
         } else {
-            Boolean nullCheckOut = checkNullValues(storedLayer3Match, statsLayer3Match);
+            final Boolean nullCheckOut = checkNullValues(storedLayer3Match, statsLayer3Match);
             if (nullCheckOut != null) {
                 verdict = nullCheckOut;
             } else {
@@ -274,9 +271,9 @@ final class FlowComparator {
         return verdict;
     }
 
-    private static boolean compareNullSafe(Ipv4Prefix statsIpv4, Ipv4Prefix storedIpv4) {
+    private static boolean compareNullSafe(final Ipv4Prefix statsIpv4, final Ipv4Prefix storedIpv4) {
         boolean verdict = true;
-        Boolean checkDestNullValuesOut = checkNullValues(storedIpv4, statsIpv4);
+        final Boolean checkDestNullValuesOut = checkNullValues(storedIpv4, statsIpv4);
         if (checkDestNullValuesOut != null) {
             verdict = checkDestNullValuesOut;
         } else if(!IpAddressEquals(statsIpv4, storedIpv4)){
@@ -286,7 +283,7 @@ final class FlowComparator {
         return verdict;
     }
 
-    private static Boolean checkNullValues(Object v1, Object v2) {
+    private static Boolean checkNullValues(final Object v1, final Object v2) {
         Boolean verdict = null;
         if (v1 == null && v2 != null) {
             verdict = Boolean.FALSE;
@@ -306,9 +303,9 @@ final class FlowComparator {
      * @param storedIpAddress
      * @return true if IPv4prefixes equals
      */
-    private static boolean IpAddressEquals(Ipv4Prefix statsIpAddress, Ipv4Prefix storedIpAddress) {
-        IntegerIpAddress statsIpAddressInt = StrIpToIntIp(statsIpAddress.getValue());
-        IntegerIpAddress storedIpAddressInt = StrIpToIntIp(storedIpAddress.getValue());
+    private static boolean IpAddressEquals(final Ipv4Prefix statsIpAddress, final Ipv4Prefix storedIpAddress) {
+        final IntegerIpAddress statsIpAddressInt = StrIpToIntIp(statsIpAddress.getValue());
+        final IntegerIpAddress storedIpAddressInt = StrIpToIntIp(storedIpAddress.getValue());
 
         if(IpAndMaskBasedMatch(statsIpAddressInt,storedIpAddressInt)){
             return true;
@@ -319,11 +316,11 @@ final class FlowComparator {
         return false;
     }
 
-    private static boolean IpAndMaskBasedMatch(IntegerIpAddress statsIpAddressInt,IntegerIpAddress storedIpAddressInt){
+    private static boolean IpAndMaskBasedMatch(final IntegerIpAddress statsIpAddressInt,final IntegerIpAddress storedIpAddressInt){
         return ((statsIpAddressInt.getIp() & statsIpAddressInt.getMask()) ==  (storedIpAddressInt.getIp() & storedIpAddressInt.getMask()));
     }
 
-    private static boolean IpBasedMatch(IntegerIpAddress statsIpAddressInt,IntegerIpAddress storedIpAddressInt){
+    private static boolean IpBasedMatch(final IntegerIpAddress statsIpAddressInt,final IntegerIpAddress storedIpAddressInt){
         return (statsIpAddressInt.getIp() == storedIpAddressInt.getIp());
     }
 
@@ -331,10 +328,10 @@ final class FlowComparator {
      * Method return integer version of ip address. Converted int will be mask if
      * mask specified
      */
-    private static IntegerIpAddress StrIpToIntIp(String ipAddresss){
+    private static IntegerIpAddress StrIpToIntIp(final String ipAddresss){
 
-        String[] parts = ipAddresss.split("/");
-        String ip = parts[0];
+        final String[] parts = ipAddresss.split("/");
+        final String ip = parts[0];
         int prefix;
 
         if (parts.length < 2) {
@@ -344,20 +341,19 @@ final class FlowComparator {
         }
 
         IntegerIpAddress integerIpAddress = null;
-        try {
-            Inet4Address addr = (Inet4Address) InetAddress.getByName(ip);
-            byte[] addrBytes = addr.getAddress();
-            int ipInt = ((addrBytes[0] & 0xFF) << 24) |
+
+            final Inet4Address addr = ((Inet4Address) InetAddresses.forString(ip));
+            final byte[] addrBytes = addr.getAddress();
+            final int ipInt = ((addrBytes[0] & 0xFF) << 24) |
                     ((addrBytes[1] & 0xFF) << 16) |
                     ((addrBytes[2] & 0xFF) << 8)  |
                     ((addrBytes[3] & 0xFF) << 0);
 
-            int mask = 0xffffffff << 32 - prefix;
+            // FIXME: Is this valid?
+            final int mask = 0xffffffff << 32 - prefix;
 
             integerIpAddress = new IntegerIpAddress(ipInt, mask);
-        } catch (UnknownHostException e){
-            logger.error("Failed to determine host IP address by name: {}", e.getMessage(), e);
-        }
+
 
         return integerIpAddress;
     }
@@ -365,7 +361,7 @@ final class FlowComparator {
     private static class IntegerIpAddress{
         int ip;
         int mask;
-        public IntegerIpAddress(int ip, int mask) {
+        public IntegerIpAddress(final int ip, final int mask) {
             this.ip = ip;
             this.mask = mask;
         }
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerProvider.java b/opendaylight/md-sal/statistics-manager/src/test/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerProvider.java
new file mode 100644 (file)
index 0000000..6a01cd2
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+/**
+ * statistics-manager
+ * org.opendaylight.controller.md.statistics.manager
+ *
+ *
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Sep 6, 2014
+ */
+public class StatisticsManagerProvider {
+
+    private final StatisticsManagerActivator activator;
+
+    public StatisticsManagerProvider(final StatisticsManagerActivator activator) {
+        this.activator = activator;
+    }
+
+    /**
+     * Method provides Initialized {@link StatisticsManager}
+     * from {@link StatisticsManagerActivator} for all tests
+     * suites;
+     *
+     * @return
+     */
+    public StatisticsManager getStatisticsManager() {
+        return activator.getStatisticManager();
+    }
+}
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.controller.md.statistics.manager;
+package org.opendaylight.controller.md.statistics.manager.impl.helper;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -35,7 +35,7 @@ public class StatisticsUpdateCommiterTest {
      */
     @Test
     public void testLayer3MatchEquals() {
-        String[][][] matchSeeds = new String[][][] {
+        final String[][][] matchSeeds = new String[][][] {
                 {{"10.1.2.0/24", "10.1.2.0/24"}, {"10.1.2.0/24", "10.1.2.0/24"}},
                 {{"10.1.2.0/24", "10.1.2.0/24"}, {"10.1.2.0/24", "10.1.1.0/24"}},
                 {{"10.1.1.0/24", "10.1.2.0/24"}, {"10.1.2.0/24", "10.1.2.0/24"}},
@@ -55,7 +55,7 @@ public class StatisticsUpdateCommiterTest {
                 {{null, null}, {null, null}},
         };
 
-        boolean[] matches = new boolean[] {
+        final boolean[] matches = new boolean[] {
                 true,
                 false,
                 false,
@@ -91,23 +91,23 @@ public class StatisticsUpdateCommiterTest {
      * @param matches expected match output
      *
      */
-    private static void checkComparisonOfL3Match(String m1Source, String m1Destination,
-            String m2Source, String msDestination, boolean matches) {
-        Ipv4Match m1Layer3 = prepareIPv4Match(m1Source, m1Destination);
-        Ipv4Match m2Layer3 = prepareIPv4Match(m2Source, msDestination);
+    private static void checkComparisonOfL3Match(final String m1Source, final String m1Destination,
+            final String m2Source, final String msDestination, final boolean matches) {
+        final Ipv4Match m1Layer3 = prepareIPv4Match(m1Source, m1Destination);
+        final Ipv4Match m2Layer3 = prepareIPv4Match(m2Source, msDestination);
         boolean comparisonResult;
         try {
             comparisonResult = FlowComparator.layer3MatchEquals(m1Layer3, m2Layer3);
             Assert.assertEquals("failed to compare: "+m1Layer3+" vs. "+m2Layer3,
                     matches, comparisonResult);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("failed to compare: {} vs. {}", m1Layer3, m2Layer3, e);
             Assert.fail(e.getMessage());
         }
     }
 
-    private static Ipv4Match prepareIPv4Match(String source, String destination) {
-        Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+    private static Ipv4Match prepareIPv4Match(final String source, final String destination) {
+        final Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
         if (source != null) {
             ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(source));
         }
@@ -118,11 +118,11 @@ public class StatisticsUpdateCommiterTest {
         return ipv4MatchBuilder.build();
     }
     /**
-     * Test method for {@link org.opendaylight.controller.md.statistics.manager.FlowComparator#ethernetMatchEquals(EthernetMatch, EthernetMatch)
+     * Test method for {@link org.opendaylight.controller.md.statistics.manager.impl.helper.FlowComparator#ethernetMatchEquals(EthernetMatch, EthernetMatch)
      */
     @Test
     public void testEthernetMatchEquals() {
-        String[][][] ethernetMatchSeeds = new String[][][] {
+        final String[][][] ethernetMatchSeeds = new String[][][] {
                 {{"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}},
                 {{"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"aa:bb:bc:cd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}},
                 {{"aa:bb:cc:dd:ee:ff", "ff:ff:ff:ff:ff:ff","0800"}, {"AA:BB:CC:DD:EE:FF", "ff:ff:ff:ff:ff:ff","0800"}},
@@ -143,7 +143,7 @@ public class StatisticsUpdateCommiterTest {
                 {{null, null,null}, {null, null,null}},
         };
 
-        boolean[] matches = new boolean[] {
+        final boolean[] matches = new boolean[] {
                 true,
                 false,
                 true,
@@ -176,24 +176,24 @@ public class StatisticsUpdateCommiterTest {
      * @param ethernetMatch1
      * @param ethernetMatch2
      */
-    private static void checkComparisonOfEthernetMatch(String macAddress1, String macAddressMask1,String etherType1,
-            String macAddress2, String macAddressMask2,String etherType2, boolean expectedResult) {
-        EthernetMatch ethernetMatch1 = prepareEthernetMatch(macAddress1, macAddressMask1,etherType1);
-        EthernetMatch ethernetMatch2 = prepareEthernetMatch(macAddress2, macAddressMask2,etherType2);
+    private static void checkComparisonOfEthernetMatch(final String macAddress1, final String macAddressMask1,final String etherType1,
+            final String macAddress2, final String macAddressMask2,final String etherType2, final boolean expectedResult) {
+        final EthernetMatch ethernetMatch1 = prepareEthernetMatch(macAddress1, macAddressMask1,etherType1);
+        final EthernetMatch ethernetMatch2 = prepareEthernetMatch(macAddress2, macAddressMask2,etherType2);
         boolean comparisonResult;
         try {
             comparisonResult = FlowComparator.ethernetMatchEquals(ethernetMatch1, ethernetMatch2);
             Assert.assertEquals("failed to compare: "+ethernetMatch1+" vs. "+ethernetMatch2,
                     expectedResult, comparisonResult);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("failed to compare: {} vs. {}", ethernetMatch1, ethernetMatch2, e);
             Assert.fail(e.getMessage());
         }
     }
 
-    private static EthernetMatch prepareEthernetMatch(String macAddress, String macAddressMask, String etherType) {
-        EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
-        EthernetSourceBuilder ethernetSourceBuilder =  new EthernetSourceBuilder();
+    private static EthernetMatch prepareEthernetMatch(final String macAddress, final String macAddressMask, final String etherType) {
+        final EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
+        final EthernetSourceBuilder ethernetSourceBuilder =  new EthernetSourceBuilder();
         if (macAddress != null) {
             ethernetSourceBuilder.setAddress(new MacAddress(macAddress));
         }
@@ -201,7 +201,7 @@ public class StatisticsUpdateCommiterTest {
             ethernetSourceBuilder.setMask(new MacAddress(macAddressMask));
         }
         if(etherType != null){
-            EthernetTypeBuilder ethernetType = new EthernetTypeBuilder();
+            final EthernetTypeBuilder ethernetType = new EthernetTypeBuilder();
             ethernetType.setType(new EtherType(Long.parseLong(etherType,16)));
             ethernetMatchBuilder.setEthernetType(ethernetType.build());
         }
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java
new file mode 100644 (file)
index 0000000..7fc171c
--- /dev/null
@@ -0,0 +1,159 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+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.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+import com.google.common.base.Optional;
+
+public class FlowStatisticsTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+//    @Test(timeout = 5000)
+    public void addedFlowOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Flow flow = getFlow();
+
+        final InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()))
+                .child(Flow.class, flow.getKey());
+        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
+        final Table table = new TableBuilder().setKey(new TableKey(flow.getTableId())).setFlow(Collections.<Flow>emptyList()).build();
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, tableII, table);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowII, flow);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                flowII.augmentation(FlowStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<FlowStatisticsData> flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII.augmentation(FlowStatisticsData.class))
+                .checkedGet();
+        assertTrue(flowStatDataOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE, flowStatDataOptional.get().getFlowStatistics().getByteCount());
+
+    }
+
+//    @Test(timeout = 5000)
+    public void deletedFlowStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Flow flow = getFlow();
+
+        final InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()))
+                .child(Flow.class, flow.getKey());
+        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
+        final Table table = new TableBuilder().setKey(new TableKey(flow.getTableId())).setFlow(Collections.<Flow>emptyList()).build();
+
+        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, tableII, table);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowII, flow);
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                flowII.augmentation(FlowStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        assertCommit(writeTx.submit());
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        Optional<Flow> flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII).checkedGet();
+        assertTrue(flowStatDataOptional.isPresent());
+//        assertEquals(COUNTER_64_TEST_VALUE, flowStatDataOptional.get().getFlowStatistics().getByteCount());
+
+        writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.delete(LogicalDatastoreType.CONFIGURATION, flowII);
+        assertCommit(writeTx.submit());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII).checkedGet();
+        assertFalse(flowStatDataOptional.isPresent());
+    }
+
+//    @Test(timeout = 23000)
+    public void getAllStatsWhenNodeIsConnectedTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityFlowStats.class);
+
+        final Flow flow = getFlow();
+
+        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId()));
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                tableII.child(Flow.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Table> tableOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(flow.getTableId()))).checkedGet();
+        assertTrue(tableOptional.isPresent());
+        final FlowStatisticsData flowStats = tableOptional.get().getFlow().get(0).getAugmentation(FlowStatisticsData.class);
+        assertTrue(flowStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, flowStats.getFlowStatistics().getByteCount());
+    }
+
+    public class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/GroupStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/GroupStatisticsTest.java
new file mode 100644 (file)
index 0000000..7a61bf2
--- /dev/null
@@ -0,0 +1,151 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+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.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityGroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+import com.google.common.base.Optional;
+
+public class GroupStatisticsTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+//    @Test(timeout = 5000)
+    public void addedGroupOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Group group = getGroup();
+
+        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Group.class, group.getKey());
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, groupII, group);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<NodeGroupStatistics> groupOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, groupII.augmentation(NodeGroupStatistics.class)).checkedGet();
+        assertTrue(groupOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE, groupOptional.get().getGroupStatistics().getByteCount());
+    }
+
+//    @Test(timeout = 5000)
+    public void deletedGroupStasRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Group group = getGroup();
+        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Group.class, group.getKey());
+
+        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, groupII, group);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        Optional<NodeGroupStatistics> groupOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class)).checkedGet();
+        assertTrue(groupOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE, groupOptional.get().getGroupStatistics().getByteCount());
+
+        writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.delete(LogicalDatastoreType.CONFIGURATION, groupII);
+        assertCommit(writeTx.submit());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        groupOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class)).checkedGet();
+        assertFalse(groupOptional.isPresent());
+
+    }
+
+//    @Test(timeout = 23000)
+    public void getAllStatsFromConnectedNodeTest() throws ExecutionException, InterruptedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityGroupStats.class);
+
+        final InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Group.class, getGroup().getKey());
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                groupII.augmentation(NodeGroupStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Group> optionalGroup = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Group.class, getGroup().getKey())).get();
+
+        assertTrue(optionalGroup.isPresent());
+        assertTrue(optionalGroup.get().getAugmentation(NodeGroupDescStats.class) != null);
+        final NodeGroupStatistics groupStats = optionalGroup.get().getAugmentation(NodeGroupStatistics.class);
+        assertTrue(groupStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, groupStats.getGroupStatistics().getByteCount());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<GroupFeatures> optionalGroupFeatures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(NodeGroupFeatures.class).child(GroupFeatures.class)).get();
+        assertTrue(optionalGroupFeatures.isPresent());
+        assertEquals(1, optionalGroupFeatures.get().getMaxGroups().size());
+        assertEquals(MAX_GROUPS_TEST_VALUE, optionalGroupFeatures.get().getMaxGroups().get(0));
+    }
+
+    private class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/MeterStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/MeterStatisticsTest.java
new file mode 100644 (file)
index 0000000..a0f360c
--- /dev/null
@@ -0,0 +1,150 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+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.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeatures;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+import com.google.common.base.Optional;
+
+public class MeterStatisticsTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+//    @Test(timeout = 5000)
+    public void addedMeterOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Meter meter = getMeter();
+        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Meter.class, meter.getKey());
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, meterII, meter);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<NodeMeterStatistics> meterStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                meterII.augmentation(NodeMeterStatistics.class)).checkedGet();
+        assertTrue(meterStatsOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getByteInCount());
+        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getPacketInCount());
+    }
+
+//    @Test(timeout = 5000)
+    public void deletedMeterStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Meter meter = getMeter();
+        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Meter.class, meter.getKey());
+
+        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, meterII, meter);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<NodeMeterStatistics> meterStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                meterII.augmentation(NodeMeterStatistics.class)).checkedGet();
+        assertTrue(meterStatsOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getByteInCount());
+        assertEquals(COUNTER_64_TEST_VALUE, meterStatsOptional.get().getMeterStatistics().getPacketInCount());
+
+        writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.delete(LogicalDatastoreType.CONFIGURATION, meterII);
+        assertCommit(writeTx.submit());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Meter> meterOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, meterII).checkedGet();
+        assertFalse(meterOptional.isPresent());
+    }
+
+//    @Test(timeout = 23000)
+    public void getAllStatsFromConnectedNodeTest() throws ExecutionException, InterruptedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNodeWithFeatures(s1Key, true);
+
+        final InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Meter.class, getMeter().getKey());
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                meterII.augmentation(NodeMeterStatistics.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Meter> optionalMeter = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(FlowCapableNode.class)
+                .child(Meter.class, getMeter().getKey())).get();
+
+        assertTrue(optionalMeter.isPresent());
+        assertTrue(optionalMeter.get().getAugmentation(NodeMeterConfigStats.class) != null);
+        final NodeMeterStatistics meterStats = optionalMeter.get().getAugmentation(NodeMeterStatistics.class);
+        assertTrue(meterStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE, meterStats.getMeterStatistics().getByteInCount());
+        assertEquals(COUNTER_64_TEST_VALUE, meterStats.getMeterStatistics().getPacketInCount());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<MeterFeatures> optionalMeterFeautures = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).augmentation(NodeMeterFeatures.class).child(MeterFeatures.class)).get();
+        assertTrue(optionalMeterFeautures.isPresent());
+        assertEquals(COUNTER_32_TEST_VALUE, optionalMeterFeautures.get().getMaxMeter());
+    }
+
+    private class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/NodeRegistrationTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/NodeRegistrationTest.java
new file mode 100644 (file)
index 0000000..18bd2d4
--- /dev/null
@@ -0,0 +1,48 @@
+package test.mock;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.controller.md.statistics.manager.StatisticsManagerProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+public class NodeRegistrationTest extends StatisticsManagerTest {
+
+//    @Test
+    public void nodeRegistrationTest() throws ExecutionException, InterruptedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        final StatisticsManagerProvider statisticsManagerProvider = new StatisticsManagerProvider(activator);
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+        Thread.sleep(1000);
+        final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
+
+        assertTrue(statisticsManagerProvider.getStatisticsManager().isProvidedFlowNodeActive(nodeII));
+    }
+
+//    @Test
+    public void nodeUnregistrationTest() throws ExecutionException, InterruptedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        final StatisticsManagerProvider statisticsManagerProvider = new StatisticsManagerProvider(activator);
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+        Thread.sleep(1000);
+        final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
+
+        assertTrue(statisticsManagerProvider.getStatisticsManager().isProvidedFlowNodeActive(nodeII));
+
+        removeNode(s1Key);
+        Thread.sleep(1000);
+        assertFalse(statisticsManagerProvider.getStatisticsManager().isProvidedFlowNodeActive(nodeII));
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/PortStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/PortStatisticsTest.java
new file mode 100644 (file)
index 0000000..9f193b0
--- /dev/null
@@ -0,0 +1,73 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+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.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+import com.google.common.base.Optional;
+
+public class PortStatisticsTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+//    @Test(timeout = 23000)
+    public void getPortStatisticsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityPortStats.class);
+
+        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).child(NodeConnector.class, new NodeConnectorKey(getNodeConnectorId()));
+
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                nodeConnectorII.augmentation(FlowCapableNodeConnectorStatisticsData.class),
+                                                new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<FlowCapableNodeConnectorStatisticsData> flowCapableNodeConnectorStatisticsDataOptional =
+                readTx.read(LogicalDatastoreType.OPERATIONAL,
+                        nodeConnectorII.augmentation(FlowCapableNodeConnectorStatisticsData.class)).checkedGet();
+        assertTrue(flowCapableNodeConnectorStatisticsDataOptional.isPresent());
+        assertEquals(BIG_INTEGER_TEST_VALUE,
+                flowCapableNodeConnectorStatisticsDataOptional.get().getFlowCapableNodeConnectorStatistics()
+                        .getReceiveDrops());
+        assertEquals(BIG_INTEGER_TEST_VALUE,
+                flowCapableNodeConnectorStatisticsDataOptional.get().getFlowCapableNodeConnectorStatistics()
+                        .getCollisionCount());
+    }
+
+    private class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/QueueStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/QueueStatisticsTest.java
new file mode 100644 (file)
index 0000000..bb9bd21
--- /dev/null
@@ -0,0 +1,197 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+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.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityQueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+import com.google.common.base.Optional;
+
+
+public class QueueStatisticsTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+//    @Test(timeout = 5000)
+    public void addedQueueOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Port port = getPort();
+
+        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
+        fcncBuilder.setConfiguration(port.getConfiguration());
+        fcncBuilder.setPortNumber(port.getPortNumber());
+        fcncBuilder.setQueue(Collections.<Queue>emptyList());
+        ncBuilder.setKey(new NodeConnectorKey(new NodeConnectorId("connector.1")));
+        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
+
+
+        final Queue queue = getQueue();
+        final InstanceIdentifier<Queue> queueII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .child(NodeConnector.class, ncBuilder.getKey()).augmentation(FlowCapableNodeConnector.class)
+                .child(Queue.class, queue.getKey());
+        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).child(NodeConnector.class, ncBuilder.getKey());
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, nodeConnectorII, ncBuilder.build());
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, queueII, queue);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, queue);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<FlowCapableNodeConnectorQueueStatisticsData> queueStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class)).checkedGet();
+        assertTrue(queueStatsOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE,
+                queueStatsOptional.get().getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
+    }
+
+//    @Test(timeout = 5000)
+    public void deletedQueueStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNode(s1Key);
+
+        final Port port = getPort();
+
+        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
+        fcncBuilder.setConfiguration(port.getConfiguration());
+        fcncBuilder.setPortNumber(port.getPortNumber());
+        fcncBuilder.setQueue(Collections.<Queue>emptyList());
+        ncBuilder.setKey(new NodeConnectorKey(new NodeConnectorId("connector.1")));
+        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
+
+
+        final Queue queue = getQueue();
+        final InstanceIdentifier<Queue> queueII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .child(NodeConnector.class, ncBuilder.getKey()).augmentation(FlowCapableNodeConnector.class)
+                .child(Queue.class, queue.getKey());
+        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key).child(NodeConnector.class, ncBuilder.getKey());
+
+        WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, nodeConnectorII, ncBuilder.build());
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, queueII, queue);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, queue);
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class),
+                                        new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        Optional<FlowCapableNodeConnectorQueueStatisticsData> queueStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class)).checkedGet();
+        assertTrue(queueStatsOptional.isPresent());
+        assertEquals(COUNTER_64_TEST_VALUE,
+                queueStatsOptional.get().getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
+
+        writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.delete(LogicalDatastoreType.CONFIGURATION, queueII);
+        assertCommit(writeTx.submit());
+
+        readTx = getDataBroker().newReadOnlyTransaction();
+        queueStatsOptional = readTx.read(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class)).checkedGet();
+        assertFalse(queueStatsOptional.isPresent());
+    }
+
+//    @Test(timeout = 23000)
+    public void getAllStatsFromConnectedNodeTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityQueueStats.class);
+
+        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
+        ncBuilder.setKey(new NodeConnectorKey(getNodeConnectorId()));
+        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcncBuilder.build());
+
+        final InstanceIdentifier<NodeConnector> nodeConnectorII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, s1Key)
+                .child(NodeConnector.class, ncBuilder.getKey());
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodeConnectorII, ncBuilder.build());
+        final InstanceIdentifier<Queue> queueII = nodeConnectorII.augmentation(FlowCapableNodeConnector.class)
+                .child(Queue.class, getQueue().getKey());
+        final QueueBuilder qBuilder = new QueueBuilder(getQueue());
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, queueII, qBuilder.build());
+        assertCommit(writeTx.submit());
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                queueII.augmentation(FlowCapableNodeConnectorQueueStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<Queue> queueOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, queueII).checkedGet();
+        assertTrue(queueOptional.isPresent());
+        final FlowCapableNodeConnectorQueueStatisticsData queueStats =
+                queueOptional.get().getAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
+        assertTrue(queueStats != null);
+        assertEquals(COUNTER_64_TEST_VALUE,
+                queueStats.getFlowCapableNodeConnectorQueueStatistics().getTransmittedBytes());
+    }
+
+    private class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/TableStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/TableStatisticsTest.java
new file mode 100644 (file)
index 0000000..f0c0fed
--- /dev/null
@@ -0,0 +1,71 @@
+package test.mock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+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.statistics.manager.StatisticsManagerActivator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityTableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import test.mock.util.StatisticsManagerTest;
+
+import com.google.common.base.Optional;
+
+public class TableStatisticsTest extends StatisticsManagerTest {
+    private final Object waitObject = new Object();
+
+//    @Test(timeout = 23000)
+    public void getTableStatisticsTest() throws ExecutionException, InterruptedException, ReadFailedException {
+        final StatisticsManagerActivator activator = new StatisticsManagerActivator();
+        activator.onSessionInitiated(providerContext);
+
+        addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityTableStats.class);
+
+        final TableId tableId = getTableId();
+        final InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId.getValue()));
+
+        getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                tableII.augmentation(FlowTableStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE);
+
+        synchronized (waitObject) {
+            waitObject.wait();
+        }
+
+        final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+        final Optional<FlowTableStatisticsData> flowTableStatisticsDataOptional = readTx.read(
+                LogicalDatastoreType.OPERATIONAL, tableII.augmentation(FlowTableStatisticsData.class)).checkedGet();
+        assertTrue(flowTableStatisticsDataOptional.isPresent());
+        assertEquals(COUNTER_32_TEST_VALUE,
+                flowTableStatisticsDataOptional.get().getFlowTableStatistics().getActiveFlows());
+        assertEquals(COUNTER_64_TEST_VALUE,
+                flowTableStatisticsDataOptional.get().getFlowTableStatistics().getPacketsLookedUp());
+    }
+
+    private class ChangeListener implements DataChangeListener {
+
+        @Override
+        public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+            synchronized (waitObject) {
+                waitObject.notify();
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/AbstractDataBrokerTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/AbstractDataBrokerTest.java
new file mode 100644 (file)
index 0000000..f9efa51
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package test.mock.util;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
+
+    private DataBrokerTestCustomizer testCustomizer;
+    private DataBroker dataBroker;
+    private DOMDataBroker domBroker;
+
+
+    @Override
+    protected void setupWithSchema(final SchemaContext context) {
+        testCustomizer = createDataBrokerTestCustomizer();
+        dataBroker = testCustomizer.createDataBroker();
+        domBroker = testCustomizer.createDOMDataBroker();
+        testCustomizer.updateSchema(context);
+        setupWithDataBroker(dataBroker);
+    }
+
+    protected void setupWithDataBroker(final DataBroker dataBroker) {
+        // Intentionally left No-op, subclasses may customize it
+    }
+
+   protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+        return new DataBrokerTestCustomizer();
+    }
+
+    public DataBroker getDataBroker() {
+        return dataBroker;
+    }
+
+    public DOMDataBroker getDomBroker() {
+        return domBroker;
+    }
+
+    protected static final void assertCommit(final ListenableFuture<Void> commit) {
+        try {
+            commit.get(500, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/AbstractSchemaAwareTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/AbstractSchemaAwareTest.java
new file mode 100644 (file)
index 0000000..d520d59
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package test.mock.util;
+
+import org.junit.Before;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public abstract class AbstractSchemaAwareTest {
+
+    private Iterable<YangModuleInfo> moduleInfos;
+    private SchemaContext schemaContext;
+
+
+    protected Iterable<YangModuleInfo> getModuleInfos() {
+        return BindingReflections.loadModuleInfos();
+    }
+
+
+    @Before
+    public final void setup() {
+        moduleInfos = getModuleInfos();
+        ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
+        moduleContext.addModuleInfos(moduleInfos);
+        schemaContext = moduleContext.tryToCreateSchemaContext().get();
+        setupWithSchema(schemaContext);
+    }
+
+    /**
+     * Setups test with Schema context.
+     * This method is called before {@link #setupWithSchemaService(SchemaService)}
+     *
+     * @param context
+     */
+    protected abstract void setupWithSchema(SchemaContext context);
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/BundleContextMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/BundleContextMock.java
new file mode 100644 (file)
index 0000000..37cea44
--- /dev/null
@@ -0,0 +1,149 @@
+package test.mock.util;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Dictionary;
+
+public class BundleContextMock implements BundleContext {
+    @Override
+    public String getProperty(String s) {
+        return null;
+    }
+
+    @Override
+    public Bundle getBundle() {
+        return null;
+    }
+
+    @Override
+    public Bundle installBundle(String s, InputStream inputStream) throws BundleException {
+        return null;
+    }
+
+    @Override
+    public Bundle installBundle(String s) throws BundleException {
+        return null;
+    }
+
+    @Override
+    public Bundle getBundle(long l) {
+        return null;
+    }
+
+    @Override
+    public Bundle[] getBundles() {
+        return new Bundle[0];
+    }
+
+    @Override
+    public void addServiceListener(ServiceListener serviceListener, String s) throws InvalidSyntaxException {
+
+    }
+
+    @Override
+    public void addServiceListener(ServiceListener serviceListener) {
+
+    }
+
+    @Override
+    public void removeServiceListener(ServiceListener serviceListener) {
+
+    }
+
+    @Override
+    public void addBundleListener(BundleListener bundleListener) {
+
+    }
+
+    @Override
+    public void removeBundleListener(BundleListener bundleListener) {
+
+    }
+
+    @Override
+    public void addFrameworkListener(FrameworkListener frameworkListener) {
+
+    }
+
+    @Override
+    public void removeFrameworkListener(FrameworkListener frameworkListener) {
+
+    }
+
+    @Override
+    public ServiceRegistration<?> registerService(String[] strings, Object o, Dictionary<String, ?> stringDictionary) {
+        return null;
+    }
+
+    @Override
+    public ServiceRegistration<?> registerService(String s, Object o, Dictionary<String, ?> stringDictionary) {
+        return null;
+    }
+
+    @Override
+    public <S> ServiceRegistration<S> registerService(Class<S> sClass, S s, Dictionary<String, ?> stringDictionary) {
+        return null;
+    }
+
+    @Override
+    public ServiceReference<?>[] getServiceReferences(String s, String s2) throws InvalidSyntaxException {
+        return new ServiceReference<?>[0];
+    }
+
+    @Override
+    public ServiceReference<?>[] getAllServiceReferences(String s, String s2) throws InvalidSyntaxException {
+        return new ServiceReference<?>[0];
+    }
+
+    @Override
+    public ServiceReference<?> getServiceReference(String s) {
+        return null;
+    }
+
+    @Override
+    public <S> ServiceReference<S> getServiceReference(Class<S> sClass) {
+        return null;
+    }
+
+    @Override
+    public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> sClass, String s) throws InvalidSyntaxException {
+        return null;
+    }
+
+    @Override
+    public <S> S getService(ServiceReference<S> sServiceReference) {
+        return null;
+    }
+
+    @Override
+    public boolean ungetService(ServiceReference<?> serviceReference) {
+        return false;
+    }
+
+    @Override
+    public File getDataFile(String s) {
+        return null;
+    }
+
+    @Override
+    public Filter createFilter(String s) throws InvalidSyntaxException {
+        return null;
+    }
+
+    @Override
+    public Bundle getBundle(String s) {
+        return null;
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/DataBrokerTestCustomizer.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/DataBrokerTestCustomizer.java
new file mode 100644 (file)
index 0000000..36ab41f
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package test.mock.util;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import javassist.ClassPool;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
+import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class DataBrokerTestCustomizer {
+
+    private DOMDataBroker domDataBroker;
+    private final RuntimeGeneratedMappingServiceImpl mappingService;
+    private final MockSchemaService schemaService;
+    private ImmutableMap<LogicalDatastoreType, DOMStore> datastores;
+    private final BindingToNormalizedNodeCodec bindingToNormalized ;
+
+    public ImmutableMap<LogicalDatastoreType, DOMStore> createDatastores() {
+        return ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
+                .put(LogicalDatastoreType.OPERATIONAL, createOperationalDatastore())
+                .put(LogicalDatastoreType.CONFIGURATION,createConfigurationDatastore())
+                .build();
+    }
+
+    public DataBrokerTestCustomizer() {
+        schemaService = new MockSchemaService();
+        ClassPool pool = ClassPool.getDefault();
+        mappingService = new RuntimeGeneratedMappingServiceImpl(pool);
+        DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(pool));
+        BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
+        GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
+        bindingToNormalized = new BindingToNormalizedNodeCodec(loading, mappingService, codecRegistry);
+        schemaService.registerSchemaContextListener(bindingToNormalized);
+    }
+
+    public DOMStore createConfigurationDatastore() {
+        InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG",
+                MoreExecutors.sameThreadExecutor(), MoreExecutors.sameThreadExecutor());
+        schemaService.registerSchemaContextListener(store);
+        return store;
+    }
+
+    public DOMStore createOperationalDatastore() {
+        InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER",
+                MoreExecutors.sameThreadExecutor(), MoreExecutors.sameThreadExecutor());
+        schemaService.registerSchemaContextListener(store);
+        return store;
+    }
+
+    public DOMDataBroker createDOMDataBroker() {
+        return new DOMDataBrokerImpl(getDatastores(), getCommitCoordinatorExecutor());
+    }
+
+    public ListeningExecutorService getCommitCoordinatorExecutor() {
+        return MoreExecutors.sameThreadExecutor();
+    }
+
+    public DataBroker createDataBroker() {
+        return new ForwardedBindingDataBroker(getDOMDataBroker(), bindingToNormalized, schemaService );
+    }
+
+    public ForwardedBackwardsCompatibleDataBroker createBackwardsCompatibleDataBroker() {
+        return new ForwardedBackwardsCompatibleDataBroker(getDOMDataBroker(), bindingToNormalized, getSchemaService(), MoreExecutors.sameThreadExecutor());
+    }
+
+    private SchemaService getSchemaService() {
+        return schemaService;
+    }
+
+    private DOMDataBroker getDOMDataBroker() {
+        if(domDataBroker == null) {
+            domDataBroker = createDOMDataBroker();
+        }
+        return domDataBroker;
+    }
+
+    private synchronized ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() {
+        if (datastores == null) {
+            datastores = createDatastores();
+        }
+        return datastores;
+    }
+
+    public void updateSchema(final SchemaContext ctx) {
+        schemaService.changeSchema(ctx);
+        mappingService.onGlobalContextUpdated(ctx);
+    }
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/FlowMockGenerator.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/FlowMockGenerator.java
new file mode 100644 (file)
index 0000000..fb5351b
--- /dev/null
@@ -0,0 +1,30 @@
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+
+import java.math.BigInteger;
+import java.util.Random;
+
+public class FlowMockGenerator {
+    private static final Random rnd = new Random();
+    private static final FlowBuilder flowBuilder = new FlowBuilder();
+
+    public static Flow getRandomFlow() {
+        flowBuilder.setKey(new FlowKey(new FlowId("flow." + rnd.nextInt(1000))));
+        flowBuilder.setOutGroup(TestUtils.nextLong(0, 4294967296L));
+        flowBuilder.setTableId((short) rnd.nextInt(256));
+        flowBuilder.setOutPort(BigInteger.valueOf(TestUtils.nextLong(0, Long.MAX_VALUE)));
+        flowBuilder.setStrict(rnd.nextBoolean());
+        flowBuilder.setContainerName("container." + rnd.nextInt(1000));
+        flowBuilder.setBarrier(rnd.nextBoolean());
+        flowBuilder.setMatch(MatchMockGenerator.getRandomMatch());
+        flowBuilder.setPriority(rnd.nextInt(65535));
+        flowBuilder.setCookie(new FlowCookie(BigInteger.valueOf(TestUtils.nextLong(0, Long.MAX_VALUE))));
+        flowBuilder.setCookieMask(flowBuilder.getCookie());
+        return flowBuilder.build();
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/GroupMockGenerator.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/GroupMockGenerator.java
new file mode 100644 (file)
index 0000000..183524d
--- /dev/null
@@ -0,0 +1,23 @@
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+
+import java.util.Random;
+
+public class GroupMockGenerator {
+    private static final Random rnd = new Random();
+    private static final GroupBuilder groupBuilder = new GroupBuilder();
+
+    public static Group getRandomGroup() {
+        groupBuilder.setKey(new GroupKey(new GroupId(TestUtils.nextLong(0, 4294967295L))));
+        groupBuilder.setContainerName("container." + rnd.nextInt(1000));
+        groupBuilder.setBarrier(rnd.nextBoolean());
+        groupBuilder.setGroupName("group." + rnd.nextInt(1000));
+        groupBuilder.setGroupType(GroupTypes.forValue(rnd.nextInt(4)));
+        return groupBuilder.build();
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MatchMockGenerator.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MatchMockGenerator.java
new file mode 100644 (file)
index 0000000..8b603c2
--- /dev/null
@@ -0,0 +1,30 @@
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
+
+import java.math.BigInteger;
+import java.util.Random;
+
+public class MatchMockGenerator {
+    private static final Random rnd = new Random();
+    private static final MatchBuilder matchBuilder = new MatchBuilder();
+    private static final IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
+    private static final MetadataBuilder metadataBuilder = new MetadataBuilder();
+
+    public static Match getRandomMatch() {
+        matchBuilder.setInPort(new NodeConnectorId("port." + rnd.nextInt(500)));
+        ipMatchBuilder.setIpDscp(new Dscp((short) rnd.nextInt(64))).build();
+        ipMatchBuilder.setIpEcn((short) rnd.nextInt(256));
+        ipMatchBuilder.setIpProtocol((short) rnd.nextInt(256));
+        matchBuilder.setIpMatch(ipMatchBuilder.build());
+        metadataBuilder.setMetadata(BigInteger.valueOf(TestUtils.nextLong(0, Long.MAX_VALUE)));
+        metadataBuilder.setMetadataMask(BigInteger.valueOf(TestUtils.nextLong(0, Long.MAX_VALUE)));
+        matchBuilder.setMetadata(metadataBuilder.build());
+        return matchBuilder.build();
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MeterMockGenerator.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MeterMockGenerator.java
new file mode 100644 (file)
index 0000000..63ebcb0
--- /dev/null
@@ -0,0 +1,35 @@
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class MeterMockGenerator {
+    private static final Random rnd = new Random();
+    private static final MeterBuilder meterBuilder = new MeterBuilder();
+    private static final MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
+    private static final MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
+
+    public static Meter getRandomMeter() {
+        meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(new BandId(TestUtils.nextLong(0, 4294967295L))));
+        meterBandHeaderBuilder.setBandBurstSize(TestUtils.nextLong(0, 4294967295L));
+        meterBandHeaderBuilder.setBandRate(TestUtils.nextLong(0, 4294967295L));
+        List<MeterBandHeader> meterBandHeaders = new ArrayList<>();
+        meterBuilder.setKey(new MeterKey(new MeterId(TestUtils.nextLong(0, 4294967295L))));
+        meterBuilder.setBarrier(rnd.nextBoolean());
+        meterBuilder.setContainerName("container." + rnd.nextInt(1000));
+        meterBuilder.setMeterName("meter." + rnd.nextInt(1000));
+        meterBuilder.setMeterBandHeaders(meterBandHeadersBuilder.setMeterBandHeader(meterBandHeaders).build());
+        return meterBuilder.build();
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MockSchemaService.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/MockSchemaService.java
new file mode 100644 (file)
index 0000000..b4876a3
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package test.mock.util;
+
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.ListenerRegistry;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+
+@SuppressWarnings("deprecation")
+public final class MockSchemaService implements SchemaService, SchemaContextProvider {
+
+    private SchemaContext schemaContext;
+
+    ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
+
+    @Override
+    public void addModule(final Module module) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public synchronized SchemaContext getGlobalContext() {
+        return schemaContext;
+    }
+
+    @Override
+    public synchronized SchemaContext getSessionContext() {
+        return schemaContext;
+    }
+
+    @Override
+    public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
+            final SchemaContextListener listener) {
+        return listeners.register(listener);
+    }
+
+    @Override
+    public void removeModule(final Module module) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public synchronized SchemaContext getSchemaContext() {
+        return schemaContext;
+    }
+
+    public synchronized void changeSchema(final SchemaContext newContext) {
+        schemaContext = newContext;
+        for (ListenerRegistration<SchemaContextListener> listener : listeners) {
+            listener.getInstance().onGlobalContextUpdated(schemaContext);
+        }
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/NotificationProviderServiceHelper.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/NotificationProviderServiceHelper.java
new file mode 100644 (file)
index 0000000..2d85f62
--- /dev/null
@@ -0,0 +1,29 @@
+package test.mock.util;
+
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class NotificationProviderServiceHelper {
+    private NotificationBrokerImpl notifBroker = new NotificationBrokerImpl(SingletonHolder.getDefaultNotificationExecutor());
+
+    public NotificationBrokerImpl getNotifBroker() {
+        return notifBroker;
+    }
+
+    public void pushDelayedNotification(final Notification notification, int delay) {
+        new Timer().schedule(new TimerTask() {
+            @Override
+            public void run() {
+                notifBroker.publish(notification);
+            }
+        }, delay);
+    }
+
+    public void pushNotification(final Notification notification) {
+        notifBroker.publish(notification);
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowStatisticsServiceMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowStatisticsServiceMock.java
new file mode 100644 (file)
index 0000000..2628bb9
--- /dev/null
@@ -0,0 +1,116 @@
+package test.mock.util;
+
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class OpendaylightFlowStatisticsServiceMock implements OpendaylightFlowStatisticsService {
+    NotificationProviderServiceHelper notifService;
+    AtomicLong transNum = new AtomicLong();
+
+    public OpendaylightFlowStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
+        this.notifService = notifService;
+    }
+
+    @Override
+    public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+        GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder builder = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+        GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder builder = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        AggregateFlowStatisticsUpdateBuilder afsuBuilder = new AggregateFlowStatisticsUpdateBuilder();
+        afsuBuilder.setMoreReplies(false);
+        afsuBuilder.setTransactionId(transId);
+        afsuBuilder.setByteCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        afsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        notifService.pushDelayedNotification(afsuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(GetAllFlowStatisticsFromFlowTableInput input) {
+        GetAllFlowStatisticsFromFlowTableOutputBuilder builder = new GetAllFlowStatisticsFromFlowTableOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(GetAllFlowsStatisticsFromAllFlowTablesInput input) {
+        GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder builder = new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        List<FlowAndStatisticsMapList> flowAndStatisticsMapLists = new ArrayList<>();
+        FlowsStatisticsUpdateBuilder flowsStatisticsUpdateBuilder = new FlowsStatisticsUpdateBuilder();
+        flowsStatisticsUpdateBuilder.setTransactionId(transId);
+        flowsStatisticsUpdateBuilder.setMoreReplies(false);
+        flowsStatisticsUpdateBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder(StatisticsManagerTest.getFlow());
+        flowAndStatisticsMapListBuilder.setTableId(StatisticsManagerTest.getFlow().getTableId());
+        flowAndStatisticsMapListBuilder.setContainerName(StatisticsManagerTest.getFlow().getContainerName());
+        flowAndStatisticsMapListBuilder.setBarrier(StatisticsManagerTest.getFlow().isBarrier());
+        flowAndStatisticsMapListBuilder.setByteCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        flowAndStatisticsMapLists.add(flowAndStatisticsMapListBuilder.build());
+        flowsStatisticsUpdateBuilder.setFlowAndStatisticsMapList(flowAndStatisticsMapLists);
+        notifService.pushDelayedNotification(flowsStatisticsUpdateBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(GetFlowStatisticsFromFlowTableInput input) {
+        GetFlowStatisticsFromFlowTableOutputBuilder builder = new GetFlowStatisticsFromFlowTableOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        List<FlowAndStatisticsMapList> flowAndStatisticsMapLists = new ArrayList<>();
+        FlowsStatisticsUpdateBuilder flowsStatisticsUpdateBuilder = new FlowsStatisticsUpdateBuilder();
+        flowsStatisticsUpdateBuilder.setTransactionId(transId);
+        flowsStatisticsUpdateBuilder.setMoreReplies(false);
+        flowsStatisticsUpdateBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder(input);
+        flowAndStatisticsMapListBuilder.setTableId(input.getTableId());
+        flowAndStatisticsMapListBuilder.setContainerName(input.getContainerName());
+        flowAndStatisticsMapListBuilder.setBarrier(input.isBarrier());
+        flowAndStatisticsMapListBuilder.setByteCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        flowAndStatisticsMapLists.add(flowAndStatisticsMapListBuilder.build());
+        flowsStatisticsUpdateBuilder.setFlowAndStatisticsMapList(flowAndStatisticsMapLists);
+        notifService.pushDelayedNotification(flowsStatisticsUpdateBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowTableStatisticsServiceMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightFlowTableStatisticsServiceMock.java
new file mode 100644 (file)
index 0000000..42be708
--- /dev/null
@@ -0,0 +1,57 @@
+package test.mock.util;
+
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class OpendaylightFlowTableStatisticsServiceMock implements OpendaylightFlowTableStatisticsService {
+    NotificationProviderServiceHelper notifService;
+    AtomicLong transNum = new AtomicLong();
+
+    public OpendaylightFlowTableStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
+        this.notifService = notifService;
+    }
+
+    @Override
+    public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(GetFlowTablesStatisticsInput input) {
+        GetFlowTablesStatisticsOutputBuilder builder = new GetFlowTablesStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        FlowTableStatisticsUpdateBuilder ftsBuilder = new FlowTableStatisticsUpdateBuilder();
+        FlowTableAndStatisticsMapBuilder ftasmBuilder = new FlowTableAndStatisticsMapBuilder();
+        List<FlowTableAndStatisticsMap> tableAndStatisticsMaps = new ArrayList<>();
+        ftasmBuilder.setKey(new FlowTableAndStatisticsMapKey(StatisticsManagerTest.getTableId()));
+        ftasmBuilder.setActiveFlows(StatisticsManagerTest.COUNTER_32_TEST_VALUE);
+        tableAndStatisticsMaps.add(ftasmBuilder.build());
+        ftsBuilder.setTransactionId(transId);
+        ftsBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        ftsBuilder.setFlowTableAndStatisticsMap(tableAndStatisticsMaps);
+        ftsBuilder.setMoreReplies(true);
+        notifService.pushDelayedNotification(ftsBuilder.build(), 0); // 1st notification
+        ftsBuilder.setMoreReplies(false);
+        ftasmBuilder.setPacketsLookedUp(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        tableAndStatisticsMaps.clear();
+        tableAndStatisticsMaps.add(ftasmBuilder.build());
+        ftsBuilder.setFlowTableAndStatisticsMap(tableAndStatisticsMaps);
+        notifService.pushDelayedNotification(ftsBuilder.build(), 0); // 2nd notification
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightGroupStatisticsServiceMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightGroupStatisticsServiceMock.java
new file mode 100644 (file)
index 0000000..7e7342f
--- /dev/null
@@ -0,0 +1,123 @@
+package test.mock.util;
+
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class OpendaylightGroupStatisticsServiceMock implements OpendaylightGroupStatisticsService {
+    NotificationProviderServiceHelper notifService;
+    AtomicLong transNum = new AtomicLong();
+
+    public OpendaylightGroupStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
+        this.notifService = notifService;
+    }
+
+    @Override
+    public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(GetAllGroupStatisticsInput input) {
+        GetAllGroupStatisticsOutputBuilder builder = new GetAllGroupStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        List<GroupStats> groupStats = new ArrayList<>();
+        GroupStatsBuilder gsBuilder = new GroupStatsBuilder();
+        GroupStatisticsUpdatedBuilder gsuBuilder = new GroupStatisticsUpdatedBuilder();
+        gsBuilder.setKey(new GroupStatsKey(StatisticsManagerTest.getGroup().getGroupId()));
+        gsBuilder.setByteCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        groupStats.add(gsBuilder.build());
+        builder.setGroupStats(groupStats);
+        gsuBuilder.setTransactionId(transId);
+        gsuBuilder.setMoreReplies(false);
+        gsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        gsuBuilder.setGroupStats(groupStats);
+        notifService.pushDelayedNotification(gsuBuilder.build(), 500);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(GetGroupDescriptionInput input) {
+        GetGroupDescriptionOutputBuilder builder = new GetGroupDescriptionOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        List<GroupDescStats> groupDescStats = new ArrayList<>();
+        GroupDescStatsUpdatedBuilder gdsuBuilder = new GroupDescStatsUpdatedBuilder();
+        GroupDescStatsBuilder gdsBuilder = new GroupDescStatsBuilder();
+        gdsBuilder.setKey(new GroupDescStatsKey(StatisticsManagerTest.getGroup().getGroupId()));
+        gdsBuilder.setBuckets(StatisticsManagerTest.getGroup().getBuckets());
+        gdsBuilder.setContainerName(StatisticsManagerTest.getGroup().getContainerName());
+        gdsBuilder.setGroupName(StatisticsManagerTest.getGroup().getGroupName());
+        gdsBuilder.setGroupType(StatisticsManagerTest.getGroup().getGroupType());
+        groupDescStats.add(gdsBuilder.build());
+        builder.setGroupDescStats(groupDescStats);
+        gdsuBuilder.setTransactionId(transId);
+        gdsuBuilder.setMoreReplies(false);
+        gdsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        gdsuBuilder.setGroupDescStats(groupDescStats);
+        notifService.pushDelayedNotification(gdsuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(GetGroupFeaturesInput input) {
+        GetGroupFeaturesOutputBuilder builder = new GetGroupFeaturesOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        GroupFeaturesUpdatedBuilder gfuBuilder = new GroupFeaturesUpdatedBuilder();
+        gfuBuilder.setTransactionId(transId);
+        gfuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        gfuBuilder.setMoreReplies(false);
+        List<Long> maxGroups = new ArrayList<>();
+        maxGroups.add(StatisticsManagerTest.MAX_GROUPS_TEST_VALUE);
+        gfuBuilder.setMaxGroups(maxGroups);
+        notifService.pushDelayedNotification(gfuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(GetGroupStatisticsInput input) {
+        GetGroupStatisticsOutputBuilder builder = new GetGroupStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        GroupStatsBuilder gsBuilder = new GroupStatsBuilder();
+        List<GroupStats> groupStats = new ArrayList<>();
+        gsBuilder.setKey(new GroupStatsKey(input.getGroupId()));
+        gsBuilder.setByteCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        groupStats.add(gsBuilder.build());
+        GroupStatisticsUpdatedBuilder gsuBuilder = new GroupStatisticsUpdatedBuilder();
+        gsuBuilder.setTransactionId(transId);
+        gsuBuilder.setMoreReplies(false);
+        gsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        gsuBuilder.setGroupStats(groupStats);
+        notifService.pushDelayedNotification(gsuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightMeterStatisticsServiceMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightMeterStatisticsServiceMock.java
new file mode 100644 (file)
index 0000000..2d65d1e
--- /dev/null
@@ -0,0 +1,119 @@
+package test.mock.util;
+
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class OpendaylightMeterStatisticsServiceMock implements OpendaylightMeterStatisticsService {
+    NotificationProviderServiceHelper notifService;
+    AtomicLong transNum = new AtomicLong();
+
+    public OpendaylightMeterStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
+        this.notifService = notifService;
+    }
+
+    @Override
+    public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(GetAllMeterConfigStatisticsInput input) {
+        GetAllMeterConfigStatisticsOutputBuilder builder = new GetAllMeterConfigStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        List<MeterConfigStats> meterConfigStats = new ArrayList<>();
+        MeterConfigStatsBuilder mcsBuilder = new MeterConfigStatsBuilder();
+        mcsBuilder.setMeterId(StatisticsManagerTest.getMeter().getMeterId());
+        mcsBuilder.setMeterName(StatisticsManagerTest.getMeter().getMeterName());
+        mcsBuilder.setContainerName(StatisticsManagerTest.getMeter().getContainerName());
+        meterConfigStats.add(mcsBuilder.build());
+        builder.setMeterConfigStats(meterConfigStats);
+        MeterConfigStatsUpdatedBuilder mscuBuilder = new MeterConfigStatsUpdatedBuilder();
+        mscuBuilder.setTransactionId(transId);
+        mscuBuilder.setMoreReplies(false);
+        mscuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        mscuBuilder.setMeterConfigStats(meterConfigStats);
+        notifService.pushDelayedNotification(mscuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(GetAllMeterStatisticsInput input) {
+        GetAllMeterStatisticsOutputBuilder builder = new GetAllMeterStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        MeterStatsBuilder msBuilder = new MeterStatsBuilder();
+        msBuilder.setByteInCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        msBuilder.setPacketInCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        msBuilder.setKey(new MeterStatsKey(StatisticsManagerTest.getMeter().getMeterId()));
+        List<MeterStats> meterStats = new ArrayList<>();
+        meterStats.add(msBuilder.build());
+        MeterStatisticsUpdatedBuilder msuBuilder = new MeterStatisticsUpdatedBuilder();
+        msuBuilder.setTransactionId(transId);
+        msuBuilder.setMoreReplies(false);
+        msuBuilder.setMeterStats(meterStats);
+        msuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        notifService.pushDelayedNotification(msuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(GetMeterFeaturesInput input) {
+        GetMeterFeaturesOutputBuilder builder = new GetMeterFeaturesOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        MeterFeaturesUpdatedBuilder mfuBuilder = new MeterFeaturesUpdatedBuilder();
+        mfuBuilder.setTransactionId(transId);
+        mfuBuilder.setMoreReplies(false);
+        mfuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        mfuBuilder.setMaxMeter(StatisticsManagerTest.COUNTER_32_TEST_VALUE);
+        notifService.pushDelayedNotification(mfuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(GetMeterStatisticsInput input) {
+        GetMeterStatisticsOutputBuilder builder = new GetMeterStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        MeterStatsBuilder msBuilder = new MeterStatsBuilder();
+        msBuilder.setKey(new MeterStatsKey(input.getMeterId()));
+        msBuilder.setByteInCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        msBuilder.setPacketInCount(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        List<MeterStats> meterStats = new ArrayList<>();
+        meterStats.add(msBuilder.build());
+        MeterStatisticsUpdatedBuilder msuBuilder = new MeterStatisticsUpdatedBuilder();
+        msuBuilder.setTransactionId(transId);
+        msuBuilder.setMoreReplies(false);
+        msuBuilder.setMeterStats(meterStats);
+        msuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        notifService.pushDelayedNotification(msuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightPortStatisticsServiceMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightPortStatisticsServiceMock.java
new file mode 100644 (file)
index 0000000..7164c56
--- /dev/null
@@ -0,0 +1,67 @@
+package test.mock.util;
+
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class OpendaylightPortStatisticsServiceMock implements OpendaylightPortStatisticsService {
+    NotificationProviderServiceHelper notifService;
+    AtomicLong transNum = new AtomicLong();
+
+    public OpendaylightPortStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
+        this.notifService = notifService;
+    }
+
+    @Override
+    public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(GetAllNodeConnectorsStatisticsInput input) {
+        GetAllNodeConnectorsStatisticsOutputBuilder builder = new GetAllNodeConnectorsStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        NodeConnectorStatisticsUpdateBuilder ncsuBuilder = new NodeConnectorStatisticsUpdateBuilder();
+        NodeConnectorStatisticsAndPortNumberMapBuilder ncsapnmBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
+        List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMaps = new ArrayList<>();
+        ncsapnmBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(StatisticsManagerTest.getNodeConnectorId()));
+        ncsapnmBuilder.setReceiveDrops(StatisticsManagerTest.BIG_INTEGER_TEST_VALUE);
+        nodeConnectorStatisticsAndPortNumberMaps.add(ncsapnmBuilder.build());
+        ncsuBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(1)));
+        ncsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        ncsuBuilder.setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatisticsAndPortNumberMaps);
+        ncsuBuilder.setMoreReplies(true);
+        notifService.pushDelayedNotification(ncsuBuilder.build(), 0); // 1st notification
+        ncsuBuilder.setMoreReplies(false);
+        ncsapnmBuilder.setCollisionCount(StatisticsManagerTest.BIG_INTEGER_TEST_VALUE);
+        nodeConnectorStatisticsAndPortNumberMaps.clear();
+        nodeConnectorStatisticsAndPortNumberMaps.add(ncsapnmBuilder.build());
+        ncsuBuilder.setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatisticsAndPortNumberMaps);
+        notifService.pushDelayedNotification(ncsuBuilder.build(), 10); // 2nd notification
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(GetNodeConnectorStatisticsInput input) {
+        GetNodeConnectorStatisticsOutputBuilder builder = new GetNodeConnectorStatisticsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightQueueStatisticsServiceMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/OpendaylightQueueStatisticsServiceMock.java
new file mode 100644 (file)
index 0000000..4f6806b
--- /dev/null
@@ -0,0 +1,83 @@
+package test.mock.util;
+
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class OpendaylightQueueStatisticsServiceMock implements OpendaylightQueueStatisticsService {
+    NotificationProviderServiceHelper notifService;
+    AtomicLong transNum = new AtomicLong();
+
+    public OpendaylightQueueStatisticsServiceMock(NotificationProviderServiceHelper notifService) {
+        this.notifService = notifService;
+    }
+
+    @Override
+    public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(GetAllQueuesStatisticsFromAllPortsInput input) {
+        GetAllQueuesStatisticsFromAllPortsOutputBuilder builder = new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        QueueStatisticsUpdateBuilder qsuBuilder = new QueueStatisticsUpdateBuilder();
+        QueueIdAndStatisticsMapBuilder qiasmBuilder = new QueueIdAndStatisticsMapBuilder();
+        List<QueueIdAndStatisticsMap> queueIdAndStatisticsMaps = new ArrayList<>();
+        qsuBuilder.setMoreReplies(false);
+        qsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        qsuBuilder.setTransactionId(transId);
+        qiasmBuilder.setTransmittedBytes(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        qiasmBuilder.setKey(new QueueIdAndStatisticsMapKey(StatisticsManagerTest.getNodeConnectorId(), StatisticsManagerTest.getQueue().getQueueId()));
+        queueIdAndStatisticsMaps.add(qiasmBuilder.build());
+        qsuBuilder.setQueueIdAndStatisticsMap(queueIdAndStatisticsMaps);
+        notifService.pushDelayedNotification(qsuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(GetAllQueuesStatisticsFromGivenPortInput input) {
+        GetAllQueuesStatisticsFromGivenPortOutputBuilder builder = new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+
+    @Override
+    public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(GetQueueStatisticsFromGivenPortInput input) {
+        GetQueueStatisticsFromGivenPortOutputBuilder builder = new GetQueueStatisticsFromGivenPortOutputBuilder();
+        TransactionId transId = new TransactionId(BigInteger.valueOf(transNum.incrementAndGet()));
+        builder.setTransactionId(transId);
+        QueueIdAndStatisticsMapBuilder qiasmBuilder = new QueueIdAndStatisticsMapBuilder();
+        List<QueueIdAndStatisticsMap> queueIdAndStatisticsMaps = new ArrayList<>();
+        qiasmBuilder.setKey(new QueueIdAndStatisticsMapKey(input.getNodeConnectorId(), input.getQueueId()));
+        qiasmBuilder.setTransmittedBytes(StatisticsManagerTest.COUNTER_64_TEST_VALUE);
+        queueIdAndStatisticsMaps.add(qiasmBuilder.build());
+        QueueStatisticsUpdateBuilder qsuBuilder = new QueueStatisticsUpdateBuilder();
+        qsuBuilder.setMoreReplies(false);
+        qsuBuilder.setTransactionId(transId);
+        qsuBuilder.setId(input.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId());
+        qsuBuilder.setQueueIdAndStatisticsMap(queueIdAndStatisticsMaps);
+        notifService.pushDelayedNotification(qsuBuilder.build(), 100);
+        return Futures.immediateFuture(RpcResultBuilder.success(builder.build()).build());
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/PortMockGenerator.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/PortMockGenerator.java
new file mode 100644 (file)
index 0000000..4c97217
--- /dev/null
@@ -0,0 +1,23 @@
+package test.mock.util;
+
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey;
+
+import java.util.Random;
+
+public class PortMockGenerator {
+    private static final Random rnd = new Random();
+    private static final PortBuilder portBuilder = new PortBuilder();
+
+    public static Port getRandomPort() {
+        portBuilder.setKey(new PortKey(TestUtils.nextLong(0, 4294967295L)));
+        portBuilder.setBarrier(rnd.nextBoolean());
+        portBuilder.setPortNumber(new CommonPort.PortNumber(TestUtils.nextLong(0, 4294967295L)));
+        portBuilder.setConfiguration(new PortConfig(rnd.nextBoolean(), rnd.nextBoolean(), rnd.nextBoolean(), rnd.nextBoolean()));
+        return portBuilder.build();
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/ProviderContextMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/ProviderContextMock.java
new file mode 100644 (file)
index 0000000..9b40a76
--- /dev/null
@@ -0,0 +1,69 @@
+package test.mock.util;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class ProviderContextMock implements BindingAwareBroker.ProviderContext {
+
+    RpcProviderRegistry rpcProviderMock;
+    NotificationProviderService notificationProviderService;
+    DataBroker dataBroker;
+
+    public ProviderContextMock(RpcProviderRegistry rpcProviderMock, DataBroker dataBroker,
+                               NotificationProviderService notificationProviderServiceMock) {
+        this.rpcProviderMock = rpcProviderMock;
+        this.dataBroker = dataBroker;
+        this.notificationProviderService = notificationProviderServiceMock;
+    }
+
+    @Override
+    public void registerFunctionality(BindingAwareProvider.ProviderFunctionality functionality) {
+
+    }
+
+    @Override
+    public void unregisterFunctionality(BindingAwareProvider.ProviderFunctionality functionality) {
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends BindingAwareService> T getSALService(Class<T> service) {
+        if (service.equals(DataBroker.class)) {
+            return (T) dataBroker;
+        }
+        else if (service.equals(NotificationProviderService.class)) {
+            return (T) notificationProviderService;
+        }
+        return null;
+    }
+
+    @Override
+    public <T extends RpcService> BindingAwareBroker.RpcRegistration<T> addRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
+        return null;
+    }
+
+    @Override
+    public <T extends RpcService> BindingAwareBroker.RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
+        return null;
+    }
+
+    @Override
+    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
+        return null;
+    }
+
+    @Override
+    public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
+        return rpcProviderMock.getRpcService(serviceInterface);
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/QueueMockGenerator.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/QueueMockGenerator.java
new file mode 100644 (file)
index 0000000..f140776
--- /dev/null
@@ -0,0 +1,27 @@
+package test.mock.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
+
+import java.util.Random;
+
+public class QueueMockGenerator {
+    private static final Random rnd = new Random();
+    private static final QueueBuilder queueBuilder = new QueueBuilder();
+
+    public static Queue getRandomQueue() {
+        queueBuilder.setKey(new QueueKey(new QueueId(TestUtils.nextLong(0, 4294967295L))));
+        queueBuilder.setPort(TestUtils.nextLong(0, 4294967295L));
+        queueBuilder.setProperty(rnd.nextInt(65535));
+        return queueBuilder.build();
+    }
+
+    public static Queue getRandomQueueWithPortNum(long portNum) {
+        queueBuilder.setKey(new QueueKey(new QueueId(TestUtils.nextLong(0, 4294967295L))));
+        queueBuilder.setPort(portNum);
+        queueBuilder.setProperty(rnd.nextInt(65535));
+        return queueBuilder.build();
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java
new file mode 100644 (file)
index 0000000..0b25486
--- /dev/null
@@ -0,0 +1,93 @@
+package test.mock.util;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class RpcProviderRegistryMock implements RpcProviderRegistry {
+
+    OpendaylightFlowStatisticsServiceMock flowStatisticsServiceMock;
+    OpendaylightFlowTableStatisticsServiceMock flowTableStatisticsServiceMock;
+    OpendaylightGroupStatisticsServiceMock groupStatisticsServiceMock;
+    OpendaylightMeterStatisticsServiceMock meterStatisticsServiceMock;
+    OpendaylightPortStatisticsServiceMock portStatisticsServiceMock;
+    OpendaylightQueueStatisticsServiceMock queueStatisticsServiceMock;
+
+    public RpcProviderRegistryMock(NotificationProviderServiceHelper notificationProviderService) {
+        this.flowStatisticsServiceMock = new OpendaylightFlowStatisticsServiceMock(notificationProviderService);
+        this.flowTableStatisticsServiceMock = new OpendaylightFlowTableStatisticsServiceMock(notificationProviderService);
+        this.groupStatisticsServiceMock = new OpendaylightGroupStatisticsServiceMock(notificationProviderService);
+        this.meterStatisticsServiceMock = new OpendaylightMeterStatisticsServiceMock(notificationProviderService);
+        this.portStatisticsServiceMock = new OpendaylightPortStatisticsServiceMock(notificationProviderService);
+        this.queueStatisticsServiceMock = new OpendaylightQueueStatisticsServiceMock(notificationProviderService);
+    }
+
+    @Override
+    public <T extends RpcService> BindingAwareBroker.RpcRegistration<T> addRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
+        return null;
+    }
+
+    @Override
+    public <T extends RpcService> BindingAwareBroker.RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface, T implementation) throws IllegalStateException {
+        return null;
+    }
+
+    @Override
+    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
+        if (serviceInterface.equals(OpendaylightFlowStatisticsService.class)) {
+            return (T)flowStatisticsServiceMock;
+        } else if (serviceInterface.equals(OpendaylightFlowTableStatisticsService.class)) {
+            return (T) flowTableStatisticsServiceMock;
+        } else if (serviceInterface.equals(OpendaylightGroupStatisticsService.class)) {
+            return (T) groupStatisticsServiceMock;
+        } else if (serviceInterface.equals(OpendaylightMeterStatisticsService.class)) {
+            return (T) meterStatisticsServiceMock;
+        } else if (serviceInterface.equals(OpendaylightPortStatisticsService.class)) {
+            return (T) portStatisticsServiceMock;
+        } else if (serviceInterface.equals(OpendaylightQueueStatisticsService.class)) {
+            return (T) queueStatisticsServiceMock;
+        } else {
+            return null;
+        }
+    }
+
+    public OpendaylightFlowStatisticsServiceMock getFlowStatisticsServiceMock() {
+        return flowStatisticsServiceMock;
+    }
+
+    public OpendaylightFlowTableStatisticsServiceMock getFlowTableStatisticsServiceMock() {
+        return flowTableStatisticsServiceMock;
+    }
+
+    public OpendaylightGroupStatisticsServiceMock getGroupStatisticsServiceMock() {
+        return groupStatisticsServiceMock;
+    }
+
+    public OpendaylightMeterStatisticsServiceMock getMeterStatisticsServiceMock() {
+        return meterStatisticsServiceMock;
+    }
+
+    public OpendaylightPortStatisticsServiceMock getPortStatisticsServiceMock() {
+        return portStatisticsServiceMock;
+    }
+
+    public OpendaylightQueueStatisticsServiceMock getQueueStatisticsServiceMock() {
+        return queueStatisticsServiceMock;
+    }
+}
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/StatisticsManagerTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/StatisticsManagerTest.java
new file mode 100644 (file)
index 0000000..7f266d9
--- /dev/null
@@ -0,0 +1,198 @@
+package test.mock.util;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+public abstract class StatisticsManagerTest extends AbstractDataBrokerTest {
+
+    public static final Counter64 COUNTER_64_TEST_VALUE = new Counter64(BigInteger.valueOf(128));
+    public static final Counter32 COUNTER_32_TEST_VALUE = new Counter32(64L);
+    public static final Long MAX_GROUPS_TEST_VALUE = 2000L;
+    public static final BigInteger BIG_INTEGER_TEST_VALUE = BigInteger.valueOf(1000);
+
+    private static Flow flow;
+    private static Group group;
+    private static Meter meter;
+    private static Port port;
+    private static Queue queue;
+    private static TableId tableId;
+    private static NodeConnectorId nodeConnectorId;
+
+    private final NotificationProviderServiceHelper notificationMock = new NotificationProviderServiceHelper();
+    protected final NodeKey s1Key = new NodeKey(new NodeId("S1"));
+    protected RpcProviderRegistryMock rpcRegistry;
+    protected ProviderContextMock providerContext;
+
+    @BeforeClass
+    public static void setupTests() {
+        flow = FlowMockGenerator.getRandomFlow();
+        group = GroupMockGenerator.getRandomGroup();
+        meter = MeterMockGenerator.getRandomMeter();
+        port = PortMockGenerator.getRandomPort();
+        queue = QueueMockGenerator.getRandomQueueWithPortNum(port.getPortNumber().getUint32());
+        tableId = new TableId((short) 2);
+        nodeConnectorId = new NodeConnectorId("connector.1");
+    }
+
+    @Before
+    public void init() {
+        rpcRegistry = new RpcProviderRegistryMock(notificationMock);
+        providerContext = new ProviderContextMock(rpcRegistry, getDataBroker(), notificationMock.getNotifBroker());
+    }
+
+    // node with statistics capabilities will enable cyclic statistics collection
+    @SafeVarargs
+    protected final void addFlowCapableNodeWithFeatures(final NodeKey nodeKey, final Boolean hasMeterCapabilities,
+                                                     final Class<? extends FeatureCapability>... capabilities)
+            throws ExecutionException, InterruptedException {
+        final Nodes nodes = new NodesBuilder().setNode(Collections.<Node>emptyList()).build();
+        final InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, nodeKey);
+
+        final FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
+        final SwitchFeaturesBuilder sfBuilder = new SwitchFeaturesBuilder();
+        final List<Class<? extends FeatureCapability>> capabilitiyList = new ArrayList<>();
+        for (final Class<? extends FeatureCapability> capability : capabilities) {
+            capabilitiyList.add(capability);
+        }
+        sfBuilder.setCapabilities(capabilitiyList);
+        sfBuilder.setMaxTables((short) 2);
+        final NodeBuilder nodeBuilder = new NodeBuilder();
+        nodeBuilder.setKey(nodeKey);
+        fcnBuilder.setSwitchFeatures(sfBuilder.build());
+        final List<Table> tables = new ArrayList<>();
+        final TableBuilder tBuilder = new TableBuilder();
+        tBuilder.setId(getFlow().getTableId());
+        tables.add(tBuilder.build());
+        fcnBuilder.setTable(tables);
+        final FlowCapableNode flowCapableNode = fcnBuilder.build();
+        nodeBuilder.addAugmentation(FlowCapableNode.class, flowCapableNode);
+        final Node node = nodeBuilder.build();
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
+        if (hasMeterCapabilities) {
+            final NodeMeterFeaturesBuilder nmfBuilder = new NodeMeterFeaturesBuilder();
+            final MeterFeaturesBuilder mfBuilder = new MeterFeaturesBuilder();
+            mfBuilder.setMaxBands((short) 4);
+            nmfBuilder.setMeterFeatures(mfBuilder.build());
+            writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier.augmentation(NodeMeterFeatures.class),
+                    nmfBuilder.build());
+        }
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, node);
+        assertCommit(writeTx.submit());
+
+        final NodeUpdatedBuilder nuBuilder = new NodeUpdatedBuilder(node);
+        final FlowCapableNodeUpdatedBuilder fcnuBuilder = new FlowCapableNodeUpdatedBuilder(flowCapableNode);
+        nuBuilder.setNodeRef(new NodeRef(flowNodeIdentifier));
+        nuBuilder.addAugmentation(FlowCapableNodeUpdated.class, fcnuBuilder.build());
+        notificationMock.pushNotification(nuBuilder.build());
+    }
+
+    public void addFlowCapableNode(final NodeKey nodeKey) throws ExecutionException, InterruptedException {
+        final Nodes nodes = new NodesBuilder().setNode(Collections.<Node>emptyList()).build();
+        final InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, nodeKey);
+
+        final FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
+        final NodeBuilder nodeBuilder = new NodeBuilder();
+        nodeBuilder.setKey(nodeKey);
+        final FlowCapableNode flowCapableNode = fcnBuilder.build();
+        nodeBuilder.addAugmentation(FlowCapableNode.class, flowCapableNode);
+        final Node node = nodeBuilder.build();
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, node);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, node);
+        assertCommit(writeTx.submit());
+
+        final NodeUpdatedBuilder nuBuilder = new NodeUpdatedBuilder(node);
+        final FlowCapableNodeUpdatedBuilder fcnuBuilder = new FlowCapableNodeUpdatedBuilder(flowCapableNode);
+        nuBuilder.setNodeRef(new NodeRef(flowNodeIdentifier));
+        nuBuilder.addAugmentation(FlowCapableNodeUpdated.class, fcnuBuilder.build());
+        notificationMock.pushNotification(nuBuilder.build());
+    }
+
+    protected void removeNode(final NodeKey nodeKey) throws ExecutionException, InterruptedException {
+        final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
+
+        final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+        writeTx.delete(LogicalDatastoreType.OPERATIONAL, nodeII);
+        writeTx.submit().get();
+
+        final NodeRemovedBuilder nrBuilder = new NodeRemovedBuilder();
+        nrBuilder.setNodeRef(new NodeRef(nodeII));
+        notificationMock.pushNotification(nrBuilder.build());
+    }
+
+    public static Flow getFlow() {
+        return flow;
+    }
+
+    public static Group getGroup() {
+        return group;
+    }
+
+    public static Meter getMeter() {
+        return meter;
+    }
+
+    public static Port getPort() {
+        return port;
+    }
+
+    public static Queue getQueue() {
+        return queue;
+    }
+
+    public static TableId getTableId() {
+        return tableId;
+    }
+
+    public static NodeConnectorId getNodeConnectorId() {
+        return nodeConnectorId;
+    }
+}
+
diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/TestUtils.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/util/TestUtils.java
new file mode 100644 (file)
index 0000000..e38a25e
--- /dev/null
@@ -0,0 +1,11 @@
+package test.mock.util;
+
+import java.util.Random;
+
+public class TestUtils {
+    private static Random rnd = new Random();
+
+    public static long nextLong(long RangeBottom, long rangeTop) {
+        return RangeBottom + ((long)(rnd.nextDouble()*(rangeTop - RangeBottom)));
+    }
+}
index 97ed15df191d8159300e5754aa111d2c0ee8ea51..e6a9a75337a50635cf4a132cfd5f2fa93bb2e734 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
   <groupId>org.opendaylight.controller.md</groupId>
index 57313d2948960b038791d75a5fdb9287cce41530..bfef646da1dc69194725762a585962f67640d1b5 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
   </parent>
   <groupId>org.opendaylight.controller.md</groupId>
   <artifactId>topology-manager</artifactId>
index 361373d78da93f114f51c887ab95c78bc6ab3265..9b36f9f4973581187e2bf0f45b376c72cdd8da4a 100644 (file)
@@ -7,17 +7,8 @@
  */
 package org.opendaylight.md.controller.topology.manager;
 
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.getNodeConnectorKey;
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.getNodeKey;
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTerminationPoint;
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTerminationPointId;
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyLink;
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNode;
-import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNodeId;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -48,12 +39,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
+import java.util.Collections;
+import java.util.List;
+
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.getNodeConnectorKey;
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.getNodeKey;
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTerminationPoint;
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTerminationPointId;
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyLink;
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNode;
+import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNodeId;
 
 class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, OpendaylightInventoryListener {
 
@@ -76,8 +71,8 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open
         processor.enqueueOperation(new TopologyOperation() {
             @Override
             public void applyOperation(ReadWriteTransaction transaction) {
-                removeAffectedLinks(nodeId, transaction);
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeInstance);
+                    removeAffectedLinks(nodeId, transaction);
+                    transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeInstance);
             }
 
             @Override
@@ -113,14 +108,24 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open
         final InstanceIdentifier<TerminationPoint> tpInstance = toTerminationPointIdentifier(
                 notification.getNodeConnectorRef());
 
+        final InstanceIdentifier<Node> node = tpInstance.firstIdentifierOf(Node.class);
+
         final TpId tpId = toTerminationPointId(getNodeConnectorKey(
                 notification.getNodeConnectorRef()).getId());
 
         processor.enqueueOperation(new TopologyOperation() {
             @Override
             public void applyOperation(ReadWriteTransaction transaction) {
-                removeAffectedLinks(tpId, transaction);
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, tpInstance);
+                Optional<Node> nodeOptional = Optional.absent();
+                try {
+                    nodeOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, node).checkedGet();
+                } catch (ReadFailedException e) {
+                    LOG.error("Error occured when trying to read NodeConnector ", e);
+                }
+                if (nodeOptional.isPresent()) {
+                    removeAffectedLinks(tpId, transaction);
+                    transaction.delete(LogicalDatastoreType.OPERATIONAL, tpInstance);
+                }
             }
 
             @Override
@@ -164,7 +169,7 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open
             public void applyOperation(final ReadWriteTransaction transaction) {
                 final Link link = toTopologyLink(notification);
                 final InstanceIdentifier<Link> path = linkPath(link);
-                transaction.merge(LogicalDatastoreType.OPERATIONAL, path, link, true);
+                transaction.put(LogicalDatastoreType.OPERATIONAL, path, link, true);
             }
 
             @Override
@@ -184,7 +189,17 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open
         processor.enqueueOperation(new TopologyOperation() {
             @Override
             public void applyOperation(final ReadWriteTransaction transaction) {
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(toTopologyLink(notification)));
+                Optional<Link> linkOptional = Optional.absent();
+                try {
+                    // read that checks if link exists (if we do not do this we might get an exception on delete)
+                    linkOptional = transaction.read(LogicalDatastoreType.OPERATIONAL,
+                            linkPath(toTopologyLink(notification))).checkedGet();
+                } catch (ReadFailedException e) {
+                    LOG.error("Error occured when trying to read Link ", e);
+                }
+                if (linkOptional.isPresent()) {
+                    transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(toTopologyLink(notification)));
+                }
             }
 
             @Override
@@ -212,89 +227,57 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, Open
     }
 
     private void removeAffectedLinks(final NodeId id, final ReadWriteTransaction transaction) {
-        CheckedFuture<Optional<Topology>, ReadFailedException> topologyDataFuture =
-                transaction.read(LogicalDatastoreType.OPERATIONAL, topology);
-        Futures.addCallback(topologyDataFuture, new FutureCallback<Optional<Topology>>() {
-            @Override
-            public void onSuccess(Optional<Topology> topologyOptional) {
-                removeAffectedLinks(id, topologyOptional);
-            }
-
-            @Override
-            public void onFailure(Throwable throwable) {
-                LOG.error("Error reading topology data for topology {}", topology, throwable);
-            }
-        });
+        Optional<Topology> topologyOptional = Optional.absent();
+        try {
+            topologyOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, topology).checkedGet();
+        } catch (ReadFailedException e) {
+            LOG.error("Error reading topology data for topology {}", topology, e);
+        }
+        if (topologyOptional.isPresent()) {
+            removeAffectedLinks(id, topologyOptional, transaction);
+        }
     }
 
-    private void removeAffectedLinks(final NodeId id, Optional<Topology> topologyOptional) {
+    private void removeAffectedLinks(final NodeId id, Optional<Topology> topologyOptional, ReadWriteTransaction transaction) {
         if (!topologyOptional.isPresent()) {
             return;
         }
 
         List<Link> linkList = topologyOptional.get().getLink() != null ?
                 topologyOptional.get().getLink() : Collections.<Link> emptyList();
-        final List<InstanceIdentifier<Link>> linkIDsToDelete = Lists.newArrayList();
         for (Link link : linkList) {
             if (id.equals(link.getSource().getSourceNode()) ||
                     id.equals(link.getDestination().getDestNode())) {
-                linkIDsToDelete.add(linkPath(link));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(link));
             }
         }
-
-        enqueueLinkDeletes(linkIDsToDelete);
-    }
-
-    private void enqueueLinkDeletes(final Collection<InstanceIdentifier<Link>> linkIDsToDelete) {
-        if(!linkIDsToDelete.isEmpty()) {
-            processor.enqueueOperation(new TopologyOperation() {
-                @Override
-                public void applyOperation(ReadWriteTransaction transaction) {
-                    for(InstanceIdentifier<Link> linkID: linkIDsToDelete) {
-                        transaction.delete(LogicalDatastoreType.OPERATIONAL, linkID);
-                    }
-                }
-
-                @Override
-                public String toString() {
-                    return "Delete Links " + linkIDsToDelete.size();
-                }
-            });
-        }
     }
 
     private void removeAffectedLinks(final TpId id, final ReadWriteTransaction transaction) {
-        CheckedFuture<Optional<Topology>, ReadFailedException> topologyDataFuture =
-                transaction.read(LogicalDatastoreType.OPERATIONAL, topology);
-        Futures.addCallback(topologyDataFuture, new FutureCallback<Optional<Topology>>() {
-            @Override
-            public void onSuccess(Optional<Topology> topologyOptional) {
-                removeAffectedLinks(id, topologyOptional);
-            }
-
-            @Override
-            public void onFailure(Throwable throwable) {
-                LOG.error("Error reading topology data for topology {}", topology, throwable);
-            }
-        });
+        Optional<Topology> topologyOptional = Optional.absent();
+        try {
+            topologyOptional = transaction.read(LogicalDatastoreType.OPERATIONAL, topology).checkedGet();
+        } catch (ReadFailedException e) {
+            LOG.error("Error reading topology data for topology {}", topology, e);
+        }
+        if (topologyOptional.isPresent()) {
+            removeAffectedLinks(id, topologyOptional, transaction);
+        }
     }
 
-    private void removeAffectedLinks(final TpId id, Optional<Topology> topologyOptional) {
+    private void removeAffectedLinks(final TpId id, Optional<Topology> topologyOptional, ReadWriteTransaction transaction) {
         if (!topologyOptional.isPresent()) {
             return;
         }
 
         List<Link> linkList = topologyOptional.get().getLink() != null
                 ? topologyOptional.get().getLink() : Collections.<Link> emptyList();
-        final List<InstanceIdentifier<Link>> linkIDsToDelete = Lists.newArrayList();
         for (Link link : linkList) {
             if (id.equals(link.getSource().getSourceTp()) ||
                     id.equals(link.getDestination().getDestTp())) {
-                linkIDsToDelete.add(linkPath(link));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, linkPath(link));
             }
         }
-
-        enqueueLinkDeletes(linkIDsToDelete);
     }
 
     private InstanceIdentifier<Node> getNodePath(final NodeId nodeId) {
index f09da0045930cf7cc843de1a924e64841f2db508..c00943339570dc67ee10ed8349f461132dc1e3e7 100644 (file)
@@ -8,13 +8,6 @@
 package org.opendaylight.md.controller.topology.manager;
 
 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.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -25,6 +18,9 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
 final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
     private static final Logger LOG = LoggerFactory.getLogger(OperationProcessor.class);
     private static final int MAX_TRANSACTION_OPERATIONS = 100;
@@ -32,7 +28,8 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
 
     private final BlockingQueue<TopologyOperation> queue = new LinkedBlockingQueue<>(OPERATION_QUEUE_DEPTH);
     private final DataBroker dataBroker;
-    private final BindingTransactionChain transactionChain;
+    private BindingTransactionChain transactionChain;
+    private volatile boolean finishing = false;
 
     OperationProcessor(final DataBroker dataBroker) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
@@ -49,48 +46,56 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
 
     @Override
     public void run() {
-        try {
-            for (; ; ) {
-                TopologyOperation op = queue.take();
+            while (!finishing) {
+                try {
+                    TopologyOperation op = queue.take();
 
-                LOG.debug("New {} operation available, starting transaction", op);
+                    LOG.debug("New {} operation available, starting transaction", op);
 
-                final ReadWriteTransaction tx = transactionChain.newReadWriteTransaction();
+                    final ReadWriteTransaction tx = transactionChain.newReadWriteTransaction();
 
-                int ops = 0;
-                do {
-                    op.applyOperation(tx);
+                    int ops = 0;
+                    do {
+                        op.applyOperation(tx);
 
-                    ops++;
-                    if (ops < MAX_TRANSACTION_OPERATIONS) {
-                        op = queue.poll();
-                    } else {
-                        op = null;
-                    }
+                        ops++;
+                        if (ops < MAX_TRANSACTION_OPERATIONS) {
+                            op = queue.poll();
+                        } else {
+                            op = null;
+                        }
 
-                    LOG.debug("Next operation {}", op);
-                } while (op != null);
+                        LOG.debug("Next operation {}", op);
+                    } while (op != null);
 
-                LOG.debug("Processed {} operations, submitting transaction", ops);
+                    LOG.debug("Processed {} operations, submitting transaction", ops);
 
-                CheckedFuture<Void, TransactionCommitFailedException> txResultFuture = tx.submit();
-                Futures.addCallback(txResultFuture, new FutureCallback<Void>() {
-                    @Override
-                    public void onSuccess(Void notUsed) {
-                        LOG.debug("Topology export successful for tx :{}", tx.getIdentifier());
+                    try {
+                        tx.submit().checkedGet();
+                    } catch (final TransactionCommitFailedException e) {
+                        LOG.warn("Stat DataStoreOperation unexpected State!", e);
+                        transactionChain.close();
+                        transactionChain = dataBroker.createTransactionChain(this);
+                        cleanDataStoreOperQueue();
                     }
 
-                    @Override
-                    public void onFailure(Throwable throwable) {
-                        LOG.error("Topology export transaction {} failed", tx.getIdentifier(), throwable.getCause());
-                    }
-                });
+                } catch (final IllegalStateException e) {
+                    LOG.warn("Stat DataStoreOperation unexpected State!", e);
+                    transactionChain.close();
+                    transactionChain = dataBroker.createTransactionChain(this);
+                    cleanDataStoreOperQueue();
+                } catch (final InterruptedException e) {
+                    LOG.warn("Stat Manager DS Operation thread interupted!", e);
+                    finishing = true;
+                } catch (final Exception e) {
+                    LOG.warn("Stat DataStore Operation executor fail!", e);
+                }
             }
-        } catch (InterruptedException e) {
-            LOG.info("Interrupted processing, terminating", e);
-        }
-
         // Drain all events, making sure any blocked threads are unblocked
+        cleanDataStoreOperQueue();
+    }
+
+    private void cleanDataStoreOperQueue() {
         while (!queue.isEmpty()) {
             queue.poll();
         }
@@ -99,6 +104,9 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
     @Override
     public void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction, Throwable cause) {
         LOG.error("Failed to export Topology manager operations, Transaction {} failed.", transaction.getIdentifier(), cause);
+        transactionChain.close();
+        transactionChain = dataBroker.createTransactionChain(this);
+        cleanDataStoreOperQueue();
     }
 
     @Override
index b7a56a489019bc56cc78cde3513d8f7a16f7bc4d..7f8d021b3bc28963cc144ed8e347d11545431600 100644 (file)
@@ -8,29 +8,11 @@
 
 package org.opendaylight.md.controller.topology.manager;
 
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.atLeast;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.SettableFuture;
+import com.google.common.util.concurrent.Uninterruptibles;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -82,17 +64,35 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
 
 public class FlowCapableTopologyExporterTest {
 
@@ -135,8 +135,12 @@ public class FlowCapableTopologyExporterTest {
     @Test
     public void testOnNodeRemoved() {
 
+        NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
+        InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
+        Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
+
         org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-                                                                nodeKey = newInvNodeKey("node1");
+                                                                nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
         InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
                 nodeKey);
@@ -154,10 +158,16 @@ public class FlowCapableTopologyExporterTest {
             };
 
         SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
+        readFuture.set(Optional.of(topology));
         ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
         doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1)
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
 
+        SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
+        readFutureNode.set(Optional.of(topoNode));
+        doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1)
+                .read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
+
         CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
 
         int expDeleteCalls = expDeletedIIDs.length;
@@ -166,11 +176,7 @@ public class FlowCapableTopologyExporterTest {
                 ArgumentCaptor.forClass(InstanceIdentifier.class);
         setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
 
-        ReadWriteTransaction mockTx2 = mock(ReadWriteTransaction.class);
-        setupStubbedDeletes(mockTx2, deletedLinkIDs, deleteLatch);
-        CountDownLatch submitLatch2 = setupStubbedSubmit(mockTx2);
-
-        doReturn(mockTx1).doReturn(mockTx2).when(mockTxChain).newReadWriteTransaction();
+        doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
 
         exporter.onNodeRemoved(new NodeRemovedBuilder().setNodeRef(new NodeRef(invNodeID)).build());
 
@@ -180,20 +186,21 @@ public class FlowCapableTopologyExporterTest {
 
         waitForDeletes(expDeleteCalls, deleteLatch);
 
-        waitForSubmit(submitLatch2);
-
         assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
 
         verifyMockTx(mockTx1);
-        verifyMockTx(mockTx2);
     }
 
     @SuppressWarnings({ "rawtypes" })
     @Test
     public void testOnNodeRemovedWithNoTopology() {
 
+        NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
+        InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
+        Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
+
         org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-                                                                nodeKey = newInvNodeKey("node1");
+                nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
         InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(
                 org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
                 nodeKey);
@@ -207,6 +214,11 @@ public class FlowCapableTopologyExporterTest {
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
         CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
 
+        SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
+        readFutureNode.set(Optional.of(topoNode));
+        doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx)
+                .read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
+
         CountDownLatch deleteLatch = new CountDownLatch(1);
         ArgumentCaptor<InstanceIdentifier> deletedLinkIDs =
                 ArgumentCaptor.forClass(InstanceIdentifier.class);
@@ -227,11 +239,17 @@ public class FlowCapableTopologyExporterTest {
     @Test
     public void testOnNodeConnectorRemoved() {
 
+        NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
+        TerminationPointKey terminationPointKey = new TerminationPointKey(new TpId("tp1"));
+
+        InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
+        Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
+
         org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-                                                                  nodeKey = newInvNodeKey("node1");
+                                                                  nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
 
         org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey =
-                newInvNodeConnKey("tp1");
+                newInvNodeConnKey(terminationPointKey.getTpId().getValue());
 
         InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
 
@@ -249,10 +267,16 @@ public class FlowCapableTopologyExporterTest {
             };
 
         final SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
+        readFuture.set(Optional.of(topology));
         ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
         doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1)
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
 
+        SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
+        readFutureNode.set(Optional.of(topoNode));
+        doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1)
+                .read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
+
         CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
 
         int expDeleteCalls = expDeletedIIDs.length;
@@ -261,11 +285,7 @@ public class FlowCapableTopologyExporterTest {
                 ArgumentCaptor.forClass(InstanceIdentifier.class);
         setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
 
-        ReadWriteTransaction mockTx2 = mock(ReadWriteTransaction.class);
-        setupStubbedDeletes(mockTx2, deletedLinkIDs, deleteLatch);
-        CountDownLatch submitLatch2 = setupStubbedSubmit(mockTx2);
-
-        doReturn(mockTx1).doReturn(mockTx2).when(mockTxChain).newReadWriteTransaction();
+        doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
 
         exporter.onNodeConnectorRemoved(new NodeConnectorRemovedBuilder().setNodeConnectorRef(
                 new NodeConnectorRef(invNodeConnID)).build());
@@ -276,23 +296,26 @@ public class FlowCapableTopologyExporterTest {
 
         waitForDeletes(expDeleteCalls, deleteLatch);
 
-        waitForSubmit(submitLatch2);
-
         assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
 
         verifyMockTx(mockTx1);
-        verifyMockTx(mockTx2);
     }
 
     @SuppressWarnings("rawtypes")
     @Test
     public void testOnNodeConnectorRemovedWithNoTopology() {
 
+        NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
+        TerminationPointKey terminationPointKey = new TerminationPointKey(new TpId("tp1"));
+
+        InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
+        Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
+
         org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-                                                                  nodeKey = newInvNodeKey("node1");
+                nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
 
         org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey =
-                newInvNodeConnKey("tp1");
+                newInvNodeConnKey(terminationPointKey.getTpId().getValue());
 
         InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
 
@@ -306,6 +329,11 @@ public class FlowCapableTopologyExporterTest {
                 .read(LogicalDatastoreType.OPERATIONAL, topologyIID);
         CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
 
+        SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
+        readFutureNode.set(Optional.of(topoNode));
+        doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx)
+                .read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
+
         CountDownLatch deleteLatch = new CountDownLatch(1);
         ArgumentCaptor<InstanceIdentifier> deletedLinkIDs =
                 ArgumentCaptor.forClass(InstanceIdentifier.class);
@@ -510,8 +538,8 @@ public class FlowCapableTopologyExporterTest {
         waitForSubmit(submitLatch);
 
         ArgumentCaptor<Link> mergedNode = ArgumentCaptor.forClass(Link.class);
-        verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(
-                Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))),
+        verify(mockTx).put(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(
+                        Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))),
                 mergedNode.capture(), eq(true));
         assertEquals("Source node ID", "sourceNode",
                 mergedNode.getValue().getSource().getSourceNode().getValue());
@@ -538,13 +566,18 @@ public class FlowCapableTopologyExporterTest {
                 destNodeConnKey = newInvNodeConnKey("destTP");
         InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
 
+        Link link = newLink(sourceNodeConnKey.getId().getValue(), newSourceTp(sourceNodeConnKey.getId().getValue()),
+                newDestTp(destNodeConnKey.getId().getValue()));
+
         ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
         CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
         doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
+        doReturn(Futures.immediateCheckedFuture(Optional.of(link))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(
+                Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
 
         exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(
                 new NodeConnectorRef(sourceConnID)).setDestination(
-                        new NodeConnectorRef(destConnID)).build());
+                new NodeConnectorRef(destConnID)).build());
 
         waitForSubmit(submitLatch);
 
@@ -552,6 +585,37 @@ public class FlowCapableTopologyExporterTest {
                 Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
     }
 
+    @Test
+    public void testOnLinkRemovedLinkDoesNotExist() {
+
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
+                sourceNodeKey = newInvNodeKey("sourceNode");
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
+                sourceNodeConnKey = newInvNodeConnKey("sourceTP");
+        InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
+
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
+                destNodeKey = newInvNodeKey("destNode");
+        org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
+                destNodeConnKey = newInvNodeConnKey("destTP");
+        InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
+
+        ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
+        CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
+        doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
+        doReturn(Futures.immediateCheckedFuture(Optional.<Link>absent())).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(
+                Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
+
+        exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(
+                new NodeConnectorRef(sourceConnID)).setDestination(
+                new NodeConnectorRef(destConnID)).build());
+
+        waitForSubmit(submitLatch);
+
+        verify(mockTx, never()).delete(LogicalDatastoreType.OPERATIONAL, topologyIID.child(
+                Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
+    }
+
     private void verifyMockTx(ReadWriteTransaction mockTx) {
         InOrder inOrder = inOrder(mockTx);
         inOrder.verify(mockTx, atLeast(0)).submit();
index 8a29139854c3f801cc372c7c7ac94a1995c20ce4..edba4e11da8661a69660b89051286b4faaa4854e 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>config-netconf-connector</artifactId>
   <packaging>bundle</packaging>
index 2e2b622bd2fa40a6212ff6c5ebe9ffeb58763a81..2b297fbadd348bdafa6bf2f874c583a6410b5bcc 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
   <artifactId>config-persister-impl</artifactId>
index 330bcc879694175695a02376d8fdcf73db79b06f..33e4ef005061eac421c54504e11a92017525f1c1 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>ietf-netconf-monitoring-extension</artifactId>
   <packaging>bundle</packaging>
index 8d4b99bf03148308847dd99796346fcad8458518..5a6c66b95cf36b9bd23c35a3bbe7c076ff8e08b2 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>ietf-netconf-monitoring</artifactId>
   <packaging>bundle</packaging>
index a15047224bfbd91d46bb91f731ef3eea34d61c47..c5fd8f1894fb78bd207486b6c1f3ced16b343318 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-api</artifactId>
   <packaging>bundle</packaging>
index e19359adb8c09e91882430b2258de458c99a50f9..6f1fafff40f8f82fe58e8baa4070c44abfc1341b 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>netconf-subsystem</artifactId>
-        <version>0.2.5-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
         <relativePath>../</relativePath>
     </parent>
     <artifactId>netconf-auth</artifactId>
index 55a87150008ab51f0a96cc163ed218e629e31201..c292d93206559fcf268866e75df86a9db3b7c2ba 100644 (file)
@@ -10,7 +10,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-cli</artifactId>
   <packaging>jar</packaging>
index 6bb67d0681fc7aa559ba888d057a260cc82b24d6..7fbb54165c27ef30b4dfb53e62a5f49e98162ff6 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-client</artifactId>
   <packaging>bundle</packaging>
index db5d14d75af8b03861997a74259cf8c7093cb16f..77551f708018996708fb459d38dcab68b269fafb 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-config</artifactId>
   <description>Configuration files for netconf</description>
index d9cc5eab43f65b6a311d85e10c0b4649eaf5b366..f4e6e99ea0c8ae426e2ae99a721b012841f319f6 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-connector-config</artifactId>
   <description>Configuration files for netconf-connector</description>
index c6544466d4ea2ae49904ce1787adb4823070d166..a987ceefc821681c5ded1111245433b1c45db093 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-impl</artifactId>
   <packaging>bundle</packaging>
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfMonitoringServiceImplTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfMonitoringServiceImplTest.java
new file mode 100644 (file)
index 0000000..1b078be
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import io.netty.channel.Channel;
+import java.util.List;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
+import org.opendaylight.controller.netconf.impl.NetconfServerSession;
+import org.opendaylight.controller.netconf.impl.NetconfServerSessionListener;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
+import org.opendaylight.controller.netconf.mapping.api.Capability;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
+import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
+
+public class NetconfMonitoringServiceImplTest {
+
+    private NetconfMonitoringServiceImpl service;
+
+    @Mock
+    private NetconfOperationProvider operationProvider;
+    @Mock
+    private NetconfManagementSession managementSession;
+    @Mock
+    private NetconfOperationServiceSnapshot snapshot;
+    @Mock
+    private NetconfOperationService operationService;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        service = new NetconfMonitoringServiceImpl(operationProvider);
+    }
+
+    @Test
+    public void testSessions() throws Exception {
+        doReturn("sessToStr").when(managementSession).toString();
+        service.onSessionUp(managementSession);
+        List list = Lists.newArrayList(managementSession);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void testGetSchemas() throws Exception {
+        doThrow(RuntimeException.class).when(operationProvider).openSnapshot(anyString());
+        service.getSchemas();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testGetSchemas2() throws Exception {
+        doThrow(Exception.class).when(operationProvider).openSnapshot(anyString());
+        service.getSchemas();
+    }
+
+    @Test
+    public void testGetSchemas3() throws Exception {
+        doReturn("").when(managementSession).toString();
+        Capability cap = mock(Capability.class);
+        Set caps = Sets.newHashSet(cap);
+        Set services = Sets.newHashSet(operationService);
+        doReturn(snapshot).when(operationProvider).openSnapshot(anyString());
+        doReturn(services).when(snapshot).getServices();
+        doReturn(caps).when(operationService).getCapabilities();
+        Optional opt = mock(Optional.class);
+        doReturn(opt).when(cap).getCapabilitySchema();
+        doReturn(true).when(opt).isPresent();
+        doReturn(opt).when(cap).getModuleNamespace();
+        doReturn("namespace").when(opt).get();
+        Optional optRev = Optional.of("rev");
+        doReturn(optRev).when(cap).getRevision();
+        doReturn(Optional.of("modName")).when(cap).getModuleName();
+        doReturn(Optional.of(Lists.newArrayList("loc"))).when(cap).getLocation();
+        doNothing().when(snapshot).close();
+
+        assertNotNull(service.getSchemas());
+        verify(snapshot, times(1)).close();
+
+        NetconfServerSessionListener sessionListener = mock(NetconfServerSessionListener.class);
+        Channel channel = mock(Channel.class);
+        NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("name", "addr", "2", "tcp", "id");
+        NetconfServerSession sm = new NetconfServerSession(sessionListener, channel, 10, header);
+        doNothing().when(sessionListener).onSessionUp(any(NetconfServerSession.class));
+        sm.sessionUp();
+        service.onSessionUp(sm);
+        assertEquals(1, service.getSessions().getSession().size());
+
+        assertEquals(Long.valueOf(10), service.getSessions().getSession().get(0).getSessionId());
+
+        service.onSessionDown(sm);
+        assertEquals(0, service.getSessions().getSession().size());
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSessionTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSessionTest.java
new file mode 100644 (file)
index 0000000..ae3d656
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.mapping.operations;
+
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+public class DefaultCloseSessionTest {
+    @Test
+    public void testDefaultCloseSession() throws Exception {
+        AutoCloseable res = mock(AutoCloseable.class);
+        doNothing().when(res).close();
+        DefaultCloseSession session = new DefaultCloseSession("", res);
+        Document doc = XmlUtil.newDocument();
+        XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
+        session.handleWithNoSubsequentOperations(doc, elem);
+    }
+
+    @Test(expected = NetconfDocumentedException.class)
+    public void testDefaultCloseSession2() throws Exception {
+        AutoCloseable res = mock(AutoCloseable.class);
+        doThrow(NetconfDocumentedException.class).when(res).close();
+        DefaultCloseSession session = new DefaultCloseSession("", res);
+        Document doc = XmlUtil.newDocument();
+        XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
+        session.handleWithNoSubsequentOperations(doc, elem);
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommitTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommitTest.java
new file mode 100644 (file)
index 0000000..98050de
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.mapping.operations;
+
+import com.google.common.collect.Sets;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
+import org.opendaylight.controller.netconf.impl.NetconfServerSession;
+import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import static org.mockito.Mockito.*;
+
+public class DefaultCommitTest {
+
+    private NetconfOperationChainedExecution operation;
+    private Document requestMessage;
+    private NetconfOperationRouter router;
+    private DefaultCommitNotificationProducer notifier;
+    private CapabilityProvider cap;
+    private DefaultCommit commit;
+
+    @Before
+    public void setUp() throws Exception {
+        operation = mock(NetconfOperationChainedExecution.class);
+        doReturn(XmlUtil.newDocument()).when(operation).execute(any(Document.class));
+        router = mock(NetconfOperationRouter.class);
+        doReturn(false).when(operation).isExecutionTermination();
+        notifier = mock(DefaultCommitNotificationProducer.class);
+        doNothing().when(notifier).sendCommitNotification(anyString(), any(Element.class), anySetOf(String.class));
+        cap = mock(CapabilityProvider.class);
+        doReturn(Sets.newHashSet()).when(cap).getCapabilities();
+        Document rpcData = XmlFileLoader.xmlFileToDocument("netconfMessages/editConfig_expectedResult.xml");
+        doReturn(rpcData).when(router).onNetconfMessage(any(Document.class), any(NetconfServerSession.class));
+        commit = new DefaultCommit(notifier, cap, "", router);
+    }
+
+    @Test
+    public void testHandleWithNotification() throws Exception {
+        requestMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/commit.xml");
+        commit.handle(requestMessage, operation);
+        verify(operation, times(1)).execute(requestMessage);
+        verify(notifier, times(1)).sendCommitNotification(anyString(), any(Element.class), anySetOf(String.class));
+    }
+
+    @Test
+    public void testHandleWithoutNotification() throws Exception {
+        requestMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/commit.xml");
+        Element elem = requestMessage.getDocumentElement();
+        elem.setAttribute("notify", "false");
+        commit.handle(requestMessage, operation);
+        verify(operation, times(1)).execute(requestMessage);
+        verify(notifier, never()).sendCommitNotification(anyString(), any(Element.class), anySetOf(String.class));
+    }
+
+    @Test(expected = NetconfDocumentedException.class)
+    public void testHandle() throws Exception {
+        Document rpcData = XmlFileLoader.xmlFileToDocument("netconfMessages/get.xml");
+        doReturn(rpcData).when(router).onNetconfMessage(any(Document.class), any(NetconfServerSession.class));
+        requestMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/commit.xml");
+        commit.handle(requestMessage, operation);
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchemaTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchemaTest.java
new file mode 100644 (file)
index 0000000..b655e90
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.mapping.operations;
+
+import com.google.common.base.Optional;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.w3c.dom.Document;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+public class DefaultGetSchemaTest {
+
+    private CapabilityProvider cap;
+    private Document doc;
+    private String getSchema;
+
+    @Before
+    public void setUp() throws Exception {
+        cap = mock(CapabilityProvider.class);
+        doc = XmlUtil.newDocument();
+        getSchema = "<get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">\n" +
+                "        <identifier>threadpool-api</identifier>\n" +
+                "        <version>2010-09-24</version>\n" +
+                "        <format\n" +
+                "                xmlns:ncm=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">ncm:yang\n" +
+                "        </format>\n" +
+                "    </get-schema>";
+    }
+
+    @Test(expected = NetconfDocumentedException.class)
+    public void testDefaultGetSchema() throws Exception {
+        DefaultGetSchema schema = new DefaultGetSchema(cap, "");
+        doThrow(IllegalStateException.class).when(cap).getSchemaForCapability(anyString(), any(Optional.class));
+        schema.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema)));
+    }
+
+    @Test
+    public void handleWithNoSubsequentOperations() throws Exception {
+        DefaultGetSchema schema = new DefaultGetSchema(cap, "");
+        doReturn("").when(cap).getSchemaForCapability(anyString(), any(Optional.class));
+        assertNotNull(schema.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema))));
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExiTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExiTest.java
new file mode 100644 (file)
index 0000000..b335165
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.mapping.operations;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelPipeline;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.impl.NetconfServerSession;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.w3c.dom.Document;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.*;
+
+public class DefaultStopExiTest {
+    @Test
+    public void testHandleWithNoSubsequentOperations() throws Exception {
+        DefaultStopExi exi = new DefaultStopExi("");
+        Document doc = XmlUtil.newDocument();
+        Channel channel = mock(Channel.class);
+        ChannelPipeline pipeline = mock(ChannelPipeline.class);
+        doReturn(pipeline).when(channel).pipeline();
+        ChannelHandler channelHandler = mock(ChannelHandler.class);
+        doReturn(channelHandler).when(pipeline).replace(anyString(), anyString(), any(ChannelHandler.class));
+
+        NetconfServerSession serverSession = new NetconfServerSession(null, channel, 2L, null);
+        exi.setNetconfSession(serverSession);
+
+        assertNotNull(exi.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"))));
+        verify(pipeline, times(1)).replace(anyString(), anyString(), any(ChannelHandler.class));
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivatorTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivatorTest.java
new file mode 100644 (file)
index 0000000..b59ea88
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.osgi;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Dictionary;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
+import org.osgi.framework.*;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+public class NetconfImplActivatorTest {
+
+    @Mock
+    private BundleContext bundle;
+    @Mock
+    private Filter filter;
+    @Mock
+    private ServiceReference reference;
+    @Mock
+    private ServiceRegistration registration;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        doReturn(filter).when(bundle).createFilter(anyString());
+        doNothing().when(bundle).addServiceListener(any(ServiceListener.class), anyString());
+
+        ServiceReference[] refs = new ServiceReference[0];
+        doReturn(refs).when(bundle).getServiceReferences(anyString(), anyString());
+        doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), anyString());
+        doReturn("").when(bundle).getProperty(anyString());
+        doReturn(registration).when(bundle).registerService(any(Class.class), any(NetconfOperationServiceFactoryListenerImpl.class), any(Dictionary.class));
+        doNothing().when(registration).unregister();
+        doNothing().when(bundle).removeServiceListener(any(ServiceListener.class));
+    }
+
+    @Test
+    public void testStart() throws Exception {
+        NetconfImplActivator activator = new NetconfImplActivator();
+        activator.start(bundle);
+        verify(bundle, times(2)).registerService(any(Class.class), any(NetconfOperationServiceFactoryListenerImpl.class), any(Dictionary.class));
+        activator.stop(bundle);
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryTrackerTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryTrackerTest.java
new file mode 100644 (file)
index 0000000..374e8ae
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.osgi;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+public class NetconfOperationServiceFactoryTrackerTest {
+
+    @Mock
+    private Filter filter;
+    @Mock
+    private BundleContext context;
+    @Mock
+    private NetconfOperationServiceFactoryListener listener;
+    @Mock
+    private NetconfOperationServiceFactory factory;
+    @Mock
+    private ServiceReference reference;
+
+    private NetconfOperationServiceFactoryTracker tracker;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        doNothing().when(listener).onRemoveNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class));
+        doReturn(filter).when(context).createFilter(anyString());
+        doReturn("").when(reference).toString();
+        doReturn(factory).when(context).getService(any(ServiceReference.class));
+        doReturn("").when(factory).toString();
+        doNothing().when(listener).onAddNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class));
+        tracker = new NetconfOperationServiceFactoryTracker(context, listener);
+    }
+
+    @Test
+    public void testNetconfOperationServiceFactoryTracker() throws Exception {
+        tracker.removedService(null, factory);
+        verify(listener, times(1)).onRemoveNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class));
+    }
+
+    @Test
+    public void testAddingService() throws Exception {
+        assertNotNull(tracker.addingService(reference));
+        verify(listener, times(1)).onAddNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class));
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/util/DeserializerExceptionHandlerTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/util/DeserializerExceptionHandlerTest.java
new file mode 100644 (file)
index 0000000..6512b4b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.impl.util;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.util.concurrent.GenericFutureListener;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.*;
+
+public class DeserializerExceptionHandlerTest {
+
+    private DeserializerExceptionHandler handler;
+    private ChannelFuture channelFuture;
+    private ChannelHandlerContext context;
+    private Channel channel;
+
+    @Before
+    public void setUp() throws Exception {
+        handler = new DeserializerExceptionHandler();
+        context = mock(ChannelHandlerContext.class);
+        channel = mock(Channel.class);
+        doReturn(channel).when(context).channel();
+        channelFuture = mock(ChannelFuture.class);
+        doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
+        doReturn(channelFuture).when(channel).writeAndFlush(anyObject());
+    }
+
+    @Test
+    public void testExceptionCaught() throws Exception {
+        handler.exceptionCaught(context, new Exception());
+        verify(context, times(1)).channel();
+    }
+}
index 3a70a399bb8f82f563eb5e9f7eaa252c9f28eeb0..b2c5c4c8f7a6fa4a6818ba5a740cae1b29ebb7c2 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>netconf-it</artifactId>
index 1a510f939c24dcae4e07b1928a08ba06d4012a9f..7d51f6db9940144e2b87720e17c0736eccd17014 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-mapping-api</artifactId>
 
index 03193b84923d98e69e7f6262d5e2e135eb45ab92..22c61954c3d02b93f790347ab343f4379d843cf6 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-monitoring</artifactId>
   <packaging>bundle</packaging>
diff --git a/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringActivatorTest.java b/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringActivatorTest.java
new file mode 100644 (file)
index 0000000..4049356
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.monitoring.osgi;
+
+import java.util.Arrays;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
+
+public class NetconfMonitoringActivatorTest {
+
+    @Mock
+    BundleContext context;
+    @Mock
+    Filter filter;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        doReturn(filter).when(context).createFilter(anyString());
+        doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
+        ServiceReference[] refs = new ServiceReference[2];
+        doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
+        doReturn(refs).when(context).getServiceReferences(anyString(), anyString());
+    }
+
+    @Test
+    public void testNetconfMonitoringActivator() throws Exception {
+        NetconfMonitoringActivator activator = new NetconfMonitoringActivator();
+        activator.start(context);
+        verify(context, times(1)).addServiceListener(any(ServiceListener.class), anyString());
+
+        activator.stop(context);
+        verify(context, times(1)).removeServiceListener(any(ServiceListener.class));
+    }
+}
diff --git a/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringOperationServiceTest.java b/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringOperationServiceTest.java
new file mode 100644 (file)
index 0000000..b8e35e9
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.monitoring.osgi;
+
+import com.google.common.base.Optional;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+
+public class NetconfMonitoringOperationServiceTest {
+    @Test
+    public void testGetters() throws Exception {
+        NetconfMonitoringService monitor = mock(NetconfMonitoringService.class);
+        NetconfMonitoringOperationService service = new NetconfMonitoringOperationService(monitor);
+
+        assertEquals(1, service.getNetconfOperations().size());
+
+        assertEquals(Optional.absent(), service.getCapabilities().iterator().next().getCapabilitySchema());
+        assertEquals(Optional.absent(), service.getCapabilities().iterator().next().getLocation());
+        assertEquals(Optional.of(MonitoringConstants.MODULE_REVISION), service.getCapabilities().iterator().next().getRevision());
+        assertEquals(Optional.of(MonitoringConstants.MODULE_NAME), service.getCapabilities().iterator().next().getModuleName());
+        assertEquals(Optional.of(MonitoringConstants.NAMESPACE), service.getCapabilities().iterator().next().getModuleNamespace());
+        assertEquals(MonitoringConstants.URI, service.getCapabilities().iterator().next().getCapabilityUri());
+    }
+}
diff --git a/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringServiceTrackerTest.java b/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringServiceTrackerTest.java
new file mode 100644 (file)
index 0000000..2a53a6c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.monitoring.osgi;
+
+import java.util.Hashtable;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyCollection;
+import static org.mockito.Mockito.*;
+
+public class NetconfMonitoringServiceTrackerTest {
+
+    @Mock
+    private ServiceReference reference;
+    @Mock
+    private BundleContext context;
+    @Mock
+    private ServiceRegistration serviceRegistration;
+    @Mock
+    private Filter filter;
+    @Mock
+    private NetconfMonitoringService monitoringService;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        doReturn(serviceRegistration).when(context).registerService(any(Class.class), any(NetconfOperationServiceFactory.class), any(Hashtable.class));
+        doNothing().when(serviceRegistration).unregister();
+        doReturn(filter).when(context).createFilter(anyString());
+        doReturn("").when(reference).toString();
+        doReturn(monitoringService).when(context).getService(any(ServiceReference.class));
+    }
+
+    @Test
+    public void testAddingService() throws Exception {
+        NetconfMonitoringServiceTracker tracker = new NetconfMonitoringServiceTracker(context);
+        tracker.addingService(reference);
+        verify(context, times(1)).registerService(any(Class.class), any(NetconfOperationServiceFactory.class), any(Hashtable.class));
+        tracker.removedService(reference, null);
+        verify(serviceRegistration, times(1)).unregister();
+    }
+}
index cb8461a29965816320f1de6087e7a13629c4be9e..e2afcc42f54f317d19490a7f9edfe864e9907acf 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-netty-util</artifactId>
   <packaging>bundle</packaging>
index 6dd23776ce0c0b2f642ffb71d833b577bae10fa8..221626b7410a4fa166dbcb63616d93dff2994abd 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
   <artifactId>netconf-ssh</artifactId>
index 3c4ee4728d9f311664f2c04e1b7c1d4f2c278580..8ec33286a7e76c51fd47d7a9907669cb6511fe17 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
   <artifactId>netconf-tcp</artifactId>
index ae0bb76832469f4f7e6c9e22095087239fd5a96f..c9de92b9d5e22799233a846e4ec1100041dcb025 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>netconf-subsystem</artifactId>
-        <version>0.2.5-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>netconf-testtool</artifactId>
index f8c3e5a504dafd32251bdbb769a555a1bce03f69..44e6c614725c18b48df15061e94d37ae4845924d 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>netconf-subsystem</artifactId>
-        <version>0.2.5-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
         <relativePath>../</relativePath>
     </parent>
     <artifactId>netconf-usermanager</artifactId>
index bed58beb0f3494a6914986c339af55611c3572b4..de9b2a0a06b762e78cfb1978464252431913e0e8 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>netconf-subsystem</artifactId>
-    <version>0.2.5-SNAPSHOT</version>
+    <version>0.3.0-SNAPSHOT</version>
   </parent>
   <artifactId>netconf-util</artifactId>
   <packaging>bundle</packaging>
index 8abf67ec8c5fe198315be84d8f8d5d9d424347e0..2bb6a2003568cbe5f990f410e6a60f0a22d5d6fa 100644 (file)
@@ -5,12 +5,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
   <artifactId>netconf-subsystem</artifactId>
 
-  <version>0.2.5-SNAPSHOT</version>
+  <version>0.3.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>${project.artifactId}</name>
   <prerequisites>
index c8f1dd270d91ed7863806f1724c3ce3eda56ce8d..a9061d57d1fc3af4c17fa3e87a4b125586cfc6d5 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>networkconfig.neutron.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <properties>
     <enunciate.version>1.26.2</enunciate.version>
index 6dc0e46b61749673b799c7d94efb91240658f4e3..3294474b49480ed9153bcef9bf2d753d6c505be8 100644 (file)
@@ -233,6 +233,9 @@ public class NeutronPortInterface implements INeutronPortCRUD, IConfigurationCon
         portDB.putIfAbsent(input.getID(), input);
         // if there are no fixed IPs, allocate one for each subnet in the network
         INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
+        if (input.getFixedIPs() == null){
+           input.setFixedIPs(new ArrayList<Neutron_IPs>());
+        }
         if (input.getFixedIPs().size() == 0) {
             List<Neutron_IPs> list = input.getFixedIPs();
             Iterator<NeutronSubnet> subnetIterator = systemCRUD.getAllSubnets().iterator();
index 998dd4488cdef15ddd68dab6c9ef86ad4a856790..75ab2816cccef11818b0e8e99fb510d181c79941 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>networkconfig.neutron</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <properties>
     <enunciate.version>1.26.2</enunciate.version>
index 558bf4191560245629426de8f65628ea9bfa3c1d..67c111f94de58ef1fefa51770ffde600701433c7 100644 (file)
@@ -4,7 +4,7 @@
 
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>app-northbound</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>maven-archetype</packaging>
 
   <name>app-northbound</name>
index da1bd411923e096bb9f6d13b740363b304632366..adb0c9870503e16ed7f2d0763a857181be1c5f6c 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
index ee83c9358093e6663a40749c4825020d0c09e499..78bfd385796a16a4ef914e967dfc92c8cd3956c8 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>bundlescanner</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index c06f8b42156b3a596171ed7b87b5d9938c2327b4..5694b2adcf43b9a2d12cdd03b123d1d14eb56c3e 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>bundlescanner.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index cbc1f0c328e58be31f53304c657ed050f746ffe1..9d229e4e7072d27970ea1a3602443a0e11d78134 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>commons.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index ad315ac008e78e78712fc6bbc7a6f74e8b12b7b3..893dcd14f34104c96533a5bae72d0e20d75e3202 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>connectionmanager.northbound</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 2e6bb7d40ca0d5245200699822198b8d9ba1c697..74fd115dee1fbb8033be1ea0d4532d300cb10707 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>containermanager.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 89d2b99cadb7b89409a11fb600638edd8897ed2d..33f9a06246a55b9cbbdc002b52ebac6c90e0a8dc 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>controllermanager.northbound</artifactId>
-  <version>0.0.2-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 43797f5c6558d84cca3f256d6f2bbdcf4f380407..083a7a2cb8539d475b00e246954e4ea7ccbe766f 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>flowprogrammer.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index c8415f8b4f77cc63496d3a8abaa5abe0810da9b4..3cd3f36be04c2e9912dba333bc79dfe2a011280e 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>hosttracker.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index c7b9cfc9a06bf4a65223879e284ace31c6235d4a..deeabd9d00c0ef3a6a422468847ab6b12b1058bb 100644 (file)
@@ -5,12 +5,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>httpservice-bridge</artifactId>
-  <version>0.0.2-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <description>HttpService bridge web application</description>
 
index 6f0d897f99ebdf9db7edfebe573d1fcbf8f90934..df0d1139afa73fe0acff6a13d9e0e65b757a3c6b 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>northbound.integrationtest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <dependencies>
     <dependency>
       <groupId>ch.qos.logback</groupId>
index ae8924feb6aaf79970c042b4a88af698e23e2bb7..a4bcde461ecb9c21433d4b93d7206cea6af8df8c 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>northbound.client</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <properties>
index 62af41ab46964cd64445805f7b3f8e07aa8c93ad..07e3a7d36ba3109677d291134b9f44a0a5656453 100644 (file)
@@ -5,12 +5,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>jolokia-bridge</artifactId>
-  <version>0.0.2-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <description>Jolokia bridge web application</description>
 
index f11297808047edac9bf33663e434cdf1363e6fa9..8b552ba25a6625b1978078473f973739f709c8c4 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>networkconfig.bridgedomain.northbound</artifactId>
-  <version>0.0.3-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 19bcfe44ec5b18835b328a3f291b15eecb192c06..8111e69c19bb0b7874387da1ecea394381f1bd5c 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>networkconfig.neutron.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 83f8191e025e1c4d23d3bd8673f2ed0046ff9408..761f1f08e9b65ed73091f634902d564fd71c9722 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>forwarding.staticrouting.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 7e2919bc44c1a7f698f2afe77c31d3347de3fc4a..4ae3d8746c44f3e0d6339892e07b49eea313f1b2 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>statistics.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 630221fcc2dac2b0c53a945cbeaf41ef63c9a1cd..1efb974b51467036add7c2fddcc4ee02f68fbde9 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>subnets.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 18eaed98ec17c35d3847746677c0e704e3fe8bde..bbb80a7811f45ef07831c65bedf0c203d79c9fd6 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>swagger-ui</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <properties>
index 614ec8847658d87800de3f6319c076357020d269..1b876f4420cf2cafc01f8eef90cf8bae2eed5cd8 100644 (file)
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>switchmanager.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 3f1a7701102467edf00dd974c254407728049176..270148420c2e16f6498997fca6d5b85b2a8b40a9 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>topology.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index c7ab2fa71201a44622d2ab3b2208a430b7e67af8..fe32bcf5d3840ddbcd735cc48eb5b91c6b593bfa 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>usermanager.northbound</artifactId>
-  <version>0.0.2-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 5a0f5f3254518733ddb7060ba6fba0cbb24dd3a7..11c885db308c9ad1a96f8a1120f599385e25db98 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.0-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../opendaylight/commons/opendaylight</relativePath>
   </parent>
   <scm>
@@ -16,7 +16,7 @@
 
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>northboundtest</artifactId>
-        <version>0.4.0-SNAPSHOT</version>
+        <version>0.5.0-SNAPSHOT</version>
         <packaging>bundle</packaging>
 
         <build>
index a8fceec2bfc435f2a4d3d01332ed720f3f9b588a..16fadee1cc9c5a65d8b0920c15a0d940e975cb34 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>protocol_plugins.openflow</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 540c9afb2c01544eee6f3dc496d29846fe953a91..4c7b8965fbbfc4383810c95583d0c39d963d8da0 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>protocol_plugins.stub</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index b691308e971cc269fd10338ad7f15e6cf369b58a..b1b68b8cb7a47dd927b6c526c54730f93d933110 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>routing.dijkstra_implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 3ee239a0f4fd990a469b7a9de40187c294c6b27e..50ac61fccbe94875cdafb33da26dfc54e8abd959 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal</artifactId>
-  <version>0.8.1-SNAPSHOT</version>
+  <version>0.9.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index b194f76a455d6d0aedce563cec5b3b28f4236192..780631791d64e9fa96c5e0313fcd762147b368a6 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal.connection</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 71506835978eb2591a33977fe108d4d781108673..a7d5dfafb9919bf1a894976b30b4de28bf371d0a 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal.connection.implementation</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 88986dcdd0d405292d52dbdfebc54383d44ac161..3f1aa86be8151db5a89e5c42ac1cfcbffeccf6e4 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 5b2269ae6d3cae45bba2461826bf5b1fdf3c5b73..4b183497450dcb7c0d29819c02ebb55692be7ce0 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal.networkconfiguration</artifactId>
-  <version>0.0.3-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 508c9bd3f5f98b66f61b484b6ec5d046b2db3da4..bf476a924aea347aeaf1dae87a0ed9ee0222a588 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>sal.networkconfiguration.implementation</artifactId>
-  <version>0.0.3-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index f72e47b283893f31e87c53a1a582726832039595..10ae20ca630758d2ab5f3055413816c1adc81c72 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>clustersession</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
+  <version>1.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
@@ -43,7 +43,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.5.1-SNAPSHOT</version>
+      <version>0.6.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
index 79390838919c54d40382cbf7047e2499f53977b9..a7b41096d7dc4d969d21f221f9c2db1799699c79 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>samples.loadbalancer</artifactId>
-  <version>0.5.2-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index d39241757fea07732c7920340fd3fdd5ebf37c7d..18aa4e1d62a35ca41f261114cf83170766d33b01 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>samples.loadbalancer.northbound</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 1208506bd5fb9bc010aaf19889a0149656e6082d..50410f85afc288b020c421a82af9e75c01592db5 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>samples.simpleforwarding</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 896e7184b223dda4455c7124d34f52bf2d8813da..49889de7f192a6336d9e9c31d4fc7a5453f9de52 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>security</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index aa9b88e1b2e19d18e1675095b4c20b08b8b3c873..23edfa399131dd4cf579d4466edf54b72363c00d 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>statisticsmanager</artifactId>
-  <version>0.5.1-SNAPSHOT</version>
+  <version>0.6.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 10abb3d2516ff815da2d7c7cd1024970a413eaa2..08db43a0f04f9e407b86f0eaa48896a9ed81d0f1 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>statisticsmanager.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <properties>
     <!-- Sonar properties using jacoco to retrieve integration test results -->
index 2946e698fe21a28f9ff5b66d28877999f5f9cb2f..22696b71e6e77660425f092832b3d84a8d51f112 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>statisticsmanager.integrationtest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <properties>
     <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <!-- Sonar jacoco plugin to get integration test coverage info -->
index 94ba0216cc1b848948c8bde003fba275c9dd8ccd..a29341ee6f7c203cf7e4653bf08f3142fe6977c8 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>switchmanager</artifactId>
-  <version>0.7.1-SNAPSHOT</version>
+  <version>0.8.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <properties>
index a0718db48a1c4ae28128831336f3bd03978020ba..fe7a0c0bcb407f42c5e975974bd6817e472c6b88 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>switchmanager.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <properties>
index 4a8d93f3b3d822eace16344fe1929ef9bf5bd5a5..708ac32763b3f12e394809ec054c89a5ffa3a75d 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>switchmanager.integrationtest</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <properties>
     <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <!-- Sonar jacoco plugin to get integration test coverage info -->
index 746135891ea5acf3b976ae64421dda9a393c4f07..430dfca74db3f50394f156a6dcb27f59bf098c3b 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>topologymanager</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index e278ecffd9c911fb1e5bb53e8e1375048cdd270a..ce6422c8c1d6dbafd3223957d76410d549c48f69 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.2-SNAPSHOT</version>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath>../../commons/integrationtest</relativePath>
   </parent>
 
   <artifactId>topologymanager.integrationtest</artifactId>
-  <version>0.4.1-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <properties>
     <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <!-- Sonar jacoco plugin to get integration test coverage info -->
index 078b55c596ef8167851a5fd8f7a45333dafbbd85..2de8c5c26c6c05cbac6d8400853393107048fb99 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <artifactId>topologymanager.shell</artifactId>
index c932a7cb31b201eb2a62246def052b428c47c6c2..e21337242aa5693f95e04882d2bd1d955cebfb80 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>usermanager</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 9567db0293dc29cb981b00184246f6cc430bc175..d973f670b207b0a36a4d98e19422e2d497aa5907 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>usermanager.implementation</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index 541dbcadfd8644023b03055f3109220cf604ecd3..25f62f059e0b229c5879faf7227b073bde24565c 100644 (file)
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>commons.opendaylight</artifactId>
-        <version>1.4.0-SNAPSHOT</version>
+        <version>1.5.0-SNAPSHOT</version>
         <relativePath>../../commons/opendaylight</relativePath>
     </parent>
   <scm>
@@ -17,7 +17,7 @@
 
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>web.brandfragment</artifactId>
-    <version>0.4.0-SNAPSHOT</version>
+    <version>0.5.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <build>
index 890694642348f55e4856acd0a5c1c21dae1fab60..8e7c9248ddc4b90d87784b1ba226f8637967f48a 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>devices.web</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index f62c6ac4d4f5169bfab268852c5f167159f16657..99238c6aad52f2d769258f57d46f04618db66d48 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>flows.web</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index fc04088961473353ac4df5731b7b8d423055be1e..adea8ace621b2b8cf987c4dd75b3bb9324ac018b 100644 (file)
@@ -5,12 +5,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>osgi-brandfragment.web</artifactId>
-  <version>0.0.2-SNAPSHOT</version>
+  <version>0.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <description>OSGi management web application brand fragment</description>
 
index 6f0a0989b86865633bfcffd5175beee51c2afecf..cd82f8b07fbeadcc09f5265fac5666da232fcad2 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>web</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index e65c19ff849abe33c0d0b08e6f97446c23758c1b..24b53db7676abb038391ac67f5242326ea77b22a 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>topology.web</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
index b66889284d0c6d48f0b434a04fa6a8dc91045c3d..14817bd186cfe8acafdf87ec212605e5577fdb55 100644 (file)
@@ -4,12 +4,12 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
-    <version>1.4.2-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <relativePath>../../commons/opendaylight</relativePath>
   </parent>
 
   <artifactId>troubleshoot.web</artifactId>
-  <version>0.4.2-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
     <dependency>
diff --git a/pom.xml b/pom.xml
index 10c05e254f84d88d25f1e3e9b5ef3da3af84b7a1..bb8ad1dbeba6459a1b9e5acb90070febc1b5a72a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -4,11 +4,11 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.parent</artifactId>
-    <version>1.0.2-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <relativePath>opendaylight/commons/parent</relativePath>
   </parent>
   <artifactId>releasepom</artifactId>
-  <version>0.1.2-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <prerequisites>
     <maven>3.0</maven>
index 3fc3a3bd6a9fd680e584eb9c2ac7ac9aec49f222..ad3c27523e4ac7a2596ef7405de4de4bed067938 100644 (file)
@@ -6,7 +6,7 @@
   </prerequisites>
   <groupId>org.opendaylight.controller</groupId>
   <artifactId>commons.thirdparty</artifactId>
-  <version>1.1.2-SNAPSHOT</version>
+  <version>1.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
index f67828bdab68fb678a67c038568b34d3a87321af..676e2a24f1d07fb5f1a1b7f966005c0914e47ecf 100644 (file)
@@ -5,13 +5,13 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>commons.thirdparty</artifactId>
-        <version>1.1.2-SNAPSHOT</version>
+        <version>1.2.0-SNAPSHOT</version>
         <relativePath>../commons/thirdparty</relativePath>
     </parent>
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
     <artifactId>ganymed</artifactId>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <dependencies>
index 7e944c15da41cf46ebaf14a4b7aa2e2ca7046ab6..27d503e89814c893a540aa191e18d5097a16c870 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.thirdparty</artifactId>
-    <version>1.1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../commons/thirdparty</relativePath>
   </parent>
   <scm>
@@ -17,7 +17,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.controller.thirdparty</groupId>
   <artifactId>com.sun.jersey.jersey-servlet</artifactId>
-  <version>1.18-SNAPSHOT</version>
+  <version>1.19.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <build>
     <plugins>
index fe15316023f41d306be25e2759addf6943cf7ced..63455dc8beacde617a67a02ceefcf0639796d8d7 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.thirdparty</artifactId>
-    <version>1.1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../commons/thirdparty</relativePath>
   </parent>
   <scm>
@@ -17,7 +17,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.controller.thirdparty</groupId>
   <artifactId>net.sf.jung2</artifactId>
-  <version>2.0.2-SNAPSHOT</version>
+  <version>2.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <build>
     <plugins>
index 8d8724dcebcaec03bf50d6f668d437e77a8dea3c..9e04a70b838a179a52e923b72b61b75829aa0c7d 100644 (file)
@@ -2,7 +2,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.controller.thirdparty</groupId>
   <artifactId>org.openflow.openflowj</artifactId>
-  <version>1.0.3-SNAPSHOT</version>
+  <version>1.1.0-SNAPSHOT</version>
   <name>OpenFlow Java</name>
   <description>A Java implemention of the OpenFlow v1.0 protocol</description>
 
@@ -10,7 +10,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.thirdparty</artifactId>
-    <version>1.1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../commons/thirdparty</relativePath>
   </parent>
   
index 85e631686e77eb43042e87c5c8536432bd76362b..78996da2cb4fb8ecfd1aa19f85cbfeb7c035b0f2 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.thirdparty</artifactId>
-    <version>1.1.1-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
     <relativePath>../commons/thirdparty</relativePath>
   </parent>
   <scm>
@@ -16,7 +16,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.controller.thirdparty</groupId>
   <artifactId>org.apache.catalina.filters.CorsFilter</artifactId>
-  <version>7.0.43-SNAPSHOT</version>
+  <version>7.1.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <build>
     <plugins>