Merge "Bug 1236 - Documented Binding-aware RPC services of MD-SAL"
authorDevin Avery <devin.avery@brocade.com>
Tue, 1 Jul 2014 13:02:59 +0000 (13:02 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 1 Jul 2014 13:02:59 +0000 (13:02 +0000)
346 files changed:
features/base/pom.xml
features/base/src/main/resources/features.xml
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPReply.java
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-persister-api/src/main/java/org/opendaylight/controller/config/persist/api/ConfigSnapshotHolder.java
opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java
opendaylight/distribution/opendaylight-karaf/pom.xml
opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/custom.properties
opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/startup.properties
opendaylight/distribution/opendaylight/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-netconf.xml [new file with mode: 0644]
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-clustering.xml [deleted file]
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/03-toaster-sample.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/99-netconf-connector.xml
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java
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/MDFlowMapping.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.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/test/MDFlowMappingTest.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java [new file with mode: 0644]
opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-match-types.yang
opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-port-types.yang
opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-table-types.yang
opendaylight/md-sal/pom.xml
opendaylight/md-sal/remoterpc-routingtable/implementation/pom.xml [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RouteChangeListener.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RoutingTable.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RoutingTableException.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/SystemException.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/impl/Activator.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/impl/RoutingTableImpl.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/impl/RoutingTableImplTest.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/integrationtest/pom.xml [deleted file]
opendaylight/md-sal/remoterpc-routingtable/integrationtest/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/impl/ZeroMQRoutingTableTestIT.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/pom.xml [deleted file]
opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqroutingtable/rest/RouteIdentifierImpl.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqroutingtable/rest/Router.java [deleted file]
opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/resources/WEB-INF/web.xml [deleted file]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java [deleted file]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataChangeListener.java [moved from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataChangeListener.java with 87% similarity]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java [moved from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadTransaction.java with 88% similarity]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java [moved from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadWriteTransaction.java with 64% similarity]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java [moved from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataWriteTransaction.java with 74% similarity]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataReadTransactionImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataReadWriteTransactionImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBindingDataBroker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java
opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java
opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java [new file with mode: 0644]
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/ListenerProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerRegistrationProxy.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/ShardTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.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/messages/AbortTransaction.java [moved from opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcServer.java with 57% similarity]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ForwardedCommitTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryFound.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyTransactionReply.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/modification/AbstractModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedDataStoreProviderModule.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java [new file with mode: 0644]
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/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/DoNothingActor.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MessageCollectorActor.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedTransactionFactory.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ConflictingModificationAppliedException.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTree.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidate.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidateNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeModification.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeSnapshot.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataValidationFailedException.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/IncorrectDataStructureException.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ModificationType.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreTreeNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreUtils.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AbstractDataTreeCandidate.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AlwaysFailOperation.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/DataNodeContainerModificationStrategy.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTree.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeCandidate.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeFactory.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeSnapshot.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationApplyOperation.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModifiedNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NoopDataTreeCandidate.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/OperationWithModification.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperation.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ValueNodeModificationStrategy.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/AbstractTreeNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ContainerNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/MutableTreeNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNodeFactory.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ValueNode.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/Version.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java
opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationMetadataTreeTest.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperationRoot.java [deleted file]
opendaylight/md-sal/sal-dom-spi/pom.xml
opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-config-dom-datastore.yang [new file with mode: 0644]
opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-operational-dom-datastore.yang [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/pom.xml [moved from opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml with 57% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDOMStoreTransaction.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDOMStoreTransaction.java with 100% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java with 100% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java with 100% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java with 100% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java with 95% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java with 98% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadTransaction.java with 96% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadWriteTransaction.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedReadWriteTransaction.java with 96% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java with 92% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java with 97% similarity]
opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java [new file with mode: 0644]
opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang [new file with mode: 0644]
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceTwoPhaseCommitTransaction.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java
opendaylight/md-sal/sal-netconf-connector/src/main/yang/odl-sal-netconf-connector-cfg.yang
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModule.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/CapturedMessageHandler.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImpl.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandler.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/Context.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcClient.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RoutingTableProvider.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImpl.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandler.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/SocketPair.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/util/XmlUtils.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/yang/odl-sal-dom-rpc-remote-cfg.yang [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImplTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/MockRoutingTable.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProviderTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/SerilizationTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImplTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandlerTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/MessagingUtil.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/RemoteServerTestClient.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/AddFlow.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/FourSimpleChildren.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/logback-test.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/pom.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/java/org/opendaylight/controller/sample/zeromq/consumer/ExampleConsumer.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/FourSimpleChildren.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/InvalidCompositeChild.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/InvalidSimpleChild.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/OneSimpleChild.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/OneSimpleOneCompositeChild.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/TwoCompositeChildren.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/TwoSimpleChildren.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/pom.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/pom.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/resources/controller.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/resources/logback.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/pom.xml [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqrouter/rest/Router.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/src/main/resources/WEB-INF/web.xml [deleted file]
opendaylight/md-sal/sal-rest-connector/pom.xml
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java
opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/simple-data-types.yang
opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml
opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml
opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java
opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java
opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider-impl.yang
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java
opendaylight/northbound/commons/pom.xml
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Accessor.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/CompareExpression.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Expression.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java with 53% similarity]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/ExpressionBuilder.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/LogicalExpression.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Query.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContext.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextProvider.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryException.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Visitor.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/javacc/fiql.jj [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/BookBean.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ExpresssionTest.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/Library.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/PersonBean.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/QueryContextTest.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ReviewBean.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/XMLAccessorTypeTest.java [new file with mode: 0644]
opendaylight/northbound/commons/src/test/resources/logback.xml [moved from opendaylight/md-sal/remoterpc-routingtable/integrationtest/src/test/resources/logback.xml with 61% similarity]
opendaylight/northbound/connectionmanager/pom.xml
opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java
opendaylight/northbound/containermanager/pom.xml
opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java
opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthboundRSApplication.java
opendaylight/northbound/controllermanager/pom.xml
opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthbound.java
opendaylight/northbound/flowprogrammer/pom.xml
opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java
opendaylight/northbound/hosttracker/pom.xml
opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java
opendaylight/northbound/staticrouting/pom.xml
opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java
opendaylight/northbound/statistics/pom.xml
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java
opendaylight/northbound/subnets/pom.xml
opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java
opendaylight/northbound/switchmanager/pom.xml
opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java
opendaylight/northbound/topology/pom.xml
opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Ethernet.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IEEE8021Q.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/UDP.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/ARPTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IEEE8021QTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IPv4Test.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/PacketTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/UDPTest.java

index 922b2d6bdfbd7652df204f2e70597a11fc0a76ac..d925f51b948cfe444a77a5875546e6986ec5ca26 100644 (file)
       </resource>
     </resources>
     <plugins>
+      <plugin>
+        <groupId>org.apache.karaf.tooling</groupId>
+        <artifactId>karaf-maven-plugin</artifactId>
+        <version>${karaf.version}</version>
+        <extensions>true</extensions>
+        <executions>
+          <execution>
+            <id>features-create-kar</id>
+            <goals>
+              <goal>features-create-kar</goal>
+            </goals>
+            <configuration>
+              <featuresFile>${project.build.directory}/classes/${features.file}</featuresFile>
+            </configuration>
+          </execution>
+        </executions>
+        <!-- There is no useful configuration for the kar mojo. The features-generate-descriptor mojo configuration may be useful -->
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-resources-plugin</artifactId>
index dd6eec8222988ed499aff01b2e56cb5163b119c2..60286175c18e0a6455dedcc19f23018216b406dd 100644 (file)
       <bundle start="true" start-level="35">mvn:orbit/org.apache.juli.extras/7.0.32.v201211081135</bundle>
       <bundle start="true" start-level="35">mvn:orbit/org.apache.tomcat.api/7.0.32.v201211081135</bundle>
       <bundle start="true" start-level="35">mvn:orbit/org.apache.tomcat.util/7.0.32.v201211201952</bundle>
+      <bundle start="true" start-level="35">wrap:mvn:virgomirror/org.eclipse.jdt.core.compiler.batch/3.8.0.I20120518-2145</bundle>
    </feature>
    <feature name="base-spring" description="Opendaylight Spring Support" version="${spring.version}">
       <bundle>mvn:org.ow2.asm/asm-all/${asm.version}</bundle>
index a6ee60f65d14b5f47b6f7a6cc2db9331f6847d51..1a446b83db92fe1a690e8ac94f181b6bf75705ac 100644 (file)
@@ -23,14 +23,17 @@ public class ARPReply extends ARPEvent {
     private final byte[] tMac;
     private final byte[] sMac;
     private final InetAddress sIP;
+    private final short vlan;
 
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
         result = prime * result + ((sIP == null) ? 0 : sIP.hashCode());
         result = prime * result + Arrays.hashCode(sMac);
         result = prime * result + Arrays.hashCode(tMac);
+        result = prime * result + vlan;
         return result;
     }
 
@@ -39,13 +42,20 @@ public class ARPReply extends ARPEvent {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
+        if (!super.equals(obj)) {
             return false;
         }
         if (!(obj instanceof ARPReply)) {
             return false;
         }
         ARPReply other = (ARPReply) obj;
+        if (port == null) {
+            if (other.port != null) {
+                return false;
+            }
+        } else if (!port.equals(other.port)) {
+            return false;
+        }
         if (sIP == null) {
             if (other.sIP != null) {
                 return false;
@@ -59,23 +69,28 @@ public class ARPReply extends ARPEvent {
         if (!Arrays.equals(tMac, other.tMac)) {
             return false;
         }
+        if (vlan != other.vlan) {
+            return false;
+        }
         return true;
     }
 
-    public ARPReply(NodeConnector port, InetAddress sIP, byte[] sMAC, InetAddress tIP, byte[] tMAC) {
+    public ARPReply(NodeConnector port, InetAddress sIP, byte[] sMAC, InetAddress tIP, byte[] tMAC, short vlan) {
         super(tIP);
         this.tMac = tMAC;
         this.sIP = sIP;
         this.sMac = sMAC;
         this.port = port;
+        this.vlan = vlan;
     }
 
-    public ARPReply(InetAddress tIP, byte[] tMAC) {
+    public ARPReply(InetAddress tIP, byte[] tMAC, short vlan) {
         super(tIP);
         this.tMac = tMAC;
         this.sIP = null;
         this.sMac = null;
         this.port = null;
+        this.vlan = vlan;
     }
 
     public byte[] getTargetMac() {
@@ -94,6 +109,10 @@ public class ARPReply extends ARPEvent {
         return port;
     }
 
+    public short getVlan() {
+        return vlan;
+    }
+
     /*
      * (non-Javadoc)
      *
@@ -122,6 +141,10 @@ public class ARPReply extends ARPEvent {
             builder.append("sIP=")
                     .append(sIP);
         }
+        if (vlan != 0) {
+            builder.append(", vlan=")
+            .append(vlan);
+        }
         builder.append("]");
         return builder.toString();
     }
index e5491824397c1678b26b819b4e2691d0295f95a6..fe456f3f8ebe6f6237352cb09f5b6a7dc8056398 100644 (file)
@@ -49,12 +49,12 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.packet.ARP;
 import org.opendaylight.controller.sal.packet.Ethernet;
 import org.opendaylight.controller.sal.packet.IDataPacketService;
+import org.opendaylight.controller.sal.packet.IEEE8021Q;
 import org.opendaylight.controller.sal.packet.IListenDataPacket;
 import org.opendaylight.controller.sal.packet.IPv4;
 import org.opendaylight.controller.sal.packet.Packet;
 import org.opendaylight.controller.sal.packet.PacketResult;
 import org.opendaylight.controller.sal.packet.RawPacket;
-import org.opendaylight.controller.sal.routing.IRouting;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.opendaylight.controller.sal.utils.NetUtils;
@@ -96,7 +96,6 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     private ISwitchManager switchManager;
     private ITopologyManager topologyManager;
     private IDataPacketService dataPacketService;
-    private IRouting routing;
     private IClusterContainerServices clusterContainerService;
     private IConnectionManager connectionManager;
     private Set<IfHostListener> hostListeners = new CopyOnWriteArraySet<IfHostListener>();
@@ -182,7 +181,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         }
     }
 
-    protected void sendARPReply(NodeConnector p, byte[] sMAC, InetAddress sIP, byte[] tMAC, InetAddress tIP) {
+    protected void sendARPReply(NodeConnector p, byte[] sMAC, InetAddress sIP, byte[] tMAC, InetAddress tIP, short vlan) {
         byte[] senderIP = sIP.getAddress();
         byte[] targetIP = tIP.getAddress();
         ARP arp = createARP(ARP.REPLY, sMAC, senderIP, tMAC, targetIP);
@@ -193,7 +192,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                     sIP, HexEncode.bytesToHexString(tMAC), tIP, p);
         }
 
-        Ethernet ethernet = createEthernet(sMAC, tMAC, arp);
+        Ethernet ethernet = createEthernet(sMAC, tMAC, arp, vlan);
 
         RawPacket destPkt = this.dataPacketService.encodeDataPacket(ethernet);
         destPkt.setOutgoingNodeConnector(p);
@@ -201,26 +200,24 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         this.dataPacketService.transmitDataPacket(destPkt);
     }
 
-    private void logArpPacket(ARP pkt, NodeConnector p) {
+    private void logArpPacket(ARP pkt, NodeConnector p, short vlan) {
         try {
-            if (pkt.getOpCode() == ARP.REQUEST) {
-                log.trace("Received Arp Request with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {}", HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()),
-                        InetAddress.getByAddress(pkt.getSenderProtocolAddress()), HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()),
-                        InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p);
-            } else if(pkt.getOpCode() == ARP.REPLY) {
-                log.trace("Received Arp Reply with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {}", HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()),
-                        InetAddress.getByAddress(pkt.getSenderProtocolAddress()), HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()),
-                        InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p);
-            }
-        } catch(UnknownHostException e) {
+            log.trace("Received Arp {} with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {} {}",
+                    ((pkt.getOpCode() == ARP.REQUEST) ? "Request" : "Reply"),
+                    HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()),
+                    InetAddress.getByAddress(pkt.getSenderProtocolAddress()),
+                    HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()),
+                    InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p, (vlan != 0 ? "on vlan " + vlan : ""));
+
+        } catch (UnknownHostException e) {
             log.warn("Illegal Ip Address in the ARP packet", e);
         }
     }
 
-    protected void handleARPPacket(Ethernet eHeader, ARP pkt, NodeConnector p) {
+    protected void handleARPPacket(Ethernet eHeader, ARP pkt, NodeConnector p, short vlan) {
 
         if(log.isTraceEnabled()) {
-            logArpPacket(pkt, p);
+            logArpPacket(pkt, p, vlan);
         }
 
         byte[] sourceMAC = eHeader.getSourceMACAddress();
@@ -264,7 +261,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         HostNodeConnector requestor = null;
         if (NetUtils.isUnicastMACAddr(sourceMAC) && p.getNode() != null) {
             try {
-                requestor = new HostNodeConnector(sourceMAC, sourceIP, p, subnet.getVlan());
+                requestor = new HostNodeConnector(sourceMAC, sourceIP, p, vlan);
             } catch (ConstructionException e) {
                 log.debug("Received ARP packet with invalid MAC: {}", HexEncode.bytesToHexString(sourceMAC));
                 return;
@@ -294,7 +291,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
             // the true value indicates we should generate replies to requestors
             // across the cluster
             log.trace("Received ARP reply packet from {}, reply to all requestors.", sourceIP);
-            arpRequestReplyEvent.put(new ARPReply(sourceIP, sourceMAC), true);
+            arpRequestReplyEvent.put(new ARPReply(sourceIP, sourceMAC, vlan), true);
             return;
         }
 
@@ -315,11 +312,11 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                     log.trace("Received local ARP req. for default gateway. Replying with controller MAC: {}",
                             HexEncode.bytesToHexString(getControllerMAC()));
                 }
-                sendARPReply(p, getControllerMAC(), targetIP, pkt.getSenderHardwareAddress(), sourceIP);
+                sendARPReply(p, getControllerMAC(), targetIP, pkt.getSenderHardwareAddress(), sourceIP, vlan);
             } else {
                 log.trace("Received non-local ARP req. for default gateway. Raising reply event");
                 arpRequestReplyEvent.put(
-                        new ARPReply(p, targetIP, getControllerMAC(), sourceIP, pkt.getSenderHardwareAddress()), false);
+                        new ARPReply(p, targetIP, getControllerMAC(), sourceIP, pkt.getSenderHardwareAddress(), vlan), false);
             }
             return;
         }
@@ -353,10 +350,10 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                 log.trace("Received ARP req. for known host {}, sending reply...", targetIP);
                 if (connectionManager.getLocalityStatus(p.getNode()) == ConnectionLocality.LOCAL) {
                     sendARPReply(p, host.getDataLayerAddressBytes(), host.getNetworkAddress(),
-                            pkt.getSenderHardwareAddress(), sourceIP);
+                            pkt.getSenderHardwareAddress(), sourceIP, vlan);
                 } else {
                     arpRequestReplyEvent.put(new ARPReply(p, host.getNetworkAddress(), host.getDataLayerAddressBytes(),
-                            sourceIP, pkt.getSenderHardwareAddress()), false);
+                            sourceIP, pkt.getSenderHardwareAddress(), vlan), false);
                 }
             } else {
                 /*
@@ -404,7 +401,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
             }
 
             byte[] destMACAddress = NetUtils.getBroadcastMACAddr();
-            Ethernet ethernet = createEthernet(getControllerMAC(), destMACAddress, arp);
+            Ethernet ethernet = createEthernet(getControllerMAC(), destMACAddress, arp, (short)0);
 
             // TODO For now send port-by-port, see how to optimize to
             // send to multiple ports at once
@@ -416,9 +413,9 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     }
 
     /**
-     * Send a unicast ARP Request to the known host on a specific switch/port as
-     * defined in the host. The sender IP is the networkAddress of the subnet
-     * The sender MAC is the controller's MAC
+     * Send a unicast ARP Request to the known host on specific (switch/port,
+     * vlan) as defined in the host. The sender IP is the networkAddress of the
+     * subnet The sender MAC is the controller's MAC
      */
     protected void sendUcastARPRequest(HostNodeConnector host, Subnet subnet) {
         log.trace("sendUcastARPRequest host:{} subnet:{}", host, subnet);
@@ -440,7 +437,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                     outPort);
         }
 
-        Ethernet ethernet = createEthernet(getControllerMAC(), targetMAC, arp);
+        Ethernet ethernet = createEthernet(getControllerMAC(), targetMAC, arp, host.getVlan());
 
         RawPacket destPkt = this.dataPacketService.encodeDataPacket(ethernet);
         destPkt.setOutgoingNodeConnector(outPort);
@@ -498,7 +495,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
      * @param pkt
      * @param p
      */
-    protected void handlePuntedIPPacket(IPv4 pkt, NodeConnector p) {
+    protected void handlePuntedIPPacket(IPv4 pkt, NodeConnector p, short vlan) {
 
         InetAddress dIP = NetUtils.getInetAddress(pkt.getDestinationAddress());
         if (dIP == null) {
@@ -653,13 +650,19 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         log.trace("Received a frame of size: {}", inPkt.getPacketData().length);
         Packet formattedPak = this.dataPacketService.decodeDataPacket(inPkt);
         if (formattedPak instanceof Ethernet) {
-            Object nextPak = formattedPak.getPayload();
+            Packet nextPak = formattedPak.getPayload();
+            short vlan = 0;
+            if (nextPak instanceof IEEE8021Q) {
+                vlan = ((IEEE8021Q) nextPak).getVid();
+                log.trace("Moved after the dot1Q header");
+                nextPak = ((IEEE8021Q) nextPak).getPayload();
+            }
             if (nextPak instanceof IPv4) {
                 log.trace("Handle IP packet: {}", formattedPak);
-                handlePuntedIPPacket((IPv4) nextPak, inPkt.getIncomingNodeConnector());
+                handlePuntedIPPacket((IPv4) nextPak, inPkt.getIncomingNodeConnector(), vlan);
             } else if (nextPak instanceof ARP) {
                 log.trace("Handle ARP packet: {}", formattedPak);
-                handleARPPacket((Ethernet) formattedPak, (ARP) nextPak, inPkt.getIncomingNodeConnector());
+                handleARPPacket((Ethernet) formattedPak, (ARP) nextPak, inPkt.getIncomingNodeConnector(), vlan);
             }
         }
         return PacketResult.IGNORED;
@@ -680,12 +683,21 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         return arp;
     }
 
-    private Ethernet createEthernet(byte[] sourceMAC, byte[] targetMAC, ARP arp) {
+    private Ethernet createEthernet(byte[] sourceMAC, byte[] targetMAC, ARP arp, short vlan) {
         Ethernet ethernet = new Ethernet();
         ethernet.setSourceMACAddress(sourceMAC);
         ethernet.setDestinationMACAddress(targetMAC);
-        ethernet.setEtherType(EtherTypes.ARP.shortValue());
-        ethernet.setPayload(arp);
+        if (vlan == 0) {
+            ethernet.setEtherType(EtherTypes.ARP.shortValue());
+            ethernet.setPayload(arp);
+        } else {
+            IEEE8021Q dot1q = new IEEE8021Q();
+            dot1q.setVid(vlan);
+            dot1q.setEtherType(EtherTypes.ARP.shortValue());
+            dot1q.setPayload(arp);
+            ethernet.setEtherType(EtherTypes.VLANTAGGED.shortValue());
+            ethernet.setPayload(dot1q);
+        }
         return ethernet;
     }
 
@@ -731,7 +743,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         }
     }
 
-    private void generateAndSendReply(InetAddress sourceIP, byte[] sourceMAC) {
+    private void generateAndSendReply(InetAddress sourceIP, byte[] sourceMAC, short vlan) {
         if (log.isTraceEnabled()) {
             log.trace("generateAndSendReply called with params sourceIP:{} sourceMAC:{}", sourceIP,
                     HexEncode.bytesToHexString(sourceMAC));
@@ -745,13 +757,14 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         for (HostNodeConnector host : hosts) {
             if (log.isTraceEnabled()) {
                 log.trace(
-                        "Sending ARP Reply with src {}/{}, target {}/{}",
+                        "Sending ARP Reply with src {}/{}, target {}/{} {}",
                         new Object[] { HexEncode.bytesToHexString(sourceMAC), sourceIP,
-                                HexEncode.bytesToHexString(host.getDataLayerAddressBytes()), host.getNetworkAddress() });
+                                HexEncode.bytesToHexString(host.getDataLayerAddressBytes()), host.getNetworkAddress(),
+                                (vlan != 0 ? "on vlan " + vlan : "") });
             }
             if (connectionManager.getLocalityStatus(host.getnodeconnectorNode()) == ConnectionLocality.LOCAL) {
                 sendARPReply(host.getnodeConnector(), sourceMAC, sourceIP, host.getDataLayerAddressBytes(),
-                        host.getNetworkAddress());
+                        host.getNetworkAddress(), vlan);
             } else {
                 /*
                  * In the remote event a requestor moved to another controller
@@ -760,7 +773,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                  */
                 arpRequestReplyEvent.put(
                         new ARPReply(host.getnodeConnector(), sourceIP, sourceMAC, host.getNetworkAddress(), host
-                                .getDataLayerAddressBytes()), false);
+                                .getDataLayerAddressBytes(), vlan), false);
             }
         }
     }
@@ -822,12 +835,12 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                         // requestors across the cluster
                         if (ev.isNewReply()) {
                             log.trace("Trigger a generateAndSendReply in response to {}", rep);
-                            generateAndSendReply(rep.getTargetIP(), rep.getTargetMac());
+                            generateAndSendReply(rep.getTargetIP(), rep.getTargetMac(), rep.getVlan());
                             // Otherwise, a specific reply. If local, send out.
                         } else if (connectionManager.getLocalityStatus(rep.getPort().getNode()) == ConnectionLocality.LOCAL) {
                             log.trace("ARPCacheEventHandler - sendUcatARPReply locally in response to {}", rep);
                             sendARPReply(rep.getPort(), rep.getSourceMac(), rep.getSourceIP(), rep.getTargetMac(),
-                                    rep.getTargetIP());
+                                    rep.getTargetIP(), rep.getVlan());
                         }
                     }
                 } catch (InterruptedException e) {
index 58dbef67d5264b87896d92dc53299502f79076f3..de8caa0e6747179c4f893c64a9c508ed7b80247d 100644 (file)
         <artifactId>netconf-client</artifactId>
         <version>${netconf.version}</version>
       </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>netconf-client</artifactId>
-            <version>${netconf.version}</version>
-            <type>test-jar</type>
-        </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>netconf-client</artifactId>
+        <version>${netconf.version}</version>
+        <type>test-jar</type>
+      </dependency>
 
       <!--Netconf config-->
       <dependency>
         <artifactId>protocol_plugins.stub</artifactId>
         <version>${protocol_plugins.stub.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>remoterpc-routingtable.implementation</artifactId>
-        <version>${mdsal.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>routing.dijkstra_implementation</artifactId>
         <artifactId>sal-remote</artifactId>
         <version>${mdsal.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal-remoterpc-connector</artifactId>
-        <version>${mdsal.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-rest-connector</artifactId>
         <artifactId>sample-toaster-provider</artifactId>
         <version>${mdsal.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller.tests</groupId>
-        <artifactId>sal-remoterpc-connector-test-consumer</artifactId>
-        <version>${mdsal.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller.tests</groupId>
-        <artifactId>sal-remoterpc-connector-test-provider</artifactId>
-        <version>${mdsal.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller.thirdparty</groupId>
         <artifactId>com.sun.jersey.jersey-servlet</artifactId>
                     <ignore></ignore>
                   </action>
                 </pluginExecution>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>javacc-maven-plugin</artifactId>
+                    <versionRange>[0.0,)</versionRange>
+                    <goals>
+                      <goal>javacc</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <execute>
+                      <runOnIncremental>false</runOnIncremental>
+                    </execute>
+                  </action>
+                </pluginExecution>
               </pluginExecutions>
             </lifecycleMappingMetadata>
           </configuration>
index c00b26d9ced898dc0dd4f4239d68b9d933332ad3..ba13ebb8f051e65d31c5a663daee15b1034d0134 100644 (file)
@@ -12,13 +12,14 @@ import java.util.SortedSet;
 public interface ConfigSnapshotHolder {
 
     /**
-     * Get part of get-config document that contains just
+     * Get XML node that should be pushed to netconf's edit-config
      */
     String getConfigSnapshot();
 
 
     /**
      * Get only required capabilities referenced by the snapshot.
+     * If no value is specified, return empty set instead of null
      */
     SortedSet<String> getCapabilities();
 
index d13052a7e273a3aa5ffb45e22e8b421ed689afde..7c069dab6b0fb04bbd511fefffbfc5ebf3be6879 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.persist.storage.file.xml.model;
 
+import java.util.TreeSet;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 
 import javax.xml.bind.annotation.XmlAnyElement;
@@ -22,7 +23,7 @@ public class ConfigSnapshot {
     public static final String SNAPSHOT_ROOT_ELEMENT_NAME = "snapshot";
 
     private String configSnapshot;
-    private SortedSet<String> capabilities;
+    private SortedSet<String> capabilities = new TreeSet<>();
 
     ConfigSnapshot(String configXml, SortedSet<String> capabilities) {
         this.configSnapshot = configXml;
index aa06cb97d74eafcc35eeea7f16128e7f94743cfb..6eda364af0d05860196bca23b7433e47f961d1a6 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory;
 
+import static com.google.common.base.Preconditions.checkState;
 import static java.lang.String.format;
 
 import com.google.common.base.Joiner;
@@ -212,7 +213,7 @@ public class AbsModuleGeneratedObjectFactory {
                         "}\n", moduleField.getName(), osgi);
                 } else {
                     str = format(
-                        "%1$sDependency = dependencyResolver.resolveInstance(%2$s.class, %1$s, %1$sJmxAttribute);",
+                        "%1$sDependency = dependencyResolver.resolveInstance(%2$s.class, %1$s, %1$sJmxAttribute);\n",
                         moduleField.getName(), osgi);
                 }
                 resolveDependenciesMap.put(moduleField, str);
@@ -222,7 +223,8 @@ public class AbsModuleGeneratedObjectFactory {
         // wrap each field resolvation statement with if !=null when dependency is not mandatory
         for (Map.Entry<ModuleField, String> entry : resolveDependenciesMap.entrySet()) {
             if (entry.getKey().getDependency().isMandatory() == false) {
-                result += format("if (%s!=null) {\n%s;\n}", entry.getKey().getName(), entry.getValue());
+                checkState(entry.getValue().endsWith(";\n"));
+                result += format("if (%s!=null) {\n%s}\n", entry.getKey().getName(), entry.getValue());
             } else {
                 result += entry.getValue();
             }
@@ -401,7 +403,7 @@ public class AbsModuleGeneratedObjectFactory {
         parameters.put(ModuleIdentifier.class.getCanonicalName(), "identifier");
         parameters.put(DependencyResolver.class.getCanonicalName(), "dependencyResolver");
 
-        String setToNulls = "this.oldInstance=null;\n;" +
+        String setToNulls = "this.oldInstance=null;\n" +
                 "this.oldModule=null;\n";
         return getConstructorStart(abstractFQN, parameters, setToNulls);
     }
index 7970b3aa00f6fc38bf334ce93b8b52a8597581b2..8a23a6b5e60e64a6baaf20fd9d7d9712894f57dd 100644 (file)
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
-    <!-- scope is compile so all features (there is only one) are installed
-            into startup.properties and the feature repo itself is not installed -->
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>base-features</artifactId>
       <version>${project.version}</version>
-      <type>pom</type>
+      <type>kar</type>
       <scope>runtime</scope>
     </dependency>
     <dependency>
index 502e1a261c713b1ea030ec014e663dcb82f4b51b..6c1ca421c257ab81807c20f4a939d556cb5338c6 100644 (file)
@@ -1,11 +1,17 @@
 # Extra packages to import from the boot class loader
 org.osgi.framework.system.packages.extra=org.apache.karaf.branding,sun.reflect,sun.reflect.misc,sun.misc,sun.nio.ch
 
+# https://bugs.eclipse.org/bugs/show_bug.cgi?id=325578
+# Extend the framework to avoid the resources to be presented with
+# a URL of type bundleresource: but to be presented as file:
+osgi.hook.configurators.include=org.eclipse.virgo.kernel.equinox.extensions.hooks.ExtensionsHookConfigurator
 
 # Embedded Tomcat configuration File
 org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
 org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
 
+# Use Equinox as default OSGi Framework Implementation
+karaf.framework=equinox
 
 # Netconf startup configuration
 netconf.tcp.address=127.0.0.1
index 288fe629f806ff74a3c241a3d27e95a39e86fcf5..ca8c83c380aea4f1c51c801a3e846a82e364fbeb 100644 (file)
@@ -7,7 +7,7 @@ mvn\:org.ops4j.pax.swissbox/pax-swissbox-bnd/1.7.0 = 5
 mvn\:org.ops4j.pax.url/pax-url-maven-commons/1.6.0 = 5
 mvn\:org.ops4j.pax.url/pax-url-aether/1.6.0 = 5
 mvn\:org.ops4j.pax.url/pax-url-wrap/1.6.0 = 5
-#mvn\:javax.annotation/javax.annotation-api/1.2 = 5
+mvn\:javax.annotation/javax.annotation-api/1.2 = 5
 mvn\:org.ops4j.pax.logging/pax-logging-api/1.7.2 = 8
 mvn\:org.ops4j.pax.logging/pax-logging-service/1.7.2 = 8
 mvn\:org.apache.karaf.service/org.apache.karaf.service.guard/3.0.1 = 10
index 7160acba8173fdf2e4981f84e44d877c8b830ce5..ef3b5f4fd99e79a3449fcb5846cac80f6271b332 100644 (file)
           <artifactId>protocol-framework</artifactId>
         </dependency>
 
-        <!-- clustering -->
-        <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>remoterpc-routingtable.implementation</artifactId>
-          <version>${mdsal.version}</version>
-        </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-binding-api</artifactId>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-netconf-connector</artifactId>
+          <artifactId>sal-inmemory-datastore</artifactId>
+          <version>1.1-SNAPSHOT</version>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-remote</artifactId>
+          <artifactId>sal-netconf-connector</artifactId>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-remoterpc-connector</artifactId>
+          <artifactId>sal-remote</artifactId>
         </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
index 8b07ce3a3309ab659892f02d6ed8ea803835ba87..7b1df982471006c073b6b1b4b654149cc665bedc 100644 (file)
@@ -15,6 +15,7 @@
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
                     <name>yang-schema-service</name>
                 </module>
+
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
                     <name>runtime-mapping-singleton</name>
                     </data-broker>
                 </module>
 
+
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-config-datastore-provider</type>
+                    <name>config-store-service</name>
+                    <schema-service>
+                        <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+                        <name>yang-schema-service</name>
+                    </schema-service>
+                </module>
+
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-operational-datastore-provider</type>
+                    <name>operational-store-service</name>
+                    <schema-service>
+                        <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+                        <name>yang-schema-service</name>
+                    </schema-service>
+                </module>
+
                 <!--
                      Tree-based in-memory data store. This is the data store which is currently
                      recommended for single-node deployments.
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-inmemory-data-broker</type>
                     <name>inmemory-data-broker</name>
+
                     <schema-service>
                         <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
                         <name>yang-schema-service</name>
                     </schema-service>
+
+                   <config-data-store>
+                        <type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type>
+                        <name>config-store-service</name>
+                    </config-data-store>
+
+                    <operational-data-store>
+                        <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type>
+                        <name>operational-store-service</name>
+                    </operational-data-store>
                 </module>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
                             <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
                         </instance>
                     </service>
+                <service>
+                    <type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type>
+                    <instance>
+                        <name>config-store-service</name>
+                        <provider>/modules/module[type='inmemory-config-datastore-provider'][name='config-store-service']</provider>
+                    </instance>
+                </service>
+                <service>
+                    <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type>
+                    <instance>
+                        <name>operational-store-service</name>
+                        <provider>/modules/module[type='inmemory-operational-datastore-provider'][name='operational-store-service']</provider>
+                    </instance>
+                </service>
                     <service>
                         <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
                         <instance>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&amp;revision=2013-10-28</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&amp;revision=2013-10-28</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store?module=opendaylight-config-dom-datastore&amp;revision=2014-06-17</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store?module=opendaylight-operational-dom-datastore&amp;revision=2014-06-17</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider?module=opendaylight-inmemory-datastore-provider&amp;revision=2014-06-17</capability>
+
     </required-capabilities>
 </snapshot>
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-netconf.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-netconf.xml
new file mode 100644 (file)
index 0000000..8fedbe4
--- /dev/null
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<snapshot>
+  <configuration>
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+
+        <!-- Netconf dispatcher to be used by all netconf-connectors --> 
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">prefix:netconf-client-dispatcher</type>
+          <name>global-netconf-dispatcher</name>
+          <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+            <name>global-boss-group</name>
+          </boss-thread-group>
+          <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+            <name>global-worker-group</name>
+          </worker-thread-group>
+          <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+            <name>global-timer</name>
+          </timer>
+        </module>
+
+        <!-- Thread factory to be used by all threadpools in netconf-connectors --> 
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">prefix:threadfactory-naming</type>
+          <name>global-netconf-processing-executor-threadfactory</name>
+          <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">remote-connector-processing-executor</name-prefix>
+        </module> 
+        <!-- Flexible threadpool for all netconf connectors, Max thread count is set to 4 --> 
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">prefix:threadpool-flexible</type>
+          <name>global-netconf-processing-executor</name>
+          <minThreadCount xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">1</minThreadCount>
+          <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">4</max-thread-count>
+          <keepAliveMillis xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">600000</keepAliveMillis>
+          <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
+            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+            <name>global-netconf-processing-executor-threadfactory</name>
+          </threadFactory>
+        </module>  
+      </modules>
+
+      <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <service>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
+          <instance>
+            <name>global-netconf-dispatcher</name>
+            <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
+          </instance>
+        </service>
+        <service>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+          <instance>
+            <name>global-netconf-processing-executor-threadfactory</name>
+            <provider>/modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']</provider>
+          </instance>
+        </service>
+        <service>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+          <instance>
+            <name>global-netconf-processing-executor</name>
+            <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
+          </instance>
+        </service>
+      </services>
+
+    </data>
+  </configuration>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher?module=odl-netconfig-client-cfg&amp;revision=2014-04-08</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&amp;revision=2013-04-05</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible?module=threadpool-impl-flexible&amp;revision=2013-12-01</capability>
+  </required-capabilities>
+</snapshot>
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-clustering.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-clustering.xml
deleted file mode 100644 (file)
index c5f99fd..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<snapshot>
-    <configuration>
-        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-                <module>
-                   <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">prefix:remote-zeromq-rpc-server</type>
-                   <name>remoter</name>
-                   <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
-                   <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
-                       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
-                       <name>dom-broker</name>
-                   </dom-broker>
-               </module>
-            </modules>
-            <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-            </services>
-        </data>
-    </configuration>
-
-    <required-capabilities>
-       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&amp;revision=2013-10-28</capability>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&amp;revision=2013-10-28</capability>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&amp;revision=2013-10-28</capability>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc?module=odl-sal-dom-rpc-remote-cfg&amp;revision=2013-10-28</capability>
-    </required-capabilities>
-</snapshot>
-
index 502bdebca26588cfc481793a0abd69731b6d708b..3958e185605e155f8b4b092e927ff5e8a679cbd1 100644 (file)
@@ -23,7 +23,7 @@
                     </rpc-registry>
 
                     <data-broker>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
                         <name>binding-data-broker</name>
                     </data-broker>
                     
index b4b433dbca7c332787a8e14aa29e8b981dc308ed..7155eb88839b661372d83309a7dad27e8831c796 100644 (file)
   <configuration>
     <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-
-        <!-- Netconf dispatcher to be used by all netconf-connectors --> 
-        <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">prefix:netconf-client-dispatcher</type>
-          <name>global-netconf-dispatcher</name>
-          <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-            <name>global-boss-group</name>
-          </boss-thread-group>
-          <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-            <name>global-worker-group</name>
-          </worker-thread-group>
-          <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
-            <name>global-timer</name>
-          </timer>
-        </module>
-
-        <!-- Netconf dispatcher to be used by all netconf-connectors --> 
-        <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">prefix:threadfactory-naming</type>
-          <name>global-netconf-processing-executor-threadfactory</name>
-          <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">remote-connector-processing-executor</name-prefix>
-        </module>  
-        <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">prefix:threadpool-flexible</type>
-          <name>global-netconf-processing-executor</name>
-          <minThreadCount xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">1</minThreadCount>
-          <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">4</max-thread-count>
-          <keepAliveMillis xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">600000</keepAliveMillis>
-          <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
-            <name>global-netconf-processing-executor-threadfactory</name>
-          </threadFactory>
-        </module>  
-
         <!-- Loopback connection to netconf server in controller using netconf-connector -->
         <module>
           <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
           </processing-executor>
         </module>
       </modules>
-
-      <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <service>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
-          <instance>
-            <name>global-netconf-dispatcher</name>
-            <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
-          </instance>
-        </service>
-        <service>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
-          <instance>
-            <name>global-netconf-processing-executor-threadfactory</name>
-            <provider>/modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']</provider>
-          </instance>
-        </service>
-        <service>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
-          <instance>
-            <name>global-netconf-processing-executor</name>
-            <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
-          </instance>
-        </service>
-      </services>
-
     </data>
   </configuration>
   <required-capabilities>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf?module=odl-sal-netconf-connector-cfg&amp;revision=2013-10-28</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher?module=odl-netconfig-client-cfg&amp;revision=2014-04-08</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&amp;revision=2013-04-05</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible?module=threadpool-impl-flexible&amp;revision=2013-12-01</capability>
   </required-capabilities>
 </snapshot>
index ba68d523af7faf32efd1e17ee040558f7a4b1323..d71858e5c36750cb33b206b6b6977ffcf604ffc8 100644 (file)
@@ -83,6 +83,7 @@ public class ComponentActivator extends ComponentActivatorAbstractBase {
 
     @Override
     protected void init() {
+        // TODO: deprecated, should be removed soon
         NodeIDType.registerIDType(NodeMapping.MD_SAL_TYPE, String.class);
         NodeConnectorIDType.registerIDType(NodeMapping.MD_SAL_TYPE, String.class, NodeMapping.MD_SAL_TYPE);
     }
@@ -232,8 +233,8 @@ public class ComponentActivator extends ComponentActivatorAbstractBase {
 
     private Dictionary<String,Object> properties() {
         final Hashtable<String,Object> props = new Hashtable<String, Object>();
-        props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), NodeMapping.MD_SAL_TYPE);
-        props.put("protocolName", NodeMapping.MD_SAL_TYPE);
+        props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), NodeIDType.OPENFLOW);
+        props.put("protocolName", NodeIDType.OPENFLOW);
         return props;
     }
 }
index ba7377e8ff3dd1b8fd6c69df70e70435d39cb2a9..acb54ba51aeb3bb6b3f00f2930d7e2c212755bf3 100644 (file)
@@ -247,7 +247,8 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa
 
         flowId = UUID.randomUUID();
         cache.put(flow, flowId);
-        return this.writeFlowAsync(MDFlowMapping.toMDFlow(flow, flowId.toString()), new NodeKey(new NodeId(node.getNodeIDString())));
+        return this.writeFlowAsync(MDFlowMapping.toMDFlow(flow, flowId.toString()), new NodeKey(
+                new NodeId(NodeMapping.OPENFLOW_ID_PREFIX + node.getID())));
     }
 
     private Future<RpcResult<TransactionStatus>> internalModifyFlowAsync(final Node node, final Flow oldFlow, final Flow newFlow, final long rid) {
@@ -261,7 +262,8 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa
         }
 
         cache.put(newFlow, flowId);
-        return this.writeFlowAsync(MDFlowMapping.toMDFlow(newFlow, flowId.toString()), new NodeKey(new NodeId(node.getNodeIDString())));
+        return this.writeFlowAsync(MDFlowMapping.toMDFlow(newFlow, flowId.toString()), new NodeKey(
+                new NodeId(NodeMapping.OPENFLOW_ID_PREFIX + node.getID())));
     }
 
     private Future<RpcResult<TransactionStatus>> internalRemoveFlowAsync(final Node node, final Flow adflow, final long rid) {
@@ -275,7 +277,8 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa
 
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow flow = MDFlowMapping.toMDFlow(adflow, flowId.toString());
         final DataModificationTransaction modification = this.dataBrokerService.beginTransaction();
-        modification.removeConfigurationData(flowPath(flow, new NodeKey(new NodeId(node.getNodeIDString()))));
+        modification.removeConfigurationData(flowPath(flow, new NodeKey(
+                new NodeId(NodeMapping.OPENFLOW_ID_PREFIX + node.getID()))));
         return modification.commit();
     }
 
index 28301654258407536725408981e986c79e1082d1..5959d233669264d98d904a1eca891aa2024854b5 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.NodeTable;
+import org.opendaylight.controller.sal.core.NodeTable.NodeTableIDType;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
@@ -489,7 +490,7 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI
                 }
 
                 try {
-                    final Node adNode = new Node(NodeMapping.MD_SAL_TYPE, NodeMapping.toADNodeId(node.getId()));
+                    final Node adNode = NodeMapping.toADNode(node.getId());
                     props.put(adNode, perNodePropMap);
                 } catch (ConstructionException e) {
                     LOG.warn("Failed to construct node for {}, skipping it", node, e);
@@ -572,7 +573,7 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI
         it.setLookupCount(tableStats.getPacketsLookedUp().getValue().longValue());
         it.setMatchedCount(tableStats.getPacketsMatched().getValue().longValue());
         it.setName(tableId.toString());
-        it.setNodeTable(new NodeTable(NodeMapping.MD_SAL_TYPE, tableId, node));
+        it.setNodeTable(new NodeTable(NodeTableIDType.OPENFLOW, tableId.byteValue(), node));
         return it;
     }
 
index 67af3e428f8ff22caca6db1b9e60a892673314eb..9b5d0e887541da50e9a802811b84e046f3573b7d 100644 (file)
@@ -357,7 +357,7 @@ public final class MDFlowMapping {
     }
 
     public static Uri toUri(final NodeConnector connector) {
-        return new NodeConnectorId(((String) connector.getID()));
+        return new NodeConnectorId(NodeMapping.OPENFLOW_ID_PREFIX + connector.getNode().getID() + ":" + (connector.getID()));
     }
 
     public static MacAddress toMacAddress(final byte[] bytes) {
index f5701bfaf23419c9c2beaed1bde59f2037095c3c..a700c86b9c5c00f41a3ade60a650298adfc5883d 100644 (file)
@@ -11,7 +11,6 @@ import java.math.BigInteger;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
-
 import org.opendaylight.controller.sal.common.util.Arguments;
 import org.opendaylight.controller.sal.core.AdvertisedBandwidth;
 import org.opendaylight.controller.sal.core.Bandwidth;
@@ -19,8 +18,10 @@ import org.opendaylight.controller.sal.core.Buffers;
 import org.opendaylight.controller.sal.core.Capabilities;
 import org.opendaylight.controller.sal.core.Config;
 import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Description;
 import org.opendaylight.controller.sal.core.MacAddress;
 import org.opendaylight.controller.sal.core.Name;
+import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.core.PeerBandwidth;
 import org.opendaylight.controller.sal.core.Property;
@@ -44,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.fl
 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.PortFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
@@ -56,12 +58,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No
 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.Objects;
 import com.google.common.base.Preconditions;
 
 public final class NodeMapping {
-    public final static String MD_SAL_TYPE = "MD_SAL";
+
+    private static final Logger LOG = LoggerFactory
+            .getLogger(NodeMapping.class);
+
+    /** openflow id prefix */
+    public static final String OPENFLOW_ID_PREFIX = "openflow:";
+
+    public final static String MD_SAL_TYPE = "MD_SAL_DEPRECATED";
 
     private final static Class<Node> NODE_CLASS = Node.class;
 
@@ -77,8 +88,19 @@ public final class NodeMapping {
     }
 
     public static org.opendaylight.controller.sal.core.Node toADNode(final NodeId id) throws ConstructionException {
-        String aDNodeId = NodeMapping.toADNodeId(id);
-        return new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, aDNodeId);
+        Long aDNodeId = openflowFullNodeIdToLong(NodeMapping.toADNodeId(id));
+        return new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, aDNodeId);
+    }
+
+    /**
+     * @param adNodeId
+     * @return
+     */
+    private static Long openflowFullNodeIdToLong(String adNodeId) {
+        if (adNodeId == null) {
+            return null;
+        }
+        return Long.valueOf(adNodeId.replaceFirst("^.*:", ""));
     }
 
     public static NodeId toNodeId(final InstanceIdentifier<?> id) {
@@ -87,7 +109,14 @@ public final class NodeMapping {
         return key.getId();
     }
 
+    /**
+     * @param nodeId containing "&lt;NodeTypeString&gt;:&lt;plainIntegerId&gt;"
+     * @return adNodeId form
+     */
     public static String toADNodeId(final NodeId nodeId) {
+        if (nodeId == null) {
+            return null;
+        }
         return nodeId.getValue();
     }
 
@@ -104,6 +133,28 @@ public final class NodeMapping {
         return new org.opendaylight.controller.sal.core.NodeConnector(nodeConnectorType, aDNodeConnectorId, aDNode);
     }
 
+    /**
+     * @param ncid nodeConnector identifier, e.g.: OF:21 or CTRL
+     * @param node
+     * @return nodeConnector attached to given node
+     * @throws ConstructionException
+     */
+    public static org.opendaylight.controller.sal.core.NodeConnector toADNodeConnector(
+            final NodeConnectorId ncid, final org.opendaylight.controller.sal.core.Node aDNode) throws ConstructionException {
+        NodeId nid = NodeMapping.toNodeId(aDNode);
+        String nodeConnectorType = NodeMapping.toNodeConnectorType(ncid, nid);
+        Object aDNodeConnectorId = NodeMapping.toADNodeConnectorId(ncid, nid);
+        return new org.opendaylight.controller.sal.core.NodeConnector(nodeConnectorType, aDNodeConnectorId, aDNode);
+    }
+
+    /**
+     * @param aDNode
+     * @return
+     */
+    private static NodeId toNodeId(org.opendaylight.controller.sal.core.Node aDNode) {
+        return new NodeId(aDNode.getType() + ":" +String.valueOf(aDNode.getID()));
+    }
+
     public static String toNodeConnectorType(final NodeConnectorId ncId, final NodeId nodeId) {
         if (ncId.equals(toLocalNodeConnectorId(nodeId))) {
             return NodeConnectorIDType.SWSTACK;
@@ -112,7 +163,7 @@ public final class NodeMapping {
         } else if (ncId.equals(toControllerNodeConnectorId(nodeId))) {
             return NodeConnectorIDType.CONTROLLER;
         }
-        return MD_SAL_TYPE;
+        return NodeConnectorIDType.OPENFLOW;
     }
 
     public static Object toADNodeConnectorId(final NodeConnectorId nodeConnectorId, final NodeId nodeId) {
@@ -121,7 +172,18 @@ public final class NodeMapping {
                 nodeConnectorId.equals(toControllerNodeConnectorId(nodeId))) {
             return org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID;
         }
-        return nodeConnectorId.getValue();
+
+        String nodeConnectorIdStripped = nodeConnectorId.getValue().replaceFirst("^.*:", "");
+        if (nodeConnectorIdStripped.matches("[0-9]+")) {
+            Short nodeConnectorIdVal = null;
+            try {
+                nodeConnectorIdVal = Short.valueOf(nodeConnectorIdStripped);
+            } catch (NumberFormatException e) {
+                LOG.warn("nodeConnectorId not supported (short): {}", nodeConnectorIdStripped, e);
+            }
+            return nodeConnectorIdVal;
+        }
+        return nodeConnectorIdStripped;
     }
 
     public static NodeId toAdNodeId(final NodeConnectorId nodeConnectorId) {
@@ -133,21 +195,21 @@ public final class NodeMapping {
     }
 
     public static NodeConnectorId toControllerNodeConnectorId(final NodeId node) {
-        return new NodeConnectorId(node.getValue() + ":" + 4294967293L);
+        return new NodeConnectorId(node.getValue() + ":" + OutputPortValues.CONTROLLER.toString());
     }
 
     public static NodeConnectorId toLocalNodeConnectorId(final NodeId node) {
-        return new NodeConnectorId(node.getValue() + ":" + 4294967294L);
+        return new NodeConnectorId(node.getValue() + ":" + OutputPortValues.LOCAL.toString());
     }
 
     public static NodeConnectorId toNormalNodeConnectorId(final NodeId node) {
-        return new NodeConnectorId(node.getValue() + ":" + 4294967290L);
+        return new NodeConnectorId(node.getValue() + ":" + OutputPortValues.NORMAL.toString());
     }
 
     public static NodeRef toNodeRef(final org.opendaylight.controller.sal.core.Node node) {
-        Preconditions.checkArgument(MD_SAL_TYPE.equals(node.getType()));
-        final String nodeId = Arguments.<String>checkInstanceOf(node.getID(), String.class);
-        final NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
+        Preconditions.checkArgument(NodeIDType.OPENFLOW.equals(node.getType()));
+        final Long nodeId = Arguments.<Long>checkInstanceOf(node.getID(), Long.class);
+        final NodeKey nodeKey = new NodeKey(new NodeId(OPENFLOW_ID_PREFIX+nodeId));
         final InstanceIdentifier<Node> nodePath = InstanceIdentifier.builder(Nodes.class).child(NODE_CLASS, nodeKey).toInstance();
         return new NodeRef(nodePath);
     }
@@ -170,7 +232,8 @@ public final class NodeMapping {
                 nodeConnectorId = toControllerNodeConnectorId(nodeId);
             }
         } else {
-            nodeConnectorId = new NodeConnectorId(Arguments.<String>checkInstanceOf(nodeConnector.getID(), String.class));
+            nodeConnectorId = new NodeConnectorId(OPENFLOW_ID_PREFIX
+                    + Arguments.<Short>checkInstanceOf(nodeConnector.getID(), Short.class));
         }
         final NodeConnectorKey connectorKey = new NodeConnectorKey(nodeConnectorId);
         final InstanceIdentifier<NodeConnector> path = nodePath.child(NODECONNECTOR_CLASS, connectorKey);
@@ -184,11 +247,27 @@ public final class NodeMapping {
     public static HashSet<Property> toADNodeConnectorProperties(final NodeConnectorUpdated nc) {
         final FlowCapableNodeConnectorUpdated fcncu = nc.<FlowCapableNodeConnectorUpdated>getAugmentation(FlowCapableNodeConnectorUpdated.class);
         if (!Objects.equal(fcncu, null)) {
-            return NodeMapping.toADNodeConnectorProperties(fcncu);
+            HashSet<Property> adNodeConnectorProperties = NodeMapping.toADNodeConnectorProperties(fcncu);
+            return adNodeConnectorProperties;
         }
         return new HashSet<Property>();
     }
 
+    /**
+     * @param id
+     * @return node description in AD form, e.g.: OF|00:00:00:...:01
+     */
+    private static Description toADDescription(NodeRef nodeRef) {
+        Description desc;
+        try {
+            desc = new Description(toADNode(nodeRef).toString());
+        } catch (ConstructionException e) {
+            desc = new Description("none");
+            LOG.warn("node description extraction failed: {}", nodeRef);
+        }
+        return desc;
+    }
+
     public static HashSet<Property> toADNodeConnectorProperties(final NodeConnector nc) {
         final FlowCapableNodeConnector fcnc = nc.<FlowCapableNodeConnector>getAugmentation(FlowCapableNodeConnector.class);
         if (!Objects.equal(fcnc, null)) {
@@ -303,7 +382,9 @@ public final class NodeMapping {
     public static HashSet<Property> toADNodeProperties(final NodeUpdated nu) {
         final FlowCapableNodeUpdated fcnu = nu.getAugmentation(FlowCapableNodeUpdated.class);
         if (fcnu != null) {
-            return toADNodeProperties(fcnu, nu.getId());
+            HashSet<Property> adNodeProperties = toADNodeProperties(fcnu, nu.getId());
+            adNodeProperties.add(toADDescription(nu.getNodeRef()));
+            return adNodeProperties;
         }
         return new HashSet<org.opendaylight.controller.sal.core.Property>();
     }
@@ -342,7 +423,7 @@ public final class NodeMapping {
     }
 
     public static MacAddress toADMacAddress(final NodeId id) {
-        final String nodeId = id.getValue().replaceAll("openflow:", "");
+        final String nodeId = id.getValue().replaceAll(OPENFLOW_ID_PREFIX, "");
         BigInteger nodeIdRaw = new BigInteger(nodeId);
         long lNodeId = nodeIdRaw.longValue();
         byte[] bytesFromDpid = ToSalConversionsUtils.bytesFromDpid(lNodeId);
index 97a25bf71cd9789df1ca0a31f006dc7b99a37e19..7bbf7f10e0c2be3c8246849d468fdbc0a8be5996 100644 (file)
@@ -208,7 +208,8 @@ public class ToSalConversionsUtils {
                 Uri nodeConnector = ((OutputActionCase) sourceAction).getOutputAction().getOutputNodeConnector();
                 if (nodeConnector != null) {
                     //for (Uri uri : nodeConnectors) {
-                        targetAction.add(new Output(fromNodeConnectorRef(nodeConnector, node)));
+                    Uri fullNodeConnector = new Uri(node.getType()+":"+node.getID()+":"+nodeConnector.getValue());
+                        targetAction.add(new Output(fromNodeConnectorRef(fullNodeConnector, node)));
                     //}
                 }
             } else if (sourceAction instanceof PopMplsActionCase) {
@@ -376,12 +377,19 @@ public class ToSalConversionsUtils {
         return null;
     }
 
-    private static NodeConnector fromNodeConnectorRef(Uri uri, Node node) {
+    /**
+     * @param openflow nodeConnector uri
+     * @param node
+     * @return assembled nodeConnector
+     */
+    public static NodeConnector fromNodeConnectorRef(Uri uri, Node node) {
         NodeConnector nodeConnector = null;
         try {
-            nodeConnector = new NodeConnector(NodeMapping.MD_SAL_TYPE,node.getNodeIDString()+":"+uri.getValue(),node);
+            NodeConnectorId nodeConnectorId = new NodeConnectorId(uri.getValue());
+            nodeConnector = NodeMapping.toADNodeConnector(nodeConnectorId, node);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            LOG.warn("nodeConnector creation failed at node: {} with nodeConnectorUri: {}",
+                    node, uri.getValue());
         }
         return nodeConnector;
     }
index 476a71a4acd0602a7b36ca41b664fcb00b3d5135..6bc669f60b17a378369ae837081c43cab38be244 100644 (file)
@@ -18,7 +18,9 @@ import org.opendaylight.controller.sal.compatibility.NodeMapping;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
@@ -93,20 +95,20 @@ public final class TopologyMapping {
     }
 
     public static String toADNodeId(final NodeId nodeId) {
-        return nodeId.getValue();
+        return nodeId.getValue().replaceFirst("^.*:", "");
     }
 
     public static NodeConnector toADNodeConnector(final TpId source, final NodeId nodeId) throws ConstructionException {
         checkNotNull(source);
-        return new NodeConnector(NodeMapping.MD_SAL_TYPE, toADNodeConnectorId(source), toADNode(nodeId));
+        return new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf(toADNodeConnectorId(source)), toADNode(nodeId));
     }
 
     public static String toADNodeConnectorId(final TpId nodeConnectorId) {
-        return nodeConnectorId.getValue();
+        return nodeConnectorId.getValue().replaceFirst("^.*:", "");
     }
 
     public static Node toADNode(final NodeId nodeId) throws ConstructionException {
         checkNotNull(nodeId);
-        return new Node(NodeMapping.MD_SAL_TYPE, toADNodeId(nodeId));
+        return new Node(NodeIDType.OPENFLOW, Long.valueOf(toADNodeId(nodeId)));
     }
 }
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/MDFlowMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/MDFlowMappingTest.java
new file mode 100644 (file)
index 0000000..4e5f318
--- /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.sal.compatibility.test;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.compatibility.MDFlowMapping;
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.Node.NodeIDType;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+
+/**
+ * test for {@link MDFlowMapping}
+ */
+public class MDFlowMappingTest {
+
+    /**
+     * Test method for {@link org.opendaylight.controller.sal.compatibility.MDFlowMapping#toUri(org.opendaylight.controller.sal.core.NodeConnector)}.
+     * @throws ConstructionException
+     */
+    @Test
+    public void testToUri() throws ConstructionException {
+        Node node = new Node(NodeIDType.OPENFLOW, 41L);
+        NodeConnector connector = new NodeConnector(NodeConnectorIDType.OPENFLOW, (short) 42, node);
+        Uri observed = MDFlowMapping.toUri(connector );
+
+        Assert.assertEquals("openflow:41:42", observed.getValue());
+    }
+
+}
index b418e6dc25879050d7e9525e671cf080c0444401..8a23ebc933b54359ed7f4dc0d5b4786c05a17d21 100644 (file)
@@ -10,9 +10,18 @@ package org.opendaylight.controller.sal.compatibility.test;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.sal.compatibility.NodeMapping;
+import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.MacAddress;
+import org.opendaylight.controller.sal.core.Node.NodeIDType;
+import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
 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.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.yangtools.yang.binding.InstanceIdentifier;
 
 /**
  * test of {@link NodeMapping} utility class
@@ -67,8 +76,118 @@ public class NodeMappingTest {
         observed = NodeMapping.toAdNodeId(null);
         Assert.assertNull(observed);
 
-        observed = NodeMapping.toAdNodeId(new NodeConnectorId("MD_SAL|openflow:5:2"));
-        Assert.assertEquals("MD_SAL|openflow:5", observed.getValue());
+        observed = NodeMapping.toAdNodeId(new NodeConnectorId("openflow:5:2"));
+        Assert.assertEquals("openflow:5", observed.getValue());
     }
 
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toADNode(NodeId)}
+     * .
+     */
+    @Test
+    public void testToAdNode1() {
+        org.opendaylight.controller.sal.core.Node observed;
+        try {
+            observed = NodeMapping.toADNode((NodeId) null);
+        } catch (NullPointerException | ConstructionException e) {
+            //expected
+        }
+
+        NodeId nodeId = new NodeId("openflow:1");
+        try {
+            observed = NodeMapping.toADNode(nodeId);
+            Assert.assertEquals("OF|00:00:00:00:00:00:00:01", observed.toString());
+        } catch (ConstructionException e) {
+            Assert.fail("should succeed to construct Node: "+e.getMessage());
+        }
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeConnectorType(NodeConnectorId, NodeId)}
+     * .
+     */
+    @Test
+    public void testToNodeConnectorType() {
+        NodeConnectorId ncId;
+        NodeId nodeId = buildNodeId("1");
+
+        ncId = buildNodeConnectorId("1", "42");
+        Assert.assertEquals(NodeConnectorIDType.OPENFLOW, NodeMapping.toNodeConnectorType(ncId, nodeId ));
+
+        ncId = buildNodeConnectorId("1", OutputPortValues.CONTROLLER.toString());
+        Assert.assertEquals(NodeConnectorIDType.CONTROLLER, NodeMapping.toNodeConnectorType(ncId, nodeId ));
+
+        ncId = buildNodeConnectorId("1", OutputPortValues.NORMAL.toString());
+        Assert.assertEquals(NodeConnectorIDType.HWPATH, NodeMapping.toNodeConnectorType(ncId, nodeId ));
+
+        ncId = buildNodeConnectorId("1", OutputPortValues.LOCAL.toString());
+        Assert.assertEquals(NodeConnectorIDType.SWSTACK, NodeMapping.toNodeConnectorType(ncId, nodeId ));
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toADNodeConnectorId(NodeConnectorId, NodeId)}
+     * .
+     */
+    @Test
+    public void testToAdNodeConnectorId() {
+        NodeConnectorId nodeConnectorId = buildNodeConnectorId("1", "2");
+        NodeId nodeId = buildNodeId("1");
+        Assert.assertEquals(Short.valueOf((short) 2), NodeMapping.toADNodeConnectorId(nodeConnectorId , nodeId));
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeRef(Node)}
+     * .
+     * @throws ConstructionException
+     */
+    @Test
+    public void testToNodeRef() throws ConstructionException {
+        org.opendaylight.controller.sal.core.Node node = new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, 42L);
+        InstanceIdentifier<?> nodePath = NodeMapping.toNodeRef(node).getValue();
+
+        String observedId = nodePath.firstKeyOf(Node.class, NodeKey.class).getId().getValue();
+        Assert.assertEquals("openflow:42", observedId);
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeConnectorRef(org.opendaylight.controller.sal.core.NodeConnector)}
+     * .
+     * @throws ConstructionException
+     */
+    @Test
+    public void testToNodeConnectorRef() throws ConstructionException {
+        org.opendaylight.controller.sal.core.Node node = new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, 42L);
+        org.opendaylight.controller.sal.core.NodeConnector nodeConnector =
+                new org.opendaylight.controller.sal.core.NodeConnector(
+                        NodeConnectorIDType.OPENFLOW, (short) 1, node);
+
+        InstanceIdentifier<?> nodeConnectorPath = NodeMapping.toNodeConnectorRef(nodeConnector ).getValue();
+        String observedNodeId = nodeConnectorPath.firstKeyOf(Node.class, NodeKey.class).getId().getValue();
+        Assert.assertEquals("openflow:42", observedNodeId);
+
+        String observedNodeConnectorId = nodeConnectorPath.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
+        Assert.assertEquals("openflow:1", observedNodeConnectorId);
+    }
+
+    /**
+     * @param nodeId
+     * @param portId
+     * @return nodeConnectorId
+     */
+    public static NodeConnectorId buildNodeConnectorId(String nodeId, String portId) {
+        return new NodeConnectorId(NodeConnectorIDType.OPENFLOW+"|" + nodeId + ":" + portId);
+    }
+
+    /**
+     * @param id
+     * @return nodeId
+     */
+    public static NodeId buildNodeId(String id) {
+        return new NodeId(NodeConnectorIDType.OPENFLOW+"|" + id);
+    }
 }
index 4d3509769c5c791e399e6a98357759c6c009d952..0157bc0c6415835b8ed52a7add015d707d57a6d8 100644 (file)
@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import junit.framework.Assert;
+
 import org.junit.Test;
 import org.opendaylight.controller.sal.action.Flood;
 import org.opendaylight.controller.sal.action.FloodAll;
@@ -47,6 +49,7 @@ import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
+import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
@@ -182,6 +185,17 @@ public class TestToSalConversionsUtils {
         checkSalFlow(salFlow);
     }
 
+    /**
+     * test of {@link ToSalConversionsUtils#fromNodeConnectorRef(Uri, Node)}
+     * @throws ConstructionException
+     */
+    @Test
+    public void testFromNodeConnectorRef() throws ConstructionException {
+        Node node = new Node(NodeIDType.OPENFLOW, 42L);
+        NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
+        Assert.assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
+    }
+
     private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) {
         switch (mt) {
         case other:
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java
new file mode 100644 (file)
index 0000000..b76370a
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ * 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.topology.test;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.compatibility.topology.TopologyMapping;
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+
+/**
+ * test for {@link TopologyMapping}
+ */
+public class TopologyMappingTest {
+
+    /**
+     * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
+     */
+    @Test
+    public void testToADNodeId() {
+        NodeId nodeId = new NodeId("openflow:1");
+        String observedNodeId = TopologyMapping.toADNodeId(nodeId);
+
+        Assert.assertEquals("1", observedNodeId);
+    }
+
+    /**
+     * 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 testToADNodeConnector() throws ConstructionException {
+        NodeId nodeId = new NodeId("openflow:1");
+        TpId source = new TpId("foo:2");
+        NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId);
+
+        Assert.assertEquals("OF|2@OF|00:00:00:00:00:00:00:01", observedNodeConnector.toString());
+    }
+
+    /**
+     * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnectorId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)}.
+     */
+    @Test
+    public void testToADNodeConnectorId() {
+        TpId source = new TpId("foo:2");
+        String observedNodeConnectorId = TopologyMapping.toADNodeConnectorId(source);
+
+        Assert.assertEquals("2", observedNodeConnectorId);
+    }
+
+    /**
+     * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
+     * @throws ConstructionException
+     */
+    @Test
+    public void testToADNode() throws ConstructionException {
+        NodeId nodeId = new NodeId("openflow:1");
+        Node observedNode = TopologyMapping.toADNode(nodeId);
+
+        Assert.assertEquals("OF|00:00:00:00:00:00:00:01", observedNode.toString());
+    }
+
+}
index efe1ce3e3aaebad8d2b2a0a866d5d12392238a7c..deff6f17984cce55c8bcf97b43159f42852ebfec 100644 (file)
@@ -275,6 +275,17 @@ module opendaylight-match-types {
         }
     }
 
+    grouping "tunnel-ipv4-match-fields" {
+        leaf tunnel-ipv4-source {
+            description "IPv4 source tunnel endpoint address.";
+            type inet:ipv4-prefix;
+        }
+        leaf tunnel-ipv4-destination {
+            description "IPv4 destination tunnel endpoint address.";
+            type inet:ipv4-prefix;
+        }
+    }
+
     grouping match {
         leaf in-port {
             type inv:node-connector-id;
@@ -321,6 +332,9 @@ module opendaylight-match-types {
             case "arp-match" {
                 uses "arp-match-fields";
             }
+            case "tunnel-ipv4-match" {
+                uses "tunnel-ipv4-match-fields";
+            }
         }
 
         choice layer-4-match {
index f1cbd8dc29e7b2a5d0b29cef831c9c0068752a7d..9e880987524c3cee54d7f0486f7dce5df272ae17 100644 (file)
@@ -62,7 +62,10 @@ module opendaylight-port-types {
     grouping common-port {
 
         leaf port-number {
-            type uint32;
+            type union {
+                type uint32;
+                type string;
+            }
         }
         
         leaf hardware-address {
index c271f8f4d00a6b99318bc25baeae9251ac13ea97..393f6db9febbc0970b36c3dca1d8bf4d24ae674d 100644 (file)
@@ -192,6 +192,14 @@ module opendaylight-table-types {
         base match-field;
         description "TCP Flag Match";
     }
+    identity tunnel_ipv4_dst {
+        base match-field;
+        description "IPv4 destination tunnel endpoint address.";
+    }
+    identity tunnel_ipv4_src {
+        base match-field;
+        description "IPv4 source tunnel endpoint address.";
+    }
         
     grouping set-field-match {
         list set-field-match {
index 05f4b4d63c5cc8983bfadf3971c66438e240cd69..24dcfad02bf46b4e610aa1ad0bac0f76d9070671 100644 (file)
     <!-- Compability Packages -->
     <module>compatibility</module>
 
-    <!-- Clustering -->
-    <module>remoterpc-routingtable/implementation</module>
-    <module>sal-remoterpc-connector/implementation</module>
-
     <!-- Documentation -->
     <module>sal-rest-docgen</module>
 
+    <!--InMemory DOM DataStore-->
+    <module>sal-inmemory-datastore</module>
+
     <!--sal-protocolbuffer-encoding-->
     <module>sal-protocolbuffer-encoding</module>
 
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/pom.xml b/opendaylight/md-sal/remoterpc-routingtable/implementation/pom.xml
deleted file mode 100644 (file)
index 8cab0b5..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?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>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-
-  <artifactId>remoterpc-routingtable.implementation</artifactId>
-  <packaging>bundle</packaging>
-  <dependencies>
-
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>clustering.services</artifactId>
-      <version>${clustering.services.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.osgi</groupId>
-          <artifactId>org.osgi.compendium</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-connector-api</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Export-Package>org.opendaylight.controller.sal.connector.remoterpc.api,
-                            org.opendaylight.controller.sal.connector.remoterpc.impl</Export-Package>
-            <Import-Package>javax.xml.bind.annotation,
-                            org.opendaylight.controller.sal.core,
-                            org.opendaylight.controller.sal.utils,
-                            org.opendaylight.controller.sal.packet,
-                            org.opendaylight.controller.sal.topology,
-                            org.opendaylight.controller.clustering.services,
-                            org.opendaylight.controller.md.sal.common.api.data,
-                            org.opendaylight.yangtools.yang.binding,
-                            org.osgi.service.component,
-                            org.slf4j,
-                            org.apache.felix.dm,
-                            org.apache.commons.lang3.builder,
-                            org.apache.commons.lang3.tuple,
-                            org.eclipse.osgi.framework.console,
-                            org.osgi.framework,
-                            javax.transaction,
-                            com.google.common.base,
-                            com.google.common.collect</Import-Package>
-            <Bundle-Activator>org.opendaylight.controller.sal.connector.remoterpc.impl.Activator</Bundle-Activator>
-          </instructions>
-          <manifestLocation>${project.basedir}/META-INF</manifestLocation>
-        </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://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
-  </scm>
-</project>
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RouteChangeListener.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RouteChangeListener.java
deleted file mode 100644 (file)
index c9b47ed..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc.api;
-
-import java.util.EventListener;
-
-public interface RouteChangeListener<I,R> extends EventListener {
-
-
-   void onRouteUpdated(I key, R new_value);
-
-   void onRouteDeleted(I key);
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RoutingTable.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RoutingTable.java
deleted file mode 100644 (file)
index e5e314c..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc.api;
-
-import java.util.Set;
-
-public interface RoutingTable<I,R> {
-
-  /**
-   * Adds a network address for the route. If the route already exists,
-   * it throws <code>DuplicateRouteException</code>.
-   * This method would be used when registering a global service.
-   *
-   *
-   * @param routeId route identifier
-   * @param route network address
-   * @throws DuplicateRouteException
-   * @throws RoutingTableException
-   */
-  public void addGlobalRoute(I routeId, R route) throws  RoutingTableException, SystemException;
-
-  /**
-   * Remove the route.
-   * This method would be used when registering a global service.
-   * @param routeId
-   * @throws RoutingTableException
-   * @throws SystemException
-   */
-  public void removeGlobalRoute(I routeId) throws RoutingTableException, SystemException;
-
-  /**
-   * Adds a network address for the route. If the route already exists,
-   * it throws <code>DuplicateRouteException</code>.
-   * This method would be used when registering a global service.
-   *
-   *
-   * @param routeId route identifier
-   * @param route network address
-   * @throws DuplicateRouteException
-   * @throws RoutingTableException
-   */
-  public R getGlobalRoute(I routeId) throws  RoutingTableException, SystemException;
-
-  /**
-   * Adds a network address for the route. If address for route
-   * exists, appends the address to the list
-   *
-   * @param routeId route identifier
-   * @param route network address
-   * @throws RoutingTableException for any logical exception
-   * @throws SystemException
-   */
-  public void addRoute(I routeId, R route) throws RoutingTableException,SystemException;
-
-
-  /**
-   * Removes the network address for the route from routing table. If only
-   * one network address existed, remove the route as well.
-   * @param routeId
-   * @param route
-   */
-  public void removeRoute(I routeId, R route) throws RoutingTableException,SystemException;
-
-  /**
-   * Adds address for a set of route identifiers. If address for route
-   * exists, appends the address to the set.
-   *
-   * @param routeIds a set of routeIds
-   * @param route network address
-   * @throws RoutingTableException for any logical exception
-   * @throws SystemException
-   */
-  public void addRoutes(Set<I> routeIds, R route) throws  RoutingTableException,SystemException;
-
-  /**
-   * Removes address for a set of route identifiers.
-   *
-   * @param routeIds a set of routeIds
-   * @param route network address
-   * @throws RoutingTableException for any logical exception
-   * @throws SystemException
-   */
-  public void removeRoutes(Set<I> routeIds, R route) throws  RoutingTableException,SystemException;
-
-  /**
-   * Returns a set of network addresses associated with this route
-   * @param routeId
-   * @return
-   */
-  public Set<R> getRoutes(I routeId);
-
-
-  /**
-   * Returns the last inserted address from the list of network addresses
-   * associated with the route.
-   * @param routeId
-   * @return
-   */
-  public R getLastAddedRoute(I routeId);
-
-  public class DuplicateRouteException extends RoutingTableException {
-      public DuplicateRouteException(String message) {
-          super(message);
-      }
-
-  }
-
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RoutingTableException.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/RoutingTableException.java
deleted file mode 100644 (file)
index fc7f6f1..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc.api;
-
-/**
- * @author: syedbahm
- */
-public class RoutingTableException extends Exception {
-
-    /**
-     * Constructs a new exception with {@code null} as its detail message.
-     * The cause is not initialized, and may subsequently be initialized by a
-     * call to {@link #initCause}.
-     */
-    public RoutingTableException() {
-        super();
-    }
-
-    /**
-     * Constructs a new exception with the specified detail message.  The
-     * cause is not initialized, and may subsequently be initialized by
-     * a call to {@link #initCause}.
-     *
-     * @param message the detail message. The detail message is saved for
-     *                later retrieval by the {@link #getMessage()} method.
-     */
-    public RoutingTableException(String message) {
-        super(message);
-    }
-
-    /**
-     * Constructs a new exception with the specified detail message and
-     * cause.  <p>Note that the detail message associated with
-     * {@code cause} is <i>not</i> automatically incorporated in
-     * this exception's detail message.
-     *
-     * @param message the detail message (which is saved for later retrieval
-     *                by the {@link #getMessage()} method).
-     * @param cause   the cause (which is saved for later retrieval by the
-     *                {@link #getCause()} method).  (A <tt>null</tt> value is
-     *                permitted, and indicates that the cause is nonexistent or
-     *                unknown.)
-     */
-    public RoutingTableException(String message, Throwable cause) {
-        super(message, cause);
-    }
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/SystemException.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/api/SystemException.java
deleted file mode 100644 (file)
index 491858e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-
-
-package org.opendaylight.controller.sal.connector.remoterpc.api;
-
-/**
- * @author: syedbahm
- *
- */
-public class SystemException extends  Exception {
-    /**
-     * Constructs a new exception with {@code null} as its detail message.
-     * The cause is not initialized, and may subsequently be initialized by a
-     * call to {@link #initCause}.
-     */
-    public SystemException() {
-        super();
-    }
-
-    /**
-     * Constructs a new exception with the specified detail message.  The
-     * cause is not initialized, and may subsequently be initialized by
-     * a call to {@link #initCause}.
-     *
-     * @param message the detail message. The detail message is saved for
-     *                later retrieval by the {@link #getMessage()} method.
-     */
-    public SystemException(String message) {
-        super(message);
-    }
-
-    /**
-     * Constructs a new exception with the specified detail message and
-     * cause.  <p>Note that the detail message associated with
-     * {@code cause} is <i>not</i> automatically incorporated in
-     * this exception's detail message.
-     *
-     * @param message the detail message (which is saved for later retrieval
-     *                by the {@link #getMessage()} method).
-     * @param cause   the cause (which is saved for later retrieval by the
-     *                {@link #getCause()} method).  (A <tt>null</tt> value is
-     *                permitted, and indicates that the cause is nonexistent or
-     *                unknown.)
-     * @since 1.4
-     */
-    public SystemException(String message, Throwable cause) {
-        super(message, cause);
-    }
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/impl/Activator.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/impl/Activator.java
deleted file mode 100644 (file)
index a826a3c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.impl;
-
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
-import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RouteChangeListener;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Set;
-
-/**
- * @author: syedbahm
- */
-public class Activator extends ComponentActivatorAbstractBase {
-
-    protected static final Logger logger = LoggerFactory
-            .getLogger(Activator.class);
-    private static final String CACHE_UPDATE_AWARE_REGISTRY_KEY = "cachenames" ;
-
-
-    /**
-     * Method which tells how many Global implementations are
-     * supported by the bundle. This way we can tune the number of
-     * components created. This components will be created ONLY at the
-     * time of bundle startup and will be destroyed only at time of
-     * bundle destruction, this is the major difference with the
-     * implementation retrieved via getImplementations where all of
-     * them are assumed to be in a container!
-     *
-     *
-     * @return The list of implementations the bundle will support,
-     * in Global version
-     */
-
-    @Override
-    protected Object[] getGlobalImplementations(){
-        logger.debug("Calling getGlobalImplementations to return:", RoutingTableImpl.class);
-        return new Object[] {
-                RoutingTableImpl.class
-        };
-    }
-
-    /**
-     * Configure the dependency for a given instance Global
-     *
-     * @param c Component assigned for this instance, this will be
-     * what will be used for configuration
-     * @param imp implementation to be configured
-     *
-     */
-    @Override
-    protected void configureGlobalInstance(Component c, Object imp){
-        if (imp.equals(RoutingTableImpl.class)) {
-            Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
-            Set<String> propSet = new HashSet<String>();
-            propSet.add(RoutingTableImpl.GLOBALRPC_CACHE);
-            propSet.add(RoutingTableImpl.RPC_CACHE);
-            props.put(CACHE_UPDATE_AWARE_REGISTRY_KEY, propSet);
-
-            c.setInterface(new String[] { RoutingTable.class.getName(),ICacheUpdateAware.class.getName()  }, props);
-            logger.debug("configureGlobalInstance adding dependency:", IClusterGlobalServices.class);
-
-
-            // RouteChangeListener services will be none or many so the
-            // dependency is optional
-            c.add(createServiceDependency()
-                    .setService(RouteChangeListener.class)
-                    .setCallbacks("setRouteChangeListener", "unsetRouteChangeListener")
-                    .setRequired(false));
-
-            //dependency is required as it provides us the caching support
-            c.add(createServiceDependency().setService(
-                    IClusterGlobalServices.class).setCallbacks(
-                    "setClusterGlobalServices",
-                    "unsetClusterGlobalServices").setRequired(true));
-
-        }
-    }
-
-
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/impl/RoutingTableImpl.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/impl/RoutingTableImpl.java
deleted file mode 100644 (file)
index e242b0a..0000000
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.impl;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.CacheListenerAddException;
-import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
-import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-
-public class RoutingTableImpl<I, R> implements RoutingTable<I, R>, ICacheUpdateAware<I, R> {
-
-    private final Logger log = LoggerFactory.getLogger(RoutingTableImpl.class);
-
-    private IClusterGlobalServices clusterGlobalServices = null;
-
-    private ConcurrentMap<I,R> globalRpcCache = null;
-    private ConcurrentMap<I, LinkedHashSet<R>> rpcCache = null;  //need routes to ordered by insert-order
-
-    public static final String GLOBALRPC_CACHE = "remoterpc_routingtable.globalrpc_cache";
-    public static final String RPC_CACHE = "remoterpc_routingtable.rpc_cache";
-
-    public RoutingTableImpl() {
-    }
-
-    @Override
-    public R getGlobalRoute(final I routeId) throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeId, "getGlobalRoute: routeId cannot be null!");
-        return globalRpcCache.get(routeId);
-    }
-
-    @Override
-    public void addGlobalRoute(final I routeId, final R route) throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeId, "addGlobalRoute: routeId cannot be null!");
-        Preconditions.checkNotNull(route, "addGlobalRoute: route cannot be null!");
-        try {
-
-            log.debug("addGlobalRoute: adding  a new route with id[{}] and value [{}]", routeId, route);
-            clusterGlobalServices.tbegin();
-            if (globalRpcCache.putIfAbsent(routeId, route) != null) {
-                throw new DuplicateRouteException(" There is already existing route " + routeId);
-            }
-            clusterGlobalServices.tcommit();
-
-        } catch (NotSupportedException | HeuristicRollbackException | RollbackException | HeuristicMixedException e) {
-            throw new RoutingTableException("Transaction error - while trying to create route id="
-                    + routeId + "with route" + route, e);
-        } catch (javax.transaction.SystemException e) {
-            throw new SystemException("System error occurred - while trying to create with value", e);
-        }
-
-    }
-
-    @Override
-    public void removeGlobalRoute(final I routeId) throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeId, "removeGlobalRoute: routeId cannot be null!");
-        try {
-            log.debug("removeGlobalRoute: removing  a new route with id [{}]", routeId);
-
-            clusterGlobalServices.tbegin();
-            globalRpcCache.remove(routeId);
-            clusterGlobalServices.tcommit();
-
-        } catch (NotSupportedException | HeuristicRollbackException | RollbackException | HeuristicMixedException e) {
-            throw new RoutingTableException("Transaction error - while trying to remove route id="
-                    + routeId, e);
-        } catch (javax.transaction.SystemException e) {
-            throw new SystemException("System error occurred - while trying to remove with value", e);
-        }
-    }
-
-
-    @Override
-    public Set<R> getRoutes(final I routeId) {
-        Preconditions.checkNotNull(routeId, "getRoutes: routeId cannot be null!");
-        Set<R> routes = rpcCache.get(routeId);
-
-        if (routes == null) {
-            return Collections.emptySet();
-        }
-
-        return ImmutableSet.copyOf(routes);
-    }
-
-
-
-    @Override
-    public R getLastAddedRoute(final I routeId) {
-
-        Set<R> routes = getRoutes(routeId);
-
-        if (routes.isEmpty()) {
-            return null;
-        }
-
-        R route = null;
-        Iterator<R> iter = routes.iterator();
-        while (iter.hasNext()) {
-            route = iter.next();
-        }
-
-        return route;
-    }
-
-    @Override
-    public void addRoute(final I routeId, final R route)  throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeId, "addRoute: routeId cannot be null");
-        Preconditions.checkNotNull(route, "addRoute: route cannot be null");
-
-        try{
-            clusterGlobalServices.tbegin();
-            log.debug("addRoute: adding a route with k/v [{}/{}]", routeId, route);
-            threadSafeAdd(routeId, route);
-            clusterGlobalServices.tcommit();
-
-        } catch (NotSupportedException | HeuristicRollbackException | RollbackException | HeuristicMixedException e) {
-            throw new RoutingTableException("Transaction error - while trying to remove route id="
-                    + routeId, e);
-        } catch (javax.transaction.SystemException e) {
-            throw new SystemException("System error occurred - while trying to remove with value", e);
-        }
-    }
-
-    @Override
-    public void addRoutes(final Set<I> routeIds, final R route) throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeIds, "addRoutes: routeIds must not be null");
-        for (I routeId : routeIds){
-            addRoute(routeId, route);
-        }
-    }
-
-    @Override
-    public void removeRoute(final I routeId, final R route) throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeId, "removeRoute: routeId cannot be null!");
-        Preconditions.checkNotNull(route, "removeRoute: route cannot be null!");
-
-        LinkedHashSet<R> routes = rpcCache.get(routeId);
-        if (routes == null) {
-            return;
-        }
-
-        try {
-            log.debug("removeRoute: removing  a new route with k/v [{}/{}]", routeId, route);
-
-            clusterGlobalServices.tbegin();
-            threadSafeRemove(routeId, route);
-            clusterGlobalServices.tcommit();
-
-        } catch (NotSupportedException | HeuristicRollbackException | RollbackException | HeuristicMixedException e) {
-            throw new RoutingTableException("Transaction error - while trying to remove route id="
-                    + routeId, e);
-        } catch (javax.transaction.SystemException e) {
-            throw new SystemException("System error occurred - while trying to remove with value", e);
-        }
-    }
-
-    @Override
-    public void removeRoutes(final Set<I> routeIds, final R route) throws RoutingTableException, SystemException {
-        Preconditions.checkNotNull(routeIds, "removeRoutes: routeIds must not be null");
-        for (I routeId : routeIds){
-            removeRoute(routeId, route);
-        }
-    }
-
-    /**
-     * This method guarantees that no 2 thread over write each other's changes.
-     * Just so that we dont end up in infinite loop, it tries for 100 times then throw
-     */
-    private void threadSafeAdd(final I routeId, final R route) {
-
-        for (int i=0;i<100;i++){
-
-            LinkedHashSet<R> updatedRoutes = new LinkedHashSet<>();
-            updatedRoutes.add(route);
-            LinkedHashSet<R> oldRoutes = rpcCache.putIfAbsent(routeId, updatedRoutes);
-            if (oldRoutes == null) {
-                return;
-            }
-
-            updatedRoutes = new LinkedHashSet<>(oldRoutes);
-            updatedRoutes.add(route);
-
-            if (rpcCache.replace(routeId, oldRoutes, updatedRoutes)) {
-                return;
-            }
-        }
-        //the method did not already return means it failed to add route in 10 attempts
-        throw new IllegalStateException("Failed to add route [" + routeId + "]");
-    }
-
-    /**
-     * This method guarantees that no 2 thread over write each other's changes.
-     * Just so that we dont end up in infinite loop, it tries for 10 times then throw
-     */
-    private void threadSafeRemove(final I routeId, final R route) {
-        LinkedHashSet<R> updatedRoutes = null;
-        for (int i=0;i<10;i++){
-            LinkedHashSet<R> oldRoutes = rpcCache.get(routeId);
-
-            // if route to be deleted is the only entry in the set then remove routeId from the cache
-            if ((oldRoutes.size() == 1) && oldRoutes.contains(route)){
-                rpcCache.remove(routeId);
-                return;
-            }
-
-            // if there are multiple routes for this routeId, remove the route to be deleted only from the set.
-            updatedRoutes = new LinkedHashSet<>(oldRoutes);
-            updatedRoutes.remove(route);
-            if (rpcCache.replace(routeId, oldRoutes, updatedRoutes)) {
-                return;
-            }
-
-        }
-        //the method did not already return means it failed to remove route in 10 attempts
-        throw new IllegalStateException("Failed to remove route [" + routeId + "]");
-    }
-
-
-    //    /**
-    //     * @deprecated doesn't do anything will be removed once listeners used
-    //     *             whiteboard pattern Registers listener for sending any change
-    //     *             notification
-    //     * @param listener
-    //     */
-    //    @Override
-    //    public void registerRouteChangeListener(RouteChangeListener listener) {
-    //
-    //    }
-
-    //    public void setRouteChangeListener(RouteChangeListener rcl) {
-    //        if(rcl != null){
-    //            routeChangeListeners.add(rcl);
-    //        }else{
-    //            log.warn("setRouteChangeListener called with null listener");
-    //        }
-    //    }
-    //
-    //    public void unSetRouteChangeListener(RouteChangeListener rcl) {
-    //        if(rcl != null){
-    //         routeChangeListeners.remove(rcl);
-    //        }else{
-    //            log.warn("unSetRouteChangeListener called with null listener");
-    //        }
-    //    }
-
-    /**
-     * Returning the set of route change listeners for Unit testing Note: the
-     * package scope is default
-     *
-     * @return List of registered RouteChangeListener<I,R> listeners
-     */
-    //    Set<RouteChangeListener> getRegisteredRouteChangeListeners() {
-    //        return routeChangeListeners;
-    //    }
-    public void setClusterGlobalServices(final IClusterGlobalServices clusterGlobalServices) {
-        this.clusterGlobalServices = clusterGlobalServices;
-    }
-
-    public void unsetClusterGlobalServices(final IClusterGlobalServices clusterGlobalServices) {
-        if ((clusterGlobalServices != null) && (this.clusterGlobalServices.equals(clusterGlobalServices))) {
-            this.clusterGlobalServices = null;
-        }
-    }
-
-    /**
-     * Finds OR Creates clustered cache for Global RPCs
-     *
-     * @throws CacheExistException       -- cluster global services exception when cache exist
-     * @throws CacheConfigException      -- cluster global services exception during cache config
-     * @throws CacheListenerAddException -- cluster global services exception during adding of listener
-     */
-
-    @SuppressWarnings("unchecked")
-    void findOrCreateGlobalRpcCache() throws CacheExistException, CacheConfigException,
-    CacheListenerAddException {
-        // TBD: HOW DO WE DECIDE ON PROPERTIES OF THE CACHE i.e. what duration it
-        // should be caching?
-
-        // let us check here if the cache already exists -- if so don't create
-        if (!clusterGlobalServices.existCache(GLOBALRPC_CACHE)) {
-
-            globalRpcCache = (ConcurrentMap<I,R>) clusterGlobalServices.createCache(GLOBALRPC_CACHE,
-                    EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
-            log.debug("Cache created [{}] ", GLOBALRPC_CACHE);
-
-        } else {
-            globalRpcCache = (ConcurrentMap<I,R>) clusterGlobalServices.getCache(GLOBALRPC_CACHE);
-            log.debug("Cache exists [{}] ", GLOBALRPC_CACHE);
-        }
-    }
-
-    /**
-     * Finds OR Creates clustered cache for Routed RPCs
-     *
-     * @throws CacheExistException       -- cluster global services exception when cache exist
-     * @throws CacheConfigException      -- cluster global services exception during cache config
-     * @throws CacheListenerAddException -- cluster global services exception during adding of listener
-     */
-
-    @SuppressWarnings("unchecked")
-    void findOrCreateRpcCache() throws CacheExistException, CacheConfigException,
-    CacheListenerAddException {
-        // TBD: HOW DO WE DECIDE ON PROPERTIES OF THE CACHE i.e. what duration it
-        // should be caching?
-
-        if (clusterGlobalServices.existCache(RPC_CACHE)){
-            rpcCache = (ConcurrentMap<I,LinkedHashSet<R>>) clusterGlobalServices.getCache(RPC_CACHE);
-            log.debug("Cache exists [{}] ", RPC_CACHE);
-            return;
-        }
-
-        //cache doesnt exist, create one
-        rpcCache = (ConcurrentMap<I,LinkedHashSet<R>>) clusterGlobalServices.createCache(RPC_CACHE,
-                EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
-        log.debug("Cache created [{}] ", RPC_CACHE);
-    }
-
-
-    /**
-     * Function called by the dependency manager when all the required
-     * dependencies are satisfied
-     */
-    void init(final Component c) {
-        try {
-
-            findOrCreateGlobalRpcCache();
-            findOrCreateRpcCache();
-
-        } catch (CacheExistException|CacheConfigException|CacheListenerAddException e) {
-            throw new IllegalStateException("could not construct routing table cache");
-        }
-    }
-
-    /**
-     * Useful for unit testing <note>It has package
-     * scope</note>
-     */
-    ConcurrentMap<I, R> getGlobalRpcCache() {
-        return this.globalRpcCache;
-    }
-
-    /**
-     * Useful for unit testing <note>It has package
-     * scope</note>
-     */
-    ConcurrentMap<I, LinkedHashSet<R>> getRpcCache() {
-        return this.rpcCache;
-    }
-
-    /**
-     * This is used from integration test NP rest API to check out the result of the
-     * cache population
-     * <Note> For testing purpose only-- use it wisely</Note>
-     *
-     * @return
-     */
-    public String dumpGlobalRpcCache() {
-        Set<Map.Entry<I, R>> cacheEntrySet = this.globalRpcCache.entrySet();
-        StringBuilder sb = new StringBuilder();
-        for (Map.Entry<I, R> entry : cacheEntrySet) {
-            sb.append("Key:").append(entry.getKey()).append("---->Value:")
-            .append((entry.getValue() != null) ? entry.getValue() : "null")
-            .append("\n");
-        }
-        return sb.toString();
-    }
-
-    public String dumpRpcCache() {
-        Set<Map.Entry<I, LinkedHashSet<R>>> cacheEntrySet = this.rpcCache.entrySet();
-        StringBuilder sb = new StringBuilder();
-        for (Map.Entry<I, LinkedHashSet<R>> entry : cacheEntrySet) {
-            sb.append("Key:").append(entry.getKey()).append("---->Value:")
-            .append((entry.getValue() != null) ? entry.getValue() : "null")
-            .append("\n");
-        }
-        return sb.toString();
-    }
-    /**
-     * Invoked when a new entry is available in the cache, the key is only
-     * provided, the value will come as an entryUpdate invocation
-     *
-     * @param key         Key for the entry just created
-     * @param cacheName   name of the cache for which update has been received
-     * @param originLocal true if the event is generated from this node
-     */
-    @Override
-    public void entryCreated(final I key, final String cacheName, final boolean originLocal) {
-        // TBD: do we require this.
-        if (log.isDebugEnabled()) {
-            log.debug("RoutingTableUpdates: entryCreated  routeId = " + key + " cacheName=" + cacheName);
-        }
-    }
-
-    /**
-     * Called anytime a given entry is updated
-     *
-     * @param key         Key for the entry modified
-     * @param new_value   the new value the key will have
-     * @param cacheName   name of the cache for which update has been received
-     * @param originLocal true if the event is generated from this node
-     */
-    @Override
-    public void entryUpdated(final I key, final R new_value, final String cacheName, final boolean originLocal) {
-        if (log.isDebugEnabled()) {
-            log.debug("RoutingTableUpdates: entryUpdated  routeId = " + key + ",value = " + new_value
-                    + " ,cacheName=" + cacheName + " originLocal=" + originLocal);
-        }
-        //        if (!originLocal) {
-        //            for (RouteChangeListener rcl : routeChangeListeners) {
-        //                rcl.onRouteUpdated(key, new_value);
-        //            }
-        //        }
-    }
-
-    /**
-     * Called anytime a given key is removed from the ConcurrentHashMap we are
-     * listening to.
-     *
-     * @param key         Key of the entry removed
-     * @param cacheName   name of the cache for which update has been received
-     * @param originLocal true if the event is generated from this node
-     */
-    @Override
-    public void entryDeleted(final I key, final String cacheName, final boolean originLocal) {
-        if (log.isDebugEnabled()) {
-            log.debug("RoutingTableUpdates: entryUpdated  routeId = " + key + " local = " + originLocal
-                    + " cacheName=" + cacheName + " originLocal=" + originLocal);
-        }
-        //        if (!originLocal) {
-        //            for (RouteChangeListener rcl : routeChangeListeners) {
-        //                rcl.onRouteDeleted(key);
-        //            }
-        //        }
-    }
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/impl/RoutingTableImplTest.java b/opendaylight/md-sal/remoterpc-routingtable/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/impl/RoutingTableImplTest.java
deleted file mode 100644 (file)
index 1ff49c1..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.impl;
-
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.when;
-
-import java.net.URI;
-import java.util.EnumSet;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.Assert;
-
-import org.apache.felix.dm.Component;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-public class RoutingTableImplTest {
-
-    private final URI namespace = URI.create("http://cisco.com/example");
-    private final QName QNAME = new QName(namespace, "global");
-
-    private IClusterGlobalServices clusterService;
-    private RoutingTableImpl<RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier>, String> routingTable;
-    ConcurrentMap mockGlobalRpcCache;
-    ConcurrentMap mockRpcCache;
-
-    @Before
-    public void setUp() throws Exception{
-        clusterService = mock(IClusterGlobalServices.class);
-        routingTable = new RoutingTableImpl<RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier>, String>();
-        mockGlobalRpcCache = new ConcurrentHashMap<>();
-        mockRpcCache = new ConcurrentHashMap<>();
-        createRoutingTableCache();
-    }
-
-    @After
-    public void tearDown(){
-        reset(clusterService);
-        mockGlobalRpcCache = null;
-        mockRpcCache = null;
-    }
-
-    @Test
-    public void addGlobalRoute_ValidArguments_ShouldAdd() throws Exception {
-
-        Assert.assertNotNull(mockGlobalRpcCache);
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = getRouteIdentifier();
-
-        final String expectedRoute = "172.27.12.1:5000";
-        routingTable.addGlobalRoute(routeIdentifier, expectedRoute);
-
-        ConcurrentMap latestCache = routingTable.getGlobalRpcCache();
-        Assert.assertEquals(mockGlobalRpcCache, latestCache);
-        Assert.assertEquals(expectedRoute, latestCache.get(routeIdentifier));
-    }
-
-    @Test (expected = RoutingTable.DuplicateRouteException.class)
-    public void addGlobalRoute_DuplicateRoute_ShouldThrow() throws Exception{
-
-        Assert.assertNotNull(mockGlobalRpcCache);
-
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = getRouteIdentifier();
-        routingTable.addGlobalRoute(routeIdentifier, new String());
-        routingTable.addGlobalRoute(routeIdentifier, new String());
-    }
-
-    @Test
-    public void getGlobalRoute_ExistingRouteId_ShouldReturnRoute() throws Exception {
-
-        Assert.assertNotNull(mockGlobalRpcCache);
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = getRouteIdentifier();
-        String expectedRoute = "172.27.12.1:5000";
-
-        routingTable.addGlobalRoute(routeIdentifier, expectedRoute);
-
-        String actualRoute = routingTable.getGlobalRoute(routeIdentifier);
-        Assert.assertEquals(expectedRoute, actualRoute);
-    }
-
-    @Test
-    public void getGlobalRoute_NonExistentRouteId_ShouldReturnNull() throws Exception {
-
-        Assert.assertNotNull(mockGlobalRpcCache);
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = getRouteIdentifier();
-
-        String actualRoute = routingTable.getGlobalRoute(routeIdentifier);
-        Assert.assertNull(actualRoute);
-    }
-
-    @Test
-    public void removeGlobalRoute_ExistingRouteId_ShouldRemove() throws Exception {
-
-        Assert.assertNotNull(mockGlobalRpcCache);
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = getRouteIdentifier();
-
-        ConcurrentMap cache = routingTable.getGlobalRpcCache();
-        Assert.assertTrue(cache.size() == 0);
-        routingTable.addGlobalRoute(routeIdentifier, "172.27.12.1:5000");
-        Assert.assertTrue(cache.size() == 1);
-
-        routingTable.removeGlobalRoute(routeIdentifier);
-        Assert.assertTrue(cache.size() == 0);
-
-    }
-
-    @Test
-    public void removeGlobalRoute_NonExistentRouteId_ShouldDoNothing() throws Exception {
-
-        Assert.assertNotNull(mockGlobalRpcCache);
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = getRouteIdentifier();
-
-        ConcurrentMap cache = routingTable.getGlobalRpcCache();
-        Assert.assertTrue(cache.size() == 0);
-
-        routingTable.removeGlobalRoute(routeIdentifier);
-        Assert.assertTrue(cache.size() == 0);
-
-    }
-
-    @Test
-    public void addRoute_ForNewRouteId_ShouldAddRoute() throws Exception {
-        Assert.assertTrue(mockRpcCache.size() == 0);
-
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeId = getRouteIdentifier();
-
-        routingTable.addRoute(routeId, new String());
-        Assert.assertTrue(mockRpcCache.size() == 1);
-
-        Set<String> routes = routingTable.getRoutes(routeId);
-        Assert.assertEquals(1, routes.size());
-    }
-
-    @Test
-    public void addRoute_ForExistingRouteId_ShouldAppendRoute() throws Exception {
-
-        Assert.assertTrue(mockRpcCache.size() == 0);
-
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeId = getRouteIdentifier();
-
-        String route_1 = "10.0.0.1:5955";
-        String route_2 = "10.0.0.2:5955";
-
-        routingTable.addRoute(routeId, route_1);
-        routingTable.addRoute(routeId, route_2);
-
-        Assert.assertTrue(mockRpcCache.size() == 1);
-
-        Set<String> routes = routingTable.getRoutes(routeId);
-        Assert.assertEquals(2, routes.size());
-        Assert.assertTrue(routes.contains(route_1));
-        Assert.assertTrue(routes.contains(route_2));
-    }
-
-    @Test
-    public void addRoute_UsingMultipleThreads_ShouldNotOverwrite(){
-        ExecutorService threadPool = Executors.newCachedThreadPool();
-
-        int numOfRoutesToAdd = 100;
-        String routePrefix_1   = "10.0.0.1:555";
-        RpcRouter.RouteIdentifier routeId = getRouteIdentifier();
-        threadPool.submit(addRoutes(numOfRoutesToAdd, routePrefix_1, routeId));
-        String routePrefix_2   = "10.0.0.1:556";
-        threadPool.submit(addRoutes(numOfRoutesToAdd, routePrefix_2, routeId));
-
-        // wait for all tasks to complete; timeout in 10 sec
-        threadPool.shutdown();
-        try {
-            threadPool.awaitTermination(10, TimeUnit.SECONDS); //
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-
-        Assert.assertEquals(2*numOfRoutesToAdd, routingTable.getRoutes(routeId).size());
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void addRoute_NullRouteId_shouldThrowNpe() throws Exception {
-
-        routingTable.addRoute(null, new String());
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void addRoute_NullRoute_shouldThrowNpe() throws Exception{
-
-        routingTable.addRoute(getRouteIdentifier(), null);
-    }
-
-    @Test (expected = UnsupportedOperationException.class)
-    public void getRoutes_Call_ShouldReturnImmutableCopy() throws Exception{
-        Assert.assertNotNull(routingTable);
-        RpcRouter.RouteIdentifier routeId = getRouteIdentifier();
-        routingTable.addRoute(routeId, new String());
-
-        Set<String> routes = routingTable.getRoutes(routeId); //returns Immutable Set
-
-        routes.add(new String()); //can not be modified; should throw
-    }
-
-    @Test
-    public void getRoutes_With2RoutesFor1RouteId_ShouldReturnASetWithSize2() throws Exception{
-        Assert.assertNotNull(routingTable);
-        RpcRouter.RouteIdentifier routeId = getRouteIdentifier();
-        routingTable.addRoute(routeId, "10.0.0.1:5555");
-        routingTable.addRoute(routeId, "10.0.0.2:5555");
-
-        Set<String> routes = routingTable.getRoutes(routeId); //returns Immutable Set
-
-        Assert.assertEquals(2, routes.size());
-    }
-
-    @Test
-    public void getLastAddedRoute_WhenMultipleRoutesExists_ShouldReturnLatestRoute()
-            throws Exception {
-
-        Assert.assertNotNull(routingTable);
-        RpcRouter.RouteIdentifier routeId = getRouteIdentifier();
-        String route_1 = "10.0.0.1:5555";
-        String route_2 = "10.0.0.2:5555";
-        routingTable.addRoute(routeId, route_1);
-        routingTable.addRoute(routeId, route_2);
-
-        Assert.assertEquals(route_2, routingTable.getLastAddedRoute(routeId));
-    }
-
-    @Test
-    public void removeRoute_WhenMultipleRoutesExist_RemovesGivenRoute() throws Exception{
-        Assert.assertNotNull(routingTable);
-        RpcRouter.RouteIdentifier routeId = getRouteIdentifier();
-        String route_1 = "10.0.0.1:5555";
-        String route_2 = "10.0.0.2:5555";
-
-        routingTable.addRoute(routeId, route_1);
-        routingTable.addRoute(routeId, route_2);
-
-        Assert.assertEquals(2, routingTable.getRoutes(routeId).size());
-
-        routingTable.removeRoute(routeId, route_1);
-        Assert.assertEquals(1, routingTable.getRoutes(routeId).size());
-
-    }
-
-    @Test
-    public void removeRoute_WhenOnlyOneRouteExists_RemovesRouteId() throws Exception{
-        Assert.assertNotNull(routingTable);
-        RpcRouter.RouteIdentifier routeId = getRouteIdentifier();
-        String route_1 = "10.0.0.1:5555";
-
-        routingTable.addRoute(routeId, route_1);
-        Assert.assertEquals(1, routingTable.getRoutes(routeId).size());
-
-        routingTable.removeRoute(routeId, route_1);
-        ConcurrentMap cache = routingTable.getRpcCache();
-        Assert.assertFalse(cache.containsKey(routeId));
-
-    }
-
-    /*
-     * Private helper methods
-     */
-    private void createRoutingTableCache() throws Exception {
-
-        //here init
-        Component c = mock(Component.class);
-
-        when(clusterService.existCache(
-                RoutingTableImpl.GLOBALRPC_CACHE)).thenReturn(false);
-
-        when(clusterService.createCache(RoutingTableImpl.GLOBALRPC_CACHE,
-                EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL))).
-                thenReturn(mockGlobalRpcCache);
-
-        when(clusterService.existCache(
-                RoutingTableImpl.RPC_CACHE)).thenReturn(false);
-
-        when(clusterService.createCache(RoutingTableImpl.RPC_CACHE,
-                EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL))).
-                thenReturn(mockRpcCache);
-
-        doNothing().when(clusterService).tbegin();
-        doNothing().when(clusterService).tcommit();
-
-        routingTable.setClusterGlobalServices(this.clusterService);
-        routingTable.init(c);
-
-        Assert.assertEquals(mockGlobalRpcCache, routingTable.getGlobalRpcCache());
-        Assert.assertEquals(mockRpcCache, routingTable.getRpcCache());
-    }
-
-    private RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> getRouteIdentifier(){
-        RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier> routeIdentifier = mock(RpcRouter.RouteIdentifier.class);
-        InstanceIdentifier identifier = mock(InstanceIdentifier.class);
-        when(routeIdentifier.getType()).thenReturn(QNAME);
-        when(routeIdentifier.getRoute()).thenReturn(identifier);
-
-        return routeIdentifier;
-    }
-
-    private Runnable addRoutes(final int numRoutes, final String routePrefix, final RpcRouter.RouteIdentifier routeId){
-        return new Runnable() {
-            @Override
-            public void run() {
-                for (int i=0;i<numRoutes;i++){
-                    String route = routePrefix + i;
-                    try {
-                        routingTable.addRoute(routeId, route);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                }
-            }
-        };
-    }
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/integrationtest/pom.xml b/opendaylight/md-sal/remoterpc-routingtable/integrationtest/pom.xml
deleted file mode 100644 (file)
index ce11be1..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.opendaylight.controller</groupId>
-    <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.1-SNAPSHOT</version>
-    <relativePath>../../../commons/integrationtest</relativePath>
-  </parent>
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
-    <tag>HEAD</tag>
-  </scm>
-
-  <artifactId>remoterpc-routingtable.integrationtest</artifactId>
-  <version>0.4.1-SNAPSHOT</version>
-
-  <dependencies>
-    <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>remoterpc-routingtable.implementation</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>clustering.services</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-    </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal.implementation</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>containermanager</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>containermanager.it.implementation</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>clustering.stub</artifactId>
-      </dependency>
-        <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-    <dependency>
-       <groupId>org.ops4j.pax.exam</groupId>
-       <artifactId>pax-exam-container-native</artifactId>
-       <scope>test</scope>
-     </dependency>
-     <dependency>
-        <groupId>org.ops4j.pax.exam</groupId>
-        <artifactId>pax-exam-link-mvn</artifactId>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.ops4j.pax.url</groupId>
-        <artifactId>pax-url-aether</artifactId>
-        <scope>test</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.slf4j</groupId>
-        <artifactId>log4j-over-slf4j</artifactId>
-      </dependency>
-      <dependency>
-        <groupId>ch.qos.logback</groupId>
-        <artifactId>logback-core</artifactId>
-      </dependency>
-      <dependency>
-        <groupId>ch.qos.logback</groupId>
-        <artifactId>logback-classic</artifactId>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>org.apache.felix.dependencymanager.shell</artifactId>
-      </dependency>
-      <dependency>
-        <groupId>eclipselink</groupId>
-        <artifactId>javax.resource</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>com.google.guava</groupId>
-          <artifactId>guava</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.yangtools</groupId>
-          <artifactId>yang-binding</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.yangtools</groupId>
-          <artifactId>yang-common</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-connector-api</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-common-util</artifactId>
-      </dependency>
-
-      <dependency>
-          <groupId>junit</groupId>
-          <artifactId>junit</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-common-api</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-binding-broker-impl</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.ops4j.pax.exam</groupId>
-          <artifactId>pax-exam-container-native</artifactId>
-          <version>${exam.version}</version>
-          <scope>test</scope>
-      </dependency>
-      <dependency>
-          <groupId>org.ops4j.pax.exam</groupId>
-          <artifactId>pax-exam-junit4</artifactId>
-          <version>${exam.version}</version>
-          <scope>test</scope>
-      </dependency>
-      <dependency>
-          <groupId>org.ops4j.pax.exam</groupId>
-          <artifactId>pax-exam-link-mvn</artifactId>
-          <version>${exam.version}</version>
-          <scope>test</scope>
-      </dependency>
-
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>config-manager</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>equinoxSDK381</groupId>
-          <artifactId>org.eclipse.osgi</artifactId>
-          <scope>test</scope>
-      </dependency>
-      <dependency>
-          <groupId>org.slf4j</groupId>
-          <artifactId>log4j-over-slf4j</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-core</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-classic</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-          <artifactId>antlr4-runtime-osgi-nohead</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-          <artifactId>xtend-lib-osgi</artifactId>
-      </dependency>
-
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>clustering.services</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>junit</groupId>
-          <artifactId>junit</artifactId>
-          <scope>test</scope>
-      </dependency>
-
-      <dependency>
-          <groupId>equinoxSDK381</groupId>
-          <artifactId>org.eclipse.osgi</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.ops4j.pax.exam</groupId>
-          <artifactId>pax-exam-junit4</artifactId>
-          <version>${exam.version}</version>
-      </dependency>
-      <dependency>
-          <groupId>org.ops4j.pax.exam</groupId>
-          <artifactId>pax-exam</artifactId>
-          <version>${exam.version}</version>
-      </dependency>
-  </dependencies>
-  <properties>
-    <!-- Sonar jacoco plugin to get integration test coverage info -->
-    <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
-  </properties>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.jacoco</groupId>
-        <artifactId>jacoco-maven-plugin</artifactId>
-        <configuration>
-          <destFile>../implementation/target/jacoco-it.exec</destFile>
-          <includes><include>org.opendaylight.controller.*</include></includes>
-        </configuration>
-        <executions>
-          <execution>
-            <id>pre-test</id>
-            <goals>
-              <goal>prepare-agent</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>post-test</id>
-            <configuration>
-              <skip>true</skip>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/opendaylight/md-sal/remoterpc-routingtable/integrationtest/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/impl/ZeroMQRoutingTableTestIT.java b/opendaylight/md-sal/remoterpc-routingtable/integrationtest/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/impl/ZeroMQRoutingTableTestIT.java
deleted file mode 100644 (file)
index 9249212..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc.impl;
-
-import junit.framework.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.util.PathUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.Set;
-
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemPackages;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-
-
-
-@RunWith(PaxExam.class)
-public class
-        ZeroMQRoutingTableTestIT {
-    private Logger log = LoggerFactory
-            .getLogger(ZeroMQRoutingTableTestIT.class);
-
-    public static final String ODL = "org.opendaylight.controller";
-    public static final String YANG = "org.opendaylight.yangtools";
-    public static final String CONTROLLER = "org.opendaylight.controller";
-    public static final String YANGTOOLS = "org.opendaylight.yangtools";
-    RoutingIdentifierImpl rii  = new RoutingIdentifierImpl();
-    // get the OSGI bundle context
-    @Inject
-    private BundleContext bc;
-    @Inject
-    private RoutingTable routingTable = null;
-
-    // Configure the OSGi container
-    @Configuration
-    public Option[] config() {
-        return options(
-                //
-                systemProperty("logback.configurationFile").value(
-                        "file:" + PathUtils.getBaseDir()
-                                + "/src/test/resources/logback.xml"),
-                // To start OSGi console for inspection remotely
-                systemProperty("osgi.console").value("2401"),
-                // Set the systemPackages (used by clustering)
-                systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
-                // List framework bundles
-
-                mavenBundle("equinoxSDK381",
-                        "org.eclipse.equinox.console").versionAsInProject(),
-                mavenBundle("equinoxSDK381",
-                        "org.eclipse.equinox.util").versionAsInProject(),
-                mavenBundle("equinoxSDK381",
-                        "org.eclipse.osgi.services").versionAsInProject(),
-                mavenBundle("equinoxSDK381",
-                        "org.eclipse.equinox.ds").versionAsInProject(),
-                mavenBundle("equinoxSDK381",
-                        "org.apache.felix.gogo.command").versionAsInProject(),
-                mavenBundle("equinoxSDK381",
-                        "org.apache.felix.gogo.runtime").versionAsInProject(),
-                mavenBundle("equinoxSDK381",
-                        "org.apache.felix.gogo.shell").versionAsInProject(),
-                // List logger bundles
-                mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
-                mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
-                mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
-                mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),
-                // List all the bundles on which the test case depends
-                mavenBundle(ODL,
-                        "clustering.services").versionAsInProject(),
-
-                mavenBundle(ODL, "sal").versionAsInProject(),
-                mavenBundle(ODL,
-                        "sal.implementation").versionAsInProject(),
-                mavenBundle(ODL, "containermanager").versionAsInProject(),
-                mavenBundle(ODL,
-                        "containermanager.it.implementation").versionAsInProject(),
-                mavenBundle("org.jboss.spec.javax.transaction",
-                        "jboss-transaction-api_1.1_spec").versionAsInProject(),
-                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
-                mavenBundle("org.apache.felix",
-                        "org.apache.felix.dependencymanager").versionAsInProject(),
-                mavenBundle("org.apache.felix",
-                        "org.apache.felix.dependencymanager.shell").versionAsInProject(),
-                mavenBundle("eclipselink", "javax.resource").versionAsInProject(),
-
-                mavenBundle("com.google.guava","guava").versionAsInProject(),
-                // List logger bundles
-                mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
-                mavenBundle("org.slf4j", "log4j-over-slf4j")
-                        .versionAsInProject(),
-                mavenBundle("ch.qos.logback", "logback-core")
-                        .versionAsInProject(),
-                mavenBundle("ch.qos.logback", "logback-classic")
-                        .versionAsInProject(),
-
-                mavenBundle(ODL, "clustering.services")
-                        .versionAsInProject(),
-                mavenBundle(ODL, "clustering.stub")
-                        .versionAsInProject(),
-
-
-                // List all the bundles on which the test case depends
-                mavenBundle(ODL, "sal")
-                        .versionAsInProject(),
-                mavenBundle(ODL, "sal-connector-api")
-                        .versionAsInProject(),
-                mavenBundle(ODL, "remoterpc-routingtable.implementation")
-                        .versionAsInProject(),
-
-                mavenBundle("org.jboss.spec.javax.transaction",
-                        "jboss-transaction-api_1.1_spec").versionAsInProject(),
-                mavenBundle("org.apache.commons", "commons-lang3")
-                        .versionAsInProject(),
-                mavenBundle("org.apache.felix",
-                        "org.apache.felix.dependencymanager")
-                        .versionAsInProject(),
-
-                mavenBundle(ODL,
-                        "sal-core-api")
-                        .versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools","yang-data-api")
-                        .versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools","yang-model-api")
-                        .versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools","yang-binding")
-                        .versionAsInProject(),
-
-                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(),
-                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), //
-                mavenBundle("org.javassist", "javassist").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), //
-
-                mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-model-util").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-parser-api").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "yang-parser-impl").versionAsInProject(),
-
-
-                mavenBundle(YANGTOOLS, "binding-generator-spi").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "binding-model-api").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "binding-generator-util").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "yang-parser-impl").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "binding-type-provider").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "binding-generator-api").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "binding-generator-spi").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "binding-generator-impl").versionAsInProject(),
-
-
-                mavenBundle(CONTROLLER, "sal-core-api").versionAsInProject().update(), //
-                mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), //
-
-                mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), //
-
-                mavenBundle(YANG+".thirdparty", "xtend-lib-osgi").versionAsInProject(),
-                mavenBundle("com.google.guava", "guava").versionAsInProject(), //
-                mavenBundle("org.javassist", "javassist").versionAsInProject(),
-                mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), //
-                mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), //
-                mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), //
-                mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), //
-
-                mavenBundle(ODL, "sal-common").versionAsInProject(), //
-                mavenBundle(ODL, "sal-common-api").versionAsInProject(),//
-                mavenBundle(ODL, "sal-common-impl").versionAsInProject(), //
-                mavenBundle(ODL, "sal-common-util").versionAsInProject(), //
-
-                mavenBundle(ODL, "config-api").versionAsInProject(), //
-                mavenBundle(ODL, "config-manager").versionAsInProject(), //
-                mavenBundle("commons-io", "commons-io").versionAsInProject(),
-                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
-
-                mavenBundle(ODL, "sal-binding-api").versionAsInProject(), //
-                mavenBundle(ODL, "sal-binding-config").versionAsInProject(),
-                mavenBundle("org.javassist", "javassist").versionAsInProject(), //
-                mavenBundle(ODL, "sal-common-util").versionAsInProject(), //
-
-                mavenBundle(YANG, "yang-data-api").versionAsInProject(), //
-                mavenBundle(YANG, "yang-data-impl").versionAsInProject(), //
-                mavenBundle(YANG, "yang-model-api").versionAsInProject(), //
-                mavenBundle(YANG, "yang-model-util").versionAsInProject(), //
-                mavenBundle(YANG, "yang-parser-api").versionAsInProject(),
-                mavenBundle(YANG, "yang-parser-impl").versionAsInProject(),
-
-
-                mavenBundle(YANG, "binding-generator-spi").versionAsInProject(), //
-                mavenBundle(YANG, "binding-model-api").versionAsInProject(), //
-                mavenBundle(YANG, "binding-generator-util").versionAsInProject(),
-                mavenBundle(YANG, "yang-parser-impl").versionAsInProject(),
-                mavenBundle(YANG, "binding-type-provider").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-api").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-spi").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-impl").versionAsInProject(),
-
-
-                mavenBundle(ODL, "sal-core-api").versionAsInProject().update(), //
-                mavenBundle(ODL, "sal-broker-impl").versionAsInProject(), //
-                mavenBundle(ODL, "sal-core-spi").versionAsInProject().update(), //
-
-                mavenBundle(YANG + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), //
-
-                mavenBundle(YANG, "concepts").versionAsInProject(),
-                mavenBundle(YANG, "yang-binding").versionAsInProject(), //
-                mavenBundle(YANG, "yang-common").versionAsInProject(), //
-                mavenBundle(YANG+".thirdparty", "xtend-lib-osgi").versionAsInProject(),
-                mavenBundle("com.google.guava", "guava").versionAsInProject(), //
-                mavenBundle("org.javassist", "javassist").versionAsInProject(),
-
-                junitBundles());
-    }
-
-    private String stateToString(int state) {
-        switch (state) {
-            case Bundle.ACTIVE:
-                return "ACTIVE";
-            case Bundle.INSTALLED:
-                return "INSTALLED";
-            case Bundle.RESOLVED:
-                return "RESOLVED";
-            case Bundle.UNINSTALLED:
-                return "UNINSTALLED";
-            default:
-                return "Not CONVERTED";
-        }
-    }
-
-    @Test
-  public  void testAddGlobalRoute () throws Exception{
-
-       routingTable.addGlobalRoute(rii,"172.27.12.1:5000");
-
-       Set<String> routes = routingTable.getRoutes(rii);
-
-       for(String route:routes){
-           Assert.assertEquals(route,"172.27.12.1:5000");
-       }
-
-
-    }
-
-
-    @Test
-    public  void testDeleteGlobalRoute () throws Exception{
-
-        routingTable.removeGlobalRoute(rii);
-
-        Set<String> routes = routingTable.getRoutes(rii);
-
-        Assert.assertNull(routes);
-
-
-    }
-
-
-
-   class RoutingIdentifierImpl implements RpcRouter.RouteIdentifier,Serializable {
-
-       private final URI namespace = URI.create("http://cisco.com/example");
-       private final QName QNAME = new QName(namespace,"global");
-       private final QName instance = new QName(URI.create("127.0.0.1"),"local");
-
-       @Override
-       public QName getContext() {
-           return QNAME;
-       }
-
-       @Override
-       public QName getType() {
-           return QNAME;
-       }
-
-       @Override
-       public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier getRoute() {
-           return InstanceIdentifier.of(instance);
-       }
-
-       @Override
-       public boolean equals(Object o) {
-           if (this == o) return true;
-           if (o == null || getClass() != o.getClass()) return false;
-
-           RoutingIdentifierImpl that = (RoutingIdentifierImpl) o;
-
-           if (QNAME != null ? !QNAME.equals(that.QNAME) : that.QNAME != null) return false;
-           if (instance != null ? !instance.equals(that.instance) : that.instance != null) return false;
-           if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) return false;
-
-           return true;
-       }
-
-       @Override
-       public int hashCode() {
-           int result = namespace != null ? namespace.hashCode() : 0;
-           result = 31 * result + (QNAME != null ? QNAME.hashCode() : 0);
-           result = 31 * result + (instance != null ? instance.hashCode() : 0);
-           return result;
-       }
-   }
-
-
-
-
-
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/pom.xml b/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/pom.xml
deleted file mode 100644 (file)
index d74e713..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-<?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>
-    <artifactId>sal-remoterpc-connector-test-parent</artifactId>
-    <groupId>org.opendaylight.controller.tests</groupId>
-    <version>1.1-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>remoterpc-routingtable-nb-it</artifactId>
-  <packaging>bundle</packaging>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Export-Package>
-             org.opendaylight.controller.tests.zmqroutingtable.rest
-            </Export-Package>
-            <Import-Package>
-              com.sun.jersey.spi.container.servlet,
-              com.fasterxml.jackson.annotation,
-              javax.ws.rs,
-              javax.ws.rs.core,
-              javax.xml.bind,
-              javax.xml.bind.annotation,
-              org.slf4j,
-              org.apache.catalina.filters,
-              org.codehaus.jackson.jaxrs,
-              org.opendaylight.controller.sal.utils,
-              org.opendaylight.yangtools.yang.common,
-              org.opendaylight.controller.sal.connector.api,
-              org.opendaylight.controller.sal.connector.remoterpc.api,
-              org.opendaylight.controller.sal.connector.remoterpc.impl,
-              org.osgi.framework,
-              com.google.common.base,
-              org.opendaylight.yangtools.yang.data.api,
-              !org.codehaus.enunciate.jaxrs
-
-            </Import-Package>
-            <Web-ContextPath>/controller/nb/v2/zmqnbrt</Web-ContextPath>
-            <Jaxrs-Resources>,${classes;ANNOTATION;javax.ws.rs.Path}</Jaxrs-Resources>
-          </instructions>
-          <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-  <dependencies>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>commons.northbound</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>remoterpc-routingtable.implementation</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>com.google.guava</groupId>
-          <artifactId>guava</artifactId>
-      </dependency>
-  </dependencies>
-
- </project>
diff --git a/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqroutingtable/rest/RouteIdentifierImpl.java b/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqroutingtable/rest/RouteIdentifierImpl.java
deleted file mode 100644 (file)
index eb5ecd7..0000000
+++ /dev/null
@@ -1,76 +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.tests.zmqroutingtable.rest;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-import java.io.Serializable;
-import java.net.URI;
-
-/**
- * @author: syedbahm
- * Date: 12/10/13
- */
-public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier, Serializable {
-
-    private final URI namespace;
-    private final QName QNAME;
-    private final QName instance;
-
-    public RouteIdentifierImpl() {
-        namespace = URI.create("http://cisco.com/example");
-        QNAME = new QName(namespace, "global");
-        instance = new QName(URI.create("127.0.0.1"), "local");
-    }
-
-    public RouteIdentifierImpl(String url,String instanceIP){
-        namespace = URI.create(url);
-        QNAME = new QName(namespace,"global");
-        instance =  new QName(URI.create(instanceIP), "local");
-    }
-
-
-    @Override
-    public QName getContext() {
-        return QNAME;
-    }
-
-    @Override
-    public QName getType() {
-        return QNAME;
-    }
-
-    @Override
-    public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier getRoute() {
-        return InstanceIdentifier.of(instance);
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        RouteIdentifierImpl that = (RouteIdentifierImpl) o;
-
-        if (!QNAME.equals(that.QNAME)) return false;
-        if (!instance.equals(that.instance)) return false;
-        if (!namespace.equals(that.namespace)) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = namespace.hashCode();
-        result = 31 * result + QNAME.hashCode();
-        result = 31 * result + instance.hashCode();
-        return result;
-    }
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqroutingtable/rest/Router.java b/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqroutingtable/rest/Router.java
deleted file mode 100644 (file)
index 9bf6e53..0000000
+++ /dev/null
@@ -1,164 +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.tests.zmqroutingtable.rest;
-
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-import org.opendaylight.controller.sal.connector.remoterpc.impl.RoutingTableImpl;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleReference;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import java.io.Serializable;
-import java.net.URI;
-
-@Path("router")
-public class Router implements Serializable {
-  private Logger _logger = LoggerFactory.getLogger(Router.class);
-  private final URI namespace = URI.create("http://cisco.com/example");
-  private final QName QNAME = new QName(namespace, "heartbeat");
-
-
-  @GET
-  @Path("/hello")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String hello() {
-    return "Hello";
-  }
-
-
-
-
-    @GET
-    @Path("/rtadd")
-    @Produces(MediaType.TEXT_PLAIN)
-    public String addToRoutingTable(@QueryParam("nsp") String namespace,@QueryParam("inst") String instance,@QueryParam("port") String port) {
-        _logger.info("Invoking adding an entry in routing table");
-
-        BundleContext ctx = getBundleContext();
-        ServiceReference routingTableServiceReference = ctx.getServiceReference(RoutingTable.class);
-        if (routingTableServiceReference == null) {
-            _logger.debug("Could not get routing table impl reference");
-            return "Could not get routingtable referen ";
-        }
-        RoutingTableImpl routingTable = (RoutingTableImpl) ctx.getService(routingTableServiceReference);
-        if (routingTable == null) {
-            _logger.info("Could not get routing table service");
-            return "Could not get routing table service";
-        }
-
-
-        RouteIdentifierImpl rii = new RouteIdentifierImpl(namespace,instance);
-        try {
-            routingTable.addGlobalRoute(rii, instance+":"+ port);
-        } catch (RoutingTableException e) {
-            _logger.error("error in adding routing identifier" + e.getMessage());
-
-        } catch (SystemException e) {
-            _logger.error("error in adding routing identifier" + e.getMessage());
-        }
-
-        StringBuilder stringBuilder = new StringBuilder();
-        stringBuilder.append("Result of adding route:").append("\n")
-                     .append(routingTable.dumpRoutingTableCache());
-        return stringBuilder.toString();
-    }
-
-  @GET
-  @Path("/rtdelete")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String invokeDeleteRoutingTable(@QueryParam("nsp") String namespace,@QueryParam("inst") String instance) {
-    _logger.info("Invoking delete an entry in routing table");
-
-    BundleContext ctx = getBundleContext();
-    ServiceReference routingTableServiceReference = ctx.getServiceReference(RoutingTable.class);
-    if (routingTableServiceReference == null) {
-      _logger.debug("Could not get routing table impl reference");
-      return "Could not get routingtable referen ";
-    }
-    RoutingTableImpl routingTable = (RoutingTableImpl) ctx.getService(routingTableServiceReference);
-    if (routingTable == null) {
-      _logger.info("Could not get routing table service");
-      return "Could not get routing table service";
-    }
-
-
-    RouteIdentifierImpl rii = new RouteIdentifierImpl(namespace,instance);
-    try {
-      routingTable.removeGlobalRoute(rii);
-    } catch (RoutingTableException e) {
-      _logger.error("error in adding routing identifier" + e.getMessage());
-
-    } catch (SystemException e) {
-      _logger.error("error in adding routing identifier" + e.getMessage());
-    }
-
-
-    StringBuilder stringBuilder = new StringBuilder();
-    stringBuilder.append("Result of deleting route:").append("\n")
-              .append(routingTable.dumpRoutingTableCache());
-
-    return stringBuilder.toString();
-  }
-
-    @GET
-    @Path("/routingtable")
-    @Produces(MediaType.TEXT_PLAIN)
-    public String invokeGetRoutingTable() {
-        _logger.info("Invoking getting of routing table");
-
-        BundleContext ctx = getBundleContext();
-        ServiceReference routingTableServiceReference = ctx.getServiceReference(RoutingTable.class);
-        if (routingTableServiceReference == null) {
-            _logger.debug("Could not get routing table impl reference");
-            return "Could not get routingtable referen ";
-        }
-        RoutingTableImpl routingTable = (RoutingTableImpl) ctx.getService(routingTableServiceReference);
-        if (routingTable == null) {
-            _logger.info("Could not get routing table service");
-            return "Could not get routing table service";
-        }
-
-
-        StringBuilder stringBuilder = new StringBuilder();
-        stringBuilder.append("Result of getting routetable:").append("\n")
-                .append(routingTable.dumpRoutingTableCache());
-
-        return stringBuilder.toString();
-    }
-
-
-
-  private BundleContext getBundleContext() {
-    ClassLoader tlcl = Thread.currentThread().getContextClassLoader();
-    Bundle bundle = null;
-
-    if (tlcl instanceof BundleReference) {
-      bundle = ((BundleReference) tlcl).getBundle();
-    } else {
-      _logger.info("Unable to determine the bundle context based on " +
-          "thread context classloader.");
-      bundle = FrameworkUtil.getBundle(this.getClass());
-    }
-    return (bundle == null ? null : bundle.getBundleContext());
-  }
-
-
-
-}
diff --git a/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/resources/WEB-INF/web.xml b/opendaylight/md-sal/remoterpc-routingtable/integrationtest/test-nb/src/main/resources/WEB-INF/web.xml
deleted file mode 100644 (file)
index 2a0f3f3..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
-        version="3.0">
-  <servlet>
-    <servlet-name>JAXRSZmqRT</servlet-name>
-    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
-    <init-param>
-      <param-name>javax.ws.rs.Application</param-name>
-      <param-value>org.opendaylight.controller.northbound.commons.NorthboundApplication</param-value>
-    </init-param>
-    <load-on-startup>1</load-on-startup>
-  </servlet>
-
-  <servlet-mapping>
-    <servlet-name>JAXRSZmqRT</servlet-name>
-    <url-pattern>/*</url-pattern>
-  </servlet-mapping>
-
-
-
-        <security-constraint>
-          <web-resource-collection>
-            <web-resource-name>NB api</web-resource-name>
-            <url-pattern>/*</url-pattern>
-            <http-method>POST</http-method>
-            <http-method>GET</http-method>
-            <http-method>PUT</http-method>
-            <http-method>PATCH</http-method>
-            <http-method>DELETE</http-method>
-            <http-method>HEAD</http-method>
-          </web-resource-collection>
-          <auth-constraint>
-            <role-name>System-Admin</role-name>
-            <role-name>Network-Admin</role-name>
-            <role-name>Network-Operator</role-name>
-            <role-name>Container-User</role-name>
-          </auth-constraint>
-        </security-constraint>
-
-        <security-role>
-                <role-name>System-Admin</role-name>
-        </security-role>
-        <security-role>
-                <role-name>Network-Admin</role-name>
-        </security-role>
-        <security-role>
-                <role-name>Network-Operator</role-name>
-        </security-role>
-        <security-role>
-                <role-name>Container-User</role-name>
-        </security-role>
-
-        <login-config>
-                <auth-method>BASIC</auth-method>
-                <realm-name>opendaylight</realm-name>
-        </login-config>
-</web-app>
diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java
deleted file mode 100644 (file)
index 7eee5c8..0000000
+++ /dev/null
@@ -1,29 +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.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-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;
-
-public interface BindingDataBroker extends AsyncDataBroker<InstanceIdentifier<?>, DataObject, BindingDataChangeListener>, BindingService {
-    @Override
-    BindingDataReadTransaction newReadOnlyTransaction();
-
-    @Override
-    BindingDataReadWriteTransaction newReadWriteTransaction();
-
-    @Override
-    BindingDataWriteTransaction newWriteOnlyTransaction();
-
-    @Override
-    ListenerRegistration<BindingDataChangeListener> registerDataChangeListener(LogicalDatastoreType store,
-            InstanceIdentifier<?> path, BindingDataChangeListener listener, DataChangeScope triggeringScope);
-}
diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingTransactionChain.java
new file mode 100644 (file)
index 0000000..eac65ad
--- /dev/null
@@ -0,0 +1,18 @@
+package org.opendaylight.controller.md.sal.binding.api;
+
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public interface BindingTransactionChain extends TransactionChain<InstanceIdentifier<?>, DataObject> {
+
+    @Override
+    ReadOnlyTransaction newReadOnlyTransaction();
+
+    @Override
+    ReadWriteTransaction newReadWriteTransaction();
+
+    @Override
+    WriteTransaction newWriteOnlyTransaction();
+
+}
diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java
new file mode 100644 (file)
index 0000000..b60d8ff
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.binding.api;
+
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Provides access to a conceptual data tree store and also provides the ability to
+ * subscribe for changes to data under a given branch of the tree.
+ * <p>
+ * For more information on usage, please see the documentation in {@link AsyncDataBroker}.
+ */
+public interface DataBroker extends AsyncDataBroker<InstanceIdentifier<?>, DataObject, DataChangeListener>, BindingService, TransactionChainFactory<InstanceIdentifier<?>, DataObject> {
+    @Override
+    ReadOnlyTransaction newReadOnlyTransaction();
+
+    @Override
+    ReadWriteTransaction newReadWriteTransaction();
+
+    @Override
+    WriteTransaction newWriteOnlyTransaction();
+
+    @Override
+    ListenerRegistration<DataChangeListener> registerDataChangeListener(LogicalDatastoreType store,
+            InstanceIdentifier<?> path, DataChangeListener listener, DataChangeScope triggeringScope);
+}
@@ -12,7 +12,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListene
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public interface BindingDataChangeListener extends AsyncDataChangeListener<InstanceIdentifier<?>, DataObject> {
+public interface DataChangeListener extends AsyncDataChangeListener<InstanceIdentifier<?>, DataObject> {
     @Override
     void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change);
 }
diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java
new file mode 100644 (file)
index 0000000..f3b42b9
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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.binding.api;
+
+import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * A transaction that provides a stateful read-only view of the data tree.
+ * <p>
+ * For more information on usage and examples, please see the documentation in
+ *  {@link org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction}.
+ */
+public interface ReadOnlyTransaction extends ReadTransaction, AsyncReadOnlyTransaction<InstanceIdentifier<?>, DataObject> {
+
+}
@@ -15,7 +15,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 
-public interface BindingDataReadTransaction extends AsyncReadTransaction<InstanceIdentifier<?>, DataObject> {
+public interface ReadTransaction extends AsyncReadTransaction<InstanceIdentifier<?>, DataObject> {
     @Override
     ListenableFuture<Optional<DataObject>> read(LogicalDatastoreType store, InstanceIdentifier<?> path);
 }
@@ -12,9 +12,10 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
- * Logical capture of a combination of both {@link BindingDataReadTransaction} and
- * {@link BindingDataWriteTransaction}.
+ * A transaction that enables combined read/write capabilities.
+ * <p>
+ * For more information on usage and examples, please see the documentation in {@link AsyncReadWriteTransaction}.
  */
-public interface BindingDataReadWriteTransaction extends BindingDataReadTransaction, BindingDataWriteTransaction, AsyncReadWriteTransaction<InstanceIdentifier<?>, DataObject> {
+public interface ReadWriteTransaction extends ReadTransaction, WriteTransaction, AsyncReadWriteTransaction<InstanceIdentifier<?>, DataObject> {
 
 }
@@ -12,7 +12,12 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public interface BindingDataWriteTransaction extends AsyncWriteTransaction<InstanceIdentifier<?>, DataObject> {
+/**
+ * A transaction that provides mutation capabilities on a data tree.
+ * <p>
+ * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
+ */
+public interface WriteTransaction extends AsyncWriteTransaction<InstanceIdentifier<?>, DataObject> {
     @Override
     void put(LogicalDatastoreType store, InstanceIdentifier<?> path, DataObject data);
 
index b09cd1c80a142e629493180a47640fb0a5d894a4..b109f89ff61adfb016b9eaa5e86818b0ec6b6965 100644 (file)
@@ -7,14 +7,16 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.opendaylight.controller.md.sal.binding.api.BindingDataChangeListener;
+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;
@@ -40,6 +42,7 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
 
 public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBroker>, DomForwardedBroker,
         SchemaContextListener, AutoCloseable {
@@ -83,8 +86,8 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
         codec.onGlobalContextUpdated(ctx);
     }
 
-    public ListenerRegistration<BindingDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
-            final InstanceIdentifier<?> path, final BindingDataChangeListener listener,
+    public ListenerRegistration<DataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
+            final InstanceIdentifier<?> path, final DataChangeListener listener,
             final DataChangeScope triggeringScope) {
         DOMDataChangeListener domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener,
                 triggeringScope);
@@ -97,8 +100,8 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
     protected Map<InstanceIdentifier<?>, DataObject> toBinding(
             final Map<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized) {
         Map<InstanceIdentifier<?>, DataObject> newMap = new HashMap<>();
-        for (Map.Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized
-                .entrySet()) {
+
+        for (Map.Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : sortedEntries(normalized)) {
             try {
                 Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential = getCodec().toBinding(
                         entry);
@@ -113,6 +116,21 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
         return newMap;
     }
 
+    private static <T> Iterable<Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier,T>> sortedEntries(final Map<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, T> map) {
+        ArrayList<Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, T>> entries = new ArrayList<>(map.entrySet());
+        Collections.sort(entries, new Comparator<Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, T>>() {
+
+            @Override
+            public int compare(final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, T> left,
+                    final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, T> right) {
+                int leftSize = Iterables.size(left.getKey().getPathArguments());
+                int rightSize = Iterables.size(right.getKey().getPathArguments());
+                return Integer.compare(leftSize, rightSize);
+            }
+        });
+        return entries;
+    }
+
     protected Set<InstanceIdentifier<?>> toBinding(
             final Set<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier> normalized) {
         Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
@@ -143,13 +161,13 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
     }
 
     private class TranslatingDataChangeInvoker implements DOMDataChangeListener {
-        private final BindingDataChangeListener bindingDataChangeListener;
+        private final DataChangeListener bindingDataChangeListener;
         private final LogicalDatastoreType store;
         private final InstanceIdentifier<?> path;
         private final DataChangeScope triggeringScope;
 
         public TranslatingDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
-                final BindingDataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) {
+                final DataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) {
             this.store = store;
             this.path = path;
             this.bindingDataChangeListener = bindingDataChangeListener;
@@ -250,10 +268,10 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
         }
     }
 
-    private static class ListenerRegistrationImpl extends AbstractListenerRegistration<BindingDataChangeListener> {
+    private static class ListenerRegistrationImpl extends AbstractListenerRegistration<DataChangeListener> {
         private final ListenerRegistration<DOMDataChangeListener> registration;
 
-        public ListenerRegistrationImpl(final BindingDataChangeListener listener,
+        public ListenerRegistrationImpl(final DataChangeListener listener,
                 final ListenerRegistration<DOMDataChangeListener> registration) {
             super(listener);
             this.registration = registration;
index a935a33a5eb26ee13371554165db996f390469b8..e5e1e300c17437e52962218f168da911b3f54526 100644 (file)
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.Nullable;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
+import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 
-public class AbstractForwardedTransaction<T extends AsyncTransaction<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>>>
-        implements Delegator<T> {
 
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractForwardedTransaction.class);
+abstract class AbstractForwardedTransaction<T extends AsyncTransaction<InstanceIdentifier, NormalizedNode<?, ?>>>
+        implements Delegator<T>, Identifiable<Object> {
+
     private final T delegate;
-    private final static CacheBuilder<Object, Object> CACHE_BUILDER = CacheBuilder.newBuilder()
-            .expireAfterWrite(10, TimeUnit.MILLISECONDS).maximumSize(100);
     private final BindingToNormalizedNodeCodec codec;
-    private final EnumMap<LogicalDatastoreType, Cache<InstanceIdentifier<?>, DataObject>> cacheMap;
 
-    protected AbstractForwardedTransaction(final T delegate, final BindingToNormalizedNodeCodec codec) {
-        super();
-        this.delegate = delegate;
-        this.codec = codec;
+    public AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
+        this.delegate = Preconditions.checkNotNull(delegateTx, "Delegate must not be null");
+        this.codec = Preconditions.checkNotNull(codec, "Codec must not be null");
+    }
 
-        this.cacheMap = new EnumMap<>(LogicalDatastoreType.class);
-        cacheMap.put(LogicalDatastoreType.OPERATIONAL, CACHE_BUILDER.<InstanceIdentifier<?>, DataObject> build());
-        cacheMap.put(LogicalDatastoreType.CONFIGURATION, CACHE_BUILDER.<InstanceIdentifier<?>, DataObject> build());
 
+    @Override
+    public final  Object getIdentifier() {
+        return delegate.getIdentifier();
     }
 
     @Override
-    public T getDelegate() {
+    public final  T getDelegate() {
         return delegate;
     }
 
-    protected final BindingToNormalizedNodeCodec getCodec() {
-        return codec;
-    }
-
-    protected ListenableFuture<Optional<DataObject>> transformFuture(final LogicalDatastoreType store,
-            final InstanceIdentifier<?> path, final ListenableFuture<Optional<NormalizedNode<?, ?>>> future) {
-        return Futures.transform(future, new Function<Optional<NormalizedNode<?, ?>>, Optional<DataObject>>() {
-            @Nullable
-            @Override
-            public Optional<DataObject> apply(@Nullable final Optional<NormalizedNode<?, ?>> normalizedNode) {
-                if (normalizedNode.isPresent()) {
-                    final DataObject dataObject;
-                    try {
-                        dataObject = codec.toBinding(path, normalizedNode.get());
-                    } catch (DeserializationException e) {
-                        LOG.warn("Failed to create dataobject from node {}", normalizedNode.get(), e);
-                        throw new IllegalStateException("Failed to create dataobject", e);
-                    }
-
-                    if (dataObject != null) {
-                        updateCache(store, path, dataObject);
-                        return Optional.of(dataObject);
-                    }
-                }
-                return Optional.absent();
-            }
-        });
-    }
-
-    protected void doPut(final DOMDataWriteTransaction writeTransaction, final LogicalDatastoreType store,
-            final InstanceIdentifier<?> path, final DataObject data) {
-        invalidateCache(store, path);
-        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = codec
-                .toNormalizedNode(path, data);
-        writeTransaction.put(store, normalized.getKey(), normalized.getValue());
-    }
-
-    protected void doPutWithEnsureParents(final DOMDataReadWriteTransaction writeTransaction,
-            final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
-        invalidateCache(store, path);
-        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = codec
-                .toNormalizedNode(path, data);
-
-        final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey();
-        ensureParentsByMerge(writeTransaction, store, normalizedPath, path);
-        LOG.debug("Tx: {} : Putting data {}", getDelegate().getIdentifier(), normalizedPath);
-        writeTransaction.put(store, normalizedPath, normalized.getValue());
-    }
-
-    protected void doMergeWithEnsureParents(final DOMDataReadWriteTransaction writeTransaction,
-            final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
-        invalidateCache(store, path);
-        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = codec
-                .toNormalizedNode(path, data);
-
-        final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey();
-        ensureParentsByMerge(writeTransaction, store, normalizedPath, path);
-        LOG.debug("Tx: {} : Merge data {}",getDelegate().getIdentifier(),normalizedPath);
-        writeTransaction.merge(store, normalizedPath, normalized.getValue());
+    @SuppressWarnings("unchecked")
+    protected final <S extends AsyncTransaction<InstanceIdentifier, NormalizedNode<?, ?>>> S getDelegateChecked(final Class<S> txType) {
+        Preconditions.checkState(txType.isInstance(delegate));
+        return (S) delegate;
     }
 
-    private void ensureParentsByMerge(final DOMDataReadWriteTransaction writeTransaction,
-            final LogicalDatastoreType store,
-            final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath,
-            final InstanceIdentifier<?> path) {
-        List<PathArgument> currentArguments = new ArrayList<>();
-        DataNormalizationOperation<?> currentOp = codec.getDataNormalizer().getRootOperation();
-        Iterator<PathArgument> iterator = normalizedPath.getPath().iterator();
-        while (iterator.hasNext()) {
-            PathArgument currentArg = iterator.next();
-            try {
-                currentOp = currentOp.getChild(currentArg);
-            } catch (DataNormalizationException e) {
-                throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
-            }
-            currentArguments.add(currentArg);
-            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier currentPath = new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(
-                    currentArguments);
-
-            final Optional<NormalizedNode<?, ?>> d;
-            try {
-                d = writeTransaction.read(store, currentPath).get();
-            } catch (InterruptedException | ExecutionException e) {
-                LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
-                throw new IllegalStateException("Failed to read pre-existing data", e);
-            }
-
-            if (!d.isPresent() && iterator.hasNext()) {
-                writeTransaction.merge(store, currentPath, currentOp.createDefault(currentArg));
-            }
-        }
-    }
-
-    protected void doMerge(final DOMDataWriteTransaction writeTransaction, final LogicalDatastoreType store,
-            final InstanceIdentifier<?> path, final DataObject data) {
-        invalidateCache(store, path);
-        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = codec
-                .toNormalizedNode(path, data);
-        writeTransaction.merge(store, normalized.getKey(), normalized.getValue());
-    }
-
-    protected void doDelete(final DOMDataWriteTransaction writeTransaction, final LogicalDatastoreType store,
-            final InstanceIdentifier<?> path) {
-        invalidateCache(store, path);
-        final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = codec.toNormalized(path);
-        writeTransaction.delete(store, normalized);
-    }
-
-    protected ListenableFuture<RpcResult<TransactionStatus>> doCommit(final DOMDataWriteTransaction writeTransaction) {
-        return writeTransaction.commit();
-    }
-
-    protected void doCancel(final DOMDataWriteTransaction writeTransaction) {
-        writeTransaction.cancel();
-    }
-
-    protected ListenableFuture<Optional<DataObject>> doRead(final DOMDataReadTransaction readTransaction,
-            final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
-        final DataObject dataObject = getFromCache(store, path);
-        if (dataObject == null) {
-            final ListenableFuture<Optional<NormalizedNode<?, ?>>> future = readTransaction.read(store,
-                    codec.toNormalized(path));
-            return transformFuture(store, path, future);
-        } else {
-            return Futures.immediateFuture(Optional.of(dataObject));
-        }
-    }
-
-    private DataObject getFromCache(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
-        Cache<InstanceIdentifier<?>, DataObject> cache = cacheMap.get(store);
-        if (cache != null) {
-            return cache.getIfPresent(path);
-        }
-        return null;
-    }
-
-    private void updateCache(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
-            final DataObject dataObject) {
-        // Check if cache exists. If not create one.
-        Cache<InstanceIdentifier<?>, DataObject> cache = cacheMap.get(store);
-        if (cache == null) {
-            cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(1, TimeUnit.MINUTES).build();
-
-        }
-
-        cache.put(path, dataObject);
+    protected final BindingToNormalizedNodeCodec getCodec() {
+        return codec;
     }
 
-    private void invalidateCache(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
-        // FIXME: Optimization: invalidate only parents and children of path
-        Cache<InstanceIdentifier<?>, DataObject> cache = cacheMap.get(store);
-        cache.invalidateAll();
-        LOG.trace("Cache invalidated");
+    protected final ListenableFuture<Optional<DataObject>> doRead(final DOMDataReadTransaction readTx,
+            final LogicalDatastoreType store, final org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> path) {
+        return Futures.transform(readTx.read(store, codec.toNormalized(path)), codec.deserializeFunction(path));
     }
-
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractReadWriteTransaction.java
new file mode 100644 (file)
index 0000000..3988bc6
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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.binding.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
+import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+
+public class AbstractReadWriteTransaction extends AbstractWriteTransaction<DOMDataReadWriteTransaction> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractReadWriteTransaction.class);
+
+    public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate, final BindingToNormalizedNodeCodec codec) {
+        super(delegate, codec);
+    }
+
+    protected final void doPutWithEnsureParents(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
+        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
+                .toNormalizedNode(path, data);
+
+        final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey();
+        ensureParentsByMerge(store, normalizedPath, path);
+        LOG.debug("Tx: {} : Putting data {}", getDelegate().getIdentifier(), normalizedPath);
+        doPut(store, path, data);
+    }
+
+    protected final void doMergeWithEnsureParents(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
+        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
+                .toNormalizedNode(path, data);
+
+        final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey();
+        ensureParentsByMerge(store, normalizedPath, path);
+        LOG.debug("Tx: {} : Merge data {}", getDelegate().getIdentifier(), normalizedPath);
+        doMerge(store, path, data);
+    }
+
+    private final void ensureParentsByMerge(final LogicalDatastoreType store,
+            final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath,
+            final InstanceIdentifier<?> path) {
+        List<PathArgument> currentArguments = new ArrayList<>();
+        DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
+        Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator();
+        while (iterator.hasNext()) {
+            PathArgument currentArg = iterator.next();
+            try {
+                currentOp = currentOp.getChild(currentArg);
+            } catch (DataNormalizationException e) {
+                throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
+            }
+            currentArguments.add(currentArg);
+            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(
+                    currentArguments);
+
+            final Optional<NormalizedNode<?, ?>> d;
+            try {
+                d = getDelegate().read(store, currentPath).get();
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
+                throw new IllegalStateException("Failed to read pre-existing data", e);
+            }
+
+            if (!d.isPresent() && iterator.hasNext()) {
+                getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
+            }
+        }
+    }
+
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractWriteTransaction.java
new file mode 100644 (file)
index 0000000..5ce6687
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.binding.impl;
+
+import java.util.Map.Entry;
+
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ *
+ * Abstract Base Transaction for transactions which are backed by
+ * {@link DOMDataWriteTransaction}
+ */
+public class AbstractWriteTransaction<T extends DOMDataWriteTransaction> extends
+        AbstractForwardedTransaction<T> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractWriteTransaction.class);
+
+    protected AbstractWriteTransaction(final T delegate,
+            final BindingToNormalizedNodeCodec codec) {
+        super(delegate, codec);
+    }
+
+    protected final void doPut(final LogicalDatastoreType store,
+            final InstanceIdentifier<?> path, final DataObject data) {
+        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
+                .toNormalizedNode(path, data);
+        getDelegate().put(store, normalized.getKey(), normalized.getValue());
+    }
+
+    protected final void doMerge(final LogicalDatastoreType store,
+            final InstanceIdentifier<?> path, final DataObject data) {
+        final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
+                .toNormalizedNode(path, data);
+        getDelegate().merge(store, normalized.getKey(), normalized.getValue());
+    }
+
+    protected final void doDelete(final LogicalDatastoreType store,
+            final InstanceIdentifier<?> path) {
+        final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = getCodec().toNormalized(path);
+        getDelegate().delete(store, normalized);
+    }
+
+    protected final ListenableFuture<RpcResult<TransactionStatus>> doCommit() {
+        return getDelegate().commit();
+    }
+
+    protected final boolean doCancel() {
+        return getDelegate().cancel();
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataReadTransactionImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataReadTransactionImpl.java
new file mode 100644 (file)
index 0000000..e71404d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.binding.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+class BindingDataReadTransactionImpl extends AbstractForwardedTransaction<DOMDataReadOnlyTransaction> implements
+        ReadOnlyTransaction {
+
+    protected BindingDataReadTransactionImpl(final DOMDataReadOnlyTransaction delegate,
+            final BindingToNormalizedNodeCodec codec) {
+        super(delegate, codec);
+    }
+
+    @Override
+    public ListenableFuture<Optional<DataObject>> read(final LogicalDatastoreType store,
+            final InstanceIdentifier<?> path) {
+        return doRead(getDelegate(),store, path);
+    }
+
+    @Override
+    public void close() {
+        getDelegate().close();
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataReadWriteTransactionImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataReadWriteTransactionImpl.java
new file mode 100644 (file)
index 0000000..5a89cc7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.binding.impl;
+
+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.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+class BindingDataReadWriteTransactionImpl extends
+        BindingDataWriteTransactionImpl<DOMDataReadWriteTransaction> implements ReadWriteTransaction {
+
+    protected BindingDataReadWriteTransactionImpl(final DOMDataReadWriteTransaction delegate,
+            final BindingToNormalizedNodeCodec codec) {
+        super(delegate, codec);
+    }
+
+    @Override
+    public ListenableFuture<Optional<DataObject>> read(final LogicalDatastoreType store,
+            final InstanceIdentifier<?> path) {
+        return doRead(getDelegate(), store, path);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataWriteTransactionImpl.java
new file mode 100644 (file)
index 0000000..a62319b
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.binding.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+class BindingDataWriteTransactionImpl<T extends DOMDataWriteTransaction> extends
+        AbstractWriteTransaction<T> implements WriteTransaction {
+
+    protected BindingDataWriteTransactionImpl(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
+        super(delegateTx, codec);
+    }
+
+
+
+    @Override
+    public void put(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
+        doPut(store, path, data);
+    }
+
+    @Override
+    public void merge(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
+        doMerge(store, path, data);
+    }
+
+    @Override
+    public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
+        doDelete( store, path);
+    }
+
+    @Override
+    public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+        return doCommit();
+    }
+
+    @Override
+    public boolean cancel() {
+        return doCancel();
+    }
+}
\ No newline at end of file
index f1be5c6922ecda45cc75f343b3f6355e402e013d..003f57cd72f053557a79fa761896894836ced89e 100644 (file)
@@ -14,6 +14,8 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map.Entry;
 
+import javax.annotation.Nullable;
+
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
@@ -42,7 +44,9 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Function;
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
@@ -75,7 +79,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
 
     public Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
             final InstanceIdentifier<? extends DataObject> bindingPath, final DataObject bindingObject) {
-        return toNormalizedNode(toEntry(bindingPath, bindingObject));
+        return toNormalizedNode(toBindingEntry(bindingPath, bindingObject));
 
     }
 
@@ -87,17 +91,16 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
                 .toNormalized(legacyEntry);
         LOG.trace("Serialization of {}, Legacy Representation: {}, Normalized Representation: {}", binding,
                 legacyEntry, normalizedEntry);
-        if (Augmentation.class.isAssignableFrom(binding.getKey().getTargetType())) {
+        if (isAugmentation(binding.getKey().getTargetType())) {
 
             for (DataContainerChild<? extends PathArgument, ?> child : ((DataContainerNode<?>) normalizedEntry
                     .getValue()).getValue()) {
                 if (child instanceof AugmentationNode) {
                     ImmutableList<PathArgument> childArgs = ImmutableList.<PathArgument> builder()
-                            .addAll(normalizedEntry.getKey().getPath()).add(child.getIdentifier()).build();
-                    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier childPath = new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(
+                            .addAll(normalizedEntry.getKey().getPathArguments()).add(child.getIdentifier()).build();
+                    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier childPath = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(
                             childArgs);
-                    return new SimpleEntry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>>(
-                            childPath, child);
+                    return toDOMEntry(childPath, child);
                 }
             }
 
@@ -119,7 +122,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
             final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized)
             throws DeserializationException {
 
-        PathArgument lastArgument = Iterables.getLast(normalized.getPath());
+        PathArgument lastArgument = Iterables.getLast(normalized.getPathArguments());
         // Used instance-identifier codec do not support serialization of last
         // path
         // argument if it is AugmentationIdentifier (behaviour expected by old
@@ -143,7 +146,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
         }
 
         int normalizedCount = getAugmentationCount(normalized);
-        AugmentationIdentifier lastArgument = (AugmentationIdentifier) Iterables.getLast(normalized.getPath());
+        AugmentationIdentifier lastArgument = (AugmentationIdentifier) Iterables.getLast(normalized.getPathArguments());
 
         // Here we employ small trick - Binding-aware Codec injects an pointer
         // to augmentation class
@@ -152,7 +155,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
         LOG.trace("Looking for candidates to match {}", normalized);
         for (QName child : lastArgument.getPossibleChildNames()) {
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier childPath = new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(
-                    ImmutableList.<PathArgument> builder().addAll(normalized.getPath()).add(new NodeIdentifier(child))
+                    ImmutableList.<PathArgument> builder().addAll(normalized.getPathArguments()).add(new NodeIdentifier(child))
                             .build());
             try {
                 if (isNotRepresentable(childPath)) {
@@ -218,19 +221,26 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
             final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized)
             throws DataNormalizationException {
         DataNormalizationOperation<?> current = legacyToNormalized.getRootOperation();
-        for (PathArgument arg : normalized.getPath()) {
+        for (PathArgument arg : normalized.getPathArguments()) {
             current = current.getChild(arg);
         }
         return current;
     }
 
-    private static final Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> toEntry(
+    private static final Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> toBindingEntry(
             final org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> key,
             final DataObject value) {
         return new SimpleEntry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject>(
                 key, value);
     }
 
+    private static final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> toDOMEntry(
+            final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier key,
+            final NormalizedNode<?, ?> value) {
+        return new SimpleEntry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>>(
+                key, value);
+    }
+
     public DataObject toBinding(final InstanceIdentifier<?> path, final NormalizedNode<?, ?> normalizedNode)
             throws DeserializationException {
         CompositeNode legacy = null;
@@ -262,7 +272,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
             if (bindingData == null) {
                 LOG.warn("Failed to deserialize {} to Binding format. Binding path is: {}", normalized, bindingPath);
             }
-            return Optional.of(toEntry(bindingPath, bindingData));
+            return Optional.of(toBindingEntry(bindingPath, bindingData));
         } else {
             return Optional.absent();
         }
@@ -304,15 +314,15 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
             final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) {
         int position = 0;
         int foundPosition = -1;
-        for (PathArgument arg : normalized.getPath()) {
+        for (PathArgument arg : normalized.getPathArguments()) {
             position++;
             if (arg instanceof AugmentationIdentifier) {
                 foundPosition = position;
             }
         }
         if (foundPosition > 0) {
-            return new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(normalized.getPath().subList(0,
-                    foundPosition));
+            Iterable<PathArgument> shortened = Iterables.limit(normalized.getPathArguments(), foundPosition);
+            return org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(shortened);
         }
         return null;
     }
@@ -404,7 +414,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
     }
 
     private boolean isAugmentationIdentifier(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier processed) {
-        return Iterables.getLast(processed.getPath()) instanceof AugmentationIdentifier;
+        return Iterables.getLast(processed.getPathArguments()) instanceof AugmentationIdentifier;
     }
 
     private static int getAugmentationCount(final InstanceIdentifier<?> potential) {
@@ -420,11 +430,46 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener {
 
     private static int getAugmentationCount(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier potential) {
         int count = 0;
-        for(PathArgument arg : potential.getPath()) {
+        for(PathArgument arg : potential.getPathArguments()) {
             if(arg instanceof AugmentationIdentifier) {
                 count++;
             }
         }
         return count;
     }
+
+    public Function<Optional<NormalizedNode<?, ?>>, Optional<DataObject>>  deserializeFunction(final InstanceIdentifier<?> path) {
+        return new DeserializeFunction(this, path);
+    }
+
+    private static class DeserializeFunction implements Function<Optional<NormalizedNode<?, ?>>, Optional<DataObject>> {
+
+        private final BindingToNormalizedNodeCodec codec;
+        private final InstanceIdentifier<?> path;
+
+        public DeserializeFunction(final BindingToNormalizedNodeCodec codec, final InstanceIdentifier<?> path) {
+            super();
+            this.codec = Preconditions.checkNotNull(codec, "Codec must not be null");
+            this.path = Preconditions.checkNotNull(path, "Path must not be null");
+        }
+
+        @Nullable
+        @Override
+        public Optional<DataObject> apply(@Nullable final Optional<NormalizedNode<?, ?>> normalizedNode) {
+            if (normalizedNode.isPresent()) {
+                final DataObject dataObject;
+                try {
+                    dataObject = codec.toBinding(path, normalizedNode.get());
+                } catch (DeserializationException e) {
+                    LOG.warn("Failed to create dataobject from node {}", normalizedNode.get(), e);
+                    throw new IllegalStateException("Failed to create dataobject", e);
+                }
+
+                if (dataObject != null) {
+                    return Optional.of(dataObject);
+                }
+            }
+            return Optional.absent();
+        }
+    }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingTranslatedTransactionChain.java
new file mode 100644 (file)
index 0000000..2d8e51c
--- /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.sal.binding.impl;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.annotation.concurrent.GuardedBy;
+
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+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.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.yangtools.concepts.Delegator;
+
+import com.google.common.base.Preconditions;
+
+class BindingTranslatedTransactionChain implements BindingTransactionChain, Delegator<DOMTransactionChain> {
+
+    private final DOMTransactionChain delegate;
+
+    @GuardedBy("this")
+    private final Map<AsyncTransaction<?, ?>, AsyncTransaction<?, ?>> delegateTxToBindingTx = new WeakHashMap<>();
+    private final BindingToNormalizedNodeCodec codec;
+
+    public BindingTranslatedTransactionChain(final DOMDataBroker chainFactory,
+            final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
+        Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null");
+        this.delegate = chainFactory.createTransactionChain(new ListenerInvoker(listener));
+        this.codec = codec;
+    }
+
+    @Override
+    public DOMTransactionChain getDelegate() {
+        return delegate;
+    }
+
+    @Override
+    public ReadOnlyTransaction newReadOnlyTransaction() {
+        DOMDataReadOnlyTransaction delegateTx = delegate.newReadOnlyTransaction();
+        ReadOnlyTransaction bindingTx = new BindingDataReadTransactionImpl(delegateTx, codec);
+        putDelegateToBinding(delegateTx, bindingTx);
+        return bindingTx;
+    }
+
+    @Override
+    public ReadWriteTransaction newReadWriteTransaction() {
+        DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction();
+        ReadWriteTransaction bindingTx = new BindingDataReadWriteTransactionImpl(delegateTx, codec);
+        putDelegateToBinding(delegateTx, bindingTx);
+        return bindingTx;
+    }
+
+    @Override
+    public WriteTransaction newWriteOnlyTransaction() {
+        DOMDataWriteTransaction delegateTx = delegate.newWriteOnlyTransaction();
+        WriteTransaction bindingTx = new BindingDataWriteTransactionImpl<>(delegateTx, codec);
+        putDelegateToBinding(delegateTx, bindingTx);
+        return bindingTx;
+    }
+
+    @Override
+    public void close() {
+        delegate.close();
+    }
+
+    private synchronized void putDelegateToBinding(final AsyncTransaction<?, ?> domTx,
+            final AsyncTransaction<?, ?> bindingTx) {
+        final Object previous = delegateTxToBindingTx.put(domTx, bindingTx);
+        Preconditions.checkState(previous == null, "DOM Transaction %s has already associated binding transation %s",domTx,previous);
+    }
+
+    private synchronized AsyncTransaction<?, ?> getBindingTransaction(final AsyncTransaction<?, ?> transaction) {
+        return delegateTxToBindingTx.get(transaction);
+    }
+
+    private final class ListenerInvoker implements TransactionChainListener {
+
+        private final TransactionChainListener listener;
+
+        public ListenerInvoker(final TransactionChainListener listener) {
+            this.listener = Preconditions.checkNotNull(listener, "Listener must not be null.");
+        }
+
+        @Override
+        public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+                final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+            Preconditions.checkState(delegate.equals(chain),
+                    "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
+            AsyncTransaction<?, ?> bindingTx = getBindingTransaction(transaction);
+            listener.onTransactionChainFailed(chain, bindingTx, cause);
+        }
+
+        @Override
+        public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+            Preconditions.checkState(delegate.equals(chain),
+                    "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
+            listener.onTransactionChainSuccessful(BindingTranslatedTransactionChain.this);
+        }
+    }
+
+}
index bf18454f4d1c3122ad7e8c5cd651e02d24f50437..1c6447a4e741615b714657c9356dc6b756fe44c0 100644 (file)
@@ -18,7 +18,6 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
 
-import org.opendaylight.controller.md.sal.binding.api.BindingDataChangeListener;
 import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
@@ -113,11 +112,11 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             final InstanceIdentifier<? extends DataObject> path, final DataChangeListener listener) {
 
 
-        BindingDataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener);
-        BindingDataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener);
+        org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener);
+        org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener);
 
-        ListenerRegistration<BindingDataChangeListener> cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
-        ListenerRegistration<BindingDataChangeListener> operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
+        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
+        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
 
         return new LegacyListenerRegistration(listener,cfgReg,operReg);
     }
@@ -187,7 +186,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
     }
 
     private class ForwardedBackwardsCompatibleTransacion extends
-            AbstractForwardedTransaction<DOMDataReadWriteTransaction> implements DataModificationTransaction {
+            AbstractReadWriteTransaction implements DataModificationTransaction {
 
         private final ListenerRegistry<DataTransactionListener> listeners = ListenerRegistry.create();
         private final Map<InstanceIdentifier<? extends DataObject>, DataObject> updated = new HashMap<>();
@@ -215,9 +214,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         public void putOperationalData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
             boolean previouslyRemoved = posponedRemovedOperational.remove(path);
             if(previouslyRemoved) {
-                doPutWithEnsureParents(getDelegate(), LogicalDatastoreType.OPERATIONAL, path, data);
+                doPutWithEnsureParents(LogicalDatastoreType.OPERATIONAL, path, data);
             } else {
-                doMergeWithEnsureParents(getDelegate(), LogicalDatastoreType.OPERATIONAL, path, data);
+                doMergeWithEnsureParents(LogicalDatastoreType.OPERATIONAL, path, data);
             }
         }
 
@@ -233,9 +232,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             }
             updated.put(path, data);
             if(previouslyRemoved) {
-                doPutWithEnsureParents(getDelegate(), LogicalDatastoreType.CONFIGURATION, path, data);
+                doPutWithEnsureParents(LogicalDatastoreType.CONFIGURATION, path, data);
             } else {
-                doMergeWithEnsureParents(getDelegate(), LogicalDatastoreType.CONFIGURATION, path, data);
+                doMergeWithEnsureParents(LogicalDatastoreType.CONFIGURATION, path, data);
             }
         }
 
@@ -309,11 +308,6 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             }
         }
 
-        @Override
-        public Object getIdentifier() {
-            return getDelegate().getIdentifier();
-        }
-
         private void changeStatus(final TransactionStatus status) {
             LOG.trace("Transaction {} changed status to {}", getIdentifier(), status);
             this.status = status;
@@ -331,11 +325,11 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         public ListenableFuture<RpcResult<TransactionStatus>> commit() {
 
             for(InstanceIdentifier<? extends DataObject> path : posponedRemovedConfiguration) {
-                doDelete(getDelegate(), LogicalDatastoreType.CONFIGURATION, path);
+                doDelete(LogicalDatastoreType.CONFIGURATION, path);
             }
 
             for(InstanceIdentifier<? extends DataObject> path : posponedRemovedOperational) {
-                doDelete(getDelegate(), LogicalDatastoreType.OPERATIONAL, path);
+                doDelete(LogicalDatastoreType.OPERATIONAL, path);
             }
 
             changeStatus(TransactionStatus.SUBMITED);
@@ -387,12 +381,12 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
     private static final class LegacyListenerRegistration implements ListenerRegistration<DataChangeListener> {
 
         private final DataChangeListener instance;
-        private final ListenerRegistration<BindingDataChangeListener> cfgReg;
-        private final ListenerRegistration<BindingDataChangeListener> operReg;
+        private final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg;
+        private final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg;
 
         public LegacyListenerRegistration(final DataChangeListener listener,
-                final ListenerRegistration<BindingDataChangeListener> cfgReg,
-                final ListenerRegistration<BindingDataChangeListener> operReg) {
+                final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg,
+                final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg) {
             this.instance = listener;
             this.cfgReg = cfgReg;
             this.operReg = operReg;
@@ -411,7 +405,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
 
     }
 
-    private static class BackwardsCompatibleOperationalDataChangeInvoker implements BindingDataChangeListener, Delegator<DataChangeListener> {
+    private static class BackwardsCompatibleOperationalDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator<DataChangeListener> {
 
         private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener<?,?> delegate;
 
@@ -436,7 +430,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
 
     }
 
-    private static class BackwardsCompatibleConfigurationDataChangeInvoker implements BindingDataChangeListener, Delegator<DataChangeListener> {
+    private static class BackwardsCompatibleConfigurationDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator<DataChangeListener> {
         private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener<?,?> delegate;
 
         public BackwardsCompatibleConfigurationDataChangeInvoker(final DataChangeListener listener) {
index 5ab088e20ec20b072e08bf1e277af48a6dbda4a1..6359b60684ef45e18d2185d1231b14b165497724 100644 (file)
@@ -7,27 +7,17 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import org.opendaylight.controller.md.sal.binding.api.BindingDataBroker;
-import org.opendaylight.controller.md.sal.binding.api.BindingDataReadTransaction;
-import org.opendaylight.controller.md.sal.binding.api.BindingDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.BindingDataWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+
+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.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * The DataBrokerImpl simply defers to the DOMDataBroker for all its operations.
  * All transactions and listener registrations are wrapped by the DataBrokerImpl
@@ -36,111 +26,32 @@ import com.google.common.util.concurrent.ListenableFuture;
  * Besides this the DataBrokerImpl and it's collaborators also cache data that
  * is already transformed from the binding independent to binding aware format
  *
- * TODO : All references in this class to CompositeNode should be switched to
- * NormalizedNode once the MappingService is updated
- *
+
  */
-public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker implements BindingDataBroker {
+public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker implements DataBroker {
 
     public ForwardedBindingDataBroker(final DOMDataBroker domDataBroker, final BindingIndependentMappingService mappingService, final SchemaService schemaService) {
         super(domDataBroker, mappingService,schemaService);
     }
 
     @Override
-    public BindingDataReadTransaction newReadOnlyTransaction() {
+
+    public ReadOnlyTransaction newReadOnlyTransaction() {
         return new BindingDataReadTransactionImpl(getDelegate().newReadOnlyTransaction(),getCodec());
     }
 
     @Override
-    public BindingDataReadWriteTransaction newReadWriteTransaction() {
+    public ReadWriteTransaction newReadWriteTransaction() {
         return new BindingDataReadWriteTransactionImpl(getDelegate().newReadWriteTransaction(),getCodec());
     }
 
     @Override
-    public BindingDataWriteTransaction newWriteOnlyTransaction() {
-        return new BindingDataWriteTransactionImpl<DOMDataWriteTransaction>(getDelegate().newWriteOnlyTransaction(),getCodec());
-    }
-
-    private abstract class AbstractBindingTransaction<T extends AsyncTransaction<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>>>
-            extends AbstractForwardedTransaction<T> implements AsyncTransaction<InstanceIdentifier<?>, DataObject> {
-
-        protected AbstractBindingTransaction(final T delegate, final BindingToNormalizedNodeCodec codec) {
-            super(delegate, codec);
-        }
-
-        @Override
-        public Object getIdentifier() {
-            return getDelegate().getIdentifier();
-        }
-
-        @Override
-        public void close() {
-            getDelegate().close();
-        }
-
+    public WriteTransaction newWriteOnlyTransaction() {
+        return new BindingDataWriteTransactionImpl<>(getDelegate().newWriteOnlyTransaction(),getCodec());
     }
 
-    private class BindingDataReadTransactionImpl extends AbstractBindingTransaction<DOMDataReadTransaction> implements
-            BindingDataReadTransaction {
-
-        protected BindingDataReadTransactionImpl(final DOMDataReadTransaction delegate,
-                final BindingToNormalizedNodeCodec codec) {
-            super(delegate, codec);
-        }
-
-        @Override
-        public ListenableFuture<Optional<DataObject>> read(final LogicalDatastoreType store,
-                final InstanceIdentifier<?> path) {
-            return doRead(getDelegate(), store, path);
-        }
-    }
-
-    private class BindingDataWriteTransactionImpl<T extends DOMDataWriteTransaction> extends
-            AbstractBindingTransaction<T> implements BindingDataWriteTransaction {
-
-        protected BindingDataWriteTransactionImpl(final T delegate, final BindingToNormalizedNodeCodec codec) {
-            super(delegate, codec);
-
-        }
-
-        @Override
-        public void cancel() {
-            doCancel(getDelegate());
-        }
-
-        @Override
-        public void put(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
-            doPut(getDelegate(), store, path, data);
-        }
-
-        @Override
-        public void merge(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
-            doMerge(getDelegate(), store, path, data);
-        }
-
-        @Override
-        public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
-            doDelete(getDelegate(), store, path);
-        }
-
-        @Override
-        public ListenableFuture<RpcResult<TransactionStatus>> commit() {
-            return doCommit(getDelegate());
-        }
-    }
-
-    private class BindingDataReadWriteTransactionImpl extends
-            BindingDataWriteTransactionImpl<DOMDataReadWriteTransaction> implements BindingDataReadWriteTransaction {
-
-        protected BindingDataReadWriteTransactionImpl(final DOMDataReadWriteTransaction delegate,
-                final BindingToNormalizedNodeCodec codec) {
-            super(delegate, codec);
-        }
-
-        @Override
-        public ListenableFuture<Optional<DataObject>> read(final LogicalDatastoreType store,
-                final InstanceIdentifier<?> path) {
-            return doRead(getDelegate(), store, path);
-        }
+    @Override
+    public BindingTransactionChain createTransactionChain(final TransactionChainListener listener) {
+        return new BindingTranslatedTransactionChain(getDelegate(), getCodec(), listener);
     }
 }
index 8acad1b2d737a0e440f7d55e1ab3c0a233dbba83..d810149c7077b663701d5385352f67da10ab7361 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.controller.sal.binding.impl;
 
 import static com.google.common.base.Preconditions.checkState;
 
-import org.opendaylight.controller.md.sal.binding.api.BindingDataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
 import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
@@ -54,7 +54,7 @@ public class RootBindingAwareBroker implements //
 
     private DataProviderService legacyDataBroker;
 
-    private BindingDataBroker dataBroker;
+    private DataBroker dataBroker;
 
     private MountPointManagerImpl mountManager;
 
@@ -124,7 +124,7 @@ public class RootBindingAwareBroker implements //
         consBuilder.put(DataBrokerService.class, getRoot());
         consBuilder.put(RpcConsumerRegistry.class, getRoot());
         if(dataBroker != null) {
-            consBuilder.put(BindingDataBroker.class, dataBroker);
+            consBuilder.put(DataBroker.class, dataBroker);
         }
         consBuilder.put(MountService.class, mountManager).build();
         supportedConsumerServices = consBuilder.build();
@@ -183,7 +183,7 @@ public class RootBindingAwareBroker implements //
         }
     }
 
-    public void setDataBroker(final BindingDataBroker asyncDataBroker) {
+    public void setDataBroker(final DataBroker asyncDataBroker) {
         dataBroker = asyncDataBroker;
     }
 }
index 4a2ec8a06346d8a6a13ce94f26d90c874eb69d71..8636ff613bb2c480e7dd62367ef2174a73ceed73 100644 (file)
@@ -25,7 +25,7 @@ module opendaylight-md-sal-binding {
     
     identity binding-async-data-broker {
         base "config:service-type";
-        config:java-class "org.opendaylight.controller.md.sal.binding.api.BindingDataBroker";
+        config:java-class "org.opendaylight.controller.md.sal.binding.api.DataBroker";
     }
 
     identity binding-data-consumer-broker {
index 800c1b4cc426e1ef09c04983f594ecb059d036d1..667887ac805f3c8ea538df89da2d22d147b62ade 100644 (file)
@@ -20,7 +20,7 @@ import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
@@ -139,7 +139,7 @@ public class ListProcessingAndOrderingTest extends AbstractDataServiceTest {
     private NormalizedNode<?, ?> resolveDataAsserted(
             final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath) {
 
-        try (DOMDataReadTransaction readTx = testContext.getDomAsyncDataBroker().newReadOnlyTransaction()){
+        try (DOMDataReadOnlyTransaction readTx = testContext.getDomAsyncDataBroker().newReadOnlyTransaction()){
             ListenableFuture<Optional<NormalizedNode<?, ?>>> data = readTx.read(LogicalDatastoreType.OPERATIONAL, domPath);
             Optional<NormalizedNode<?, ?>> potential = data.get();
             assertTrue(potential.isPresent());
index a15c711e2d2eb88c0a5647baaaa4bdc168a91cac..5ede600d9777917a0df963c01b5a08128057f722 100644 (file)
@@ -119,7 +119,7 @@ public class TestHelper {
                 mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // //
 
 
-
+                mavenBundle(CONTROLLER, "sal-inmemory-datastore").versionAsInProject(), // /
                 mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), // //
                 mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), //
 
index 37ef257224d30ad749a6030557fab85f7fb734c6..63a921d6f309db37a0a438bbadbafdaadb528485 100644 (file)
@@ -20,7 +20,6 @@
                 </capability>
                 <capability>urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2010-09-24
                 </capability>
-                <capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</capability>
                 <capability>urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&amp;revision=2010-09-24
                 </capability>
                 <capability>
index fb429e5fd1342c0ca675040a315c1b8ad76456c7..3a68092f07e27f0ffe56dc090c01a0e04b37d3fd 100644 (file)
@@ -12,14 +12,11 @@ import org.opendaylight.yangtools.concepts.Path;
 
 /**
  *
- * Provides access to a conceptual data tree store.
+ * Base interface that provides access to a conceptual data tree store and also provides the ability to
+ * subscribe for changes to data under a given branch of the tree.
  *
  * <p>
- * Also provides the ability to subscribe for changes to data under a given
- * branch of the tree.
- *
- * <p>
- * All operations on data tree are performed via one of the transactions:
+ * All operations on the data tree are performed via one of the transactions:
  * <ul>
  * <li>Read-Only - allocated using {@link #newReadOnlyTransaction()}
  * <li>Write-Only - allocated using {@link #newWriteOnlyTransaction()}
@@ -133,7 +130,7 @@ public interface AsyncDataBroker<P extends Path<P>, D, L extends AsyncDataChange
      * {@inheritDoc}
      */
     @Override
-    public AsyncReadTransaction<P, D> newReadOnlyTransaction();
+    public AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
 
     /**
      * {@inheritDoc}
index cedd883b220199116502b47bc034ac1fe98ea5f2..a558b96b2d56fa26658741d8ee11ac63f3e735a3 100644 (file)
@@ -72,7 +72,7 @@ public interface AsyncDataTransactionFactory<P extends Path<P>, D> {
      *
      * @return new read-only transaction
      */
-    AsyncReadTransaction<P, D> newReadOnlyTransaction();
+    AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
 
     /**
      * Allocates new read-write transaction which provides a mutable view of the data
diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java
new file mode 100644 (file)
index 0000000..4beb5c6
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.common.api.data;
+
+import org.opendaylight.yangtools.concepts.Path;
+
+/**
+ * Read-only transaction, which provides stable view of data
+ * and is {@link AutoCloseable} resource.
+ *
+ * @see AsyncReadTransaction
+ *
+* @param <P>
+ *            Type of path (subtree identifier), which represents location in
+ *            tree
+ * @param <D>
+ *            Type of data (payload), which represents data payload
+ */
+public interface AsyncReadOnlyTransaction<P extends Path<P>, D> extends AsyncReadTransaction<P, D>, AutoCloseable {
+
+    /**
+     * Closes this transaction and releases all resources associated with it.
+     *
+     */
+    @Override
+    public void close();
+}
index 6cf5a5b532d41725ce76f45299536de76c63ece2..e1cd4a712a0d9804ac1846a8e8bf4ad6f23dc8ca 100644 (file)
@@ -14,7 +14,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 
 /**
  *
- * Provides a stateful read-only view of the data tree.
+ * Provides a stateful read view of the data tree.
  *
  * <p>
  * View of the data tree is a stable point-in-time snapshot of the current data tree state when
@@ -25,8 +25,8 @@ import com.google.common.util.concurrent.ListenableFuture;
  * <b>Implementation Note:</b> This interface is not intended to be implemented
  * by users of MD-SAL, but only to be consumed by them.
  *
- * <h2>Transaction isolation example</h2> Lest assume initial state of data tree
- * for <code>PATH</code> is <code>A</code>.
+ * <h2>Transaction isolation example</h2>
+ * Lets assume initial state of data tree for <code>PATH</code> is <code>A</code>.
  *
  * <pre>
  * txRead = broker.newReadOnlyTransaction();   // read Transaction is snapshot of data
index 34101366c806fe56884622ed3118e7d35090228c..16b4ed4fe2ed14d7cf7db8e5e88621df801d9f1c 100644 (file)
@@ -124,6 +124,8 @@ import org.opendaylight.yangtools.concepts.Path;
  * or other functions from {@link com.google.common.util.concurrent.Futures} to
  * register more specific listeners.
  *
+ * @see AsyncReadTransaction
+ * @see AsyncWriteTransaction
  *
  * @param <P>
  *            Type of path (subtree identifier), which represents location in
index c7cc91528b7c255f60416df67e1ebddf4660c7b5..08ddfe689819702e5805bb8a78f5dbee6eb2f4ee 100644 (file)
@@ -29,15 +29,10 @@ import org.opendaylight.yangtools.concepts.Path;
  * @param <D> Type of data (payload), which represents data payload
  */
 public interface AsyncTransaction<P extends Path<P>,D> extends //
-    Identifiable<Object>,
-    AutoCloseable {
+    Identifiable<Object> {
 
     @Override
     public Object getIdentifier();
 
-    /**
-     * Closes transaction and releases all resources associated with it.
-     */
-    @Override
-    public void close();
+
 }
index e2734eaddc4845396e3d866dec8d918ac9fe4bca..f7eae27320107ef6a90696ff73f2cf40b3c99fde 100644 (file)
@@ -53,13 +53,19 @@ public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransa
      * {@link TransactionStatus#NEW} or {@link TransactionStatus#SUBMITED}
      *
      * Invoking cancel() on {@link TransactionStatus#FAILED} or
-     * {@link TransactionStatus#CANCELED} will have no effect.
+     * {@link TransactionStatus#CANCELED} will have no effect, and transaction
+     * is considered cancelled.
      *
-     * @throws IllegalStateException
-     *             If transaction status is {@link TransactionStatus#COMMITED}
+     * Invoking cancel() on finished transaction  (future returned by {@link #commit()}
+     * already completed with {@link TransactionStatus#COMMITED}) will always
+     * fail (return false).
+     *
+     * @return <tt>false</tt> if the task could not be cancelled,
+     * typically because it has already completed normally;
+     * <tt>true</tt> otherwise
      *
      */
-    public void cancel();
+    public boolean cancel();
 
     /**
      * Store a piece of data at specified path. This acts as an add / replace
@@ -141,20 +147,6 @@ public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransa
      */
     public void delete(LogicalDatastoreType store, P path);
 
-    /**
-     *
-     * Closes transaction and resources allocated to the transaction.
-     *
-     * This call does not change Transaction status. Client SHOULD explicitly
-     * {@link #commit()} or {@link #cancel()} transaction.
-     *
-     * @throws IllegalStateException
-     *             if the transaction has not been updated by invoking
-     *             {@link #commit()} or {@link #cancel()}.
-     */
-    @Override
-    public void close();
-
     /**
      * Submits transaction to be applied to update logical data tree.
      * <p>
index e7e0eb0ff87e424973de4b9c9d6fdf9111ccae4c..940559ef895bf9cec406eee2fbe73a7617da581a 100644 (file)
@@ -27,7 +27,7 @@ public interface TransactionChain<P extends Path<P>, D> extends AutoCloseable, A
      * @throws TransactionChainClosedException if the chain has been closed.
      */
     @Override
-    public AsyncReadTransaction<P, D> newReadOnlyTransaction();
+    public AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
 
 
     /**
index ddf089c68fd0e5000d0eec58d51b2ee841311bd0..ce861f7e7afbb4884fbf9ddbc8979eb0a1a3a64e 100644 (file)
@@ -18,6 +18,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import java.util.AbstractMap;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
@@ -390,15 +391,44 @@ public class DataNormalizerTest {
         Collections.sort(unorderdChildData, new Comparator<LegacyNodeData>() {
             @Override
             public int compare(LegacyNodeData arg1, LegacyNodeData arg2) {
-                String str1 = arg1.nodeKey.getLocalName();
-                if (!(arg1.nodeData instanceof List))
-                    str1 += arg1.nodeData; // add simple node value
-
-                String str2 = arg2.nodeKey.getLocalName();
-                if (!(arg2.nodeData instanceof List))
-                    str2 += arg2.nodeData; // add simple node value
-
-                return str1.compareTo(str2);
+                if (!(arg1.nodeData instanceof List) && !(arg2.nodeData instanceof List)) {
+                    // if neither is a list, just compare them
+                    String str1 = arg1.nodeKey.getLocalName() + arg1.nodeData;
+                    String str2 = arg2.nodeKey.getLocalName() + arg2.nodeData;
+                    return str1.compareTo(str2);
+                } else if (arg1.nodeData instanceof List && arg2.nodeData instanceof List) {
+                    // if both are lists, first check their local name
+                    String str1 = arg1.nodeKey.getLocalName();
+                    String str2 = arg2.nodeKey.getLocalName();
+                    if (!str1.equals(str2)) {
+                        return str1.compareTo(str2);
+                    } else {
+                        // if local names are the same, then look at the list contents
+                        List<LegacyNodeData> l1 = (List<LegacyNodeData>) arg1.nodeData;
+                        List<LegacyNodeData> l2 = (List<LegacyNodeData>) arg2.nodeData;
+
+                        if (l1.size() != l2.size()) {
+                            // if the sizes are different, use that
+                            return l2.size() - l1.size();
+                        } else {
+                            // lastly sort and recursively check the list contents
+                            Collections.sort(l1, this);
+                            Collections.sort(l2, this);
+
+                            for (int i = 0 ; i < l1.size() ; i++) {
+                                int diff = this.compare(l1.get(i), l2.get(i));
+                                if (diff != 0) {
+                                    return diff;
+                                }
+                            }
+                            return 0;
+                        }
+                    }
+                } else if( arg1.nodeData instanceof List ) {
+                    return -1;
+                } else{
+                    return 1;
+                }
             }
         });
 
@@ -417,15 +447,49 @@ public class DataNormalizerTest {
         Collections.sort(unorderedChildNodes, new Comparator<Node<?>>() {
             @Override
             public int compare(Node<?> n1, Node<?> n2) {
-                String str1 = n1.getKey().getLocalName();
-                if (n1 instanceof SimpleNode)
-                    str1 += ((SimpleNode<?>) n1).getValue();
-
-                String str2 = n2.getKey().getLocalName();
-                if (n2 instanceof SimpleNode)
-                    str2 += ((SimpleNode<?>) n2).getValue();
-
-                return str1.compareTo(str2);
+                if (n1 instanceof SimpleNode && n2 instanceof SimpleNode) {
+                    // if they're SimpleNodes just compare their strings
+                    String str1 = n1.getKey().getLocalName() + ((SimpleNode<?>)n1).getValue();
+                    String str2 = n2.getKey().getLocalName() + ((SimpleNode<?>)n2).getValue();
+                    return str1.compareTo(str2);
+                } else if (n1 instanceof CompositeNode && n2 instanceof CompositeNode) {
+                    // if they're CompositeNodes, things are more interesting
+                    String str1 = n1.getKey().getLocalName();
+                    String str2 = n2.getKey().getLocalName();
+                    if (!str1.equals(str2)) {
+                        // if their local names differ, return that difference
+                        return str1.compareTo(str2);
+                    } else {
+                        // otherwise, we need to look at their contents
+                        ArrayList<Node<?>> l1 = new ArrayList<Node<?>>( ((CompositeNode)n1).getValue() );
+                        ArrayList<Node<?>> l2 = new ArrayList<Node<?>>( ((CompositeNode)n2).getValue() );
+
+                        if (l1.size() != l2.size()) {
+                            // if they have different numbers of things in them return that
+                            return l2.size() - l1.size();
+                        } else {
+                            // otherwise, compare the individual elements, first sort them
+                            Collections.sort(l1, this);
+                            Collections.sort(l2, this);
+
+                            // then compare them individually
+                            for(int i = 0 ; i < l2.size() ; i++) {
+                                int diff = this.compare(l1.get(i), l2.get(i));
+                                if(diff != 0){
+                                    return diff;
+                                }
+                            }
+                            return 0;
+                        }
+                    }
+                } else if (n1 instanceof CompositeNode && n2 instanceof SimpleNode) {
+                    return -1;
+                } else if (n2 instanceof CompositeNode && n1 instanceof SimpleNode) {
+                    return 1;
+                } else {
+                    assertTrue("Expected either SimpleNodes CompositeNodes", false);
+                    return 0;
+                }
             }
         });
 
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListener.java
new file mode 100644 (file)
index 0000000..ba09d04
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+import akka.actor.Props;
+import akka.actor.UntypedActor;
+import akka.japi.Creator;
+
+public class DataChangeListener extends UntypedActor {
+    @Override public void onReceive(Object message) throws Exception {
+        throw new UnsupportedOperationException("onReceive");
+    }
+
+    public static Props props() {
+        return Props.create(new Creator<DataChangeListener>() {
+            @Override
+            public DataChangeListener create() throws Exception {
+                return new DataChangeListener();
+            }
+
+        });
+
+    }
+}
index 8d5b0c2f4a65f49d188786ad9f5927f29939166e..f64c6f1a8669888726f30bfe4099aa628365ccbb 100644 (file)
@@ -8,6 +8,12 @@
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
+import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
+import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
@@ -18,34 +24,72 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
  */
-public class DistributedDataStore implements DOMStore {
+public class DistributedDataStore implements DOMStore, SchemaContextListener {
+
+    private static final Logger
+        LOG = LoggerFactory.getLogger(DistributedDataStore.class);
+
+
+    private final String type;
+    private final ActorContext actorContext;
+
+    public DistributedDataStore(ActorSystem actorSystem, String type) {
+        this(new ActorContext(actorSystem, actorSystem.actorOf(ShardManager.props(type))), type);
+    }
+
+    public DistributedDataStore(ActorContext actorContext, String type) {
+        this.type = type;
+        this.actorContext = actorContext;
+    }
+
 
     @Override
-    public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerChangeListener(InstanceIdentifier path, L listener, AsyncDataBroker.DataChangeScope scope) {
-        return new ListenerRegistrationProxy();
+    public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerChangeListener(
+        InstanceIdentifier path, L listener,
+        AsyncDataBroker.DataChangeScope scope) {
+
+        ActorRef dataChangeListenerActor = actorContext.getActorSystem().actorOf(DataChangeListener.props());
+
+        Object result = actorContext.executeShardOperation(Shard.DEFAULT_NAME,
+            new RegisterChangeListener(path, dataChangeListenerActor.path(),
+                AsyncDataBroker.DataChangeScope.BASE),
+            ActorContext.ASK_DURATION);
+
+        RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result;
+        return new ListenerRegistrationProxy(reply.getListenerRegistrationPath());
     }
 
+
+
     @Override
     public DOMStoreTransactionChain createTransactionChain() {
-        return new TransactionChainProxy();
+        return new TransactionChainProxy(actorContext);
     }
 
     @Override
     public DOMStoreReadTransaction newReadOnlyTransaction() {
-        return new TransactionProxy();
+        return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
-        return new TransactionProxy();
+        return new TransactionProxy(actorContext, TransactionProxy.TransactionType.WRITE_ONLY);
     }
 
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
-        return new TransactionProxy();
+        return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_WRITE);
+    }
+
+    @Override public void onGlobalContextUpdated(SchemaContext schemaContext) {
+        actorContext.getShardManager().tell(new UpdateSchemaContext(schemaContext), null);
     }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerProxy.java
new file mode 100644 (file)
index 0000000..7c38ee5
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+import akka.actor.ActorSelection;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class ListenerProxy implements AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>{
+    private final ActorSelection listenerRegistrationActor;
+
+    public ListenerProxy(ActorSelection listenerRegistrationActor) {
+        this.listenerRegistrationActor = listenerRegistrationActor;
+    }
+
+    @Override public void onDataChanged(
+        AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> change) {
+        throw new UnsupportedOperationException("onDataChanged");
+    }
+}
index c2fc8c0277472108abc4f72b5012445ef4937807..a548a885eb2c73600e013ccf3a0cd46fe34950d9 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorPath;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 
 /**
@@ -17,6 +18,13 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
  * The ListenerRegistrationProxy talks to a remote ListenerRegistration actor.
  */
 public class ListenerRegistrationProxy implements ListenerRegistration {
+    private final ActorPath listenerRegistrationPath;
+
+    public ListenerRegistrationProxy(ActorPath listenerRegistrationPath) {
+
+        this.listenerRegistrationPath = listenerRegistrationPath;
+    }
+
     @Override
     public Object getInstance() {
         throw new UnsupportedOperationException("getInstance");
index 8365328669587b5e083c8e53ca819eb63857cd40..5b4f7ef8989711dffdf4cdd8fbe7d483165f23a7 100644 (file)
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
+import akka.actor.ActorSelection;
+import akka.actor.Props;
 import akka.event.Logging;
 import akka.event.LoggingAdapter;
+import akka.japi.Creator;
+import akka.persistence.Persistent;
 import akka.persistence.UntypedProcessor;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
+import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChainReply;
+import org.opendaylight.controller.cluster.datastore.messages.ForwardedCommitTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
 import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.modification.Modification;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 
 /**
- * A Shard represents a portion of the logical data tree
- * <p/>
+ * A Shard represents a portion of the logical data tree <br/>
+ * <p>
  * Our Shard uses InMemoryDataStore as it's internal representation and delegates all requests it
- *
+ * </p>
  */
 public class Shard extends UntypedProcessor {
 
-  ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
+    public static final String DEFAULT_NAME = "default";
+
+    private final ListeningExecutorService storeExecutor =
+        MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
+
+    private final InMemoryDOMDataStore store;
+
+    private final Map<Modification, DOMStoreThreePhaseCommitCohort>
+        modificationToCohort = new HashMap<>();
+
+    private final LoggingAdapter log =
+        Logging.getLogger(getContext().system(), this);
+
+    private Shard(String name) {
+        store = new InMemoryDOMDataStore(name, storeExecutor);
+    }
+
+    public static Props props(final String name) {
+        return Props.create(new Creator<Shard>() {
+
+            @Override
+            public Shard create() throws Exception {
+                return new Shard(name);
+            }
+
+        });
+    }
+
+    @Override
+    public void onReceive(Object message) throws Exception {
+        if (message instanceof CreateTransactionChain) {
+            createTransactionChain();
+        } else if (message instanceof RegisterChangeListener) {
+            registerChangeListener((RegisterChangeListener) message);
+        } else if (message instanceof UpdateSchemaContext) {
+            updateSchemaContext((UpdateSchemaContext) message);
+        } else if (message instanceof ForwardedCommitTransaction) {
+            handleForwardedCommit((ForwardedCommitTransaction) message);
+        } else if (message instanceof Persistent) {
+            commit((Persistent) message);
+        }
+    }
+
+    private void commit(Persistent message) {
+        Modification modification = (Modification) message.payload();
+        DOMStoreThreePhaseCommitCohort cohort =
+            modificationToCohort.remove(modification);
+        if (cohort == null) {
+            log.error(
+                "Could not find cohort for modification : " + modification);
+            return;
+        }
+        final ListenableFuture<Void> future = cohort.commit();
+        final ActorRef sender = getSender();
+        final ActorRef self = getSelf();
+        future.addListener(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    future.get();
+                    sender.tell(new CommitTransactionReply(), self);
+                } catch (InterruptedException | ExecutionException e) {
+                    log.error(e, "An exception happened when committing");
+                }
+            }
+        }, getContext().dispatcher());
+    }
 
-  private final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", storeExecutor);
+    private void handleForwardedCommit(ForwardedCommitTransaction message) {
+        log.info("received forwarded transaction");
+        modificationToCohort
+            .put(message.getModification(), message.getCohort());
+        getSelf().forward(Persistent.create(message.getModification()),
+            getContext());
+    }
 
-  LoggingAdapter log = Logging.getLogger(getContext().system(), this);
+    private void updateSchemaContext(UpdateSchemaContext message) {
+        store.onGlobalContextUpdated(message.getSchemaContext());
+    }
+
+    private void registerChangeListener(
+        RegisterChangeListener registerChangeListener) {
+
+        ActorSelection listenerRegistrationActor = getContext()
+            .system().actorSelection(registerChangeListener.getDataChangeListenerPath());
+
+        AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>
+            listener = new ListenerProxy(listenerRegistrationActor);
+
+        org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>>
+            registration =
+            store.registerChangeListener(registerChangeListener.getPath(),
+                listener, registerChangeListener.getScope());
+        ActorRef listenerRegistration =
+            getContext().actorOf(ListenerRegistration.props(registration));
+        getSender()
+            .tell(new RegisterChangeListenerReply(listenerRegistration.path()),
+                getSelf());
+    }
 
-  @Override
-  public void onReceive(Object message) throws Exception {
-    if (message instanceof CreateTransactionChain) {
-      createTransactionChain();
-    } else if(message instanceof RegisterChangeListener){
-      registerChangeListener((RegisterChangeListener) message);
-    } else if(message instanceof UpdateSchemaContext){
-      updateSchemaContext((UpdateSchemaContext) message);
+    private void createTransactionChain() {
+        DOMStoreTransactionChain chain = store.createTransactionChain();
+        ActorRef transactionChain =
+            getContext().actorOf(ShardTransactionChain.props(chain));
+        getSender()
+            .tell(new CreateTransactionChainReply(transactionChain.path()),
+                getSelf());
     }
-  }
-
-  private void updateSchemaContext(UpdateSchemaContext message) {
-    store.onGlobalContextUpdated(message.getSchemaContext());
-  }
-
-  private void registerChangeListener(RegisterChangeListener registerChangeListener) {
-    org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> registration =
-            store.registerChangeListener(registerChangeListener.getPath(), registerChangeListener.getListener(), registerChangeListener.getScope());
-    ActorRef listenerRegistration = getContext().actorOf(ListenerRegistration.props(registration));
-    getSender().tell(new RegisterChangeListenerReply(listenerRegistration.path()), getSelf());
-  }
-
-  private void createTransactionChain() {
-    DOMStoreTransactionChain chain = store.createTransactionChain();
-    ActorRef transactionChain = getContext().actorOf(ShardTransactionChain.props(chain));
-    getSender().tell(new CreateTransactionChainReply(transactionChain.path()), getSelf());
-  }
 }
index 63266d6308287d2e816724f3f73b192b0d120bce..4e2369d3758596bd1217670f8f3ec5a2438db36d 100644 (file)
@@ -8,12 +8,18 @@
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorPath;
+import akka.actor.ActorRef;
 import akka.actor.Address;
+import akka.actor.Props;
 import akka.actor.UntypedActor;
 import akka.event.Logging;
 import akka.event.LoggingAdapter;
+import akka.japi.Creator;
 import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
+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 java.util.HashMap;
 import java.util.List;
@@ -21,41 +27,77 @@ import java.util.Map;
 
 /**
  * The ShardManager has the following jobs,
- *
- *  - Create all the local shard replicas that belong on this cluster member
- *  - Find the primary replica for any given shard
- *  - Engage in shard replica elections which decide which replica should be the primary
- *
- * Creation of Shard replicas
- * ==========================
- *  When the ShardManager is constructed it reads the cluster configuration to find out which shard replicas
- *  belong on this member. It finds out the name of the current cluster member from the Akka Clustering Service.
- *
- * Replica Elections
- * =================
- *  The Shard Manager uses multiple cues to initiate election.
- *      - When a member of the cluster dies
- *      - When a local shard replica dies
- *      - When a local shard replica comes alive
+ * <p>
+ * <li> Create all the local shard replicas that belong on this cluster member
+ * <li> Find the primary replica for any given shard
+ * <li> Engage in shard replica elections which decide which replica should be the primary
+ * </p>
+ * <p/>
+ * <h3>>Creation of Shard replicas</h3
+ * <p>
+ * When the ShardManager is constructed it reads the cluster configuration to find out which shard replicas
+ * belong on this member. It finds out the name of the current cluster member from the Akka Clustering Service.
+ * </p>
+ * <p/>
+ * <h3> Replica Elections </h3>
+ * <p/>
+ * <p>
+ * The Shard Manager uses multiple cues to initiate election.
+ * <li> When a member of the cluster dies
+ * <li> When a local shard replica dies
+ * <li> When a local shard replica comes alive
+ * </p>
  */
 public class ShardManager extends UntypedActor {
 
-    // Stores a mapping between a shard name and the address of the current primary
-    private final Map<String, Address> shardNameToPrimaryAddress = new HashMap<>();
+  // Stores a mapping between a shard name and the address of the current primary
+  private final Map<String, Address> shardNameToPrimaryAddress = new HashMap<>();
+
+  // Stores a mapping between a member name and the address of the member
+  private final Map<String, Address> memberNameToAddress = new HashMap<>();
+
+  // Stores a mapping between the shard name and all the members on which a replica of that shard are available
+  private final Map<String, List<String>> shardNameToMembers = new HashMap<>();
 
-    // Stores a mapping between a member name and the address of the member
-    private final Map<String, Address> memberNameToAddress = new HashMap<>();
+  private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
 
-    // Stores a mapping between the shard name and all the members on which a replica of that shard are available
-    private final Map<String, List<String>> shardNameToMembers = new HashMap<>();
+  private final ActorPath defaultShardPath;
 
-    LoggingAdapter log = Logging.getLogger(getContext().system(), this);
+  /**
+   *
+   * @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be
+   *             configuration or operational
+   */
+  private ShardManager(String type){
+    ActorRef actor = getContext().actorOf(Shard.props(Shard.DEFAULT_NAME + "-" + type));
+    defaultShardPath = actor.path();
+  }
 
-    @Override
-    public void onReceive(Object message) throws Exception {
-        if(message instanceof FindPrimary ){
-            FindPrimary msg = ((FindPrimary) message);
-            getSender().tell(new PrimaryNotFound(msg.getShardName()), getSelf());
-        }
+  public static Props props(final String type){
+    return Props.create(new Creator<ShardManager>(){
+
+      @Override
+      public ShardManager create() throws Exception {
+        return new ShardManager(type);
+      }
+    });
+  }
+
+  @Override
+  public void onReceive(Object message) throws Exception {
+    if (message instanceof FindPrimary) {
+      FindPrimary msg = ((FindPrimary) message);
+      String shardName = msg.getShardName();
+      if(Shard.DEFAULT_NAME.equals(shardName)){
+        getSender().tell(new PrimaryFound(defaultShardPath.toString()), getSelf());
+      } else {
+        getSender().tell(new PrimaryNotFound(shardName), getSelf());
+      }
+    } else if(message instanceof UpdateSchemaContext){
+        // FIXME : Notify all local shards of a context change
+        getContext().system().actorSelection(defaultShardPath).forward(message, getContext());
     }
+  }
+
+
 }
index b316b9df04966d82faf19ffc0743994dc684ec4a..75744cad5b920b942efda865d0fa6ed29c41f3d7 100644 (file)
@@ -28,6 +28,12 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.WriteData;
 import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply;
+import org.opendaylight.controller.cluster.datastore.modification.CompositeModification;
+import org.opendaylight.controller.cluster.datastore.modification.DeleteModification;
+import org.opendaylight.controller.cluster.datastore.modification.ImmutableCompositeModification;
+import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
+import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
+import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
@@ -37,40 +43,48 @@ import java.util.concurrent.ExecutionException;
 
 /**
  * The ShardTransaction Actor represents a remote transaction
- *
+ *<p>
  * The ShardTransaction Actor delegates all actions to DOMDataReadWriteTransaction
- *
+ *</p>
+ *<p>
  * Even though the DOMStore and the DOMStoreTransactionChain implement multiple types of transactions
  * the ShardTransaction Actor only works with read-write transactions. This is just to keep the logic simple. At this
  * time there are no known advantages for creating a read-only or write-only transaction which may change over time
  * at which point we can optimize things in the distributed store as well.
- *
- * Handles Messages
- * ----------------
- * {@link org.opendaylight.controller.cluster.datastore.messages.ReadData}
- * {@link org.opendaylight.controller.cluster.datastore.messages.WriteData}
- * {@link org.opendaylight.controller.cluster.datastore.messages.MergeData}
- * {@link org.opendaylight.controller.cluster.datastore.messages.DeleteData}
- * {@link org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction}
- * {@link org.opendaylight.controller.cluster.datastore.messages.CloseTransaction}
+ *</p>
+ *<p>
+ * Handles Messages <br/>
+ * ---------------- <br/>
+ * <li> {@link org.opendaylight.controller.cluster.datastore.messages.ReadData}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.messages.WriteData}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.messages.MergeData}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.messages.DeleteData}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.messages.CloseTransaction}
+ * </p>
  */
 public class ShardTransaction extends UntypedActor {
 
+  private final ActorRef shardActor;
+
   private final DOMStoreReadWriteTransaction transaction;
 
+  private final MutableCompositeModification modification = new MutableCompositeModification();
+
   private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
 
-  public ShardTransaction(DOMStoreReadWriteTransaction transaction) {
+  public ShardTransaction(DOMStoreReadWriteTransaction transaction, ActorRef shardActor) {
     this.transaction = transaction;
+    this.shardActor = shardActor;
   }
 
 
-  public static Props props(final DOMStoreReadWriteTransaction transaction){
+  public static Props props(final DOMStoreReadWriteTransaction transaction, final ActorRef shardActor){
     return Props.create(new Creator<ShardTransaction>(){
 
       @Override
       public ShardTransaction create() throws Exception {
-        return new ShardTransaction(transaction);
+        return new ShardTransaction(transaction, shardActor);
       }
     });
   }
@@ -89,6 +103,9 @@ public class ShardTransaction extends UntypedActor {
       readyTransaction((ReadyTransaction) message);
     } else if(message instanceof CloseTransaction){
       closeTransaction((CloseTransaction) message);
+    } else if(message instanceof GetCompositedModification){
+      // This is here for testing only
+      getSender().tell(new GetCompositeModificationReply(new ImmutableCompositeModification(modification)), getSelf());
     }
   }
 
@@ -118,23 +135,26 @@ public class ShardTransaction extends UntypedActor {
 
 
   private void writeData(WriteData message){
+    modification.addModification(new WriteModification(message.getPath(), message.getData()));
     transaction.write(message.getPath(), message.getData());
     getSender().tell(new WriteDataReply(), getSelf());
   }
 
   private void mergeData(MergeData message){
+    modification.addModification(new MergeModification(message.getPath(), message.getData()));
     transaction.merge(message.getPath(), message.getData());
     getSender().tell(new MergeDataReply(), getSelf());
   }
 
   private void deleteData(DeleteData message){
+    modification.addModification(new DeleteModification(message.getPath()));
     transaction.delete(message.getPath());
     getSender().tell(new DeleteDataReply(), getSelf());
   }
 
   private void readyTransaction(ReadyTransaction message){
     DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
-    ActorRef cohortActor = getContext().actorOf(ThreePhaseCommitCohort.props(cohort));
+    ActorRef cohortActor = getContext().actorOf(ThreePhaseCommitCohort.props(cohort, shardActor, modification));
     getSender().tell(new ReadyTransactionReply(cohortActor.path()), getSelf());
 
   }
@@ -143,4 +163,25 @@ public class ShardTransaction extends UntypedActor {
     transaction.close();
     getSender().tell(new CloseTransactionReply(), getSelf());
   }
+
+
+  // These classes are in here for test purposes only
+
+  static class GetCompositedModification {
+
+  }
+
+  static class GetCompositeModificationReply {
+    private final CompositeModification modification;
+
+
+    GetCompositeModificationReply(CompositeModification modification) {
+      this.modification = modification;
+    }
+
+
+    public CompositeModification getModification() {
+      return modification;
+    }
+  }
 }
index 83913fe416fb766698ce9bd4294819d48276905d..79aaa86b28baaa71f161dceca0d56f59528d94a1 100644 (file)
@@ -34,7 +34,7 @@ public class ShardTransactionChain extends UntypedActor{
   public void onReceive(Object message) throws Exception {
     if(message instanceof CreateTransaction){
       DOMStoreReadWriteTransaction transaction = chain.newReadWriteTransaction();
-      ActorRef transactionActor = getContext().actorOf(ShardTransaction.props(transaction));
+      ActorRef transactionActor = getContext().actorOf(ShardTransaction.props(transaction, getContext().parent()));
       getSender().tell(new CreateTransactionReply(transactionActor.path()), getSelf());
     } else if (message instanceof CloseTransactionChain){
       chain.close();
index 8e21cb2d86fc846d4923526024b62e0aff332f12..61baf1ab64421e04f76d52ec684709ca33f38d25 100644 (file)
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.actor.UntypedActor;
+import akka.event.Logging;
+import akka.event.LoggingAdapter;
 import akka.japi.Creator;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.cluster.datastore.messages.AbortTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.ForwardedCommitTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransactionReply;
+import org.opendaylight.controller.cluster.datastore.modification.CompositeModification;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
 
+import java.util.concurrent.ExecutionException;
+
 public class ThreePhaseCommitCohort extends UntypedActor{
   private final DOMStoreThreePhaseCommitCohort cohort;
+  private final ActorRef shardActor;
+  private final CompositeModification modification;
 
-  public ThreePhaseCommitCohort(DOMStoreThreePhaseCommitCohort cohort) {
-
+  public ThreePhaseCommitCohort(DOMStoreThreePhaseCommitCohort cohort, ActorRef shardActor, CompositeModification modification) {
     this.cohort = cohort;
+    this.shardActor = shardActor;
+    this.modification = modification;
   }
 
-  @Override
-  public void onReceive(Object message) throws Exception {
-    throw new UnsupportedOperationException("onReceive");
-  }
+  private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
 
-  public static Props props(final DOMStoreThreePhaseCommitCohort cohort) {
+  public static Props props(final DOMStoreThreePhaseCommitCohort cohort, final ActorRef shardActor, final CompositeModification modification) {
     return Props.create(new Creator<ThreePhaseCommitCohort>(){
       @Override
       public ThreePhaseCommitCohort create() throws Exception {
-        return new ThreePhaseCommitCohort(cohort);
+        return new ThreePhaseCommitCohort(cohort, shardActor, modification);
       }
     });
   }
+
+  @Override
+  public void onReceive(Object message) throws Exception {
+    if(message instanceof CanCommitTransaction){
+      canCommit((CanCommitTransaction) message);
+    } else if(message instanceof PreCommitTransaction) {
+      preCommit((PreCommitTransaction) message);
+    } else if(message instanceof CommitTransaction){
+      commit((CommitTransaction) message);
+    } else if (message instanceof AbortTransaction){
+      abort((AbortTransaction) message);
+    }
+  }
+
+  private void abort(AbortTransaction message) {
+    final ListenableFuture<Void> future = cohort.abort();
+    final ActorRef sender = getSender();
+    final ActorRef self = getSelf();
+
+    future.addListener(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          future.get();
+          sender.tell(new AbortTransactionReply(), self);
+        } catch (InterruptedException | ExecutionException e) {
+          log.error(e, "An exception happened when aborting");
+        }
+      }
+    }, getContext().dispatcher());
+  }
+
+  private void commit(CommitTransaction message) {
+    // Forward the commit to the shard
+    log.info("Commit transaction now + " + shardActor);
+    shardActor.forward(new ForwardedCommitTransaction(cohort, modification), getContext());
+
+  }
+
+  private void preCommit(PreCommitTransaction message) {
+    final ListenableFuture<Void> future = cohort.preCommit();
+    final ActorRef sender = getSender();
+    final ActorRef self = getSelf();
+
+    future.addListener(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          future.get();
+          sender.tell(new PreCommitTransactionReply(), self);
+        } catch (InterruptedException | ExecutionException e) {
+          log.error(e, "An exception happened when preCommitting");
+        }
+      }
+    }, getContext().dispatcher());
+
+  }
+
+  private void canCommit(CanCommitTransaction message) {
+    final ListenableFuture<Boolean> future = cohort.canCommit();
+    final ActorRef sender = getSender();
+    final ActorRef self = getSelf();
+
+    future.addListener(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          Boolean canCommit = future.get();
+          sender.tell(new CanCommitTransactionReply(canCommit), self);
+        } catch (InterruptedException | ExecutionException e) {
+          log.error(e, "An exception happened when aborting");
+        }
+      }
+    }, getContext().dispatcher());
+
+  }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
new file mode 100644 (file)
index 0000000..197b3b7
--- /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.cluster.datastore;
+
+import akka.actor.ActorPath;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * ThreePhaseCommitCohortProxy represents a set of remote cohort proxies
+ */
+public class ThreePhaseCommitCohortProxy implements
+    DOMStoreThreePhaseCommitCohort{
+
+    private final List<ActorPath> cohortPaths;
+
+    public ThreePhaseCommitCohortProxy(List<ActorPath> cohortPaths) {
+
+        this.cohortPaths = cohortPaths;
+    }
+
+    @Override public ListenableFuture<Boolean> canCommit() {
+        throw new UnsupportedOperationException("canCommit");
+    }
+
+    @Override public ListenableFuture<Void> preCommit() {
+        throw new UnsupportedOperationException("preCommit");
+    }
+
+    @Override public ListenableFuture<Void> abort() {
+        throw new UnsupportedOperationException("abort");
+    }
+
+    @Override public ListenableFuture<Void> commit() {
+        throw new UnsupportedOperationException("commit");
+    }
+
+    public List<ActorPath> getCohortPaths() {
+        return Collections.unmodifiableList(this.cohortPaths);
+    }
+}
index 1ee0d89e6116837a1733848aae5f85e1cf02cd34..837ffc1b51dd8c5b2a80a3cf2f71a1076406648d 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.cluster.datastore;
 
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
@@ -17,23 +18,32 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
  * TransactionChainProxy acts as a proxy for a DOMStoreTransactionChain created on a remote shard
  */
 public class TransactionChainProxy implements DOMStoreTransactionChain{
+    private final ActorContext actorContext;
+
+    public TransactionChainProxy(ActorContext actorContext) {
+        this.actorContext = actorContext;
+    }
+
     @Override
     public DOMStoreReadTransaction newReadOnlyTransaction() {
-        throw new UnsupportedOperationException("newReadOnlyTransaction");
+        return new TransactionProxy(actorContext,
+            TransactionProxy.TransactionType.READ_ONLY);
     }
 
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
-        throw new UnsupportedOperationException("newReadWriteTransaction");
+        return new TransactionProxy(actorContext,
+            TransactionProxy.TransactionType.WRITE_ONLY);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
-        throw new UnsupportedOperationException("newWriteOnlyTransaction");
+        return new TransactionProxy(actorContext,
+            TransactionProxy.TransactionType.READ_WRITE);
     }
 
     @Override
     public void close() {
-        throw new UnsupportedOperationException("close");
+        throw new UnsupportedOperationException("close - not sure what to do here?");
     }
 }
index 609dea0b360819ebc576e636e2237b8cb9868172..32bb7d0951964975b850c8a1a685ce7d95c03f47 100644 (file)
 
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorPath;
+import akka.actor.ActorSelection;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListenableFutureTask;
+import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
+import org.opendaylight.controller.cluster.datastore.messages.MergeData;
+import org.opendaylight.controller.cluster.datastore.messages.ReadData;
+import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
+import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.WriteData;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
  * TransactionProxy acts as a proxy for one or more transactions that were created on a remote shard
- *
+ * <p>
  * Creating a transaction on the consumer side will create one instance of a transaction proxy. If during
  * the transaction reads and writes are done on data that belongs to different shards then a separate transaction will
  * be created on each of those shards by the TransactionProxy
- *
+ *</p>
+ * <p>
  * The TransactionProxy does not make any guarantees about atomicity or order in which the transactions on the various
  * shards will be executed.
- *
+ * </p>
  */
 public class TransactionProxy implements DOMStoreReadWriteTransaction {
+
+    public enum TransactionType {
+        READ_ONLY,
+        WRITE_ONLY,
+        READ_WRITE
+    }
+
+    private static final AtomicLong counter = new AtomicLong();
+
+    private final TransactionType readOnly;
+    private final ActorContext actorContext;
+    private final Map<String, ActorSelection> remoteTransactionPaths = new HashMap<>();
+    private final String identifier;
+
+    public TransactionProxy(
+        ActorContext actorContext,
+        TransactionType readOnly) {
+
+        this.identifier = "transaction-" + counter.getAndIncrement();
+        this.readOnly = readOnly;
+        this.actorContext = actorContext;
+
+        Object response = actorContext.executeShardOperation(Shard.DEFAULT_NAME, new CreateTransaction(), ActorContext.ASK_DURATION);
+        if(response instanceof CreateTransactionReply){
+            CreateTransactionReply reply = (CreateTransactionReply) response;
+            remoteTransactionPaths.put(Shard.DEFAULT_NAME, actorContext.actorSelection(reply.getTransactionPath()));
+        }
+    }
+
     @Override
-    public ListenableFuture<Optional<NormalizedNode<?, ?>>> read(InstanceIdentifier path) {
-        throw new UnsupportedOperationException("read");
+    public ListenableFuture<Optional<NormalizedNode<?, ?>>> read(final InstanceIdentifier path) {
+        final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
+
+        Callable<Optional<NormalizedNode<?,?>>> call = new Callable() {
+
+            @Override public Optional<NormalizedNode<?,?>> call() throws Exception {
+                Object response = actorContext
+                    .executeRemoteOperation(remoteTransaction, new ReadData(path),
+                        ActorContext.ASK_DURATION);
+                if(response instanceof ReadDataReply){
+                    ReadDataReply reply = (ReadDataReply) response;
+                    //FIXME : A cast should not be required here ???
+                    return (Optional<NormalizedNode<?, ?>>) Optional.of(reply.getNormalizedNode());
+                }
+
+                return Optional.absent();
+            }
+        };
+
+        ListenableFutureTask<Optional<NormalizedNode<?, ?>>>
+            future = ListenableFutureTask.create(call);
+
+        //FIXME : Use a thread pool here
+        Executors.newSingleThreadExecutor().submit(future);
+
+        return future;
     }
 
     @Override
     public void write(InstanceIdentifier path, NormalizedNode<?, ?> data) {
-        throw new UnsupportedOperationException("write");
+        final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
+        remoteTransaction.tell(new WriteData(path, data), null);
     }
 
     @Override
     public void merge(InstanceIdentifier path, NormalizedNode<?, ?> data) {
-        throw new UnsupportedOperationException("merge");
+        final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
+        remoteTransaction.tell(new MergeData(path, data), null);
     }
 
     @Override
     public void delete(InstanceIdentifier path) {
-        throw new UnsupportedOperationException("delete");
+        final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
+        remoteTransaction.tell(new DeleteData(path), null);
     }
 
     @Override
     public DOMStoreThreePhaseCommitCohort ready() {
-        throw new UnsupportedOperationException("ready");
+        List<ActorPath> cohortPaths = new ArrayList<>();
+
+        for(ActorSelection remoteTransaction : remoteTransactionPaths.values()) {
+            Object result = actorContext.executeRemoteOperation(remoteTransaction,
+                new ReadyTransaction(),
+                ActorContext.ASK_DURATION
+            );
+
+            if(result instanceof ReadyTransactionReply){
+                ReadyTransactionReply reply = (ReadyTransactionReply) result;
+                cohortPaths.add(reply.getCohortPath());
+            }
+        }
+
+        return new ThreePhaseCommitCohortProxy(cohortPaths);
     }
 
     @Override
     public Object getIdentifier() {
-        throw new UnsupportedOperationException("getIdentifier");
+        return this.identifier;
     }
 
     @Override
     public void close() {
-        throw new UnsupportedOperationException("close");
+        for(ActorSelection remoteTransaction : remoteTransactionPaths.values()) {
+            remoteTransaction.tell(new CloseTransaction(), null);
+        }
+    }
+
+    private ActorSelection remoteTransactionFromIdentifier(InstanceIdentifier path){
+        String shardName = shardNameFromIdentifier(path);
+        return remoteTransactionPaths.get(shardName);
+    }
+
+    private String shardNameFromIdentifier(InstanceIdentifier path){
+        return Shard.DEFAULT_NAME;
     }
 }
@@ -1,13 +1,12 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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.connector.remoterpc;
-
-public interface RemoteRpcServer extends AutoCloseable {
+package org.opendaylight.controller.cluster.datastore.messages;
 
+public class AbortTransaction {
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbortTransactionReply.java
new file mode 100644 (file)
index 0000000..84234e5
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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;
+
+public class AbortTransactionReply {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransaction.java
new file mode 100644 (file)
index 0000000..526d60f
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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;
+
+public class CanCommitTransaction {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CanCommitTransactionReply.java
new file mode 100644 (file)
index 0000000..d143c14
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+public class CanCommitTransactionReply {
+  private final Boolean canCommit;
+
+  public CanCommitTransactionReply(Boolean canCommit) {
+    this.canCommit = canCommit;
+  }
+
+  public Boolean getCanCommit() {
+    return canCommit;
+  }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransaction.java
new file mode 100644 (file)
index 0000000..d7b210f
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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;
+
+public class CommitTransaction {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CommitTransactionReply.java
new file mode 100644 (file)
index 0000000..a0e5e89
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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;
+
+public class CommitTransactionReply {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ForwardedCommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ForwardedCommitTransaction.java
new file mode 100644 (file)
index 0000000..0104993
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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 org.opendaylight.controller.cluster.datastore.modification.Modification;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+
+public class ForwardedCommitTransaction {
+  private final DOMStoreThreePhaseCommitCohort cohort;
+  private final Modification modification;
+
+  public ForwardedCommitTransaction(DOMStoreThreePhaseCommitCohort cohort, Modification modification){
+    this.cohort = cohort;
+    this.modification = modification;
+  }
+
+  public DOMStoreThreePhaseCommitCohort getCohort() {
+    return cohort;
+  }
+
+  public Modification getModification() {
+    return modification;
+  }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransaction.java
new file mode 100644 (file)
index 0000000..87a9c77
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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;
+
+public class PreCommitTransaction {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PreCommitTransactionReply.java
new file mode 100644 (file)
index 0000000..f499c72
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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;
+
+public class PreCommitTransactionReply {
+}
index 1326898b0f4059ef215c34d8b175306a1b2a8c9a..d6aae3786fc3e4f1e08eda17c168345c83073dc9 100644 (file)
@@ -9,4 +9,39 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 public class PrimaryFound {
+  private final String primaryPath;
+
+  public PrimaryFound(String primaryPath) {
+    this.primaryPath = primaryPath;
+  }
+
+  public String getPrimaryPath() {
+    return primaryPath;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    PrimaryFound that = (PrimaryFound) o;
+
+    if (!primaryPath.equals(that.primaryPath)) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return primaryPath.hashCode();
+  }
+
+  @Override
+  public String toString() {
+    return "PrimaryFound{" +
+            "primaryPath='" + primaryPath + '\'' +
+            '}';
+  }
+
+
 }
index 48565d4fbb5b8847b1c90beea6ce7ca964b00256..32d31bf84db44e87a4ebbbd6328c97c3898fd9ae 100644 (file)
@@ -11,14 +11,14 @@ package org.opendaylight.controller.cluster.datastore.messages;
 import akka.actor.ActorPath;
 
 public class ReadyTransactionReply {
-  private final ActorPath path;
+  private final ActorPath cohortPath;
 
-  public ReadyTransactionReply(ActorPath path) {
+  public ReadyTransactionReply(ActorPath cohortPath) {
 
-    this.path = path;
+    this.cohortPath = cohortPath;
   }
 
-  public ActorPath getPath() {
-    return path;
+  public ActorPath getCohortPath() {
+    return cohortPath;
   }
 }
index 0123a701471e29ef5a81ad41dc3fb2304e4cbf62..7c9e4f0665a2710e2ed4b28f4792e6a043a48800 100644 (file)
@@ -8,32 +8,34 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
+import akka.actor.ActorPath;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 public class RegisterChangeListener {
-  private final InstanceIdentifier path;
-  private final AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>> listener;
-  private final AsyncDataBroker.DataChangeScope scope;
+    private final InstanceIdentifier path;
+    private final ActorPath dataChangeListenerPath;
+    private final AsyncDataBroker.DataChangeScope scope;
 
 
-  public RegisterChangeListener(InstanceIdentifier path, AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>> listener, AsyncDataBroker.DataChangeScope scope) {
-    this.path = path;
-    this.listener = listener;
-    this.scope = scope;
-  }
+    public RegisterChangeListener(InstanceIdentifier path,
+        ActorPath dataChangeListenerPath,
+        AsyncDataBroker.DataChangeScope scope) {
+        this.path = path;
+        this.dataChangeListenerPath = dataChangeListenerPath;
+        this.scope = scope;
+    }
 
-  public InstanceIdentifier getPath() {
-    return path;
-  }
+    public InstanceIdentifier getPath() {
+        return path;
+    }
 
-  public AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>> getListener() {
-    return listener;
-  }
 
-  public AsyncDataBroker.DataChangeScope getScope() {
-    return scope;
-  }
+    public AsyncDataBroker.DataChangeScope getScope() {
+        return scope;
+    }
+
+    public ActorPath getDataChangeListenerPath() {
+        return dataChangeListenerPath;
+    }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModification.java
new file mode 100644 (file)
index 0000000..5d9f962
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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.modification;
+
+
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+import java.io.Serializable;
+
+/**
+ * Base class to be used for all simple modifications that can be applied to a DOMStoreTransaction
+ */
+public abstract class AbstractModification implements Modification,
+    Serializable {
+
+    private static final long serialVersionUID = 1638042650152084457L;
+
+    protected final InstanceIdentifier path;
+
+    protected AbstractModification(InstanceIdentifier path) {
+        this.path = path;
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java
new file mode 100644 (file)
index 0000000..4c856d3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.modification;
+
+import java.util.List;
+
+/**
+ * CompositeModification contains a list of modifications that need to be applied to the DOMStore
+ * <p>
+ * A CompositeModification gets stored in the transaction log for a Shard. During recovery when the transaction log
+ * is being replayed a DOMStoreWriteTransaction could be created and a CompositeModification could be applied to it.
+ * </p>
+ */
+public interface CompositeModification extends Modification {
+    /**
+     * Get a list of Modifications contained by this Composite
+     * @return
+     */
+    List<Modification> getModifications();
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
new file mode 100644 (file)
index 0000000..063ec3e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.modification;
+
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+/**
+ * DeleteModification store all the parameters required to delete a path from the data tree
+ */
+public class DeleteModification extends AbstractModification {
+  public DeleteModification(InstanceIdentifier path) {
+    super(path);
+  }
+
+  @Override
+  public void apply(DOMStoreWriteTransaction transaction) {
+    transaction.delete(path);
+  }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/ImmutableCompositeModification.java
new file mode 100644 (file)
index 0000000..5a15d76
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.modification;
+
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+
+import java.util.List;
+
+public class ImmutableCompositeModification implements CompositeModification{
+
+  private final CompositeModification modification;
+
+  public ImmutableCompositeModification(CompositeModification modification){
+    this.modification = modification;
+  }
+
+  @Override
+  public List<Modification> getModifications() {
+    return modification.getModifications();
+  }
+
+  @Override
+  public void apply(DOMStoreWriteTransaction transaction) {
+    modification.apply(transaction);
+  }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
new file mode 100644 (file)
index 0000000..0457a78
--- /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.cluster.datastore.modification;
+
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * MergeModification stores all the parameters required to merge data into the specified path
+ */
+public class MergeModification extends AbstractModification{
+  private final NormalizedNode data;
+
+
+  public MergeModification(InstanceIdentifier path, NormalizedNode data) {
+    super(path);
+    this.data = data;
+  }
+
+  @Override
+  public void apply(DOMStoreWriteTransaction transaction) {
+    transaction.merge(path, data);
+  }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java
new file mode 100644 (file)
index 0000000..60dbf0f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.modification;
+
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+
+/**
+ * Represents a modification to the data store.
+ * <p>
+ * Simple modifications can be of type,
+ * <li> {@link org.opendaylight.controller.cluster.datastore.modification.WriteModification}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.modification.MergeModification}
+ * <li> {@link org.opendaylight.controller.cluster.datastore.modification.DeleteModification}
+ * </p>
+ *
+ * <p>
+ * Modifications can in turn be lumped into a single {@link org.opendaylight.controller.cluster.datastore.modification.CompositeModification}
+ * which can then be applied to a write transaction
+ * </p>
+ */
+public interface Modification {
+  /**
+   * Apply the modification to the specified transaction
+   * @param transaction
+   */
+  void apply(DOMStoreWriteTransaction transaction);
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
new file mode 100644 (file)
index 0000000..9f37ba4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.modification;
+
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * MutableCompositeModification is just a mutable version of a
+ * CompositeModification {@link org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification#addModification(Modification)}
+ */
+public class MutableCompositeModification
+    implements CompositeModification, Serializable {
+
+    private static final long serialVersionUID = 1163377899140186790L;
+
+    private final List<Modification> modifications = new ArrayList<>();
+
+    @Override
+    public void apply(DOMStoreWriteTransaction transaction) {
+        for (Modification modification : modifications) {
+            modification.apply(transaction);
+        }
+    }
+
+    /**
+     * Add a new Modification to the list of Modifications represented by this
+     * composite
+     *
+     * @param modification
+     */
+    public void addModification(Modification modification) {
+        modifications.add(modification);
+    }
+
+    public List<Modification> getModifications() {
+        return Collections.unmodifiableList(modifications);
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
new file mode 100644 (file)
index 0000000..1b2a87f
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.modification;
+
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * WriteModification stores all the parameters required to write data to the specified path
+ */
+public class WriteModification extends AbstractModification {
+
+  private final NormalizedNode data;
+
+  public WriteModification(InstanceIdentifier path, NormalizedNode data) {
+    super(path);
+    this.data = data;
+  }
+
+  @Override
+  public void apply(DOMStoreWriteTransaction transaction) {
+    transaction.write(path, data);
+  }
+
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
new file mode 100644 (file)
index 0000000..ba4d4de
--- /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.cluster.datastore.utils;
+
+import akka.actor.ActorPath;
+import akka.actor.ActorRef;
+import akka.actor.ActorSelection;
+import akka.actor.ActorSystem;
+import akka.util.Timeout;
+import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
+import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import scala.concurrent.Await;
+import scala.concurrent.Future;
+import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
+
+import java.util.concurrent.TimeUnit;
+
+import static akka.pattern.Patterns.ask;
+
+/**
+ * The ActorContext class contains utility methods which could be used by
+ * non-actors (like DistributedDataStore) to work with actors a little more
+ * easily. An ActorContext can be freely passed around to local object instances
+ * but should not be passed to actors especially remote actors
+ */
+public class ActorContext {
+    private static final Logger
+        LOG = LoggerFactory.getLogger(ActorContext.class);
+
+    public static final FiniteDuration ASK_DURATION = Duration.create(5, TimeUnit.SECONDS);
+    public static final Duration AWAIT_DURATION = Duration.create(5, TimeUnit.SECONDS);
+
+    private final ActorSystem actorSystem;
+    private final ActorRef shardManager;
+
+    public ActorContext(ActorSystem actorSystem, ActorRef shardManager){
+        this.actorSystem = actorSystem;
+        this.shardManager = shardManager;
+    }
+
+    public ActorSystem getActorSystem() {
+        return actorSystem;
+    }
+
+    public ActorRef getShardManager() {
+        return shardManager;
+    }
+
+    public ActorSelection actorSelection(String actorPath){
+        return actorSystem.actorSelection(actorPath);
+    }
+
+    public ActorSelection actorSelection(ActorPath actorPath){
+        return actorSystem.actorSelection(actorPath);
+    }
+
+
+    /**
+     * Finds the primary for a given shard
+     *
+     * @param shardName
+     * @return
+     */
+    public ActorSelection findPrimary(String shardName) {
+        Object result = executeLocalOperation(shardManager,
+            new FindPrimary(shardName), ASK_DURATION);
+
+        if(result instanceof PrimaryFound){
+            PrimaryFound found = (PrimaryFound) result;
+
+            LOG.error("Primary found {}", found.getPrimaryPath());
+
+            return actorSystem.actorSelection(found.getPrimaryPath());
+        }
+        throw new RuntimeException("primary was not found");
+    }
+
+    /**
+     * Executes an operation on a local actor and wait for it's response
+     * @param actor
+     * @param message
+     * @param duration
+     * @return The response of the operation
+     */
+    public Object executeLocalOperation(ActorRef actor, Object message,
+        FiniteDuration duration){
+        Future<Object> future =
+            ask(actor, message, new Timeout(duration));
+
+        try {
+            return Await.result(future, AWAIT_DURATION);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Execute an operation on a remote actor and wait for it's response
+     * @param actor
+     * @param message
+     * @param duration
+     * @return
+     */
+    public Object executeRemoteOperation(ActorSelection actor, Object message,
+        FiniteDuration duration){
+        Future<Object> future =
+            ask(actor, message, new Timeout(duration));
+
+        try {
+            return Await.result(future, AWAIT_DURATION);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * 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
+     * @param duration
+     * @throws java.lang.RuntimeException when a primary is not found or if the message to the remote shard fails or times out
+     *
+     * @return
+     */
+    public Object executeShardOperation(String shardName, Object message, FiniteDuration duration){
+        ActorSelection primary = findPrimary(shardName);
+
+        return executeRemoteOperation(primary, message, duration);
+    }
+
+}
index 241bcb0a41654987835c249374c0c953d83e8814..3a78f93d8d18874e56386422771e322ac2d34581 100644 (file)
@@ -1,34 +1,36 @@
 package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
 
+import akka.actor.ActorSystem;
 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
 
 public class DistributedDataStoreProviderModule extends org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedDataStoreProviderModule {
-    public DistributedDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
+  public DistributedDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    super(identifier, dependencyResolver);
+  }
+
+  public DistributedDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedDataStoreProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+    super(identifier, dependencyResolver, oldModule, oldInstance);
+  }
+
+  @Override
+  public void customValidation() {
+    // add custom validation form module attributes here.
+  }
+
+  @Override
+  public java.lang.AutoCloseable createInstance() {
+    ActorSystem actorSystem = ActorSystem.create("opendaylight-cluster");
+    final DistributedDataStore configurationStore = new DistributedDataStore(actorSystem, "config");
+    final DistributedDataStore operationalStore = new DistributedDataStore(actorSystem, "operational");
+
+    final class AutoCloseableDistributedDataStore implements AutoCloseable {
+
+      @Override
+      public void close() throws Exception {
+      }
     }
 
-    public DistributedDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedDataStoreProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        new DistributedDataStore();
-
-        final class AutoCloseableDistributedDataStore implements AutoCloseable {
-
-            @Override
-            public void close() throws Exception {
-
-            }
-        }
-
-        return new AutoCloseableDistributedDataStore();
-    }
+    return new AutoCloseableDistributedDataStore();
+  }
 
 }
index 2fe7b69cc9b349548f9b44ea36f5d9a9adf1bc2c..45ef32f7ad798ad15a0840c1c7860bf61f34913d 100644 (file)
@@ -17,12 +17,12 @@ public abstract class AbstractActorTest {
   private static ActorSystem system;
 
   @BeforeClass
-  public static void setUp(){
+  public static void setUpClass(){
     system = ActorSystem.create("test");
   }
 
   @AfterClass
-  public static void tearDown(){
+  public static void tearDownClass(){
     JavaTestKit.shutdownActorSystem(system);
     system = null;
   }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java
new file mode 100644 (file)
index 0000000..8c3ec82
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * 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;
+
+import akka.actor.ActorPath;
+import akka.actor.ActorRef;
+import akka.actor.ActorSelection;
+import akka.actor.Props;
+import akka.testkit.JavaTestKit;
+import junit.framework.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChainReply;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.messages.WriteData;
+import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+
+public class BasicIntegrationTest extends AbstractActorTest {
+
+    @Test
+    public void integrationTest() {
+        // This test will
+        // - create a Shard
+        // - initiate a transaction
+        // - write something
+        // - read the transaction for commit
+        // - commit the transaction
+
+
+        new JavaTestKit(getSystem()) {{
+            final Props props = Shard.props("config");
+            final ActorRef shard = getSystem().actorOf(props);
+
+            new Within(duration("5 seconds")) {
+                protected void run() {
+
+                    shard.tell(
+                        new UpdateSchemaContext(TestModel.createTestContext()),
+                        getRef());
+
+                    shard.tell(new CreateTransactionChain(), getRef());
+
+                    final ActorSelection transactionChain =
+                        new ExpectMsg<ActorSelection>("match hint") {
+                            protected ActorSelection match(Object in) {
+                                if (in instanceof CreateTransactionChainReply) {
+                                    ActorPath transactionChainPath =
+                                        ((CreateTransactionChainReply) in)
+                                            .getTransactionChainPath();
+                                    return getSystem()
+                                        .actorSelection(transactionChainPath);
+                                } else {
+                                    throw noMatch();
+                                }
+                            }
+                        }.get(); // this extracts the received message
+
+                    Assert.assertNotNull(transactionChain);
+
+                    transactionChain.tell(new CreateTransaction(), getRef());
+
+                    final ActorSelection transaction =
+                        new ExpectMsg<ActorSelection>("match hint") {
+                            protected ActorSelection match(Object in) {
+                                if (in instanceof CreateTransactionReply) {
+                                    ActorPath transactionPath =
+                                        ((CreateTransactionReply) in)
+                                            .getTransactionPath();
+                                    return getSystem()
+                                        .actorSelection(transactionPath);
+                                } else {
+                                    throw noMatch();
+                                }
+                            }
+                        }.get(); // this extracts the received message
+
+                    Assert.assertNotNull(transaction);
+
+                    transaction.tell(new WriteData(TestModel.TEST_PATH,
+                        ImmutableNodes.containerNode(TestModel.TEST_QNAME)),
+                        getRef());
+
+                    Boolean writeDone = new ExpectMsg<Boolean>("match hint") {
+                        protected Boolean match(Object in) {
+                            if (in instanceof WriteDataReply) {
+                                return true;
+                            } else {
+                                throw noMatch();
+                            }
+                        }
+                    }.get(); // this extracts the received message
+
+                    Assert.assertTrue(writeDone);
+
+                    transaction.tell(new ReadyTransaction(), getRef());
+
+                    final ActorSelection cohort =
+                        new ExpectMsg<ActorSelection>("match hint") {
+                            protected ActorSelection match(Object in) {
+                                if (in instanceof ReadyTransactionReply) {
+                                    ActorPath cohortPath =
+                                        ((ReadyTransactionReply) in)
+                                            .getCohortPath();
+                                    return getSystem()
+                                        .actorSelection(cohortPath);
+                                } else {
+                                    throw noMatch();
+                                }
+                            }
+                        }.get(); // this extracts the received message
+
+                    Assert.assertNotNull(cohort);
+
+                    cohort.tell(new PreCommitTransaction(), getRef());
+
+                    Boolean preCommitDone =
+                        new ExpectMsg<Boolean>("match hint") {
+                            protected Boolean match(Object in) {
+                                if (in instanceof PreCommitTransactionReply) {
+                                    return true;
+                                } else {
+                                    throw noMatch();
+                                }
+                            }
+                        }.get(); // this extracts the received message
+
+                    Assert.assertTrue(preCommitDone);
+
+                    cohort.tell(new CommitTransaction(), getRef());
+
+                    final Boolean commitDone =
+                        new ExpectMsg<Boolean>("match hint") {
+                            protected Boolean match(Object in) {
+                                if (in instanceof CommitTransactionReply) {
+                                    return true;
+                                } else {
+                                    throw noMatch();
+                                }
+                            }
+                        }.get(); // this extracts the received message
+
+                    Assert.assertTrue(commitDone);
+
+                }
+
+
+            };
+        }};
+
+
+    }
+}
index 6544f3303022b698580d24f350073e5a79fa7b55..3a74a4ca7656dc01ae650d011595335474297de1 100644 (file)
@@ -1,6 +1,13 @@
 package org.opendaylight.controller.cluster.datastore;
 
+import akka.actor.ActorRef;
+import akka.actor.Props;
 import junit.framework.Assert;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
+import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor;
+import org.opendaylight.controller.cluster.datastore.utils.MockActorContext;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 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.AsyncDataChangeListener;
@@ -12,13 +19,27 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-public class DistributedDataStoreTest {
+public class DistributedDataStoreTest extends AbstractActorTest{
 
     private DistributedDataStore distributedDataStore;
+    private MockActorContext mockActorContext;
+    private ActorRef doNothingActorRef;
 
     @org.junit.Before
     public void setUp() throws Exception {
-        distributedDataStore = new DistributedDataStore();
+        final Props props = Props.create(DoNothingActor.class);
+
+        doNothingActorRef = getSystem().actorOf(props);
+
+        mockActorContext = new MockActorContext(getSystem(), doNothingActorRef);
+        distributedDataStore = new DistributedDataStore(mockActorContext, "config");
+        distributedDataStore.onGlobalContextUpdated(
+            TestModel.createTestContext());
+
+        // Make CreateTransactionReply as the default response. Will need to be
+        // tuned if a specific test requires some other response
+        mockActorContext.setExecuteShardOperationResponse(
+            new CreateTransactionReply(doNothingActorRef.path()));
     }
 
     @org.junit.After
@@ -28,8 +49,9 @@ public class DistributedDataStoreTest {
 
     @org.junit.Test
     public void testRegisterChangeListener() throws Exception {
+        mockActorContext.setExecuteShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path()));
         ListenerRegistration registration =
-                distributedDataStore.registerChangeListener(InstanceIdentifier.builder().build(), new AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>() {
+                distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>() {
             @Override
             public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> change) {
                 throw new UnsupportedOperationException("onDataChanged");
index 9c1ea70fdbc93a86e91b7ef2764392e23265aeba..fa436c16053bc42ad9835e7ecbccd1cb202fc4b8 100644 (file)
@@ -8,6 +8,7 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
+import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound;
 import scala.concurrent.duration.Duration;
 
@@ -26,17 +27,13 @@ public class ShardManagerTest {
     }
 
     @Test
-    public void testOnReceiveFindPrimary() throws Exception {
+    public void testOnReceiveFindPrimaryForNonExistentShard() throws Exception {
 
         new JavaTestKit(system) {{
-            final Props props = Props.create(ShardManager.class);
-            final TestActorRef<ShardManager> subject = TestActorRef.create(system, props, "test");
+            final Props props = ShardManager.props("config");
+            final TestActorRef<ShardManager> subject = TestActorRef.create(system, props);
 
-            // can also use JavaTestKit “from the outside”
-            final JavaTestKit probe = new JavaTestKit(system);
-
-            // the run() method needs to finish within 3 seconds
-            new Within(duration("3 seconds")) {
+            new Within(duration("1 seconds")) {
                 protected void run() {
 
                     subject.tell(new FindPrimary("inventory"), getRef());
@@ -49,4 +46,25 @@ public class ShardManagerTest {
             };
         }};
     }
+
+  @Test
+  public void testOnReceiveFindPrimaryForExistentShard() throws Exception {
+
+    new JavaTestKit(system) {{
+      final Props props = ShardManager.props("config");
+      final TestActorRef<ShardManager> subject = TestActorRef.create(system, props);
+
+      // the run() method needs to finish within 3 seconds
+      new Within(duration("1 seconds")) {
+        protected void run() {
+
+          subject.tell(new FindPrimary(Shard.DEFAULT_NAME), getRef());
+
+          expectMsgClass(PrimaryFound.class);
+
+          expectNoMsg();
+        }
+      };
+    }};
+  }
 }
\ No newline at end of file
index b5a341d95c950dd859e755d135be2c3354388dbc..48365fa1a06a90c87131ab6bda0e71db78595ee6 100644 (file)
@@ -22,7 +22,7 @@ public class ShardTest extends AbstractActorTest{
   @Test
   public void testOnReceiveCreateTransactionChain() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = Props.create(Shard.class);
+      final Props props = Shard.props("config");
       final ActorRef subject = getSystem().actorOf(props, "testCreateTransactionChain");
 
       new Within(duration("1 seconds")) {
@@ -55,7 +55,7 @@ public class ShardTest extends AbstractActorTest{
   @Test
   public void testOnReceiveRegisterListener() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = Props.create(Shard.class);
+      final Props props = Shard.props("config");
       final ActorRef subject = getSystem().actorOf(props, "testRegisterChangeListener");
 
       new Within(duration("1 seconds")) {
@@ -63,7 +63,7 @@ public class ShardTest extends AbstractActorTest{
 
           subject.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
 
-          subject.tell(new RegisterChangeListener(InstanceIdentifier.builder().build(), noOpDataChangeListener() , AsyncDataBroker.DataChangeScope.BASE), getRef());
+          subject.tell(new RegisterChangeListener(TestModel.TEST_PATH, getRef().path() , AsyncDataBroker.DataChangeScope.BASE), getRef());
 
           final String out = new ExpectMsg<String>("match hint") {
             // do not put code outside this method, will run afterwards
@@ -87,6 +87,8 @@ public class ShardTest extends AbstractActorTest{
     }};
   }
 
+
+
   private  AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>> noOpDataChangeListener(){
     return new AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>() {
       @Override
@@ -95,4 +97,4 @@ public class ShardTest extends AbstractActorTest{
       }
     };
   }
-}
\ No newline at end of file
+}
index 36633c55d590c023651a39e82feef8ba48d780d5..9116f24c92971b3f0491b6de52d07eff01d84645 100644 (file)
@@ -18,12 +18,18 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.WriteData;
 import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply;
+import org.opendaylight.controller.cluster.datastore.modification.CompositeModification;
+import org.opendaylight.controller.cluster.datastore.modification.DeleteModification;
+import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
+import org.opendaylight.controller.cluster.datastore.modification.Modification;
+import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class ShardTransactionTest extends AbstractActorTest {
   private static ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(MoreExecutors.sameThreadExecutor());
@@ -37,7 +43,8 @@ public class ShardTransactionTest extends AbstractActorTest {
   @Test
   public void testOnReceiveReadData() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = ShardTransaction.props(store.newReadWriteTransaction());
+      final ActorRef shard = getSystem().actorOf(Shard.props("config"));
+      final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard);
       final ActorRef subject = getSystem().actorOf(props, "testReadData");
 
       new Within(duration("1 seconds")) {
@@ -69,10 +76,36 @@ public class ShardTransactionTest extends AbstractActorTest {
     }};
   }
 
+  private void assertModification(final ActorRef subject, final Class<? extends Modification> modificationType){
+    new JavaTestKit(getSystem()) {{
+      new Within(duration("1 seconds")) {
+        protected void run() {
+          subject.tell(new ShardTransaction.GetCompositedModification(), getRef());
+
+          final CompositeModification compositeModification = new ExpectMsg<CompositeModification>("match hint") {
+            // do not put code outside this method, will run afterwards
+            protected CompositeModification match(Object in) {
+              if (in instanceof ShardTransaction.GetCompositeModificationReply) {
+                return ((ShardTransaction.GetCompositeModificationReply) in).getModification();
+              } else {
+                throw noMatch();
+              }
+            }
+          }.get(); // this extracts the received message
+
+          assertTrue(compositeModification.getModifications().size() == 1);
+          assertEquals(modificationType, compositeModification.getModifications().get(0).getClass());
+
+        }
+      };
+    }};
+  }
+
   @Test
   public void testOnReceiveWriteData() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = ShardTransaction.props(store.newReadWriteTransaction());
+      final ActorRef shard = getSystem().actorOf(Shard.props("config"));
+      final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard);
       final ActorRef subject = getSystem().actorOf(props, "testWriteData");
 
       new Within(duration("1 seconds")) {
@@ -93,6 +126,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
           assertEquals("match", out);
 
+          assertModification(subject, WriteModification.class);
           expectNoMsg();
         }
 
@@ -104,7 +138,8 @@ public class ShardTransactionTest extends AbstractActorTest {
   @Test
   public void testOnReceiveMergeData() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = ShardTransaction.props(store.newReadWriteTransaction());
+      final ActorRef shard = getSystem().actorOf(Shard.props("config"));
+      final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard);
       final ActorRef subject = getSystem().actorOf(props, "testMergeData");
 
       new Within(duration("1 seconds")) {
@@ -125,6 +160,8 @@ public class ShardTransactionTest extends AbstractActorTest {
 
           assertEquals("match", out);
 
+          assertModification(subject, MergeModification.class);
+
           expectNoMsg();
         }
 
@@ -136,7 +173,8 @@ public class ShardTransactionTest extends AbstractActorTest {
   @Test
   public void testOnReceiveDeleteData() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = ShardTransaction.props(store.newReadWriteTransaction());
+      final ActorRef shard = getSystem().actorOf(Shard.props("config"));
+      final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard);
       final ActorRef subject = getSystem().actorOf(props, "testDeleteData");
 
       new Within(duration("1 seconds")) {
@@ -157,6 +195,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
           assertEquals("match", out);
 
+          assertModification(subject, DeleteModification.class);
           expectNoMsg();
         }
 
@@ -169,7 +208,8 @@ public class ShardTransactionTest extends AbstractActorTest {
   @Test
   public void testOnReceiveReadyTransaction() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = ShardTransaction.props(store.newReadWriteTransaction());
+      final ActorRef shard = getSystem().actorOf(Shard.props("config"));
+      final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard);
       final ActorRef subject = getSystem().actorOf(props, "testReadyTransaction");
 
       new Within(duration("1 seconds")) {
@@ -202,7 +242,8 @@ public class ShardTransactionTest extends AbstractActorTest {
   @Test
   public void testOnReceiveCloseTransaction() throws Exception {
     new JavaTestKit(getSystem()) {{
-      final Props props = ShardTransaction.props(store.newReadWriteTransaction());
+      final ActorRef shard = getSystem().actorOf(Shard.props("config"));
+      final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard);
       final ActorRef subject = getSystem().actorOf(props, "testCloseTransaction");
 
       new Within(duration("1 seconds")) {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
new file mode 100644 (file)
index 0000000..6d057a4
--- /dev/null
@@ -0,0 +1,225 @@
+package org.opendaylight.controller.cluster.datastore;
+
+import akka.actor.ActorRef;
+import akka.actor.Props;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+import junit.framework.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
+import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.DeleteData;
+import org.opendaylight.controller.cluster.datastore.messages.MergeData;
+import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
+import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
+import org.opendaylight.controller.cluster.datastore.messages.WriteData;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor;
+import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor;
+import org.opendaylight.controller.cluster.datastore.utils.MockActorContext;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+
+import java.util.List;
+
+public class TransactionProxyTest extends AbstractActorTest {
+
+    @Test
+    public void testRead() throws Exception {
+        final Props props = Props.create(DoNothingActor.class);
+        final ActorRef actorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(new CreateTransactionReply(actorRef.path()));
+        actorContext.setExecuteRemoteOperationResponse("message");
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+
+        ListenableFuture<Optional<NormalizedNode<?, ?>>> read =
+            transactionProxy.read(TestModel.TEST_PATH);
+
+        Optional<NormalizedNode<?, ?>> normalizedNodeOptional = read.get();
+
+        Assert.assertFalse(normalizedNodeOptional.isPresent());
+
+        actorContext.setExecuteRemoteOperationResponse(new ReadDataReply(
+            ImmutableNodes.containerNode(TestModel.TEST_QNAME)));
+
+        read = transactionProxy.read(TestModel.TEST_PATH);
+
+        normalizedNodeOptional = read.get();
+
+        Assert.assertTrue(normalizedNodeOptional.isPresent());
+    }
+
+    @Test
+    public void testWrite() throws Exception {
+        final Props props = Props.create(MessageCollectorActor.class);
+        final ActorRef actorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(new CreateTransactionReply(actorRef.path()));
+        actorContext.setExecuteRemoteOperationResponse("message");
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+        transactionProxy.write(TestModel.TEST_PATH,
+            ImmutableNodes.containerNode(TestModel.NAME_QNAME));
+
+        ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)));
+        Object messages = testContext
+            .executeLocalOperation(actorRef, "messages",
+                ActorContext.ASK_DURATION);
+
+        Assert.assertNotNull(messages);
+
+        Assert.assertTrue(messages instanceof List);
+
+        List<Object> listMessages = (List<Object>) messages;
+
+        Assert.assertEquals(1, listMessages.size());
+
+        Assert.assertTrue(listMessages.get(0) instanceof WriteData);
+    }
+
+    @Test
+    public void testMerge() throws Exception {
+        final Props props = Props.create(MessageCollectorActor.class);
+        final ActorRef actorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(new CreateTransactionReply(actorRef.path()));
+        actorContext.setExecuteRemoteOperationResponse("message");
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+        transactionProxy.merge(TestModel.TEST_PATH,
+            ImmutableNodes.containerNode(TestModel.NAME_QNAME));
+
+        ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)));
+        Object messages = testContext
+            .executeLocalOperation(actorRef, "messages",
+                ActorContext.ASK_DURATION);
+
+        Assert.assertNotNull(messages);
+
+        Assert.assertTrue(messages instanceof List);
+
+        List<Object> listMessages = (List<Object>) messages;
+
+        Assert.assertEquals(1, listMessages.size());
+
+        Assert.assertTrue(listMessages.get(0) instanceof MergeData);
+    }
+
+    @Test
+    public void testDelete() throws Exception {
+        final Props props = Props.create(MessageCollectorActor.class);
+        final ActorRef actorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(new CreateTransactionReply(actorRef.path()));
+        actorContext.setExecuteRemoteOperationResponse("message");
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+        transactionProxy.delete(TestModel.TEST_PATH);
+
+        ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)));
+        Object messages = testContext
+            .executeLocalOperation(actorRef, "messages",
+                ActorContext.ASK_DURATION);
+
+        Assert.assertNotNull(messages);
+
+        Assert.assertTrue(messages instanceof List);
+
+        List<Object> listMessages = (List<Object>) messages;
+
+        Assert.assertEquals(1, listMessages.size());
+
+        Assert.assertTrue(listMessages.get(0) instanceof DeleteData);
+    }
+
+    @Test
+    public void testReady() throws Exception {
+        final Props props = Props.create(DoNothingActor.class);
+        final ActorRef doNothingActorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(new CreateTransactionReply(doNothingActorRef.path()));
+        actorContext.setExecuteRemoteOperationResponse(new ReadyTransactionReply(doNothingActorRef.path()));
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+
+        DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
+
+        Assert.assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
+
+        ThreePhaseCommitCohortProxy proxy = (ThreePhaseCommitCohortProxy) ready;
+
+        Assert.assertTrue("No cohort paths returned", proxy.getCohortPaths().size() > 0);
+
+    }
+
+    @Test
+    public void testGetIdentifier(){
+        final Props props = Props.create(DoNothingActor.class);
+        final ActorRef doNothingActorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(
+            new CreateTransactionReply(doNothingActorRef.path()));
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+        Assert.assertNotNull(transactionProxy.getIdentifier());
+    }
+
+    @Test
+    public void testClose(){
+        final Props props = Props.create(MessageCollectorActor.class);
+        final ActorRef actorRef = getSystem().actorOf(props);
+
+        final MockActorContext actorContext = new MockActorContext(this.getSystem());
+        actorContext.setExecuteShardOperationResponse(new CreateTransactionReply(actorRef.path()));
+        actorContext.setExecuteRemoteOperationResponse("message");
+
+        TransactionProxy transactionProxy =
+            new TransactionProxy(actorContext,
+                TransactionProxy.TransactionType.READ_ONLY);
+
+        transactionProxy.close();
+
+        ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)));
+        Object messages = testContext
+            .executeLocalOperation(actorRef, "messages",
+                ActorContext.ASK_DURATION);
+
+        Assert.assertNotNull(messages);
+
+        Assert.assertTrue(messages instanceof List);
+
+        List<Object> listMessages = (List<Object>) messages;
+
+        Assert.assertEquals(1, listMessages.size());
+
+        Assert.assertTrue(listMessages.get(0) instanceof CloseTransaction);
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java
new file mode 100644 (file)
index 0000000..efaca5d
--- /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.cluster.datastore.modification;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.junit.Before;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public abstract class AbstractModificationTest {
+
+  protected InMemoryDOMDataStore store;
+
+  @Before
+  public void setUp(){
+    store = new InMemoryDOMDataStore("test", MoreExecutors.sameThreadExecutor());
+    store.onGlobalContextUpdated(TestModel.createTestContext());
+  }
+
+  protected void commitTransaction(DOMStoreWriteTransaction transaction){
+    DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
+    cohort.preCommit();
+    cohort.commit();
+  }
+
+  protected Optional<NormalizedNode<?,?>> readData(InstanceIdentifier path) throws Exception{
+    DOMStoreReadTransaction transaction = store.newReadOnlyTransaction();
+    ListenableFuture<Optional<NormalizedNode<?, ?>>> future = transaction.read(path);
+    return future.get();
+  }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java
new file mode 100644 (file)
index 0000000..c1f9f3a
--- /dev/null
@@ -0,0 +1,35 @@
+package org.opendaylight.controller.cluster.datastore.modification;
+
+import com.google.common.base.Optional;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+
+public class DeleteModificationTest 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));
+    writeModification.apply(writeTransaction);
+    commitTransaction(writeTransaction);
+
+    //Check if it's in the datastore
+    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
+    Assert.assertTrue(data.isPresent());
+
+    //Delete stuff from the datastore
+    DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
+    DeleteModification deleteModification = new DeleteModification(TestModel.TEST_PATH);
+    deleteModification.apply(deleteTransaction);
+    commitTransaction(deleteTransaction);
+
+    data = readData(TestModel.TEST_PATH);
+    Assert.assertFalse(data.isPresent());
+  }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java
new file mode 100644 (file)
index 0000000..fd125fb
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.controller.cluster.datastore.modification;
+
+import com.google.common.base.Optional;
+import org.junit.Assert;
+import org.junit.Test;
+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;
+
+public class MergeModificationTest extends AbstractModificationTest{
+
+  @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));
+    writeModification.apply(writeTransaction);
+    commitTransaction(writeTransaction);
+
+    //Check if it's in the datastore
+    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
+    Assert.assertTrue(data.isPresent());
+
+  }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java
new file mode 100644 (file)
index 0000000..e30936b
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.controller.cluster.datastore.modification;
+
+import com.google.common.base.Optional;
+import junit.framework.Assert;
+import org.junit.Test;
+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;
+
+public class MutableCompositeModificationTest extends AbstractModificationTest {
+
+  @Test
+  public void testApply() throws Exception {
+
+    MutableCompositeModification compositeModification = new MutableCompositeModification();
+    compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)));
+
+    DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction();
+    compositeModification.apply(transaction);
+    commitTransaction(transaction);
+
+    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
+
+    Assert.assertNotNull(data.get());
+    Assert.assertEquals(TestModel.TEST_QNAME, data.get().getNodeType());
+  }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java
new file mode 100644 (file)
index 0000000..e206bf8
--- /dev/null
@@ -0,0 +1,26 @@
+package org.opendaylight.controller.cluster.datastore.modification;
+
+import com.google.common.base.Optional;
+import org.junit.Assert;
+import org.junit.Test;
+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;
+
+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));
+    writeModification.apply(writeTransaction);
+    commitTransaction(writeTransaction);
+
+    //Check if it's in the datastore
+    Optional<NormalizedNode<?,?>> data = readData(TestModel.TEST_PATH);
+    Assert.assertTrue(data.isPresent());
+
+  }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/DoNothingActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/DoNothingActor.java
new file mode 100644 (file)
index 0000000..819cfd0
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * 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.utils;
+
+import akka.actor.UntypedActor;
+
+public class DoNothingActor extends UntypedActor {
+
+    @Override public void onReceive(Object message) throws Exception {
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MessageCollectorActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MessageCollectorActor.java
new file mode 100644 (file)
index 0000000..f75aa54
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.utils;
+
+import akka.actor.UntypedActor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * MessageCollectorActor collects messages as it receives them. It can send
+ * those collected messages to any sender which sends it the "messages" message
+ * <p>
+ *     This class would be useful as a mock to test whether messages were sent
+ *     to a remote actor or not.
+ * </p>
+ */
+public class MessageCollectorActor extends UntypedActor {
+    private List<Object> messages = new ArrayList<>();
+
+    @Override public void onReceive(Object message) throws Exception {
+        if(message instanceof String){
+            if("messages".equals(message)){
+                getSender().tell(messages, getSelf());
+            }
+        } else {
+            messages.add(message);
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockActorContext.java
new file mode 100644 (file)
index 0000000..fe62516
--- /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.cluster.datastore.utils;
+
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSelection;
+import akka.actor.ActorSystem;
+import scala.concurrent.duration.FiniteDuration;
+
+public class MockActorContext extends ActorContext {
+
+    private Object executeShardOperationResponse;
+    private Object executeRemoteOperationResponse;
+    private Object executeLocalOperationResponse;
+
+    public MockActorContext(ActorSystem actorSystem) {
+        super(actorSystem, null);
+    }
+
+    public MockActorContext(ActorSystem actorSystem, ActorRef shardManager) {
+        super(actorSystem, shardManager);
+    }
+
+
+    @Override public Object executeShardOperation(String shardName,
+        Object message, FiniteDuration duration) {
+        return executeShardOperationResponse;
+    }
+
+    @Override public Object executeRemoteOperation(ActorSelection actor,
+        Object message, FiniteDuration duration) {
+        return executeRemoteOperationResponse;
+    }
+
+    @Override public ActorSelection findPrimary(String shardName) {
+        return null;
+    }
+
+    public void setExecuteShardOperationResponse(Object response){
+        executeShardOperationResponse = response;
+    }
+
+    public void setExecuteRemoteOperationResponse(Object response){
+        executeRemoteOperationResponse = response;
+    }
+
+    public void setExecuteLocalOperationResponse(
+        Object executeLocalOperationResponse) {
+        this.executeLocalOperationResponse = executeLocalOperationResponse;
+    }
+
+
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf
new file mode 100644 (file)
index 0000000..2647850
--- /dev/null
@@ -0,0 +1,11 @@
+akka {
+    actor {
+        serializers {
+          java = "akka.serialization.JavaSerializer"
+        }
+
+        serialization-bindings {
+            "org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification" = java
+        }
+    }
+}
\ No newline at end of file
index c120508f875acfc0f5710aaced9d699204307fbc..613cf1bfe24e1b31cf854d978c35c48ef11d96f3 100644 (file)
@@ -29,7 +29,7 @@ public interface DOMDataBroker extends
      * {@inheritDoc}
      */
     @Override
-    DOMDataReadTransaction newReadOnlyTransaction();
+    DOMDataReadOnlyTransaction newReadOnlyTransaction();
 
     /**
      * {@inheritDoc}
diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java
new file mode 100644 (file)
index 0000000..18fb988
--- /dev/null
@@ -0,0 +1,9 @@
+package org.opendaylight.controller.md.sal.dom.api;
+
+import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public interface DOMDataReadOnlyTransaction extends DOMDataReadTransaction, AsyncReadOnlyTransaction<InstanceIdentifier, NormalizedNode<?, ?>> {
+
+}
index b894911ffad8fcac128f38f743df5a3a6819ea30..73a0c28465108e951ddafdd6fa2639bd088f9ff1 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 public interface DOMTransactionChain extends TransactionChain<InstanceIdentifier, NormalizedNode<?, ?>> {
 
     @Override
-    DOMDataReadTransaction newReadOnlyTransaction();
+    DOMDataReadOnlyTransaction newReadOnlyTransaction();
 
     @Override
     DOMDataReadWriteTransaction newReadWriteTransaction();
index bac9146bf5395f29a7ce9c8fa733802b0cf42259..022882fcebd042404689f64abf2ed614894c3262 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-core-spi</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-inmemory-datastore</artifactId>
+      <version>1.1-SNAPSHOT</version>
+
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>util</artifactId>
@@ -88,8 +94,6 @@
                             org.opendaylight.controller.config.yang.md.sal.dom.statistics,
                             org.opendaylight.controller.md.sal.dom.broker.impl,
                             org.opendaylight.controller.md.sal.dom.broker.impl.*,
-                            org.opendaylight.controller.md.sal.dom.store.impl,
-                            org.opendaylight.controller.md.sal.dom.store.impl.*,
                             org.opendaylight.yangtools.yang.util,
                             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.dom.impl.rev131028.*</Private-Package>
             <Import-Package>*</Import-Package>
index ad0de54bc035bf49863ef350cdc045af2fd35f48..d3852d28c5ba1ff9d6191f135cbcaba0c88ad2b4 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.config.yang.md.sal.dom.impl;
 
-import java.util.Hashtable;
-import java.util.concurrent.Executors;
-
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 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;
@@ -17,9 +17,8 @@ import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
 import org.osgi.framework.BundleContext;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Hashtable;
+import java.util.concurrent.Executors;
 
 /**
 *
@@ -49,8 +48,22 @@ public final class DomInmemoryDataBrokerModule extends
     @Override
     public java.lang.AutoCloseable createInstance() {
         ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
-        InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor);
-        InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor);
+        //Initializing Operational DOM DataStore defaulting to InMemoryDOMDataStore if one is not configured
+        DOMStore operStore =  getOperationalDataStoreDependency();
+        if(operStore == null){
+           //we will default to InMemoryDOMDataStore creation
+          operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor);
+          //here we will register the SchemaContext listener
+          getSchemaServiceDependency().registerSchemaServiceListener((InMemoryDOMDataStore)operStore);
+        }
+
+        DOMStore configStore = getConfigDataStoreDependency();
+        if(configStore == null){
+           //we will default to InMemoryDOMDataStore creation
+           configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor);
+          //here we will register the SchemaContext listener
+          getSchemaServiceDependency().registerSchemaServiceListener((InMemoryDOMDataStore)configStore);
+        }
         ImmutableMap<LogicalDatastoreType, DOMStore> datastores = ImmutableMap
                 .<LogicalDatastoreType, DOMStore> builder().put(LogicalDatastoreType.OPERATIONAL, operStore)
                 .put(LogicalDatastoreType.CONFIGURATION, configStore).build();
@@ -59,8 +72,6 @@ public final class DomInmemoryDataBrokerModule extends
 
         getBundleContext().registerService(DOMDataBroker.class, newDataBroker, new Hashtable<String, String>());
 
-        getSchemaServiceDependency().registerSchemaServiceListener(operStore);
-        getSchemaServiceDependency().registerSchemaServiceListener(configStore);
 
         return newDataBroker;
     }
index 0c07b0684c9b9291344c8f55daadd7d3846ee4da..0be4327f7ae06231cd86814c62c724ddb16fd937 100644 (file)
@@ -75,8 +75,7 @@ abstract class AbstractDOMForwardedCompositeTransaction<K, T extends DOMStoreTra
         return identifier;
     }
 
-    @Override
-    public void close() {
+    protected void closeSubtransactions() {
         /*
          *  We share one exception for all failures, which are added
          *  as supressedExceptions to it.
index 2203087c997ce536485f5359b03ee85c56c1c568..5694d0bca9a68fccd5f31557418a8824b35d7a5a 100644 (file)
@@ -13,7 +13,7 @@ import java.util.Map.Entry;
 import javax.annotation.concurrent.GuardedBy;
 
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
@@ -66,7 +66,7 @@ public abstract class AbstractDOMForwardedTransactionFactory<T extends DOMStoreT
      *
      * Subtransaction for reading is selected by supplied
      * {@link LogicalDatastoreType} as parameter for
-     * {@link DOMDataReadTransaction#read(LogicalDatastoreType,org.opendaylight.yangtools.yang.data.api.InstanceIdentifier)}
+     * {@link DOMDataReadOnlyTransaction#read(LogicalDatastoreType,org.opendaylight.yangtools.yang.data.api.InstanceIdentifier)}
      * .
      *
      * Id of returned transaction is retrieved via
@@ -74,7 +74,7 @@ public abstract class AbstractDOMForwardedTransactionFactory<T extends DOMStoreT
      *
      * @return New composite read-only transaction.
      */
-    public DOMDataReadTransaction newReadOnlyTransaction() {
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
         checkNotClosed();
         ImmutableMap.Builder<LogicalDatastoreType, DOMStoreReadTransaction> builder = ImmutableMap.builder();
         for (Entry<LogicalDatastoreType, T> store : storeTxFactories.entrySet()) {
index d2543f02bc548be0430584d926a0ed372c6ccf55..f207783c29f7820e5e472b13359d90f8b92f39db 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -26,7 +26,7 @@ import com.google.common.util.concurrent.ListenableFuture;
  */
 class DOMForwardedReadOnlyTransaction extends
         AbstractDOMForwardedCompositeTransaction<LogicalDatastoreType, DOMStoreReadTransaction> implements
-        DOMDataReadTransaction {
+        DOMDataReadOnlyTransaction {
 
     protected DOMForwardedReadOnlyTransaction(final Object identifier,
             final ImmutableMap<LogicalDatastoreType, DOMStoreReadTransaction> backingTxs) {
@@ -39,4 +39,9 @@ class DOMForwardedReadOnlyTransaction extends
         return getSubtransaction(store).read(path);
     }
 
+    @Override
+    public void close() {
+        closeSubtransactions();
+    }
+
 }
index eeb345e9ce663e7340300f779ab789805be86a7f..f791522a2a77214e9a233f966801fac096948618 100644 (file)
@@ -50,13 +50,31 @@ import com.google.common.util.concurrent.ListenableFuture;
 class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
         AbstractDOMForwardedCompositeTransaction<LogicalDatastoreType, T> implements DOMDataWriteTransaction {
 
+    /**
+     *  Implementation of real commit.
+     *
+     *  Transaction can not be commited if commitImpl is null,
+     *  so this seting this property to null is also used to
+     *  prevent write to
+     *  already commited / canceled transaction {@link #checkNotCanceled()
+     *
+     *
+     */
     @GuardedBy("this")
-    private DOMDataCommitImplementation commitImpl;
-
-    @GuardedBy("this")
-    private boolean canceled;
+    private volatile DOMDataCommitImplementation commitImpl;
+
+    /**
+     *
+     * Future task of transaction commit.
+     *
+     * This value is initially null, and is once updated if transaction
+     * is commited {@link #commit()}.
+     * If this future exists, transaction MUST not be commited again
+     * and all modifications should fail. See {@link #checkNotCommited()}.
+     *
+     */
     @GuardedBy("this")
-    private ListenableFuture<RpcResult<TransactionStatus>> commitFuture;
+    private volatile ListenableFuture<RpcResult<TransactionStatus>> commitFuture;
 
     protected DOMForwardedWriteTransaction(final Object identifier,
             final ImmutableMap<LogicalDatastoreType, T> backingTxs, final DOMDataCommitImplementation commitImpl) {
@@ -83,15 +101,19 @@ class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
     }
 
     @Override
-    public synchronized void cancel() {
-        checkState(!canceled, "Transaction was canceled.");
-        if (commitFuture != null) {
-            // FIXME: Implement cancelation of commit future
-            // when Broker impl will support cancelation.
-            throw new UnsupportedOperationException("Not implemented yet.");
+    public synchronized boolean cancel() {
+        // Transaction is already canceled, we are safe to return true
+        final boolean cancelationResult;
+        if (commitImpl == null && commitFuture != null) {
+            // Transaction is submitted, we try to cancel future.
+            cancelationResult = commitFuture.cancel(false);
+        } else if(commitImpl == null) {
+            return true;
+        } else {
+            cancelationResult = true;
+            commitImpl = null;
         }
-        canceled = true;
-        commitImpl = null;
+        return cancelationResult;
 
     }
 
@@ -105,20 +127,26 @@ class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
         }
         ImmutableList<DOMStoreThreePhaseCommitCohort> cohorts = cohortsBuilder.build();
         commitFuture = commitImpl.commit(this, cohorts);
+
+        /*
+         *We remove reference to Commit Implementation in order
+         *to prevent memory leak
+         */
+        commitImpl = null;
         return commitFuture;
     }
 
     private void checkNotReady() {
-        checkNotCanceled();
         checkNotCommited();
+        checkNotCanceled();
     }
 
     private void checkNotCanceled() {
-        Preconditions.checkState(!canceled, "Transaction was canceled.");
+        Preconditions.checkState(commitImpl != null, "Transaction was canceled.");
     }
 
     private void checkNotCommited() {
-        checkState(commitFuture == null, "Transaction was already commited.");
+        checkState(commitFuture == null, "Transaction was already submited.");
     }
 
 }
\ No newline at end of file
index 29f2af511e8b8bb03ab0921837b8acae80aa59a7..b3fb7b6da8be09d67c0b7244f50f99c093a8173b 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
@@ -55,10 +56,10 @@ public abstract class BackwardsCompatibleTransaction<T extends DOMDataReadTransa
         this.normalizer = normalizer;
     }
 
-    public static BackwardsCompatibleTransaction<?> readOnlyTransaction(final DOMDataReadTransaction readTx,
+    public static BackwardsCompatibleTransaction<?> readOnlyTransaction(final DOMDataReadOnlyTransaction readTx,
             final DataNormalizer normalizer) {
 
-        return new BackwardsCompatibleTransaction<DOMDataReadTransaction>(readTx, normalizer) {
+        return new BackwardsCompatibleTransaction<DOMDataReadOnlyTransaction>(readTx, normalizer) {
 
             @Override
             public TransactionStatus getStatus() {
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ConflictingModificationAppliedException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ConflictingModificationAppliedException.java
deleted file mode 100644 (file)
index 3625d33..0000000
+++ /dev/null
@@ -1,33 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-/**
- * Exception thrown when a proposed change fails validation before being
- * applied into the Data Tree because the Data Tree has been modified
- * in way that a conflicting
- * node is present.
- */
-public class ConflictingModificationAppliedException extends DataValidationFailedException {
-
-    /**
-     *
-     */
-    private static final long serialVersionUID = 1L;
-
-    public ConflictingModificationAppliedException(final InstanceIdentifier path, final String message, final Throwable cause) {
-        super(path, message, cause);
-    }
-
-    public ConflictingModificationAppliedException(final InstanceIdentifier path, final String message) {
-        super(path, message);
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTree.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTree.java
deleted file mode 100644 (file)
index 4807e15..0000000
+++ /dev/null
@@ -1,51 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * Interface representing a data tree which can be modified in an MVCC fashion.
- */
-public interface DataTree {
-    /**
-     * Take a read-only point-in-time snapshot of the tree.
-     *
-     * @return Data tree snapshot.
-     */
-    DataTreeSnapshot takeSnapshot();
-
-    /**
-     * Make the data tree use a new schema context. The context will be used
-     * only by subsequent operations.
-     *
-     * @param newSchemaContext new SchemaContext
-     * @throws IllegalArgumentException if the new context is incompatible
-     */
-    void setSchemaContext(SchemaContext newSchemaContext);
-
-    /**
-     * Validate whether a particular modification can be applied to the data tree.
-     */
-    void validate(DataTreeModification modification) throws DataValidationFailedException;
-
-    /**
-     * Prepare a modification for commit.
-     *
-     * @param modification
-     * @return candidate data tree
-     */
-    DataTreeCandidate prepare(DataTreeModification modification);
-
-    /**
-     * Commit a data tree candidate.
-     *
-     * @param candidate data tree candidate
-     */
-    void commit(DataTreeCandidate candidate);
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidate.java
deleted file mode 100644 (file)
index d860dfc..0000000
+++ /dev/null
@@ -1,35 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-/**
- * An encapsulation of a validated data tree modification. This candidate
- * is ready for atomic commit to the datastore. It allows access to before-
- * and after-state as it will be seen in to subsequent commit. This capture
- * can be accessed for reference, but cannot be modified and the content
- * is limited to nodes which were affected by the modification from which
- * this instance originated.
- */
-public interface DataTreeCandidate {
-    /**
-     * Get the candidate tree root node.
-     *
-     * @return Candidate tree root node
-     */
-    DataTreeCandidateNode getRootNode();
-
-    /**
-     * Get the candidate tree root path. This is the path of the root node
-     * relative to the root of InstanceIdentifier namespace.
-     *
-     * @return Relative path of the root node
-     */
-    InstanceIdentifier getRootPath();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidateNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidateNode.java
deleted file mode 100644 (file)
index 528419d..0000000
+++ /dev/null
@@ -1,58 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Optional;
-
-/**
- * A single node within a {@link DataTreeCandidate}. The nodes are organized
- * in tree hierarchy, reflecting the modification from which this candidate
- * was created. The node itself exposes the before- and after-image of the
- * tree restricted to the modified nodes.
- */
-public interface DataTreeCandidateNode {
-    /**
-     * Get the node identifier.
-     *
-     * @return The node identifier.
-     */
-    PathArgument getIdentifier();
-
-    /**
-     * Get an unmodifiable iterable of modified child nodes.
-     *
-     * @return Unmodifiable iterable of modified child nodes.
-     */
-    Iterable<DataTreeCandidateNode> getChildNodes();
-
-    /**
-     * Return the type of modification this node is undergoing.
-     *
-     * @return Node modification type.
-     */
-    ModificationType getModificationType();
-
-    /**
-     * Return the before-image of data corresponding to the node.
-     *
-     * @return Node data as they were present in the tree before
-     *         the modification was applied.
-     */
-    Optional<NormalizedNode<?, ?>> getDataAfter();
-
-    /**
-     * Return the after-image of data corresponding to the node.
-     *
-     * @return Node data as they will be present in the tree after
-     *         the modification is applied.
-     */
-    Optional<NormalizedNode<?, ?>> getDataBefore();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeModification.java
deleted file mode 100644 (file)
index e4370c4..0000000
+++ /dev/null
@@ -1,50 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Class encapsulation of set of modifications to a base tree. This tree is backed
- * by a read-only snapshot and tracks modifications on top of that. The modification
- * has the ability to rebase itself to a new snapshot.
- */
-public interface DataTreeModification extends DataTreeSnapshot {
-    /**
-     * Delete the node at specified path.
-     *
-     * @param path Node path
-     */
-    void delete(InstanceIdentifier path);
-
-    /**
-     * Merge the specified data with the currently-present data
-     * at specified path.
-     *
-     * @param path Node path
-     * @param data Data to be merged
-     */
-    void merge(InstanceIdentifier path, NormalizedNode<?, ?> data);
-
-    /**
-     * Replace the data at specified path with supplied data.
-     *
-     * @param path Node path
-     * @param data New node data
-     */
-    void write(InstanceIdentifier path, NormalizedNode<?, ?> data);
-
-    /**
-     * Finish creation of a modification, making it ready for application
-     * to the data tree. Any calls to this object's methods will result
-     * in undefined behavior, possibly with an
-     * {@link IllegalStateException} being thrown.
-     */
-    void ready();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeSnapshot.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeSnapshot.java
deleted file mode 100644 (file)
index a94acc5..0000000
+++ /dev/null
@@ -1,37 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Optional;
-
-/**
- * Read-only snapshot of a {@link DataTree}. The snapshot is stable and isolated,
- * e.g. data tree changes occurring after the snapshot has been taken are not
- * visible through the snapshot.
- */
-public interface DataTreeSnapshot {
-    /**
-     * Read a particular node from the snapshot.
-     *
-     * @param path Path of the node
-     * @return Optional result encapsulating the presence and value of the node
-     */
-    Optional<NormalizedNode<?, ?>> readNode(InstanceIdentifier path);
-
-    /**
-     * Create a new data tree modification based on this snapshot, using the
-     * specified data application strategy.
-     *
-     * @param strategy data modification strategy
-     * @return A new data tree modification
-     */
-    DataTreeModification newModification();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataValidationFailedException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataValidationFailedException.java
deleted file mode 100644 (file)
index 3683240..0000000
+++ /dev/null
@@ -1,53 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Exception thrown when a proposed change fails validation before being
- * applied into the datastore. This can have multiple reasons, for example
- * the datastore has been concurrently modified such that a conflicting
- * node is present, or the modification is structurally incorrect.
- */
-public class DataValidationFailedException extends Exception {
-    private static final long serialVersionUID = 1L;
-    private final InstanceIdentifier path;
-
-    /**
-     * Create a new instance.
-     *
-     * @param path Object path which caused this exception
-     * @param message Specific message describing the failure
-     */
-    public DataValidationFailedException(final InstanceIdentifier path, final String message) {
-        this(path, message, null);
-    }
-    /**
-     * Create a new instance, initializing
-     *
-     * @param path Object path which caused this exception
-     * @param message Specific message describing the failure
-     * @param cause Exception which triggered this failure, may be null
-     */
-    public DataValidationFailedException(final InstanceIdentifier path, final String message, final Throwable cause) {
-        super(message, cause);
-        this.path = Preconditions.checkNotNull(path);
-    }
-
-    /**
-     * Returns the offending object path.
-     *
-     * @return Path of the offending object
-     */
-    public InstanceIdentifier getPath() {
-        return path;
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/IncorrectDataStructureException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/IncorrectDataStructureException.java
deleted file mode 100644 (file)
index 87482a9..0000000
+++ /dev/null
@@ -1,33 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-/**
- * Exception thrown when a proposed change fails validation before being
- * applied into the datastore because of incorrect structure of user supplied
- * data.
- *
- */
-public class IncorrectDataStructureException extends DataValidationFailedException {
-
-    /**
-     *
-     */
-    private static final long serialVersionUID = 1L;
-
-    public IncorrectDataStructureException(final InstanceIdentifier path, final String message, final Throwable cause) {
-        super(path, message, cause);
-    }
-
-    public IncorrectDataStructureException(final InstanceIdentifier path, final String message) {
-        super(path, message);
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ModificationType.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ModificationType.java
deleted file mode 100644 (file)
index b9a26f5..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.store.impl.tree;
-
-/**
- * Enumeration of all possible node modification states. These are used in
- * data tree modification context to quickly assess what sort of modification
- * the node is undergoing.
- */
-public enum ModificationType {
-    /**
-     * Node is currently unmodified.
-     */
-    UNMODIFIED,
-
-    /**
-     * A child node, either direct or indirect, has been modified. This means
-     * that the data representation of this node has potentially changed.
-     */
-    SUBTREE_MODIFIED,
-
-    /**
-     * This node has been placed into the tree, potentially completely replacing
-     * pre-existing contents.
-     */
-    WRITE,
-
-    /**
-     * This node has been deleted along with any of its child nodes.
-     */
-    DELETE,
-
-    /**
-     * Node has been written into the tree, but instead of replacing pre-existing
-     * contents, it has been merged. This means that any incoming nodes which
-     * were present in the tree have been replaced, but their child nodes have
-     * been retained.
-     */
-    MERGE,
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreTreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreTreeNode.java
deleted file mode 100644 (file)
index d714f1c..0000000
+++ /dev/null
@@ -1,29 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-
-import com.google.common.base.Optional;
-
-/**
- * A tree node which has references to its child leaves. This are typically
- * internal non-data leaves, such as containers, lists, etc.
- *
- * @param <C> Final node type
- */
-public interface StoreTreeNode<C extends StoreTreeNode<C>> {
-
-    /**
-     * Returns a direct child of the node
-     *
-     * @param child Identifier of child
-     * @return Optional with node if the child is existing, {@link Optional#absent()} otherwise.
-     */
-    Optional<C> getChild(PathArgument child);
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreUtils.java
deleted file mode 100644 (file)
index b634866..0000000
+++ /dev/null
@@ -1,70 +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.store.impl.tree;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-
-import com.google.common.base.Strings;
-
-/**
- * Data store tree manipulation utilities.
- */
-public final class StoreUtils {
-    private static final int STRINGTREE_INDENT = 4;
-
-    private StoreUtils() {
-        throw new UnsupportedOperationException("Utility class should not be instantiated");
-    }
-
-    /**
-     * Convert a data subtree under a node into a human-readable string format.
-     *
-     * @param node Data subtree root
-     * @return String containing a human-readable form of the subtree.
-     */
-    public static String toStringTree(final NormalizedNode<?, ?> node) {
-        final StringBuilder builder = new StringBuilder();
-        toStringTree(builder, node, 0);
-        return builder.toString();
-    }
-
-    private static void toStringTree(final StringBuilder builder, final NormalizedNode<?, ?> node, final int offset) {
-        final String prefix = Strings.repeat(" ", offset);
-
-        builder.append(prefix).append(toStringTree(node.getIdentifier()));
-        if (node instanceof NormalizedNodeContainer<?, ?, ?>) {
-            final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) node;
-
-            builder.append(" {\n");
-            for (NormalizedNode<?, ?> child : container.getValue()) {
-                toStringTree(builder, child, offset + STRINGTREE_INDENT);
-            }
-
-            builder.append(prefix).append('}');
-        } else {
-            builder.append(' ').append(node.getValue());
-        }
-        builder.append('\n');
-    }
-
-    private static String toStringTree(final PathArgument identifier) {
-        if (identifier instanceof NodeIdentifierWithPredicates) {
-            StringBuilder builder = new StringBuilder();
-            builder.append(identifier.getNodeType().getLocalName());
-            builder.append(((NodeIdentifierWithPredicates) identifier).getKeyValues().values());
-            return builder.toString();
-        } else if (identifier instanceof AugmentationIdentifier) {
-            return "augmentation";
-        }
-        return identifier.getNodeType().getLocalName();
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java
deleted file mode 100644 (file)
index fe98468..0000000
+++ /dev/null
@@ -1,107 +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.store.impl.tree;
-
-import java.util.AbstractMap.SimpleEntry;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-
-/**
- * A set of utility methods for interacting with {@link org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode} objects.
- */
-public final class TreeNodeUtils {
-    private TreeNodeUtils() {
-        throw new UnsupportedOperationException("Utility class should not be instantiated");
-    }
-
-    /**
-     * Finds a node in tree
-     *
-     * @param tree Data Tree
-     * @param path Path to the node
-     * @return Optional with node if the node is present in tree, {@link Optional#absent()} otherwise.
-     */
-    public static <T extends StoreTreeNode<T>> Optional<T> findNode(final T tree, final InstanceIdentifier path) {
-        Optional<T> current = Optional.<T> of(tree);
-        Iterator<PathArgument> pathIter = path.getPath().iterator();
-        while (current.isPresent() && pathIter.hasNext()) {
-            current = current.get().getChild(pathIter.next());
-        }
-        return current;
-    }
-
-    public static <T extends StoreTreeNode<T>> T findNodeChecked(final T tree, final InstanceIdentifier path) {
-        T current = tree;
-        List<PathArgument> nested = new ArrayList<>(path.getPath().size());
-        for(PathArgument pathArg : path.getPath()) {
-            Optional<T> potential = current.getChild(pathArg);
-            nested.add(pathArg);
-            Preconditions.checkArgument(potential.isPresent(),"Child %s is not present in tree.",nested);
-            current = potential.get();
-        }
-        return current;
-    }
-
-    /**
-     * Finds a node or closest parent in  the tree
-     *
-     * @param tree Data Tree
-     * @param path Path to the node
-     * @return Map.Entry Entry with key which is path to closest parent and value is parent node.
-     *
-     */
-    public static <T extends StoreTreeNode<T>> Map.Entry<InstanceIdentifier, T> findClosest(final T tree, final InstanceIdentifier path) {
-        return findClosestsOrFirstMatch(tree, path, Predicates.<T>alwaysFalse());
-    }
-
-    public static <T extends StoreTreeNode<T>> Map.Entry<InstanceIdentifier, T> findClosestsOrFirstMatch(final T tree, final InstanceIdentifier path, final Predicate<T> predicate) {
-        Optional<T> parent = Optional.<T>of(tree);
-        Optional<T> current = Optional.<T> of(tree);
-
-        int nesting = 0;
-        Iterator<PathArgument> pathIter = path.getPath().iterator();
-        while (current.isPresent() && pathIter.hasNext() && !predicate.apply(current.get())) {
-            parent = current;
-            current = current.get().getChild(pathIter.next());
-            nesting++;
-        }
-        if(current.isPresent()) {
-            final InstanceIdentifier currentPath = new InstanceIdentifier(path.getPath().subList(0, nesting));
-            return new SimpleEntry<InstanceIdentifier,T>(currentPath,current.get());
-        }
-
-        /*
-         * Subtracting 1 from nesting level at this point is safe, because we
-         * cannot reach here with nesting == 0: that would mean the above check
-         * for current.isPresent() failed, which it cannot, as current is always
-         * present. At any rate we check state just to be on the safe side.
-         */
-        Preconditions.checkState(nesting > 0);
-        final InstanceIdentifier parentPath = new InstanceIdentifier(path.getPath().subList(0, nesting - 1));
-
-        return new SimpleEntry<InstanceIdentifier,T>(parentPath,parent.get());
-    }
-
-    public static <T extends StoreTreeNode<T>> Optional<T> getChild(final Optional<T> parent,final PathArgument child) {
-        if(parent.isPresent()) {
-            return parent.get().getChild(child);
-        }
-        return Optional.absent();
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AbstractDataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AbstractDataTreeCandidate.java
deleted file mode 100644 (file)
index cddda5c..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.sal.dom.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-import com.google.common.base.Preconditions;
-
-abstract class AbstractDataTreeCandidate implements DataTreeCandidate {
-    private final InstanceIdentifier rootPath;
-
-    protected AbstractDataTreeCandidate(final InstanceIdentifier rootPath) {
-        this.rootPath = Preconditions.checkNotNull(rootPath);
-    }
-
-    @Override
-    public final InstanceIdentifier getRootPath() {
-        return rootPath;
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AlwaysFailOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AlwaysFailOperation.java
deleted file mode 100644 (file)
index c09a1a3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.opendaylight.controller.md.sal.dom.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-
-import com.google.common.base.Optional;
-
-/**
- * An implementation of apply operation which fails to do anything,
- * consistently. An instance of this class is used by the data tree
- * if it does not have a SchemaContext attached and hence cannot
- * perform anything meaningful.
- */
-final class AlwaysFailOperation implements ModificationApplyOperation {
-    @Override
-    public Optional<TreeNode> apply(final ModifiedNode modification,
-            final Optional<TreeNode> storeMeta, final Version version) {
-        throw new IllegalStateException("Schema Context is not available.");
-    }
-
-    @Override
-    public void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional<TreeNode> storeMetadata) {
-        throw new IllegalStateException("Schema Context is not available.");
-    }
-
-    @Override
-    public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
-        throw new IllegalStateException("Schema Context is not available.");
-    }
-
-    @Override
-    public void verifyStructure(final ModifiedNode modification) {
-        throw new IllegalStateException("Schema Context is not available.");
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/DataNodeContainerModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/DataNodeContainerModificationStrategy.java
deleted file mode 100644 (file)
index dc89148..0000000
+++ /dev/null
@@ -1,160 +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.store.impl.tree.data;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.AugmentationSchemaProxy;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-
-/**
- * Base strategy for applying changes to a ContainerNode, irrespective of its
- * actual type.
- *
- * @param <T> Type of the container node
- */
-abstract class DataNodeContainerModificationStrategy<T extends DataNodeContainer> extends NormalizedNodeContainerModificationStrategy {
-
-    private final T schema;
-    private final LoadingCache<PathArgument, ModificationApplyOperation> childCache = CacheBuilder.newBuilder()
-            .build(CacheLoader.from(new Function<PathArgument, ModificationApplyOperation>() {
-
-                @Override
-                public ModificationApplyOperation apply(final PathArgument identifier) {
-                    if (identifier instanceof AugmentationIdentifier && schema instanceof AugmentationTarget) {
-                        return from(schema, (AugmentationTarget) schema, (AugmentationIdentifier) identifier);
-                    }
-
-                    DataSchemaNode child = schema.getDataChildByName(identifier.getNodeType());
-                    if (child == null) {
-                        return null;
-                    }
-                    return from(child);
-                }
-            }));
-
-    protected DataNodeContainerModificationStrategy(final T schema,
-            final Class<? extends NormalizedNode<?, ?>> nodeClass) {
-        super(nodeClass);
-        this.schema = schema;
-    }
-
-    protected T getSchema() {
-        return schema;
-    }
-
-    @Override
-    public Optional<ModificationApplyOperation> getChild(final PathArgument identifier) {
-        try {
-            return Optional.<ModificationApplyOperation> fromNullable(childCache.get(identifier));
-        } catch (ExecutionException e) {
-            return Optional.absent();
-        }
-    }
-
-    @Override
-    @SuppressWarnings("rawtypes")
-    protected abstract DataContainerNodeBuilder createBuilder(NormalizedNode<?, ?> original);
-
-    @Override
-    public String toString() {
-        return getClass().getSimpleName() + " [" + schema + "]";
-    }
-
-    public static class AugmentationModificationStrategy extends DataNodeContainerModificationStrategy<AugmentationSchema> {
-
-        protected AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) {
-            super(createAugmentProxy(schema,resolved), AugmentationNode.class);
-        }
-
-        @Override
-        @SuppressWarnings("rawtypes")
-        protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof AugmentationNode);
-            return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original);
-        }
-
-
-        private static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) {
-            Set<DataSchemaNode> realChildSchemas = new HashSet<>();
-            for(DataSchemaNode augChild : schema.getChildNodes()) {
-                realChildSchemas.add(resolved.getDataChildByName(augChild.getQName()));
-            }
-            return new AugmentationSchemaProxy(schema, realChildSchemas);
-        }
-    }
-
-    public static class ContainerModificationStrategy extends DataNodeContainerModificationStrategy<ContainerSchemaNode> {
-
-        public ContainerModificationStrategy(final ContainerSchemaNode schemaNode) {
-            super(schemaNode, ContainerNode.class);
-        }
-
-        @Override
-        @SuppressWarnings("rawtypes")
-        protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof ContainerNode);
-            return ImmutableContainerNodeBuilder.create((ContainerNode) original);
-        }
-    }
-
-    public static class ListEntryModificationStrategy extends DataNodeContainerModificationStrategy<ListSchemaNode> {
-
-        protected ListEntryModificationStrategy(final ListSchemaNode schema) {
-            super(schema, MapEntryNode.class);
-        }
-
-        @Override
-        @SuppressWarnings("rawtypes")
-        protected final DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof MapEntryNode);
-            return ImmutableMapEntryNodeBuilder.create((MapEntryNode) original);
-        }
-    }
-
-    public static class UnkeyedListItemModificationStrategy extends DataNodeContainerModificationStrategy<ListSchemaNode> {
-
-        public UnkeyedListItemModificationStrategy(final ListSchemaNode schemaNode) {
-            super(schemaNode, UnkeyedListEntryNode.class);
-        }
-
-        @Override
-        @SuppressWarnings("rawtypes")
-        protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof UnkeyedListEntryNode);
-            return ImmutableUnkeyedListEntryNodeBuilder.create((UnkeyedListEntryNode) original);
-        }
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTree.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTree.java
deleted file mode 100644 (file)
index 803105f..0000000
+++ /dev/null
@@ -1,137 +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.store.impl.tree.data;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTree;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreUtils;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Read-only snapshot of the data tree.
- */
-final class InMemoryDataTree implements DataTree {
-    private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTree.class);
-    private static final InstanceIdentifier PUBLIC_ROOT_PATH = InstanceIdentifier.builder().build();
-
-    private final ReadWriteLock rwLock = new ReentrantReadWriteLock(true);
-    private ModificationApplyOperation applyOper = new AlwaysFailOperation();
-    private SchemaContext currentSchemaContext;
-    private TreeNode rootNode;
-
-    public InMemoryDataTree(final TreeNode rootNode, final SchemaContext schemaContext) {
-        this.rootNode = Preconditions.checkNotNull(rootNode);
-
-        if (schemaContext != null) {
-            // Also sets applyOper
-            setSchemaContext(schemaContext);
-        }
-    }
-
-    @Override
-    public synchronized void setSchemaContext(final SchemaContext newSchemaContext) {
-        Preconditions.checkNotNull(newSchemaContext);
-
-        LOG.info("Attepting to install schema context {}", newSchemaContext);
-
-        /*
-         * FIXME: we should walk the schema contexts, both current and new and see
-         *        whether they are compatible here. Reject incompatible changes.
-         */
-
-        // Instantiate new apply operation, this still may fail
-        final ModificationApplyOperation newApplyOper = SchemaAwareApplyOperation.from(newSchemaContext);
-
-        // Ready to change the context now, make sure no operations are running
-        rwLock.writeLock().lock();
-        try {
-            this.applyOper = newApplyOper;
-            this.currentSchemaContext = newSchemaContext;
-        } finally {
-            rwLock.writeLock().unlock();
-        }
-    }
-
-    @Override
-    public InMemoryDataTreeSnapshot takeSnapshot() {
-        rwLock.readLock().lock();
-        try {
-            return new InMemoryDataTreeSnapshot(currentSchemaContext, rootNode, applyOper);
-        } finally {
-            rwLock.readLock().unlock();
-        }
-    }
-
-    @Override
-    public void validate(final DataTreeModification modification) throws DataValidationFailedException {
-        Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass());
-
-        final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification;
-        m.getStrategy().checkApplicable(PUBLIC_ROOT_PATH, m.getRootModification(), Optional.<TreeNode>of(rootNode));
-    }
-
-    @Override
-    public synchronized DataTreeCandidate prepare(final DataTreeModification modification) {
-        Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass());
-
-        final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification;
-        final ModifiedNode root = m.getRootModification();
-
-        if (root.getType() == ModificationType.UNMODIFIED) {
-            return new NoopDataTreeCandidate(PUBLIC_ROOT_PATH, root);
-        }
-
-        rwLock.writeLock().lock();
-        try {
-            final Optional<TreeNode> newRoot = m.getStrategy().apply(m.getRootModification(),
-                    Optional.<TreeNode>of(rootNode), rootNode.getSubtreeVersion().next());
-            Preconditions.checkState(newRoot.isPresent(), "Apply strategy failed to produce root node");
-            return new InMemoryDataTreeCandidate(PUBLIC_ROOT_PATH, root, rootNode, newRoot.get());
-        } finally {
-            rwLock.writeLock().unlock();
-        }
-    }
-
-    @Override
-    public synchronized void commit(final DataTreeCandidate candidate) {
-        if (candidate instanceof NoopDataTreeCandidate) {
-            return;
-        }
-
-        Preconditions.checkArgument(candidate instanceof InMemoryDataTreeCandidate, "Invalid candidate class %s", candidate.getClass());
-        final InMemoryDataTreeCandidate c = (InMemoryDataTreeCandidate)candidate;
-
-        LOG.debug("Updating datastore from {} to {}", rootNode, c.getAfterRoot());
-
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("Data Tree is {}", StoreUtils.toStringTree(c.getAfterRoot().getData()));
-        }
-
-        // Ready to change the context now, make sure no operations are running
-        rwLock.writeLock().lock();
-        try {
-            Preconditions.checkState(c.getBeforeRoot() == rootNode,
-                    String.format("Store tree %s and candidate base %s differ.", rootNode, c.getBeforeRoot()));
-            this.rootNode = c.getAfterRoot();
-        } finally {
-            rwLock.writeLock().unlock();
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeCandidate.java
deleted file mode 100644 (file)
index bafea6b..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.opendaylight.controller.md.sal.dom.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
-
-final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate {
-    private static abstract class AbstractNode implements DataTreeCandidateNode {
-        private final ModifiedNode mod;
-        private final TreeNode newMeta;
-        private final TreeNode oldMeta;
-
-        protected AbstractNode(final ModifiedNode mod,
-                final TreeNode oldMeta, final TreeNode newMeta) {
-            this.newMeta = newMeta;
-            this.oldMeta = oldMeta;
-            this.mod = Preconditions.checkNotNull(mod);
-        }
-
-        protected final ModifiedNode getMod() {
-            return mod;
-        }
-
-        protected final TreeNode getNewMeta() {
-            return newMeta;
-        }
-
-        protected final TreeNode getOldMeta() {
-            return oldMeta;
-        }
-
-        private static final TreeNode childMeta(final TreeNode parent, final PathArgument id) {
-            if (parent != null) {
-                return parent.getChild(id).orNull();
-            } else {
-                return null;
-            }
-        }
-
-        @Override
-        public Iterable<DataTreeCandidateNode> getChildNodes() {
-            return Iterables.transform(mod.getChildren(), new Function<ModifiedNode, DataTreeCandidateNode>() {
-                @Override
-                public DataTreeCandidateNode apply(final ModifiedNode input) {
-                    final PathArgument id = input.getIdentifier();
-                    return new ChildNode(input, childMeta(oldMeta, id), childMeta(newMeta, id));
-                }
-            });
-        }
-
-        @Override
-        public ModificationType getModificationType() {
-            return mod.getType();
-        }
-
-        private Optional<NormalizedNode<?, ?>> optionalData(final TreeNode meta) {
-            if (meta != null) {
-                return Optional.<NormalizedNode<?,?>>of(meta.getData());
-            } else {
-                return Optional.absent();
-            }
-        }
-
-        @Override
-        public Optional<NormalizedNode<?, ?>> getDataAfter() {
-            return optionalData(newMeta);
-        }
-
-        @Override
-        public Optional<NormalizedNode<?, ?>> getDataBefore() {
-            return optionalData(oldMeta);
-        }
-    }
-
-    private static final class ChildNode extends AbstractNode {
-        public ChildNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
-            super(mod, oldMeta, newMeta);
-        }
-
-        @Override
-        public PathArgument getIdentifier() {
-            return getMod().getIdentifier();
-        }
-    }
-
-    private static final class RootNode extends AbstractNode {
-        public RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
-            super(mod, oldMeta, newMeta);
-        }
-
-        @Override
-        public PathArgument getIdentifier() {
-            throw new IllegalStateException("Attempted to get identifier of the root node");
-        }
-    }
-
-    private final RootNode root;
-
-    InMemoryDataTreeCandidate(final InstanceIdentifier rootPath, final ModifiedNode modificationRoot,
-            final TreeNode beforeRoot, final TreeNode afterRoot) {
-        super(rootPath);
-        this.root = new RootNode(modificationRoot, beforeRoot, afterRoot);
-    }
-
-    TreeNode getAfterRoot() {
-        return root.getNewMeta();
-    }
-
-    TreeNode getBeforeRoot() {
-        return root.getOldMeta();
-    }
-
-    @Override
-    public DataTreeCandidateNode getRootNode() {
-        return root;
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeFactory.java
deleted file mode 100644 (file)
index 4640be4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.opendaylight.controller.md.sal.dom.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * A factory for creating in-memory data trees.
- */
-public final class InMemoryDataTreeFactory implements DataTreeFactory {
-    private static final InMemoryDataTreeFactory INSTANCE = new InMemoryDataTreeFactory();
-
-    private InMemoryDataTreeFactory() {
-        // Never instantiated externally
-    }
-
-    @Override
-    public InMemoryDataTree create() {
-        final NodeIdentifier root = new NodeIdentifier(SchemaContext.NAME);
-        final NormalizedNode<?, ?> data = Builders.containerBuilder().withNodeIdentifier(root).build();
-
-        return new InMemoryDataTree(TreeNodeFactory.createTreeNode(data, Version.initial()), null);
-    }
-
-    /**
-     * Get an instance of this factory. This method cannot fail.
-     *
-     * @return Data tree factory instance.
-     */
-    public static final InMemoryDataTreeFactory getInstance() {
-        return INSTANCE;
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java
deleted file mode 100644 (file)
index 39ff4f0..0000000
+++ /dev/null
@@ -1,178 +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.store.impl.tree.data;
-
-import java.util.Map.Entry;
-
-import javax.annotation.concurrent.GuardedBy;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.TreeNodeUtils;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-final class InMemoryDataTreeModification implements DataTreeModification {
-    private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeModification.class);
-    private final ModificationApplyOperation strategyTree;
-    private final InMemoryDataTreeSnapshot snapshot;
-    private final ModifiedNode rootNode;
-
-    @GuardedBy("this")
-    private boolean sealed = false;
-
-    InMemoryDataTreeModification(final InMemoryDataTreeSnapshot snapshot, final ModificationApplyOperation resolver) {
-        this.snapshot = Preconditions.checkNotNull(snapshot);
-        this.strategyTree = Preconditions.checkNotNull(resolver);
-        this.rootNode = ModifiedNode.createUnmodified(snapshot.getRootNode());
-    }
-
-    ModifiedNode getRootModification() {
-        return rootNode;
-    }
-
-    ModificationApplyOperation getStrategy() {
-        return strategyTree;
-    }
-
-    @Override
-    public synchronized void write(final InstanceIdentifier path, final NormalizedNode<?, ?> value) {
-        checkSealed();
-        resolveModificationFor(path).write(value);
-    }
-
-    @Override
-    public synchronized void merge(final InstanceIdentifier path, final NormalizedNode<?, ?> data) {
-        checkSealed();
-        mergeImpl(resolveModificationFor(path),data);
-    }
-
-    private void mergeImpl(final OperationWithModification op,final NormalizedNode<?,?> data) {
-
-        if(data instanceof NormalizedNodeContainer<?,?,?>) {
-            @SuppressWarnings({ "rawtypes", "unchecked" })
-            NormalizedNodeContainer<?,?,NormalizedNode<PathArgument, ?>> dataContainer = (NormalizedNodeContainer) data;
-            for(NormalizedNode<PathArgument, ?> child : dataContainer.getValue()) {
-                PathArgument childId = child.getIdentifier();
-                mergeImpl(op.forChild(childId), child);
-            }
-        }
-        op.merge(data);
-    }
-
-    @Override
-    public synchronized void delete(final InstanceIdentifier path) {
-        checkSealed();
-        resolveModificationFor(path).delete();
-    }
-
-    @Override
-    public synchronized Optional<NormalizedNode<?, ?>> readNode(final InstanceIdentifier path) {
-        /*
-         * Walk the tree from the top, looking for the first node between root and
-         * the requested path which has been modified. If no such node exists,
-         * we use the node itself.
-         */
-        final Entry<InstanceIdentifier, ModifiedNode> entry = TreeNodeUtils.findClosestsOrFirstMatch(rootNode, path, ModifiedNode.IS_TERMINAL_PREDICATE);
-        final InstanceIdentifier key = entry.getKey();
-        final ModifiedNode mod = entry.getValue();
-
-        final Optional<TreeNode> result = resolveSnapshot(key, mod);
-        if (result.isPresent()) {
-            NormalizedNode<?, ?> data = result.get().getData();
-            return NormalizedNodeUtils.findNode(key, data, path);
-        } else {
-            return Optional.absent();
-        }
-    }
-
-    private Optional<TreeNode> resolveSnapshot(final InstanceIdentifier path,
-            final ModifiedNode modification) {
-        final Optional<Optional<TreeNode>> potentialSnapshot = modification.getSnapshotCache();
-        if(potentialSnapshot.isPresent()) {
-            return potentialSnapshot.get();
-        }
-
-        try {
-            return resolveModificationStrategy(path).apply(modification, modification.getOriginal(),
-                    snapshot.getRootNode().getSubtreeVersion().next());
-        } catch (Exception e) {
-            LOG.error("Could not create snapshot for {}:{}", path,modification,e);
-            throw e;
-        }
-    }
-
-    private ModificationApplyOperation resolveModificationStrategy(final InstanceIdentifier path) {
-        LOG.trace("Resolving modification apply strategy for {}", path);
-        return TreeNodeUtils.findNodeChecked(strategyTree, path);
-    }
-
-    private OperationWithModification resolveModificationFor(final InstanceIdentifier path) {
-        ModifiedNode modification = rootNode;
-        // We ensure strategy is present.
-        ModificationApplyOperation operation = resolveModificationStrategy(path);
-        for (PathArgument pathArg : path.getPath()) {
-            modification = modification.modifyChild(pathArg);
-        }
-        return OperationWithModification.from(operation, modification);
-    }
-
-    @Override
-    public synchronized void ready() {
-        Preconditions.checkState(!sealed, "Attempted to seal an already-sealed Data Tree.");
-        sealed = true;
-        rootNode.seal();
-    }
-
-    @GuardedBy("this")
-    private void checkSealed() {
-        Preconditions.checkState(!sealed, "Data Tree is sealed. No further modifications allowed.");
-    }
-
-    @Override
-    public String toString() {
-        return "MutableDataTree [modification=" + rootNode + "]";
-    }
-
-    @Override
-    public synchronized DataTreeModification newModification() {
-        Preconditions.checkState(sealed, "Attempted to chain on an unsealed modification");
-
-        if(rootNode.getType() == ModificationType.UNMODIFIED) {
-            return snapshot.newModification();
-        }
-
-        /*
-         *  FIXME: Add advanced transaction chaining for modification of not rebased
-         *  modification.
-         *
-         *  Current computation of tempRoot may yeld incorrect subtree versions
-         *  if there are multiple concurrent transactions, which may break
-         *  versioning preconditions for modification of previously occured write,
-         *  directly nested under parent node, since node version is derived from
-         *  subtree version.
-         *
-         *  For deeper nodes subtree version is derived from their respective metadata
-         *  nodes, so this incorrect root subtree version is not affecting us.
-         */
-        TreeNode originalSnapshotRoot = snapshot.getRootNode();
-        Optional<TreeNode> tempRoot = strategyTree.apply(rootNode, Optional.of(originalSnapshotRoot), originalSnapshotRoot.getSubtreeVersion().next());
-
-        InMemoryDataTreeSnapshot tempTree = new InMemoryDataTreeSnapshot(snapshot.getSchemaContext(), tempRoot.get(), strategyTree);
-        return tempTree.newModification();
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeSnapshot.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeSnapshot.java
deleted file mode 100644 (file)
index ee91e62..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.opendaylight.controller.md.sal.dom.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeUtils;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-final class InMemoryDataTreeSnapshot implements DataTreeSnapshot {
-    private final ModificationApplyOperation applyOper;
-    private final SchemaContext schemaContext;
-    private final TreeNode rootNode;
-
-    InMemoryDataTreeSnapshot(final SchemaContext schemaContext, final TreeNode rootNode,
-            final ModificationApplyOperation applyOper) {
-        this.schemaContext = Preconditions.checkNotNull(schemaContext);
-        this.rootNode = Preconditions.checkNotNull(rootNode);
-        this.applyOper = Preconditions.checkNotNull(applyOper);
-    }
-
-    TreeNode getRootNode() {
-        return rootNode;
-    }
-
-    SchemaContext getSchemaContext() {
-        return schemaContext;
-    }
-
-    @Override
-    public Optional<NormalizedNode<?, ?>> readNode(final InstanceIdentifier path) {
-        return NormalizedNodeUtils.findNode(rootNode.getData(), path);
-    }
-
-    @Override
-    public InMemoryDataTreeModification newModification() {
-        return new InMemoryDataTreeModification(this, applyOper);
-    }
-
-    @Override
-    public String toString() {
-        return rootNode.getSubtreeVersion().toString();
-    }
-
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationApplyOperation.java
deleted file mode 100644 (file)
index f72d575..0000000
+++ /dev/null
@@ -1,93 +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.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-
-import com.google.common.base.Optional;
-
-/**
- *
- * Operation responsible for applying {@link ModifiedNode} on tree.
- *
- * Operation is composite - operation on top level node consists of
- * suboperations on child nodes. This allows to walk operation hierarchy and
- * invoke suboperations independently.
- *
- * <b>Implementation notes</b>
- * <ul>
- * <li>
- * Implementations MUST expose all nested suboperations which operates on child
- * nodes expose via {@link #getChild(PathArgument)} method.
- * <li>Same suboperations SHOULD be used when invoked via
- * {@link #apply(ModifiedNode, Optional)} if applicable.
- *
- *
- * Hierarchical composite operation which is responsible for applying
- * modification on particular subtree and creating updated subtree
- *
- *
- */
-interface ModificationApplyOperation extends StoreTreeNode<ModificationApplyOperation> {
-
-    /**
-     *
-     * Implementation of this operation must be stateless and must not change
-     * state of this object.
-     *
-     * @param modification
-     *            NodeModification to be applied
-     * @param storeMeta
-     *            Store Metadata Node on which NodeModification should be
-     *            applied
-     * @param version New subtree version of parent node
-     * @throws IllegalArgumentException
-     *             If it is not possible to apply Operation on provided Metadata
-     *             node
-     * @return new {@link StoreMetadataNode} if operation resulted in updating
-     *         node, {@link Optional#absent()} if {@link ModifiedNode}
-     *         resulted in deletion of this node.
-     */
-    Optional<TreeNode> apply(ModifiedNode modification, Optional<TreeNode> storeMeta, Version version);
-
-    /**
-     *
-     * Performs structural verification of NodeModification, such as writen values / types
-     * uses right structural elements.
-     *
-     * @param modification to be verified.
-     * @throws IllegalArgumentException If provided NodeModification does not adhere to the structure.
-     */
-    void verifyStructure(ModifiedNode modification) throws IllegalArgumentException;
-
-    /**
-     * Returns a suboperation for specified tree node
-     *
-     * @return Reference to suboperation for specified tree node, {@link Optional#absent()}
-     *    if suboperation is not supported for specified tree node.
-     */
-    @Override
-    Optional<ModificationApplyOperation> getChild(PathArgument child);
-
-    /**
-     *
-     * Checks if provided node modification could be applied to current metadata node.
-     *
-     * @param modification Modification
-     * @param current Metadata Node to which modification should be applied
-     * @return true if modification is applicable
-     *         false if modification is no applicable
-     * @throws DataValidationFailedException
-     */
-    void checkApplicable(InstanceIdentifier path, NodeModification modification, Optional<TreeNode> current) throws DataValidationFailedException;
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModifiedNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModifiedNode.java
deleted file mode 100644 (file)
index f83ea1a..0000000
+++ /dev/null
@@ -1,225 +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.store.impl.tree.data;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.annotation.concurrent.GuardedBy;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-
-/**
- * Node Modification Node and Tree
- *
- * Tree which structurally resembles data tree and captures client modifications
- * to the data store tree.
- *
- * This tree is lazily created and populated via {@link #modifyChild(PathArgument)}
- * and {@link StoreMetadataNode} which represents original state {@link #getOriginal()}.
- */
-final class ModifiedNode implements StoreTreeNode<ModifiedNode>, Identifiable<PathArgument>, NodeModification {
-
-    public static final Predicate<ModifiedNode> IS_TERMINAL_PREDICATE = new Predicate<ModifiedNode>() {
-        @Override
-        public boolean apply(final ModifiedNode input) {
-            switch (input.getType()) {
-            case DELETE:
-            case MERGE:
-            case WRITE:
-                return true;
-            case SUBTREE_MODIFIED:
-            case UNMODIFIED:
-                return false;
-            }
-
-            throw new IllegalArgumentException(String.format("Unhandled modification type %s", input.getType()));
-        }
-    };
-
-    private final Map<PathArgument, ModifiedNode> children = new LinkedHashMap<>();
-    private final Optional<TreeNode> original;
-    private final PathArgument identifier;
-    private ModificationType modificationType = ModificationType.UNMODIFIED;
-    private Optional<TreeNode> snapshotCache;
-    private NormalizedNode<?, ?> value;
-
-    private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original) {
-        this.identifier = identifier;
-        this.original = original;
-    }
-
-    /**
-     *
-     *
-     * @return
-     */
-    public NormalizedNode<?, ?> getWrittenValue() {
-        return value;
-    }
-
-    @Override
-    public PathArgument getIdentifier() {
-        return identifier;
-    }
-
-    /**
-     *
-     * Returns original store metadata
-     * @return original store metadata
-     */
-    @Override
-    public Optional<TreeNode> getOriginal() {
-        return original;
-    }
-
-    /**
-     * Returns modification type
-     *
-     * @return modification type
-     */
-    @Override
-    public ModificationType getType() {
-        return modificationType;
-    }
-
-    /**
-     *
-     * Returns child modification if child was modified
-     *
-     * @return Child modification if direct child or it's subtree
-     *  was modified.
-     *
-     */
-    @Override
-    public Optional<ModifiedNode> getChild(final PathArgument child) {
-        return Optional.<ModifiedNode> fromNullable(children.get(child));
-    }
-
-    /**
-     *
-     * Returns child modification if child was modified, creates {@link ModifiedNode}
-     * for child otherwise.
-     *
-     * If this node's {@link ModificationType} is {@link ModificationType#UNMODIFIED}
-     * changes modification type to {@link ModificationType#SUBTREE_MODIFIED}
-     *
-     * @param child
-     * @return {@link ModifiedNode} for specified child, with {@link #getOriginal()}
-     *         containing child metadata if child was present in original data.
-     */
-    public ModifiedNode modifyChild(final PathArgument child) {
-        clearSnapshot();
-        if (modificationType == ModificationType.UNMODIFIED) {
-            updateModificationType(ModificationType.SUBTREE_MODIFIED);
-        }
-        final ModifiedNode potential = children.get(child);
-        if (potential != null) {
-            return potential;
-        }
-
-        final Optional<TreeNode> currentMetadata;
-        if (original.isPresent()) {
-            final TreeNode orig = original.get();
-            currentMetadata = orig.getChild(child);
-        } else {
-            currentMetadata = Optional.absent();
-        }
-
-        ModifiedNode newlyCreated = new ModifiedNode(child, currentMetadata);
-        children.put(child, newlyCreated);
-        return newlyCreated;
-    }
-
-    /**
-     *
-     * Returns all recorded direct child modification
-     *
-     * @return all recorded direct child modifications
-     */
-    @Override
-    public Iterable<ModifiedNode> getChildren() {
-        return children.values();
-    }
-
-    /**
-     *
-     * Records a delete for associated node.
-     *
-     */
-    public void delete() {
-        clearSnapshot();
-        updateModificationType(ModificationType.DELETE);
-        children.clear();
-        this.value = null;
-    }
-
-    /**
-     *
-     * Records a write for associated node.
-     *
-     * @param value
-     */
-    public void write(final NormalizedNode<?, ?> value) {
-        clearSnapshot();
-        updateModificationType(ModificationType.WRITE);
-        children.clear();
-        this.value = value;
-    }
-
-    public void merge(final NormalizedNode<?, ?> data) {
-        clearSnapshot();
-        updateModificationType(ModificationType.MERGE);
-        // FIXME: Probably merge with previous value.
-        this.value = data;
-    }
-
-    void seal() {
-        clearSnapshot();
-        for (ModifiedNode child : children.values()) {
-            child.seal();
-        }
-    }
-
-    private void clearSnapshot() {
-        snapshotCache = null;
-    }
-
-    public Optional<TreeNode> storeSnapshot(final Optional<TreeNode> snapshot) {
-        snapshotCache = snapshot;
-        return snapshot;
-    }
-
-    public Optional<Optional<TreeNode>> getSnapshotCache() {
-        return Optional.fromNullable(snapshotCache);
-    }
-
-    @GuardedBy("this")
-    private void updateModificationType(final ModificationType type) {
-        modificationType = type;
-        clearSnapshot();
-    }
-
-    @Override
-    public String toString() {
-        return "NodeModification [identifier=" + identifier + ", modificationType="
-                + modificationType + ", childModification=" + children + "]";
-    }
-
-    public static ModifiedNode createUnmodified(final TreeNode metadataTree) {
-        return new ModifiedNode(metadataTree.getIdentifier(), Optional.of(metadataTree));
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java
deleted file mode 100644 (file)
index e7e79f8..0000000
+++ /dev/null
@@ -1,44 +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.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-
-import com.google.common.base.Optional;
-
-/**
- * Internal interface representing a modification action of a particular node.
- * It is used by the validation code to allow for a read-only view of the
- * modification tree as we should never modify that during validation.
- */
-interface NodeModification extends Identifiable<PathArgument> {
-    /**
-     * Get the type of modification.
-     *
-     * @return Modification type.
-     */
-    ModificationType getType();
-
-    /**
-     * Get the original tree node to which the modification is to be applied.
-     *
-     * @return The original node, or {@link Optional#absent()} if the node is
-     *         a new node.
-     */
-    Optional<TreeNode> getOriginal();
-
-    /**
-     * Get a read-only view of children nodes.
-     *
-     * @return Iterable of all children nodes.
-     */
-    Iterable<? extends NodeModification> getChildren();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NoopDataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NoopDataTreeCandidate.java
deleted file mode 100644 (file)
index 227684a..0000000
+++ /dev/null
@@ -1,63 +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.store.impl.tree.data;
-
-import java.util.Collections;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-/**
- * Internal utility class for an empty candidate. We instantiate this class
- * for empty modifications, saving memory and processing speed. Instances
- * of this class are explicitly recognized and processing of them is skipped.
- */
-final class NoopDataTreeCandidate extends AbstractDataTreeCandidate {
-    private static final DataTreeCandidateNode ROOT = new DataTreeCandidateNode() {
-        @Override
-        public ModificationType getModificationType() {
-            return ModificationType.UNMODIFIED;
-        }
-
-        @Override
-        public Iterable<DataTreeCandidateNode> getChildNodes() {
-            return Collections.emptyList();
-        }
-
-        @Override
-        public PathArgument getIdentifier() {
-            throw new IllegalStateException("Attempted to read identifier of the no-operation change");
-        }
-
-        @Override
-        public Optional<NormalizedNode<?, ?>> getDataAfter() {
-            return Optional.absent();
-        }
-
-        @Override
-        public Optional<NormalizedNode<?, ?>> getDataBefore() {
-            return Optional.absent();
-        }
-    };
-
-    protected NoopDataTreeCandidate(final InstanceIdentifier rootPath, final ModifiedNode modificationRoot) {
-        super(rootPath);
-        Preconditions.checkArgument(modificationRoot.getType() == ModificationType.UNMODIFIED);
-    }
-
-    @Override
-    public DataTreeCandidateNode getRootNode() {
-        return ROOT;
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java
deleted file mode 100644 (file)
index 1d10ab6..0000000
+++ /dev/null
@@ -1,337 +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.store.impl.tree.data;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Map;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.ListEntryModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.ValueNodeModificationStrategy.LeafSetEntryModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.MutableTreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareApplyOperation {
-
-    private final Class<? extends NormalizedNode<?, ?>> nodeClass;
-
-    protected NormalizedNodeContainerModificationStrategy(final Class<? extends NormalizedNode<?, ?>> nodeClass) {
-        this.nodeClass = nodeClass;
-    }
-
-    @Override
-    public void verifyStructure(final ModifiedNode modification) throws IllegalArgumentException {
-        if (modification.getType() == ModificationType.WRITE) {
-
-        }
-        for (ModifiedNode childModification : modification.getChildren()) {
-            resolveChildOperation(childModification.getIdentifier()).verifyStructure(childModification);
-        }
-    }
-
-    @Override
-    protected void checkWriteApplicable(final InstanceIdentifier path, final NodeModification modification,
-            final Optional<TreeNode> current) throws DataValidationFailedException {
-        // FIXME: Implement proper write check for replacement of node container
-        //        prerequisite is to have transaction chain available for clients
-        //        otherwise this will break chained writes to same node.
-    }
-
-    @SuppressWarnings("rawtypes")
-    @Override
-    protected void verifyWrittenStructure(final NormalizedNode<?, ?> writtenValue) {
-        checkArgument(nodeClass.isInstance(writtenValue), "Node should must be of type %s", nodeClass);
-        checkArgument(writtenValue instanceof NormalizedNodeContainer);
-
-        NormalizedNodeContainer container = (NormalizedNodeContainer) writtenValue;
-        for (Object child : container.getValue()) {
-            checkArgument(child instanceof NormalizedNode);
-
-            /*
-             * FIXME: fail-fast semantics:
-             *
-             * We can validate the data structure here, aborting the commit
-             * before it ever progresses to being committed.
-             */
-        }
-    }
-
-    @Override
-    protected TreeNode applyWrite(final ModifiedNode modification,
-            final Optional<TreeNode> currentMeta, final Version version) {
-        final NormalizedNode<?, ?> newValue = modification.getWrittenValue();
-        final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version);
-
-        if (Iterables.isEmpty(modification.getChildren())) {
-            return newValueMeta;
-        }
-
-        /*
-         * This is where things get interesting. The user has performed a write and
-         * then she applied some more modifications to it. So we need to make sense
-         * of that an apply the operations on top of the written value. We could have
-         * done it during the write, but this operation is potentially expensive, so
-         * we have left it out of the fast path.
-         *
-         * As it turns out, once we materialize the written data, we can share the
-         * code path with the subtree change. So let's create an unsealed TreeNode
-         * and run the common parts on it -- which end with the node being sealed.
-         */
-        final MutableTreeNode mutable = newValueMeta.mutable();
-        mutable.setSubtreeVersion(version);
-
-        @SuppressWarnings("rawtypes")
-        final NormalizedNodeContainerBuilder dataBuilder = createBuilder(newValue);
-
-        return mutateChildren(mutable, dataBuilder, version, modification.getChildren());
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    private TreeNode mutateChildren(final MutableTreeNode meta, final NormalizedNodeContainerBuilder data,
-            final Version nodeVersion, final Iterable<ModifiedNode> modifications) {
-
-        for (ModifiedNode mod : modifications) {
-            final PathArgument id = mod.getIdentifier();
-            final Optional<TreeNode> cm = meta.getChild(id);
-
-            Optional<TreeNode> result = resolveChildOperation(id).apply(mod, cm, nodeVersion);
-            if (result.isPresent()) {
-                final TreeNode tn = result.get();
-                meta.addChild(tn);
-                data.addChild(tn.getData());
-            } else {
-                meta.removeChild(id);
-                data.removeChild(id);
-            }
-        }
-
-        meta.setData(data.build());
-        return meta.seal();
-    }
-
-    @Override
-    protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta,
-            final Version version) {
-        // For Node Containers - merge is same as subtree change - we only replace children.
-        return applySubtreeChange(modification, currentMeta, version);
-    }
-
-    @Override
-    public TreeNode applySubtreeChange(final ModifiedNode modification,
-            final TreeNode currentMeta, final Version version) {
-        final MutableTreeNode newMeta = currentMeta.mutable();
-        newMeta.setSubtreeVersion(version);
-
-        @SuppressWarnings("rawtypes")
-        NormalizedNodeContainerBuilder dataBuilder = createBuilder(currentMeta.getData());
-
-        return mutateChildren(newMeta, dataBuilder, version, modification.getChildren());
-    }
-
-    @Override
-    protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification,
-            final Optional<TreeNode> current) throws DataValidationFailedException {
-        checkConflicting(path, current.isPresent(), "Node was deleted by other transaction.");
-        checkChildPreconditions(path, modification, current);
-    }
-
-    private void checkChildPreconditions(final InstanceIdentifier path, final NodeModification modification, final Optional<TreeNode> current) throws DataValidationFailedException {
-        final TreeNode currentMeta = current.get();
-        for (NodeModification childMod : modification.getChildren()) {
-            final PathArgument childId = childMod.getIdentifier();
-            final Optional<TreeNode> childMeta = currentMeta.getChild(childId);
-
-            InstanceIdentifier childPath = path.node(childId);
-            resolveChildOperation(childId).checkApplicable(childPath, childMod, childMeta);
-        }
-    }
-
-    @Override
-    protected void checkMergeApplicable(final InstanceIdentifier path, final NodeModification modification,
-            final Optional<TreeNode> current) throws DataValidationFailedException {
-        if(current.isPresent()) {
-            checkChildPreconditions(path, modification,current);
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    protected abstract NormalizedNodeContainerBuilder createBuilder(NormalizedNode<?, ?> original);
-
-    public static class ChoiceModificationStrategy extends NormalizedNodeContainerModificationStrategy {
-
-        private final Map<PathArgument, ModificationApplyOperation> childNodes;
-
-        public ChoiceModificationStrategy(final ChoiceNode schemaNode) {
-            super(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode.class);
-            ImmutableMap.Builder<PathArgument, ModificationApplyOperation> child = ImmutableMap.builder();
-
-            for (ChoiceCaseNode caze : schemaNode.getCases()) {
-                for (DataSchemaNode cazeChild : caze.getChildNodes()) {
-                    SchemaAwareApplyOperation childNode = from(cazeChild);
-                    child.put(new NodeIdentifier(cazeChild.getQName()), childNode);
-                }
-            }
-            childNodes = child.build();
-        }
-
-        @Override
-        public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
-            return Optional.fromNullable(childNodes.get(child));
-        }
-
-        @Override
-        @SuppressWarnings("rawtypes")
-        protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode);
-            return ImmutableChoiceNodeBuilder.create((org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) original);
-        }
-    }
-
-    public static class OrderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy {
-
-        private final Optional<ModificationApplyOperation> entryStrategy;
-
-        @SuppressWarnings({ "unchecked", "rawtypes" })
-        protected OrderedLeafSetModificationStrategy(final LeafListSchemaNode schema) {
-            super((Class) LeafSetNode.class);
-            entryStrategy = Optional.<ModificationApplyOperation> of(new LeafSetEntryModificationStrategy(schema));
-        }
-
-        @SuppressWarnings("rawtypes")
-        @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof OrderedLeafSetNode<?>);
-            return ImmutableOrderedLeafSetNodeBuilder.create((OrderedLeafSetNode<?>) original);
-        }
-
-        @Override
-        public Optional<ModificationApplyOperation> getChild(final PathArgument identifier) {
-            if (identifier instanceof NodeWithValue) {
-                return entryStrategy;
-            }
-            return Optional.absent();
-        }
-    }
-
-    public static class OrderedMapModificationStrategy extends NormalizedNodeContainerModificationStrategy {
-
-        private final Optional<ModificationApplyOperation> entryStrategy;
-
-        protected OrderedMapModificationStrategy(final ListSchemaNode schema) {
-            super(OrderedMapNode.class);
-            entryStrategy = Optional.<ModificationApplyOperation> of(new ListEntryModificationStrategy(schema));
-        }
-
-        @SuppressWarnings("rawtypes")
-        @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof OrderedMapNode);
-            return ImmutableOrderedMapNodeBuilder.create((OrderedMapNode) original);
-        }
-
-        @Override
-        public Optional<ModificationApplyOperation> getChild(final PathArgument identifier) {
-            if (identifier instanceof NodeIdentifierWithPredicates) {
-                return entryStrategy;
-            }
-            return Optional.absent();
-        }
-
-        @Override
-        public String toString() {
-            return "OrderedMapModificationStrategy [entry=" + entryStrategy + "]";
-        }
-    }
-
-    public static class UnorderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy {
-
-        private final Optional<ModificationApplyOperation> entryStrategy;
-
-        @SuppressWarnings({ "unchecked", "rawtypes" })
-        protected UnorderedLeafSetModificationStrategy(final LeafListSchemaNode schema) {
-            super((Class) LeafSetNode.class);
-            entryStrategy = Optional.<ModificationApplyOperation> of(new LeafSetEntryModificationStrategy(schema));
-        }
-
-        @SuppressWarnings("rawtypes")
-        @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof LeafSetNode<?>);
-            return ImmutableLeafSetNodeBuilder.create((LeafSetNode<?>) original);
-        }
-
-        @Override
-        public Optional<ModificationApplyOperation> getChild(final PathArgument identifier) {
-            if (identifier instanceof NodeWithValue) {
-                return entryStrategy;
-            }
-            return Optional.absent();
-        }
-    }
-
-    public static class UnorderedMapModificationStrategy extends NormalizedNodeContainerModificationStrategy {
-
-        private final Optional<ModificationApplyOperation> entryStrategy;
-
-        protected UnorderedMapModificationStrategy(final ListSchemaNode schema) {
-            super(MapNode.class);
-            entryStrategy = Optional.<ModificationApplyOperation> of(new ListEntryModificationStrategy(schema));
-        }
-
-        @SuppressWarnings("rawtypes")
-        @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode<?, ?> original) {
-            checkArgument(original instanceof MapNode);
-            return ImmutableMapNodeBuilder.create((MapNode) original);
-        }
-
-        @Override
-        public Optional<ModificationApplyOperation> getChild(final PathArgument identifier) {
-            if (identifier instanceof NodeIdentifierWithPredicates) {
-                return entryStrategy;
-            }
-            return Optional.absent();
-        }
-
-        @Override
-        public String toString() {
-            return "UnorderedMapModificationStrategy [entry=" + entryStrategy + "]";
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/OperationWithModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/OperationWithModification.java
deleted file mode 100644 (file)
index e1cc1a1..0000000
+++ /dev/null
@@ -1,68 +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.store.impl.tree.data;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Optional;
-
-final class OperationWithModification {
-
-    private final ModifiedNode modification;
-
-    private final ModificationApplyOperation applyOperation;
-
-    private OperationWithModification(final ModificationApplyOperation op, final ModifiedNode mod) {
-        this.modification = mod;
-        this.applyOperation = op;
-    }
-
-    public OperationWithModification write(final NormalizedNode<?, ?> value) {
-        modification.write(value);
-        applyOperation.verifyStructure(modification);
-        return this;
-    }
-
-    public OperationWithModification delete() {
-        modification.delete();
-        return this;
-    }
-
-    public ModifiedNode getModification() {
-        return modification;
-    }
-
-    public ModificationApplyOperation getApplyOperation() {
-        return applyOperation;
-    }
-
-    public Optional<TreeNode> apply(final Optional<TreeNode> data, final Version version) {
-        return applyOperation.apply(modification, data, version);
-    }
-
-    public static OperationWithModification from(final ModificationApplyOperation operation,
-            final ModifiedNode modification) {
-        return new OperationWithModification(operation, modification);
-
-    }
-
-    public void merge(final NormalizedNode<?, ?> data) {
-        modification.merge(data);
-        applyOperation.verifyStructure(modification);
-
-    }
-
-    public OperationWithModification forChild(final PathArgument childId) {
-        ModifiedNode childMod = modification.modifyChild(childId);
-        Optional<ModificationApplyOperation> childOp = applyOperation.getChild(childId);
-        return from(childOp.get(),childMod);
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperation.java
deleted file mode 100644 (file)
index f600635..0000000
+++ /dev/null
@@ -1,281 +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.store.impl.tree.data;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.List;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ConflictingModificationAppliedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.IncorrectDataStructureException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.ContainerModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.UnkeyedListItemModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.ChoiceModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.OrderedLeafSetModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.OrderedMapModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.UnorderedLeafSetModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.ValueNodeModificationStrategy.LeafModificationStrategy;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-abstract class SchemaAwareApplyOperation implements ModificationApplyOperation {
-    private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareApplyOperation.class);
-
-    public static SchemaAwareApplyOperation from(final DataSchemaNode schemaNode) {
-        if (schemaNode instanceof ContainerSchemaNode) {
-            return new ContainerModificationStrategy((ContainerSchemaNode) schemaNode);
-        } else if (schemaNode instanceof ListSchemaNode) {
-            return fromListSchemaNode((ListSchemaNode) schemaNode);
-        } else if (schemaNode instanceof ChoiceNode) {
-            return new ChoiceModificationStrategy((ChoiceNode) schemaNode);
-        } else if (schemaNode instanceof LeafListSchemaNode) {
-            return fromLeafListSchemaNode((LeafListSchemaNode) schemaNode);
-        } else if (schemaNode instanceof LeafSchemaNode) {
-            return new LeafModificationStrategy((LeafSchemaNode) schemaNode);
-        }
-        throw new IllegalArgumentException("Not supported schema node type for " + schemaNode.getClass());
-    }
-
-    public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree,
-            final AugmentationTarget augSchemas, final AugmentationIdentifier identifier) {
-        AugmentationSchema augSchema = null;
-
-        allAugments:
-            for (AugmentationSchema potential : augSchemas.getAvailableAugmentations()) {
-                for (DataSchemaNode child : potential.getChildNodes()) {
-                    if (identifier.getPossibleChildNames().contains(child.getQName())) {
-                        augSchema = potential;
-                        break allAugments;
-                    }
-                }
-            }
-
-        if (augSchema != null) {
-            return new DataNodeContainerModificationStrategy.AugmentationModificationStrategy(augSchema, resolvedTree);
-        }
-        return null;
-    }
-
-    public static boolean checkConflicting(final InstanceIdentifier path, final boolean condition, final String message) throws ConflictingModificationAppliedException {
-        if(!condition) {
-            throw new ConflictingModificationAppliedException(path, message);
-        }
-        return condition;
-    }
-
-    private static SchemaAwareApplyOperation fromListSchemaNode(final ListSchemaNode schemaNode) {
-        List<QName> keyDefinition = schemaNode.getKeyDefinition();
-        if (keyDefinition == null || keyDefinition.isEmpty()) {
-            return new UnkeyedListModificationStrategy(schemaNode);
-        }
-        if (schemaNode.isUserOrdered()) {
-            return new OrderedMapModificationStrategy(schemaNode);
-        }
-
-        return new NormalizedNodeContainerModificationStrategy.UnorderedMapModificationStrategy(schemaNode);
-    }
-
-    private static SchemaAwareApplyOperation fromLeafListSchemaNode(final LeafListSchemaNode schemaNode) {
-        if(schemaNode.isUserOrdered()) {
-            return new OrderedLeafSetModificationStrategy(schemaNode);
-        } else {
-            return new UnorderedLeafSetModificationStrategy(schemaNode);
-        }
-    }
-
-    private static final void checkNotConflicting(final InstanceIdentifier path, final TreeNode original, final TreeNode current) throws ConflictingModificationAppliedException {
-        checkConflicting(path, original.getVersion().equals(current.getVersion()),
-                "Node was replaced by other transaction.");
-        checkConflicting(path, original.getSubtreeVersion().equals(current.getSubtreeVersion()),
-                "Node children was modified by other transaction");
-    }
-
-    protected final ModificationApplyOperation resolveChildOperation(final PathArgument child) {
-        Optional<ModificationApplyOperation> potential = getChild(child);
-        checkArgument(potential.isPresent(), "Operation for child %s is not defined.", child);
-        return potential.get();
-    }
-
-    @Override
-    public void verifyStructure(final ModifiedNode modification) throws IllegalArgumentException {
-        if (modification.getType() == ModificationType.WRITE) {
-            verifyWrittenStructure(modification.getWrittenValue());
-        }
-    }
-
-    @Override
-    public final void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional<TreeNode> current) throws DataValidationFailedException {
-        switch (modification.getType()) {
-        case DELETE:
-            checkDeleteApplicable(modification, current);
-        case SUBTREE_MODIFIED:
-            checkSubtreeModificationApplicable(path, modification, current);
-            return;
-        case WRITE:
-            checkWriteApplicable(path, modification, current);
-            return;
-        case MERGE:
-            checkMergeApplicable(path, modification, current);
-            return;
-        case UNMODIFIED:
-            return;
-        default:
-            throw new UnsupportedOperationException("Suplied modification type "+ modification.getType()+ "is not supported.");
-        }
-
-    }
-
-    protected void checkMergeApplicable(final InstanceIdentifier path, final NodeModification modification, final Optional<TreeNode> current) throws DataValidationFailedException {
-        Optional<TreeNode> original = modification.getOriginal();
-        if (original.isPresent() && current.isPresent()) {
-            /*
-             * We need to do conflict detection only and only if the value of leaf changed
-             * before two transactions. If value of leaf is unchanged between two transactions
-             * it should not cause transaction to fail, since result of this merge
-             * leads to same data.
-             */
-            if(!original.get().getData().equals(current.get().getData())) {
-                checkNotConflicting(path, original.get(), current.get());
-            }
-        }
-    }
-
-    protected void checkWriteApplicable(final InstanceIdentifier path, final NodeModification modification, final Optional<TreeNode> current) throws DataValidationFailedException {
-        Optional<TreeNode> original = modification.getOriginal();
-        if (original.isPresent() && current.isPresent()) {
-            checkNotConflicting(path, original.get(), current.get());
-        } else if(original.isPresent()) {
-            throw new ConflictingModificationAppliedException(path,"Node was deleted by other transaction.");
-        }
-    }
-
-    private void checkDeleteApplicable(final NodeModification modification, final Optional<TreeNode> current) {
-        // Delete is always applicable, we do not expose it to subclasses
-        if (current.isPresent()) {
-            LOG.trace("Delete operation turned to no-op on missing node {}", modification);
-        }
-    }
-
-    @Override
-    public final Optional<TreeNode> apply(final ModifiedNode modification,
-            final Optional<TreeNode> currentMeta, final Version version) {
-
-        switch (modification.getType()) {
-        case DELETE:
-            return modification.storeSnapshot(Optional.<TreeNode> absent());
-        case SUBTREE_MODIFIED:
-            Preconditions.checkArgument(currentMeta.isPresent(), "Metadata not available for modification",
-                    modification);
-            return modification.storeSnapshot(Optional.of(applySubtreeChange(modification, currentMeta.get(),
-                    version)));
-        case MERGE:
-            if(currentMeta.isPresent()) {
-                return modification.storeSnapshot(Optional.of(applyMerge(modification,currentMeta.get(), version)));
-            } // Fallback to write is intentional - if node is not preexisting merge is same as write
-        case WRITE:
-            return modification.storeSnapshot(Optional.of(applyWrite(modification, currentMeta, version)));
-        case UNMODIFIED:
-            return currentMeta;
-        default:
-            throw new IllegalArgumentException("Provided modification type is not supported.");
-        }
-    }
-
-    protected abstract TreeNode applyMerge(ModifiedNode modification,
-            TreeNode currentMeta, Version version);
-
-    protected abstract TreeNode applyWrite(ModifiedNode modification,
-            Optional<TreeNode> currentMeta, Version version);
-
-    protected abstract TreeNode applySubtreeChange(ModifiedNode modification,
-            TreeNode currentMeta, Version version);
-
-    /**
-     *
-     * Checks is supplied {@link NodeModification} is applicable for Subtree Modification.
-     *
-     * @param path Path to current node
-     * @param modification Node modification which should be applied.
-     * @param current Current state of data tree
-     * @throws ConflictingModificationAppliedException If subtree was changed in conflicting way
-     * @throws IncorrectDataStructureException If subtree modification is not applicable (e.g. leaf node).
-     */
-    protected abstract void checkSubtreeModificationApplicable(InstanceIdentifier path, final NodeModification modification,
-            final Optional<TreeNode> current) throws DataValidationFailedException;
-
-    protected abstract void verifyWrittenStructure(NormalizedNode<?, ?> writtenValue);
-
-    public static class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation {
-
-        private final Optional<ModificationApplyOperation> entryStrategy;
-
-        protected UnkeyedListModificationStrategy(final ListSchemaNode schema) {
-            entryStrategy = Optional.<ModificationApplyOperation> of(new UnkeyedListItemModificationStrategy(schema));
-        }
-
-        @Override
-        protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta,
-                final Version version) {
-            return applyWrite(modification, Optional.of(currentMeta), version);
-        }
-
-        @Override
-        protected TreeNode applySubtreeChange(final ModifiedNode modification,
-                final TreeNode currentMeta, final Version version) {
-            throw new UnsupportedOperationException("UnkeyedList does not support subtree change.");
-        }
-
-        @Override
-        protected TreeNode applyWrite(final ModifiedNode modification,
-                final Optional<TreeNode> currentMeta, final Version version) {
-            return TreeNodeFactory.createTreeNode(modification.getWrittenValue(), version);
-        }
-
-        @Override
-        public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
-            if (child instanceof NodeIdentifier) {
-                return entryStrategy;
-            }
-            return Optional.absent();
-        }
-
-        @Override
-        protected void verifyWrittenStructure(final NormalizedNode<?, ?> writtenValue) {
-
-        }
-
-        @Override
-        protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification,
-                final Optional<TreeNode> current) throws IncorrectDataStructureException {
-            throw new IncorrectDataStructureException(path, "Subtree modification is not allowed.");
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ValueNodeModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ValueNodeModificationStrategy.java
deleted file mode 100644 (file)
index 900fa32..0000000
+++ /dev/null
@@ -1,88 +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.store.impl.tree.data;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.IncorrectDataStructureException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-
-import com.google.common.base.Optional;
-
-abstract class ValueNodeModificationStrategy<T extends DataSchemaNode> extends SchemaAwareApplyOperation {
-
-    private final T schema;
-    private final Class<? extends NormalizedNode<?, ?>> nodeClass;
-
-    protected ValueNodeModificationStrategy(final T schema, final Class<? extends NormalizedNode<?, ?>> nodeClass) {
-        super();
-        this.schema = schema;
-        this.nodeClass = nodeClass;
-    }
-
-    @Override
-    protected void verifyWrittenStructure(final NormalizedNode<?, ?> writtenValue) {
-        checkArgument(nodeClass.isInstance(writtenValue), "Node should must be of type %s", nodeClass);
-    }
-
-    @Override
-    public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
-        throw new UnsupportedOperationException("Node " + schema.getPath()
-                + "is leaf type node. Child nodes not allowed");
-    }
-
-    @Override
-    protected TreeNode applySubtreeChange(final ModifiedNode modification,
-            final TreeNode currentMeta, final Version version) {
-        throw new UnsupportedOperationException("Node " + schema.getPath()
-                + "is leaf type node. Subtree change is not allowed.");
-    }
-
-    @Override
-    protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta,
-            final Version version) {
-        // Just overwrite whatever was there
-        return applyWrite(modification, null, version);
-    }
-
-    @Override
-    protected TreeNode applyWrite(final ModifiedNode modification,
-            final Optional<TreeNode> currentMeta, final Version version) {
-        return TreeNodeFactory.createTreeNode(modification.getWrittenValue(), version);
-    }
-
-    @Override
-    protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification,
-            final Optional<TreeNode> current) throws IncorrectDataStructureException {
-        throw new IncorrectDataStructureException(path, "Subtree modification is not allowed.");
-    }
-
-    public static class LeafSetEntryModificationStrategy extends ValueNodeModificationStrategy<LeafListSchemaNode> {
-        @SuppressWarnings({ "unchecked", "rawtypes" })
-        protected LeafSetEntryModificationStrategy(final LeafListSchemaNode schema) {
-            super(schema, (Class) LeafSetEntryNode.class);
-        }
-    }
-
-    public static class LeafModificationStrategy extends ValueNodeModificationStrategy<LeafSchemaNode> {
-        @SuppressWarnings({ "unchecked", "rawtypes" })
-        protected LeafModificationStrategy(final LeafSchemaNode schema) {
-            super(schema, (Class) LeafNode.class);
-        }
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/AbstractTreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/AbstractTreeNode.java
deleted file mode 100644 (file)
index 522bf3c..0000000
+++ /dev/null
@@ -1,41 +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.store.impl.tree.spi;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-import com.google.common.base.Preconditions;
-
-/**
- * A very basic data tree node.
- */
-abstract class AbstractTreeNode implements TreeNode {
-    private final NormalizedNode<?, ?> data;
-    private final Version version;
-
-    protected AbstractTreeNode(final NormalizedNode<?, ?> data, final Version version) {
-        this.data = Preconditions.checkNotNull(data);
-        this.version = Preconditions.checkNotNull(version);
-    }
-
-    @Override
-    public PathArgument getIdentifier() {
-        return data.getIdentifier();
-    }
-
-    @Override
-    public final Version getVersion() {
-        return version;
-    }
-
-    @Override
-    public final NormalizedNode<?, ?> getData() {
-        return data;
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ContainerNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ContainerNode.java
deleted file mode 100644 (file)
index 3ca8db2..0000000
+++ /dev/null
@@ -1,118 +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.store.impl.tree.spi;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.opendaylight.yangtools.util.MapAdaptor;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-/**
- * A TreeNode capable of holding child nodes. The fact that any of the children
- * changed is tracked by the subtree version.
- */
-final class ContainerNode extends AbstractTreeNode {
-    private final Map<PathArgument, TreeNode> children;
-    private final Version subtreeVersion;
-
-    protected ContainerNode(final NormalizedNode<?, ?> data, final Version version,
-            final Map<PathArgument, TreeNode> children, final Version subtreeVersion) {
-        super(data, version);
-        this.children = Preconditions.checkNotNull(children);
-        this.subtreeVersion = Preconditions.checkNotNull(subtreeVersion);
-    }
-
-    @Override
-    public Version getSubtreeVersion() {
-        return subtreeVersion;
-    }
-
-    @Override
-    public Optional<TreeNode> getChild(final PathArgument key) {
-        return Optional.fromNullable(children.get(key));
-    }
-
-    @Override
-    public MutableTreeNode mutable() {
-        return new Mutable(this);
-    }
-
-    private static final class Mutable implements MutableTreeNode {
-        private final Version version;
-        private Map<PathArgument, TreeNode> children;
-        private NormalizedNode<?, ?> data;
-        private Version subtreeVersion;
-
-        private Mutable(final ContainerNode parent) {
-            this.data = parent.getData();
-            this.children = MapAdaptor.getDefaultInstance().takeSnapshot(parent.children);
-            this.subtreeVersion = parent.getSubtreeVersion();
-            this.version = parent.getVersion();
-        }
-
-        @Override
-        public Optional<TreeNode> getChild(final PathArgument child) {
-            return Optional.fromNullable(children.get(child));
-        }
-
-        @Override
-        public void setSubtreeVersion(final Version subtreeVersion) {
-            this.subtreeVersion = Preconditions.checkNotNull(subtreeVersion);
-        }
-
-        @Override
-        public void addChild(final TreeNode child) {
-            children.put(child.getIdentifier(), child);
-        }
-
-        @Override
-        public void removeChild(final PathArgument id) {
-            children.remove(id);
-        }
-
-        @Override
-        public TreeNode seal() {
-            final TreeNode ret = new ContainerNode(data, version, MapAdaptor.getDefaultInstance().optimize(children), subtreeVersion);
-
-            // This forces a NPE if this class is accessed again. Better than corruption.
-            children = null;
-            return ret;
-        }
-
-        @Override
-        public void setData(final NormalizedNode<?, ?> data) {
-            this.data = Preconditions.checkNotNull(data);
-        }
-    }
-
-    private static ContainerNode create(final Version version, final NormalizedNode<?, ?> data,
-            final Iterable<NormalizedNode<?, ?>> children) {
-
-        final Map<PathArgument, TreeNode> map = new HashMap<>();
-        for (NormalizedNode<?, ?> child : children) {
-            map.put(child.getIdentifier(), TreeNodeFactory.createTreeNode(child, version));
-        }
-
-        return new ContainerNode(data, version, map, version);
-    }
-
-    public static ContainerNode create(final Version version, final NormalizedNodeContainer<?, ?, NormalizedNode<?, ?>> container) {
-        return create(version, container, container.getValue());
-    }
-
-    public static ContainerNode create(final Version version, final OrderedNodeContainer<NormalizedNode<?, ?>> container) {
-        return create(version, container, container.getValue());
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/MutableTreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/MutableTreeNode.java
deleted file mode 100644 (file)
index 087f4de..0000000
+++ /dev/null
@@ -1,59 +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.store.impl.tree.spi;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * A mutable tree node. This is a transient view materialized from a pre-existing
- * node. Modifications are isolated. Once this object is {@link #seal()}-ed,
- * any interactions with it will result in undefined behavior.
- */
-public interface MutableTreeNode extends StoreTreeNode<TreeNode> {
-    /**
-     * Set the data component of the node.
-     *
-     * @param data New data component, may not be null.
-     */
-    void setData(NormalizedNode<?, ?> data);
-
-    /**
-     * Set the new subtree version. This is typically invoked when the user
-     * has modified some of this node's children.
-     *
-     * @param subtreeVersion New subtree version.
-     */
-    void setSubtreeVersion(Version subtreeVersion);
-
-    /**
-     * Add a new child node. This acts as add-or-replace operation, e.g. it
-     * succeeds even if a conflicting child is already present.
-     *
-     * @param child New child node.
-     */
-    void addChild(TreeNode child);
-
-    /**
-     * Remove a child node. This acts as delete-or-nothing operation, e.g. it
-     * succeeds even if the corresponding child is not present.
-     *
-     * @param id Child identificator.
-     */
-    void removeChild(PathArgument id);
-
-    /**
-     * Finish node modification and return a read-only view of this node. After
-     * this method is invoked, any further calls to this object's method result
-     * in undefined behavior.
-     *
-     * @return Read-only view of this node.
-     */
-    TreeNode seal();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNode.java
deleted file mode 100644 (file)
index def1958..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.sal.dom.store.impl.tree.spi;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * A very basic data tree node. It has a version (when it was last modified),
- * a subtree version (when any of its children were modified) and some read-only
- * data.
- */
-public interface TreeNode extends Identifiable<PathArgument>, StoreTreeNode<TreeNode> {
-    /**
-     * Get the data node version.
-     *
-     * @return Current data node version.
-     */
-    Version getVersion();
-
-    /**
-     * Get the subtree version.
-     *
-     * @return Current subtree version.
-     */
-    Version getSubtreeVersion();
-
-    /**
-     * Get a read-only view of the underlying data.
-     *
-     * @return Unmodifiable view of the underlying data.
-     */
-    NormalizedNode<?, ?> getData();
-
-    /**
-     * Get a mutable, isolated copy of the node.
-     *
-     * @return Mutable copy
-     */
-    MutableTreeNode mutable();
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNodeFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNodeFactory.java
deleted file mode 100644 (file)
index 9547628..0000000
+++ /dev/null
@@ -1,46 +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.store.impl.tree.spi;
-
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer;
-
-/**
- * Public entrypoint for other packages. Allows instantiating a tree node
- * with specified version.
- */
-public final class TreeNodeFactory {
-    private TreeNodeFactory() {
-        throw new UnsupportedOperationException("Utility class should not be instantiated");
-    }
-
-    /**
-     * Create a new AbstractTreeNode from a data node, descending recursively as needed.
-     * This method should only ever be used for new data.
-     *
-     * @param data data node
-     * @param version data node version
-     * @return new AbstractTreeNode instance, covering the data tree provided
-     */
-    public static final TreeNode createTreeNode(final NormalizedNode<?, ?> data, final Version version) {
-        if (data instanceof NormalizedNodeContainer<?, ?, ?>) {
-            @SuppressWarnings("unchecked")
-            NormalizedNodeContainer<?, ?, NormalizedNode<?, ?>> container = (NormalizedNodeContainer<?, ?, NormalizedNode<?, ?>>) data;
-            return ContainerNode.create(version, container);
-
-        }
-        if (data instanceof OrderedNodeContainer<?>) {
-            @SuppressWarnings("unchecked")
-            OrderedNodeContainer<NormalizedNode<?, ?>> container = (OrderedNodeContainer<NormalizedNode<?, ?>>) data;
-            return ContainerNode.create(version, container);
-        }
-
-        return new ValueNode(data, version);
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ValueNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ValueNode.java
deleted file mode 100644 (file)
index d89928b..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.sal.dom.store.impl.tree.spi;
-
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-
-/**
- * Concretization of AbstractTreeNode for leaf nodes which only contain data.
- * Instances of this class report all children as absent, subtree version
- * equal to this node's version and do not support mutable view.
- */
-final class ValueNode extends AbstractTreeNode {
-    private static final Logger LOG = LoggerFactory.getLogger(ValueNode.class);
-
-    protected ValueNode(final NormalizedNode<?, ?> data, final Version version) {
-        super(data, version);
-    }
-
-    @Override
-    public Optional<TreeNode> getChild(final PathArgument childId) {
-        LOG.warn("Attempted to access child {} of value-node {}", childId, this);
-        return Optional.absent();
-    }
-
-    @Override
-    public Version getSubtreeVersion() {
-        return getVersion();
-    }
-
-    @Override
-    public MutableTreeNode mutable() {
-        /**
-         * Value nodes can only we read/written/delete, which does a straight
-         * replace. That means they don't haver need to be made mutable.
-         */
-        throw new UnsupportedOperationException(String.format("Attempted to mutate value-node %s", this));
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/Version.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/Version.java
deleted file mode 100644 (file)
index 09a35d3..0000000
+++ /dev/null
@@ -1,37 +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.store.impl.tree.spi;
-
-/**
- * The concept of a version, either node version, or a subtree version. The
- * only interface contract this class has is that no two versions are the
- * same.
- */
-public final class Version {
-    private Version() {
-
-    }
-
-    /**
-     * Create a new version, distinct from any other version.
-     *
-     * @return a new version.
-     */
-    public Version next() {
-        return new Version();
-    }
-
-    /**
-     * Create an initial version.
-     *
-     * @return a new version.
-     */
-    public static final Version initial() {
-        return new Version();
-    }
-}
index b0ccfb995db612188cff2bbb5014def94911e4d7..4f44f361d5d352e51378a681ef57dc48ebddd78c 100644 (file)
@@ -4,7 +4,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
@@ -19,7 +19,7 @@ public class DOMDataBrokerProxy extends AbstractBrokerServiceProxy<DOMDataBroker
     }
 
     @Override
-    public DOMDataReadTransaction newReadOnlyTransaction() {
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
         return getDelegate().newReadOnlyTransaction();
     }
 
index 3c29fe588567dafee48c5f4e628e4eb22a8364fc..82897b0198cbf183953f2051f87c8fcfe9f030a8 100644 (file)
@@ -6,9 +6,14 @@ module opendaylight-sal-dom-broker-impl {
        import config { prefix config; revision-date 2013-04-05; }
        import opendaylight-md-sal-dom {prefix sal;}
        import opendaylight-md-sal-common {prefix common;}
+       import opendaylight-config-dom-datastore {prefix config-dom-store-spi;}
+       import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;}
 
     description
-        "Service definition for Binding Aware MD-SAL.";
+        "Service definition for Binding Aware MD-SAL.
+        Note: The dom-inmemory-data-broker utilizes configurable config-dom-datastore
+        and operation-dom-datastore. If configuration is not done for this stores
+        then it defaults to InMemoryDOMDataStore";
  
     revision "2013-10-28" {
         description
@@ -66,7 +71,8 @@ module opendaylight-sal-dom-broker-impl {
     augment "/config:modules/config:module/config:configuration" {
         case dom-inmemory-data-broker {
             when "/config:modules/config:module/config:type = 'dom-inmemory-data-broker'";
-            
+
+
             container schema-service {
                 uses config:service-ref {
                     refine type {
@@ -74,7 +80,25 @@ module opendaylight-sal-dom-broker-impl {
                         config:required-identity sal:schema-service;
                     }
                 }
-            
+
+            }
+
+            container config-data-store{
+                 uses config:service-ref {
+                     refine type {
+                         mandatory false;
+                         config:required-identity  config-dom-store-spi:config-dom-datastore;
+                     }
+                 }
+            }
+
+            container operational-data-store{
+                  uses config:service-ref {
+                       refine type {
+                           mandatory false;
+                           config:required-identity operational-dom-store-spi:operational-dom-datastore;
+                       }
+                   }
             }
         }
     }
index 66d57f9f87ae9181b549f2a2029b938509473618..29e078918e65eeae080f62c61d6ce5bae4fc3a9f 100644 (file)
@@ -63,8 +63,8 @@ public class DOMBrokerPerformanceTest {
 
     @Before
     public void setupStore() {
-        InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
-        InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
+       InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
+       InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
         schemaContext = TestModel.createTestContext();
 
         operStore.onGlobalContextUpdated(schemaContext);
index 2a955e5f4215e6dccc0c397ca9c0850ccb159aa3..38f08b30f94ea37d4e73e3537c5c7bd798eb12ed 100644 (file)
@@ -104,28 +104,29 @@ public class DOMTransactionChainTest {
          */
         DOMDataReadWriteTransaction thirdDeleteTx = allocateAndDelete(txChain);
 
-        /**
-         * third transaction is sealed.
-         */
-        ListenableFuture<RpcResult<TransactionStatus>> thirdDeleteTxFuture = thirdDeleteTx.commit();
-
         /**
          * We commit first transaction
          *
          */
         assertCommitSuccessful(firstWriteTxFuture);
 
-        // Alocates store transaction
+        /**
+         *
+         * Allocates transaction from data store.
+         *
+         */
         DOMDataReadTransaction storeReadTx = domBroker.newReadOnlyTransaction();
+
         /**
          * We verify transaction is commited to store, container should exists
          * in datastore.
          */
         assertTestContainerExists(storeReadTx);
+
         /**
-         * We commit third transaction
-         *
+         * third transaction is sealed and commited
          */
+        ListenableFuture<RpcResult<TransactionStatus>> thirdDeleteTxFuture = thirdDeleteTx.commit();
         assertCommitSuccessful(thirdDeleteTxFuture);
 
         /**
diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java
deleted file mode 100644 (file)
index 413d81d..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-package org.opendaylight.controller.md.sal.dom.store.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutionException;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-
-public class InMemoryDataStoreTest {
-
-    private SchemaContext schemaContext;
-    private InMemoryDOMDataStore domStore;
-
-    @Before
-    public void setupStore() {
-        domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.sameThreadExecutor());
-        schemaContext = TestModel.createTestContext();
-        domStore.onGlobalContextUpdated(schemaContext);
-
-    }
-
-    @Test
-    public void testTransactionIsolation() throws InterruptedException, ExecutionException {
-
-        assertNotNull(domStore);
-
-        DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
-        assertNotNull(readTx);
-
-        DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
-        assertNotNull(writeTx);
-        /**
-         *
-         * Writes /test in writeTx
-         *
-         */
-        writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
-        /**
-         *
-         * Reads /test from writeTx Read should return container.
-         *
-         */
-        ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
-        assertTrue(writeTxContainer.get().isPresent());
-
-        /**
-         *
-         * Reads /test from readTx Read should return Absent.
-         *
-         */
-        ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
-        assertFalse(readTxContainer.get().isPresent());
-    }
-
-    @Test
-    public void testTransactionCommit() throws InterruptedException, ExecutionException {
-
-        DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
-        assertNotNull(writeTx);
-        /**
-         *
-         * Writes /test in writeTx
-         *
-         */
-        writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
-        /**
-         *
-         * Reads /test from writeTx Read should return container.
-         *
-         */
-        ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
-        assertTrue(writeTxContainer.get().isPresent());
-
-        DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
-
-        assertThreePhaseCommit(cohort);
-
-        Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
-                .get();
-        assertTrue(afterCommitRead.isPresent());
-    }
-
-    @Test
-    public void testTransactionAbort() throws InterruptedException, ExecutionException {
-
-        DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
-        assertNotNull(writeTx);
-
-        assertTestContainerWrite(writeTx);
-
-        DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
-
-        assertTrue(cohort.canCommit().get().booleanValue());
-        cohort.preCommit().get();
-        cohort.abort().get();
-
-        Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
-                .get();
-        assertFalse(afterCommitRead.isPresent());
-    }
-
-    @Test
-    public void testTransactionChain() throws InterruptedException, ExecutionException {
-        DOMStoreTransactionChain txChain = domStore.createTransactionChain();
-        assertNotNull(txChain);
-
-        /**
-         * We alocate new read-write transaction and write /test
-         *
-         *
-         */
-        DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
-        assertTestContainerWrite(firstTx);
-
-        /**
-         * First transaction is marked as ready, we are able to allocate chained
-         * transactions
-         */
-        DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
-
-        /**
-         * We alocate chained transaction - read transaction, note first one is
-         * still not commited to datastore.
-         */
-        DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
-
-        /**
-         *
-         * We test if we are able to read data from tx, read should not fail
-         * since we are using chained transaction.
-         *
-         *
-         */
-        assertTestContainerExists(secondReadTx);
-
-        /**
-         *
-         * We alocate next transaction, which is still based on first one, but
-         * is read-write.
-         *
-         */
-        DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
-
-        /**
-         * We test existence of /test in third transaction container should
-         * still be visible from first one (which is still uncommmited).
-         *
-         *
-         */
-        assertTestContainerExists(thirdDeleteTx);
-
-        /**
-         * We delete node in third transaction
-         */
-        thirdDeleteTx.delete(TestModel.TEST_PATH);
-
-        /**
-         * third transaction is sealed.
-         */
-        DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready();
-
-        /**
-         * We commit first transaction
-         *
-         */
-        assertThreePhaseCommit(firstWriteTxCohort);
-
-        // Alocates store transacion
-        DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction();
-        /**
-         * We verify transaction is commited to store, container should exists
-         * in datastore.
-         */
-        assertTestContainerExists(storeReadTx);
-        /**
-         * We commit third transaction
-         *
-         */
-        assertThreePhaseCommit(thirdDeleteTxCohort);
-    }
-
-    @Test
-    @Ignore
-    public void testTransactionConflict() throws InterruptedException, ExecutionException {
-        DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction();
-        DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction();
-        assertTestContainerWrite(txOne);
-        assertTestContainerWrite(txTwo);
-
-        /**
-         * Commits transaction
-         */
-        assertThreePhaseCommit(txOne.ready());
-
-        /**
-         * Asserts that txTwo could not be commited
-         */
-        assertFalse(txTwo.ready().canCommit().get());
-    }
-
-    private static void assertThreePhaseCommit(final DOMStoreThreePhaseCommitCohort cohort)
-            throws InterruptedException, ExecutionException {
-        assertTrue(cohort.canCommit().get().booleanValue());
-        cohort.preCommit().get();
-        cohort.commit().get();
-    }
-
-    private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
-            throws InterruptedException, ExecutionException {
-        /**
-         *
-         * Writes /test in writeTx
-         *
-         */
-        writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
-        return assertTestContainerExists(writeTx);
-    }
-
-    /**
-     *
-     * Reads /test from readTx Read should return container.
-     *
-     */
-    private static Optional<NormalizedNode<?, ?>> assertTestContainerExists(DOMStoreReadTransaction readTx)
-            throws InterruptedException, ExecutionException {
-
-        ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = readTx.read(TestModel.TEST_PATH);
-        assertTrue(writeTxContainer.get().isPresent());
-        return writeTxContainer.get();
-    }
-
-}
index 2c965047dbf1dea8112a2b8b4fe9bc414ae34665..91aa57c25957a392bffb82f092c4b19f0a5ba4ed 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 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.InputStream;
+import java.util.Collections;
+import java.util.Set;
+
 public class TestModel {
 
     public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationMetadataTreeTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationMetadataTreeTest.java
deleted file mode 100644 (file)
index 4fb190f..0000000
+++ /dev/null
@@ -1,259 +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.store.impl.tree.data;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.ID_QNAME;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.INNER_LIST_QNAME;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.NAME_QNAME;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.OUTER_LIST_PATH;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.OUTER_LIST_QNAME;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.TEST_PATH;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.TEST_QNAME;
-import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.VALUE_QNAME;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTree;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-import com.google.common.base.Optional;
-
-/**
- *
- * Schema structure of document is
- *
- * <pre>
- * container root { 
- *      list list-a {
- *              key leaf-a;
- *              leaf leaf-a;
- *              choice choice-a {
- *                      case one {
- *                              leaf one;
- *                      }
- *                      case two-three {
- *                              leaf two;
- *                              leaf three;
- *                      }
- *              }
- *              list list-b {
- *                      key leaf-b;
- *                      leaf leaf-b;
- *              }
- *      }
- * }
- * </pre>
- *
- */
-public class ModificationMetadataTreeTest {
-
-    private static final Short ONE_ID = 1;
-    private static final Short TWO_ID = 2;
-    private static final String TWO_ONE_NAME = "one";
-    private static final String TWO_TWO_NAME = "two";
-
-    private static final InstanceIdentifier OUTER_LIST_1_PATH = InstanceIdentifier.builder(OUTER_LIST_PATH)
-            .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) //
-            .build();
-
-    private static final InstanceIdentifier OUTER_LIST_2_PATH = InstanceIdentifier.builder(OUTER_LIST_PATH)
-            .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
-            .build();
-
-    private static final InstanceIdentifier TWO_TWO_PATH = InstanceIdentifier.builder(OUTER_LIST_2_PATH)
-            .node(INNER_LIST_QNAME) //
-            .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) //
-            .build();
-
-    private static final InstanceIdentifier TWO_TWO_VALUE_PATH = InstanceIdentifier.builder(TWO_TWO_PATH)
-            .node(VALUE_QNAME) //
-            .build();
-
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
-            .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
-                    .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) //
-                    .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) //
-                    .build()) //
-                    .build();
-
-    private SchemaContext schemaContext;
-    private ModificationApplyOperation applyOper;
-
-    @Before
-    public void prepare() {
-        schemaContext = TestModel.createTestContext();
-        assertNotNull("Schema context must not be null.", schemaContext);
-        applyOper = SchemaAwareApplyOperation.from(schemaContext);
-    }
-
-    /**
-     * Returns a test document
-     *
-     * <pre>
-     * test
-     *     outer-list
-     *          id 1
-     *     outer-list
-     *          id 2
-     *          inner-list
-     *                  name "one"
-     *          inner-list
-     *                  name "two"
-     *
-     * </pre>
-     *
-     * @return
-     */
-    public NormalizedNode<?, ?> createDocumentOne() {
-        return ImmutableContainerNodeBuilder
-                .create()
-                .withNodeIdentifier(new NodeIdentifier(schemaContext.getQName()))
-                .withChild(createTestContainer()).build();
-
-    }
-
-    private ContainerNode createTestContainer() {
-        return ImmutableContainerNodeBuilder
-                .create()
-                .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
-                .withChild(
-                        mapNodeBuilder(OUTER_LIST_QNAME)
-                        .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
-                        .withChild(BAR_NODE).build()).build();
-    }
-
-    @Test
-    public void basicReadWrites() {
-        DataTreeModification modificationTree = new InMemoryDataTreeModification(new InMemoryDataTreeSnapshot(schemaContext,
-                TreeNodeFactory.createTreeNode(createDocumentOne(), Version.initial()), applyOper),
-                new SchemaAwareApplyOperationRoot(schemaContext));
-        Optional<NormalizedNode<?, ?>> originalBarNode = modificationTree.readNode(OUTER_LIST_2_PATH);
-        assertTrue(originalBarNode.isPresent());
-        assertSame(BAR_NODE, originalBarNode.get());
-
-        // writes node to /outer-list/1/inner_list/two/value
-        modificationTree.write(TWO_TWO_VALUE_PATH, ImmutableNodes.leafNode(VALUE_QNAME, "test"));
-
-        // reads node to /outer-list/1/inner_list/two/value
-        // and checks if node is already present
-        Optional<NormalizedNode<?, ?>> barTwoCModified = modificationTree.readNode(TWO_TWO_VALUE_PATH);
-        assertTrue(barTwoCModified.isPresent());
-        assertEquals(ImmutableNodes.leafNode(VALUE_QNAME, "test"), barTwoCModified.get());
-
-        // delete node to /outer-list/1/inner_list/two/value
-        modificationTree.delete(TWO_TWO_VALUE_PATH);
-        Optional<NormalizedNode<?, ?>> barTwoCAfterDelete = modificationTree.readNode(TWO_TWO_VALUE_PATH);
-        assertFalse(barTwoCAfterDelete.isPresent());
-    }
-
-
-    public DataTreeModification createEmptyModificationTree() {
-        /**
-         * Creates empty Snapshot with associated schema context.
-         */
-        DataTree t = InMemoryDataTreeFactory.getInstance().create();
-        t.setSchemaContext(schemaContext);
-
-        /**
-         *
-         * Creates Mutable Data Tree based on provided snapshot and schema
-         * context.
-         *
-         */
-        return t.takeSnapshot().newModification();
-    }
-
-    @Test
-    public void createFromEmptyState() {
-
-        DataTreeModification modificationTree = createEmptyModificationTree();
-        /**
-         * Writes empty container node to /test
-         *
-         */
-        modificationTree.write(TEST_PATH, ImmutableNodes.containerNode(TEST_QNAME));
-
-        /**
-         * Writes empty list node to /test/outer-list
-         */
-        modificationTree.write(OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME).build());
-
-        /**
-         * Reads list node from /test/outer-list
-         */
-        Optional<NormalizedNode<?, ?>> potentialOuterList = modificationTree.readNode(OUTER_LIST_PATH);
-        assertTrue(potentialOuterList.isPresent());
-
-        /**
-         * Reads container node from /test and verifies that it contains test
-         * node
-         */
-        Optional<NormalizedNode<?, ?>> potentialTest = modificationTree.readNode(TEST_PATH);
-        ContainerNode containerTest = assertPresentAndType(potentialTest, ContainerNode.class);
-
-        /**
-         *
-         * Gets list from returned snapshot of /test and verifies it contains
-         * outer-list
-         *
-         */
-        assertPresentAndType(containerTest.getChild(new NodeIdentifier(OUTER_LIST_QNAME)), MapNode.class);
-
-    }
-
-    @Test
-    public void writeSubtreeReadChildren() {
-        DataTreeModification modificationTree = createEmptyModificationTree();
-        modificationTree.write(TEST_PATH, createTestContainer());
-        Optional<NormalizedNode<?, ?>> potential = modificationTree.readNode(TWO_TWO_PATH);
-        assertPresentAndType(potential, MapEntryNode.class);
-    }
-
-    @Test
-    public void writeSubtreeDeleteChildren() {
-        DataTreeModification modificationTree = createEmptyModificationTree();
-        modificationTree.write(TEST_PATH, createTestContainer());
-
-        // We verify data are present
-        Optional<NormalizedNode<?, ?>> potentialBeforeDelete = modificationTree.readNode(TWO_TWO_PATH);
-        assertPresentAndType(potentialBeforeDelete, MapEntryNode.class);
-
-        modificationTree.delete(TWO_TWO_PATH);
-        Optional<NormalizedNode<?, ?>> potentialAfterDelete = modificationTree.readNode(TWO_TWO_PATH);
-        assertFalse(potentialAfterDelete.isPresent());
-
-    }
-
-    private static <T> T assertPresentAndType(final Optional<?> potential, final Class<T> type) {
-        assertNotNull(potential);
-        assertTrue(potential.isPresent());
-        assertTrue(type.isInstance(potential.get()));
-        return type.cast(potential.get());
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperationRoot.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperationRoot.java
deleted file mode 100644 (file)
index 03ece2f..0000000
+++ /dev/null
@@ -1,39 +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.store.impl.tree.data;
-
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class SchemaAwareApplyOperationRoot extends DataNodeContainerModificationStrategy<ContainerSchemaNode> {
-    private final SchemaContext context;
-
-    public SchemaAwareApplyOperationRoot(final SchemaContext context) {
-        super(context,ContainerNode.class);
-        this.context = context;
-    }
-
-    public SchemaContext getContext() {
-        return context;
-    }
-
-    @Override
-    public String toString() {
-        return "SchemaAwareApplyOperationRoot [context=" + context + "]";
-    }
-
-    @Override
-    @SuppressWarnings("rawtypes")
-    protected DataContainerNodeBuilder createBuilder(NormalizedNode<?, ?> original) {
-        return ImmutableContainerNodeBuilder.create((ContainerNode) original);
-    }
-}
index 660a67923ffe5ba06a37484a571505c801af7931..88ac86a45e3f6259a53da0e71f4fb5f2f6a8ed50 100644 (file)
       <artifactId>sal-core-api</artifactId>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yang-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>config</id>
+            <goals>
+              <goal>generate-sources</goal>
+            </goals>
+            <configuration>
+              <codeGenerators>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+                  <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                  <additionalConfiguration>
+                    <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+                  </additionalConfiguration>
+                </generator>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+                  <outputBaseDir>${salGeneratorPath}</outputBaseDir>
+                </generator>
+              </codeGenerators>
+              <inspectDependencies>true</inspectDependencies>
+            </configuration>
+          </execution>
+        </executions>
+      </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>
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-config-dom-datastore.yang b/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-config-dom-datastore.yang
new file mode 100644 (file)
index 0000000..9a3ab18
--- /dev/null
@@ -0,0 +1,22 @@
+module opendaylight-config-dom-datastore {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store";
+    prefix "config-dom-store-spi";
+
+       import config { prefix config; revision-date 2013-04-05; }
+
+        description
+            "DOM Service Provider Interface definition for MD-SAL config store";
+
+     revision "2014-06-17" {
+             description
+                 "Initial revision";
+         }
+
+     identity config-dom-datastore {
+             base "config:service-type";
+             config:java-class  "org.opendaylight.controller.sal.core.spi.data.DOMStore";
+
+     }
+
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-operational-dom-datastore.yang b/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-operational-dom-datastore.yang
new file mode 100644 (file)
index 0000000..fd40884
--- /dev/null
@@ -0,0 +1,22 @@
+module opendaylight-operational-dom-datastore {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store";
+    prefix "operational-dom-store-spi";
+
+       import config { prefix config; revision-date 2013-04-05; }
+
+        description
+            "DOM Service Provider Interface definition for MD-SAL operational store";
+
+     revision "2014-06-17" {
+             description
+                 "Initial revision";
+         }
+
+     identity operational-dom-datastore {
+             base "config:service-type";
+             config:java-class  "org.opendaylight.controller.sal.core.spi.data.DOMStore";
+
+     }
+
+}
\ No newline at end of file
similarity index 57%
rename from opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml
rename to opendaylight/md-sal/sal-inmemory-datastore/pom.xml
index 63b80e91811ce6080d9dec87e1ca84c6a422e14a..dadef821eb349e048d8395f6ab1c24cb39eb89b4 100644 (file)
@@ -5,79 +5,74 @@
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>sal-parent</artifactId>
     <version>1.1-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
   </parent>
 
-  <artifactId>sal-remoterpc-connector</artifactId>
-  <packaging>bundle</packaging>
+  <artifactId>sal-inmemory-datastore</artifactId>
 
-  <properties>
-    <stax.version>1.0.1</stax.version>
-    <zeromq.version>0.3.1</zeromq.version>
-  </properties>
+  <packaging>bundle</packaging>
 
   <dependencies>
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sal-common-util</artifactId>
-      <version>${project.version}</version>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
     </dependency>
+
+    <!-- SAL Dependencies -->
+
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sal-connector-api</artifactId>
-      <version>${project.version}</version>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>config-api</artifactId>
     </dependency>
-    <!-- MD Sal interdependencies -->
+
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sal-core-api</artifactId>
-      <version>${project.version}</version>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-api</artifactId>
     </dependency>
+
     <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-annotations</artifactId>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-config</artifactId>
     </dependency>
 
     <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-core</artifactId>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-api</artifactId>
     </dependency>
 
     <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-databind</artifactId>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-util</artifactId>
     </dependency>
+
     <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-core-api</artifactId>
     </dependency>
-
-    <!-- Tests -->
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-core-spi</artifactId>
     </dependency>
+
     <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>concepts</artifactId>
     </dependency>
+
     <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>remoterpc-routingtable.implementation</artifactId>
-      <version>${project.version}</version>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>util</artifactId>
     </dependency>
 
-    <!-- AD Sal -->
     <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
     </dependency>
 
-    <!-- Yang tools -->
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-common</artifactId>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-data-api</artifactId>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-data-impl</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-parser-impl</artifactId>
+    </dependency>
 
-    <!-- Third Party -->
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
     </dependency>
+
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.zeromq</groupId>
-      <artifactId>jeromq</artifactId>
-      <version>${zeromq.version}</version>
-    </dependency>
 
+    <!-- Test Dependencies -->
     <dependency>
-      <groupId>stax</groupId>
-      <artifactId>stax-api</artifactId>
-      <version>${stax.version}</version>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
         <extensions>true</extensions>
         <configuration>
           <instructions>
-            <Import-Package>*,
-                            !org.codehaus.enunciate.jaxrs</Import-Package>
-            <Export-Package>org.opendaylight.controller.config.yang.md.sal.remote.rpc,
-                            org.opendaylight.controller.sal.connector.remoterpc.util,
-                            org.opendaylight.controller.sal.connector.remoterpc.dto,
-                            org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcClient,
-                            org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcServer,
-                            org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcProvider</Export-Package>
             <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+
+            <Export-Package>org.opendaylight.controller.md.sal.dom.store.impl.*</Export-Package>
+
+            <Import-Package>*</Import-Package>
           </instructions>
         </configuration>
       </plugin>
-
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>org.opendaylight.controller.*</include>
+          </includes>
+          <check>false</check>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <goals>
+              <goal>report</goal>
+            </goals>
+            <phase>test</phase>
+          </execution>
+        </executions>
+      </plugin>
       <plugin>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yang-maven-plugin</artifactId>
         <executions>
           <execution>
+            <id>config</id>
             <goals>
               <goal>generate-sources</goal>
             </goals>
                   <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
                   <outputBaseDir>${salGeneratorPath}</outputBaseDir>
                 </generator>
-                <generator>
-                  <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
-                  <outputBaseDir>target/site/models</outputBaseDir>
-                </generator>
-
-                <generator>
-                  <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
-                  <outputBaseDir>target/site/models</outputBaseDir>
-                </generator>
               </codeGenerators>
               <inspectDependencies>true</inspectDependencies>
             </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://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Architecture:Clustering</url>
+  </scm>
+
 </project>
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java
new file mode 100644 (file)
index 0000000..3ed02df
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+
+import com.google.common.util.concurrent.MoreExecutors;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+
+public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModule {
+    public InMemoryConfigDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public InMemoryConfigDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.inmemory_datastore_provider.InMemoryConfigDataStoreProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+      InMemoryDOMDataStore   ids = new InMemoryDOMDataStore("DOM-CFG", MoreExecutors.sameThreadExecutor());
+      getSchemaServiceDependency().registerSchemaServiceListener(ids);
+      return ids;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java
new file mode 100644 (file)
index 0000000..1931c14
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: opendaylight-inmemory-datastore-provider yang module local name: inmemory-config-datastore-provider
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Thu Jun 19 17:10:42 PDT 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+public class InMemoryConfigDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModuleFactory {
+
+}
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java
new file mode 100644 (file)
index 0000000..eea9599
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+
+import com.google.common.util.concurrent.MoreExecutors;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+
+public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModule {
+    public InMemoryOperationalDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public InMemoryOperationalDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.inmemory_datastore_provider.InMemoryOperationalDataStoreProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+      InMemoryDOMDataStore ids = new InMemoryDOMDataStore("DOM-OPER", MoreExecutors.sameThreadExecutor());
+      getSchemaServiceDependency().registerSchemaServiceListener(ids);
+      return ids;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java
new file mode 100644 (file)
index 0000000..49bc6a2
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: opendaylight-inmemory-datastore-provider yang module local name: inmemory-operational-datastore-provider
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Thu Jun 19 17:10:42 PDT 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+public class InMemoryOperationalDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModuleFactory {
+
+}
@@ -7,27 +7,25 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.Collections;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.annotation.concurrent.GuardedBy;
-
+import com.google.common.base.Optional;
+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.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ConflictingModificationAppliedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTree;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.InMemoryDataTreeFactory;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
@@ -44,12 +42,12 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
+import javax.annotation.concurrent.GuardedBy;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static com.google.common.base.Preconditions.checkState;
 
 /**
  * In-memory DOM Data Store
@@ -61,12 +59,13 @@ import com.google.common.util.concurrent.ListeningExecutorService;
  *
  */
 public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, SchemaContextListener,
-        TransactionReadyPrototype {
+        TransactionReadyPrototype,AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
     private final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create();
     private final ListenerTree listenerTree = ListenerTree.create();
     private final AtomicLong txCounter = new AtomicLong(0);
     private final ListeningExecutorService executor;
+
     private final String name;
 
     public InMemoryDOMDataStore(final String name, final ListeningExecutorService executor) {
@@ -104,6 +103,10 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
         dataTree.setSchemaContext(ctx);
     }
 
+    @Override
+    public void close(){
+        executor.shutdownNow();
+    }
     @Override
     public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerChangeListener(
             final InstanceIdentifier path, final L listener, final DataChangeScope scope) {
@@ -218,6 +221,8 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
         @Override
         public void close() {
 
+             executor.shutdownNow();
+
         }
 
         protected synchronized void onTransactionFailed(final SnapshotBackedWriteTransaction transaction,
@@ -7,26 +7,18 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
-import static org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.builder;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder;
 import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.SimpleEventFactory;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Node;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Walker;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
@@ -34,15 +26,22 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 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.HashMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Multimap;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import static org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.builder;
 
 /**
  * Resolve Data Change Events based on modifications and listeners
@@ -94,7 +93,7 @@ final class ResolveDataChangeEventsTask implements Callable<Iterable<ChangeListe
      *
      * Dispatch between merge variant and reuse variant of notification task is
      * done in
-     * {@link #addNotificationTask(com.google.common.collect.ImmutableList.Builder, Node, Collection)}
+     * {@link #addNotificationTask(com.google.common.collect.ImmutableList.Builder, Node, java.util.Collection)}
      *
      * @return Collection of notification tasks.
      */
@@ -114,7 +113,7 @@ final class ResolveDataChangeEventsTask implements Callable<Iterable<ChangeListe
      * {@link #addNotificationTaskByScope(com.google.common.collect.ImmutableList.Builder, Node, DOMImmutableDataChangeEvent)}
      * . Otherwise events are merged by scope and distributed between listeners
      * to particular scope. See
-     * {@link #addNotificationTasksAndMergeEvents(com.google.common.collect.ImmutableList.Builder, Node, Collection)}
+     * {@link #addNotificationTasksAndMergeEvents(com.google.common.collect.ImmutableList.Builder, Node, java.util.Collection)}
      * .
      *
      * @param taskListBuilder
@@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -9,8 +9,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl;
 
 import static com.google.common.base.Preconditions.checkState;
 
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification;
-import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot;
+
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
@@ -21,11 +20,13 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Objects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 
 /**
  * Implementation of Write transaction which is backed by
  * {@link DataTreeSnapshot} and executed according to
- * {@link TransactionReadyPrototype}.
+ * {@link org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction.TransactionReadyPrototype}.
  *
  */
 class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction implements DOMStoreWriteTransaction {
@@ -139,10 +140,10 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme
 
     /**
      * Prototype implementation of
-     * {@link #ready(SnapshotBackedWriteTransaction)}
+     * {@link #ready(org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction)}
      *
      * This class is intended to be implemented by Transaction factories
-     * responsible for allocation of {@link SnapshotBackedWriteTransaction} and
+     * responsible for allocation of {@link org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction} and
      * providing underlying logic for applying implementation.
      *
      */
@@ -7,18 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl.tree;
 
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import javax.annotation.concurrent.GuardedBy;
-
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration;
@@ -27,17 +17,26 @@ import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+import javax.annotation.concurrent.GuardedBy;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 /**
  * A set of listeners organized as a tree by node to which they listen. This class
  * allows for efficient lookup of listeners when we walk the DataTreeCandidate.
  */
-public final class ListenerTree {
+public final class ListenerTree  {
     private static final Logger LOG = LoggerFactory.getLogger(ListenerTree.class);
     private final ReadWriteLock rwLock = new ReentrantReadWriteLock(true);
     private final Node rootNode = new Node(null, null);
@@ -173,7 +172,7 @@ public final class ListenerTree {
     /**
      * This is a single node within the listener tree. Note that the data returned from
      * and instance of this class is guaranteed to have any relevance or consistency
-     * only as long as the {@link Walker} instance through which it is reached remains
+     * only as long as the {@link org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Walker} instance through which it is reached remains
      * unclosed.
      */
     public static final class Node implements StoreTreeNode<Node>, Identifiable<PathArgument> {
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang
new file mode 100644 (file)
index 0000000..03220a3
--- /dev/null
@@ -0,0 +1,71 @@
+
+module opendaylight-inmemory-datastore-provider {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider";
+    prefix "inmemory-datastore-provider";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+       import opendaylight-config-dom-datastore {prefix config-dom-store-spi;}
+       import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;}
+    import opendaylight-md-sal-dom {prefix sal;}
+
+    description
+        "InMemory datastore provider implementation for config & operational datastore";
+
+    revision "2014-06-17" {
+        description
+        "Initial revision.";
+    }
+
+    // This is the definition of the service implementation as a module identity.
+    identity inmemory-config-datastore-provider {
+            base config:module-type;
+            config:provided-service config-dom-store-spi:config-dom-datastore;
+            config:java-name-prefix InMemoryConfigDataStoreProvider;
+    }
+
+        // This is the definition of the service implementation as a module identity.
+
+     identity inmemory-operational-datastore-provider {
+             base config:module-type;
+             config:provided-service operational-dom-store-spi:operational-dom-datastore;
+             config:java-name-prefix InMemoryOperationalDataStoreProvider;
+      }
+
+
+    // Augments the 'configuration' choice node under modules/module.
+    augment "/config:modules/config:module/config:configuration" {
+        case inmemory-config-datastore-provider {
+            when "/config:modules/config:module/config:type = 'inmemory-config-datastore-provider'";
+
+            container schema-service {
+              uses config:service-ref {
+                   refine type {
+                          mandatory false;
+                          config:required-identity sal:schema-service;
+                    }
+              }
+            }
+        }
+    }
+
+
+
+      // Augments the 'configuration' choice node under modules/module.
+        augment "/config:modules/config:module/config:configuration" {
+            case inmemory-operational-datastore-provider {
+                when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'";
+
+                container schema-service {
+                  uses config:service-ref {
+                       refine type {
+                              mandatory false;
+                              config:required-identity sal:schema-service;
+                        }
+                  }
+                }
+            }
+        }
+}
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java
new file mode 100644 (file)
index 0000000..369a7da
--- /dev/null
@@ -0,0 +1,248 @@
+package org.opendaylight.controller.md.sal.dom.store.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+
+public class InMemoryDataStoreTest {
+
+  private SchemaContext schemaContext;
+  private InMemoryDOMDataStore domStore;
+
+  @Before
+  public void setupStore() {
+    domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.sameThreadExecutor());
+    schemaContext = TestModel.createTestContext();
+    domStore.onGlobalContextUpdated(schemaContext);
+
+  }
+
+  @Test
+  public void testTransactionIsolation() throws InterruptedException, ExecutionException {
+
+    assertNotNull(domStore);
+
+    DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
+    assertNotNull(readTx);
+
+    DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+    assertNotNull(writeTx);
+    /**
+     *
+     * Writes /test in writeTx
+     *
+     */
+    writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+    /**
+     *
+     * Reads /test from writeTx Read should return container.
+     *
+     */
+    ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
+    assertTrue(writeTxContainer.get().isPresent());
+
+    /**
+     *
+     * Reads /test from readTx Read should return Absent.
+     *
+     */
+    ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
+    assertFalse(readTxContainer.get().isPresent());
+  }
+
+  @Test
+  public void testTransactionCommit() throws InterruptedException, ExecutionException {
+
+    DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+    assertNotNull(writeTx);
+    /**
+     *
+     * Writes /test in writeTx
+     *
+     */
+    writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+    /**
+     *
+     * Reads /test from writeTx Read should return container.
+     *
+     */
+    ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
+    assertTrue(writeTxContainer.get().isPresent());
+
+    DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
+
+    assertThreePhaseCommit(cohort);
+
+    Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
+        .get();
+    assertTrue(afterCommitRead.isPresent());
+  }
+
+  @Test
+  public void testTransactionAbort() throws InterruptedException, ExecutionException {
+
+    DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+    assertNotNull(writeTx);
+
+    assertTestContainerWrite(writeTx);
+
+    DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
+
+    assertTrue(cohort.canCommit().get().booleanValue());
+    cohort.preCommit().get();
+    cohort.abort().get();
+
+    Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
+        .get();
+    assertFalse(afterCommitRead.isPresent());
+  }
+
+  @Test
+  public void testTransactionChain() throws InterruptedException, ExecutionException {
+    DOMStoreTransactionChain txChain = domStore.createTransactionChain();
+    assertNotNull(txChain);
+
+    /**
+     * We alocate new read-write transaction and write /test
+     *
+     *
+     */
+    DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
+    assertTestContainerWrite(firstTx);
+
+    /**
+     * First transaction is marked as ready, we are able to allocate chained
+     * transactions
+     */
+    DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
+
+    /**
+     * We alocate chained transaction - read transaction, note first one is
+     * still not commited to datastore.
+     */
+    DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
+
+    /**
+     *
+     * We test if we are able to read data from tx, read should not fail
+     * since we are using chained transaction.
+     *
+     *
+     */
+    assertTestContainerExists(secondReadTx);
+
+    /**
+     *
+     * We alocate next transaction, which is still based on first one, but
+     * is read-write.
+     *
+     */
+    DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
+
+    /**
+     * We test existence of /test in third transaction container should
+     * still be visible from first one (which is still uncommmited).
+     *
+     *
+     */
+    assertTestContainerExists(thirdDeleteTx);
+
+    /**
+     * We delete node in third transaction
+     */
+    thirdDeleteTx.delete(TestModel.TEST_PATH);
+
+    /**
+     * third transaction is sealed.
+     */
+    DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready();
+
+    /**
+     * We commit first transaction
+     *
+     */
+    assertThreePhaseCommit(firstWriteTxCohort);
+
+    // Alocates store transacion
+    DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction();
+    /**
+     * We verify transaction is commited to store, container should exists
+     * in datastore.
+     */
+    assertTestContainerExists(storeReadTx);
+    /**
+     * We commit third transaction
+     *
+     */
+    assertThreePhaseCommit(thirdDeleteTxCohort);
+  }
+
+  @Test
+  @Ignore
+  public void testTransactionConflict() throws InterruptedException, ExecutionException {
+    DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction();
+    DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction();
+    assertTestContainerWrite(txOne);
+    assertTestContainerWrite(txTwo);
+
+    /**
+     * Commits transaction
+     */
+    assertThreePhaseCommit(txOne.ready());
+
+    /**
+     * Asserts that txTwo could not be commited
+     */
+    assertFalse(txTwo.ready().canCommit().get());
+  }
+
+  private static void assertThreePhaseCommit(final DOMStoreThreePhaseCommitCohort cohort)
+      throws InterruptedException, ExecutionException {
+    assertTrue(cohort.canCommit().get().booleanValue());
+    cohort.preCommit().get();
+    cohort.commit().get();
+  }
+
+  private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
+      throws InterruptedException, ExecutionException {
+    /**
+     *
+     * Writes /test in writeTx
+     *
+     */
+    writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+    return assertTestContainerExists(writeTx);
+  }
+
+  /**
+   * Reads /test from readTx Read should return container.
+   */
+  private static Optional<NormalizedNode<?, ?>> assertTestContainerExists(DOMStoreReadTransaction readTx)
+      throws InterruptedException, ExecutionException {
+
+    ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = readTx.read(TestModel.TEST_PATH);
+    assertTrue(writeTxContainer.get().isPresent());
+    return writeTxContainer.get();
+  }
+
+}
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java
new file mode 100644 (file)
index 0000000..3feeb29
--- /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.md.sal.dom.store.impl;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+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.InputStream;
+import java.util.Collections;
+import java.util.Set;
+
+public class TestModel {
+
+    public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
+        "test");
+    public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
+    public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
+    public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
+    public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
+    public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
+    public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
+    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
+
+    public static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME);
+    public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
+    public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
+    public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
+
+
+    public static final InputStream getDatastoreTestInputStream() {
+        return getInputStream(DATASTORE_TEST_YANG);
+    }
+
+    private static InputStream getInputStream(final String resourceName) {
+        return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
+    }
+
+    public static SchemaContext createTestContext() {
+        YangParserImpl parser = new YangParserImpl();
+        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
+        return parser.resolveSchemaContext(modules);
+    }
+}
diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang
new file mode 100644 (file)
index 0000000..17541fe
--- /dev/null
@@ -0,0 +1,42 @@
+module odl-datastore-test {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test";
+    prefix "store-test";
+    
+    revision "2014-03-13" {
+        description "Initial revision.";
+    }
+
+    container test {
+        list outer-list {
+            key id;
+            leaf id {
+                type uint16;
+            }
+            choice outer-choice {
+                case one {
+                    leaf one {
+                        type string;
+                    }
+                }
+                case two-three {
+                    leaf two {
+                        type string;
+                    }
+                    leaf three {
+                        type string;
+                    }
+               }
+           }
+           list inner-list {
+                key name;
+                leaf name {
+                    type string;
+                }
+                leaf value {
+                    type string;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
index f73d9cc72f893aa0260e6adc7bf0f257eb18252e..037bfb4a82c2cd8f34dbfe05513e602e7077b3ff 100644 (file)
@@ -12,13 +12,10 @@ import static org.opendaylight.controller.config.api.JmxAttributeValidationExcep
 
 import java.io.File;
 import java.io.InputStream;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration;
 import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
@@ -33,19 +30,16 @@ import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import org.opendaylight.protocol.framework.TimedReconnectStrategy;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Host;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yangtools.yang.model.util.repo.AbstractCachingSchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.util.repo.FilesystemSchemaCachingProvider;
 import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProviders;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.net.InetAddresses;
-import io.netty.util.HashedWheelTimer;
-
 /**
  *
  */
@@ -67,6 +61,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
     @Override
     protected void customValidation() {
         checkNotNull(getAddress(), addressJmxAttribute);
+        checkCondition(isHostAddressPresent(getAddress()), "Host address not present in " + getAddress(), addressJmxAttribute);
         checkNotNull(getPort(), portJmxAttribute);
         checkNotNull(getDomRegistry(), portJmxAttribute);
         checkNotNull(getDomRegistry(), domRegistryJmxAttribute);
@@ -77,11 +72,9 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
         checkNotNull(getBetweenAttemptsTimeoutMillis(), betweenAttemptsTimeoutMillisJmxAttribute);
         checkCondition(getBetweenAttemptsTimeoutMillis() > 0, "must be > 0", betweenAttemptsTimeoutMillisJmxAttribute);
 
-        // FIXME BUG-944 remove backwards compatibility
-        if(getClientDispatcher() == null) {
-            checkCondition(getBossThreadGroup() != null, "Client dispatcher was not set, thread groups have to be set instead", bossThreadGroupJmxAttribute);
-            checkCondition(getWorkerThreadGroup() != null, "Client dispatcher was not set, thread groups have to be set instead", workerThreadGroupJmxAttribute);
-        }
+        checkNotNull(getClientDispatcher(), clientDispatcherJmxAttribute);
+        checkNotNull(getBindingRegistry(), bindingRegistryJmxAttribute);
+        checkNotNull(getProcessingExecutor(), processingExecutorJmxAttribute);
 
         // Check username + password in case of ssh
         if(getTcpOnly() == false) {
@@ -89,33 +82,21 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
             checkNotNull(getPassword(), passwordJmxAttribute);
         }
 
-        // FIXME BUG 944 remove this warning
-        if(getBindingRegistry() == null) {
-            logger.warn("Configuration property: \"binding-registry\" not set for sal-netconf-connector (" + getIdentifier() + "). " +
-                    "Netconf-connector now requires a dependency on \"binding-broker-osgi-registry\". " +
-                    "The dependency is optional for now to preserve backwards compatibility, but will be mandatory in the future. " +
-                    "Please set the property as in \"01-netconf-connector\" initial config file. " +
-                    "The service will be retrieved from OSGi service registry now.");
-        }
+    }
 
-        // FIXME BUG 944 remove this warning
-        if(getProcessingExecutor() == null) {
-            logger.warn("Configuration property: \"processing-executor\" not set for sal-netconf-connector (" + getIdentifier() + "). " +
-                    "Netconf-connector now requires a dependency on \"threadpool\". " +
-                    "The dependency is optional for now to preserve backwards compatibility, but will be mandatory in the future. " +
-                    "Please set the property as in \"01-netconf-connector\" initial config file. " +
-                    "New instance will be created for the executor.");
-        }
+    private boolean isHostAddressPresent(Host address) {
+        return address.getDomainName() != null ||
+               address.getIpAddress() != null && (address.getIpAddress().getIpv4Address() != null || address.getIpAddress().getIpv6Address() != null);
     }
 
     @Override
     public java.lang.AutoCloseable createInstance() {
         final RemoteDeviceId id = new RemoteDeviceId(getIdentifier());
 
-        final ExecutorService globalProcessingExecutor = getGlobalProcessingExecutor();
+        final ExecutorService globalProcessingExecutor = getProcessingExecutorDependency().getExecutor();
 
         final Broker domBroker = getDomRegistryDependency();
-        final BindingAwareBroker bindingBroker = getBindingRegistryBackwards();
+        final BindingAwareBroker bindingBroker = getBindingRegistryDependency();
 
         final RemoteDeviceHandler salFacade = new NetconfDeviceSalFacade(id, domBroker, bindingBroker, bundleContext, globalProcessingExecutor);
         final NetconfDevice device =
@@ -123,8 +104,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
         final NetconfDeviceCommunicator listener = new NetconfDeviceCommunicator(id, device);
         final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(listener);
 
-        // FIXME BUG-944 remove backwards compatibility
-        final NetconfClientDispatcher dispatcher = getClientDispatcher() == null ? createDispatcher() : getClientDispatcherDependency();
+        final NetconfClientDispatcher dispatcher = getClientDispatcherDependency();
         listener.initializeRemoteConnection(dispatcher, clientConfig);
 
         return new AutoCloseable() {
@@ -136,30 +116,6 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
         };
     }
 
-    private BindingAwareBroker getBindingRegistryBackwards() {
-        if(getBindingRegistry() != null) {
-            return getBindingRegistryDependency();
-        } else {
-            // FIXME BUG 944 remove backwards compatibility
-            final ServiceReference<BindingAwareBroker> serviceReference = bundleContext.getServiceReference(BindingAwareBroker.class);
-            Preconditions
-                    .checkNotNull(
-                            serviceReference,
-                            "Unable to retrieve %s from OSGi service registry, use binding-registry config property to inject %s with config subsystem",
-                            BindingAwareBroker.class, BindingAwareBroker.class);
-            return bundleContext.getService(serviceReference);
-        }
-    }
-
-    private ExecutorService getGlobalProcessingExecutor() {
-        if(getProcessingExecutor() != null) {
-            return getProcessingExecutorDependency().getExecutor();
-        } else {
-            // FIXME BUG 944 remove backwards compatibility
-            return Executors.newCachedThreadPool();
-        }
-    }
-
     private synchronized AbstractCachingSchemaSourceProvider<String, InputStream> getGlobalNetconfSchemaProvider() {
         if(GLOBAL_NETCONF_SOURCE_PROVIDER == null) {
             final String storageFile = "cache/schema";
@@ -171,16 +127,6 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
         return GLOBAL_NETCONF_SOURCE_PROVIDER;
     }
 
-    // FIXME BUG-944 remove backwards compatibility
-    /**
-     * @deprecated Use getClientDispatcherDependency method instead to retrieve injected dispatcher.
-     * This one creates new instance of NetconfClientDispatcher and will be removed in near future.
-     */
-    @Deprecated
-    private NetconfClientDispatcher createDispatcher() {
-        return new NetconfClientDispatcherImpl(getBossThreadGroupDependency(), getWorkerThreadGroupDependency(), new HashedWheelTimer());
-    }
-
     public void setBundleContext(final BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
@@ -226,15 +172,12 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
     }
 
     private InetSocketAddress getSocketAddress() {
-        /*
-         * Uncomment after Switch to IP Address
-        if(getAddress().getIpv4Address() != null) {
-            addressValue = getAddress().getIpv4Address().getValue();
+        if(getAddress().getDomainName() != null) {
+            return new InetSocketAddress(getAddress().getDomainName().getValue(), getPort().getValue());
         } else {
-            addressValue = getAddress().getIpv6Address().getValue();
+            IpAddress ipAddress = getAddress().getIpAddress();
+            String ip = ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue();
+            return new InetSocketAddress(ip, getPort().getValue());
         }
-         */
-        final InetAddress inetAddress = InetAddresses.forString(getAddress());
-        return new InetSocketAddress(inetAddress, getPort().intValue());
     }
 }
index 457b8c36b987996bd28c041cff0d17068547f7a6..8b6ac7d5671643cdad49babaecd0026de338f9c6 100644 (file)
@@ -48,7 +48,7 @@ public final class NetconfDeviceCommitHandler implements DataCommitHandler<Insta
             Thread.currentThread().interrupt();
             throw new RuntimeException(id + ": Interrupted while waiting for response", e);
         } catch (final ExecutionException e) {
-            logger.warn("%s: Error executing pre commit operation on remote device", id, e);
+            logger.warn("{}: Error executing pre commit operation on remote device", id, e);
             return new FailingTransaction(twoPhaseCommit, e);
         }
 
index 41f9fec3c4d5e1f0240cc9adc84b179ac52bc50f..1a3b108f8be7bb0d0748ff6e9db949d6fdfe8bc2 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.connect.netconf.sal;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CONFIG_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DEFAULT_OPERATION_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_ERROR_OPTION_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_OPERATION_QNAME;
@@ -17,13 +18,16 @@ import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessag
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_TARGET_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil.ROLLBACK_ON_ERROR_OPTION;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.ExecutionException;
-
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.sal.common.util.RpcErrors;
@@ -39,16 +43,13 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
 import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
 import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
 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.ImmutableList;
-import com.google.common.collect.Lists;
-
 /**
  *  Remote transaction that delegates data change to remote device using netconf messages.
  */
@@ -87,17 +88,18 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact
     }
 
     private void sendMerge(final InstanceIdentifier key, final CompositeNode value) throws InterruptedException, ExecutionException {
-        sendEditRpc(createEditConfigStructure(key, Optional.<String>absent(), Optional.of(value)));
+        sendEditRpc(createEditConfigStructure(key, Optional.<String>absent(), Optional.of(value)), Optional.<String>absent());
     }
 
     private void sendDelete(final InstanceIdentifier toDelete) throws InterruptedException, ExecutionException {
-        sendEditRpc(createEditConfigStructure(toDelete, Optional.of("delete"), Optional.<CompositeNode>absent()));
+        // FIXME use org.opendaylight.yangtools.yang.data.api.ModifyAction instead of strings
+        // TODO add string lowercase value to ModifyAction enum entries
+        sendEditRpc(createEditConfigStructure(toDelete, Optional.of("delete"), Optional.<CompositeNode>absent()), Optional.of("none"));
     }
 
-    private void sendEditRpc(final CompositeNode editStructure) throws InterruptedException, ExecutionException {
-        final ImmutableCompositeNode editConfigRequest = createEditConfigRequest(editStructure);
+    private void sendEditRpc(final CompositeNode editStructure, final Optional<String> defaultOperation) throws InterruptedException, ExecutionException {
+        final ImmutableCompositeNode editConfigRequest = createEditConfigRequest(editStructure, defaultOperation);
         final RpcResult<CompositeNode> rpcResult = rpc.invokeRpc(NETCONF_EDIT_CONFIG_QNAME, editConfigRequest).get();
-        // TODO 874 add default operation when sending delete
 
         // Check result
         if(rpcResult.isSuccessful() == false) {
@@ -106,16 +108,26 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact
         }
     }
 
-    private ImmutableCompositeNode createEditConfigRequest(final CompositeNode editStructure) {
+    private ImmutableCompositeNode createEditConfigRequest(final CompositeNode editStructure, Optional<String> defaultOperation) {
         final CompositeNodeBuilder<ImmutableCompositeNode> ret = ImmutableCompositeNode.builder();
 
+        // Target
         final Node<?> targetWrapperNode = ImmutableCompositeNode.create(NETCONF_TARGET_QNAME, ImmutableList.<Node<?>>of(targetNode));
         ret.add(targetWrapperNode);
 
+        // Default operation
+        if(defaultOperation.isPresent()) {
+            SimpleNode<String> defOp = NodeFactory.createImmutableSimpleNode(NETCONF_DEFAULT_OPERATION_QNAME, null, defaultOperation.get());
+            ret.add(defOp);
+        }
+
+        // Error option
         if(rollbackSupported) {
             ret.addLeaf(NETCONF_ERROR_OPTION_QNAME, ROLLBACK_ON_ERROR_OPTION);
         }
+
         ret.setQName(NETCONF_EDIT_CONFIG_QNAME);
+        // Edit content
         ret.add(editStructure);
         return ret.toInstance();
     }
index 2adc1be79e65b35b4bc52312e56d6653b2d7551f..21f94474f893a4b2c4dde263a477cc6336ce39d8 100644 (file)
@@ -70,6 +70,8 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
                     final DataNodeContainer schemaForEdit = NetconfMessageTransformUtil.createSchemaForEdit(schemaContext.get());
                     w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaForEdit, codecProvider);
                 } else {
+                    // FIXME get and get-config needs schema as well to transform filter using schema context
+                    // e.g. Identityref nodes in filter fail to serialize properly to xml without schema
                     w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaContext.get(), codecProvider);
                 }
             } else {
index 08a5822d366d16fa5d078e17ae8af2065cdba30e..ee6daa1e3d0dd81d60ca7c298402d837dbc6a457 100644 (file)
@@ -48,16 +48,14 @@ public class NetconfMessageTransformUtil {
     private NetconfMessageTransformUtil() {
     }
 
-    public static final QName IETF_NETCONF_MONITORING = QName.create(
-            "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring", "2010-10-04", "ietf-netconf-monitoring");
+    public static final QName IETF_NETCONF_MONITORING = QName.create("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring", "2010-10-04", "ietf-netconf-monitoring");
     public static URI NETCONF_URI = URI.create("urn:ietf:params:xml:ns:netconf:base:1.0");
     public static QName NETCONF_QNAME = QName.create(NETCONF_URI, null, "netconf");
     public static QName NETCONF_DATA_QNAME = QName.create(NETCONF_QNAME, "data");
     public static QName NETCONF_RPC_REPLY_QNAME = QName.create(NETCONF_QNAME, "rpc-reply");
     public static QName NETCONF_ERROR_OPTION_QNAME = QName.create(NETCONF_QNAME, "error-option");
     public static QName NETCONF_RUNNING_QNAME = QName.create(NETCONF_QNAME, "running");
-    static List<Node<?>> RUNNING = Collections.<Node<?>> singletonList(new SimpleNodeTOImpl<>(NETCONF_RUNNING_QNAME,
-            null, null));
+    static List<Node<?>> RUNNING = Collections.<Node<?>> singletonList(new SimpleNodeTOImpl<>(NETCONF_RUNNING_QNAME, null, null));
     public static QName NETCONF_SOURCE_QNAME = QName.create(NETCONF_QNAME, "source");
     public static CompositeNode CONFIG_SOURCE_RUNNING = new CompositeNodeTOImpl(NETCONF_SOURCE_QNAME, null, RUNNING);
     public static QName NETCONF_CANDIDATE_QNAME = QName.create(NETCONF_QNAME, "candidate");
@@ -65,6 +63,7 @@ public class NetconfMessageTransformUtil {
     public static QName NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config");
     public static QName NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit");
     public static QName NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation");
+    public static QName NETCONF_DEFAULT_OPERATION_QNAME = QName.create(NETCONF_OPERATION_QNAME, "default-operation");
     public static QName NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config");
     public static QName NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config");
     public static QName NETCONF_TYPE_QNAME = QName.create(NETCONF_QNAME, "type");
index c59c41c4374838908cf3d7440bc71cef7940b0d3..6bad4798c290524dc04ff2d39611f2a1f0c33453 100644 (file)
@@ -9,6 +9,7 @@ module odl-sal-netconf-connector-cfg {
     import opendaylight-md-sal-dom {prefix dom;}
     import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;}
     import odl-netconf-cfg { prefix cfg-net; revision-date 2014-04-08; }
+    import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
 
     description
         "Service definition for Binding Aware MD-SAL.";
@@ -38,11 +39,11 @@ module odl-sal-netconf-connector-cfg {
             when "/config:modules/config:module/config:type = 'sal-netconf-connector'";
 
             leaf address {
-                type string;
+                type inet:host;
             }
 
             leaf port {
-                type uint32;
+                type inet:port-number;
             }
 
             leaf tcp-only {
@@ -69,40 +70,16 @@ module odl-sal-netconf-connector-cfg {
             container binding-registry {
                 uses config:service-ref {
                     refine type {
-                        // FIXME BUG-944 make mandatory (remove backwards compatibility)
-                        mandatory false;
+                        mandatory true;
                         config:required-identity md-sal-binding:binding-broker-osgi-registry;
                     }
                 }
             }
 
-            // FIXME BUG-944 remove backwards compatibility
-            // Deprecated, replaced by client dispatcher.
-            // This dependency will be removed in near future and all configurations of netconf-connector need to be changed to use dispatcher dependency.
-            container boss-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
-            // FIXME BUG-944 remove backwards compatibility
-            // Deprecated, replaced by client dispatcher.
-            // This dependency will be removed in near future and all configurations of netconf-connector need to be changed to use dispatcher dependency.
-            container worker-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
             container event-executor {
                 uses config:service-ref {
                     refine type {
+                        mandatory true;
                         config:required-identity netty:netty-event-executor;
                     }
                 }
@@ -111,8 +88,7 @@ module odl-sal-netconf-connector-cfg {
             container processing-executor {
                 uses config:service-ref {
                     refine type {
-                        // FIXME BUG-944 make mandatory (remove backwards compatibility)
-                        mandatory false;
+                        mandatory true;
                         config:required-identity th:threadpool;
                     }
                 }
@@ -120,7 +96,6 @@ module odl-sal-netconf-connector-cfg {
                 description "Makes up for flaws in netty threading design";
             }
 
-            // Replaces thread group dependencies
             container client-dispatcher {
                 uses config:service-ref {
                     refine type {
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModule.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModule.java
deleted file mode 100644 (file)
index e3ac9ba..0000000
+++ /dev/null
@@ -1,69 +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.config.yang.md.sal.remote.rpc;
-
-import org.opendaylight.controller.sal.connector.remoterpc.ClientImpl;
-import org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcProvider;
-import org.opendaylight.controller.sal.connector.remoterpc.RoutingTableProvider;
-import org.opendaylight.controller.sal.connector.remoterpc.ServerImpl;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.osgi.framework.BundleContext;
-
-/**
- *
- */
-public final class ZeroMQServerModule
-extends org.opendaylight.controller.config.yang.md.sal.remote.rpc.AbstractZeroMQServerModule {
-
-    private static final Integer ZEROMQ_ROUTER_PORT = 5554;
-    private BundleContext bundleContext;
-
-    public ZeroMQServerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public ZeroMQServerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            final ZeroMQServerModule oldModule, final java.lang.AutoCloseable oldInstance) {
-
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    protected void customValidation() {
-        // Add custom validation for module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-
-        Broker broker = getDomBrokerDependency();
-
-        final int port = getPort() != null ? getPort() : ZEROMQ_ROUTER_PORT;
-
-        ServerImpl serverImpl = new ServerImpl(port);
-
-        ClientImpl clientImpl = new ClientImpl();
-
-        RoutingTableProvider provider = new RoutingTableProvider(bundleContext);//,serverImpl);
-
-        RemoteRpcProvider facade = new RemoteRpcProvider(serverImpl, clientImpl);
-        facade.setRoutingTableProvider(provider);
-        facade.setContext(bundleContext);
-        facade.setRpcProvisionRegistry((RpcProvisionRegistry) broker);
-
-        broker.registerProvider(facade, bundleContext);
-        return facade;
-    }
-
-    public void setBundleContext(final BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java
deleted file mode 100644 (file)
index 0c2a370..0000000
+++ /dev/null
@@ -1,35 +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.config.yang.md.sal.remote.rpc;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.spi.Module;
-import org.osgi.framework.BundleContext;
-
-/**
-*
-*/
-public class ZeroMQServerModuleFactory extends org.opendaylight.controller.config.yang.md.sal.remote.rpc.AbstractZeroMQServerModuleFactory
-{
-
-    @Override
-    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
-        ZeroMQServerModule module = (ZeroMQServerModule) super.createModule(instanceName, dependencyResolver, bundleContext);
-        module.setBundleContext(bundleContext);
-        return module;
-    }
-
-    @Override
-    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
-            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
-        ZeroMQServerModule module = (ZeroMQServerModule) super.createModule(instanceName, dependencyResolver, old,bundleContext);
-        module.setBundleContext(bundleContext);
-        return module;
-    }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/CapturedMessageHandler.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/CapturedMessageHandler.java
deleted file mode 100644 (file)
index 2dc5eee..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-public class CapturedMessageHandler implements Runnable {
-
-  private Logger _logger = LoggerFactory.getLogger(CapturedMessageHandler.class);
-
-  private ZMQ.Socket socket;
-
-  public CapturedMessageHandler(ZMQ.Socket socket){
-    this.socket = socket;
-  }
-
-  @Override
-  public void run(){
-
-    try {
-      while (!Thread.currentThread().isInterrupted()){
-        String message = socket.recvStr();
-        _logger.debug("Captured [{}]", message);
-      }
-    } catch (Exception e) {
-      _logger.error("Exception raised [{}]", e.getMessage());
-    }
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImpl.java
deleted file mode 100644 (file)
index 200ebae..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-
-import org.opendaylight.controller.sal.common.util.RpcErrors;
-import org.opendaylight.controller.sal.common.util.Rpcs;
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
-import org.opendaylight.controller.sal.connector.remoterpc.util.XmlUtils;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * An implementation of {@link org.opendaylight.controller.sal.core.api.RpcImplementation} that makes
- * remote RPC calls
- */
-public class ClientImpl implements RemoteRpcClient {
-
-  private final Logger _logger = LoggerFactory.getLogger(ClientImpl.class);
-
-  private final ZMQ.Context context = ZMQ.context(1);
-  private final ClientRequestHandler handler;
-  private RoutingTableProvider routingTableProvider;
-
-  public ClientImpl(){
-    handler = new ClientRequestHandler(context);
-    start();
-  }
-
-  public ClientImpl(ClientRequestHandler handler){
-    this.handler = handler;
-    start();
-  }
-
-  public RoutingTableProvider getRoutingTableProvider() {
-    return routingTableProvider;
-  }
-
-  @Override
-  public void setRoutingTableProvider(RoutingTableProvider routingTableProvider) {
-    this.routingTableProvider = routingTableProvider;
-  }
-
-  @Override
-  public void start() {/*NOOPS*/}
-
-  @Override
-  public void stop() {
-    closeZmqContext();
-    handler.close();
-    _logger.info("Stopped");
-  }
-
-  @Override
-  public void close(){
-    stop();
-  }
-
-  /**
-   * Finds remote server that can execute this rpc and sends a message to it
-   * requesting execution.
-   * The call blocks until a response from remote server is received. Its upto
-   * the client of this API to implement a timeout functionality.
-   *
-   * @param rpc   remote service to be executed
-   * @param input payload for the remote service
-   * @return
-   */
-  public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(QName rpc, CompositeNode input) {
-    RouteIdentifierImpl routeId = new RouteIdentifierImpl();
-    routeId.setType(rpc);
-
-    String address = lookupRemoteAddressForGlobalRpc(routeId);
-    return sendMessage(input, routeId, address);
-  }
-
-  /**
-   * Finds remote server that can execute this routed rpc and sends a message to it
-   * requesting execution.
-   * The call blocks until a response from remote server is received. Its upto
-   * the client of this API to implement a timeout functionality.
-   *
-   * @param rpc
-   *          rpc to be called
-   * @param identifier
-   *          instance identifier on which rpc is to be executed
-   * @param input
-   *          payload
-   * @return
-   */
-  public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(QName rpc, InstanceIdentifier identifier, CompositeNode input) {
-
-    RouteIdentifierImpl routeId = new RouteIdentifierImpl();
-    routeId.setType(rpc);
-    routeId.setRoute(identifier);
-
-    String address = lookupRemoteAddressForRpc(routeId);
-
-    return sendMessage(input, routeId, address);
-  }
-
-  private ListenableFuture<RpcResult<CompositeNode>> sendMessage(CompositeNode input, RouteIdentifierImpl routeId, String address) {
-    Message request = new Message.MessageBuilder()
-        .type(Message.MessageType.REQUEST)
-        .sender(Context.getInstance().getLocalUri())
-        .recipient(address)
-        .route(routeId)
-        .payload(XmlUtils.compositeNodeToXml(input))
-        .build();
-
-    List<RpcError> errors = new ArrayList<RpcError>();
-
-    try{
-      Message response = handler.handle(request);
-      CompositeNode payload = null;
-
-      if ( response != null ) {
-
-        _logger.info("Received response [{}]", response);
-
-        Object rawPayload = response.getPayload();
-        switch (response.getType()) {
-          case ERROR:
-            if ( rawPayload instanceof List )
-              errors = (List) rawPayload;
-              break;
-
-          case RESPONSE:
-            payload = XmlUtils.xmlToCompositeNode((String) rawPayload);
-            break;
-
-          default:
-            errors.add(
-                RpcErrors.getRpcError(null, null,null,null,"Unable to get response from remote controller", null, null)
-            );
-            break;
-
-        }
-      }
-      return Futures.immediateFuture(Rpcs.getRpcResult(true, payload, errors));
-
-    } catch (Exception e){
-      collectErrors(e, errors);
-      return Futures.immediateFuture(Rpcs.<CompositeNode>getRpcResult(false, null, errors));
-    }
-  }
-
-  /**
-   * Find address for the given route identifier in routing table
-   * @param  routeId route identifier
-   * @return         remote network address
-   */
-  private String lookupRemoteAddressForGlobalRpc(RpcRouter.RouteIdentifier<?, ?, ?> routeId){
-    checkNotNull(routeId, "route must not be null");
-
-    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> routingTable = routingTableProvider.getRoutingTable();
-    checkNotNull(routingTable.isPresent(), "Routing table is null");
-
-    String address = null;
-    try {
-      address = routingTable.get().getGlobalRoute(routeId);
-    } catch (RoutingTableException|SystemException e) {
-      _logger.error("Exception caught while looking up remote address " + e);
-    }
-    checkState(address != null, "Address not found for route [%s]", routeId);
-
-    return address;
-  }
-
-  /**
-   * Find address for the given route identifier in routing table
-   * @param  routeId route identifier
-   * @return         remote network address
-   */
-  private String lookupRemoteAddressForRpc(RpcRouter.RouteIdentifier<?, ?, ?> routeId){
-    checkNotNull(routeId, "route must not be null");
-
-    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> routingTable = routingTableProvider.getRoutingTable();
-    checkNotNull(routingTable.isPresent(), "Routing table is null");
-
-    String address = routingTable.get().getLastAddedRoute(routeId);
-    checkState(address != null, "Address not found for route [%s]", routeId);
-
-    return address;
-  }
-
-  private void collectErrors(Exception e, List<RpcError> errors){
-    if (e == null) return;
-    if (errors == null) errors = new ArrayList<RpcError>();
-
-    errors.add(RpcErrors.getRpcError(null, null, null, null, e.getMessage(), null, e.getCause()));
-    for (Throwable t : e.getSuppressed()) {
-      errors.add(RpcErrors.getRpcError(null, null, null, null, t.getMessage(), null, t));
-    }
-  }
-
-  /**
-   * Closes ZMQ Context. It tries to gracefully terminate the context. If
-   * termination takes more than a second, its forcefully shutdown.
-   */
-  private void closeZmqContext() {
-    ExecutorService exec = Executors.newSingleThreadExecutor();
-    FutureTask<?> zmqTermination = new FutureTask<Void>(new Runnable() {
-
-      @Override
-      public void run() {
-        try {
-          if (context != null)
-            context.term();
-          _logger.debug("ZMQ Context terminated");
-        } catch (Exception e) {
-          _logger.debug("ZMQ Context termination threw exception [{}]. Continuing shutdown...", e);
-        }
-      }
-    }, null);
-
-    exec.execute(zmqTermination);
-
-    try {
-      zmqTermination.get(1L, TimeUnit.SECONDS);
-    } catch (Exception e) {/*ignore and continue with shutdown*/}
-
-    exec.shutdownNow();
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandler.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandler.java
deleted file mode 100644 (file)
index fe70fb7..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/**
- *
- */
-class ClientRequestHandler implements AutoCloseable{
-
-  private Logger _logger = LoggerFactory.getLogger(ClientRequestHandler.class);
-  private final String DEFAULT_NAME = "remoterpc-client-worker";
-  private final String INPROC_PROTOCOL_PREFIX = "inproc://";
-  private final String TCP_PROTOCOL_PREFIX = "tcp://";
-
-  private ZMQ.Context context;
-
-  /*
-   * Worker thread pool. Each thread runs a ROUTER-DEALER pair
-   */
-  private ExecutorService workerPool;
-
-  /*
-   * Set of remote servers this client is currently connected to
-   */
-  private Map<String, String> connectedServers;
-
-  protected ClientRequestHandler(ZMQ.Context context) {
-    this.context = context;
-    connectedServers = new ConcurrentHashMap<String, String>();
-    start();
-  }
-
-  /**
-   * Starts a pool of worker as needed. A worker thread that has not been used for 5 min
-   * is terminated and removed from the pool. If thread dies due to an exception, its
-   * restarted.
-   */
-  private void start(){
-
-    workerPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
-        5L, TimeUnit.MINUTES,
-        new SynchronousQueue<Runnable>()){
-
-      @Override
-      protected void afterExecute(Runnable r, Throwable t) {
-        if (isTerminating() || isTerminated() || isShutdown())
-          return;
-
-        Worker worker = (Worker) r;
-        Preconditions.checkState( worker != null );
-        String remoteServerAddress = worker.getRemoteServerAddress();
-        connectedServers.remove(remoteServerAddress);
-
-        if ( t != null ){
-          _logger.debug("Exception caught while terminating worker [{},{}]. " +
-              "Restarting worker...", t.getClass(), t.getMessage());
-
-          connectedServers.put(remoteServerAddress, remoteServerAddress);
-          this.execute(r);
-        }
-        super.afterExecute(r, null);
-      }
-    };
-  }
-
-  public Message handle(Message request) throws IOException, ClassNotFoundException, InterruptedException {
-
-    String remoteServerAddress = request.getRecipient();
-    //if we already have router-dealer bridge setup for this address the send request
-    //otherwise first create the bridge and then send request
-    if ( connectedServers.containsKey(remoteServerAddress) )
-      return sendMessage(request, remoteServerAddress);
-
-    else{
-      workerPool.execute(new Worker(remoteServerAddress));
-      connectedServers.put(remoteServerAddress, remoteServerAddress);
-      //give little time for sockets to get initialized
-      //TODO: Add socket ping-pong message to ensure socket init rather than thread.sleep.
-      Thread.sleep(1000);
-      return sendMessage(request, remoteServerAddress);
-    }
-  }
-
-  private Message sendMessage(Message request, String address) throws IOException, ClassNotFoundException {
-    Message response = null;
-    ZMQ.Socket socket = context.socket(ZMQ.REQ);
-
-    try {
-      String inProcessSocketAddress = INPROC_PROTOCOL_PREFIX + address;
-      socket.connect( inProcessSocketAddress );
-      _logger.debug("Sending request [{}]", request);
-      socket.send(Message.serialize(request));
-      _logger.info("Request sent. Waiting for reply...");
-      byte[] reply = socket.recv(0);
-      _logger.info("Response received");
-      response = (Message) Message.deserialize(reply);
-      _logger.debug("Response [{}]", response);
-    } finally {
-      socket.close();
-    }
-    return response;
-  }
-
-  /**
-   * This gets called automatically if used with try-with-resources
-   */
-  @Override
-  public void close(){
-    workerPool.shutdown();
-    _logger.info("Request Handler closed");
-  }
-
-  /**
-   * Total number of workers in the pool. Number of workers represent
-   * number of remote servers {@link org.opendaylight.controller.sal.connector.remoterpc.ClientImpl} is connected to.
-   *
-   * @return worker count
-   */
-  public int getWorkerCount(){
-
-    if (workerPool == null) return 0;
-
-    return ((ThreadPoolExecutor)workerPool).getActiveCount();
-  }
-  /**
-   * Handles RPC request
-   */
-  private class Worker implements Runnable {
-    private String name;
-    private String remoteServer;  //<serverip:rpc-port>
-
-    public Worker(String address){
-      this.name = DEFAULT_NAME + "[" + address + "]";
-      this.remoteServer = address;
-    }
-
-    public String getRemoteServerAddress(){
-      return this.remoteServer;
-    }
-
-    @Override
-    public void run() {
-      Thread.currentThread().setName(name);
-      _logger.debug("Starting ... ");
-
-      ZMQ.Socket router = context.socket(ZMQ.ROUTER);
-      ZMQ.Socket dealer = context.socket(ZMQ.DEALER);
-
-      try {
-        int success = router.bind(INPROC_PROTOCOL_PREFIX + remoteServer);
-        Preconditions.checkState(-1 != success, "Could not bind to " + remoteServer);
-
-        dealer.connect(TCP_PROTOCOL_PREFIX + remoteServer);
-
-        _logger.info("Worker started for [{}]", remoteServer);
-
-        //TODO: Add capture handler
-        //This code will block until the zmq context is terminated.
-        ZMQ.proxy(router, dealer, null);
-
-      } catch (Exception e) {
-        _logger.debug("Ignoring exception [{}, {}]", e.getClass(), e.getMessage());
-      } finally {
-        try {
-          router.close();
-          dealer.close();
-        } catch (Exception x) {
-          _logger.debug("Exception while closing socket [{}]", x);
-        }
-        _logger.debug("Closing...");
-      }
-    }
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/Context.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/Context.java
deleted file mode 100644 (file)
index 37bff7b..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-
-import org.zeromq.ZMQ;
-
-/**
- * Provides a ZeroMQ Context object
- */
-public class Context {
-  private final ZMQ.Context zmqContext = ZMQ.context(1);
-  private String uri;
-  private final String DEFAULT_RPC_PORT = "5554";
-
-  private static Context _instance = new Context();
-
-  private Context() {}
-
-  public static Context getInstance(){
-    return _instance;
-  }
-
-  public ZMQ.Context getZmqContext(){
-    return this.zmqContext;
-  }
-
-  public String getLocalUri(){
-    uri = (uri != null) ? uri
-            : new StringBuilder().append(getIpAddress()).append(":")
-              .append(getRpcPort()).toString();
-
-    return uri;
-  }
-
-  public String getRpcPort(){
-    String rpcPort = (System.getProperty("rpc.port") != null)
-        ? System.getProperty("rpc.port")
-        : DEFAULT_RPC_PORT;
-
-    return rpcPort;
-  }
-
-  private String getIpAddress(){
-    String ipAddress = (System.getProperty("local.ip") != null)
-        ? System.getProperty("local.ip")
-        : findIpAddress();
-
-    return ipAddress;
-  }
-
-  /**
-   * Finds IPv4 address of the local VM
-   * TODO: This method is non-deterministic. There may be more than one IPv4 address. Cant say which
-   * address will be returned. Read IP from a property file or enhance the code to make it deterministic.
-   * Should we use IP or hostname?
-   *
-   * @return
-   */
-  private String findIpAddress() {
-    String hostAddress = null;
-    Enumeration<?> e = null;
-    try {
-      e = NetworkInterface.getNetworkInterfaces();
-    } catch (SocketException e1) {
-      e1.printStackTrace();
-    }
-    while (e.hasMoreElements()) {
-
-      NetworkInterface n = (NetworkInterface) e.nextElement();
-
-      Enumeration<?> ee = n.getInetAddresses();
-      while (ee.hasMoreElements()) {
-        InetAddress i = (InetAddress) ee.nextElement();
-        if ((i instanceof Inet4Address) && (i.isSiteLocalAddress()))
-          hostAddress = i.getHostAddress();
-      }
-    }
-    return hostAddress;
-
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcClient.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcClient.java
deleted file mode 100644 (file)
index 94e3232..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-public interface RemoteRpcClient extends AutoCloseable{
-
-    void setRoutingTableProvider(RoutingTableProvider provider);
-
-    void stop();
-
-    void start();
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java
deleted file mode 100644 (file)
index 76df256..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
-import org.opendaylight.controller.sal.core.api.RpcRoutingContext;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
-public class RemoteRpcProvider implements
-    RpcImplementation,
-    RoutedRpcDefaultImplementation,
-    AutoCloseable,
-    Provider {
-
-  private final Logger _logger = LoggerFactory.getLogger(RemoteRpcProvider.class);
-
-  private final ServerImpl server;
-  private final ClientImpl client;
-  private RoutingTableProvider routingTableProvider;
-  private final RpcListener listener = new RpcListener();
-  private final RoutedRpcListener routeChangeListener = new RoutedRpcListener();
-  private ProviderSession brokerSession;
-  private RpcProvisionRegistry rpcProvisionRegistry;
-  private BundleContext context;
-  private ServiceTracker<?, ?> clusterTracker;
-
-  public RemoteRpcProvider(ServerImpl server, ClientImpl client) {
-    this.server = server;
-    this.client = client;
-  }
-
-  public void setRoutingTableProvider(RoutingTableProvider provider) {
-    this.routingTableProvider = provider;
-    client.setRoutingTableProvider(provider);
-  }
-
-  public void setContext(BundleContext context){
-    this.context = context;
-  }
-
-  public void setRpcProvisionRegistry(RpcProvisionRegistry rpcProvisionRegistry){
-    this.rpcProvisionRegistry = rpcProvisionRegistry;
-  }
-
-  @Override
-  public void onSessionInitiated(ProviderSession session) {
-    brokerSession = session;
-    server.setBrokerSession(session);
-    start();
-  }
-
-  @Override
-  public Set<QName> getSupportedRpcs() {
-    //TODO: Ask Tony if we need to get this from routing table
-    return Collections.emptySet();
-  }
-
-  @Override
-  public Collection<ProviderFunctionality> getProviderFunctionality() {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(QName rpc, CompositeNode input) {
-    return client.invokeRpc(rpc, input);
-  }
-
-  @Override
-  public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(QName rpc, InstanceIdentifier identifier, CompositeNode input) {
-    return client.invokeRpc(rpc, identifier, input);
-  }
-
-  public void start() {
-    server.start();
-    client.start();
-    brokerSession.addRpcRegistrationListener(listener);
-    rpcProvisionRegistry.setRoutedRpcDefaultDelegate(this);
-    rpcProvisionRegistry.registerRouteChangeListener(routeChangeListener);
-
-    announceSupportedRpcs();
-    announceSupportedRoutedRpcs();
-  }
-
-  @Override
-  public void close() throws Exception {
-    unregisterSupportedRpcs();
-    unregisterSupportedRoutedRpcs();
-    server.close();
-    client.close();
-  }
-
-  public void stop() {
-    server.stop();
-    client.stop();
-  }
-
-  /**
-   * Add all the locally registered RPCs in the clustered routing table
-   */
-  private void announceSupportedRpcs(){
-    Set<QName> currentlySupported = brokerSession.getSupportedRpcs();
-    for (QName rpc : currentlySupported) {
-      listener.onRpcImplementationAdded(rpc);
-    }
-  }
-
-  /**
-   * Add all the locally registered Routed RPCs in the clustered routing table
-   */
-  private void announceSupportedRoutedRpcs(){
-
-    //TODO: announce all routed RPCs as well
-
-  }
-
-  /**
-   * Un-Register all the supported RPCs from clustered routing table
-   */
-  private void unregisterSupportedRpcs(){
-    Set<QName> currentlySupported = brokerSession.getSupportedRpcs();
-    //TODO: remove all routed RPCs as well
-    for (QName rpc : currentlySupported) {
-      listener.onRpcImplementationRemoved(rpc);
-    }
-  }
-
-  /**
-   * Un-Register all the locally supported Routed RPCs from clustered routing table
-   */
-  private void unregisterSupportedRoutedRpcs(){
-
-    //TODO: remove all routed RPCs as well
-
-  }
-
-  private RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> getRoutingTable(){
-    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> routingTable =
-        routingTableProvider.getRoutingTable();
-
-    checkState(routingTable.isPresent(), "Routing table is null");
-
-    return routingTable.get();
-  }
-
-  /**
-   * Listener for rpc registrations in broker
-   */
-  private class RpcListener implements RpcRegistrationListener {
-
-    @Override
-    public void onRpcImplementationAdded(QName rpc) {
-
-      _logger.debug("Adding registration for [{}]", rpc);
-      RouteIdentifierImpl routeId = new RouteIdentifierImpl();
-      routeId.setType(rpc);
-
-      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
-
-      try {
-        routingTable.addGlobalRoute(routeId, server.getServerAddress());
-        _logger.debug("Route added [{}-{}]", routeId, server.getServerAddress());
-
-      } catch (RoutingTableException | SystemException e) {
-        //TODO: This can be thrown when route already exists in the table. Broker
-        //needs to handle this.
-        _logger.error("Unhandled exception while adding global route to routing table [{}]", e);
-
-      }
-    }
-
-    @Override
-    public void onRpcImplementationRemoved(QName rpc) {
-
-      _logger.debug("Removing registration for [{}]", rpc);
-      RouteIdentifierImpl routeId = new RouteIdentifierImpl();
-      routeId.setType(rpc);
-
-      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
-
-      try {
-        routingTable.removeGlobalRoute(routeId);
-      } catch (RoutingTableException | SystemException e) {
-        _logger.error("Route delete failed {}", e);
-      }
-    }
-  }
-
-  /**
-   * Listener for Routed Rpc registrations in broker
-   */
-  private class RoutedRpcListener
-      implements RouteChangeListener<RpcRoutingContext, InstanceIdentifier> {
-
-    /**
-     *
-     * @param routeChange
-     */
-    @Override
-    public void onRouteChange(RouteChange<RpcRoutingContext, InstanceIdentifier> routeChange) {
-      Map<RpcRoutingContext, Set<InstanceIdentifier>> announcements = routeChange.getAnnouncements();
-      announce(getRouteIdentifiers(announcements));
-
-      Map<RpcRoutingContext, Set<InstanceIdentifier>> removals = routeChange.getRemovals();
-      remove(getRouteIdentifiers(removals));
-    }
-
-    /**
-     *
-     * @param announcements
-     */
-    private void announce(Set<RpcRouter.RouteIdentifier<?, ?, ?>> announcements) {
-      _logger.debug("Announcing [{}]", announcements);
-      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
-      try {
-        routingTable.addRoutes(announcements, server.getServerAddress());
-      } catch (RoutingTableException | SystemException e) {
-        _logger.error("Route announcement failed {}", e);
-      }
-    }
-
-    /**
-     *
-     * @param removals
-     */
-    private void remove(Set<RpcRouter.RouteIdentifier<?, ?, ?>> removals){
-      _logger.debug("Removing [{}]", removals);
-      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
-      try {
-        routingTable.removeRoutes(removals, server.getServerAddress());
-      } catch (RoutingTableException | SystemException e) {
-        _logger.error("Route removal failed {}", e);
-      }
-    }
-
-    /**
-     *
-     * @param changes
-     * @return
-     */
-    private Set<RpcRouter.RouteIdentifier<?, ?, ?>> getRouteIdentifiers(Map<RpcRoutingContext, Set<InstanceIdentifier>> changes) {
-      RouteIdentifierImpl routeId = null;
-      Set<RpcRouter.RouteIdentifier<?, ?, ?>> routeIdSet = new HashSet<>();
-
-      for (RpcRoutingContext context : changes.keySet()){
-        routeId = new RouteIdentifierImpl();
-        routeId.setType(context.getRpc());
-        //routeId.setContext(context.getContext());
-
-        for (InstanceIdentifier instanceId : changes.get(context)){
-          routeId.setRoute(instanceId);
-          routeIdSet.add(routeId);
-        }
-      }
-      return routeIdSet;
-    }
-
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RoutingTableProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RoutingTableProvider.java
deleted file mode 100644 (file)
index d960303..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.impl.RoutingTableImpl;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-import com.google.common.base.Optional;
-
-public class RoutingTableProvider implements AutoCloseable {
-
-    @SuppressWarnings("rawtypes")
-    final ServiceTracker<RoutingTable,RoutingTable> tracker;
-
-    private RoutingTableImpl<?, ?> routingTableImpl = null;
-
-    //final private RouteChangeListener routeChangeListener;
-
-
-    public RoutingTableProvider(BundleContext ctx){//,RouteChangeListener rcl) {
-        @SuppressWarnings("rawtypes")
-        ServiceTracker<RoutingTable, RoutingTable> rawTracker = new ServiceTracker<>(ctx, RoutingTable.class, null);
-        tracker = rawTracker;
-        tracker.open();
-
-        //routeChangeListener = rcl;
-    }
-
-    public Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> getRoutingTable() {
-        @SuppressWarnings("unchecked")
-        RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> tracked = tracker.getService();
-
-        if(tracked instanceof RoutingTableImpl){
-            if(routingTableImpl != tracked){
-             routingTableImpl= (RoutingTableImpl<?, ?>)tracked;
-             //routingTableImpl.setRouteChangeListener(routeChangeListener);
-            }
-        }
-
-        return Optional.fromNullable(tracked);
-    }
-
-    @Override
-    public void close() throws Exception {
-        tracker.close();
-    }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImpl.java
deleted file mode 100644 (file)
index 3acea35..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
-/**
- * ZeroMq based implementation of RpcRouter.
- */
-public class ServerImpl implements RemoteRpcServer {
-
-  private final Logger _logger = LoggerFactory.getLogger(ServerImpl.class);
-
-  private ExecutorService serverPool;
-  protected ServerRequestHandler handler;
-
-  private Set<QName> remoteServices;
-  private ProviderSession brokerSession;
-  private ZMQ.Context context;
-
-  private final String HANDLER_INPROC_ADDRESS = "inproc://rpc-request-handler";
-  private final int HANDLER_WORKER_COUNT = 2;
-  private final int HWM = 200;//high water mark on sockets
-  private volatile State status = State.STOPPED;
-
-  private String serverAddress;
-  private final int port;
-
-  public static enum State {
-    STARTING, STARTED, STOPPED;
-  }
-
-  public ServerImpl(int port) {
-    this.port = port;
-  }
-
-  public State getStatus() {
-    return this.status;
-  }
-
-  public Optional<ServerRequestHandler> getHandler() {
-    return Optional.fromNullable(this.handler);
-  }
-
-  public void setBrokerSession(ProviderSession session) {
-    this.brokerSession = session;
-  }
-
-  public Optional<ProviderSession> getBrokerSession() {
-    return Optional.fromNullable(this.brokerSession);
-  }
-
-  public Optional<ZMQ.Context> getZmqContext() {
-    return Optional.fromNullable(this.context);
-  }
-
-  public String getServerAddress() {
-    return serverAddress;
-  }
-
-  public String getHandlerAddress() {
-    return HANDLER_INPROC_ADDRESS;
-  }
-
-  /**
-   *
-   */
-  public void start() {
-    Preconditions.checkState(State.STOPPED == this.getStatus(),
-        "Remote RPC Server is already running");
-
-    status = State.STARTING;
-    _logger.debug("Remote RPC Server is starting...");
-
-    String hostIpAddress = findIpAddress();
-
-    //Log and silently die as per discussion in the bug (bug-362)
-    //https://bugs.opendaylight.org/show_bug.cgi?id=362
-    //
-    // A tracking enhancement defect (bug-366) is created to properly fix this issue
-    //https://bugs.opendaylight.org/show_bug.cgi?id=366
-    //checkState(hostIpAddress != null, "Remote RPC Server could not acquire host ip address");
-
-    if (hostIpAddress == null) {
-      _logger.error("Remote RPC Server could not acquire host ip address. Stopping...");
-      stop();
-      return;
-    }
-
-    this.serverAddress = new StringBuilder(hostIpAddress).
-        append(":").
-        append(port).
-        toString();
-
-    context = ZMQ.context(1);
-    remoteServices = new HashSet<QName>();//
-    serverPool = Executors.newSingleThreadExecutor();//main server thread
-    serverPool.execute(receive()); // Start listening rpc requests
-
-    status = State.STARTED;
-    _logger.info("Remote RPC Server started [{}]", getServerAddress());
-  }
-
-  public void stop(){
-    close();
-  }
-
-  /**
-   *
-   */
-  @Override
-  public void close() {
-
-    if (State.STOPPED == this.getStatus()) return; //do nothing
-
-    if (serverPool != null)
-      serverPool.shutdown();
-
-    closeZmqContext();
-
-    status = State.STOPPED;
-    _logger.info("Remote RPC Server stopped");
-  }
-
-  /**
-   * Closes ZMQ Context. It tries to gracefully terminate the context. If
-   * termination takes more than 5 seconds, its forcefully shutdown.
-   */
-  private void closeZmqContext() {
-    ExecutorService exec = Executors.newSingleThreadExecutor();
-    FutureTask<?> zmqTermination = new FutureTask<Void>(new Runnable() {
-
-      @Override
-      public void run() {
-        try {
-          if (context != null)
-            context.term();
-          _logger.debug("ZMQ Context terminated gracefully!");
-        } catch (Exception e) {
-          _logger.debug("ZMQ Context termination threw exception [{}]. Continuing shutdown...", e);
-        }
-      }
-    }, null);
-
-    exec.execute(zmqTermination);
-
-    try {
-      zmqTermination.get(5L, TimeUnit.SECONDS);
-    } catch (Exception e) {/*ignore and continue with shutdown*/}
-
-    exec.shutdownNow();
-  }
-
-  /**
-   * Main listener thread that spawns {@link ServerRequestHandler} as workers.
-   *
-   * @return
-   */
-  private Runnable receive() {
-    return new Runnable() {
-
-      @Override
-      public void run() {
-        Thread.currentThread().setName("remote-rpc-server");
-        _logger.debug("Remote RPC Server main thread starting...");
-
-        //socket clients connect to (frontend)
-        ZMQ.Socket clients = context.socket(ZMQ.ROUTER);
-
-        //socket RequestHandlers connect to (backend)
-        ZMQ.Socket workers = context.socket(ZMQ.DEALER);
-
-        try (SocketPair capturePair = new SocketPair();
-             ServerRequestHandler requestHandler = new ServerRequestHandler(context,
-                 brokerSession,
-                 HANDLER_WORKER_COUNT,
-                 HANDLER_INPROC_ADDRESS,
-                 getServerAddress());) {
-
-          handler = requestHandler;
-          clients.setHWM(HWM);
-          clients.bind("tcp://*:" + port);
-          workers.setHWM(HWM);
-          workers.bind(HANDLER_INPROC_ADDRESS);
-          //start worker threads
-          _logger.debug("Remote RPC Server worker threads starting...");
-          requestHandler.start();
-          //start capture thread
-          // handlerPool.execute(new CaptureHandler(capturePair.getReceiver()));
-          //  Connect work threads to client threads via a queue
-          ZMQ.proxy(clients, workers, null);//capturePair.getSender());
-
-        } catch (Exception e) {
-          _logger.debug("Unhandled exception [{}, {}]", e.getClass(), e.getMessage());
-        } finally {
-          if (clients != null) clients.close();
-          if (workers != null) workers.close();
-          _logger.info("Remote RPC Server stopped");
-        }
-      }
-    };
-  }
-
-  /**
-   * Finds IPv4 address of the local VM
-   * TODO: This method is non-deterministic. There may be more than one IPv4 address. Cant say which
-   * address will be returned. Read IP from a property file or enhance the code to make it deterministic.
-   * Should we use IP or hostname?
-   *
-   * @return
-   */
-  private String findIpAddress() {
-    Enumeration<?> e = null;
-    try {
-      e = NetworkInterface.getNetworkInterfaces();
-    } catch (SocketException e1) {
-      _logger.error("Failed to get list of interfaces", e1);
-      return null;
-    }
-    while (e.hasMoreElements()) {
-
-      NetworkInterface n = (NetworkInterface) e.nextElement();
-
-      Enumeration<?> ee = n.getInetAddresses();
-      while (ee.hasMoreElements()) {
-        InetAddress i = (InetAddress) ee.nextElement();
-        _logger.debug("Trying address {}", i);
-        if ((i instanceof Inet4Address) && (!i.isLoopbackAddress())) {
-          String hostAddress = i.getHostAddress();
-          _logger.debug("Settled on host address {}", hostAddress);
-          return hostAddress;
-        }
-      }
-    }
-
-    _logger.error("Failed to find a suitable host address");
-    return null;
-  }
-
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandler.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandler.java
deleted file mode 100644 (file)
index a25387d..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Future;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.connector.remoterpc.util.XmlUtils;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-/**
- *
- */
-public class ServerRequestHandler implements AutoCloseable{
-
-  private final Logger _logger = LoggerFactory.getLogger(ServerRequestHandler.class);
-  private final String DEFAULT_NAME = "remote-rpc-worker";
-  private final String dealerAddress;
-  private final String serverAddress;
-  private final int workerCount;
-  private final ZMQ.Context context;
-  private final Broker.ProviderSession broker;
-
-  private RequestHandlerThreadPool workerPool;
-  private final AtomicInteger threadId = new AtomicInteger();
-
-  public ServerRequestHandler(ZMQ.Context context,
-                              Broker.ProviderSession session,
-                              int workerCount,
-                              String dealerAddress,
-                              String serverAddress) {
-    this.context       = context;
-    this.dealerAddress = dealerAddress;
-    this.serverAddress = serverAddress;
-    this.broker        = session;
-    this.workerCount   = workerCount;
-  }
-
-  public ThreadPoolExecutor getWorkerPool(){
-    return workerPool;
-  }
-
-  public void start(){
-    workerPool = new RequestHandlerThreadPool(
-        workerCount, workerCount,
-        0L, TimeUnit.MILLISECONDS,
-        new LinkedBlockingQueue<Runnable>());
-    //unbound is ok. Task will never be submitted
-
-    for (int i=0;i<workerCount;i++){
-      workerPool.execute(new Worker(threadId.incrementAndGet()));
-    }
-  }
-
-  /**
-   * This gets called automatically if used with try-with-resources
-   * @throws Exception
-   */
-  @Override
-  public void close() throws Exception {
-    if (workerPool != null)
-      workerPool.shutdown();
-    _logger.info("Request Handler closed");
-  }
-
-  /**
-   * Worker to handles RPC request
-   */
-  private class Worker implements Runnable {
-    private final String name;
-
-    public Worker(int id){
-      this.name = DEFAULT_NAME + "-" + id;
-    }
-
-    @Override
-    public void run() {
-      Thread.currentThread().setName(name);
-      _logger.debug("Starting... ");
-      ZMQ.Socket socket = null;
-
-      try {
-        socket = context.socket(ZMQ.REP);
-        socket.connect(dealerAddress);
-
-        while (!Thread.currentThread().isInterrupted()) {
-
-          MessageHandler handler = new MessageHandler(socket);
-          handler.receiveMessage();
-
-          if (handler.hasMessageForBroker()) {
-
-            Message request = handler.getMessage();
-            Future<RpcResult<CompositeNode>> rpc = null;
-            RpcResult<CompositeNode> result = null;
-
-            //TODO Call this in a new thread with timeout
-            try {
-              rpc = broker.rpc(
-                  (QName) request.getRoute().getType(),
-                  XmlUtils.xmlToCompositeNode((String) request.getPayload()));
-
-              result = (rpc != null) ? rpc.get() : null;
-
-              handler.sendResponse(result);
-
-            } catch (Exception e) {
-              _logger.debug("Broker threw  [{}]", e);
-              handler.sendError(e.getMessage());
-            }
-          }
-
-        }
-      } catch (Exception e) {
-        printException(e);
-      } finally {
-        closeSocket(socket);
-      }
-    }
-
-    private void printException(Exception e) {
-      try (StringWriter s = new StringWriter();
-           PrintWriter p = new PrintWriter(s)) {
-        e.printStackTrace(p);
-        _logger.debug(s.toString());
-      } catch (IOException e1) {/*Ignore and continue*/ }
-    }
-
-    private void closeSocket(ZMQ.Socket socket) {
-      try {
-        if (socket != null) socket.close();
-      } catch (Exception x) {
-        _logger.debug("Exception while closing socket [{}]", x);
-      } finally {
-        if (socket != null) socket.close();
-      }
-      _logger.debug("Closing...");
-    }
-  }
-
-
-  /**
-   *
-   */
-  public class RequestHandlerThreadPool extends ThreadPoolExecutor{
-
-    public RequestHandlerThreadPool(int corePoolSize,
-                                    int maximumPoolSize,
-                                    long keepAliveTime,
-                                    TimeUnit unit,
-                                    BlockingQueue<Runnable> workQueue) {
-      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
-    }
-
-    @Override
-    protected void afterExecute(Runnable r, Throwable t) {
-      if (isTerminating() || isTerminated() || isShutdown())
-        return;
-
-      if ( t != null ){
-        _logger.debug("Exception caught while terminating worker [{},{}]", t.getClass(), t.getMessage());
-      }
-
-      this.execute(new Worker(threadId.incrementAndGet()));
-      super.afterExecute(r, null);
-    }
-  }
-
-  class MessageHandler{
-    private final ZMQ.Socket socket;
-    private Message message;          //parsed message received on zmq server port
-    private boolean messageForBroker = false; //if the message is valid and not a "ping" message
-
-    public MessageHandler(ZMQ.Socket socket){
-      this.socket = socket;
-    }
-
-    void receiveMessage(){
-      byte[] bytes = socket.recv(); //this blocks
-      _logger.debug("Received bytes:[{}]", bytes.length);
-
-      Object objectRecvd = null;
-      try{
-        objectRecvd = Message.deserialize(bytes);
-      }catch (Exception e){
-        sendError(e.getMessage());
-        return;
-      }
-
-      if (!(objectRecvd instanceof Message)) {
-        sendError("Invalid message received");
-        return;
-      }
-
-      message = (Message) objectRecvd;
-
-      _logger.info("Received request [{}]", message);
-
-      if (Message.MessageType.PING == message.getType()){
-        sendPong();
-        return;
-      }
-
-      messageForBroker = true;
-    }
-
-    boolean hasMessageForBroker(){
-      return messageForBroker;
-    }
-
-    Message getMessage(){
-      return message;
-    }
-
-    void sendResponse(RpcResult<CompositeNode> result){
-      CompositeNode payload = (result != null) ? result.getResult() : null;
-
-      String recipient = null;
-      RpcRouter.RouteIdentifier<?, ?, ?> routeId = null;
-
-      if (message != null) {
-        recipient = message.getSender();
-        routeId   = message.getRoute();
-      }
-
-      Message response = new Message.MessageBuilder()
-          .type(Message.MessageType.RESPONSE)
-          .sender(serverAddress)
-          .recipient(recipient)
-          .route(routeId)
-          .payload(XmlUtils.compositeNodeToXml(payload))
-          .build();
-
-      send(response);
-    }
-
-    private void sendError(String msg){
-      Message errorResponse = new Message.MessageBuilder()
-          .type(Message.MessageType.ERROR)
-          .sender(serverAddress)
-          .payload(msg)
-          .build();
-
-      send(errorResponse);
-    }
-
-    private void sendPong(){
-      Message pong = new Message.MessageBuilder()
-          .type(Message.MessageType.PONG)
-          .sender(serverAddress)
-          .build();
-
-      send(pong);
-    }
-
-    private void send(Message msg){
-      byte[] serializedMessage = null;
-      try {
-        serializedMessage = Message.serialize(msg);
-      } catch (Exception e) {
-        _logger.debug("Unexpected error during serialization of response [{}]", msg);
-        return;
-      }
-
-      if (serializedMessage != null)
-        if (socket.send(serializedMessage))
-          _logger.info("Response sent [{}]", msg);
-        else  _logger.debug("Failed to send serialized message");
-    }
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/SocketPair.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/SocketPair.java
deleted file mode 100644 (file)
index f569944..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.sal.connector.remoterpc;
-
-import org.zeromq.ZMQ;
-
-import java.util.UUID;
-
-/**
- *
- */
-public class SocketPair implements AutoCloseable{
-  private ZMQ.Socket sender;
-  private ZMQ.Socket receiver;
-
-  private static final String INPROC_PREFIX = "inproc://";
-
-  public SocketPair(){
-    String address = new StringBuilder(INPROC_PREFIX)
-                         .append(UUID.randomUUID())
-                         .toString();
-
-    receiver = Context.getInstance().getZmqContext().socket(ZMQ.PAIR);
-    receiver.bind(address);
-
-    sender = Context.getInstance().getZmqContext().socket(ZMQ.PAIR);
-    sender.connect(address);
-  }
-
-  public ZMQ.Socket getSender(){
-    return this.sender;
-  }
-
-  public ZMQ.Socket getReceiver(){
-    return this.receiver;
-  }
-
-  @Override
-  public void close() throws Exception {
-    sender.close();
-    receiver.close();
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java
deleted file mode 100644 (file)
index cbcfe3e..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.dto;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-
-public class Message implements Serializable {
-    private static final long serialVersionUID = 1L;
-
- public static enum MessageType {
-    PING((byte) 0),
-    PONG((byte) 1),
-    REQUEST((byte) 2),
-    RESPONSE((byte) 3),
-    ERROR((byte)4);
-
-    private final byte type;
-
-    MessageType(byte type) {
-      this.type = type;
-    }
-
-    public byte getType(){
-      return this.type;
-    }
-  }
-
-  private MessageType type;
-  private String sender;
-  private String recipient;
-  private RpcRouter.RouteIdentifier<?, ?, ?> route;
-  private Object payload;
-
-  public MessageType getType() {
-    return type;
-  }
-
-  public void setType(MessageType type) {
-    this.type = type;
-  }
-
-  public String getSender() {
-    return sender;
-  }
-
-  public void setSender(String sender) {
-    this.sender = sender;
-  }
-
-  public RpcRouter.RouteIdentifier<?, ?, ?> getRoute() {
-    return route;
-  }
-
-  public void setRoute(RpcRouter.RouteIdentifier<?, ?, ?> route) {
-    this.route = route;
-  }
-
-  public Object getPayload() {
-    return payload;
-  }
-
-  public void setPayload(Object payload) {
-    this.payload = payload;
-  }
-
-  public String getRecipient() {
-    return recipient;
-  }
-
-  public void setRecipient(String recipient) {
-    this.recipient = recipient;
-  }
-
-  @Override
-  public String toString() {
-    return "Message{" +
-        "type=" + type +
-        ", sender='" + sender + '\'' +
-        ", recipient='" + recipient + '\'' +
-        ", route=" + route +
-        ", payload=" + payload +
-        '}';
-  }
-
-  /**
-   * Converts any {@link Serializable} object to byte[]
-   *
-   * @param obj
-   * @return
-   * @throws IOException
-   */
-  public static byte[] serialize(Object obj) throws IOException {
-    ByteArrayOutputStream b = new ByteArrayOutputStream();
-    ObjectOutputStream o = new ObjectOutputStream(b);
-    o.writeObject(obj);
-    return b.toByteArray();
-  }
-
-  /**
-   * Converts byte[] to a java object
-   *
-   * @param bytes
-   * @return
-   * @throws IOException
-   * @throws ClassNotFoundException
-   */
-  public static Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
-    ByteArrayInputStream b = new ByteArrayInputStream(bytes);
-    ObjectInputStream o = new ObjectInputStream(b);
-    return o.readObject();
-  }
-
-  public static class Response extends Message implements RpcRouter.RpcReply<Object> {
-    private static final long serialVersionUID = 1L;
-    private ResponseCode code; // response code
-
-    public static enum ResponseCode {
-      SUCCESS(200), BADREQUEST(400), TIMEOUT(408), GONE(410), SERVERERROR(500), SERVICEUNAVAILABLE(503);
-
-      private final int code;
-
-      ResponseCode(int code) {
-        this.code = code;
-      }
-    }
-
-    public ResponseCode getCode() {
-      return code;
-    }
-
-    public void setCode(ResponseCode code) {
-      this.code = code;
-    }
-  }
-
-  /**
-   * Builds a {@link Message} object
-   */
-  public static class MessageBuilder{
-
-    private final Message message;
-
-    public MessageBuilder(){
-      message = new Message();
-    }
-
-
-    public MessageBuilder type(MessageType type){
-      message.setType(type);
-      return this;
-    }
-
-    public MessageBuilder sender(String sender){
-      message.setSender(sender);
-      return this;
-    }
-
-    public MessageBuilder recipient(String recipient){
-      message.setRecipient(recipient);
-      return this;
-    }
-
-    public MessageBuilder route(RpcRouter.RouteIdentifier<?, ?, ?> route){
-      message.setRoute(route);
-      return this;
-    }
-
-    public MessageBuilder payload(Object obj){
-      message.setPayload(obj);
-      return this;
-    }
-
-    public Message build(){
-      return message;
-    }
-  }
-}
-
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java
deleted file mode 100644 (file)
index 85f4113..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.dto;
-
-import org.zeromq.ZMQ;
-
-/**
- * A class encapsulating {@link Message} and the {@link ZMQ.Socket} over which it is transmitted
- */
-public class MessageWrapper {
-
-  private Message _message;
-  private ZMQ.Socket _receiveSocket;
-
-  public MessageWrapper(Message message, ZMQ.Socket receiveSocket) {
-    this._message = message;
-    this._receiveSocket = receiveSocket;
-  }
-
-  public Message getMessage() {
-    return _message;
-  }
-
-  public ZMQ.Socket getReceiveSocket() {
-    return _receiveSocket;
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java
deleted file mode 100644 (file)
index 53c7cc0..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc.dto;
-
-import java.io.Serializable;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier>,Serializable {
-  private static final long serialVersionUID = 1L;
-
-  private QName context;
-  private QName type;
-  private InstanceIdentifier route;
-
-  @Override
-  public QName getContext() {
-    return this.context;
-  }
-
-  @Override
-  public QName getType() {
-    return this.type;
-  }
-
-  @Override
-  public InstanceIdentifier getRoute() {
-    return this.route;
-  }
-
-  public void setContext(QName context) {
-    this.context = context;
-  }
-
-  public void setType(QName type) {
-    this.type = type;
-  }
-
-  public void setRoute(InstanceIdentifier route) {
-    this.route = route;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-
-    RouteIdentifierImpl that = (RouteIdentifierImpl) o;
-
-    if (context == null){
-      if (that.getContext() != null)  return false;
-    }else
-      if (!context.equals(that.context)) return false;
-
-    if (route == null){
-      if (that.getRoute() != null) return false;
-    }else
-      if (!route.equals(that.route)) return false;
-
-    if (type == null){
-      if (that.getType() != null) return false;
-    }else
-      if (!type.equals(that.type)) return false;
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int prime = 31;
-    int result = 0;
-    result = prime * result + (context == null ? 0:context.hashCode());
-    result = prime * result + (type    == null ? 0:type.hashCode());
-    result = prime * result + (route   == null ? 0:route.hashCode());
-    return result;
-  }
-
-  @Override
-  public String toString() {
-    return "RouteIdentifierImpl{" +
-        "context=" + context +
-        ", type=" + type +
-        ", route=" + route +
-        '}';
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/util/XmlUtils.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/util/XmlUtils.java
deleted file mode 100644 (file)
index 3bc3963..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.util;
-
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;
-import org.opendaylight.yangtools.yang.data.impl.NodeUtils;
-import org.opendaylight.yangtools.yang.data.impl.XmlTreeBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.ByteArrayInputStream;
-import java.io.StringWriter;
-
-public class XmlUtils {
-
-  private static final Logger _logger = LoggerFactory.getLogger(XmlUtils.class);
-
-  public static String compositeNodeToXml(CompositeNode cNode){
-    if (cNode == null) return new String();
-
-    Document domTree = NodeUtils.buildShadowDomTree(cNode);
-    StringWriter writer = new StringWriter();
-    try {
-      TransformerFactory tf = TransformerFactory.newInstance();
-      Transformer transformer = tf.newTransformer();
-      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-      transformer.transform(new DOMSource(domTree), new StreamResult(writer));
-    } catch (TransformerException e) {
-      _logger.error("Error during translation of Document to OutputStream", e);
-    }
-
-    return writer.toString();
-  }
-
-  public static CompositeNode xmlToCompositeNode(String xml){
-    if (xml==null || xml.length()==0) return null;
-
-    Node<?> dataTree;
-    try {
-      dataTree = XmlTreeBuilder.buildDataTree(new ByteArrayInputStream(xml.getBytes()));
-    } catch (XMLStreamException e) {
-      _logger.error("Error during building data tree from XML", e);
-      return null;
-    }
-    if (dataTree == null) {
-      _logger.error("data tree is null");
-      return null;
-    }
-    if (dataTree instanceof SimpleNode) {
-      _logger.error("RPC XML was resolved as SimpleNode");
-      return null;
-    }
-    return (CompositeNode) dataTree;
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/yang/odl-sal-dom-rpc-remote-cfg.yang b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/yang/odl-sal-dom-rpc-remote-cfg.yang
deleted file mode 100644 (file)
index beeb936..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-module odl-sal-dom-rpc-remote-cfg {
-       yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc";
-    prefix "rpc-cluster";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-dom {prefix dom;}
-    
-    description
-        "Service definition for Binding Aware MD-SAL.";
-    revision "2013-10-28" {
-        description
-            "Initial revision";
-    }
-
-    identity remote-rpc-server {
-        base config:service-type;
-        config:java-class "org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcServer";
-    }
-
-    identity remote-rpc-client {
-        base config:service-type;
-        config:java-class "org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcClient";
-    }
-
-    identity remote-zeromq-rpc-server {
-        base config:module-type;
-        config:java-name-prefix ZeroMQServer;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case remote-zeromq-rpc-server {
-            when "/config:modules/config:module/config:type = 'remote-zeromq-rpc-server'";
-            
-            container dom-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity dom:dom-broker-osgi-registry;
-                    }
-                }
-            }
-            
-            leaf port {
-                type uint16;
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImplTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImplTest.java
deleted file mode 100644 (file)
index f8d14ce..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-
-import junit.framework.Assert;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-import com.google.common.base.Optional;
-
-/**
- *
- */
-public class ClientImplTest {
-  RoutingTableProvider routingTableProvider;
-  ClientImpl client;
-  ClientRequestHandler mockHandler;
-
-  @Before
-  public void setUp() throws Exception {
-
-    //mock routing table
-    routingTableProvider = mock(RoutingTableProvider.class);
-    RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> mockRoutingTable = new MockRoutingTable<String, String>();
-    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> optionalRoutingTable = Optional.fromNullable(mockRoutingTable);
-    when(routingTableProvider.getRoutingTable()).thenReturn(optionalRoutingTable);
-
-    //mock ClientRequestHandler
-    mockHandler = mock(ClientRequestHandler.class);
-
-    client = new ClientImpl(mockHandler);
-    client.setRoutingTableProvider(routingTableProvider);
-
-  }
-
-  @After
-  public void tearDown() throws Exception {
-
-  }
-
-  @Test
-  public void getRoutingTableProvider_Call_ShouldReturnMockProvider() throws Exception {
-    Assert.assertEquals(routingTableProvider, client.getRoutingTableProvider());
-
-  }
-
-  @Test
-  public void testStart() throws Exception {
-
-  }
-
-  @Test
-  public void testStop() throws Exception {
-
-  }
-
-  @Test
-  public void testClose() throws Exception {
-
-  }
-
-  //@Test
-  public void invokeRpc_NormalCall_ShouldReturnSuccess() throws Exception {
-
-    when(mockHandler.handle(any(Message.class))).
-            thenReturn(MessagingUtil.createEmptyMessage());
-
-    RpcResult<CompositeNode> result = client.invokeRpc(null, null).get();
-
-    Assert.assertTrue(result.isSuccessful());
-    Assert.assertTrue(result.getErrors().isEmpty());
-    Assert.assertNull(result.getResult());
-  }
-
-  //@Test
-  public void invokeRpc_HandlerThrowsException_ShouldReturnError() throws Exception {
-
-    when(mockHandler.handle(any(Message.class))).
-            thenThrow(new IOException());
-
-    RpcResult<CompositeNode> result = client.invokeRpc(null, null).get();
-
-    Assert.assertFalse(result.isSuccessful());
-    Assert.assertFalse(result.getErrors().isEmpty());
-    Assert.assertNull(result.getResult());
-  }
-
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java
deleted file mode 100644 (file)
index 0918868..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.Assert;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-/**
- *
- */
-public class ClientRequestHandlerTest {
-
-  private final Logger _logger = LoggerFactory.getLogger(ClientRequestHandlerTest.class);
-
-  ZMQ.Context context;
-  ExecutorService serverThread;
-  final String SERVER_ADDRESS = "localhost:5553";
-
-  ClientRequestHandler handler;
-
-  @Before
-  public void setUp() throws Exception {
-    context = ZMQ.context(1);
-    serverThread = Executors.newCachedThreadPool();
-    handler = new ClientRequestHandler(context);
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    serverThread.shutdown();
-    MessagingUtil.closeZmqContext(context);
-    handler.close();
-  }
-
- @Test
-  public void handle_SingleRemote_ShouldReturnResponse() throws Exception {
-    serverThread.execute(MessagingUtil.startReplyServer(context, SERVER_ADDRESS, 1));
-    Message request = new Message();
-    request.setRecipient(SERVER_ADDRESS);
-    Message response = handleMessageWithTimeout(request);
-    Assert.assertNotNull(response);
-    //should be connected to only 1 remote server
-    Assert.assertEquals(1, handler.getWorkerCount());
-    Assert.assertEquals(response.getRecipient(), SERVER_ADDRESS);
-  }
-
- // @Test
-  public void handle_MultiRemote_ShouldReturnResponses() throws Exception {
-    ExecutorService threadPool = Executors.newCachedThreadPool();
-    final int port = 5555;
-    String serverAddress = null;
-    for (int i = 0; i < 5; i++) {
-      serverAddress = "localhost:" + (port + i);
-      serverThread.execute(MessagingUtil.startReplyServer(context, serverAddress, 1));
-      threadPool.execute(createEmptyMessageTaskAndHandle(handler, serverAddress));
-    }
-    Thread.sleep(5000);//wait for all messages to get processed
-    //should be connected to 5 remote server
-    Assert.assertEquals(5, handler.getWorkerCount());
-  }
-
-  private Runnable createEmptyMessageTaskAndHandle(final ClientRequestHandler handler, final String serverAddress) {
-
-    return new Runnable() {
-      @Override
-      public void run() {
-        Message request = new Message();
-        request.setRecipient(serverAddress);
-        try {
-          Message response = handleMessageWithTimeout(request);
-          Assert.assertNotNull(response);
-          Assert.assertEquals(response.getRecipient(), serverAddress);
-        } catch (Exception e) {
-          throw new RuntimeException(e);
-        }
-      }
-    };
-  }
-
-  private Message handleMessageWithTimeout(final Message request) {
-    Message response = null;
-
-    FutureTask<?> task = new FutureTask<Message>(new Callable<Message>() {
-
-      @Override
-      public Message call() {
-        try {
-          return handler.handle(request);
-        } catch (Exception e) {
-          _logger.debug("Client handler failed to handle request. Exception is [{}]", e);
-        }
-        return null;
-      }
-    });
-
-    serverThread.execute(task);
-
-    try {
-      response = (Message) task.get(5L, TimeUnit.SECONDS); //wait for max 5 sec for server to respond
-    } catch (Exception e) {/*ignore and continue*/}
-
-    return response;
-  }
-
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/MockRoutingTable.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/MockRoutingTable.java
deleted file mode 100644 (file)
index 179051e..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-
-/**
- * Mock implementation of routing table
- */
-public class MockRoutingTable<K, V> implements RoutingTable {
-
-
-  @Override
-  public void addRoute(Object o, Object o2) throws RoutingTableException, SystemException {
-
-  }
-
-  @Override
-  public void addGlobalRoute(Object o, Object o2) throws RoutingTableException, SystemException {
-
-  }
-
-  @Override
-  public void removeRoute(Object o, Object o2) {
-
-  }
-
-  @Override
-  public void addRoutes(Set set, Object o) throws RoutingTableException, SystemException {
-    //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @Override
-  public void removeRoutes(Set set, Object o) throws RoutingTableException, SystemException {
-    //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @Override
-  public void removeGlobalRoute(Object o) throws RoutingTableException, SystemException {
-
-  }
-
-  @Override
-  public Object getGlobalRoute(Object o) throws RoutingTableException, SystemException {
-    return null;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @Override
-  public Set<String> getRoutes(Object o) {
-    Set<String> routes = new HashSet<String>();
-    routes.add("localhost:5554");
-    return routes;
-  }
-
-  @Override
-  public Object getLastAddedRoute(Object o) {
-    return null;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-//  @Override
-//  public Set<Map.Entry> getAllRoutes() {
-//    return Collections.emptySet();
-//  }
-
-//  @Override
-//  public Object getARoute(Object o) {
-//    return null;
-//  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProviderTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProviderTest.java
deleted file mode 100644 (file)
index 06360aa..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RemoteRpcProviderTest {
-  @Before
-  public void setUp() throws Exception {
-
-  }
-
-  @After
-  public void tearDown() throws Exception {
-
-  }
-
-  @Test
-  public void testSetRoutingTableProvider() throws Exception {
-
-  }
-
-  @Test
-  public void testOnSessionInitiated() throws Exception {
-
-  }
-
-  @Test
-  public void testGetSupportedRpcs() throws Exception {
-
-  }
-
-  @Test
-  public void testGetProviderFunctionality() throws Exception {
-
-  }
-
-  @Test
-  public void testInvokeRpc() throws Exception {
-
-  }
-
-  @Test
-  public void testInvokeRoutedRpc() throws Exception {
-
-  }
-
-  @Test
-  public void testStart() throws Exception {
-
-  }
-
-  @Test
-  public void testClose() throws Exception {
-
-  }
-
-  @Test
-  public void testStop() throws Exception {
-
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/SerilizationTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/SerilizationTest.java
deleted file mode 100644 (file)
index 41422fd..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;
-import org.opendaylight.yangtools.yang.data.impl.NodeUtils;
-import org.opendaylight.yangtools.yang.data.impl.XmlTreeBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.StringWriter;
-
-public class SerilizationTest {
-
-  private static final Logger _logger = LoggerFactory.getLogger(SerilizationTest.class);
-
-  public void fromXml() {
-  }
-
-  @Test
-  public void toXml() throws FileNotFoundException {
-
-    //InputStream xmlStream = SerilizationTest.class.getResourceAsStream("/FourSimpleChildren.xml");
-    InputStream xmlStream = SerilizationTest.class.getResourceAsStream("/AddFlow.xml");
-    StringWriter writer = new StringWriter();
-
-    CompositeNode data = loadCompositeNode(xmlStream);
-    Document domTree = NodeUtils.buildShadowDomTree(data);
-    try {
-      TransformerFactory tf = TransformerFactory.newInstance();
-      Transformer transformer = tf.newTransformer();
-      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-      //transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-      //transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-      //transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-      //transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
-      transformer.transform(new DOMSource(domTree), new StreamResult(writer));
-    } catch (TransformerException e) {
-      _logger.error("Error during translation of Document to OutputStream", e);
-    }
-
-    _logger.info("Parsed xml [{}]", writer.toString());
-  }
-
-  // Figure out how to include TestUtils through pom ...was getting errors
-  private CompositeNode loadCompositeNode(InputStream xmlInputStream) throws FileNotFoundException {
-    if (xmlInputStream == null) {
-      throw new IllegalArgumentException();
-    }
-    Node<?> dataTree;
-    try {
-      dataTree = XmlTreeBuilder.buildDataTree(xmlInputStream);
-    } catch (XMLStreamException e) {
-      _logger.error("Error during building data tree from XML", e);
-      return null;
-    }
-    if (dataTree == null) {
-      _logger.error("data tree is null");
-      return null;
-    }
-    if (dataTree instanceof SimpleNode) {
-      _logger.error("RPC XML was resolved as SimpleNode");
-      return null;
-    }
-    return (CompositeNode) dataTree;
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImplTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImplTest.java
deleted file mode 100644 (file)
index 7ffdf17..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import junit.framework.Assert;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.zeromq.ZMQ;
-
-import zmq.Ctx;
-import zmq.SocketBase;
-
-import com.google.common.base.Optional;
-
-public class ServerImplTest {
-
-  private static ZMQ.Context context;
-  private ServerImpl server;
-  private Broker.ProviderSession brokerSession;
-  private RoutingTableProvider routingTableProvider;
-  private RpcRegistrationListener listener;
-
-  ExecutorService pool;
-
-  //Server configuration
-  private final int HANDLER_COUNT = 2;
-  private final int HWM = 200;
-  private final int port = 5554;
-  //server address
-  private final String SERVER_ADDRESS = "tcp://localhost:5554";
-
-  //@BeforeClass
-  public static void init() {
-    context = ZMQ.context(1);
-  }
-
-  //@AfterClass
-  public static void destroy() {
-    MessagingUtil.closeZmqContext(context);
-  }
-
-  @Before
-  public void setup() throws InterruptedException {
-    context = ZMQ.context(1);
-    brokerSession = mock(Broker.ProviderSession.class);
-    routingTableProvider = mock(RoutingTableProvider.class);
-    listener = mock(RpcRegistrationListener.class);
-
-    server = new ServerImpl(port);
-    server.setBrokerSession(brokerSession);
-
-    RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> mockRoutingTable = new MockRoutingTable<String, String>();
-    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> optionalRoutingTable = Optional.fromNullable(mockRoutingTable);
-    when(routingTableProvider.getRoutingTable()).thenReturn(optionalRoutingTable);
-
-    when(brokerSession.addRpcRegistrationListener(listener)).thenReturn(null);
-    when(brokerSession.getSupportedRpcs()).thenReturn(Collections.<QName>emptySet());
-    when(brokerSession.rpc(null, mock(CompositeNode.class))).thenReturn(null);
-    server.start();
-    Thread.sleep(5000);//wait for server to start
-  }
-
-  @After
-  public void tearDown() throws InterruptedException {
-
-    if (pool != null)
-      pool.shutdown();
-
-    if (server != null)
-      server.stop();
-
-    MessagingUtil.closeZmqContext(context);
-
-    Thread.sleep(5000);//wait for server to stop
-    Assert.assertEquals(ServerImpl.State.STOPPED, server.getStatus());
-  }
-
-  @Test
-  public void getBrokerSession_Call_ShouldReturnBrokerSession() throws Exception {
-    Optional<Broker.ProviderSession> mayBeBroker = server.getBrokerSession();
-
-    if (mayBeBroker.isPresent())
-      Assert.assertEquals(brokerSession, mayBeBroker.get());
-    else
-      Assert.fail("Broker does not exist in Remote RPC Server");
-
-  }
-
-  @Test
-  public void start_Call_ShouldSetServerStatusToStarted() throws Exception {
-    Assert.assertEquals(ServerImpl.State.STARTED, server.getStatus());
-
-  }
-
-  @Test
-  public void start_Call_ShouldCreateNZmqSockets() throws Exception {
-    final int EXPECTED_COUNT = 2 + HANDLER_COUNT; //1 ROUTER + 1 DEALER + HANDLER_COUNT
-
-    Optional<ZMQ.Context> mayBeContext = server.getZmqContext();
-    if (mayBeContext.isPresent())
-      Assert.assertEquals(EXPECTED_COUNT, findSocketCount(mayBeContext.get()));
-    else
-      Assert.fail("ZMQ Context does not exist in Remote RPC Server");
-  }
-
-  @Test
-  public void start_Call_ShouldCreate1ServerThread() {
-    final String SERVER_THREAD_NAME = "remote-rpc-server";
-    final int EXPECTED_COUNT = 1;
-    List<Thread> serverThreads = findThreadsWithName(SERVER_THREAD_NAME);
-    Assert.assertEquals(EXPECTED_COUNT, serverThreads.size());
-  }
-
-  @Test
-  public void start_Call_ShouldCreateNHandlerThreads() {
-    //final String WORKER_THREAD_NAME = "remote-rpc-worker";
-    final int EXPECTED_COUNT = HANDLER_COUNT;
-
-    Optional<ServerRequestHandler> serverRequestHandlerOptional = server.getHandler();
-    if (serverRequestHandlerOptional.isPresent()){
-      ServerRequestHandler handler = serverRequestHandlerOptional.get();
-      ThreadPoolExecutor workerPool = handler.getWorkerPool();
-      Assert.assertEquals(EXPECTED_COUNT, workerPool.getPoolSize());
-    } else {
-      Assert.fail("Server is in illegal state. ServerHandler does not exist");
-    }
-
-  }
-
-  @Test
-  public void testStop() throws Exception {
-
-  }
-
-  @Test
-  public void testOnRouteUpdated() throws Exception {
-
-  }
-
-  @Test
-  public void testOnRouteDeleted() throws Exception {
-
-  }
-
-  private int findSocketCount(ZMQ.Context context)
-      throws NoSuchFieldException, IllegalAccessException {
-    Field ctxField = context.getClass().getDeclaredField("ctx");
-    ctxField.setAccessible(true);
-    Ctx ctx = Ctx.class.cast(ctxField.get(context));
-
-    Field socketListField = ctx.getClass().getDeclaredField("sockets");
-    socketListField.setAccessible(true);
-    List<SocketBase> sockets = List.class.cast(socketListField.get(ctx));
-
-    return sockets.size();
-  }
-
-  private List<Thread> findThreadsWithName(String name) {
-    Thread[] threads = new Thread[Thread.activeCount()];
-    Thread.enumerate(threads);
-
-    List<Thread> foundThreads = new ArrayList<Thread>();
-    for (Thread t : threads) {
-      if (t.getName().startsWith(name))
-        foundThreads.add(t);
-    }
-
-    return foundThreads;
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandlerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandlerTest.java
deleted file mode 100644 (file)
index e5fbc76..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc;
-
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import junit.framework.Assert;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.zeromq.ZMQ;
-
-public class ServerRequestHandlerTest {
-
-  ServerRequestHandler handler;
-  ZMQ.Context context;
-  ExecutorService executorService = Executors.newCachedThreadPool();
-  private final int workerCount = 2;
-  private final String mockDealerAddress = "inproc://rpc-request-handler";
-  private final String mockServerIp = "localhost";
-  private final int mockServerPort = 5554;
-
-  @Before
-  public void setUp() throws Exception {
-    context = ZMQ.context(1);
-    String mockServerAddress = mockServerIp + ":" + mockServerPort;
-    Broker.ProviderSession mockSession = mock(Broker.ProviderSession.class);
-    handler = new ServerRequestHandler(context, mockSession, workerCount, mockDealerAddress, mockServerAddress);
-    handler.start();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    executorService.shutdown();
-    MessagingUtil.closeZmqContext(context);
-    handler.close();
-  }
-
-  @Test
-  public void testStart() throws Exception {
-    //should start workers == workerCount
-    Assert.assertEquals(workerCount, handler.getWorkerPool().getPoolSize());
-
-    //killing a thread should recreate another one
-
-    //start router-dealer bridge
-    executorService.execute(MessagingUtil.createRouterDealerBridge(context, mockDealerAddress, mockServerPort));
-    Thread.sleep(1000); //give sometime for socket initialization
-
-    //this will kill the thread
-    final String WORKER_THREAD_NAME = "remote-rpc-worker";
-    interruptAThreadWithName(WORKER_THREAD_NAME);
-
-    //send 4 message to router
-    for (int i = 0; i < 4; i++)
-      executorService.execute(MessagingUtil.sendAnEmptyMessage(context, "tcp://" + mockServerIp + ":" + mockServerPort));
-
-    //worker pool size should not change.
-    Assert.assertEquals(workerCount, handler.getWorkerPool().getPoolSize());
-
-    Thread.sleep(10000); //wait for processing to complete
-  }
-
-  @Test
-  public void testClose() throws Exception {
-
-  }
-
-  /**
-   * Interrupts the first thread found whose name starts with the provided name
-   *
-   * @param name
-   */
-  private void interruptAThreadWithName(String name) {
-    List<Thread> workerThreads = findThreadsWithName(name);
-    if (workerThreads.size() > 0) workerThreads.get(0).interrupt();
-  }
-
-  /**
-   * Find all threads that start with the given name
-   *
-   * @param name
-   * @return
-   */
-  private List<Thread> findThreadsWithName(String name) {
-    Thread[] threads = new Thread[Thread.activeCount()];
-    Thread.enumerate(threads);
-
-    List<Thread> foundThreads = new ArrayList<Thread>();
-    for (Thread t : threads) {
-      if (t.getName().startsWith(name))
-        foundThreads.add(t);
-    }
-
-    return foundThreads;
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/MessagingUtil.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/MessagingUtil.java
deleted file mode 100644 (file)
index 883aa52..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sal.connector.remoterpc.utils;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.Assert;
-
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-public class MessagingUtil {
-
-  private static final Logger _logger = LoggerFactory.getLogger(MessagingUtil.class);
-
-  public static Runnable startReplyServer(final ZMQ.Context context,
-                                          final String serverAddress,
-                                          final int numRequests /*number of requests after which server shuts down*/) {
-    return new Runnable() {
-
-      @Override
-      public void run() {
-        final ZMQ.Socket socket = context.socket(ZMQ.REP);
-        try {
-          int returnCode = socket.bind("tcp://" + serverAddress);
-          Assert.assertNotSame(-1, returnCode);
-          _logger.info(" Starting reply server[{}] for test...", serverAddress);
-
-          //for (int i=0;i<numRequests;i++) {
-          while (!Thread.currentThread().isInterrupted()) {
-            byte[] bytes = socket.recv();
-            _logger.debug(" Got request ");
-            socket.send(bytes);
-            _logger.debug(" Sent response ");
-          }
-        } catch (Exception x) {
-          StringWriter w = new StringWriter();
-          PrintWriter p = new PrintWriter(w);
-          x.printStackTrace(p);
-          _logger.debug(w.toString());
-        } finally {
-          socket.close();
-          _logger.info("Shutting down reply server");
-        }
-      }
-    };
-  }
-
-  public static Runnable createRouterDealerBridge(final ZMQ.Context context, final String dealerAddress, final int routerPort) {
-    return new Runnable() {
-      @Override
-      public void run() {
-        ZMQ.Socket router = null;
-        ZMQ.Socket dealer = null;
-        try {
-          router = context.socket(ZMQ.ROUTER);
-          dealer = context.socket(ZMQ.DEALER);
-          router.bind("tcp://*:" + routerPort);
-          dealer.bind(dealerAddress);
-          ZMQ.proxy(router, dealer, null);
-        } catch (Exception e) {/*Ignore*/} finally {
-          if (router != null) router.close();
-          if (dealer != null) dealer.close();
-        }
-      }
-    };
-  }
-
-  public static Runnable sendAMessage(final ZMQ.Context context, final String serverAddress, final Message msg)
-      throws IOException, ClassNotFoundException, InterruptedException {
-
-    return new Runnable() {
-      @Override
-      public void run() {
-        final ZMQ.Socket socket = context.socket(ZMQ.REQ);
-        try {
-
-          socket.connect(serverAddress);
-          System.out.println(Thread.currentThread().getName() + " Sending message");
-          try {
-            socket.send(Message.serialize(msg));
-          } catch (IOException e) {
-            e.printStackTrace();
-          }
-          byte[] bytes = socket.recv();
-          Message response = null;
-          try {
-            response = (Message) Message.deserialize(bytes);
-          } catch (IOException e) {
-            e.printStackTrace();
-          } catch (ClassNotFoundException e) {
-            e.printStackTrace();
-          }
-          System.out.println(Thread.currentThread().getName() + " Got response " + response);
-        } catch (Exception x) {
-          x.printStackTrace();
-        } finally {
-          socket.close();
-        }
-      }
-    };
-  }
-
-  public static Runnable sendAnEmptyMessage(final ZMQ.Context context, final String serverAddress)
-          throws IOException, ClassNotFoundException, InterruptedException {
-
-    return new Runnable() {
-      @Override
-      public void run() {
-        final ZMQ.Socket socket = context.socket(ZMQ.REQ);
-        try {
-
-          socket.connect(serverAddress);
-          System.out.println(Thread.currentThread().getName() + " Sending message");
-          try {
-            socket.send(Message.serialize(new Message()));
-          } catch (IOException e) {
-            e.printStackTrace();
-          }
-          byte[] bytes = socket.recv();
-          Message response = null;
-          try {
-            response = (Message) Message.deserialize(bytes);
-          } catch (IOException e) {
-            e.printStackTrace();
-          } catch (ClassNotFoundException e) {
-            e.printStackTrace();
-          }
-          System.out.println(Thread.currentThread().getName() + " Got response " + response);
-        } catch (Exception x) {
-          x.printStackTrace();
-        } finally {
-          socket.close();
-        }
-      }
-    };
-  }
-
-  public static Message createEmptyMessage() {
-    return new Message();
-  }
-
-  /**
-   * Closes ZMQ Context. It tries to gracefully terminate the context. If
-   * termination takes more than a second, its forcefully shutdown.
-   */
-  public static void closeZmqContext(final ZMQ.Context context) {
-    if (context == null) return;
-
-    ExecutorService exec = Executors.newSingleThreadExecutor();
-    FutureTask<?> zmqTermination = new FutureTask<Void>(new Runnable() {
-
-      @Override
-      public void run() {
-        try {
-          if (context != null)
-            context.term();
-            _logger.debug("ZMQ Context terminated gracefully!");
-        } catch (Exception e) {/*Ignore and continue shutdown*/}
-      }
-    }, null);
-
-    exec.execute(zmqTermination);
-
-    try {
-      zmqTermination.get(1L, TimeUnit.SECONDS);
-    } catch (Exception e) {
-      _logger.debug("ZMQ Context terminated forcefully!");
-    }
-
-    exec.shutdownNow();
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/RemoteServerTestClient.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/RemoteServerTestClient.java
deleted file mode 100644 (file)
index 7a4f4a5..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.opendaylight.controller.sal.connector.remoterpc.utils;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.connector.remoterpc.util.XmlUtils;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.zeromq.ZMQ;
-
-public class RemoteServerTestClient {
-
-
-
-  public static void main(String args[]) throws Exception{
-    String serverAddress = "tcp://10.195.128.108:5666";
-    ZMQ.Context ctx = ZMQ.context(1);
-    ExecutorService executor = Executors.newSingleThreadExecutor();
-    RemoteServerTestClient client = new RemoteServerTestClient();
-    executor.execute(
-        MessagingUtil.sendAMessage(ctx, serverAddress, client.createPingMessage(serverAddress))
-    );
-    MessagingUtil.sendAMessage(ctx, serverAddress, client.createPingMessage(serverAddress));
-
-    Thread.sleep(5000);
-    MessagingUtil.closeZmqContext(ctx);
-    executor.shutdown();
-  }
-
-  public Message createPingMessage(String serverAddress){
-    Message ping = new Message.MessageBuilder()
-        .type(Message.MessageType.PING)
-        .sender("localhost:5444")
-        .recipient(serverAddress)
-        .build();
-
-    return ping;
-  }
-  public Message createAddFlowMessage(String serverAddress ){
-
-    RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier = getAddFlowRpcIdentifier();
-
-    Message addFlow = new Message.MessageBuilder()
-        .type(Message.MessageType.REQUEST)
-        .sender("localhost:5444")
-        .recipient(serverAddress)
-        .route(routeIdentifier)
-        .payload(getAddFlowPayload(1,1))
-        .build();
-
-    return addFlow;
-  }
-
-  private RpcRouter.RouteIdentifier<?, ?, ?> getAddFlowRpcIdentifier(){
-    throw new UnsupportedOperationException();
-  }
-
-  private CompositeNode getAddFlowPayload(int flowId, int tableId){
-    final String xml =
-    "<flow xmlns=\"urn:opendaylight:flow:inventory\">"
-    + "<priority>5</priority>"
-    + "<flow-name>Foo</flow-name>"
-    + "<match>"
-    + "<ethernet-match>"
-    + "<ethernet-type>"
-    + "<type>2048</type>"
-    + "</ethernet-type>"
-    + "</ethernet-match>"
-    + "<ipv4-destination>10.0.10.2/24</ipv4-destination>"
-    + "</match>"
-    + "<id>" + flowId + "</id>"
-    + "<table_id>" + tableId + "</table_id>"
-    + "<instructions>"
-    + "<instruction>"
-    + "<order>0</order>"
-    + "<apply-actions>"
-    + "<action>"
-    + "<order>0</order>"
-    + "<dec-nw-ttl/>"
-    + "</action>"
-    + "</apply-actions>"
-    + "</instruction>"
-    + "</instructions>"
-    + "</flow>";
-
-    return XmlUtils.xmlToCompositeNode(xml);
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/AddFlow.xml b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/AddFlow.xml
deleted file mode 100644 (file)
index b042b8f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<add-flow xmlns="urn:opendaylight:flow:service">
-  <input>
-    <transaction-uri>BA-7</transaction-uri>
-    <table_id>4</table_id>
-    <priority>5</priority>
-    <node>
-      /(urn:opendaylight:inventory?revision=2013-08-19)nodes/(urn:opendaylight:inventory?revision=2013-08-19)node[{(urn:opendaylight:inventory?revision=2013-08-19)id=openflow:1}]
-    </node>
-    <match>
-      <ipv4-destination>10.0.10.2/24</ipv4-destination>
-      <ethernet-match>
-        <ethernet-type>
-          <type>2048</type>
-        </ethernet-type>
-      </ethernet-match>
-    </match>
-    <instructions>
-      <instruction>
-        <order>0</order>
-        <apply-actions>
-          <action>
-            <order>0</order>
-            <dec-nw-ttl/>
-          </action>
-        </apply-actions>
-      </instruction>
-    </instructions>
-    <flow-table>
-      /(urn:opendaylight:inventory?revision=2013-08-19)nodes/(urn:opendaylight:inventory?revision=2013-08-19)node[{(urn:opendaylight:inventory?revision=2013-08-19)id=openflow:1}]/(urn:opendaylight:flow:inventory?revision=2013-08-19)table[{(urn:opendaylight:flow:inventory?revision=2013-08-19)id=4}]
-    </flow-table>
-    <flow-ref>
-      /(urn:opendaylight:inventory?revision=2013-08-19)nodes/(urn:opendaylight:inventory?revision=2013-08-19)node[{(urn:opendaylight:inventory?revision=2013-08-19)id=openflow:1}]/(urn:opendaylight:flow:inventory?revision=2013-08-19)table[{(urn:opendaylight:flow:inventory?revision=2013-08-19)id=4}]/(urn:opendaylight:flow:inventory?revision=2013-08-19)flow[{(urn:opendaylight:flow:inventory?revision=2013-08-19)id=4}]
-    </flow-ref>
-    <flow-name>Foo</flow-name>
-  </input>
-</add-flow>
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/FourSimpleChildren.xml b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/FourSimpleChildren.xml
deleted file mode 100644 (file)
index 5ac991b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<rpc>
-    <name>eth0</name>
-    <type>ethernetCsmacd</type>
-    <enabled>false</enabled>
-    <description>some interface</description>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/logback-test.xml b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/resources/logback-test.xml
deleted file mode 100644 (file)
index 7eb75b9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<configuration scan="true">
-
-  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-    <encoder>
-      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-      </pattern>
-    </encoder>
-  </appender>
-
-  <root level="DEBUG">
-    <appender-ref ref="STDOUT" />
-  </root>
-</configuration>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/pom.xml
deleted file mode 100644 (file)
index 8435884..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?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.tests</groupId>
-    <artifactId>sal-remoterpc-connector-test-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
-  </parent>
-  <artifactId>sal-remoterpc-connector-test-consumer</artifactId>
-  <packaging>bundle</packaging>
-
-  <dependencies>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-binding-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-core-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-binding</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-common</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-data-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-data-impl</artifactId>
-      <version>${yangtools.version}</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <configuration>
-          <instructions>
-            <Bundle-Activator>org.opendaylight.controller.sample.zeromq.consumer.ExampleConsumer</Bundle-Activator>
-          </instructions>
-        </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>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
-  </scm>
-</project>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/java/org/opendaylight/controller/sample/zeromq/consumer/ExampleConsumer.java b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/java/org/opendaylight/controller/sample/zeromq/consumer/ExampleConsumer.java
deleted file mode 100644 (file)
index aac6da4..0000000
+++ /dev/null
@@ -1,128 +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.sample.zeromq.consumer;
-
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Hashtable;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.sal.core.api.AbstractConsumer;
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.opendaylight.yangtools.yang.data.impl.XmlTreeBuilder;
-
-import javax.xml.stream.XMLStreamException;
-
-public class ExampleConsumer extends AbstractConsumer {
-
-  private final URI namespace = URI.create("http://cisco.com/example");
-  private final QName QNAME = new QName(namespace, "heartbeat");
-
-  private ConsumerSession session;
-
-  private ServiceRegistration<ExampleConsumer> thisReg;
-  private Logger _logger = LoggerFactory.getLogger(ExampleConsumer.class);
-
-  @Override
-  public void onSessionInitiated(ConsumerSession session) {
-    this.session = session;
-  }
-
-  public RpcResult<CompositeNode> invokeRpc(QName qname, CompositeNode input) {
-    _logger.info("Invoking RPC:[{}] with Input:[{}]", qname.getLocalName(), input);
-    RpcResult<CompositeNode> result = null;
-    Future<RpcResult<CompositeNode>> future = ExampleConsumer.this.session.rpc(qname, input);
-    try {
-      result = future.get();
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    _logger.info("Returning Result:[{}]", result);
-    return result;
-  }
-
-  @Override
-  protected void startImpl(BundleContext context){
-    thisReg = context.registerService(ExampleConsumer.class, this, new Hashtable<String,String>());
-  }
-  @Override
-  protected void stopImpl(BundleContext context) {
-    super.stopImpl(context);
-    thisReg.unregister();
-  }
-
-  public CompositeNode getValidCompositeNodeWithOneSimpleChild() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/OneSimpleChild.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  public CompositeNode getValidCompositeNodeWithTwoSimpleChildren() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/TwoSimpleChildren.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  public CompositeNode getValidCompositeNodeWithFourSimpleChildren() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/FourSimpleChildren.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  public CompositeNode getValidCompositeNodeWithOneSimpleOneCompositeChild() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/OneSimpleOneCompositeChild.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  public CompositeNode getValidCompositeNodeWithTwoCompositeChildren() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/TwoCompositeChildren.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  public CompositeNode getInvalidCompositeNodeSimpleChild() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/InvalidSimpleChild.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  public CompositeNode getInvalidCompositeNodeCompositeChild() throws FileNotFoundException {
-    InputStream xmlStream = ExampleConsumer.class.getResourceAsStream("/InvalidCompositeChild.xml");
-    return loadCompositeNode(xmlStream);
-  }
-
-  //Note to self:  Stolen from TestUtils
-  ///Users/alefan/odl/controller4/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java
-  // Figure out how to include TestUtils through pom ...was getting errors
-  private CompositeNode loadCompositeNode(InputStream xmlInputStream) throws FileNotFoundException {
-    if (xmlInputStream == null) {
-      throw new IllegalArgumentException();
-    }
-    Node<?> dataTree;
-    try {
-      dataTree = XmlTreeBuilder.buildDataTree(xmlInputStream);
-    } catch (XMLStreamException e) {
-      _logger.error("Error during building data tree from XML", e);
-      return null;
-    }
-    if (dataTree == null) {
-      _logger.error("data tree is null");
-      return null;
-    }
-    if (dataTree instanceof SimpleNode) {
-      _logger.error("RPC XML was resolved as SimpleNode");
-      return null;
-    }
-    return (CompositeNode) dataTree;
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/FourSimpleChildren.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/FourSimpleChildren.xml
deleted file mode 100644 (file)
index 5ac991b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<rpc>
-    <name>eth0</name>
-    <type>ethernetCsmacd</type>
-    <enabled>false</enabled>
-    <description>some interface</description>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/InvalidCompositeChild.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/InvalidCompositeChild.xml
deleted file mode 100644 (file)
index 3979d02..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<rpc>
-    <innerinterface1>
-        <name>eth1</name>
-        <type>ethernet</type>
-        <enabled>false</enabled>
-        <description>some interface</description>
-    </innerinterface1>
-    <innerinterface2>
-        <name>error</name>
-        <type>ethernet</type>
-        <enabled>true</enabled>
-        <description>some interface</description>
-    </innerinterface2>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/InvalidSimpleChild.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/InvalidSimpleChild.xml
deleted file mode 100644 (file)
index 6082d72..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<rpc>
-    <name>error</name>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/OneSimpleChild.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/OneSimpleChild.xml
deleted file mode 100644 (file)
index f431b04..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<rpc>
-    <name>eth0</name>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/OneSimpleOneCompositeChild.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/OneSimpleOneCompositeChild.xml
deleted file mode 100644 (file)
index bca7682..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<rpc>
-    <name>eth0</name>
-    <innerinterface>
-        <name>eth1</name>
-        <type>ethernetCsmacd</type>
-        <enabled>false</enabled>
-        <description>some interface</description>
-    </innerinterface>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/TwoCompositeChildren.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/TwoCompositeChildren.xml
deleted file mode 100644 (file)
index c49407e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<rpc>
-    <innerinterface1>
-        <name>eth1</name>
-        <type>ethernet</type>
-        <enabled>false</enabled>
-        <description>some interface</description>
-    </innerinterface1>
-    <innerinterface2>
-        <name>eth2</name>
-        <type>ethernet</type>
-        <enabled>true</enabled>
-        <description>some interface</description>
-    </innerinterface2>
-</rpc>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/TwoSimpleChildren.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/consumer-service/src/main/resources/TwoSimpleChildren.xml
deleted file mode 100644 (file)
index 5f4729c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<rpc>
-    <name>eth0</name>
-    <type>ethernetCsmacd</type>
-</rpc>
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/pom.xml
deleted file mode 100644 (file)
index 3f47700..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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>sal-parent</artifactId>
-    <version>1.1-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-  <groupId>org.opendaylight.controller.tests</groupId>
-  <artifactId>sal-remoterpc-connector-test-parent</artifactId>
-  <packaging>pom</packaging>
-
-  <modules>
-    <module>consumer-service</module>
-    <module>provider-service</module>
-    <module>test-it</module>
-    <module>test-nb</module>
-  </modules>
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
-  </scm>
-
-</project>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/pom.xml
deleted file mode 100644 (file)
index 2b9dc0c..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<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>
-        <artifactId>sal-remoterpc-connector-test-parent</artifactId>
-        <groupId>org.opendaylight.controller.tests</groupId>
-        <version>1.1-SNAPSHOT</version>
-  </parent>
-  <artifactId>sal-remoterpc-connector-test-provider</artifactId>
-  <packaging>bundle</packaging>
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
-  </scm>
-
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <configuration>
-          <instructions>
-            <Bundle-Activator>org.opendaylight.controller.sample.zeromq.provider.ExampleProvider</Bundle-Activator>
-          </instructions>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-binding-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-core-api</artifactId>
-    </dependency>
-
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-binding</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-common</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-data-api</artifactId>
-    </dependency>
-        <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-data-impl</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-remoterpc-connector</artifactId>
-    </dependency>
-
-  </dependencies>
-</project>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java
deleted file mode 100644 (file)
index ff930db..0000000
+++ /dev/null
@@ -1,130 +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.sample.zeromq.provider;
-
-import org.opendaylight.controller.sal.common.util.RpcErrors;
-import org.opendaylight.controller.sal.common.util.Rpcs;
-import org.opendaylight.controller.sal.core.api.AbstractProvider;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
-import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class ExampleProvider extends AbstractProvider implements RpcImplementation {
-
-  private final URI namespace = URI.create("http://cisco.com/example");
-  private final QName QNAME = new QName(namespace, "heartbeat");
-  private RpcRegistration reg;
-
-  private ServiceRegistration thisReg;
-
-  private ProviderSession session;
-  private Logger _logger = LoggerFactory.getLogger(ExampleProvider.class);
-
-  @Override
-  public void onSessionInitiated(ProviderSession session) {
-    this.session = session;
-  }
-
-  @Override
-  public Set<QName> getSupportedRpcs() {
-    Set<QName> supportedRpcs = new HashSet<QName>();
-    supportedRpcs.add(QNAME);
-    return supportedRpcs;
-  }
-
-  @Override
-  public RpcResult<CompositeNode> invokeRpc(final QName rpc, CompositeNode input) {
-    boolean success = false;
-    CompositeNode output = null;
-    Collection<RpcError> errors = new ArrayList<>();
-
-    // Only handle supported RPC calls
-    if (getSupportedRpcs().contains(rpc))  {
-      if (input == null) {
-        errors.add(RpcErrors.getRpcError("app", "tag", "info", RpcError.ErrorSeverity.WARNING, "message:null input", RpcError.ErrorType.RPC, null));
-      }
-      else {
-        if (isErroneousInput(input)) {
-          errors.add(RpcErrors.getRpcError("app", "tag", "info", RpcError.ErrorSeverity.ERROR, "message:error", RpcError.ErrorType.RPC, null));
-        }
-        else {
-          success = true;
-          output = addSuccessNode(input);
-        }
-      }
-    }
-    return Rpcs.getRpcResult(success, output, errors);
-  }
-
-  // Examines input -- dives into CompositeNodes and finds any value equal to "error"
-  private boolean isErroneousInput(CompositeNode input) {
-    for (Node<?> n : input.getChildren()) {
-      if (n instanceof CompositeNode) {
-        if (isErroneousInput((CompositeNode)n)) {
-          return true;
-        }
-      }
-      else {  //SimpleNode
-        if ((input.getChildren().get(0).getValue()).equals("error")) {
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-
-  // Adds a child SimpleNode containing the value "success" to the input CompositeNode
-  private CompositeNode addSuccessNode(CompositeNode input) {
-    List<Node<?>> list = new ArrayList<Node<?>>(input.getChildren());
-    SimpleNodeTOImpl<String> simpleNode = new SimpleNodeTOImpl<String>(QNAME, input, "success");
-    list.add(simpleNode);
-    return new CompositeNodeTOImpl(QNAME, null, list);
-  }
-
-  @Override
-  protected void startImpl(BundleContext context) {
-    thisReg = context.registerService(ExampleProvider.class, this, new Hashtable<String, String>());
-  }
-
-  @Override
-  protected void stopImpl(BundleContext context) {
-    if (reg != null) {
-      try {
-        reg.close();
-        thisReg.unregister();
-      } catch (Exception e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
-      }
-    }
-  }
-
-  public void announce(QName name) {
-    _logger.debug("Announcing [{}]\n\n\n", name);
-    reg = this.session.addRpcImplementation(name, this);
-  }
-
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml
deleted file mode 100644 (file)
index 0ffc330..0000000
+++ /dev/null
@@ -1,467 +0,0 @@
-<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>
-        <artifactId>sal-remoterpc-connector-test-parent</artifactId>
-        <groupId>org.opendaylight.controller.tests</groupId>
-        <version>1.1-SNAPSHOT</version>
-    </parent>
-    <artifactId>sal-remoterpc-connector-test-it</artifactId>
-    <scm>
-        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
-    </scm>
-
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.ops4j.pax.exam</groupId>
-                <artifactId>maven-paxexam-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>generate-config</id>
-                        <goals>
-                            <goal>generate-depends-file</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-        <pluginManagement>
-            <plugins>
-                <!--This plugin's configuration is used to store Eclipse
-                    m2e settings only. It has no influence on the Maven build itself. -->
-                <plugin>
-                    <groupId>org.eclipse.m2e</groupId>
-                    <artifactId>lifecycle-mapping</artifactId>
-                    <version>${lifecycle.mapping.version}</version>
-                    <configuration>
-                        <lifecycleMappingMetadata>
-                            <pluginExecutions>
-                                <pluginExecution>
-                                    <pluginExecutionFilter>
-                                        <groupId>
-                                            org.ops4j.pax.exam
-                                        </groupId>
-                                        <artifactId>
-                                            maven-paxexam-plugin
-                                        </artifactId>
-                                        <versionRange>
-                                            [1.2.4,)
-                                        </versionRange>
-                                        <goals>
-                                            <goal>
-                                                generate-depends-file
-                                            </goal>
-                                        </goals>
-                                    </pluginExecutionFilter>
-                                    <action>
-                                        <ignore></ignore>
-                                    </action>
-                                </pluginExecution>
-                            </pluginExecutions>
-                        </lifecycleMappingMetadata>
-                    </configuration>
-                </plugin>
-            </plugins>
-        </pluginManagement>
-    </build>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-            <artifactId>xtend-lib-osgi</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.tests</groupId>
-            <artifactId>sal-remoterpc-connector-test-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.tests</groupId>
-            <artifactId>sal-remoterpc-connector-test-consumer</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-broker-impl</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-native</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit4</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-link-mvn</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-aether</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>equinoxSDK381</groupId>
-            <artifactId>org.eclipse.osgi</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>log4j-over-slf4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-binding-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-common-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-core-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-remoterpc-connector</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>containermanager</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.osgi</groupId>
-                    <artifactId>org.osgi.compendium</artifactId>
-                </exclusion>
-                <exclusion>
-                    <artifactId>commons-io</artifactId>
-                    <groupId>commons-io</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-binding</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-data-api</artifactId>
-        </dependency>
-        <!--dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-data-impl</artifactId>
-            <version>${yangtools.version}</version> </dependency -->
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-parser-impl</artifactId>
-            <version>${yangtools.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-common-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-            <artifactId>antlr4-runtime-osgi-nohead</artifactId>
-        </dependency>
-
-        <!-- routing table dependencies -->
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>zeromq-routingtable.implementation</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>clustering.services</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.osgi</groupId>
-                    <artifactId>org.osgi.compendium</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal.implementation</artifactId>
-            <exclusions>
-                <exclusion>
-                    <artifactId>commons-io</artifactId>
-                    <groupId>commons-io</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>containermanager</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.osgi</groupId>
-                    <artifactId>org.osgi.compendium</artifactId>
-                </exclusion>
-                <exclusion>
-                    <artifactId>commons-io</artifactId>
-                    <groupId>commons-io</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>containermanager.it.implementation</artifactId>
-            <exclusions>
-                <exclusion>
-                    <artifactId>commons-io</artifactId>
-                    <groupId>commons-io</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>clustering.stub</artifactId>
-            <exclusions>
-                <exclusion>
-                    <artifactId>commons-io</artifactId>
-                    <groupId>commons-io</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.dependencymanager.shell</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.osgi</groupId>
-                    <artifactId>org.osgi.compendium</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>eclipselink</groupId>
-            <artifactId>javax.resource</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal</artifactId>
-        </dependency>
-        <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>ietf-netconf-monitoring</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-binding</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools.model</groupId>
-            <artifactId>yang-ext</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools.model</groupId>
-            <artifactId>opendaylight-l2-types</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-binding-it</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-binding-config</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-binding-broker-impl</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-broker-impl</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.controller.model</groupId>
-            <artifactId>model-inventory</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-connector-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-common-util</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>clustering.services</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>equinoxSDK381</groupId>
-            <artifactId>org.eclipse.osgi</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-            <version>${jackson.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-annotations</artifactId>
-            <version>${jackson.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-core</artifactId>
-            <version>${jackson.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.zeromq</groupId>
-            <artifactId>jeromq</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-            <artifactId>xtend-lib-osgi</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-binding-broker-impl</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-native</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit4</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-netconf-connector</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>logback-config</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-impl</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-file-xml-adapter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>netconf-impl</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>netconf-client</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam</artifactId>
-            <version>${exam.version}</version>
-            <!-- Compile scope here is intentional, it is used in TestHelper
-                class which could be downloaded via nexus and reused in other integration
-                tests. -->
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-link-mvn</artifactId>
-            <version>${exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>equinoxSDK381</groupId>
-            <artifactId>org.eclipse.osgi</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>log4j-over-slf4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.model</groupId>
-            <artifactId>model-flow-service</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-manager</artifactId>
-            <exclusions>
-                <exclusion>
-                    <artifactId>commons-io</artifactId>
-                    <groupId>commons-io</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller.model</groupId>
-            <artifactId>model-flow-management</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-            <artifactId>antlr4-runtime-osgi-nohead</artifactId>
-        </dependency>
-    </dependencies>
-</project>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java
deleted file mode 100644 (file)
index e02e290..0000000
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.sample.zeromq.test.it;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.opendaylight.controller.sal.connector.remoterpc.RemoteRpcClient;
-
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sample.zeromq.consumer.ExampleConsumer;
-import org.opendaylight.controller.sample.zeromq.provider.ExampleProvider;
-
-import org.opendaylight.controller.test.sal.binding.it.TestHelper;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.util.Filter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
-import javax.inject.Inject;
-
-import java.io.IOException;
-import java.net.URI;
-
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles;
-
-//import static org.ops4j.pax.exam.CoreOptions.*;
-
-@RunWith(PaxExam.class)
-public class RouterTest {
-
-  private Logger _logger = LoggerFactory.getLogger(RouterTest.class);
-
-  public static final String ODL = "org.opendaylight.controller";
-  public static final String YANG = "org.opendaylight.yangtools";
-  public static final String SAMPLE = "org.opendaylight.controller.tests";
-  private final URI namespace = URI.create("http://cisco.com/example");
-  private final QName QNAME = new QName(namespace, "heartbeat");
-
-
-  @Inject
-  org.osgi.framework.BundleContext ctx;
-
-  @Inject
-  @Filter(timeout=60*1000)
-  Broker broker;
-
-  private ZMQ.Context zmqCtx = ZMQ.context(1);
-  //private Server router;
-  //private ExampleProvider provider;
-
-  //@Test
-  public void testInvokeRpc() throws Exception{
-    //Thread.sleep(1000);
-    //Send announcement
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-
-    _logger.debug("Provider sends announcement [{}]", "heartbeat");
-    provider.announce(QNAME);
-    ServiceReference routerRef = ctx.getServiceReference(RemoteRpcClient.class);
-    RemoteRpcClient router = (RemoteRpcClient) ctx.getService(routerRef);
-    _logger.debug("Found router[{}]", router);
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = router.invokeRpc(QNAME, consumer.getValidCompositeNodeWithOneSimpleChild());
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertNotNull(result);
-    }
-  }
-
-  @Test
-  public void testInvokeRpcWithValidSimpleNode() throws Exception{
-    //Thread.sleep(1500);
-
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-    // Provider sends announcement
-    _logger.debug("Provider sends announcement [{}]", "heartbeat");
-    provider.announce(QNAME);
-    // Consumer invokes RPC
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    CompositeNode input = consumer.getValidCompositeNodeWithOneSimpleChild();
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, input);
-      Assert.assertNotNull(result);
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertTrue(result.isSuccessful());
-      Assert.assertNotNull(result.getResult());
-      Assert.assertEquals(0, result.getErrors().size());
-      Assert.assertEquals(input.getChildren().size()+1, result.getResult().getChildren().size());
-    }
-  }
-
-  @Test
-  public void testInvokeRpcWithValidSimpleNodes() throws Exception{
-    //Thread.sleep(1500);
-
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-    // Provider sends announcement
-    _logger.debug("Provider sends announcement [{}]", "heartbeat");
-    provider.announce(QNAME);
-    // Consumer invokes RPC
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    CompositeNode input = consumer.getValidCompositeNodeWithFourSimpleChildren();
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, input);
-      Assert.assertNotNull(result);
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertTrue(result.isSuccessful());
-      Assert.assertNotNull(result.getResult());
-      Assert.assertEquals(0, result.getErrors().size());
-      Assert.assertEquals(input.getChildren().size()+1, result.getResult().getChildren().size());
-    }
-  }
-
-  @Test
-  public void testInvokeRpcWithValidCompositeNode() throws Exception{
-    //Thread.sleep(1500);
-
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-    // Provider sends announcement
-    _logger.debug("Provider sends announcement [{}]", "heartbeat");
-    provider.announce(QNAME);
-    // Consumer invokes RPC
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    CompositeNode input = consumer.getValidCompositeNodeWithTwoCompositeChildren();
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, input);
-      Assert.assertNotNull(result);
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertTrue(result.isSuccessful());
-      Assert.assertNotNull(result.getResult());
-      Assert.assertEquals(0, result.getErrors().size());
-      Assert.assertEquals(input.getChildren().size()+1, result.getResult().getChildren().size());
-    }
-  }
-
-  @Test
-  public void testInvokeRpcWithNullInput() throws Exception{
-    //Thread.sleep(1500);
-
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-    // Provider sends announcement
-    _logger.debug("Provider sends announcement [{}]", QNAME.getLocalName());
-    provider.announce(QNAME);
-    // Consumer invokes RPC
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, null);
-      Assert.assertNotNull(result);
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertFalse(result.isSuccessful());
-      Assert.assertNull(result.getResult());
-      Assert.assertEquals(1, result.getErrors().size());
-      Assert.assertEquals(RpcError.ErrorSeverity.WARNING, ((RpcError)result.getErrors().toArray()[0]).getSeverity());
-    }
-  }
-
-  @Test
-  public void testInvokeRpcWithInvalidSimpleNode() throws Exception{
-    //Thread.sleep(1500);
-
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-    // Provider sends announcement
-    _logger.debug("Provider sends announcement [{}]", QNAME.getLocalName());
-    provider.announce(QNAME);
-    // Consumer invokes RPC
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    CompositeNode input = consumer.getInvalidCompositeNodeSimpleChild();
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, input);
-      Assert.assertNotNull(result);
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertFalse(result.isSuccessful());
-      Assert.assertNull(result.getResult());
-      Assert.assertEquals(1, result.getErrors().size());
-      Assert.assertEquals(RpcError.ErrorSeverity.ERROR, ((RpcError)result.getErrors().toArray()[0]).getSeverity());
-    }
-  }
-
-  @Test
-  public void testInvokeRpcWithInvalidCompositeNode() throws Exception{
-    //Thread.sleep(1500);
-
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    Assert.assertNotNull(providerRef);
-    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-    Assert.assertNotNull(provider);
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    Assert.assertNotNull(consumerRef);
-    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-    Assert.assertNotNull(consumer);
-
-    // Provider sends announcement
-    _logger.debug("Provider sends announcement [{}]", QNAME.getLocalName());
-    provider.announce(QNAME);
-    // Consumer invokes RPC
-    _logger.debug("Invoking RPC [{}]", QNAME);
-    CompositeNode input = consumer.getInvalidCompositeNodeCompositeChild();
-    for (int i = 0; i < 3; i++) {
-      RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, input);
-      Assert.assertNotNull(result);
-      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-      Assert.assertFalse(result.isSuccessful());
-      Assert.assertNull(result.getResult());
-      Assert.assertEquals(1, result.getErrors().size());
-      Assert.assertEquals(RpcError.ErrorSeverity.ERROR, ((RpcError)result.getErrors().toArray()[0]).getSeverity());
-    }
-  }
-
-  //@Test
-  // This method is UNTESTED -- need to get around the bundling issues before I know if this even work
-//  public void testInvokeRpcWithValidCompositeNode() throws Exception{
-//    Thread.sleep(10000);
-//    //Send announcement
-//    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-//    Assert.assertNotNull(providerRef);
-//
-//    ExampleProvider provider = (ExampleProvider)ctx.getService(providerRef);
-//    Assert.assertNotNull(provider);
-//
-//    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-//    Assert.assertNotNull(consumerRef);
-//
-//    ExampleConsumer consumer = (ExampleConsumer)ctx.getService(consumerRef);
-//    Assert.assertNotNull(consumer);
-//
-//    _logger.debug("Provider sends announcement [{}]", "heartbeat");
-//    provider.announce(QNAME);
-//    ServiceReference routerRef = ctx.getServiceReference(Client.class);
-//    Client router = (Client) ctx.getService(routerRef);
-//    _logger.debug("Found router[{}]", router);
-//    _logger.debug("Invoking RPC [{}]", QNAME);
-//    for (int i = 0; i < 3; i++) {
-//      RpcResult<CompositeNode> result = router.getInstance().invokeRpc(QNAME, consumer.getValidCompositeNodeWithOneSimpleChild());
-//      _logger.debug("{}-> Result is: Successful:[{}], Payload:[{}], Errors: [{}]", i, result.isSuccessful(), result.getResult(), result.getErrors());
-//      Assert.assertNotNull(result);
-//    }
-//  }
-
-  private Message send(Message msg) throws IOException {
-    ZMQ.Socket reqSocket = zmqCtx.socket(ZMQ.REQ);
-    reqSocket.connect("tcp://localhost:5555");
-    reqSocket.send(Message.serialize(msg));
-    Message response = parseMessage(reqSocket);
-
-    return response;
-  }
-
-  /**
-   * @param socket
-   * @return
-   */
-  private Message parseMessage(ZMQ.Socket socket) {
-
-    Message msg = null;
-    try {
-      byte[] bytes = socket.recv();
-      _logger.debug("Received bytes:[{}]", bytes.length);
-      msg = (Message) Message.deserialize(bytes);
-    } catch (Throwable t) {
-      t.printStackTrace();
-    }
-    return msg;
-  }
-
-
-  private void printState(){
-    Bundle[] b = ctx.getBundles();
-    _logger.debug("\n\nNumber of bundles [{}]\n\n]", b.length);
-    for (int i=0;i<b.length;i++){
-      _logger.debug("Bundle States {}-{} ",b[i].getSymbolicName(), stateToString(b[i].getState()));
-
-      if ( Bundle.INSTALLED == b[i].getState() || (Bundle.RESOLVED == b[i].getState())){
-        try {
-          b[i].start();
-        } catch (BundleException e) {
-          e.printStackTrace();
-        }
-      }
-    }
-  }
-
-  private String stateToString(int state) {
-    switch (state) {
-      case Bundle.ACTIVE:
-        return "ACTIVE";
-      case Bundle.INSTALLED:
-        return "INSTALLED";
-      case Bundle.RESOLVED:
-        return "RESOLVED";
-      case Bundle.UNINSTALLED:
-        return "UNINSTALLED";
-      default:
-        return "Not CONVERTED";
-    }
-  }
-
-  @Configuration
-  public Option[] config() {
-    return options(systemProperty("osgi.console").value("2401"),
-            systemProperty("rpc.port").value("5555"),
-            mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), //
-            mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), //
-            mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), //
-            mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), //
-
-            //mavenBundle(ODL, "sal-binding-broker-impl").versionAsInProject().update(), //
-            mavenBundle(ODL, "sal-common").versionAsInProject(), //
-            mavenBundle(ODL, "sal-common-api").versionAsInProject(),//
-            mavenBundle(ODL, "sal-common-impl").versionAsInProject(), //
-            mavenBundle(ODL, "sal-common-util").versionAsInProject(), //
-            mavenBundle(ODL, "sal-core-api").versionAsInProject().update(), //
-            mavenBundle(ODL, "sal-broker-impl").versionAsInProject(), //
-            mavenBundle(ODL, "sal-core-spi").versionAsInProject().update(), //
-            mavenBundle(ODL, "sal-connector-api").versionAsInProject(), //
-
-
-            baseModelBundles(),
-            bindingAwareSalBundles(),
-            TestHelper.bindingIndependentSalBundles(),
-            TestHelper.configMinumumBundles(),
-            TestHelper.mdSalCoreBundles(),
-
-            //Added the consumer
-            mavenBundle(SAMPLE, "sal-remoterpc-connector-test-consumer").versionAsInProject(), //
-            //**** These two bundles below are NOT successfully resolved -- some of their dependencies must be missing
-            //**** This causes the "Message" error to occur, the class cannot be found
-            mavenBundle(SAMPLE, "sal-remoterpc-connector-test-provider").versionAsInProject(), //
-            mavenBundle(ODL, "sal-remoterpc-connector").versionAsInProject(), //
-
-            mavenBundle(ODL, "zeromq-routingtable.implementation").versionAsInProject(),
-            mavenBundle(YANG, "concepts").versionAsInProject(),
-            mavenBundle(YANG, "yang-binding").versionAsInProject(), //
-            mavenBundle(YANG, "yang-common").versionAsInProject(), //
-            mavenBundle(YANG, "yang-data-api").versionAsInProject(), //
-            mavenBundle(YANG, "yang-data-impl").versionAsInProject(), //
-            mavenBundle(YANG, "yang-model-api").versionAsInProject(), //
-            mavenBundle(YANG, "yang-parser-api").versionAsInProject(), //
-            mavenBundle(YANG, "yang-parser-impl").versionAsInProject(), //
-            mavenBundle(YANG, "yang-model-util").versionAsInProject(), //
-            mavenBundle(YANG + ".thirdparty", "xtend-lib-osgi").versionAsInProject(), //
-            mavenBundle(YANG + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), //
-            mavenBundle("com.google.guava", "guava").versionAsInProject(), //
-            mavenBundle("org.zeromq", "jeromq").versionAsInProject(),
-            mavenBundle("org.codehaus.jackson", "jackson-mapper-asl").versionAsInProject(),
-            mavenBundle("org.codehaus.jackson", "jackson-core-asl").versionAsInProject(),
-            //routingtable dependencies
-            systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
-            // List framework bundles
-            mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
-            mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
-            mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
-            mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
-            mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
-            mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
-            mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
-            // List logger bundles
-
-            mavenBundle("org.opendaylight.controller", "clustering.services")
-                    .versionAsInProject(),
-            mavenBundle("org.opendaylight.controller", "clustering.stub")
-                    .versionAsInProject(),
-
-
-            // List all the bundles on which the test case depends
-            mavenBundle("org.opendaylight.controller", "sal")
-                    .versionAsInProject(),
-            mavenBundle("org.opendaylight.controller", "sal.implementation")
-                    .versionAsInProject(),
-            mavenBundle("org.jboss.spec.javax.transaction",
-                    "jboss-transaction-api_1.1_spec").versionAsInProject(),
-            mavenBundle("org.apache.commons", "commons-lang3")
-                    .versionAsInProject(),
-            mavenBundle("org.apache.felix",
-                    "org.apache.felix.dependencymanager")
-                    .versionAsInProject(),
-
-            junitBundles()
-    );
-  }
-
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/resources/controller.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/resources/controller.xml
deleted file mode 100644 (file)
index c8e3b83..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<persisted-snapshots>
-    <snapshots>
-        <snapshot>
-            <required-capabilities>
-                <capability>urn:opendaylight:params:xml:ns:yang:controller:config?module=config&amp;revision=2013-04-05
-                </capability>
-                <capability>
-                    urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28
-                </capability>
-                <capability>
-                    urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28
-                </capability>
-                <capability>
-                    urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&amp;revision=2013-10-28
-                </capability>
-                <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&amp;revision=2013-10-28</capability>
-                <capability>
-                    urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc?module=odl-sal-dom-rpc-remote-cfg&amp;revision=2013-10-28
-                </capability>
-            </required-capabilities>
-            <configuration>
-
-                <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-                    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                                prefix:schema-service-singleton
-                            </type>
-                            <name>yang-schema-service</name>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                                prefix:hash-map-data-store
-                            </type>
-                            <name>hash-map-data-store</name>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                                prefix:dom-broker-impl
-                            </type>
-                            <name>dom-broker</name>
-                            <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
-                                    dom:dom-data-store
-                                </type>
-                                <name>ref_hash-map-data-store</name>
-                            </data-store>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                prefix:binding-broker-impl
-                            </type>
-                            <name>binding-broker-impl</name>
-                            <notification-service
-                                    xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                                    binding:binding-notification-service
-                                </type>
-                                <name>ref_binding-notification-broker</name>
-                            </notification-service>
-                            <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                                    binding:binding-data-broker
-                                </type>
-                                <name>ref_binding-data-broker</name>
-                            </data-broker>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                prefix:runtime-generated-mapping
-                            </type>
-                            <name>runtime-mapping-singleton</name>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                prefix:binding-notification-broker
-                            </type>
-                            <name>binding-notification-broker</name>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                prefix:binding-data-broker
-                            </type>
-                            <name>binding-data-broker</name>
-                            <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
-                                    dom:dom-broker-osgi-registry
-                                </type>
-                                <name>ref_dom-broker</name>
-                            </dom-broker>
-                            <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                    binding:binding-dom-mapping-service
-                                </type>
-                                <name>ref_runtime-mapping-singleton</name>
-                            </mapping-service>
-                        </module>
-                        <module>
-                            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
-                                prefix:remote-zeromq-rpc-server
-                            </type>
-                            <name>remoter</name>
-                            <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
-                            <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
-                                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
-                                    prefix:dom-broker-osgi-registry
-                                </type>
-                                <name>ref_dom-broker</name>
-                            </dom-broker>
-                        </module>
-                    </modules>
-
-                    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-                        <service>
-                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
-                                dom:schema-service
-                            </type>
-                            <instance>
-                                <name>ref_yang-schema-service</name>
-                                <provider>
-                                    /config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']
-                                </provider>
-                            </instance>
-                        </service>
-                        <service>
-                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                                binding:binding-notification-service
-                            </type>
-                            <instance>
-                                <name>ref_binding-notification-broker</name>
-                                <provider>
-                                    /config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']
-                                </provider>
-                            </instance>
-                        </service>
-                        <service>
-                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
-                                dom:dom-data-store
-                            </type>
-                            <instance>
-                                <name>ref_hash-map-data-store</name>
-                                <provider>
-                                    /config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']
-                                </provider>
-                            </instance>
-                        </service>
-                        <service>
-                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                                binding:binding-broker-osgi-registry
-                            </type>
-                            <instance>
-                                <name>ref_binding-broker-impl</name>
-                                <provider>
-                                    /config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']
-                                </provider>
-                            </instance>
-                        </service>
-                        <service>
-                            <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                binding-impl:binding-dom-mapping-service
-                            </type>
-                            <instance>
-                                <name>ref_runtime-mapping-singleton</name>
-                                <provider>
-                                    /config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']
-                                </provider>
-                            </instance>
-                        </service>
-                        <service>
-                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
-                                dom:dom-broker-osgi-registry
-                            </type>
-                            <instance>
-                                <name>ref_dom-broker</name>
-                                <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']
-                                </provider>
-                            </instance>
-                        </service>
-                        <service>
-                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                                binding:binding-data-broker
-                            </type>
-                            <instance>
-                                <name>ref_binding-data-broker</name>
-                                <provider>
-                                    /config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']
-                                </provider>
-                            </instance>
-                        </service>
-                    </services>
-                </data>
-
-            </configuration>
-        </snapshot>
-    </snapshots>
-</persisted-snapshots>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/resources/logback.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/resources/logback.xml
deleted file mode 100644 (file)
index 1d17796..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<configuration scan="true">
-
-  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-    <encoder>
-      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-      </pattern>
-    </encoder>
-  </appender>
-
-
-  <logger name="org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort" level="ERROR"/>
-
-  <root level="info">
-    <appender-ref ref="STDOUT" />
-  </root>
-</configuration>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/pom.xml
deleted file mode 100644 (file)
index b681db2..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?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>
-    <artifactId>sal-remoterpc-connector-test-parent</artifactId>
-    <groupId>org.opendaylight.controller.tests</groupId>
-    <version>1.1-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>sal-remoterpc-connector-test-nb</artifactId>
-  <packaging>bundle</packaging>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Export-Package>
-            </Export-Package>
-            <Import-Package>
-              com.sun.jersey.spi.container.servlet,
-              !org.codehaus.jackson.annotate,
-              javax.ws.rs,
-              javax.ws.rs.core,
-              javax.xml.bind,
-              javax.xml.bind.annotation,
-              org.slf4j,
-              org.apache.catalina.filters,
-              !org.codehaus.jackson.jaxrs,
-              org.opendaylight.controller.sample.zeromq.provider,
-              org.opendaylight.controller.sample.zeromq.consumer,
-              org.opendaylight.controller.sal.utils,
-              org.opendaylight.yangtools.yang.common,
-              org.opendaylight.controller.sal.connector.api,
-              org.opendaylight.controller.sal.connector.remoterpc.api;version="[0.4,1)",
-              org.opendaylight.controller.sal.connector.remoterpc.impl;version="[0.4,1)",
-              org.opendaylight.controller.sal.connector.remoterpc.dto,
-              org.opendaylight.controller.sal.connector.remoterpc.util,
-              org.osgi.framework,
-              com.google.common.base,
-              org.opendaylight.yangtools.yang.data.api,
-              !org.codehaus.enunciate.jaxrs
-
-            </Import-Package>
-            <Web-ContextPath>/controller/nb/v2/zmqnb</Web-ContextPath>
-            <Jaxrs-Resources>,${classes;ANNOTATION;javax.ws.rs.Path}</Jaxrs-Resources>
-          </instructions>
-          <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-  <dependencies>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>commons.northbound</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller.tests</groupId>
-      <artifactId>sal-remoterpc-connector-test-provider</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller.tests</groupId>
-      <artifactId>sal-remoterpc-connector-test-consumer</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-remoterpc-connector</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>remoterpc-routingtable.implementation</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>com.google.guava</groupId>
-          <artifactId>guava</artifactId>
-      </dependency>
-  </dependencies>
-
- </project>
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqrouter/rest/Router.java b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/src/main/java/org/opendaylight/controller/tests/zmqrouter/rest/Router.java
deleted file mode 100644 (file)
index e97be52..0000000
+++ /dev/null
@@ -1,273 +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.tests.zmqrouter.rest;
-
-import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-import org.opendaylight.controller.sal.connector.remoterpc.impl.RoutingTableImpl;
-import org.opendaylight.controller.sal.connector.remoterpc.util.XmlUtils;
-import org.opendaylight.controller.sample.zeromq.consumer.ExampleConsumer;
-import org.opendaylight.controller.sample.zeromq.provider.ExampleProvider;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.Set;
-
-@Path("router")
-public class Router {
-  private Logger _logger = LoggerFactory.getLogger(Router.class);
-  private final URI namespace = URI.create("http://cisco.com/example");
-  private final QName QNAME = new QName(namespace, "heartbeat");
-
-
-  @GET
-  @Path("/hello")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String hello() {
-    return "Hello";
-  }
-
-  @GET
-  @Path("/announce")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String announce() {
-    _logger.info("Announce request received");
-
-    BundleContext ctx = getBundleContext();
-    ServiceReference providerRef = ctx.getServiceReference(ExampleProvider.class);
-    if (providerRef == null) {
-      _logger.debug("Could not get provider reference");
-      return "Could not get provider reference";
-    }
-
-    ExampleProvider provider = (ExampleProvider) ctx.getService(providerRef);
-    if (provider == null) {
-      _logger.info("Could not get provider service");
-      return "Could not get provider service";
-    }
-
-    provider.announce(QNAME);
-    return "Announcement sent ";
-
-  }
-
-  @GET
-  @Path("/rpc")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String invokeRpc() throws Exception {
-    _logger.info("Invoking RPC");
-
-    ExampleConsumer consumer = getConsumer();
-    RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, consumer.getValidCompositeNodeWithOneSimpleChild());
-    _logger.info("Result [{}]", result.isSuccessful());
-
-    return stringify(result);
-  }
-
-  @GET
-  @Path("/rpc-success")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String invokeRpcSuccess() throws Exception {
-    ExampleConsumer consumer = getConsumer();
-    RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, consumer.getValidCompositeNodeWithFourSimpleChildren()); //TODO: Change this
-    _logger.info("Result [{}]", result.isSuccessful());
-
-    return stringify(result);
-  }
-
-  @GET
-  @Path("/rpc-failure")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String invokeRpcFailure() throws Exception {
-    ExampleConsumer consumer = getConsumer();
-    //RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, consumer.getInvalidCompositeNodeCompositeChild()); //TODO: Change this
-    RpcResult<CompositeNode> result = consumer.invokeRpc(QNAME, null); //TODO: Change this
-    _logger.info("Result [{}]", result.isSuccessful());
-
-    return stringify(result);
-  }
-
-  @GET
-  @Path("/routingtable")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String invokeRoutingTable() {
-    _logger.info("Invoking adding an entry in routing table");
-
-    BundleContext ctx = getBundleContext();
-    ServiceReference routingTableServiceReference = ctx.getServiceReference(RoutingTable.class);
-    if (routingTableServiceReference == null) {
-      _logger.debug("Could not get routing table impl reference");
-      return "Could not get routingtable referen ";
-    }
-    RoutingTableImpl routingTable = (RoutingTableImpl) ctx.getService(routingTableServiceReference);
-    if (routingTable == null) {
-      _logger.info("Could not get routing table service");
-      return "Could not get routing table service";
-    }
-
-
-    RoutingIdentifierImpl rii = new RoutingIdentifierImpl();
-    try {
-      routingTable.addGlobalRoute(rii.toString(), "172.27.12.1:5000");
-    } catch (RoutingTableException e) {
-      _logger.error("error in adding routing identifier" + e.getMessage());
-
-    } catch (SystemException e) {
-      _logger.error("error in adding routing identifier" + e.getMessage());
-    }
-
-    String result = routingTable.dumpRoutingTableCache();
-
-
-
-
-    _logger.info("Result [{}] routes added for route" + rii + result);
-
-    return result;
-  }
-
-  @GET
-  @Path("/routingtabledelete")
-  @Produces(MediaType.TEXT_PLAIN)
-  public String invokeDeleteRoutingTable() {
-    _logger.info("Invoking adding an entry in routing table");
-
-    BundleContext ctx = getBundleContext();
-    ServiceReference routingTableServiceReference = ctx.getServiceReference(RoutingTable.class);
-    if (routingTableServiceReference == null) {
-      _logger.debug("Could not get routing table impl reference");
-      return "Could not get routingtable referen ";
-    }
-    RoutingTable routingTable = (RoutingTableImpl) ctx.getService(routingTableServiceReference);
-    if (routingTable == null) {
-      _logger.info("Could not get routing table service");
-      return "Could not get routing table service";
-    }
-
-
-    RoutingIdentifierImpl rii = new RoutingIdentifierImpl();
-    try {
-      routingTable.removeGlobalRoute(rii.toString());
-    } catch (RoutingTableException e) {
-      _logger.error("error in adding routing identifier" + e.getMessage());
-
-    } catch (SystemException e) {
-      _logger.error("error in adding routing identifier" + e.getMessage());
-    }
-
-    Set<String> routes = routingTable.getRoutes(rii.toString());
-
-    StringBuilder stringBuilder = new StringBuilder();
-    if (routes != null) {
-      for (String route : routes) {
-        stringBuilder.append(route);
-      }
-    } else {
-      stringBuilder.append(" successfully");
-    }
-
-    _logger.info("Result [{}] routes removed for route" + rii + stringBuilder.toString());
-
-    return stringBuilder.toString();
-  }
-
-  private String stringify(RpcResult<CompositeNode> result) {
-    CompositeNode node = result.getResult();
-    StringBuilder builder = new StringBuilder("result:").append(XmlUtils.compositeNodeToXml(node)).append("\n")
-        .append("error:").append(result.getErrors()).append("\n");
-
-    return builder.toString();
-  }
-
-  private BundleContext getBundleContext() {
-    ClassLoader tlcl = Thread.currentThread().getContextClassLoader();
-    Bundle bundle = null;
-
-    if (tlcl instanceof BundleReference) {
-      bundle = ((BundleReference) tlcl).getBundle();
-    } else {
-      _logger.info("Unable to determine the bundle context based on " +
-          "thread context classloader.");
-      bundle = FrameworkUtil.getBundle(this.getClass());
-    }
-    return (bundle == null ? null : bundle.getBundleContext());
-  }
-
-  private ExampleConsumer getConsumer() {
-    BundleContext ctx = getBundleContext();
-    ServiceReference consumerRef = ctx.getServiceReference(ExampleConsumer.class);
-    if (consumerRef == null) {
-      _logger.debug("Could not get consumer reference");
-      throw new NullPointerException("Could not get consumer reference");
-    }
-    ExampleConsumer consumer = (ExampleConsumer) ctx.getService(consumerRef);
-    if (consumer == null) {
-      _logger.info("Could not get consumer service");
-      throw new NullPointerException("Could not get consumer service");
-    }
-    return consumer;
-  }
-
-  class RoutingIdentifierImpl implements RpcRouter.RouteIdentifier, Serializable {
-
-    private final URI namespace = URI.create("http://cisco.com/example");
-    private final QName QNAME = new QName(namespace, "global");
-    private final QName instance = new QName(URI.create("127.0.0.1"), "local");
-
-    @Override
-    public QName getContext() {
-      return QNAME;
-    }
-
-    @Override
-    public QName getType() {
-      return QNAME;
-    }
-
-    @Override
-    public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier getRoute() {
-      return InstanceIdentifier.of(instance);
-    }
-
-      @Override
-      public boolean equals(Object o) {
-          if (this == o) return true;
-          if (o == null || getClass() != o.getClass()) return false;
-
-          RoutingIdentifierImpl that = (RoutingIdentifierImpl) o;
-
-          if (!QNAME.equals(that.QNAME)) return false;
-          if (!instance.equals(that.instance)) return false;
-          if (!namespace.equals(that.namespace)) return false;
-
-          return true;
-      }
-
-      @Override
-      public int hashCode() {
-          int result = namespace.hashCode();
-          result = 31 * result + QNAME.hashCode();
-          result = 31 * result + instance.hashCode();
-          return result;
-      }
-  }
-}
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/src/main/resources/WEB-INF/web.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-nb/src/main/resources/WEB-INF/web.xml
deleted file mode 100644 (file)
index 5bd2139..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
-        version="3.0">
-  <servlet>
-    <servlet-name>JAXRSZmq</servlet-name>
-    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
-    <init-param>
-      <param-name>javax.ws.rs.Application</param-name>
-      <param-value>org.opendaylight.controller.northbound.commons.NorthboundApplication</param-value>
-    </init-param>
-    <load-on-startup>1</load-on-startup>
-  </servlet>
-
-  <servlet-mapping>
-    <servlet-name>JAXRSZmq</servlet-name>
-    <url-pattern>/*</url-pattern>
-  </servlet-mapping>
-
-
-
-        <security-constraint>
-          <web-resource-collection>
-            <web-resource-name>NB api</web-resource-name>
-            <url-pattern>/*</url-pattern>
-            <http-method>POST</http-method>
-            <http-method>GET</http-method>
-            <http-method>PUT</http-method>
-            <http-method>PATCH</http-method>
-            <http-method>DELETE</http-method>
-            <http-method>HEAD</http-method>
-          </web-resource-collection>
-          <auth-constraint>
-            <role-name>System-Admin</role-name>
-            <role-name>Network-Admin</role-name>
-            <role-name>Network-Operator</role-name>
-            <role-name>Container-User</role-name>
-          </auth-constraint>
-        </security-constraint>
-
-        <security-role>
-                <role-name>System-Admin</role-name>
-        </security-role>
-        <security-role>
-                <role-name>Network-Admin</role-name>
-        </security-role>
-        <security-role>
-                <role-name>Network-Operator</role-name>
-        </security-role>
-        <security-role>
-                <role-name>Container-User</role-name>
-        </security-role>
-
-        <login-config>
-                <auth-method>BASIC</auth-method>
-                <realm-name>opendaylight</realm-name>
-        </login-config>
-</web-app>
index 46f4a2366a29e444623a0dfe525f8914add2a82f..b760263967864947268a3cc34df07e0a309e581b 100644 (file)
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-util</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-remote</artifactId>
       <artifactId>mockito-all</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <build>
index 1e5bfbd6b93e7fe540931a0f6f828625a4a963c1..696bf715355e402a0932532a36cde8e795a08236 100644 (file)
@@ -9,15 +9,15 @@ package org.opendaylight.controller.sal.rest.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Preconditions;
+import com.google.gson.stream.JsonWriter;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import javax.activation.UnsupportedDataTypeException;
-
 import org.opendaylight.controller.sal.core.api.mount.MountInstance;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
 import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO;
@@ -29,6 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -48,13 +49,8 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.gson.stream.JsonWriter;
-
 class JsonMapper {
 
-    private final Set<LeafListSchemaNode> foundLeafLists = new HashSet<>();
-    private final Set<ListSchemaNode> foundLists = new HashSet<>();
     private MountInstance mountPoint;
     private final Logger logger = LoggerFactory.getLogger(JsonMapper.class);
 
@@ -77,15 +73,14 @@ class JsonMapper {
         }
 
         writer.endObject();
-
-        foundLeafLists.clear();
-        foundLists.clear();
     }
 
     private void writeChildrenOfParent(final JsonWriter writer, final CompositeNode parent, final DataNodeContainer parentSchema)
             throws IOException {
         checkNotNull(parent);
 
+        final Set<QName> foundLists = new HashSet<>();
+
         Set<DataSchemaNode> parentSchemaChildNodes = parentSchema == null ?
                                    Collections.<DataSchemaNode>emptySet() : parentSchema.getChildNodes();
 
@@ -98,59 +93,88 @@ class JsonMapper {
 
                 logger.debug( "No schema found for data node \"" + child.getNodeType() );
 
-                handleNoSchemaFound( writer, child, parent );
+                if( !foundLists.contains( child.getNodeType() ) ) {
+                    handleNoSchemaFound( writer, child, parent );
+
+                    // Since we don't have a schema, we don't know which nodes are supposed to be
+                    // lists so treat every one as a potential list to avoid outputting duplicates.
+
+                    foundLists.add( child.getNodeType() );
+                }
             }
             else if (childSchema instanceof ContainerSchemaNode) {
                 Preconditions.checkState(child instanceof CompositeNode,
                         "Data representation of Container should be CompositeNode - " + child.getNodeType());
                 writeContainer(writer, (CompositeNode) child, (ContainerSchemaNode) childSchema);
             } else if (childSchema instanceof ListSchemaNode) {
-                if (!foundLists.contains(childSchema)) {
+                if (!foundLists.contains( child.getNodeType() ) ) {
                     Preconditions.checkState(child instanceof CompositeNode,
                             "Data representation of List should be CompositeNode - " + child.getNodeType());
-                    foundLists.add((ListSchemaNode) childSchema);
+                    foundLists.add( child.getNodeType() );
                     writeList(writer, parent, (CompositeNode) child, (ListSchemaNode) childSchema);
                 }
             } else if (childSchema instanceof LeafListSchemaNode) {
-                if (!foundLeafLists.contains(childSchema)) {
+                if (!foundLists.contains( child.getNodeType() ) ) {
                     Preconditions.checkState(child instanceof SimpleNode<?>,
                             "Data representation of LeafList should be SimpleNode - " + child.getNodeType());
-                    foundLeafLists.add((LeafListSchemaNode) childSchema);
+                    foundLists.add( child.getNodeType() );
                     writeLeafList(writer, parent, (SimpleNode<?>) child, (LeafListSchemaNode) childSchema);
                 }
             } else if (childSchema instanceof LeafSchemaNode) {
                 Preconditions.checkState(child instanceof SimpleNode<?>,
                         "Data representation of LeafList should be SimpleNode - " + child.getNodeType());
                 writeLeaf(writer, (SimpleNode<?>) child, (LeafSchemaNode) childSchema);
+            } else if (childSchema instanceof AnyXmlSchemaNode) {
+                if( child instanceof CompositeNode ) {
+                    writeContainer(writer, (CompositeNode) child, null);
+                }
+                else {
+                    handleNoSchemaFound( writer, child, parent );
+                }
             } else {
                 throw new UnsupportedDataTypeException("Schema can be ContainerSchemaNode, ListSchemaNode, "
                         + "LeafListSchemaNode, or LeafSchemaNode. Other types are not supported yet.");
             }
         }
+    }
 
-        for (Node<?> child : parent.getValue()) {
-            DataSchemaNode childSchema = findFirstSchemaForNode(child, parentSchemaChildNodes);
-            if (childSchema instanceof LeafListSchemaNode) {
-                foundLeafLists.remove(childSchema);
-            } else if (childSchema instanceof ListSchemaNode) {
-                foundLists.remove(childSchema);
-            }
+    private void writeValue( final JsonWriter writer, Object value ) throws IOException {
+        if( value != null ) {
+            writer.value( String.valueOf( value ) );
+        }
+        else {
+            writer.value( "" );
         }
     }
 
     private void handleNoSchemaFound( final JsonWriter writer, final Node<?> node,
                                       final CompositeNode parent ) throws IOException {
         if( node instanceof SimpleNode<?> ) {
-            writeName( node, null, writer );
-            Object value = node.getValue();
-            if( value != null ) {
-                writer.value( String.valueOf( value ) );
+            List<SimpleNode<?>> nodeLeafList = parent.getSimpleNodesByName( node.getNodeType() );
+            if( nodeLeafList.size() == 1 ) {
+                writeName( node, null, writer );
+                writeValue( writer, node.getValue() );
+            }
+            else { // more than 1, write as a json array
+                writeName( node, null, writer );
+                writer.beginArray();
+                for( SimpleNode<?> leafNode: nodeLeafList ) {
+                    writeValue( writer, leafNode.getValue() );
+                }
+
+                writer.endArray();
             }
         } else { // CompositeNode
             Preconditions.checkState( node instanceof CompositeNode,
                     "Data representation of Container should be CompositeNode - " + node.getNodeType() );
 
-            writeContainer( writer, (CompositeNode) node, null );
+            List<CompositeNode> nodeList = parent.getCompositesByName( node.getNodeType() );
+            if( nodeList.size() == 1 ) {
+                writeContainer( writer, (CompositeNode) node, null );
+            }
+            else { // more than 1, write as a json array
+                writeList( writer, parent, (CompositeNode) node, null );
+            }
         }
     }
 
index 062d03a49f56e12ca6bb178fa39303b78fc059da..3d047dd07f53e47a4000a5de137fcc52e3affa75 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.controller.sal.restconf.impl;
 
+import com.google.common.util.concurrent.Futures;
+import java.util.Collections;
 import java.util.concurrent.Future;
-
 import javax.ws.rs.core.Response.Status;
-
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.sal.common.util.Rpcs;
 import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
 import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.core.api.data.DataChangeListener;
@@ -23,6 +24,7 @@ import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType;
 import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
@@ -160,20 +162,24 @@ public class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNod
 
     public Future<RpcResult<TransactionStatus>> commitConfigurationDataDelete( final InstanceIdentifier path ) {
         this.checkPreconditions();
-
-        final DataModificationTransaction transaction = dataService.beginTransaction();
-        LOG.info( "Delete Configuration via Restconf: {}", path );
-        transaction.removeConfigurationData( path );
-        return transaction.commit();
+        return deleteDataAtTarget(path,dataService.beginTransaction());
     }
 
     public Future<RpcResult<TransactionStatus>> commitConfigurationDataDeleteBehindMountPoint(
                                           final MountInstance mountPoint, final InstanceIdentifier path ) {
         this.checkPreconditions();
+        return deleteDataAtTarget(path,mountPoint.beginTransaction());
+    }
 
-        final DataModificationTransaction transaction = mountPoint.beginTransaction();
-        LOG.info( "Delete Configuration via Restconf: {}", path );
-        transaction.removeConfigurationData( path );
+    private Future<RpcResult<TransactionStatus>> deleteDataAtTarget(final InstanceIdentifier path,
+            final DataModificationTransaction transaction) {
+        LOG.info("Delete Configuration via Restconf: {}", path);
+        CompositeNode redDataAtPath = transaction.readConfigurationData(path);
+        if (redDataAtPath == null) {
+            return Futures.immediateFuture(Rpcs.<TransactionStatus> getRpcResult(true, TransactionStatus.COMMITED,
+                    Collections.<RpcError> emptyList()));
+        }
+        transaction.removeConfigurationData(path);
         return transaction.commit();
     }
 
index b0916f4500d65d9dfb3291f4435e7c2aad31cc1b..6330c0a479caa5acf2926e5ce9820bc3a435e756 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdent
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -804,7 +805,8 @@ public class ControllerContext implements SchemaContextListener {
 
     public boolean isInstantiatedDataSchema( final DataSchemaNode node ) {
         return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode ||
-                node instanceof ContainerSchemaNode || node instanceof ListSchemaNode;
+               node instanceof ContainerSchemaNode || node instanceof ListSchemaNode ||
+               node instanceof AnyXmlSchemaNode;
     }
 
     private void addKeyValue( final HashMap<QName, Object> map, final DataSchemaNode node,
index 9700d48bc298f30576796d76a72489d5ae0900da..4716a02be2f26230721be7e08eb697eaeb0224cc 100644 (file)
@@ -56,6 +56,7 @@ import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
 import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -1044,97 +1045,127 @@ public class RestconfImpl implements RestconfService {
             }
         }
 
-        if ((nodeBuilder instanceof CompositeNodeWrapper)) {
-            final List<NodeWrapper<?>> children = ((CompositeNodeWrapper) nodeBuilder).getValues();
-            for (final NodeWrapper<? extends Object> child : children) {
-                final List<DataSchemaNode> potentialSchemaNodes =
-                        this.controllerContext.findInstanceDataChildrenByName(
-                                             ((DataNodeContainer) schema), child.getLocalName());
+        if ( nodeBuilder instanceof CompositeNodeWrapper ) {
+            if( schema instanceof DataNodeContainer ) {
+                normalizeCompositeNode( (CompositeNodeWrapper)nodeBuilder, (DataNodeContainer)schema,
+                                        mountPoint, currentAugment );
+            }
+            else if( schema instanceof AnyXmlSchemaNode ) {
+                normalizeAnyXmlNode( (CompositeNodeWrapper)nodeBuilder, (AnyXmlSchemaNode)schema );
+            }
+        }
+        else if ( nodeBuilder instanceof SimpleNodeWrapper ) {
+            normalizeSimpleNode( (SimpleNodeWrapper) nodeBuilder, schema, mountPoint );
+        }
+        else if ((nodeBuilder instanceof EmptyNodeWrapper)) {
+            normalizeEmptyNode( (EmptyNodeWrapper) nodeBuilder, schema );
+        }
+    }
 
-                if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) {
-                    StringBuilder builder = new StringBuilder();
-                    for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) {
-                        builder.append("   ").append(potentialSchemaNode.getQName().getNamespace().toString())
-                               .append("\n");
-                    }
+    private void normalizeAnyXmlNode( CompositeNodeWrapper compositeNode, AnyXmlSchemaNode schema ) {
+        List<NodeWrapper<?>> children = compositeNode.getValues();
+        for( NodeWrapper<? extends Object> child : children ) {
+            child.setNamespace( schema.getQName().getNamespace() );
+            if( child instanceof CompositeNodeWrapper ) {
+                normalizeAnyXmlNode( (CompositeNodeWrapper)child, schema );
+            }
+        }
+    }
 
-                    throw new RestconfDocumentedException(
-                                 "Node \"" + child.getLocalName() +
-                                 "\" is added as augment from more than one module. " +
-                                 "Therefore node must have namespace (XML format) or module name (JSON format)." +
-                                 "\nThe node is added as augment from modules with namespaces:\n" + builder,
-                                 ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE );
-                }
+    private void normalizeEmptyNode( EmptyNodeWrapper emptyNodeBuilder, DataSchemaNode schema ) {
+        if ((schema instanceof LeafSchemaNode)) {
+            emptyNodeBuilder.setComposite(false);
+        }
+        else {
+            if ((schema instanceof ContainerSchemaNode)) {
+                // FIXME: Add presence check
+                emptyNodeBuilder.setComposite(true);
+            }
+        }
+    }
+
+    private void normalizeSimpleNode( SimpleNodeWrapper simpleNode, DataSchemaNode schema,
+                                      MountInstance mountPoint ) {
+        final Object value = simpleNode.getValue();
+        Object inputValue = value;
+        TypeDefinition<? extends Object> typeDefinition = this.typeDefinition(schema);
+        if ((typeDefinition instanceof IdentityrefTypeDefinition)) {
+            if ((value instanceof String)) {
+                inputValue = new IdentityValuesDTO( simpleNode.getNamespace().toString(),
+                        (String) value, null, (String) value );
+            } // else value is already instance of IdentityValuesDTO
+        }
+
+        Object outputValue = inputValue;
+
+        if( typeDefinition != null ) {
+            Codec<Object,Object> codec = RestCodec.from(typeDefinition, mountPoint);
+            outputValue = codec == null ? null : codec.deserialize(inputValue);
+        }
+
+        simpleNode.setValue(outputValue);
+    }
 
-                boolean rightNodeSchemaFound = false;
+    private void normalizeCompositeNode( CompositeNodeWrapper compositeNodeBuilder,
+                                         DataNodeContainer schema, MountInstance mountPoint,
+                                         QName currentAugment ) {
+        final List<NodeWrapper<?>> children = compositeNodeBuilder.getValues();
+        for (final NodeWrapper<? extends Object> child : children) {
+            final List<DataSchemaNode> potentialSchemaNodes =
+                    this.controllerContext.findInstanceDataChildrenByName(
+                                                           schema, child.getLocalName());
+
+            if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) {
+                StringBuilder builder = new StringBuilder();
                 for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) {
-                    if (!rightNodeSchemaFound) {
-                        final QName potentialCurrentAugment =
-                                this.normalizeNodeName(child, potentialSchemaNode, currentAugment, mountPoint);
-                        if (child.getQname() != null ) {
-                            this.normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint);
-                            rightNodeSchemaFound = true;
-                        }
-                    }
+                    builder.append("   ").append(potentialSchemaNode.getQName().getNamespace().toString())
+                           .append("\n");
                 }
 
-                if (!rightNodeSchemaFound) {
-                    throw new RestconfDocumentedException(
-                               "Schema node \"" + child.getLocalName() + "\" was not found in module.",
-                               ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT );
-                }
+                throw new RestconfDocumentedException(
+                             "Node \"" + child.getLocalName() +
+                             "\" is added as augment from more than one module. " +
+                             "Therefore node must have namespace (XML format) or module name (JSON format)." +
+                             "\nThe node is added as augment from modules with namespaces:\n" + builder,
+                             ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE );
             }
 
-            if ((schema instanceof ListSchemaNode)) {
-                final List<QName> listKeys = ((ListSchemaNode) schema).getKeyDefinition();
-                for (final QName listKey : listKeys) {
-                    boolean foundKey = false;
-                    for (final NodeWrapper<? extends Object> child : children) {
-                        if (Objects.equal(child.unwrap().getNodeType().getLocalName(), listKey.getLocalName())) {
-                            foundKey = true;
-                        }
-                    }
-
-                    if (!foundKey) {
-                        throw new RestconfDocumentedException(
-                                       "Missing key in URI \"" + listKey.getLocalName() +
-                                       "\" of list \"" + schema.getQName().getLocalName() + "\"",
-                                       ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE );
+            boolean rightNodeSchemaFound = false;
+            for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) {
+                if (!rightNodeSchemaFound) {
+                    final QName potentialCurrentAugment =
+                            this.normalizeNodeName(child, potentialSchemaNode, currentAugment, mountPoint);
+                    if (child.getQname() != null ) {
+                        this.normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint);
+                        rightNodeSchemaFound = true;
                     }
                 }
             }
-        }
-        else {
-            if ((nodeBuilder instanceof SimpleNodeWrapper)) {
-                final SimpleNodeWrapper simpleNode = ((SimpleNodeWrapper) nodeBuilder);
-                final Object value = simpleNode.getValue();
-                Object inputValue = value;
-                TypeDefinition<? extends Object> typeDefinition = this.typeDefinition(schema);
-                if ((typeDefinition instanceof IdentityrefTypeDefinition)) {
-                    if ((value instanceof String)) {
-                        inputValue = new IdentityValuesDTO( nodeBuilder.getNamespace().toString(),
-                                                            (String) value, null, (String) value );
-                    } // else value is already instance of IdentityValuesDTO
-                }
 
-                Codec<Object,Object> codec = RestCodec.from(typeDefinition, mountPoint);
-                Object outputValue = codec == null ? null : codec.deserialize(inputValue);
-
-                simpleNode.setValue(outputValue);
+            if (!rightNodeSchemaFound) {
+                throw new RestconfDocumentedException(
+                           "Schema node \"" + child.getLocalName() + "\" was not found in module.",
+                           ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT );
             }
-            else {
-                if ((nodeBuilder instanceof EmptyNodeWrapper)) {
-                    final EmptyNodeWrapper emptyNodeBuilder = ((EmptyNodeWrapper) nodeBuilder);
-                    if ((schema instanceof LeafSchemaNode)) {
-                        emptyNodeBuilder.setComposite(false);
-                    }
-                    else {
-                        if ((schema instanceof ContainerSchemaNode)) {
-                            // FIXME: Add presence check
-                            emptyNodeBuilder.setComposite(true);
-                        }
+        }
+
+        if ((schema instanceof ListSchemaNode)) {
+            ListSchemaNode listSchemaNode = (ListSchemaNode)schema;
+            final List<QName> listKeys = listSchemaNode.getKeyDefinition();
+            for (final QName listKey : listKeys) {
+                boolean foundKey = false;
+                for (final NodeWrapper<? extends Object> child : children) {
+                    if (Objects.equal(child.unwrap().getNodeType().getLocalName(), listKey.getLocalName())) {
+                        foundKey = true;
                     }
                 }
+
+                if (!foundKey) {
+                    throw new RestconfDocumentedException(
+                                   "Missing key in URI \"" + listKey.getLocalName() +
+                                   "\" of list \"" + listSchemaNode.getQName().getLocalName() + "\"",
+                                   ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE );
+                }
             }
         }
     }
@@ -1237,6 +1268,9 @@ public class RestconfImpl implements RestconfService {
         else if (node instanceof LeafSchemaNode) {
             return _typeDefinition((LeafSchemaNode)node);
         }
+        else if (node instanceof AnyXmlSchemaNode) {
+            return null;
+        }
         else {
             throw new IllegalArgumentException("Unhandled parameter types: " +
                     Arrays.<Object>asList(node).toString());
index 1ec7253b8d595dea9ef3e62a05decbd224178975..93d32a14992e9df0209be9409cbea91074db514a 100644 (file)
@@ -116,6 +116,75 @@ public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader
 
     }
 
+    static class ComplexAnyXmlVerifier extends LeafVerifier {
+
+        ComplexAnyXmlVerifier() {
+            super( null, JsonToken.BEGIN_OBJECT );
+        }
+
+        @Override
+        void verify( JsonReader reader, String keyName ) throws IOException {
+
+            reader.beginObject();
+            String innerKey = reader.nextName();
+            assertEquals( "Json reader child key for " + keyName, "data", innerKey );
+            assertEquals( "Json token type for key " + innerKey, JsonToken.BEGIN_OBJECT, reader.peek() );
+
+            reader.beginObject();
+            verifyLeaf( reader, innerKey, "leaf1", "leaf1-value" );
+            verifyLeaf( reader, innerKey, "leaf2", "leaf2-value" );
+
+            String nextName = reader.nextName();
+            assertEquals( "Json reader child key for " + innerKey, "leaf-list", nextName );
+            reader.beginArray();
+            assertEquals( "Json value for key " + nextName, "leaf-list-value1", reader.nextString() );
+            assertEquals( "Json value for key " + nextName, "leaf-list-value2", reader.nextString() );
+            reader.endArray();
+
+            nextName = reader.nextName();
+            assertEquals( "Json reader child key for " + innerKey, "list", nextName );
+            reader.beginArray();
+            verifyNestedLists( reader, 1 );
+            verifyNestedLists( reader, 3 );
+            reader.endArray();
+
+            reader.endObject();
+            reader.endObject();
+        }
+
+        void verifyNestedLists( JsonReader reader, int leafNum ) throws IOException {
+            reader.beginObject();
+
+            String nextName = reader.nextName();
+            assertEquals( "Json reader next name", "nested-list", nextName );
+
+            reader.beginArray();
+
+            reader.beginObject();
+            verifyLeaf( reader, "nested-list", "nested-leaf", "nested-value" + leafNum++ );
+            reader.endObject();
+
+            reader.beginObject();
+            verifyLeaf( reader, "nested-list", "nested-leaf", "nested-value" + leafNum );
+            reader.endObject();
+
+            reader.endArray();
+            reader.endObject();
+        }
+
+        void verifyLeaf( JsonReader reader, String parent, String name, String value ) throws IOException {
+            String nextName = reader.nextName();
+            assertEquals( "Json reader child key for " + parent, name, nextName );
+            assertEquals( "Json token type for key " + parent, JsonToken.STRING, reader.peek() );
+            assertEquals( "Json value for key " + nextName, value, reader.nextString() );
+        }
+
+        @Override
+        Object getActualValue( JsonReader reader ) throws IOException {
+            return null;
+        }
+    }
+
     @BeforeClass
     public static void initialize() {
         dataLoad("/cnsn-to-json/simple-data-types");
@@ -208,6 +277,9 @@ public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader
         expectedMap.put( "lfunion14", new StringVerifier( "zero" ) );
         expectedMap.put( "lfempty", new EmptyVerifier() );
         expectedMap.put( "identityref1", new StringVerifier( "simple-data-types:iden" ) );
+        expectedMap.put( "complex-any", new ComplexAnyXmlVerifier() );
+        expectedMap.put( "simple-any", new StringVerifier( "simple" ) );
+        expectedMap.put( "empty-any", new StringVerifier( "" ) );
 
         while (jReader.hasNext()) {
             String keyName = jReader.nextName();
index ddab7004408f4d60aa3e89f8660f8aa9749bce7b..19ca812f8e9a90c1aad698be0df347b2b651b26f 100644 (file)
@@ -7,19 +7,20 @@
  */
 
 package org.opendaylight.controller.sal.restconf.impl.test;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.Futures;
 import java.util.Map;
 import java.util.concurrent.Future;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InOrder;
@@ -42,9 +43,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
+import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
 
 /**
  * Unit tests for BrokerFacade.
@@ -275,6 +274,8 @@ public class BrokerFacadeTest {
         Future<RpcResult<TransactionStatus>> expFuture =  Futures.immediateFuture( null );
 
         when( dataBroker.beginTransaction() ).thenReturn( mockTransaction );
+        when(mockTransaction.readConfigurationData(any(InstanceIdentifier.class))).thenReturn(
+                ImmutableCompositeNode.builder().toInstance());
         mockTransaction.removeConfigurationData( instanceID );
         when( mockTransaction.commit() ).thenReturn( expFuture );
 
@@ -294,6 +295,8 @@ public class BrokerFacadeTest {
         Future<RpcResult<TransactionStatus>> expFuture =  Futures.immediateFuture( null );
 
         when( mockMountInstance.beginTransaction() ).thenReturn( mockTransaction );
+        when(mockTransaction.readConfigurationData(any(InstanceIdentifier.class))).thenReturn(
+                ImmutableCompositeNode.builder().toInstance());
         mockTransaction.removeConfigurationData( instanceID );
         when( mockTransaction.commit() ).thenReturn( expFuture );
 
index 22b34a44203e0ba67384f6635e7b55bb0dc4e2e5..19a7eff480dece01d1e9ff5743b3ef9c5fa94c5e 100644 (file)
@@ -11,16 +11,14 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-public class DummyFuture implements Future<RpcResult<TransactionStatus>> {
+public class DummyFuture<T> implements Future<RpcResult<T>> {
 
     private final boolean cancel;
     private final boolean isCancelled;
     private final boolean isDone;
-    private final RpcResult<TransactionStatus> result;
+    private final RpcResult<T> result;
 
     public DummyFuture() {
         cancel = false;
@@ -29,16 +27,13 @@ public class DummyFuture implements Future<RpcResult<TransactionStatus>> {
         result = null;
     }
 
-    private DummyFuture(final Builder builder) {
+    private DummyFuture(final Builder<T> builder) {
         cancel = builder.cancel;
         isCancelled = builder.isCancelled;
         isDone = builder.isDone;
         result = builder.result;
     }
 
-    public static Builder builder() {
-        return new DummyFuture.Builder();
-    }
 
     @Override
     public boolean cancel(final boolean mayInterruptIfRunning) {
@@ -56,45 +51,45 @@ public class DummyFuture implements Future<RpcResult<TransactionStatus>> {
     }
 
     @Override
-    public RpcResult<TransactionStatus> get() throws InterruptedException, ExecutionException {
+    public RpcResult<T> get() throws InterruptedException, ExecutionException {
         return result;
     }
 
     @Override
-    public RpcResult<TransactionStatus> get(final long timeout, final TimeUnit unit) throws InterruptedException,
+    public RpcResult<T> get(final long timeout, final TimeUnit unit) throws InterruptedException,
     ExecutionException, TimeoutException {
         return result;
     }
 
-    public static class Builder {
+    public static class Builder<T> {
 
         private boolean cancel;
         private boolean isCancelled;
         private boolean isDone;
-        private RpcResult<TransactionStatus> result;
+        private RpcResult<T> result;
 
-        public Builder cancel(final boolean cancel) {
+        public Builder<T> cancel(final boolean cancel) {
             this.cancel = cancel;
             return this;
         }
 
-        public Builder isCancelled(final boolean isCancelled) {
+        public Builder<T> isCancelled(final boolean isCancelled) {
             this.isCancelled = isCancelled;
             return this;
         }
 
-        public Builder isDone(final boolean isDone) {
+        public Builder<T> isDone(final boolean isDone) {
             this.isDone = isDone;
             return this;
         }
 
-        public Builder rpcResult(final RpcResult<TransactionStatus> result) {
+        public Builder<T> rpcResult(final RpcResult<T> result) {
             this.result = result;
             return this;
         }
 
-        public Future<RpcResult<TransactionStatus>> build() {
-            return new DummyFuture(this);
+        public Future<RpcResult<T>> build() {
+            return new DummyFuture<T>(this);
         }
     }
 }
index 56a58eeadd1f5d80f4dc4f2926c48a9968fbe3c8..e8cbf3140f35f9f750612ddc5c932a8763034a4b 100644 (file)
@@ -17,11 +17,9 @@ import java.io.FileNotFoundException;
 import java.io.UnsupportedEncodingException;
 import java.util.Set;
 import java.util.concurrent.Future;
-
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.junit.BeforeClass;
@@ -85,7 +83,7 @@ public class RestDeleteOperationTest extends JerseyTest {
 
     private Future<RpcResult<TransactionStatus>> createFuture(TransactionStatus statusName) {
         RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(statusName).build();
-        return DummyFuture.builder().rpcResult(rpcResult).build();
+        return new DummyFuture.Builder<TransactionStatus>().rpcResult(rpcResult).build();
     }
 
 }
index cfbc9fdb767c2c9c8fb8bc7e8d4954f5e5e210e8..5b36fd52f78c329649fb3d593034d6bf028031f0 100644 (file)
@@ -15,25 +15,29 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML;
 
+import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Future;
-
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
-
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.sal.common.util.RpcErrors;
 import org.opendaylight.controller.sal.core.api.mount.MountInstance;
 import org.opendaylight.controller.sal.core.api.mount.MountService;
 import org.opendaylight.controller.sal.rest.api.Draft02;
@@ -47,14 +51,15 @@ import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import com.google.common.util.concurrent.Futures;
-
 public class RestPostOperationTest extends JerseyTest {
 
     private static String xmlDataAbsolutePath;
@@ -102,12 +107,12 @@ public class RestPostOperationTest extends JerseyTest {
         resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
                 StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
                 JsonToCompositeNodeProvider.INSTANCE);
-        resourceConfig.registerClasses( RestconfDocumentedExceptionMapper.class );
+        resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class);
         return resourceConfig;
     }
 
     @Test
-    public void postOperationsStatusCodes() throws UnsupportedEncodingException {
+    public void postOperationsStatusCodes() throws IOException {
         controllerContext.setSchemas(schemaContextTestModule);
         mockInvokeRpc(cnSnDataOutput, true);
         String uri = "/operations/test-module:rpc-test";
@@ -119,6 +124,12 @@ public class RestPostOperationTest extends JerseyTest {
         mockInvokeRpc(null, false);
         assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
 
+        List<RpcError> rpcErrors = new ArrayList<>();
+        rpcErrors.add( RpcErrors.getRpcError("applicationTag1", "tag1", "info1", ErrorSeverity.ERROR, "message1", ErrorType.RPC, null));
+        rpcErrors.add( RpcErrors.getRpcError("applicationTag2", "tag2", "info2", ErrorSeverity.WARNING, "message2", ErrorType.PROTOCOL, null));
+        mockInvokeRpc(null, false, rpcErrors);
+        assertEquals(500,post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
+
         uri = "/operations/test-module:rpc-wrongtest";
         assertEquals(400, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
     }
@@ -150,7 +161,7 @@ public class RestPostOperationTest extends JerseyTest {
         mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
         assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
 
-        assertEquals( 400, post(uri, MediaType.APPLICATION_JSON, "" ));
+        assertEquals(400, post(uri, MediaType.APPLICATION_JSON, ""));
     }
 
     @Test
@@ -158,7 +169,8 @@ public class RestPostOperationTest extends JerseyTest {
         controllerContext.setSchemas(schemaContextYangsIetf);
         RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
                 TransactionStatus.COMMITED).build();
-        Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+        Future<RpcResult<TransactionStatus>> dummyFuture = new DummyFuture.Builder<TransactionStatus>().rpcResult(
+                rpcResult).build();
         when(
                 brokerFacade.commitConfigurationDataPostBehindMountPoint(any(MountInstance.class),
                         any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
@@ -175,14 +187,23 @@ public class RestPostOperationTest extends JerseyTest {
         uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont";
         assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData3));
 
-        assertEquals( 400, post(uri, MediaType.APPLICATION_JSON, "" ));
+        assertEquals(400, post(uri, MediaType.APPLICATION_JSON, ""));
     }
 
-    private void mockInvokeRpc(CompositeNode result, boolean sucessful) {
-        RpcResult<CompositeNode> rpcResult = new DummyRpcResult.Builder<CompositeNode>().result(result)
-                .isSuccessful(sucessful).build();
+    private void mockInvokeRpc(CompositeNode result, boolean sucessful, Collection<RpcError> errors) {
+
+        DummyRpcResult.Builder<CompositeNode> builder = new DummyRpcResult.Builder<CompositeNode>().result(result)
+                .isSuccessful(sucessful);
+        if (!errors.isEmpty()) {
+            builder.errors(errors);
+        }
+        RpcResult<CompositeNode> rpcResult = builder.build();
         when(brokerFacade.invokeRpc(any(QName.class), any(CompositeNode.class)))
-            .thenReturn(Futures.<RpcResult<CompositeNode>>immediateFuture( rpcResult ));
+                .thenReturn(Futures.<RpcResult<CompositeNode>> immediateFuture(rpcResult));
+    }
+
+    private void mockInvokeRpc(CompositeNode result, boolean sucessful) {
+        mockInvokeRpc(result, sucessful, Collections.<RpcError> emptyList());
     }
 
     private void mockCommitConfigurationDataPostMethod(TransactionStatus statusName) {
@@ -190,9 +211,9 @@ public class RestPostOperationTest extends JerseyTest {
                 .build();
         Future<RpcResult<TransactionStatus>> dummyFuture = null;
         if (statusName != null) {
-            dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+            dummyFuture = new DummyFuture.Builder<TransactionStatus>().rpcResult(rpcResult).build();
         } else {
-            dummyFuture = DummyFuture.builder().build();
+            dummyFuture = new DummyFuture.Builder<TransactionStatus>().build();
         }
 
         when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
@@ -204,7 +225,8 @@ public class RestPostOperationTest extends JerseyTest {
         initMocking();
         RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
                 TransactionStatus.COMMITED).build();
-        Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+        Future<RpcResult<TransactionStatus>> dummyFuture = new DummyFuture.Builder<TransactionStatus>().rpcResult(
+                rpcResult).build();
 
         when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
                 .thenReturn(dummyFuture);
index 77b39b73529dca04ee8b6279b824c01a4361bf25..44b5f491d66ff71f1ca2ea53196f5c4db7536f8c 100644 (file)
@@ -18,12 +18,10 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
 import java.util.concurrent.Future;
-
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.junit.BeforeClass;
@@ -88,7 +86,7 @@ public class RestPutOperationTest extends JerseyTest {
         resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
                 StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
                 JsonToCompositeNodeProvider.INSTANCE);
-        resourceConfig.registerClasses( RestconfDocumentedExceptionMapper.class );
+        resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class);
         return resourceConfig;
     }
 
@@ -104,14 +102,15 @@ public class RestPutOperationTest extends JerseyTest {
         mockCommitConfigurationDataPutMethod(TransactionStatus.FAILED);
         assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData));
 
-        assertEquals( 400, put(uri, MediaType.APPLICATION_JSON, "" ));
+        assertEquals(400, put(uri, MediaType.APPLICATION_JSON, ""));
     }
 
     @Test
     public void putConfigStatusCodesEmptyBody() throws UnsupportedEncodingException {
         String uri = "/config/ietf-interfaces:interfaces/interface/eth0";
-        Response resp = target(uri).request( MediaType.APPLICATION_JSON).put(Entity.entity( "", MediaType.APPLICATION_JSON));
-        assertEquals( 400, put(uri, MediaType.APPLICATION_JSON, "" ));
+        Response resp = target(uri).request(MediaType.APPLICATION_JSON).put(
+                Entity.entity("", MediaType.APPLICATION_JSON));
+        assertEquals(400, put(uri, MediaType.APPLICATION_JSON, ""));
     }
 
     @Test
@@ -120,7 +119,8 @@ public class RestPutOperationTest extends JerseyTest {
 
         RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
                 TransactionStatus.COMMITED).build();
-        Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+        Future<RpcResult<TransactionStatus>> dummyFuture = new DummyFuture.Builder<TransactionStatus>().rpcResult(
+                rpcResult).build();
         when(
                 brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class),
                         any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
@@ -143,7 +143,8 @@ public class RestPutOperationTest extends JerseyTest {
     public void putDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException {
         RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
                 TransactionStatus.COMMITED).build();
-        Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+        Future<RpcResult<TransactionStatus>> dummyFuture = new DummyFuture.Builder<TransactionStatus>().rpcResult(
+                rpcResult).build();
         when(
                 brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class),
                         any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
@@ -166,7 +167,8 @@ public class RestPutOperationTest extends JerseyTest {
     private void mockCommitConfigurationDataPutMethod(TransactionStatus statusName) {
         RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(statusName)
                 .build();
-        Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+        Future<RpcResult<TransactionStatus>> dummyFuture = new DummyFuture.Builder<TransactionStatus>().rpcResult(
+                rpcResult).build();
         when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class)))
                 .thenReturn(dummyFuture);
     }
index e146cf8f4fa165a4d3234b616e3bbad1516004e1..c5c459618933af91bb272654d0b40b070fb7ffd3 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -18,6 +19,12 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.when;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import com.google.common.io.ByteStreams;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -29,7 +36,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -41,7 +49,6 @@ import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathFactory;
-
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.junit.Before;
@@ -63,13 +70,6 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.common.io.ByteStreams;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-
 /**
  * Unit tests for RestconfDocumentedExceptionMapper.
  *
@@ -842,6 +842,14 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest {
                 errorListEntrySet.iterator().next().getKey() );
         assertTrue( "\"error\" Json element is not an Array", errorListElement.isJsonArray() );
 
+        // As a final check, make sure there aren't multiple "error" array elements. Unfortunately,
+        // the call above to getAsJsonObject().entrySet() will out duplicate "error" elements. So
+        // we'll use regex on the json string to verify this.
+
+        Matcher matcher = Pattern.compile( "\"error\"[ ]*:[ ]*\\[", Pattern.DOTALL ).matcher( bos.toString() );
+        assertTrue( "Expected 1 \"error\" element", matcher.find() );
+        assertFalse( "Found multiple \"error\" elements", matcher.find() );
+
         return errorListElement.getAsJsonArray();
     }
 
@@ -850,7 +858,6 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest {
             final ErrorInfoVerifier errorInfoVerifier ) {
 
         JsonElement errorInfoElement = null;
-        Map<String, String> actualErrorInfo = null;
         Map<String, String> leafMap = Maps.newHashMap();
         for( Entry<String, JsonElement> entry: errorEntryElement.getAsJsonObject().entrySet() ) {
             String leafName = entry.getKey();
index 9b382d210ebd5de7c88c01a814a16aecc4194a3f..3617ed9fb0d897adaf654ed96f0f98967811d7d2 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.sal.restconf.impl.test.structures;
 
+import static org.junit.Assert.assertFalse;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -56,10 +57,14 @@ public class LstItem {
     }
 
     public void addLfLst(LfLst lfLst) {
+        assertFalse( "Found multiple leaf list elements for " + lfLst.getName(),
+                    lfLsts.containsKey( lfLst.getName() ) );
         lfLsts.put(lfLst.getName(), lfLst);
     }
 
     public void addLst(Lst lst) {
+        assertFalse( "Found multiple list elements for " + lst.getName(),
+                     lsts.containsKey( lst.getName() ) );
         lsts.put(lst.getName(), lst);
     }
 
index 9bdea8157910f1db92ce1458876014ece1dc6487..cf6e513b30a1bdc6f10f7725bba73d54aaefac2c 100644 (file)
@@ -269,6 +269,10 @@ module simple-data-types {
         }
     }
          
-         
+       anyxml complex-any;
+       
+       anyxml simple-any;
+       
+       anyxml empty-any;
   }
 }
\ No newline at end of file
index 28d355dbab0a44375559dad7e57670f87cc7b047..ed02ca35f6f13ba2d82bd358e05fb159df537587 100644 (file)
@@ -23,7 +23,6 @@
     <lfenum>enum3</lfenum>
     <lfbits>bit3 bit2</lfbits>
     <lfbinary>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</lfbinary>
-    <lfempty />
     <lfunion1>324</lfunion1>
     <lfunion2>33.3</lfunion2>
     <lfunion3>55</lfunion3>
     <lfunion12>false</lfunion12>
     <lfunion13>b1</lfunion13>
     <lfunion14>zero</lfunion14>
+    <lfempty />
     <identityref1 xmlns:x="simple:data:types">x:iden</identityref1>
-</cont>
\ No newline at end of file
+    <complex-any>
+      <data>
+        <leaf1>leaf1-value</leaf1>
+        <leaf2>leaf2-value</leaf2>
+
+        <leaf-list>leaf-list-value1</leaf-list>
+        <leaf-list>leaf-list-value2</leaf-list>
+
+        <list>
+            <nested-list>
+                <nested-leaf>nested-value1</nested-leaf>
+            </nested-list>
+            <nested-list>
+                <nested-leaf>nested-value2</nested-leaf>
+            </nested-list>
+        </list>
+
+         <list>
+            <nested-list>
+                <nested-leaf>nested-value3</nested-leaf>
+            </nested-list>
+            <nested-list>
+                <nested-leaf>nested-value4</nested-leaf>
+            </nested-list>
+        </list>
+      </data>
+    </complex-any>
+    <simple-any>simple</simple-any>
+    <empty-any></empty-any>
+</cont>
index 57581d100d619064dcb5831c5ea8e590d7670872..4cce64dcd329a9404d9273a24d45dd253db08dad 100644 (file)
@@ -99,7 +99,7 @@
                             </rpc-registry>
 
                             <data-broker>
-                              <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+                              <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
                               <name>binding-data-broker</name>
                             </data-broker>
 
index bd8e89fd7a5ab99ddb1246a167d0b142f446a07f..388c78eaaf6365c77241c17cae04848680882624 100644 (file)
@@ -9,9 +9,11 @@
 */
 package org.opendaylight.controller.config.yang.config.toaster_provider.impl;
 
+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.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sample.toaster.provider.OpendaylightToaster;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -21,23 +23,26 @@ import org.slf4j.LoggerFactory;
 /**
 *
 */
-public final class ToasterProviderModule extends org.opendaylight.controller.config.yang.config.toaster_provider.impl.AbstractToasterProviderModule
- {
+public final class ToasterProviderModule extends
       org.opendaylight.controller.config.yang.config.toaster_provider.impl.AbstractToasterProviderModule {
     private static final Logger log = LoggerFactory.getLogger(ToasterProviderModule.class);
 
-    public ToasterProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public ToasterProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public ToasterProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            ToasterProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public ToasterProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            final ToasterProviderModule oldModule, final java.lang.AutoCloseable oldInstance) {
 
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
     @Override
     protected void customValidation() {
-        // No need to validate dependencies, since all dependencies have mandatory true flag in yang
+        // No need to validate dependencies, since all dependencies have
+        // mandatory true flag in yang
         // config-subsystem will perform the validation for dependencies
     }
 
@@ -48,11 +53,12 @@ public final class ToasterProviderModule extends org.opendaylight.controller.con
         // Register to md-sal
         opendaylightToaster.setNotificationProvider(getNotificationServiceDependency());
 
-        DataProviderService dataBrokerService = getDataBrokerDependency();
+        DataBroker dataBrokerService = getDataBrokerDependency();
         opendaylightToaster.setDataProvider(dataBrokerService);
 
-        final ListenerRegistration<DataChangeListener> dataChangeListenerRegistration =
-                dataBrokerService.registerDataChangeListener( OpendaylightToaster.TOASTER_IID, opendaylightToaster );
+        final ListenerRegistration<DataChangeListener> dataChangeListenerRegistration = dataBrokerService
+                .registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, OpendaylightToaster.TOASTER_IID,
+                        opendaylightToaster, DataChangeScope.SUBTREE);
 
         final BindingAwareBroker.RpcRegistration<ToasterService> rpcRegistration = getRpcRegistryDependency()
                 .addRpcImplementation(ToasterService.class, opendaylightToaster);
index 2ecd7e7b684fe8bdafd6af17527cbb21daeee83f..ec352e8f510dad03911be2ad2eeb0ec6a5c44542 100644 (file)
@@ -17,29 +17,30 @@ import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.opendaylight.controller.config.yang.config.toaster_provider.impl.ToasterProviderRuntimeMXBean;
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
+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.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.controller.sal.common.util.RpcErrors;
 import org.opendaylight.controller.sal.common.util.Rpcs;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.DisplayString;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInput;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.RestockToasterInput;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster.ToasterStatus;
-import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.RestockToasterInput;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterBuilder;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterOutOfBreadBuilder;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestocked;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestockedBuilder;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,7 +57,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
     private static final DisplayString TOASTER_MODEL_NUMBER = new DisplayString("Model 1 - Binding Aware");
 
     private NotificationProviderService notificationProvider;
-    private DataBrokerService dataProvider;
+    private DataBroker dataProvider;
 
     private final ExecutorService executor;
 
@@ -76,11 +77,11 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
         executor = Executors.newFixedThreadPool(1);
     }
 
-    public void setNotificationProvider(NotificationProviderService salService) {
+    public void setNotificationProvider(final NotificationProviderService salService) {
         this.notificationProvider = salService;
     }
 
-    public void setDataProvider(DataBrokerService salDataProvider) {
+    public void setDataProvider(final DataBroker salDataProvider) {
         this.dataProvider = salDataProvider;
         updateStatus();
     }
@@ -94,9 +95,9 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
         executor.shutdown();
 
         if (dataProvider != null) {
-            final DataModificationTransaction t = dataProvider.beginTransaction();
-            t.removeOperationalData(TOASTER_IID);
-            t.commit().get();
+            WriteTransaction t = dataProvider.newWriteOnlyTransaction();
+            t.delete(LogicalDatastoreType.OPERATIONAL,TOASTER_IID);
+            t.commit().get(); // FIXME: This call should not be blocking.
         }
     }
 
@@ -118,8 +119,8 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
      * Implemented from the DataChangeListener interface.
      */
     @Override
-    public void onDataChanged( DataChangeEvent<InstanceIdentifier<?>, DataObject> change ) {
-        DataObject dataObject = change.getUpdatedConfigurationData().get( TOASTER_IID );
+    public void onDataChanged( final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change ) {
+        DataObject dataObject = change.getUpdatedSubtree();
         if( dataObject instanceof Toaster )
         {
             Toaster toaster = (Toaster) dataObject;
@@ -150,7 +151,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
      * RestConf RPC call implemented from the ToasterService interface.
      */
     @Override
-    public Future<RpcResult<Void>> makeToast(MakeToastInput input) {
+    public Future<RpcResult<Void>> makeToast(final MakeToastInput input) {
         LOG.info("makeToast: " + input);
 
         synchronized (taskLock) {
@@ -191,7 +192,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
      * ToasterRestocked notification.
      */
     @Override
-    public Future<RpcResult<java.lang.Void>> restockToaster(RestockToasterInput input) {
+    public Future<RpcResult<java.lang.Void>> restockToaster(final RestockToasterInput input) {
         LOG.info( "restockToaster: " + input );
 
         synchronized( taskLock ) {
@@ -226,12 +227,11 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
 
     private void updateStatus() {
         if (dataProvider != null) {
-            final DataModificationTransaction t = dataProvider.beginTransaction();
-            t.removeOperationalData(TOASTER_IID);
-            t.putOperationalData(TOASTER_IID, buildToaster());
+            WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
+            tx.put(LogicalDatastoreType.OPERATIONAL,TOASTER_IID, buildToaster());
 
             try {
-                t.commit().get();
+                tx.commit().get();
             } catch (InterruptedException | ExecutionException e) {
                 LOG.warn("Failed to update toaster status, operational otherwise", e);
             }
@@ -249,7 +249,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti
 
         final MakeToastInput toastRequest;
 
-        public MakeToastTask(MakeToastInput toast) {
+        public MakeToastTask(final MakeToastInput toast) {
             toastRequest = toast;
         }
 
index d6de5cfd17136d625a205b0b77122b2143c803fc..8de0c98c63e98f136ac91c98b1792fb040e0be63 100644 (file)
@@ -53,7 +53,7 @@ module toaster-provider-impl {
                 uses config:service-ref {
                     refine type {
                         mandatory false;
-                        config:required-identity mdsal:binding-data-broker;
+                        config:required-identity mdsal:binding-async-data-broker;
                     }
                 }
             }
index 1069858b4777008a321b7021beb172ca951675df..f5fe089d4d80d1b614636b9522e0963ac2d922c9 100644 (file)
@@ -95,8 +95,10 @@ public class NetconfOperationServiceImpl implements NetconfOperationService {
         Set<Capability> capabilities = new HashSet<>();
         // [RFC6241] 8.3.  Candidate Configuration Capability
         capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
+
+        // TODO rollback on error not supported EditConfigXmlParser:100
         // [RFC6241] 8.5.  Rollback-on-Error Capability
-        capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:rollback-on-error:1.0"));
+        // capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:rollback-on-error:1.0"));
 
         Set<Module> modules = yangStoreSnapshot.getModules();
         for (Module module : modules) {
index 8d85a35bc79ad3f77eb516c14cb23b2003974c13..eddad8b4c7c1df593c45a5f829c3c56828339e18 100644 (file)
@@ -8,6 +8,11 @@
 
 package org.opendaylight.controller.netconf.persist.impl;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Function;
+import com.google.common.base.Stopwatch;
+import com.google.common.collect.Collections2;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collection;
@@ -16,11 +21,10 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.concurrent.TimeUnit;
-
 import javax.annotation.concurrent.Immutable;
-
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
@@ -41,11 +45,6 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Stopwatch;
-import com.google.common.collect.Collections2;
-
 @Immutable
 public class ConfigPusher {
     private static final Logger logger = LoggerFactory.getLogger(ConfigPusher.class);
@@ -84,7 +83,11 @@ public class ConfigPusher {
         ConflictingVersionException lastException;
         Stopwatch stopwatch = new Stopwatch().start();
         do {
-            try (NetconfOperationService operationService = getOperationServiceWithRetries(configSnapshotHolder.getCapabilities(), configSnapshotHolder.toString())) {
+            String idForReporting = configSnapshotHolder.toString();
+            SortedSet<String> expectedCapabilities = checkNotNull(configSnapshotHolder.getCapabilities(),
+                    "Expected capabilities must not be null - %s, check %s", idForReporting,
+                    configSnapshotHolder.getClass().getName());
+            try (NetconfOperationService operationService = getOperationServiceWithRetries(expectedCapabilities, idForReporting)) {
                 return pushConfig(configSnapshotHolder, operationService);
             } catch (ConflictingVersionException e) {
                 lastException = e;
@@ -252,7 +255,7 @@ public class ConfigPusher {
     private static NetconfMessage createEditConfigMessage(Element dataElement) throws NetconfDocumentedException {
         String editConfigResourcePath = "/netconfOp/editConfig.xml";
         try (InputStream stream = ConfigPersisterNotificationHandler.class.getResourceAsStream(editConfigResourcePath)) {
-            Preconditions.checkNotNull(stream, "Unable to load resource " + editConfigResourcePath);
+            checkNotNull(stream, "Unable to load resource " + editConfigResourcePath);
 
             Document doc = XmlUtil.readXmlToDocument(stream);
 
@@ -274,7 +277,7 @@ public class ConfigPusher {
     private static NetconfMessage getCommitMessage() {
         String resource = "/netconfOp/commit.xml";
         try (InputStream stream = ConfigPusher.class.getResourceAsStream(resource)) {
-            Preconditions.checkNotNull(stream, "Unable to load resource " + resource);
+            checkNotNull(stream, "Unable to load resource " + resource);
             return new NetconfMessage(XmlUtil.readXmlToDocument(stream));
         } catch (SAXException | IOException e) {
             // error reading the xml file bundled into the jar
index 148b0446e309f4470f55ee0205e7be6cd429499d..f7091beba5fcb09f26cb1248dbdfdd52d600db77 100644 (file)
@@ -143,8 +143,8 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
         }
 
         notificationVerifier.assertNotificationCount(2);
-        notificationVerifier.assertNotificationContent(0, 0, 0, 9);
-        notificationVerifier.assertNotificationContent(1, 4, 3, 9);
+        notificationVerifier.assertNotificationContent(0, 0, 0, 8);
+        notificationVerifier.assertNotificationContent(1, 4, 3, 8);
 
         mockedAggregator.assertSnapshotCount(2);
         // Capabilities are stripped for persister
index cf4ec213c296bbd103dfe75f7650670b008aa041..ad8b25ff2156d8e937d65d054b41b1e3f34c159e 100644 (file)
@@ -52,15 +52,8 @@ public class SshClientAdapter implements Runnable {
     }
 
     public void run() {
-        SshSession session;
-        try {
-            session = sshClient.openSession();
-        } catch (IOException e) {
-            logger.error("Cannot establish session", e);
-            sshClient.close();
-            return;
-        }
         try {
+            SshSession session = sshClient.openSession();
             invoker.invoke(session);
             InputStream stdOut = session.getStdout();
             session.getStderr();
@@ -90,6 +83,8 @@ public class SshClientAdapter implements Runnable {
 
         } catch (VirtualSocketException e) {
             // Netty closed connection prematurely.
+            // Or maybe tried to open ganymed connection without having initialized session
+            // (ctx.channel().remoteAddress() is null)
             // Just pass and move on.
         } catch (Exception e) {
             logger.error("Unexpected exception", e);
@@ -117,6 +112,7 @@ public class SshClientAdapter implements Runnable {
 
     private void writeImpl(ByteBuf message) throws IOException {
         message.getBytes(0, stdIn, message.readableBytes());
+        message.release();
         stdIn.flush();
     }
 
index d97990a5e6f304724b150a40b9e92c8203a3c28a..626ebe937e6942396d695369435cde67f90beda2 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket;
 /**
  * Exception class which provides notification about exceptional situations at the virtual socket layer.
  */
+// FIXME: Switch to checked exception, create a runtime exception to workaround Socket API
 public class VirtualSocketException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 }
index 09c075735a6c3b7090de71554c6fdefc73ef34ec..a2d2dac112e932d7578698bd1eccf54f54942f50 100644 (file)
@@ -12,7 +12,6 @@
   <version>0.4.2-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <dependencies>
-
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>usermanager</artifactId>
     </dependency>
+
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
@@ -78,6 +84,7 @@
             <Export-Package>org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.types,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.northbound.commons</Export-Package>
             <Import-Package>javax.ws.rs,
               javax.ws.rs.ext,
           <manifestLocation>${project.basedir}/META-INF</manifestLocation>
         </configuration>
       </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-source</id>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <phase>generate-sources</phase>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-sources/javacc</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>javacc-maven-plugin</artifactId>
+        <version>2.6</version>
+        <executions>
+          <execution>
+            <id>javacc</id>
+            <goals>
+              <goal>javacc</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
     </plugins>
   </build>
   <scm>
index 4393b79f6446463074b869918651c273ff6cfa2a..87f51364ba1c5b59f3b9326a518a07c99c72129c 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService;
+import org.opendaylight.controller.northbound.commons.query.QueryContextProvider;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleReference;
@@ -58,6 +59,7 @@ public class NorthboundApplication extends Application {
         } );
         _singletons.add(getJsonProvider());
         _singletons.add(new JacksonJsonProcessingExceptionMapper());
+        _singletons.add(new QueryContextProvider());
     }
 
     ////////////////////////////////////////////////////////////////
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Accessor.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Accessor.java
new file mode 100644 (file)
index 0000000..2d910ed
--- /dev/null
@@ -0,0 +1,55 @@
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+/*package*/ class Accessor {
+    protected final AccessibleObject _accessorObj;
+
+    public Accessor(AccessibleObject accessor) {
+        _accessorObj = accessor;
+        _accessorObj.setAccessible(true);
+    }
+
+    public AccessibleObject getAccessibleObject() {
+        return _accessorObj;
+    }
+
+    public Annotation[] getAnnotations() {
+        return _accessorObj.getAnnotations();
+    }
+
+    public Object getValue(Object parent) throws QueryException {
+        try {
+            if (_accessorObj instanceof Field) {
+                return ((Field)_accessorObj).get(parent);
+            } else {
+                // assume method
+                return ((Method)_accessorObj).invoke(parent);
+            }
+        } catch (Exception e) {
+            throw new QueryException("Failure in retrieving value", e);
+        }
+    }
+    public Type getGenericType() {
+        if (_accessorObj instanceof Field) {
+            return ((Field)_accessorObj).getGenericType();
+        } else {
+            // assume method
+            return ((Method)_accessorObj).getGenericReturnType();
+        }
+    }
+    public Class<?> getType() {
+
+        if (_accessorObj instanceof Field) {
+            return ((Field)_accessorObj).getType();
+        } else {
+            // assume method
+            return ((Method)_accessorObj).getReturnType();
+        }
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/CompareExpression.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/CompareExpression.java
new file mode 100644 (file)
index 0000000..6b972e6
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * 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.northbound.commons.query;
+
+/*package*/ class CompareExpression implements Expression {
+
+    public static enum OP { RE, EQ, NE, GT, GE, LT, LE };
+
+    private final OP _operation;
+    private final String _selector;
+    private final String _arg;
+
+    public CompareExpression(OP op, String selector, String arg) {
+        _operation = op;
+        _selector = selector;
+        _arg = unQuote(arg);
+    }
+
+
+    public OP getOperator() {
+        return _operation;
+    }
+
+    public String getSelector() {
+        return _selector;
+    }
+
+    public String getArgument() {
+        return _arg;
+    }
+
+    @Override
+    public boolean accept(Visitor visitor) throws QueryException {
+        return visitor.visit(this);
+    }
+
+    @Override
+    public String toString() {
+        return "[" + _selector + " " + _operation + " " + _arg + "]";
+    }
+
+    private static String unQuote(String s) {
+        if (s.startsWith("\"") && s.endsWith("\"")) {
+            s = s.substring(1, s.length()-1);
+        } else if (s.startsWith("\'") && s.endsWith("\'")) {
+            s = s.substring(1, s.length()-1);
+        }
+        return s;
+    }
+
+}
@@ -1,20 +1,12 @@
-/*
+/**
  * 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.store.impl.tree;
+package org.opendaylight.controller.northbound.commons.query;
 
-/**
- * Factory interface for creating data trees.
- */
-public interface DataTreeFactory {
-    /**
-     * Create a new data tree.
-     *
-     * @return A data tree instance.
-     */
-    DataTree create();
+/*package*/ interface Expression {
+    boolean accept(Visitor visitor) throws QueryException;
 }
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/ExpressionBuilder.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/ExpressionBuilder.java
new file mode 100644 (file)
index 0000000..f1b2999
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * 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.northbound.commons.query;
+
+import java.util.Stack;
+
+/*package*/ class ExpressionBuilder {
+    private final Stack<Expression> _stack = new Stack<Expression>();
+    private LogicalExpression.OP _lastOp = null;
+
+    public ExpressionBuilder() {}
+
+    public ExpressionBuilder withAnd() {
+        _lastOp = LogicalExpression.OP.AND;
+        return this;
+    }
+
+    public ExpressionBuilder withOr() {
+        _lastOp = LogicalExpression.OP.OR;
+        return this;
+    }
+
+    public ExpressionBuilder withTerm(Expression exp) {
+        if (_lastOp != null) {
+            exp = new LogicalExpression(_lastOp, _stack.pop(), exp);
+            _lastOp = null;
+        }
+        _stack.push(exp);
+        return this;
+    }
+
+    public Expression build() {
+        return _stack.pop();
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java
new file mode 100644 (file)
index 0000000..3977837
--- /dev/null
@@ -0,0 +1,67 @@
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ */
+/*package*/ class IteratableTypeInfo extends TypeInfo {
+
+    public IteratableTypeInfo(String name, Accessor accessor) {
+        super(name, accessor.getType(), accessor);
+    }
+
+    @Override
+    public Object retrieve(Object target, String[] query, int index) throws QueryException {
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("retrieve collection: {}/{} type:{}", index, query.length,
+                    target.getClass());
+        }
+        explore();
+        Collection<?> c = (Collection<?>) target;
+        Iterator<?> it = c.iterator();
+        List<Object> objects = new ArrayList<Object>();
+        while (it.hasNext()) {
+            Object item = it.next();
+            for (TypeInfo child : _types.values()) {
+                Object val = child.retrieve(item, query, index);
+                if (val != null) objects.add(val);
+            }
+        }
+        return objects;
+
+    }
+
+    @Override
+    public synchronized void explore() {
+        if (_explored) return;
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("exploring iteratable type: {} gtype: {}", _class,
+                    _accessor.getGenericType());
+        }
+        Type t = _accessor.getGenericType();
+        if (t instanceof ParameterizedType) {
+            Type[] pt = ((ParameterizedType) t).getActualTypeArguments();
+            // First type is a child, ignore rest
+            if (pt.length > 0) {
+                _types.put(_name, new TypeInfo(_name, (Class)pt[0], null));
+            }
+        }
+        _explored = true;
+    }
+
+    @Override
+    public TypeInfo getCollectionChild(Class<?> childType) {
+        explore();
+        for (TypeInfo ti : _types.values()) {
+            if (ti.getType().equals(childType)) {
+                return ti;
+            }
+        }
+        return null;
+    }
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/LogicalExpression.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/LogicalExpression.java
new file mode 100644 (file)
index 0000000..4e99820
--- /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.northbound.commons.query;
+
+/*package*/ class LogicalExpression implements Expression {
+
+    public static enum OP { AND, OR }
+
+    private final OP _op;
+    private final Expression _arg1;
+    private final Expression _arg2;
+
+    public LogicalExpression(OP op, Expression first, Expression second) {
+        _op = op;
+        _arg1 = first;
+        _arg2 = second;
+    }
+
+    public OP getOperator() {
+        return _op;
+    }
+
+    public Expression getFirst() {
+        return _arg1;
+    }
+
+    public Expression getSecond() {
+        return _arg2;
+    }
+
+    @Override
+    public boolean accept(Visitor visitor) throws QueryException {
+        return visitor.visit(this);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(_arg1.toString())
+        .append(_op.toString())
+        .append(_arg2.toString());
+        return sb.toString();
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Query.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Query.java
new file mode 100644 (file)
index 0000000..15dcaeb
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * 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.northbound.commons.query;
+
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ * Represents a parsed query used in filtering of collections.
+ */
+public interface Query<T> {
+
+    /**
+     * Find items in the given collection and return them as a new list. The
+     * original collection is not changed.
+     *
+     * @param collection to search in.
+     * @return list of items which match the query.
+     * @throws QueryException
+     */
+    public List<T> find(Collection<T> collection) throws QueryException;
+
+    /**
+     * Apply the query on the given collection. Note that this method will modify
+     * the given object by removing any items which don't match the query criteria.
+     * If the collection is 'singleton' or unmodifiable, invocation will result in
+     * an exception.
+     *
+     * @param collection
+     * @return the number matched items
+     * @throws QueryException
+     */
+    public int filter(Collection<T> collection) throws QueryException;
+
+    /**
+     * Search the given root for a child collection and them apply the query on.
+     * Note that this method will modify the given object by removing any items
+     * which don't match the query criteria.
+     *
+     * @param root - top level object to search in
+     * @param childType - the child type which represents the collection.
+     * @return the number of matched items
+     * @throws QueryException
+     */
+    public int filter(T root, Class<?> childType) throws QueryException;
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContext.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContext.java
new file mode 100644 (file)
index 0000000..59a78ac
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * 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.northbound.commons.query;
+
+/**
+ * Query context
+ */
+public interface QueryContext {
+
+    /**
+     * Create a Query
+     * @param queryString - query string to parse
+     * @param clazz - The class which represents the top level jaxb object
+     * @return a query object
+     * @throws QueryException if the query cannot be parsed.
+     */
+    <T> Query<T> createQuery(String queryString, Class<T> clazz)
+            throws QueryException;
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java
new file mode 100644 (file)
index 0000000..13d70b1
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * 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.northbound.commons.query;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*package*/ class QueryContextImpl implements QueryContext {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(QueryContext.class);
+
+    @Override
+    public <T> Query<T> createQuery(String queryString, Class<T> type) throws QueryException {
+        if (queryString == null || queryString.trim().length() == 0) return null;
+        try {
+            if (LOGGER.isDebugEnabled()) LOGGER.debug("Processing query: {}", queryString);
+            // FiqlParser is a parser generated by javacc
+            Expression expression = FiqlParser.parse(queryString);
+            if (LOGGER.isDebugEnabled()) LOGGER.debug("Query expression: {}", expression);
+            // create Query and return;
+            return new QueryImpl<T>(type, expression);
+        } catch (Exception ex) {
+            if (LOGGER.isDebugEnabled()) LOGGER.error("Query processing failed = {}",
+                    queryString, ex);
+            throw new QueryException("Unable to parse query.", ex);
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextProvider.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextProvider.java
new file mode 100644 (file)
index 0000000..65a232c
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * 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.northbound.commons.query;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
+/**
+ * A provider for getting hold of the QueryContext.
+ */
+@Provider
+public class QueryContextProvider implements ContextResolver<QueryContext> {
+
+    // Singleton Query Context instance
+    private static final QueryContext queryContext = new QueryContextImpl();
+
+    @Override
+    public QueryContext getContext(Class<?> type) {
+        return queryContext;
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryException.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryException.java
new file mode 100644 (file)
index 0000000..9ff78ed
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * 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.northbound.commons.query;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Signals that an error happened during the parsing or processing of a query.
+ */
+public class QueryException extends WebApplicationException {
+
+    private static final long serialVersionUID = 1L;
+
+    public QueryException(String msg) {
+        super(Response.status(Response.Status.BAD_REQUEST)
+                .entity(msg).type(MediaType.TEXT_PLAIN).build());
+    }
+
+    public QueryException(String msg, Throwable cause) {
+        super(cause, Response.status(Response.Status.BAD_REQUEST)
+                .entity(msg).type(MediaType.TEXT_PLAIN).build());
+    }
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java
new file mode 100644 (file)
index 0000000..a520f98
--- /dev/null
@@ -0,0 +1,237 @@
+/**
+ * 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.northbound.commons.query;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.opendaylight.controller.northbound.commons.query.CompareExpression.OP;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+/*package*/ class QueryImpl<T> implements Query<T> {
+    public static final Logger LOGGER = LoggerFactory.getLogger(QueryImpl.class);
+    private static final boolean ALLOW_OBJECT_STRING_COMPARE = true;
+
+    private final Expression expression;
+    private final TypeInfo rootType ;
+    /**
+     * Set the expression and cache
+     * @param type
+     * @param expression
+     */
+    public QueryImpl(Class<T> type, Expression expression) {
+        this.expression = expression;
+        this.rootType = TypeInfo.createRoot(null, type);
+    }
+
+    @Override
+    public List<T> find(Collection<T> collection) throws QueryException {
+        // new arraylist for result
+        List<T> result = new ArrayList<T>();
+        for (T item : collection) {
+            if (match(item, rootType)) {
+                result.add(item);
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public int filter(Collection<T> collection) throws QueryException {
+        // find items
+        List<T> matched = new ArrayList<T>();
+        for (T item : collection) {
+            if (match(item, rootType)) {
+                matched.add(item);
+            }
+        }
+        collection.clear();
+        collection.addAll(matched);
+        return matched.size();
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Override
+    public int filter(T rootObject, Class<?> childClass) throws QueryException {
+        // retrieve underlying collection
+        TypeInfo childType = rootType.getCollectionChild(childClass);
+        if (childType == null || !(childType instanceof IteratableTypeInfo)) {
+            return 0;
+        }
+        Collection collection = (Collection)
+                childType.getAccessor().getValue(rootObject);
+        // get the child type of the collection type
+        TypeInfo ti = childType.getCollectionChild(childClass);
+        List matched = new ArrayList();
+        for (Object item : collection) {
+            if (match(item, ti)) {
+                matched.add(item);
+            }
+        }
+        collection.clear();
+        collection.addAll(matched);
+        return matched.size();
+    }
+
+    private boolean match(final Object object, final TypeInfo rootType)
+            throws QueryException {
+        return expression.accept(new Visitor () {
+            @Override
+            public boolean visit(LogicalExpression le) throws QueryException {
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Logical exp {}|{}|{}", le.getOperator(), le.getFirst(),
+                            le.getSecond());
+                }
+                return (le.getOperator() == LogicalExpression.OP.AND) ?
+                        le.getFirst().accept(this) && le.getSecond().accept(this) :
+                            le.getFirst().accept(this) || le.getSecond().accept(this);
+            }
+
+            @Override
+            public boolean visit(CompareExpression ce) throws QueryException {
+                boolean result = visitInternal(ce);
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("=== Compare exp {}|{}|{} == {}", ce.getOperator(),
+                            ce.getSelector(), ce.getArgument(), result);
+                }
+                return result;
+            }
+
+            public boolean visitInternal(CompareExpression ce) throws QueryException {
+                String[] selector = ce.getSelector().split("\\.");
+                if (!rootType.getName().equals(selector[0])) {
+                    if (LOGGER.isDebugEnabled()) {
+                        LOGGER.debug("Root name mismatch: {} != {}",
+                                rootType.getName(), selector[0]);
+                    }
+                    return false;
+                }
+                Object value = rootType.retrieve(object, selector, 1);
+                if(value == null){ // nothing to compare against
+                    return false;
+                }
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Comparing [{}] {} [{}]", ce.getArgument(),
+                            ce.getOperator(), value.toString());
+                }
+                if (value instanceof Collection) {
+                    Collection<?> collection = (Collection<?>) value;
+                    if(collection.size() == 0 && ce.getOperator() == OP.NE) {
+                        // collection doesn't contain query string
+                        return true;
+                    }
+                    // If there are elements iterate
+                    Iterator<?> it = collection.iterator();
+                    OP operator = ce.getOperator();
+                    if (operator == OP.NE) {
+                        // negate the operator
+                        operator = OP.EQ;
+                    }
+                    while (it.hasNext()) {
+                        Object item = it.next();
+                        if (compare(parse(ce.getArgument(), item), item, operator)) {
+                            // if match found check the operator and return false for NE
+                            return (ce.getOperator() != OP.NE);
+                        }
+                    }
+                    // return true for NE and false for rest
+                    return (ce.getOperator() == OP.NE);
+                } else {
+                    return compare(parse(ce.getArgument(), value), value,
+                            ce.getOperator());
+                }
+            }
+
+        });
+    }
+
+    private boolean compare(Object valueToMatch, Object actualValue, OP operator) {
+        if (valueToMatch == null || actualValue == null) return false;
+        if (ALLOW_OBJECT_STRING_COMPARE && (valueToMatch instanceof String)
+                && !(actualValue instanceof String)) {
+            actualValue = actualValue.toString();
+        }
+
+        int compareResult = -1;
+        if (valueToMatch instanceof Comparable) {
+            compareResult = ((Comparable)actualValue).compareTo(valueToMatch);
+        } else {
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("Not a comparable type: {} {}",
+                        valueToMatch.getClass().getName(),
+                        actualValue.getClass().getName());
+            }
+            return false;
+        }
+        switch(operator) {
+            case EQ :
+                return compareResult == 0;
+            case RE :
+                // Regex match,
+                if (valueToMatch instanceof String) {
+                    return Pattern.matches((String)valueToMatch, actualValue.toString());
+                } else {
+                    return compareResult == 0;
+                }
+            case NE:
+                return compareResult != 0;
+            case GT :
+                return compareResult > 0;
+            case GE :
+                return compareResult >= 0;
+            case LT :
+                return compareResult < 0;
+            case LE :
+                return compareResult <= 0;
+            default:
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Unrecognized comparator - {}", operator);
+                }
+            return false;
+        }
+    }
+    private Object parse(String arg, Object value) {
+        if (value == null) return null;
+
+        try {
+            if (value instanceof String) {
+                return arg;
+            } else if (value instanceof Byte) {
+                return Byte.decode(arg);
+            } else if (value instanceof Double) {
+                return Double.parseDouble(arg);
+            } else if (value instanceof Float) {
+                return Float.parseFloat(arg);
+            } else if (value instanceof Integer) {
+                return Integer.parseInt(arg);
+            } else if (value instanceof Long) {
+                return Long.parseLong(arg);
+            } else if (value instanceof Short) {
+                return Short.parseShort(arg);
+            }
+        } catch (NumberFormatException ignore) {
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("Exception parsing {}", arg, value);
+            }
+        }
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Using string comparision for type - {}",
+                    value.getClass().getName());
+        }
+        // Not a number or string. Convert to a string and compare as last resort
+        return ALLOW_OBJECT_STRING_COMPARE ? arg.toString() : null;
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java
new file mode 100644 (file)
index 0000000..91f01d8
--- /dev/null
@@ -0,0 +1,294 @@
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A wrapper over a JAXB type to allow traversal of the object graph and
+ * search for specific values in the object tree.
+ */
+/*package*/ class TypeInfo {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(TypeInfo.class);
+    public static final String DEFAULT_NAME = "##default";
+
+    protected final String _name; // the jaxb name
+    protected Class<?> _class; // jaxb type class
+    protected final XmlAccessType _accessType; // jaxb access type
+    protected final Accessor _accessor; // accessor to access object value
+    protected Map<String,TypeInfo> _types = new HashMap<String,TypeInfo>();
+    protected volatile boolean _explored = false;
+    /**
+     * Create a TypeInfo with a name and a class type. The accessor will be null
+     * for a root node.
+     */
+    protected TypeInfo(String name, Class<?> clz, Accessor accessor) {
+        _name = name;
+        _class = clz;
+        _accessor = accessor;
+        XmlAccessorType accessorType = null;
+        if(clz == null) {
+            throw new NullPointerException("Type class can not be null");
+        }
+        accessorType = clz.getAnnotation(XmlAccessorType.class);
+        _accessType = (accessorType == null ?
+                XmlAccessType.PUBLIC_MEMBER : accessorType.value());
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Created type info name:{} type:{}", _name, _class);
+        }
+    }
+
+    /**
+     * @return the Accessor to access the value
+     */
+    public final Accessor getAccessor() {
+        return _accessor;
+    }
+
+    /**
+     * @return get the child by name
+     */
+    public final TypeInfo getChild(String name) {
+        return _types.get(name);
+    }
+
+    public TypeInfo getCollectionChild(Class<?> childType) {
+        explore();
+        for (TypeInfo ti : _types.values()) {
+            if (Collection.class.isAssignableFrom(ti.getType())) {
+                ParameterizedType p = (ParameterizedType)
+                        ti.getAccessor().getGenericType();
+                Type[] pts = p.getActualTypeArguments();
+                if (pts.length == 1 && pts[0].equals(childType)) {
+                    return ti;
+                }
+            }
+        }
+        return null;
+    }
+
+    public Class getType() {
+        return _class;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    /**
+     * @return the object value by a selector query
+     */
+    public Object retrieve(Object target, String[] query, int index)
+            throws QueryException {
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("retrieve: {}/{} type:{}", index, query.length, target.getClass());
+        }
+        if (index >= query.length) return null;
+        explore();
+        if (!target.getClass().equals(_class)) {
+            if (_class.isAssignableFrom(target.getClass())) {
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Handling subtype {} of {} ", target.getClass(), _class);
+                }
+                // explore the subtype
+                TypeInfo subTypeInfo = new TypeInfo(getRootName(target.getClass()),
+                        target.getClass(), _accessor);
+                return subTypeInfo.retrieve(target, query, index);
+            } else {
+                // non compatible object; bail out
+                return null;
+            }
+        }
+        TypeInfo child = getChild(query[index]);
+        if (child == null) return null;
+        target = child.getAccessor().getValue(target);
+        if (index+1 == query.length) {
+            // match found
+            return target;
+        }
+        return child.retrieve(target, query, index+1);
+    }
+
+    /**
+     * Explore the type info for children.
+     */
+    public synchronized void explore() {
+        if (_explored) return;
+        for (Class<?> c = _class; c != null; c = c.getSuperclass()) {
+            if (c.equals(Object.class)) break;
+            // Currently only fields and methods annotated with JAXB annotations are
+            // considered as valid for search purposes.
+            //check methods first
+            for (Method m : c.getDeclaredMethods()) {
+                String tn = getTypeName(m, _accessType);
+                if (tn != null) {
+                    if (LOGGER.isDebugEnabled()) LOGGER.debug(
+                            "exploring type: {} name: {} method: {}",
+                            _class.getSimpleName(), tn, m);
+                    _types.put(tn, createTypeInfo(tn, new Accessor(m)));
+                }
+            }
+            for (Field f : c.getDeclaredFields()) {
+                String tn = getTypeName(f, _accessType);
+                if (tn != null) {
+                    if (LOGGER.isDebugEnabled()) LOGGER.debug(
+                            "exploring type: {} name: {} field: {}",
+                            _class.getSimpleName(), tn, f);
+                    _types.put(tn, createTypeInfo(tn, new Accessor(f)));
+                }
+            }
+        }
+        _explored = true;
+    }
+
+    public static final String getTypeName(Field f, XmlAccessType access) {
+        // ignore static, transient and xmltransient fields
+        if (Modifier.isTransient(f.getModifiers()) ||
+                Modifier.isStatic(f.getModifiers()) ||
+                f.getAnnotation(XmlTransient.class) != null ) {
+            return null;
+        }
+        // try to read annotation
+        String name = getTypeName(f.getAnnotations(), f.getName());
+        if (name != null) return name;
+        // no annotation present check accesstype
+        else if (access == XmlAccessType.NONE) { // none return name
+            return name;
+        } else if (access == XmlAccessType.FIELD) {
+            // return field name if no annotation present
+            return f.getName();
+        } else if (access == XmlAccessType.PUBLIC_MEMBER
+                && Modifier.isPublic(f.getModifiers())) { // look for public access
+            return f.getName();
+        }
+        // return annotated name ( if any )
+        return null;
+    }
+
+    public static final String getTypeName(Method m, XmlAccessType access) {
+        // ignore static, transient and xmltransient fields
+        if (Modifier.isStatic(m.getModifiers()) ||
+                m.getAnnotation(XmlTransient.class) != null ) {
+            return null;
+        }
+        // try to read annotation
+        String name = getTypeName(m.getAnnotations(), m.getName());
+        if (name != null) return name;
+        //check acces type
+        else if (access == XmlAccessType.NONE) { // none return name
+            return name;
+        } else if (access == XmlAccessType.PROPERTY) {
+            // return bean property name if no annotation present
+            return getBeanPropertyName(m);
+        } else if (access == XmlAccessType.PUBLIC_MEMBER
+                && Modifier.isPublic(m.getModifiers())) { // look for public access
+            return getBeanPropertyName(m);
+        }
+        return null;
+    }
+
+    private static String getBeanPropertyName(Method m){
+        try
+        {
+            Class<?> clazz=m.getDeclaringClass();
+            BeanInfo info = Introspector.getBeanInfo(clazz);
+            PropertyDescriptor[] props = info.getPropertyDescriptors();
+            for (PropertyDescriptor pd : props)
+            {
+                if (m.equals(pd.getReadMethod())) return pd.getName();
+            }
+        }
+        catch (IntrospectionException e)
+        {
+            LOGGER.error("Could not read bean property name for method = {}",
+                    m.getName(), e);
+        }
+        return null;
+    }
+
+    public static TypeInfo createRoot(String name, Class<?> clz) {
+        // root is always a composite type
+        // FIXME assert its a JAXB type
+        XmlRootElement root = clz.getAnnotation(XmlRootElement.class);
+        if (root == null) throw new IllegalArgumentException("Not a JAXB type: " + clz);
+        if (name == null) name = getRootName(clz);
+        return new TypeInfo(name, clz, null);
+    }
+
+    public static TypeInfo createTypeInfo(String name, Accessor accessor) {
+        if (accessor.getAccessibleObject().getAnnotation(XmlElementWrapper.class) != null) {
+            //XmlElementWrapperType
+            return new WrapperTypeInfo(name, accessor);
+        } else if (Collection.class.isAssignableFrom(accessor.getType())) {
+            // collection type
+            return new IteratableTypeInfo(name, accessor);
+        }
+        return new TypeInfo(name, accessor.getType(), accessor);
+    }
+
+    public static String getRootName(Class<?> cls) {
+        XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
+        if (root == null) return null;
+        String rootName = root.name();
+        if (DEFAULT_NAME.equals(rootName)) {
+            String clsName = cls.getSimpleName();
+            rootName = Character.toLowerCase(clsName.charAt(0)) + clsName.substring(1);
+        }
+        return rootName;
+    }
+
+    protected static String getTypeName(Annotation[] annotations, String dflt) {
+        String name = null;
+        for (Annotation a : annotations) {
+            if (a.annotationType() == XmlAttribute.class) {
+                name = ((XmlAttribute)a).name();
+            } else if (a.annotationType() == XmlElement.class) {
+                name = ((XmlElement)a).name();
+            } else if (a.annotationType() == XmlElementRef.class) {
+                name = ((XmlElementRef)a).name();
+            } else if (a.annotationType() == XmlElementWrapper.class) {
+                name = ((XmlElementWrapper)a).name();
+                // break the loop as we don't want name to be overwritten by XmlElement
+                break;
+            } else if (a.annotationType() == XmlType.class) {
+                name = ((XmlType)a).name();
+            } else if (a.annotationType() == XmlTransient.class) {
+                // transient type
+                return null;
+            }
+        }
+        if (DEFAULT_NAME.equals(name)) return dflt;
+        return name;
+    }
+
+    @Override
+    public String toString() {
+        return " TypeInfo [_name=" + _name + ", _class=" + _class
+                + ", _accessType=" + _accessType + ", _accessor=" + _accessor
+                + ", _types=" + _types + ", _explored=" + _explored + " ] ";
+    }
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Visitor.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Visitor.java
new file mode 100644 (file)
index 0000000..0c1d2be
--- /dev/null
@@ -0,0 +1,16 @@
+/**
+ * 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.northbound.commons.query;
+
+/*package*/ interface Visitor {
+
+    boolean visit(LogicalExpression exp) throws QueryException;
+
+    boolean visit(CompareExpression exp) throws QueryException;
+
+}
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java
new file mode 100644 (file)
index 0000000..a8172f2
--- /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.northbound.commons.query;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class WrapperTypeInfo extends TypeInfo {
+
+    protected WrapperTypeInfo(String name, Accessor accessor) {
+        super(name, accessor.getType(), accessor);
+    }
+
+    @Override
+    public Object retrieve(Object target, String[] query, int index) throws QueryException {
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("retrieve collection: {}/{}", index, query.length);
+        }
+        if (index >= query.length) return null;
+        explore();
+        TypeInfo child = getChild(query[index]);
+        if (child == null) return null;
+        if (query.length == index+1) { // skipping this node
+            return target;
+        }else { // if list of list go to next node to get value
+            return child.retrieve(target, query, index+1);
+        }
+    }
+
+    @Override
+    public synchronized void explore() {
+        if (_explored) return;
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("exploring wrapper type: {} gtype: {}", _class,
+                    _accessor.getGenericType());
+        }
+        String tn = null;
+        AccessibleObject accessibleObject = _accessor.getAccessibleObject();
+        XmlElement xmlElement = accessibleObject.getAnnotation(XmlElement.class);
+        if (accessibleObject instanceof Field) {
+            Field f = (Field) accessibleObject;
+            tn = DEFAULT_NAME.equals(xmlElement.name())?f.getName() : xmlElement.name();
+        }else if (accessibleObject instanceof Method) {
+            Method m = (Method) accessibleObject;
+            tn = DEFAULT_NAME.equals(xmlElement.name())?m.getName() : xmlElement.name();
+        }
+        this._types.put(tn, new IteratableTypeInfo(tn, this._accessor));
+        _explored = true;
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/main/javacc/fiql.jj b/opendaylight/northbound/commons/src/main/javacc/fiql.jj
new file mode 100644 (file)
index 0000000..b447a32
--- /dev/null
@@ -0,0 +1,124 @@
+
+options {
+  STATIC = false;
+}
+
+PARSER_BEGIN(FiqlParser)
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.util.regex.*;
+
+/*package*/ class FiqlParser {
+  public static Expression parse(String query) throws ParseException {
+    FiqlParser parser = new FiqlParser(new java.io.StringReader(query));
+    return parser.START();
+  }
+}
+
+PARSER_END(FiqlParser)
+
+/* whitespace */
+SKIP :
+{
+  " " | "\t"
+}
+
+TOKEN : {
+  <#ALPHA  : ( ["a"-"z", "A"-"Z", "0"-"9"] )+ >
+}
+
+TOKEN : {
+  <NUM     : ("+"|"-")?(["0"-"9"])+"."(["0"-"9"])* >
+  |
+  <LPAREN  : "(" >
+  |
+  <RPAREN  : ")" >
+}
+
+/* comparision ops */
+TOKEN : {
+  <RE      : ("=") >
+  |
+  <EQ      : ("==" | "=eq=") >
+  |
+  <NE      : ("!=" | "=ne=") >
+  |
+  <LT      : ("=lt=" | "<") >
+  |
+  <LE      : ("=le=" | "<=") >
+  |
+  <GT      : ("=gt=" | ">") >
+  |
+  <GE      : ("=ge=" | ">=") >
+}
+
+/* ops */
+TOKEN : {
+  <AND     : (";" | "and") >
+  |
+  <OR      : ("," | "or") >
+}
+
+/* strings */
+TOKEN : {
+  <STRING : ( ~["\"", "'", "(", ")", ";", ",", "=", "<", ">", "!", "~", " "] )+ >
+  |
+  <DQ_STRING : ( "\"" ( ~["\""] )* "\"" ) >
+  |
+  <SQ_STRING : ( "'" ( ~["'"] )* "'" ) >
+}
+
+/* Root production */
+Expression START() :
+{
+  Expression e;
+}
+{
+  e = EXPR()
+  <EOF>
+  {
+    return e;
+  }
+}
+
+Expression EXPR():
+{
+  ExpressionBuilder builder = new ExpressionBuilder();
+  Expression t;
+}
+{
+  t = TERM() { builder.withTerm(t); }
+  (
+    (<AND> t = TERM()) { builder.withAnd().withTerm(t); }
+    |
+    (<OR> t = TERM() ) { builder.withOr().withTerm(t); }
+  )*
+  {
+    return builder.build();
+  }
+}
+
+Expression TERM() :
+{
+  Token selector, arg;
+  Expression exp;
+  CompareExpression.OP op;
+}
+{
+  selector = <STRING>
+  (
+    ( <EQ>  {op=CompareExpression.OP.EQ;} |
+      <RE>  {op=CompareExpression.OP.RE;} |
+      <NE>  {op=CompareExpression.OP.NE;} |
+      <LT>  {op=CompareExpression.OP.LT;} |
+      <LE>  {op=CompareExpression.OP.LE;} |
+      <GT>  {op=CompareExpression.OP.GT;} |
+      <GE>  {op=CompareExpression.OP.GE;}
+    )
+    ( arg = <STRING> | arg = <DQ_STRING> | arg = <SQ_STRING> | arg = <NUM>)
+  ) { return new CompareExpression(op, selector.image, arg.image); }
+  |
+  (
+    <LPAREN> exp = EXPR() <RPAREN>
+  ) { return exp; }
+}
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/BookBean.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/BookBean.java
new file mode 100644 (file)
index 0000000..5d518f6
--- /dev/null
@@ -0,0 +1,92 @@
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.northbound.commons.types.StringList;
+
+/**
+ */
+
+@XmlRootElement(name="book")
+public class BookBean {
+
+    @XmlElement(name="name")
+    private String _name; // simple type
+
+    private String _isbn; // method annotation
+
+    @XmlElement(name="author")
+    private PersonBean _author; // composite type
+
+    @XmlElementWrapper//for XMLWrapper iterative composite types
+    @XmlElement(name="review")
+    private final List<ReviewBean> reviews = new ArrayList<ReviewBean>();
+
+    @XmlElement
+    private List<String> soldBy; //Iterative Type
+
+    @XmlElementWrapper(name="test")
+    @XmlElement
+    private final List<StringList> testList = new ArrayList<StringList>(); //XMLWrapper list of list
+
+    @XmlElementWrapper(name="parent")
+    @XmlElement(name="child")
+    private final List<WrapperList> wrapperList = new ArrayList<WrapperList>(); // XMLWrapper of XMLWrapper
+
+    public BookBean(){}
+
+    public BookBean(String name, String id, PersonBean person) {
+        _name = name;
+        _isbn = id;
+        _author = person;
+        soldBy = new ArrayList<String>();
+    }
+
+    public BookBean addReview(ReviewBean review) {
+        reviews.add(review);
+        return this;
+    }
+
+    public void setSellerInfo(List<String> sellers) {
+        soldBy = new ArrayList<String>(sellers);
+    }
+
+    public void addWrapperList(WrapperList list){
+        wrapperList.add(list);
+    }
+
+    public void addToTestList(StringList testList){
+        this.testList.add(testList);
+    }
+    public String getName() {
+        return "1"+_name;
+    }
+
+    @XmlElement(name="isbn")
+    public String get_isbn() {
+        return "pre"+_isbn;
+    }
+
+    public PersonBean getauthor() {
+        return _author;
+    }
+
+    @Override
+    public String toString() {
+        return "BookBean [_name=" + _name + ", _isbn=" + _isbn + ", _author="
+                + _author + ", reviews=" + reviews + ", soldBy=" + soldBy
+                + ", testList=" + testList + ", wrapperList=" + wrapperList + "]";
+    }
+
+}
+
+class WrapperList {
+  @XmlElementWrapper(name="items")
+  @XmlElement
+  public List<String> item = new ArrayList<String>();
+}
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ExpresssionTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ExpresssionTest.java
new file mode 100644 (file)
index 0000000..3e2e153
--- /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.northbound.commons.query;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.northbound.commons.query.CompareExpression.OP;
+
+public class ExpresssionTest {
+
+    private static final List<PersonBean> people = new ArrayList<PersonBean>();
+    private static final ArrayList<BookBean> books = new ArrayList<BookBean>();
+
+    public static void p(String msg) {
+        //System.out.println("======= " + msg);
+    }
+
+    public static boolean matches(Expression exp, final PersonBean person) throws Exception {
+
+        boolean result = exp.accept(new Visitor() {
+            @Override
+            public boolean visit(LogicalExpression le) throws QueryException {
+                p("=== LE " + le.getOperator() + "|" + le.getFirst() + "|" + le.getSecond());
+                return (le.getOperator() == LogicalExpression.OP.AND) ?
+                        le.getFirst().accept(this) && le.getSecond().accept(this) :
+                            le.getFirst().accept(this) || le.getSecond().accept(this);
+            }
+
+            @Override
+            public boolean visit(CompareExpression ce) {
+                p("=== CE " + ce.getOperator() + "|" + ce.getSelector() + "|" + ce.getArgument());
+                if (person == null) {
+                    return false;
+                }
+                try {
+                    // check if the selector matches any of the fields
+                    Field field = PersonBean.class.getDeclaredField(ce.getSelector());
+                    if (field == null) {
+                        p("No field found by name : " + ce.getSelector());
+                        return false;
+                    }
+                    Object value = field.get(person);
+                    if (value instanceof String) {
+                        p("Comparing [" + ce.getArgument() + "] "+ ce.getOperator() + " [" + value.toString() + "]");
+                        if (ce.getOperator() == OP.EQ) {
+                            return ce.getArgument().equals(value.toString());
+                        } else if (ce.getOperator() == OP.RE) {
+                            return Pattern.matches(ce.getArgument(), value.toString());
+                        } else if (ce.getOperator() == OP.NE) {
+                            return !ce.getArgument().equals(value.toString());
+                        } else {
+                            p("Comparator : " + ce.getOperator() + " cannot apply to Strings");
+                            return false;
+                        }
+                    } else {
+                        // assume its a #
+                        int valToMatch = Integer.parseInt(ce.getArgument());
+                        int actualValue = (Integer)value;
+                        p("Comparing: " + valToMatch + " " + ce.getOperator() + " " + actualValue);
+                        switch(ce.getOperator()) {
+                        case EQ :
+                        case RE :
+                            return actualValue == valToMatch;
+                        case NE :
+                            return actualValue != valToMatch;
+                        case GT :
+                            return actualValue > valToMatch;
+                        case GE :
+                            return actualValue >= valToMatch;
+                        case LT :
+                            return actualValue < valToMatch;
+                        case LE :
+                            return actualValue <= valToMatch;
+                        default:
+                            p("Unrecognized compare operator: " + ce.getOperator());
+                            return false;
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+        });
+        p("RESULT: " + result);
+        return result;
+    }
+
+    @BeforeClass
+    public static void load() {
+        System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
+
+        people.add(new PersonBean(100, "John", "Doe", "San Jose"));
+        people.add(new PersonBean(200, "Foo", "Bar", "San Francisco"));
+        people.add(new PersonBean(300, "A", "B", "San Francisco"));
+        people.add(new PersonBean(400, "X", "Y", "New York"));
+
+        books.add(new BookBean("Book1", "A001", people.get(0)));
+        books.add(new BookBean("Book2", "A002", people.get(1)));
+        books.add(new BookBean("Book3", "A003", people.get(2)));
+
+        ReviewBean review1 = new ReviewBean("cool", people.get(2));
+        ReviewBean review2 = new ReviewBean("kewl", people.get(3));
+        ReviewBean review3 = new ReviewBean("+++", people.get(0));
+        ReviewBean review4 = new ReviewBean("---", people.get(1));
+
+        books.get(0).addReview(review1).addReview(review2).addReview(review3).addReview(review4);
+        books.get(1).addReview(review1).addReview(review2).addReview(review3).addReview(review4);
+        books.get(2).addReview(review1).addReview(review2).addReview(review3).addReview(review4);
+    }
+
+    @Test
+    public void testCXFQueries() throws Exception {
+        // following queries copied from apache cxf
+        Assert.assertFalse(matches(parseQuery("id=gt=100;name=Fred"), null));
+        Assert.assertFalse(matches(parseQuery("id=gt=100;name==Fred"), null));
+        Assert.assertFalse(matches(parseQuery("id=lt=123"), null));
+        Assert.assertFalse(matches(parseQuery("date=le=2010-03-11"), null));
+        Assert.assertFalse(matches(parseQuery("time=le=2010-03-11T18:00:00"), null));
+        Assert.assertFalse(matches(parseQuery("name==CXF;version=ge=2.2"), null));
+        Assert.assertFalse(matches(parseQuery("(age=lt=25,age=gt=35);city==London"), null));
+        Assert.assertFalse(matches(parseQuery("date=lt=2000-01-01;date=gt=1999-01-01;(sub==math,sub==physics)"), null));
+    }
+
+    public Expression parseQuery(String query) throws Exception {
+        p("PARSING query: " + query);
+        // FiqlParser is a parser generated by javacc
+        Expression exp = FiqlParser.parse(query);
+        p(exp.toString());
+        return exp;
+    }
+
+    public int find(String query) throws Exception {
+        int found = 0;
+        Expression exp = parseQuery(query);
+        TypeInfo.createRoot("person", PersonBean.class);
+        for (PersonBean person : people) {
+            if (matches(exp, person)) found++;
+        }
+        return found;
+    }
+
+    @Test
+    public void testPeopleQueries() throws Exception {
+        Assert.assertTrue(find("id==200") == 1);
+        Assert.assertTrue(find("id!=100;(city='San.*')") == 2);
+        Assert.assertTrue(find("id>200;(city='San.*')") == 1);
+        Assert.assertTrue(find("city='San.*'") == 3);
+    }
+
+    @Test
+    public void testTypeTree() throws Exception {
+        TypeInfo bookType = TypeInfo.createRoot("book", BookBean.class);
+        Assert.assertEquals("John", bookType.retrieve(books.get(0),
+                "book.author.firstName".split("\\."), 1));
+        Object result = bookType.retrieve(books.get(0),
+                "book.reviews.review.comment".split("\\."), 1);
+        Assert.assertTrue( result instanceof List);
+        List<Object> commentList = (List<Object>) result;
+        Assert.assertTrue(commentList.contains("cool"));
+    }
+
+    @Test
+    public void testQueryAPI() throws Exception {
+        QueryContext qc = new QueryContextImpl();
+
+        // find all books written by author with firstName "John"
+        Query q1 = qc.createQuery("book.author.firstName==John", BookBean.class);
+        Collection<BookBean> r1 = q1.find(books);
+        p("Filtered books: " + r1.size());
+        Assert.assertEquals(1, r1.size());
+
+        // find all books reviewed by people in a city "San*"
+        Query q2 = qc.createQuery("book.reviews.review.reviewer.city=San.*", BookBean.class);
+        Collection<BookBean> r2 = q2.find(books);
+
+        p("Filtered books: " + r2.size());
+        Assert.assertEquals(3, r2.size());
+
+        // find all books reviewed by people in a city "San*"
+        Query q3 = qc.createQuery("book==foo", BookBean.class);
+        Collection<BookBean> r3 = q3.find(books);
+        Assert.assertEquals(0, r3.size());
+    }
+
+    @Test
+    public void testFilter() throws Exception {
+        Library library = new Library((List)books.clone());
+        QueryContext qc = new QueryContextImpl();
+        // find all books written by author with firstName "John"
+        Query q1 = qc.createQuery("book.author.firstName==John", Library.class);
+        int sizeBefore = library.getList().size();
+        System.out.println(q1.filter(library, BookBean.class));
+        Assert.assertEquals(1, library.getList().size());
+    }
+}
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/Library.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/Library.java
new file mode 100644 (file)
index 0000000..c54b0e7
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * 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.northbound.commons.query;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name="library")
+public class Library {
+
+    @XmlElement(name="book")
+    private final List<BookBean> _list;
+
+    public Library(List<BookBean> list) {
+        _list = list;
+    }
+
+    public List<BookBean> getList() {
+        return _list;
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/PersonBean.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/PersonBean.java
new file mode 100644 (file)
index 0000000..b4b9ed5
--- /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.northbound.commons.query;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name="person")
+
+public class PersonBean {
+
+    @XmlElement
+    public String firstName;
+    @XmlElement
+    public String lastName;
+    @XmlElement
+    public String city;
+    @XmlElement
+    public int id;
+
+    @XmlElementWrapper(name="emails") // ElementWrapper iteratable type
+    @XmlElement
+    public List<String> email;
+
+    public PersonBean(){}
+    public PersonBean(int n, String f, String l, String c) {
+        firstName = f;
+        lastName = l;
+        city = c;
+        id = n;
+    }
+
+    public void setEmail(List<String> emails){
+        email = emails;
+    }
+    @Override
+    public String toString() {
+        return "PersonBean [firstName=" + firstName + ", lastName=" + lastName
+                + ", city=" + city + ", id=" + id + "]";
+    }
+
+}
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/QueryContextTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/QueryContextTest.java
new file mode 100644 (file)
index 0000000..b6e582b
--- /dev/null
@@ -0,0 +1,269 @@
+/**
+ * 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.northbound.commons.query;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.northbound.commons.types.StringList;
+
+public class QueryContextTest {
+
+    protected static final List<PersonBean> people = new ArrayList<PersonBean>();
+    protected static final List<BookBean> books = new ArrayList<BookBean>();
+
+    public static void p(String msg) {
+        System.out.println("=== " + msg);
+    }
+
+    @BeforeClass
+    public static void load() {
+        people.add(new PersonBean(100, "John", "Doe", "San Jose"));
+        people.add(new PersonBean(200, "Foo", "Bar", "San Francisco"));
+        people.add(new PersonBean(300, "A", "B", "San Francisco"));
+        people.add(new PersonBean(400, "X", "Y", "New York"));
+
+        books.add(new BookBean("Book1", "A001", people.get(0)));
+        books.add(new BookBean("Book2", "A002", people.get(1)));
+        books.add(new BookBean("Book3", "A003", people.get(2)));
+
+        ReviewBean review1 = new ReviewBean("cool", people.get(2));
+        ReviewBean review2 = new ReviewBean("kewl", people.get(3));
+
+        books.get(0).addReview(review1).addReview(review2);
+        books.get(1).addReview(review1);
+        books.get(2).addReview(review2).addReview(review1);
+
+    }
+
+    @Test
+    public void testQueryContext() {
+        QueryContext queryContext = new QueryContextImpl();
+        Assert.assertNotNull(queryContext);
+    }
+
+    @Test
+    public void testSimpleQuery() throws QueryException {
+        QueryContext queryContext = new QueryContextImpl();
+        Query<PersonBean> query = queryContext.createQuery(
+                "person.id==200", PersonBean.class);
+        Assert.assertNotNull(query);
+
+        List<PersonBean> found = query.find(people);
+        Assert.assertNotNull(found);
+        Assert.assertTrue(found.size() == 1);
+        Assert.assertEquals("Foo", found.get(0).firstName);
+    }
+
+    @Test
+    public void testAndQuery() throws QueryException {
+        QueryContext queryContext = new QueryContextImpl();
+        Query<PersonBean> query = queryContext.createQuery(
+                "person.id!=200;(person.city='San.*')", PersonBean.class);
+        Assert.assertNotNull(query);
+
+        List<PersonBean> found = query.find(people);
+        Assert.assertNotNull(found);
+        Assert.assertTrue(found.size() == 2);
+        Assert.assertEquals("John", found.get(0).firstName);
+        Assert.assertEquals("A", found.get(1).firstName);
+    }
+
+    @Test
+    public void testOrQuery() throws QueryException {
+        QueryContext queryContext = new QueryContextImpl();
+        Query<PersonBean> query = queryContext.createQuery(
+                "person.id==200,(person.city='San.*')", PersonBean.class);
+        Assert.assertNotNull(query);
+
+        List<PersonBean> found = query.find(people);
+        Assert.assertNotNull(found);
+        Assert.assertTrue(found.size() == 3);
+        Assert.assertEquals("John", found.get(0).firstName);
+        Assert.assertEquals("Foo", found.get(1).firstName);
+        Assert.assertEquals("A", found.get(2).firstName);
+    }
+
+    @Test
+    public void testXmlElementWrapper() throws QueryException {
+        List<String> emails = new ArrayList<String>();
+        emails.add("john@cisco.com");
+        emails.add("john@gmail.com");
+        people.get(0).setEmail(emails);
+
+        p(toXml(people.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Query<PersonBean> query = queryContext.createQuery(
+                "person.emails.email==john@cisco.com", PersonBean.class);
+        Assert.assertNotNull(query);
+
+        List<PersonBean> found = query.find(people);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1,found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+    }
+
+    @Test
+    public void testXmlWrapperOfWrapper() throws QueryException{
+        WrapperList wrapper = new WrapperList();
+        wrapper.item.add("Test1");
+        wrapper.item.add("Test2");
+
+        books.get(0).addWrapperList(wrapper);
+        books.get(1).addWrapperList(wrapper);
+
+        System.out.println(toXml(books.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Query<BookBean> query = queryContext.createQuery(
+                "book.parent.child.items.item==Test1", BookBean.class);
+        Assert.assertNotNull(query);
+    }
+
+    @Test
+    public void testXmlElementWrapperListofList() throws QueryException {
+        // create Stringlist
+        List<String> testList = new ArrayList<String>();
+        testList.add("A");
+        testList.add("B");
+        StringList itemList = new StringList(testList);
+        books.get(0).addToTestList(itemList);
+
+        System.out.println(toXml(books.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Query<BookBean> query = queryContext.createQuery(
+                "book.test.testList.item==A", BookBean.class);
+        Assert.assertNotNull(query);
+    }
+
+    @Test
+    public void testPrimitiveIteratableTypes() throws QueryException {
+        // Load data for this test
+        List<String> sellers = new ArrayList<String>();
+        sellers.add("Amazon");
+
+        books.get(0).setSellerInfo(sellers);
+        sellers.add("Barners & Nobles");
+        books.get(1).setSellerInfo(sellers);
+        sellers.add("Borders");
+        sellers.remove("Amazon");
+        sellers.add("BookShop");
+        books.get(2).setSellerInfo(sellers);
+
+        System.out.println(toXml(books.get(0)));
+
+        QueryContext queryContext = new QueryContextImpl();
+        Query<BookBean> query = queryContext.createQuery(
+                "book.soldBy==Amazon", BookBean.class);
+        Assert.assertNotNull(query);
+
+        List<BookBean> found = query.find(books);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(2,found.size());
+        Assert.assertEquals("John", found.get(0).getauthor().firstName);
+
+        query = queryContext.createQuery(
+                "book.soldBy!=Amazon", BookBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(books);
+        System.out.println("books" +found);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1,found.size());
+        Assert.assertEquals("A", found.get(0).getauthor().firstName);
+    }
+
+    @Test
+    public void testCompositeIteratableTypes() throws QueryException {
+        QueryContext queryContext = new QueryContextImpl();
+        Query<BookBean> query = queryContext.createQuery("book.reviews.review.reviewer.firstName==X",
+                BookBean.class);
+        Assert.assertNotNull(query);
+
+        List<BookBean> found = query.find(books);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(2, found.size());
+        Assert.assertEquals("John", found.get(0).getauthor().firstName);
+
+        query = queryContext.createQuery("book.reviews.review.comment==kewl",
+                BookBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(books);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(2, found.size());
+        p("Book 0" + found.get(0));
+        Assert.assertEquals("John", found.get(0).getauthor().firstName);
+
+        query = queryContext.createQuery("book.reviews.review.reviewer.id>300",
+                BookBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(books);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(2, found.size());
+        p("Book 0" + found.get(0));
+        Assert.assertEquals("John", found.get(0).getauthor().firstName);
+
+        query = queryContext.createQuery("book.reviews.review.reviewer.firstName!=X",
+                BookBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(books);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        p("Book 0" + found.get(0));
+        Assert.assertEquals("Foo", found.get(0).getauthor().firstName);
+    }
+
+    @Test
+    public void testXMLAccessorType() {
+        //Assert.fail("implement");
+    }
+
+    @Test
+    public void testMethodAnnotation() throws QueryException {
+        System.out.println(toXml(books.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Query<BookBean> query = queryContext.createQuery(
+                "book.isbn==preA003", BookBean.class);
+        Assert.assertNotNull(query);
+
+        List<BookBean> found = query.find(books);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1,found.size());
+        Assert.assertEquals("A", found.get(0).getauthor().firstName);
+    }
+
+    public static String toXml(Object element) {
+        try {
+            JAXBContext jc = JAXBContext.newInstance(element.getClass());
+            Marshaller marshaller = jc.createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            marshaller.marshal(element, baos);
+            return baos.toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    @Test
+    public void testXMLElementWrapperForCompositeTypes(){
+        //Assert.fail("implement");
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ReviewBean.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ReviewBean.java
new file mode 100644 (file)
index 0000000..ea2f873
--- /dev/null
@@ -0,0 +1,41 @@
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ */
+@XmlRootElement(name="review")
+public class ReviewBean {
+    @XmlElement(name="date")
+    private  Date _publishedDate;
+    @XmlElement(name="comment")
+    private  String _comment;
+    @XmlElement(name="reviewer")
+    private  PersonBean _reviewer;
+    @XmlElement
+    private int _upVotes;
+    @XmlElement
+    private int _downVotes;
+    public ReviewBean(){}
+
+    public ReviewBean(String comment, PersonBean user) {
+        _comment = comment;
+        _reviewer = user;
+        _publishedDate = new Date();
+    }
+
+    public void vote(int up, int down) {
+        _upVotes += up;
+        _downVotes += down;
+    }
+
+    @Override
+    public String toString() {
+        return "ReviewBean <publishedDate>" + _publishedDate + "</publishedDate> <comment>"
+                + _comment + "</comment> <reviewer>" + _reviewer + "</reviewer> <upVotes>" + _upVotes
+                + "</upVotes> <downVotes>" + _downVotes + "</downVotes>";
+    }
+}
diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/XMLAccessorTypeTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/XMLAccessorTypeTest.java
new file mode 100644 (file)
index 0000000..25cb692
--- /dev/null
@@ -0,0 +1,374 @@
+package org.opendaylight.controller.northbound.commons.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class XMLAccessorTypeTest {
+
+    @Test
+    public void testPublicAccessType() throws Exception {
+        // create bean
+        List<PublicAccessBean> testList = new ArrayList<PublicAccessBean>();
+        testList.add(new PublicAccessBean("John", "Scott", "private", 1,
+                "transient", "elem1"));
+        testList.add(new PublicAccessBean("Foo", "Bar", "private1", 2,
+                "transient1", "elem2"));
+        QueryContextTest.p(QueryContextTest.toXml(testList.get(0)));
+
+        QueryContext queryContext = new QueryContextImpl();
+        Assert.assertNotNull(queryContext);
+        // search for public field
+        Query<PublicAccessBean> query = queryContext.createQuery(
+                "publicbean.firstName==Foo", PublicAccessBean.class);
+        Assert.assertNotNull(query);
+
+        List<PublicAccessBean> found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("Foo", found.get(0).firstName);
+
+        // search for public getter
+        query = queryContext.createQuery("publicbean.privateGetterField<2",
+                PublicAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+
+        // test for transient field
+        query = queryContext.createQuery("publicbean.transientField='trans*'",
+                PublicAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(0, found.size());
+
+        // test for private field
+        query = queryContext.createQuery("publicbean.privateField==private",
+                PublicAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(0, found.size());
+
+        // test for XML Element
+        query = queryContext.createQuery("publicbean.element==elem1",
+                PublicAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+    }
+
+    @Test
+    public void testFieldAccessType() throws QueryException {
+        // create bean
+        List<FieldAccessBean> testList = new ArrayList<FieldAccessBean>();
+        testList.add(new FieldAccessBean("John", "Scott", "private", 1, "elem1"));
+        testList.add(new FieldAccessBean("Foo", "Bar", "private1", 2, "elem2"));
+
+        QueryContextTest.p(QueryContextTest.toXml(testList.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Assert.assertNotNull(queryContext);
+        // test private field
+        Query<FieldAccessBean> query = queryContext.createQuery(
+                "field.privateField==private", FieldAccessBean.class);
+        Assert.assertNotNull(query);
+
+        List<FieldAccessBean> found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+
+        // test public field
+        query = queryContext.createQuery("field.firstName==Foo",
+                FieldAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("Foo", found.get(0).firstName);
+
+        // test annotated field
+        query = queryContext.createQuery("field.element==elem2",
+                FieldAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("Foo", found.get(0).firstName);
+
+        // test annotated method
+        query = queryContext.createQuery("field.privateGetterField==11",
+                FieldAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+    }
+
+    @Test
+    public void testPropertyAccessType() throws QueryException {
+        // create bean
+        List<PropertyAccessBean> testList = new ArrayList<PropertyAccessBean>();
+        testList.add(new PropertyAccessBean("John", "Scott", "private", 1, "elem1",
+                "transient1"));
+        testList.add(new PropertyAccessBean("Foo", "Bar", "private1", 2, "elem2",
+                "transient2"));
+
+        QueryContextTest.p(QueryContextTest.toXml(testList.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Assert.assertNotNull(queryContext);
+        // test public getter public field
+        Query<PropertyAccessBean> query = queryContext.createQuery(
+                "property.firstName==John", PropertyAccessBean.class);
+        Assert.assertNotNull(query);
+
+        List<PropertyAccessBean> found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+
+        // test public field no getter
+        query = queryContext.createQuery("property.lastName==Bar",
+                PropertyAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(0, found.size());
+
+        // test annotated field
+        query = queryContext.createQuery("property.element==elem2",
+                PropertyAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("Foo", found.get(0).firstName);
+
+        // test annotated method
+        query = queryContext.createQuery("property.field==private",
+                PropertyAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).firstName);
+
+        // test transient method
+        query = queryContext.createQuery("property.transientField==transient1",
+                PropertyAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(0, found.size());
+    }
+
+    @Test
+    public void testNoneAccessType() throws QueryException {
+        // create bean
+        List<NoneAccessBean> testList = new ArrayList<NoneAccessBean>();
+        testList.add(new NoneAccessBean("John", "Scott", "private"));
+        testList.add(new NoneAccessBean("Foo", "Bar", "private1"));
+
+        QueryContextTest.p(QueryContextTest.toXml(testList.get(0)));
+        QueryContext queryContext = new QueryContextImpl();
+        Assert.assertNotNull(queryContext);
+        // test annotated field
+        Query<NoneAccessBean> query = queryContext.createQuery(
+                "test.firstName==John", NoneAccessBean.class);
+        Assert.assertNotNull(query);
+
+        List<NoneAccessBean> found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).getFirstName());
+        // test unannotated field
+        query = queryContext
+                .createQuery("test.lastName==Bar", NoneAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(0, found.size());
+        // test annotated method
+        query = queryContext.createQuery("test.testField==private",
+                NoneAccessBean.class);
+        Assert.assertNotNull(query);
+
+        found = query.find(testList);
+        Assert.assertNotNull(found);
+        Assert.assertEquals(1, found.size());
+        Assert.assertEquals("John", found.get(0).getFirstName());
+
+    }
+
+}
+
+// default ( public memeber )
+@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
+@XmlRootElement(name = "publicbean")
+class PublicAccessBean {
+
+  public String firstName;
+  public String lastName;
+  private String privateField;
+  private int privateGetterField;
+  @XmlTransient
+  public String transientField;
+  @XmlElement(name = "element")
+  private String xmlElem;
+
+  public PublicAccessBean() {
+  }
+
+  public PublicAccessBean(String firstName, String lastName,
+      String privateField, int privateGetterField, String transientField,
+      String xmlElem) {
+    this.firstName = firstName;
+    this.lastName = lastName;
+    this.privateField = privateField;
+    this.privateGetterField = privateGetterField;
+    this.transientField = transientField;
+    this.xmlElem = xmlElem;
+  }
+
+  public int getPrivateGetterField() {
+    return privateGetterField;
+  }
+
+  public void setPrivateGetterField(int field) {
+    this.privateGetterField = field;
+  }
+}
+
+// default ( public memeber )
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "field")
+class FieldAccessBean {
+
+  public String firstName;
+  public String lastName;
+  private String privateField;
+  private int test;
+  @XmlElement(name = "element")
+  private String xmlElem;
+
+  public FieldAccessBean() {
+  }
+
+  public FieldAccessBean(String firstName, String lastName,
+      String privateField, int privateGetterField, String xmlElem) {
+    this.firstName = firstName;
+    this.lastName = lastName;
+    this.privateField = privateField;
+    this.xmlElem = xmlElem;
+    this.test = privateGetterField;
+  }
+
+  public String getPrivateField() {
+    return privateField;
+  }
+
+  @XmlElement(name = "privateGetterField")
+  public int getPrivateGetterField() {
+    return test + 10;
+  }
+}
+
+// default ( public memeber )
+@XmlAccessorType(XmlAccessType.PROPERTY)
+@XmlRootElement(name = "property")
+class PropertyAccessBean {
+
+  public String firstName;
+  public String lastName;
+  private String privateField;
+  private int privateGetterField;
+  @XmlElement(name = "element")
+  private String xmlElem;
+  private String transientField;
+
+  public PropertyAccessBean() {
+  }
+
+  public PropertyAccessBean(String firstName, String lastName,
+      String privateField, int privateGetterField, String xmlElem,
+      String transientField) {
+    this.firstName = firstName;
+    this.lastName = lastName;
+    this.privateField = privateField;
+    this.privateGetterField = privateGetterField;
+    this.xmlElem = xmlElem;
+    this.transientField = transientField;
+  }
+
+  public int getPrivateGetterField() {
+    return privateGetterField;
+  }
+
+  @XmlElement(name = "field")
+  public String getPrivateField() {
+    return privateField;
+  }
+
+  public String getFirstName() {
+    return firstName;
+  }
+
+  @XmlTransient
+  public String getTransientField() {
+    return transientField;
+  }
+}
+
+// default ( public memeber )
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement(name = "test")
+class NoneAccessBean {
+  @XmlElement
+  private String firstName;
+  public String lastName;
+  private String testField;
+
+  public NoneAccessBean() {
+  }
+
+  public NoneAccessBean(String firstName, String lastName, String testField) {
+    this.firstName = firstName;
+    this.lastName = lastName;
+    this.testField = testField;
+  }
+
+  @XmlElement(name = "testField")
+  public String getTestField() {
+    return testField;
+  }
+
+  public String getFirstName() {
+    return firstName;
+  }
+}
similarity index 61%
rename from opendaylight/md-sal/remoterpc-routingtable/integrationtest/src/test/resources/logback.xml
rename to opendaylight/northbound/commons/src/test/resources/logback.xml
index 6d9dfda9a365f9a08f9d4ba5b7733f2cb6340ba6..97e15deb944b4093fbb3a52e225b4a8e34fa0cae 100644 (file)
@@ -1,11 +1,15 @@
 <configuration scan="true">
+
   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
     <encoder>
-      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+      <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
       </pattern>
     </encoder>
   </appender>
 
+
+  <logger name="org.opendaylight.controller.northbound.commons.query" level="INFO"/>
+
   <root level="error">
     <appender-ref ref="STDOUT" />
   </root>
index a0940e34284833673913654600ef50a81908b9b8..ad315ac008e78e78712fc6bbc7a6f74e8b12b7b3 100644 (file)
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.sal.authorization,
               org.opendaylight.controller.connectionmanager,
               org.opendaylight.controller.sal.connection,
               org.slf4j,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind.annotation,
               javax.xml.bind,
index e2c1b32c4bf3ab129604d3e66763b3913f0f03d2..dde3210928689278af7d7f2e3103b0e78c114b47 100644 (file)
@@ -27,6 +27,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -36,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.connection.ConnectionConstants;
@@ -50,7 +52,14 @@ import org.opendaylight.controller.sal.utils.Status;
 @Path("/")
 public class ConnectionManagerNorthbound {
     private String username;
+    private QueryContext queryContext;
 
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
     @Context
     public void setSecurityContext(SecurityContext context) {
         if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
@@ -115,7 +124,8 @@ public class ConnectionManagerNorthbound {
         @ResponseCode(code = 406, condition = "Invalid Controller IP Address passed."),
         @ResponseCode(code = 503, condition = "Connection Manager Service not available")})
 
-    public Nodes getNodes(@DefaultValue("") @QueryParam("controller") String controllerAddress) {
+    public Nodes getNodes(@DefaultValue("") @QueryParam("controller") String controllerAddress,
+        @QueryParam("_q") String queryString) {
         if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container");
         }
@@ -140,7 +150,12 @@ public class ConnectionManagerNorthbound {
         } else {
             nodeSet = connectionManager.getLocalNodes();
         }
-        return new Nodes(nodeSet);
+        Nodes nodes = new Nodes(nodeSet);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, Nodes.class)
+                .filter(nodes, Node.class);
+        }
+        return nodes;
     }
 
     /**
index 457b1bd6a40c714e8b7dbd7f94d837f07c51d8d4..2e6bb7d40ca0d5245200699822198b8d9ba1c697 100644 (file)
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               com.sun.jersey.spi.container.servlet,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind.annotation,
               javax.xml.bind,
index fe38361cca246465bf514686b0beb872e72dd9f5..754167814d763555ede965c5de8c6ee867f5c9f5 100644 (file)
@@ -21,11 +21,13 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -41,6 +43,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict
 import org.opendaylight.controller.northbound.commons.exception.ResourceForbiddenException;
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.authorization.UserLevel;
@@ -68,6 +71,14 @@ import org.opendaylight.controller.usermanager.IUserManager;
 @Path("/")
 public class ContainerManagerNorthbound {
     private String username;
+    private QueryContext queryContext;
+
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
 
     @Context
     public void setSecurityContext(SecurityContext context) {
@@ -172,13 +183,18 @@ public class ContainerManagerNorthbound {
     @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"),
             @ResponseCode(code = 401, condition = "User is not authorized to perform this operation"),
             @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public ContainerConfigs viewAllContainers() {
+    public ContainerConfigs viewAllContainers(@QueryParam("_q") String queryString) {
 
         handleNetworkAuthorization(getUserName());
 
         IContainerManager containerManager = getContainerManager();
-
-        return new ContainerConfigs(containerManager.getContainerConfigList());
+        ContainerConfigs result = new ContainerConfigs(
+                containerManager.getContainerConfigList());
+        if (queryString != null) {
+            queryContext.createQuery(queryString, ContainerConfigs.class)
+                .filter(result, ContainerConfig.class);
+        }
+        return result;
     }
 
     /**
@@ -481,7 +497,8 @@ public class ContainerManagerNorthbound {
     @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"),
             @ResponseCode(code = 404, condition = "The container is not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public FlowSpecConfigs viewContainerFlowSpecs(@PathParam(value = "container") String container) {
+    public FlowSpecConfigs viewContainerFlowSpecs(@PathParam(value = "container") String container,
+        @QueryParam("_q") String queryString) {
 
         handleContainerAuthorization(container, getUserName());
         handleForbiddenOnDefault(container);
@@ -489,8 +506,13 @@ public class ContainerManagerNorthbound {
         handleContainerNotExists(container);
 
         IContainerManager containerManager = getContainerManager();
-
-        return new FlowSpecConfigs(containerManager.getContainerFlows(container));
+        FlowSpecConfigs result = new FlowSpecConfigs(
+                containerManager.getContainerFlows(container));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, FlowSpecConfigs.class)
+                .filter(result, ContainerFlowConfig.class);
+        }
+        return result;
     }
 
     /**
index b9d2200180dbd858c17624dbaa7b2bd8e0c97038..db3d543a69d9d948e77f67fe8bd68a76fb797fd7 100644 (file)
@@ -11,8 +11,11 @@ package org.opendaylight.controller.containermanager.northbound;
 
 import java.util.HashSet;
 import java.util.Set;
+
 import javax.ws.rs.core.Application;
 
+import org.opendaylight.controller.northbound.commons.query.QueryContextProvider;
+
 import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 
 /**
@@ -28,6 +31,7 @@ public class ContainerManagerNorthboundRSApplication extends Application {
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(ContainerManagerNorthbound.class);
         classes.add(JacksonJaxbJsonProvider.class);
+        classes.add(QueryContextProvider.class);
         return classes;
     }
 }
index 07d34cb6d4ee7e20ff48c387d8275687837c445e..89d2b99cadb7b89409a11fb600638edd8897ed2d 100644 (file)
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.sal.authorization,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind.annotation,
               javax.xml.bind,
index 003f8b3b95df37b465ad04caf487181614511ddc..aaf93d1f4bacb0c73ace34595121f6641ce33323 100644 (file)
@@ -25,6 +25,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -36,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.BadRequestExcept
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Property;
@@ -55,6 +57,14 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
 public class ControllerManagerNorthbound {
 
     private String username;
+    private QueryContext queryContext;
+
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
 
     @Context
     public void setSecurityContext(SecurityContext context) {
@@ -122,7 +132,8 @@ public class ControllerManagerNorthbound {
             @ResponseCode(code = 404, condition = "The containerName or property is not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public ControllerProperties getControllerProperties(@PathParam("containerName") String containerName,
-            @QueryParam("propertyName") String propertyName) {
+            @QueryParam("propertyName") String propertyName,
+            @QueryParam("_q") String queryString) {
 
         if (!isValidContainer(containerName)) {
             throw new ResourceNotFoundException("Container " + containerName + " does not exist.");
@@ -147,8 +158,12 @@ public class ControllerManagerNorthbound {
             throw new ResourceNotFoundException("Unable to find property with name: " + propertyName);
         }
         properties.add(property);
-
-        return new ControllerProperties(properties);
+        ControllerProperties result = new ControllerProperties(properties);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, ControllerProperties.class)
+                .filter(result, Property.class);
+        }
+        return result;
 
     }
 
index 205b68a91c9859055d51aa0d043b6ce42abd6dd9..43797f5c6558d84cca3f256d6f2bbdcf4f380407 100644 (file)
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.sal.authorization,
               org.opendaylight.controller.usermanager,
               com.sun.jersey.spi.container.servlet,
               org.apache.catalina.filters,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind.annotation,
               javax.xml.bind,
index 4928ddef3b0296b8525531791dfe4272064dfaa1..42bd59ea4577ff5c6d40b3ad4e8efaa976c900f5 100644 (file)
@@ -19,10 +19,12 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -37,6 +39,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
@@ -62,6 +65,14 @@ public class FlowProgrammerNorthbound {
 
     private String username;
 
+    private QueryContext queryContext;
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
+
     @Context
     public void setSecurityContext(SecurityContext context) {
         if (context != null && context.getUserPrincipal() != null) {
@@ -194,15 +205,21 @@ public class FlowProgrammerNorthbound {
     @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"),
         @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
         @ResponseCode(code = 404, condition = "The containerName is not found"),
-        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public FlowConfigs getStaticFlows(@PathParam("containerName") String containerName) {
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable"),
+        @ResponseCode(code = 400, condition = "Incorrect query syntex")})
+    public FlowConfigs getStaticFlows(@PathParam("containerName") String containerName,
+                   @QueryParam("_q") String queryString) {
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
                     + containerName);
         }
 
-        List<FlowConfig> flowConfigs = getStaticFlowsInternal(containerName, null);
-        return new FlowConfigs(flowConfigs);
+        FlowConfigs result = new FlowConfigs(getStaticFlowsInternal(containerName, null));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, FlowConfigs.class)
+                .filter(result, FlowConfig.class);
+        }
+        return result;
     }
 
     /**
@@ -272,7 +289,8 @@ public class FlowProgrammerNorthbound {
         @ResponseCode(code = 404, condition = "The containerName or nodeId is not found"),
         @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public FlowConfigs getStaticFlows(@PathParam("containerName") String containerName,
-            @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId) {
+            @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
+            @QueryParam("_q") String queryString) {
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
                     + containerName);
@@ -281,8 +299,12 @@ public class FlowProgrammerNorthbound {
         if (node == null) {
             throw new ResourceNotFoundException(nodeId + " : " + RestMessages.NONODE.toString());
         }
-        List<FlowConfig> flows = getStaticFlowsInternal(containerName, node);
-        return new FlowConfigs(flows);
+        FlowConfigs flows = new FlowConfigs(getStaticFlowsInternal(containerName, node));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, FlowConfigs.class)
+                .filter(flows, FlowConfig.class);
+        }
+        return flows;
     }
 
     /**
index bf1b082cfef7eecb48f4c8861eebbd0b97b74e39..c8415f8b4f77cc63496d3a8abaa5abe0810da9b4 100644 (file)
               com.sun.jersey.spi.container.servlet,
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.northbound.commons.utils,
               org.opendaylight.controller.sal.authorization,
               org.opendaylight.controller.sal.packet.address,
               javax.ws.rs,
               javax.ws.rs.core,
+              javax.ws.rs.ext,
               javax.xml.bind.annotation,
               javax.xml.bind,
               org.slf4j,
index 74c13d11f129943ba45e449411adfbc9f09d41e3..d7579c82e10bdd378dd603bfee9c4fde1d0ad414 100644 (file)
@@ -21,11 +21,13 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -39,6 +41,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
@@ -69,6 +72,14 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
 public class HostTrackerNorthbound {
 
     private String username;
+    private QueryContext queryContext;
+
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
 
     @Context
     public void setSecurityContext(SecurityContext context) {
@@ -107,7 +118,7 @@ public class HostTrackerNorthbound {
         return hostTracker;
     }
 
-    private Hosts convertHosts(Set<HostNodeConnector> hostNodeConnectors) {
+    private Set<HostConfig> convertHosts(Set<HostNodeConnector> hostNodeConnectors) {
         if(hostNodeConnectors == null) {
             return null;
         }
@@ -115,7 +126,7 @@ public class HostTrackerNorthbound {
         for(HostNodeConnector hnc : hostNodeConnectors) {
             hosts.add(HostConfig.convert(hnc));
         }
-        return new Hosts(hosts);
+        return hosts;
     }
 
     /**
@@ -194,14 +205,20 @@ public class HostTrackerNorthbound {
             @ResponseCode(code = 200, condition = "Operation successful"),
             @ResponseCode(code = 404, condition = "The containerName is not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public Hosts getActiveHosts(@PathParam("containerName") String containerName) {
+    public Hosts getActiveHosts(@PathParam("containerName") String containerName,
+        @QueryParam("_q") String queryString) {
 
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
                     + containerName);
         }
         IfIptoHost hostTracker = getIfIpToHostService(containerName);
-        return convertHosts(hostTracker.getAllHosts());
+        Hosts hosts = new Hosts(convertHosts(hostTracker.getAllHosts()));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, Hosts.class)
+                .filter(hosts, HostConfig.class);
+        }
+        return hosts;
     }
 
     /**
@@ -281,13 +298,19 @@ public class HostTrackerNorthbound {
             @ResponseCode(code = 404, condition = "The containerName is not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public Hosts getInactiveHosts(
-            @PathParam("containerName") String containerName) {
+            @PathParam("containerName") String containerName,
+            @QueryParam("_q") String queryString) {
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
                     + containerName);
         }
         IfIptoHost hostTracker = getIfIpToHostService(containerName);
-        return convertHosts(hostTracker.getInactiveStaticHosts());
+        Hosts hosts = new Hosts(convertHosts(hostTracker.getInactiveStaticHosts()));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, Hosts.class)
+                .filter(hosts, HostConfig.class);
+        }
+        return hosts;
     }
 
     /**
index dd2a2e6223bb5ab19d776fa71093ad70e89d2bc3..83f8191e025e1c4d23d3bd8673f2ed0046ff9408 100644 (file)
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.sal.authorization,
               org.slf4j,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind.annotation,
               javax.xml.bind,
index e765af524d5a6e215531bc7682a644b3d277339c..20f6cb40a56cb812fa5370a5dd01cc6bf2ef85e8 100644 (file)
@@ -19,11 +19,13 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -37,6 +39,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc
 import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
@@ -74,6 +77,14 @@ import org.opendaylight.controller.sal.utils.Status;
 public class StaticRoutingNorthbound {
 
     private String username;
+    private QueryContext queryContext;
+
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
 
     @Context
     public void setSecurityContext(SecurityContext context) {
@@ -148,7 +159,8 @@ public class StaticRoutingNorthbound {
             @ResponseCode(code = 200, condition = "Operation successful"),
             @ResponseCode(code = 404, condition = "The containerName passed was not found") })
     public StaticRoutes getStaticRoutes(
-            @PathParam("containerName") String containerName) {
+            @PathParam("containerName") String containerName,
+            @QueryParam("_q") String queryString) {
 
         if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
                 Privilege.WRITE, this)){
@@ -156,7 +168,12 @@ public class StaticRoutingNorthbound {
                 UnauthorizedException("User is not authorized to perform this operation on container "
                             + containerName);
         }
-        return new StaticRoutes(getStaticRoutesInternal(containerName));
+        StaticRoutes result = new StaticRoutes(getStaticRoutesInternal(containerName));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, StaticRoutes.class)
+                .filter(result, StaticRoute.class);
+        }
+        return result;
     }
 
     /**
index 76ce062424b32568f9838e8ab05476ace1201439..7e2919bc44c1a7f698f2afe77c31d3347de3fc4a 100644 (file)
@@ -64,7 +64,9 @@
                 org.opendaylight.controller.northbound.commons,
                 org.opendaylight.controller.northbound.commons.exception,
                 org.opendaylight.controller.northbound.commons.utils,
+                org.opendaylight.controller.northbound.commons.query,
                 javax.ws.rs,
+                javax.ws.rs.ext,
                 javax.ws.rs.core,
                 javax.xml.bind.annotation,
                 javax.xml.bind,
index 5338849a62626ed740c6d930d72064efa1dca4d2..4175f1e3c49984c7d90ac03b2207df946c9f7e3a 100644 (file)
@@ -15,9 +15,11 @@ import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -29,6 +31,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
@@ -57,7 +60,14 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
 public class StatisticsNorthbound {
 
     private String username;
+    private QueryContext queryContext;
 
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
     @Context
     public void setSecurityContext(SecurityContext context) {
         if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
@@ -234,7 +244,8 @@ public class StatisticsNorthbound {
         @ResponseCode(code = 404, condition = "The containerName is not found"),
         @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public AllFlowStatistics getFlowStatistics(
-            @PathParam("containerName") String containerName) {
+            @PathParam("containerName") String containerName,
+            @QueryParam("_q") String queryString) {
         if (!NorthboundUtils.isAuthorized(
                 getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException(
@@ -265,7 +276,12 @@ public class StatisticsNorthbound {
             FlowStatistics stat = new FlowStatistics(node, flowStats);
             statistics.add(stat);
         }
-        return new AllFlowStatistics(statistics);
+        AllFlowStatistics result = new AllFlowStatistics(statistics);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, AllFlowStatistics.class)
+                .filter(result, FlowStatistics.class);
+        }
+        return result;
     }
 
     /**
@@ -610,7 +626,8 @@ public class StatisticsNorthbound {
         @ResponseCode(code = 404, condition = "The containerName is not found"),
         @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public AllPortStatistics getPortStatistics(
-            @PathParam("containerName") String containerName) {
+            @PathParam("containerName") String containerName,
+            @QueryParam("_q") String queryString) {
 
         if (!NorthboundUtils.isAuthorized(
                 getUserName(), containerName, Privilege.READ, this)) {
@@ -638,7 +655,13 @@ public class StatisticsNorthbound {
             PortStatistics portStat = new PortStatistics(node, stat);
             statistics.add(portStat);
         }
-        return new AllPortStatistics(statistics);
+
+        AllPortStatistics result = new AllPortStatistics(statistics);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, AllPortStatistics.class)
+                .filter(result, PortStatistics.class);
+        }
+        return result;
     }
 
     /**
@@ -924,7 +947,8 @@ public class StatisticsNorthbound {
         @ResponseCode(code = 404, condition = "The containerName is not found"),
         @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
     public AllTableStatistics getTableStatistics(
-            @PathParam("containerName") String containerName) {
+            @PathParam("containerName") String containerName,
+            @QueryParam("_q") String queryString) {
 
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
@@ -952,7 +976,12 @@ public class StatisticsNorthbound {
             TableStatistics tableStat = new TableStatistics(node, stat);
             statistics.add(tableStat);
         }
-        return new AllTableStatistics(statistics);
+        AllTableStatistics allstats = new AllTableStatistics(statistics);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, AllTableStatistics.class)
+                .filter(allstats, TableStatistics.class);
+        }
+        return allstats;
     }
 
     /**
index 5aa2f7f202a00c30eff3937d0f7bb34efb76cf0c..630221fcc2dac2b0c53a945cbeaf41ef63c9a1cd 100644 (file)
               org.opendaylight.controller.switchmanager,
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.northbound.commons.utils,
               com.sun.jersey.spi.container.servlet,
               org.opendaylight.controller.sal.authorization,
               org.opendaylight.controller.usermanager,
               javax.ws.rs,
               javax.ws.rs.core,
+              javax.ws.rs.ext,
               javax.xml.bind,
               javax.xml.bind.annotation,
               org.slf4j,
index 3465dc95addd727ade9243e3410208cc7735ec40..b6274795df9279275e1b1d7e145aa2fa3055914b 100644 (file)
@@ -19,11 +19,13 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -35,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -63,6 +66,14 @@ public class SubnetsNorthbound {
     protected static final Logger logger = LoggerFactory.getLogger(SubnetsNorthbound.class);
 
     private String username;
+    private QueryContext queryContext;
+
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
 
     @Context
     public void setSecurityContext(SecurityContext context) {
@@ -160,9 +171,11 @@ public class SubnetsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
         @ResponseCode(code = 404, condition = "The containerName passed was not found"),
-        @ResponseCode(code = 503, condition = "Service unavailable") })
+        @ResponseCode(code = 503, condition = "Service unavailable"),
+        @ResponseCode(code = 400, condition = "Incorrect query syntex") })
     @TypeHint(SubnetConfigs.class)
-    public SubnetConfigs listSubnets(@PathParam("containerName") String containerName) {
+    public SubnetConfigs listSubnets(@PathParam("containerName") String containerName,
+        @QueryParam("_q") String queryString) {
 
         handleContainerDoesNotExist(containerName);
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
@@ -174,7 +187,13 @@ public class SubnetsNorthbound {
         if (switchManager == null) {
             throw new ServiceUnavailableException("SwitchManager " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
-        return new SubnetConfigs(switchManager.getSubnetsConfigList());
+        List<SubnetConfig> subnets = switchManager.getSubnetsConfigList();
+        if (queryString != null) {
+            subnets = queryContext.createQuery(queryString, SubnetConfig.class)
+                    .find(subnets);
+
+        }
+        return new SubnetConfigs(subnets);
     }
 
     /**
index 590f0bb533dbf610990fb4082a10f8b220a86023..614ec8847658d87800de3f6319c076357020d269 100644 (file)
@@ -58,7 +58,9 @@
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
               org.opendaylight.controller.sal.authorization,
+              org.opendaylight.controller.northbound.commons.query,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind.annotation,
               javax.xml.bind,
index e30dad24ab18866b1c455a8facf7bf347a0d22b2..dab5d7d1b26785b6f2564d1d0ebb3fbecda861e5 100644 (file)
@@ -23,11 +23,13 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -38,6 +40,7 @@ import org.opendaylight.controller.northbound.commons.exception.InternalServerEr
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
@@ -60,6 +63,14 @@ import org.opendaylight.controller.switchmanager.SwitchConfig;
 public class SwitchNorthbound {
 
     private String username;
+    private QueryContext queryContext;
+
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
 
     @Context
     public void setSecurityContext(SecurityContext context) {
@@ -200,8 +211,9 @@ public class SwitchNorthbound {
     @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"),
         @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
         @ResponseCode(code = 404, condition = "The containerName is not found"),
-        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public Nodes getNodes(@PathParam("containerName") String containerName) {
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable"),
+        @ResponseCode(code = 400, condition = "Incorrect query syntex") })
+    public Nodes getNodes(@PathParam("containerName") String containerName, @QueryParam("_q") String queryString) {
 
         if (!isValidContainer(containerName)) {
             throw new ResourceNotFoundException("Container " + containerName + " does not exist.");
@@ -233,8 +245,12 @@ public class SwitchNorthbound {
             NodeProperties nodeProps = new NodeProperties(node, props);
             res.add(nodeProps);
         }
-
-        return new Nodes(res);
+        Nodes result = new Nodes(res);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, Nodes.class)
+                .filter(result, NodeProperties.class);
+        }
+        return result;
     }
 
     /**
@@ -564,9 +580,11 @@ public class SwitchNorthbound {
     @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"),
         @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
         @ResponseCode(code = 404, condition = "The containerName is not found"),
-        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable"),
+        @ResponseCode(code = 400, condition = "Incorrect query syntex") })
     public NodeConnectors getNodeConnectors(@PathParam("containerName") String containerName,
-            @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId) {
+            @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
+            @QueryParam("_q") String queryString) {
 
         if (!isValidContainer(containerName)) {
             throw new ResourceNotFoundException("Container " + containerName + " does not exist.");
@@ -598,8 +616,12 @@ public class SwitchNorthbound {
             NodeConnectorProperties ncProps = new NodeConnectorProperties(nc, props);
             res.add(ncProps);
         }
-
-        return new NodeConnectors(res);
+        NodeConnectors result = new NodeConnectors(res);
+        if (queryString != null) {
+            queryContext.createQuery(queryString, NodeConnectors.class)
+                .filter(result, NodeConnectorProperties.class);
+        }
+        return result;
     }
 
     /**
index 4a1142bb1813784fd7b5108a807ac9fde26bc6c5..3f1a7701102467edf00dd974c254407728049176 100644 (file)
@@ -51,6 +51,7 @@
               org.opendaylight.controller.northbound.commons,
               org.opendaylight.controller.northbound.commons.exception,
               org.opendaylight.controller.northbound.commons.utils,
+              org.opendaylight.controller.northbound.commons.query,
               org.opendaylight.controller.sal.core,
               org.opendaylight.controller.sal.packet,
               org.opendaylight.controller.sal.authorization,
@@ -62,6 +63,7 @@
               com.sun.jersey.spi.container.servlet,
               com.fasterxml.jackson.annotation,
               javax.ws.rs,
+              javax.ws.rs.ext,
               javax.ws.rs.core,
               javax.xml.bind,
               javax.xml.bind.annotation,
index 427aa1c1deaaf98c86fa3ecd072757bc6331892c..3773070504a0fa4be1e107e422793b52085217d2 100644 (file)
@@ -21,10 +21,12 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.ext.ContextResolver;
 
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
@@ -33,6 +35,7 @@ import org.opendaylight.controller.northbound.commons.RestMessages;
 import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Edge;
@@ -59,7 +62,14 @@ import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig;
 public class TopologyNorthboundJAXRS {
 
     private String username;
+    private QueryContext queryContext;
 
+    @Context
+    public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+      if (queryCtxResolver != null) {
+        queryContext = queryCtxResolver.getContext(QueryContext.class);
+      }
+    }
     @Context
     public void setSecurityContext(SecurityContext context) {
         if (context != null && context.getUserPrincipal() != null) {
@@ -240,7 +250,8 @@ public class TopologyNorthboundJAXRS {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(Topology.class)
     @StatusCodes({ @ResponseCode(code = 404, condition = "The Container Name was not found") })
-    public Topology getTopology(@PathParam("containerName") String containerName) {
+    public Topology getTopology(@PathParam("containerName") String containerName,
+        @QueryParam("_q") String queryString) {
 
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
@@ -253,16 +264,21 @@ public class TopologyNorthboundJAXRS {
         }
 
         Map<Edge, Set<Property>> topo = topologyManager.getEdges();
-        if (topo != null) {
-            List<EdgeProperties> res = new ArrayList<EdgeProperties>();
-            for (Map.Entry<Edge, Set<Property>> entry : topo.entrySet()) {
-                EdgeProperties el = new EdgeProperties(entry.getKey(), entry.getValue());
-                res.add(el);
-            }
-            return new Topology(res);
+        if (topo == null) {
+            return null;
+        }
+        List<EdgeProperties> res = new ArrayList<EdgeProperties>();
+        for (Map.Entry<Edge, Set<Property>> entry : topo.entrySet()) {
+            EdgeProperties el = new EdgeProperties(entry.getKey(), entry.getValue());
+            res.add(el);
         }
+        Topology result = new Topology(res);
 
-        return null;
+        if (queryString != null) {
+            queryContext.createQuery(queryString, Topology.class)
+                .filter(result, EdgeProperties.class);
+        }
+        return result;
     }
 
     /**
@@ -311,7 +327,8 @@ public class TopologyNorthboundJAXRS {
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(TopologyUserLinks.class)
     @StatusCodes({ @ResponseCode(code = 404, condition = "The Container Name was not found") })
-    public TopologyUserLinks getUserLinks(@PathParam("containerName") String containerName) {
+    public TopologyUserLinks getUserLinks(@PathParam("containerName") String containerName,
+        @QueryParam("_q") String queryString) {
 
         if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException("User is not authorized to perform this operation on container "
@@ -324,12 +341,16 @@ public class TopologyNorthboundJAXRS {
         }
 
         ConcurrentMap<String, TopologyUserLinkConfig> userLinks = topologyManager.getUserLinks();
-        if ((userLinks != null) && (userLinks.values() != null)) {
-            List<TopologyUserLinkConfig> res = new ArrayList<TopologyUserLinkConfig>(userLinks.values());
-            return new TopologyUserLinks(res);
+        if ((userLinks == null) || (userLinks.values() == null)) {
+            return null;
         }
-
-        return null;
+        TopologyUserLinks result = new TopologyUserLinks(
+                new ArrayList<TopologyUserLinkConfig>(userLinks.values()));
+        if (queryString != null) {
+            queryContext.createQuery(queryString, TopologyUserLinks.class)
+                .filter(result, TopologyUserLinkConfig.class);
+        }
+        return result;
     }
 
     /**
index 5c2af6d8b430471d25f68a68c25e8915c9d02e97..932ac4e20be37f8d5ea1234265054209ceda120f 100644 (file)
@@ -32,11 +32,15 @@ import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.packet.Ethernet;
 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
+import org.opendaylight.controller.sal.packet.PacketException;
 import org.opendaylight.controller.sal.packet.PacketResult;
 import org.opendaylight.controller.sal.packet.RawPacket;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.HexEncode;
+import org.opendaylight.controller.sal.utils.NetUtils;
 import org.openflow.protocol.OFMessage;
 import org.openflow.protocol.OFPacketIn;
 import org.openflow.protocol.OFPacketOut;
@@ -169,12 +173,10 @@ public class DataPacketMuxDemux implements IContainerListener,
 
     @Override
     public void receive(ISwitch sw, OFMessage msg) {
-        if (sw == null || msg == null
-                || this.pluginOutDataPacketServices == null) {
+        if (sw == null || msg == null || this.pluginOutDataPacketServices == null) {
             // Something fishy, we cannot do anything
-            logger.debug(
-                    "sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!",
-                    new Object[] { sw, msg, this.pluginOutDataPacketServices });
+            logger.debug("sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!", new Object[] { sw,
+                    msg, this.pluginOutDataPacketServices });
             return;
         }
 
@@ -185,8 +187,7 @@ public class DataPacketMuxDemux implements IContainerListener,
                 logger.debug("Connection service refused DataPacketMuxDemux receive {} {}", sw, msg);
                 return;
             }
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return;
         }
 
@@ -204,63 +205,72 @@ public class DataPacketMuxDemux implements IContainerListener,
                 // pass the parsed packet simply because once the
                 // packet infra is settled all the packets will passed
                 // around as parsed and read-only
-                for (int i = 0; i < this.iDataPacketListen.size(); i++) {
-                    IDataPacketListen s = this.iDataPacketListen.get(i);
-                    if (s.receiveDataPacket(dataPacket).equals(
-                            PacketResult.CONSUME)) {
+                for (IDataPacketListen s : this.iDataPacketListen) {
+                      if (s.receiveDataPacket(dataPacket).equals(PacketResult.CONSUME)) {
                         logger.trace("Consumed locally data packet");
                         return;
                     }
                 }
 
-                // Now dispatch the packet toward SAL at least for
-                // default container, we need to revisit this in a general
-                // slicing architecture refresh
-                IPluginOutDataPacketService defaultOutService = this.pluginOutDataPacketServices
-                        .get(GlobalConstants.DEFAULT.toString());
-                if (defaultOutService != null) {
-                    defaultOutService.receiveDataPacket(dataPacket);
-                    if (logger.isTraceEnabled()) {
-                      logger.trace(
-                              "Dispatched to apps a frame of size: {} on " +
-                              "container: {}: {}", new Object[] {
-                                    ofPacket.getPacketData().length,
-                                    GlobalConstants.DEFAULT.toString(),
-                                    HexEncode.bytesToHexString(dataPacket
-                                            .getPacketData()) });
-                    }
-                }
+                boolean dispatched_to_container = false;
+
                 // Now check the mapping between nodeConnector and
                 // Container and later on optimally filter based on
                 // flowSpec
                 List<String> containersRX = this.nc2Container.get(p);
                 if (containersRX != null) {
-                    for (int i = 0; i < containersRX.size(); i++) {
-                        String container = containersRX.get(i);
-                        IPluginOutDataPacketService s = this.pluginOutDataPacketServices
-                                .get(container);
-                        if (s != null) {
-                            // TODO add filtering on a per-flowSpec base
-                            s.receiveDataPacket(dataPacket);
-                            if (logger.isTraceEnabled()) {
-                              logger.trace(
-                                      "Dispatched to apps a frame of size: {}" +
-                                      " on container: {}: {}", new Object[] {
-                                            ofPacket.getPacketData().length,
-                                            container,
-                                            HexEncode.bytesToHexString(dataPacket
-                                                    .getPacketData()) });
+                    Ethernet frame = new Ethernet();
+                    byte data[] = dataPacket.getPacketData();
+                    frame.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte);
+                    Match packetMatch = frame.getMatch();
+                    for (String container : containersRX) {
+                        boolean notify = true;
+                        List<ContainerFlow> containerFlows = this.container2FlowSpecs.get(container);
+                        if (containerFlows != null) {
+                            notify = false;
+                            for (ContainerFlow cFlow : containerFlows) {
+                                if (cFlow.allowsMatch(packetMatch)) {
+                                    notify = true;
+                                    break;
+                                }
+                            }
+                            if (notify) {
+                                IPluginOutDataPacketService s = this.pluginOutDataPacketServices.get(container);
+                                if (s != null) {
+                                    s.receiveDataPacket(dataPacket);
+                                    if (logger.isTraceEnabled()) {
+                                        logger.trace(
+                                                "Dispatched to apps a frame of size: {}" + " on container: {}: {}",
+                                                new Object[] { ofPacket.getPacketData().length, container,
+                                                        HexEncode.bytesToHexString(dataPacket.getPacketData()) });
+                                    }
+                                }
+                                dispatched_to_container = true;
                             }
                         }
                     }
                 }
-
+                if (!dispatched_to_container) {
+                    // Now dispatch the packet toward SAL for default container
+                    IPluginOutDataPacketService defaultOutService = this.pluginOutDataPacketServices
+                        .get(GlobalConstants.DEFAULT.toString());
+                    if (defaultOutService != null) {
+                        defaultOutService.receiveDataPacket(dataPacket);
+                        if (logger.isTraceEnabled()) {
+                            logger.trace("Dispatched to apps a frame of size: {} on " + "container: {}: {}",
+                                         new Object[] { ofPacket.getPacketData().length,
+                                                        GlobalConstants.DEFAULT.toString(),
+                                                        HexEncode.bytesToHexString(dataPacket.getPacketData()) });
+                        }
+                    }
+                }
                 // This is supposed to be the catch all for all the
                 // DataPacket hence we will assume it has been handled
                 return;
             } catch (ConstructionException cex) {
+            } catch (PacketException e) {
+                logger.debug("Failed to deserialize raw packet: ", e.getMessage());
             }
-
             // If we reach this point something went wrong.
             return;
         } else {
index 8fc0d625ebe0dd5b08bff4df864efe6a2e3068bd..21c17b366c04c025683b5c032981f043428e326a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -258,18 +258,23 @@ public class ARP extends Packet {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (!super.equals(obj))
+        }
+        if (!super.equals(obj)) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         ARP other = (ARP) obj;
         if (fieldValues == null) {
-            if (other.fieldValues != null)
+            if (other.fieldValues != null) {
                 return false;
-        } else if (!fieldValues.equals(other.fieldValues))
+            }
+        } else if (!fieldValues.equals(other.fieldValues)) {
             return false;
+        }
         return true;
     }
 }
index d0068564a93b29a326395b1e6cae9eeacf968a53..235e71a760faa01eb9cf9d2acf92a73c8acf00ce 100644 (file)
@@ -15,6 +15,8 @@ import java.util.Map;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.NetUtils;
 
@@ -139,4 +141,10 @@ public class Ethernet extends Packet {
         return this;
     }
 
+    @Override
+    public void populateMatch(Match match) {
+        match.setField(MatchType.DL_SRC, this.getSourceMACAddress());
+        match.setField(MatchType.DL_DST, this.getDestinationMACAddress());
+        match.setField(MatchType.DL_TYPE, this.getEtherType());
+    }
 }
index 39c7d386bc1fe3ccf5ff397ebfcc491fe108aad6..9825d0eefb791098bf1724d5996c44f881c0da6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -13,6 +13,8 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 
 /**
  * Class that represents the IEEE 802.1Q objects
@@ -148,4 +150,10 @@ public class IEEE8021Q extends Packet {
         return this;
     }
 
+    @Override
+    public void populateMatch(Match match) {
+        match.setField(MatchType.DL_VLAN, this.getVid());
+        match.setField(MatchType.DL_VLAN_PR, this.getPcp());
+        match.setField(MatchType.DL_TYPE, this.getEtherType());
+    }
 }
index 559acd633ab7e56b6cb22042f7d3974a1e217212..3363f423d695f1b2f090e6c5274715f47d765e3c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -20,6 +20,8 @@ import java.util.Random;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NetUtils;
 import org.slf4j.Logger;
@@ -577,4 +579,12 @@ public class IPv4 extends Packet {
             corrupted = true;
         }
     }
+
+    @Override
+    public void populateMatch(Match match) {
+        match.setField(MatchType.NW_SRC, NetUtils.getInetAddress(this.getSourceAddress()));
+        match.setField(MatchType.NW_DST, NetUtils.getInetAddress(this.getDestinationAddress()));
+        match.setField(MatchType.NW_PROTO, this.getProtocol());
+        match.setField(MatchType.NW_TOS, this.getDiffServ());
+    }
 }
index 6f5cf04a529ed5a2872ff1d7c299eac71a1e060a..9b5dc082bb2303084775026131a11552b5614add 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.opendaylight.controller.sal.utils.NetUtils;
 
index efb938e37f50745aae8f1f560b0d85f2bb7e7c07..35244ea697d871617b09db6e232da95af0d51ebf 100644 (file)
@@ -151,18 +151,23 @@ public class LLDPTLV extends Packet {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (!super.equals(obj))
+        }
+        if (!super.equals(obj)) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         LLDPTLV other = (LLDPTLV) obj;
         if (fieldValues == null) {
-            if (other.fieldValues != null)
+            if (other.fieldValues != null) {
                 return false;
-        } else if (!fieldValues.equals(other.fieldValues))
+            }
+        } else if (!fieldValues.equals(other.fieldValues)) {
             return false;
+        }
         return true;
     }
 
index 58b5d3914aa2dc199111dd2f2dc1ff8d5289dcc0..789aa126533c93c16660e5eafcfc995dc510fab1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -13,6 +13,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.opendaylight.controller.sal.utils.NetUtils;
 import org.slf4j.Logger;
@@ -364,4 +365,31 @@ public abstract class Packet {
         return true;
     }
 
+    /**
+     * Adds to the passed Match this packet's header fields
+     *
+     * @param match
+     *            The Match object to populate
+     */
+    public void populateMatch(Match match) {
+        // To be overridden by derived packet classes which have well known
+        // header fields so that Packet.getMatch would return desired result
+    }
+
+    /**
+     * Returns the Match object containing this packet and its payload
+     * encapsulated packets' header fields
+     *
+     * @return The Match containing the header fields of this packet and of its
+     *         payload encapsulated packets
+     */
+    public Match getMatch() {
+        Match match = new Match();
+        Packet packet = this;
+        while (packet != null) {
+            packet.populateMatch(match);
+            packet = packet.getPayload();
+        }
+        return match;
+    }
 }
index 8253ac46d3f5405ace57da8022be90a183645a68..d27494599c280418044e4ef78210678562852cc0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -15,6 +15,8 @@ import java.util.Map;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 
 /**
  * Class that represents the TCP segment objects
@@ -238,4 +240,9 @@ public class TCP extends Packet {
         return (BitBufferHelper.getShort(fieldValues.get(CHECKSUM)));
     }
 
+    @Override
+    public void populateMatch(Match match) {
+        match.setField(MatchType.TP_SRC, this.getSourcePort());
+        match.setField(MatchType.TP_DST, this.getDestinationPort());
+    }
 }
index f82ed8fcaee00115bef01f4a6b03813389bf1a0c..069a277f89d9ee44df2e4ca22d9783fb9b9a6404 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -15,6 +15,8 @@ import java.util.Map;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 
 /**
  * Class that represents the UDP datagram objects
@@ -156,4 +158,10 @@ public class UDP extends Packet {
         fieldValues.put(CHECKSUM, checksum);
         return this;
     }
+
+    @Override
+    public void populateMatch(Match match) {
+        match.setField(MatchType.TP_SRC, this.getSourcePort());
+        match.setField(MatchType.TP_DST, this.getDestinationPort());
+    }
 }
index a3ebd7ee0d164163b18f8091199f63bc89c4e30a..10bd535eb2790a1876fe2f9cfa29afb681b4ed1b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
index 2494eb6b2d459460c0ab825e9b18c0fc15d30029..494dd2abf28c0d0e660debeb6a9936c3c752315a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,9 +9,14 @@
 
 package org.opendaylight.controller.sal.packet;
 
+import java.util.Arrays;
+
 import junit.framework.Assert;
 
 import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
 
 public class EthernetTest {
 
@@ -95,4 +100,22 @@ public class EthernetTest {
 
     }
 
+    @Test
+    public void testGetMatch() throws Exception {
+        Ethernet eth = new Ethernet();
+        byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d };
+        byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 };
+        short ethType = EtherTypes.IPv4.shortValue();
+        eth.setDestinationMACAddress(dmac);
+        eth.setSourceMACAddress(smac);
+        eth.setEtherType(ethType);
+
+        Match match = eth.getMatch();
+
+        Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue()));
+        Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue()));
+        Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue());
+
+    }
+
 }
index a4c6c1fc4b335472d302c655ffd52e1544767e36..2443b491c7e8a7fb69fba50c65681a6bd691f597 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,7 +9,11 @@
 package org.opendaylight.controller.sal.packet;
 
 import junit.framework.Assert;
+
 import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.NetUtils;
 
 public class IEEE8021QTest {
@@ -212,4 +216,21 @@ public class IEEE8021QTest {
         Assert.assertTrue(data[44] == (byte) 0x09);
         Assert.assertTrue(data[45] == (byte) 0xFE);
     }
+
+    @Test
+    public void testGetMatchFullPacket() throws Exception {
+        IEEE8021Q dot1q = new IEEE8021Q();
+        byte priority = 4;
+        short vlanId = 59;
+        short ethType = EtherTypes.IPv4.shortValue();
+        dot1q.setPcp(priority);
+        dot1q.setVid(vlanId);
+        dot1q.setEtherType(ethType);
+
+        Match match = dot1q.getMatch();
+
+        Assert.assertEquals(priority, (byte) match.getField(MatchType.DL_VLAN_PR).getValue());
+        Assert.assertEquals(vlanId, (short) match.getField(MatchType.DL_VLAN).getValue());
+        Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue());
+    }
 }
index 5afcd8be7dc4f47d79270dd00b6c3c8870c07631..f5298711b677a64ef9c80863580743ce2c394e52 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -15,6 +15,8 @@ import java.util.Arrays;
 import junit.framework.Assert;
 
 import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NetUtils;
@@ -452,4 +454,31 @@ public class IPv4Test {
         Assert.assertFalse(decIcmp.isCorrupted());
         Assert.assertTrue(Arrays.equals(icmpRawPayload, decIcmp.getRawPayload()));
     }
+
+    @Test
+    public void testGetMatch() throws Exception {
+        IPv4 ip = new IPv4();
+        InetAddress sourceAddress = InetAddress.getByName("172.168.190.15");
+        InetAddress destintationAddress = InetAddress.getByName("23.128.0.11");
+        byte protocol = IPProtocols.TCP.byteValue();
+        byte tos = 7;
+        ip.setVersion((byte) 4);
+        ip.setIdentification((short) 5);
+        ip.setDiffServ(tos);
+        ip.setECN((byte) 0);
+        ip.setTotalLength((short) 84);
+        ip.setFlags((byte) 2);
+        ip.setFragmentOffset((short) 0);
+        ip.setTtl((byte) 64);
+        ip.setProtocol(protocol);
+        ip.setDestinationAddress(destintationAddress);
+        ip.setSourceAddress(sourceAddress);
+
+        Match match = ip.getMatch();
+
+        Assert.assertEquals(sourceAddress, match.getField(MatchType.NW_SRC).getValue());
+        Assert.assertEquals(destintationAddress, match.getField(MatchType.NW_DST).getValue());
+        Assert.assertEquals(protocol, (byte) match.getField(MatchType.NW_PROTO).getValue());
+        Assert.assertEquals(tos, (byte) match.getField(MatchType.NW_TOS).getValue());
+    }
 }
index 8f3b283b2ea020a175b53e952d08f41cd7ca1c69..95eff32ef1899f39a3838f2f46fea8c0f51923fa 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,11 +9,17 @@
 
 package org.opendaylight.controller.sal.packet;
 
+import java.net.InetAddress;
+import java.util.Arrays;
 import java.util.Map;
 
 import junit.framework.Assert;
 
 import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
+import org.opendaylight.controller.sal.utils.IPProtocols;
 
 public class PacketTest {
 
@@ -120,9 +126,9 @@ public class PacketTest {
         eth.setSourceMACAddress(sMAC);
         eth.setEtherType(etherType);
 
-        dMACdata = (byte[]) fCValues.get("DestinationMACAddress");
-        sMACdata = (byte[]) fCValues.get("SourceMACAddress");
-        etherTypedata = (byte[]) fCValues.get("EtherType");
+        dMACdata = fCValues.get("DestinationMACAddress");
+        sMACdata = fCValues.get("SourceMACAddress");
+        etherTypedata = fCValues.get("EtherType");
 
         Assert.assertTrue(dMACdata[0] == 10);
         Assert.assertTrue(dMACdata[1] == 12);
@@ -160,4 +166,62 @@ public class PacketTest {
         Assert.assertTrue(data[13] == 6);
 
     }
+
+    @Test
+    public void testGetMatch() throws Exception {
+        TCP tcp = new TCP();
+        short sport = (short) 11093;
+        short dport = (short) 23;
+        tcp.setSourcePort(sport);
+        tcp.setDestinationPort(dport);
+
+        IPv4 ip = new IPv4();
+        InetAddress sourceAddress = InetAddress.getByName("192.168.100.100");
+        InetAddress destintationAddress = InetAddress.getByName("192.168.100.101");
+        byte protocol = IPProtocols.TCP.byteValue();
+        byte tos = 5;
+        ip.setVersion((byte) 4);
+        ip.setIdentification((short) 5);
+        ip.setDiffServ(tos);
+        ip.setECN((byte) 0);
+        ip.setTotalLength((short) 84);
+        ip.setFlags((byte) 2);
+        ip.setFragmentOffset((short) 0);
+        ip.setTtl((byte) 64);
+        ip.setProtocol(protocol);
+        ip.setDestinationAddress(destintationAddress);
+        ip.setSourceAddress(sourceAddress);
+        ip.setPayload(tcp);
+
+        IEEE8021Q dot1q = new IEEE8021Q();
+        byte priority = 4;
+        short vlanId = 59;
+        short ethType = EtherTypes.IPv4.shortValue();
+        dot1q.setPcp(priority);
+        dot1q.setVid(vlanId);
+        dot1q.setEtherType(ethType);
+        dot1q.setPayload(ip);
+
+        Ethernet eth = new Ethernet();
+        byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d };
+        byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 };
+        eth.setDestinationMACAddress(dmac);
+        eth.setSourceMACAddress(smac);
+        eth.setEtherType(EtherTypes.VLANTAGGED.shortValue());
+        eth.setPayload(dot1q);
+
+        Match match = eth.getMatch();
+
+        Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue()));
+        Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue()));
+        Assert.assertEquals(priority, (byte) match.getField(MatchType.DL_VLAN_PR).getValue());
+        Assert.assertEquals(vlanId, (short) match.getField(MatchType.DL_VLAN).getValue());
+        Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue());
+        Assert.assertEquals(sourceAddress, match.getField(MatchType.NW_SRC).getValue());
+        Assert.assertEquals(destintationAddress, match.getField(MatchType.NW_DST).getValue());
+        Assert.assertEquals(protocol, (byte) match.getField(MatchType.NW_PROTO).getValue());
+        Assert.assertEquals(tos, (byte) match.getField(MatchType.NW_TOS).getValue());
+        Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue());
+        Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue());
+    }
 }
index 3e18aedfdb38b7238ef9a72c9d49bff151aec685..e56f41e5c1b301cf78eb8e1e5df3f29fcbe1e7e2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -12,6 +12,8 @@ package org.opendaylight.controller.sal.packet;
 import junit.framework.Assert;
 
 import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 
 public class TCPTest {
 
@@ -113,4 +115,18 @@ public class TCPTest {
         short checksum = tcp.getChecksum();
         Assert.assertTrue(checksum == 200);
     }
+
+    @Test
+    public void testGetMatch() throws Exception {
+        TCP tcp = new TCP();
+        short sport = (short) 52012;
+        short dport = (short) 40345;
+        tcp.setSourcePort(sport);
+        tcp.setDestinationPort(dport);
+
+        Match match = tcp.getMatch();
+
+        Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue());
+        Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue());
+    }
 }
index 8d5be849a034d5a147998d7adcf5099481acb552..a3a597a82d0fcb4524da02f174c9ca0419174c81 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -12,6 +12,8 @@ package org.opendaylight.controller.sal.packet;
 import junit.framework.Assert;
 
 import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
 
 public class UDPTest {
 
@@ -95,4 +97,19 @@ public class UDPTest {
 
     }
 
+    @Test
+    public void testGetMatch() throws Exception {
+        UDP udp = new UDP();
+        short sport = (short) 33000;
+        short dport = (short) 843;
+        udp.setSourcePort(sport);
+        udp.setDestinationPort(dport);
+
+        Match match = udp.getMatch();
+
+        Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue());
+        Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue());
+
+    }
+
 }