Merge "Bug 5974: He plugin: Don't invalidate session context that is not valid."
authorAbhijit Kumbhare <abhijit.kumbhare@ericsson.com>
Thu, 23 Jun 2016 07:47:53 +0000 (07:47 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 23 Jun 2016 07:47:53 +0000 (07:47 +0000)
359 files changed:
.gitignore
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticProviderImpl.java [deleted file]
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java
applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModule.java
applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModuleFactory.java
applications/bulk-o-matic/src/main/resources/initial/71-bulk-o-matic.xml
applications/bulk-o-matic/src/main/resources/org/opendaylight/blueprint/bulk-o-matic.xml [new file with mode: 0644]
applications/bulk-o-matic/src/main/yang/bulk-o-matic.yang
applications/features/pom.xml
applications/features/src/main/features/features.xml
applications/forwardingrules-manager-config/pom.xml [deleted file]
applications/forwardingrules-manager-config/src/main/resources/initial/30-forwardingrules-manager.xml [deleted file]
applications/forwardingrules-manager/pom.xml
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModule.java [deleted file]
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModuleFactory.java [deleted file]
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/FlowNodeReconciliation.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerConfig.java [deleted file]
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java
applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml [new file with mode: 0644]
applications/forwardingrules-manager/src/main/yang/forwarding-manager.yang [deleted file]
applications/forwardingrules-manager/src/main/yang/forwardingrules-manager-config.yang [new file with mode: 0644]
applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/util/FRMTest.java
applications/forwardingrules-sync/pom.xml
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SyncPlanPushStrategy.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SyncReactor.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FrmExecutors.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalRetryListener.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureWithCompressionDecorator.java [deleted file]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecorator.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecorator.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SynchronizationDiffInput.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/markandsweep/SwitchFlowId.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ItemSyncBox.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistry.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperGuavaImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ZipQueueEntry.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProviderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/GroupForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalRetryListenerTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecoratorTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/DiffInputFactory.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistryTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperTest.java
applications/inventory-manager/src/main/config/default-config.xml [deleted file]
applications/inventory-manager/src/main/java/org/opendaylight/openflowplugin/applications/inventory/manager/InventoryActivator.java
applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModule.java [deleted file]
applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModuleFactory.java [deleted file]
applications/inventory-manager/src/main/yang/inventory-manager-impl.yang [deleted file]
applications/lldp-speaker/pom.xml
applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeaker.java
applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModule.java [deleted file]
applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModuleFactory.java [deleted file]
applications/lldp-speaker/src/main/resources/initial/71-lldp-speaker.xml [deleted file]
applications/lldp-speaker/src/main/resources/org/opendaylight/blueprint/lldp-speaker.xml [new file with mode: 0644]
applications/lldp-speaker/src/main/yang/lldp-speaker-config.yang [new file with mode: 0644]
applications/lldp-speaker/src/main/yang/lldp-speaker.yang
applications/of-switch-config-pusher/pom.xml
applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java
applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModule.java [deleted file]
applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModuleFactory.java [deleted file]
applications/of-switch-config-pusher/src/main/resources/initial/70-of-switch-config-pusher.xml [deleted file]
applications/of-switch-config-pusher/src/main/resources/org/opendaylight/blueprint/of-switch-config-pusher.xml [new file with mode: 0644]
applications/of-switch-config-pusher/src/main/yang/of-switch-config-pusher.yang [deleted file]
applications/pom.xml
applications/statistics-manager-config/pom.xml [deleted file]
applications/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml [deleted file]
applications/statistics-manager/pom.xml
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModule.java [deleted file]
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModuleFactory.java [deleted file]
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManagerFactory.java [new file with mode: 0644]
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatNodeRegistrationImpl.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerFactoryImpl.java [new file with mode: 0644]
applications/statistics-manager/src/main/resources/org/opendaylight/blueprint/statistics-manager.xml [new file with mode: 0644]
applications/statistics-manager/src/main/yang/statistics-manager-app-config.yang [new file with mode: 0644]
applications/statistics-manager/src/main/yang/statistics-manager.yang [deleted file]
applications/table-miss-enforcer/pom.xml
applications/table-miss-enforcer/src/main/java/org/opendaylight/openflowplugin/applications/tableMissEnforcer/LLDPPacketPuntEnforcer.java
applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModule.java [deleted file]
applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModuleFactory.java [deleted file]
applications/table-miss-enforcer/src/main/resources/initial/69-table-miss-enforcer.xml [deleted file]
applications/table-miss-enforcer/src/main/resources/org/opendaylight/blueprint/table-miss-enforcer.xml [new file with mode: 0644]
applications/table-miss-enforcer/src/main/yang/table-miss-enforcer.yang [deleted file]
applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tableMissEnforcer/LLDPDataChangeListenerTest.java
applications/topology-lldp-discovery/src/main/config/default-config.xml [deleted file]
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryProvider.java [deleted file]
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModule.java [deleted file]
applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java [deleted file]
applications/topology-lldp-discovery/src/main/resources/org/opendaylight/blueprint/topology-lldp-discovery.xml [new file with mode: 0644]
applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-config.yang [new file with mode: 0644]
applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-impl.yang [deleted file]
applications/topology-manager/src/main/config/default-config.xml [deleted file]
applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyProvider.java
applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessor.java
applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModule.java [deleted file]
applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java [deleted file]
applications/topology-manager/src/main/resources/org/opendaylight/blueprint/topology-manager.xml [new file with mode: 0644]
applications/topology-manager/src/main/yang/topology-manager-impl.yang [deleted file]
artifacts/pom.xml
distribution/karaf/pom.xml
drop-test-karaf/pom.xml
drop-test-karaf/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/test/droptest/rev150327/DropTestProviderModule.java [deleted file]
drop-test-karaf/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/test/droptest/rev150327/DropTestProviderModuleFactory.java [deleted file]
drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test.xml [new file with mode: 0644]
drop-test-karaf/src/main/resources/initial/69-drop-test.xml [deleted file]
drop-test-karaf/src/main/yang/drop-test.yang [deleted file]
extension/features-he/pom.xml [moved from extension/features-li/pom.xml with 94% similarity]
extension/features-he/src/main/features/features.xml [moved from extension/features-li/src/main/features/features.xml with 82% similarity]
extension/openflowjava-extension-nicira/pom.xml
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java
extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistratorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverter.java
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverterTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/MatchUtilTest.java [moved from extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtilTest.java with 98% similarity]
extension/pom.xml
features-he/pom.xml [moved from features-li/pom.xml with 78% similarity]
features-he/src/main/features/features.xml [moved from features-li/src/main/features/features.xml with 58% similarity]
features/pom.xml
features/src/main/features/features.xml
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPManager.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ConnectionContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceRegistry.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceState.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceSynchronizeListener.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceValidListener.java [moved from applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticProvider.java with 59% similarity]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/MessageTranslator.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/PortNumberCache.java [deleted file]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/handlers/DeviceInitializationPhaseHandler.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/handlers/DeviceTerminationPhaseHandler.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/DeviceContextChangeListener.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/LifecycleConductor.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/RoleChangeListener.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/ServiceChangeListener.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/AbstractModelDrivenSwitchRegistration.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitch.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitchRegistration.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/ConnectionConductor.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/NotificationQueueWrapper.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/session/IMessageDispatchService.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/session/SessionContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/session/SessionManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/queue/QueueProcessor.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/util/PollableQueuesZipper.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/role/RoleContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/role/RoleManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/StatisticsContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/StatisticsManager.java
openflowplugin-api/src/main/yang/openflow-provider-config.yang [new file with mode: 0644]
openflowplugin-api/src/main/yang/openflow-provider.yang
openflowplugin-blueprint-config-he/pom.xml [new file with mode: 0644]
openflowplugin-blueprint-config-he/src/main/resources/org/opendaylight/blueprint/openflowplugin-helium.xml [new file with mode: 0644]
openflowplugin-blueprint-config/pom.xml [new file with mode: 0644]
openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml [new file with mode: 0644]
openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin-new.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartOnTheFlyService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallback.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalExperimenterMessageServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/SinglePurposeMultipartReplyTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInAllTablesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllGroupsStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllPortStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesAllPortsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesOnePortService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MatchingFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OneQueueOnePortService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/FlowStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/GroupStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/MeterStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/NodeConnectorStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/QueueStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/FlowDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/GroupDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/MeterDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/NodeConnectorDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/OpendaylightDirectStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/QueueDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/plugin/impl/rev150327/OpenFlowProviderModule.java
openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/plugin/impl/rev150327/OpenFlowProviderModuleFactory.java
openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/commands.xml [moved from openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/commands.xml with 100% similarity]
openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/OutboundQueueProviderImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContextTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/ItemLifecycleListenerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallbackTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/FlowCapableTransactionServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/PacketProcessingServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalExperimenterMessageServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalPortServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/SinglePurposeMultipartReplyTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/FlowDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/GroupDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/MeterDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/NodeConnectorDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/OpendaylightDirectStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/QueueDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilsTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java
openflowplugin/.gitignore [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtil.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionContextOFImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/RoleUtil.java
openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java
openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModuleFactory.java
openflowplugin/src/main/yang/openflow-plugin-cfg.yang
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/MessageDispatchServiceImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/OFRoleManagerTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtilTest.java
parent/pom.xml
pom.xml
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestServiceProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestServiceProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestServiceProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java
test-scripts/.gitignore [deleted file]

index df9979ce4a3be3936d28993761b2f5a23f4765cc..1b78296903f38bf0b5cc8c6cf93b2e88a3335f33 100644 (file)
@@ -1,24 +1,29 @@
-.idea/\r
-target/\r
-*.class\r
-*.iml\r
-**/target\r
-**/bin\r
-dist\r
-**/logs\r
-products\r
-repository\r
-workspace\r
-*~\r
-target\r
-.classpath\r
-.project\r
-.settings\r
-MANIFEST.MF\r
-xtend-gen\r
+.idea/
+target/
+*.class
+*.iml
+**/target
+**/bin
+dist
+**/logs
+products
+repository
+workspace
+*~
+target
+.classpath
+.project
+.settings
+MANIFEST.MF
+xtend-gen
 yang-gen-sal
 yang-gen-config
-.externalToolBuilders\r
-maven-eclipse.xml\r
+.externalToolBuilders
+maven-eclipse.xml
 .metadata/
 .checkstyle
+maven-metadata-local.xml
+*.pyc
+/.pydevproject
+*.log
+.tox/
diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticProviderImpl.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticProviderImpl.java
deleted file mode 100644 (file)
index 2655826..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.bulk.o.matic;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.SalBulkFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Created by mirehak on 6/8/15.
- */
-public class BulkOMaticProviderImpl implements BulkOMaticProvider {
-
-    private static final Logger LOG = LoggerFactory.getLogger(BulkOMaticProviderImpl.class);
-
-    private final BindingAwareBroker.RpcRegistration<SalBulkFlowService> serviceRpcRegistration;
-
-    public BulkOMaticProviderImpl(RpcProviderRegistry rpcRegistry, DataBroker dataBroker) {
-        LOG.info("creating bulk-o-matic");
-        SalFlowService flowService = rpcRegistry.getRpcService(SalFlowService.class);
-        SalBulkFlowService bulkOMaticService = new SalBulkFlowServiceImpl(flowService, dataBroker);
-        bulkOMaticService.register();
-        serviceRpcRegistration = rpcRegistry.addRpcImplementation(SalBulkFlowService.class, bulkOMaticService);
-    }
-
-    @Override
-    public void close() {
-        LOG.info("destroying bulk-o-matic");
-        serviceRpcRegistration.close();
-    }
-}
index 9f904348e47371bcfff4377fe24fc64295ec9168..f7d96ddb83b2b0e6702d29dac2b84e8998ef77d6 100644 (file)
@@ -10,12 +10,39 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.*;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.Future;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.BulkFlowBaseContentGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowRpcAddMultipleInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowRpcAddTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.ReadFlowTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.SalBulkFlowService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
@@ -24,7 +51,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -32,15 +63,6 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import javax.management.*;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.Future;
-
 /**
  * Simple implementation providing bulk flows operations.
  */
@@ -48,11 +70,12 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
 
     private final SalFlowService flowService;
     private final DataBroker dataBroker;
-    private FlowCounter flowCounterBeanImpl = new FlowCounter();
+    private final FlowCounter flowCounterBeanImpl = new FlowCounter();
     private final ExecutorService fjService = new ForkJoinPool();
     public SalBulkFlowServiceImpl(SalFlowService flowService, DataBroker dataBroker) {
         this.flowService = Preconditions.checkNotNull(flowService);
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
+        register();
     }
 
     @Override
index 6e383523459743cfbe2df642020773f85fe5cead..da55a971f170c9bc2d9dba8208a812e1dbbb45fa 100644 (file)
@@ -1,8 +1,12 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608;
 
-import org.opendaylight.openflowplugin.applications.bulk.o.matic.BulkOMaticProviderImpl;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
-public class BulkOMaticModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608.AbstractBulkOMaticModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class BulkOMaticModule extends AbstractBulkOMaticModule {
     public BulkOMaticModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -11,13 +15,9 @@ public class BulkOMaticModule extends org.opendaylight.yang.gen.v1.urn.opendayli
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return new BulkOMaticProviderImpl(getRpcRegistryDependency(), getDataBrokerDependency());
+        // Instances are created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
 }
index b5dba7cc15ccc228f32175f4e2ef3286f001c1c5..a28c7e22d1bb747742c99134be7cca695911e42e 100644 (file)
@@ -8,6 +8,11 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608;
-public class BulkOMaticModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608.AbstractBulkOMaticModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class BulkOMaticModuleFactory extends AbstractBulkOMaticModuleFactory {
 
 }
index b4384803eccbdcd473cd96615f53dbc89afbcee6..0094e3f8a042e552694a19735a7a3f70530e2b9f 100644 (file)
@@ -5,6 +5,9 @@
   ~ 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
+
+  NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
   -->
 
 <!-- vi: set et smarttab sw=4 tabstop=4: -->
diff --git a/applications/bulk-o-matic/src/main/resources/org/opendaylight/blueprint/bulk-o-matic.xml b/applications/bulk-o-matic/src/main/resources/org/opendaylight/blueprint/bulk-o-matic.xml
new file mode 100644 (file)
index 0000000..f7ee5ef
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+
+  <odl:rpc-service id="flowService"
+      interface="org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService"/>
+
+  <bean id="bulkFlowService" class="org.opendaylight.openflowplugin.applications.bulk.o.matic.SalBulkFlowServiceImpl">
+    <argument ref="flowService"/>
+    <argument ref="dataBroker"/>
+  </bean>
+
+  <odl:rpc-implementation ref="bulkFlowService"/>
+</blueprint>
\ No newline at end of file
index 8bff09395abb3b114a171e610fa0c1f2cf921afd..8da9818e661638063fcc7bd51afe245f30c1ec8e 100644 (file)
@@ -17,6 +17,7 @@ module bulk-o-matic {
     identity bulk-o-matic {
         base "config:module-type";
         config:java-name-prefix BulkOMatic;
+        status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
index 864bacd565306ab340db041223edce33bd1d1e72..0d58d5a7ee51ec66aeb1d584da9542a18b8beeda 100644 (file)
       <type>xml</type>
     </dependency>
 
-    <dependency>
-      <groupId>org.opendaylight.openflowplugin.applications</groupId>
-      <artifactId>statistics-manager-config</artifactId>
-      <type>xml</type>
-      <classifier>config</classifier>
-    </dependency>
-
     <dependency>
       <groupId>org.opendaylight.openflowplugin.model</groupId>
       <artifactId>model-flow-base</artifactId>
index e73e62689340199dd88b97800dae3d3ac4ab9599..4954d337a36e53096900424bf6d74a6ac85b6407 100644 (file)
@@ -22,7 +22,6 @@
         <bundle>mvn:org.opendaylight.openflowplugin.applications/inventory-manager/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/forwardingrules-manager/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
-        <configfile finalname="${config.configfile.directory}/${config.statistics.manager.configfile}">mvn:org.opendaylight.openflowplugin.applications/statistics-manager-config/{{VERSION}}/xml/config</configfile>
     </feature>
 
 </features>
diff --git a/applications/forwardingrules-manager-config/pom.xml b/applications/forwardingrules-manager-config/pom.xml
deleted file mode 100644 (file)
index 6376f35..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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.openflowplugin</groupId>
-        <artifactId>applications</artifactId>
-        <version>0.3.0-SNAPSHOT</version>
-    </parent>
-
-    <groupId>org.opendaylight.openflowplugin.applications</groupId>
-    <artifactId>forwardingrules-manager-config</artifactId>
-    <description>Configuration files for forwarding rules manager</description>
-    <packaging>jar</packaging>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/initial/30-forwardingrules-manager.xml
-                                    </file>
-                                    <type>xml</type>
-                                    <classifier>config</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-</project>
diff --git a/applications/forwardingrules-manager-config/src/main/resources/initial/30-forwardingrules-manager.xml b/applications/forwardingrules-manager-config/src/main/resources/initial/30-forwardingrules-manager.xml
deleted file mode 100644 (file)
index 450ec70..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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:frm="urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager">
-                        frm:forwardingrules-manager
-                    </type>
-                    <name>forwardingrules-manager</name>
-
-                    <data-broker>
-                        <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>
-
-                    <rpc-registry>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                            binding:binding-rpc-registry
-                        </type>
-                        <name>binding-rpc-broker</name>
-                    </rpc-registry>
-                    <forwarding-manager-settings>
-                        <stale-marking-enabled>false</stale-marking-enabled>
-                        <reconciliation-retry-count>5</reconciliation-retry-count>
-                    </forwarding-manager-settings>
-                    <entity-ownership-service>
-                        <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
-                        <name>entity-ownership-service</name>
-                    </entity-ownership-service>
-                </module>
-            </modules>
-        </data>
-    </configuration>
-
-    <required-capabilities>
-        <capability>
-            urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager?module=forwardingrules-manager&amp;revision=2014-09-25
-        </capability>
-        <capability>
-            urn:opendaylight:flow:service?module=sal-flow&amp;revision=2013-08-19
-        </capability>
-        <capability>
-            urn:opendaylight:group:service?module=sal-group&amp;revision=2013-09-18
-        </capability>
-        <capability>
-            urn:opendaylight:meter:service?module=sal-meter&amp;revision=2013-09-18
-        </capability>
-        <capability>
-            urn:opendaylight:port:service?module=sal-port&amp;revision=2013-11-07
-        </capability>
-        <capability>
-            urn:opendaylight:queue:service?module=sal-queue&amp;revision=2015-03-05
-        </capability>
-        <capability>
-            urn:opendaylight:table:service?module=sal-table&amp;revision=2013-10-26
-        </capability>
-        <capability>
-            urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service?module=distributed-entity-ownership-service&amp;revision=2015-08-10
-        </capability>
-    </required-capabilities>
-
-</snapshot>
-
index d5ad08f08fd16471ad8b8e9143e4afd39280ad57..2ef4b514e4c954a779643db4e7fd194f5cd7bd20 100644 (file)
@@ -41,7 +41,7 @@
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-api</artifactId>
+      <artifactId>sal-common-util</artifactId>
     </dependency>
 
     <dependency>
diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModule.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModule.java
deleted file mode 100644 (file)
index d92645a..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
-
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ForwardingRulesManagerModule extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModule {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerModule.class);
-    private static final boolean ENABLE_FGM_STALE_MARKING = false;
-    private static final int RECONCILIATION_RETRY_COUNT = 5;
-
-    public ForwardingRulesManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public ForwardingRulesManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.ForwardingRulesManagerModule 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() {
-        LOG.info("FRM module initialization.");
-        final ForwardingRulesManagerConfig config = readConfig();
-        final ForwardingRulesManagerImpl forwardingrulessManagerProvider =
-                new ForwardingRulesManagerImpl(getDataBrokerDependency(), getRpcRegistryDependency(), config, getEntityOwnershipServiceDependency());
-        forwardingrulessManagerProvider.start();
-        LOG.info("FRM module started successfully.");
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                try {
-                    forwardingrulessManagerProvider.close();
-                } catch (final Exception e) {
-                    LOG.warn("Unexpected error by stopping FRM", e);
-                }
-                LOG.info("FRM module stopped.");
-            }
-        };
-    }
-
-    private ForwardingRulesManagerConfig readConfig(){
-
-        final ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder fwdRulesMgrCfgBuilder = ForwardingRulesManagerConfig.builder();
-
-        if (getForwardingManagerSettings() != null && getForwardingManagerSettings().getStaleMarkingEnabled() != null){
-            fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(getForwardingManagerSettings().getStaleMarkingEnabled());
-        }
-        else{
-            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
-            fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(ENABLE_FGM_STALE_MARKING);
-        }
-
-       if(getForwardingManagerSettings() != null && getForwardingManagerSettings().getReconciliationRetryCount()>0){
-                   fwdRulesMgrCfgBuilder.setReconciliationRetryCount(getForwardingManagerSettings().getReconciliationRetryCount());
-       }
-       else{
-             LOG.warn("Could not load XML configuration file via ConfigSubsystem for reconciliation retry! " +
-             "Fallback to default config value(s)");
-             fwdRulesMgrCfgBuilder.setReconciliationRetryCount(RECONCILIATION_RETRY_COUNT);
-            }
-
-
-
-        return fwdRulesMgrCfgBuilder.build();
-
-    }
-
-}
diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModuleFactory.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModuleFactory.java
deleted file mode 100644 (file)
index 9a42dac..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: forwardingrules-manager yang module local name: forwardingrules-manager
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Apr 23 19:20:17 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
-public class ForwardingRulesManagerModuleFactory extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModuleFactory {
-
-}
index 5e891b1721188c1eaf69e75ba80f396e48bcd53c..9bf1f26732f96af104febb614013420437e016df 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.applications.frm;
 
 import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -35,7 +36,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  *
  * Created: Aug 26, 2014
  */
-public interface FlowNodeReconciliation extends ClusteredDataChangeListener, AutoCloseable {
+public interface FlowNodeReconciliation extends ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
 
     /**
      * Method contains Node registration to {@link ForwardingRulesManager} functionality
index 286ffa1027db270863915fc5aaa6ec6c89e2ffb2..d6916d18e004c9fb080a6fd43f7e994b843a5abc 100644 (file)
@@ -8,11 +8,8 @@
 
 package org.opendaylight.openflowplugin.applications.frm;
 
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
-
-import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
@@ -20,7 +17,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
@@ -161,7 +160,7 @@ public interface ForwardingRulesManager extends AutoCloseable {
      * @return True if owner, else false
      */
     public boolean isNodeOwner(InstanceIdentifier<FlowCapableNode> ident);
-     
+
     /**
      * Content definition method and prevent code duplicity
      * @return FlowNodeConnectorInventoryTranslatorImpl
index 2b62037b373c20eade1284e0ff6d14fdcd43a556..6c43cd4912f64f43aed34ad0af79cf54839f288a 100644 (file)
@@ -8,25 +8,20 @@
 
 package org.opendaylight.openflowplugin.applications.frm.impl;
 
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
+
 import java.util.concurrent.Callable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+
+import org.opendaylight.controller.md.sal.binding.api.*;
 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;
@@ -38,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
@@ -59,6 +55,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
@@ -71,6 +69,8 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nonnull;
+
 
 /**
  * forwardingrules-manager
@@ -92,7 +92,13 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     private final ForwardingRulesManager provider;
     public static final String SEPARATOR = ":";
 
-    private ListenerRegistration<DataChangeListener> listenerRegistration;
+    private ListenerRegistration<FlowNodeReconciliationImpl> listenerRegistration;
+
+    private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE
+            = InstanceIdentifier.builder(Nodes.class)
+            .child(Node.class)
+            .augmentation(FlowCapableNode.class)
+            .build();
 
     public FlowNodeReconciliationImpl (final ForwardingRulesManager manager, final DataBroker db) {
         this.provider = Preconditions.checkNotNull(manager, "ForwardingRulesManager can not be null!");
@@ -101,14 +107,17 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
         final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class).augmentation(FlowCapableNode.class);
 
+        final DataTreeIdentifier<FlowCapableNode> treeId =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier);
+
+        try {
         SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
                 ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
-        try {
-            listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataChangeListener>>() {
+
+            listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<FlowNodeReconciliationImpl>>() {
                 @Override
-                public ListenerRegistration<DataChangeListener> call() throws Exception {
-                    return db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                            flowNodeWildCardIdentifier, FlowNodeReconciliationImpl.this, DataChangeScope.BASE);
+                public ListenerRegistration<FlowNodeReconciliationImpl> call() throws Exception {
+                    return dataBroker.registerDataTreeChangeListener(treeId, FlowNodeReconciliationImpl.this);
                 }
             });
         } catch (Exception e) {
@@ -132,46 +141,56 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     }
 
     @Override
-    public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
-        Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
-        /* All DataObjects for create */
-        final Set<InstanceIdentifier<?>>  createdData = changeEvent.getCreatedData() != null
-                ? changeEvent.getCreatedData().keySet() : Collections.<InstanceIdentifier<?>> emptySet();
-        /* All DataObjects for remove */
-        final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
-                ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>> emptySet();
-        /* All updated DataObjects */
-        final Map<InstanceIdentifier<?>, DataObject> updateData = changeEvent.getUpdatedData() != null
-                ? changeEvent.getUpdatedData() : Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
-
-        for (InstanceIdentifier<?> entryKey : removeData) {
-            final InstanceIdentifier<FlowCapableNode> nodeIdent = entryKey
-                    .firstIdentifierOf(FlowCapableNode.class);
-            if ( ! nodeIdent.isWildcarded()) {
-                flowNodeDisconnected(nodeIdent);
+    public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> changes) {
+        Preconditions.checkNotNull(changes, "Changes may not be null!");
+
+        for (DataTreeModification<FlowCapableNode> change : changes) {
+            final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().getRootIdentifier();
+            final DataObjectModification<FlowCapableNode> mod = change.getRootNode();
+            final InstanceIdentifier<FlowCapableNode> nodeIdent =
+                    key.firstIdentifierOf(FlowCapableNode.class);
+
+            switch (mod.getModificationType()) {
+                case DELETE:
+                    if (mod.getDataAfter() == null) {
+                        remove(key, mod.getDataBefore(), nodeIdent);
+                    }
+                    break;
+                case SUBTREE_MODIFIED:
+                    //NO-OP since we donot need to reconciliate on Node-updated
+                    break;
+                case WRITE:
+                    if (mod.getDataBefore() == null) {
+                        add(key, mod.getDataAfter(), nodeIdent);
+                    }
+                    break;
+                default:
+                    throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
             }
         }
-        for (InstanceIdentifier<?> entryKey : createdData) {
-            final InstanceIdentifier<FlowCapableNode> nodeIdent = entryKey
-                    .firstIdentifierOf(FlowCapableNode.class);
+    }
+
+
+
+    public void remove(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode del,
+                       InstanceIdentifier<FlowCapableNode> nodeIdent) {
+        if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
+            LOG.warn("Node removed: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+
             if ( ! nodeIdent.isWildcarded()) {
-                flowNodeConnected(nodeIdent);
+                flowNodeDisconnected(nodeIdent);
             }
+
         }
+    }
 
-        // FIXME: just a hack to cover DS/operational dirty start
-        // if all conventional ways failed and there is update
-        if (removeData.isEmpty() && createdData.isEmpty() && updateData.size() == 1) {
-            for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : updateData.entrySet()) {
-                // and only if this update covers top element (flow-capable-node)
-                if (FlowCapableNode.class.equals(entry.getKey().getTargetType())) {
-                    final InstanceIdentifier<FlowCapableNode> nodeIdent = entry.getKey()
-                            .firstIdentifierOf(FlowCapableNode.class);
-                    if (!nodeIdent.isWildcarded()) {
-                        // then force registration to local node cache and reconcile
-                        flowNodeConnected(nodeIdent, true);
-                    }
-                }
+    public void add(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode add,
+                    InstanceIdentifier<FlowCapableNode> nodeIdent) {
+        if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
+            LOG.warn("Node added: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+
+            if ( ! nodeIdent.isWildcarded()) {
+                flowNodeConnected(nodeIdent);
             }
         }
     }
@@ -534,8 +553,9 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     }
 
 
-
-
-
+    private boolean compareInstanceIdentifierTail(InstanceIdentifier<?> identifier1,
+                                                  InstanceIdentifier<?> identifier2) {
+        return Iterables.getLast(identifier1.getPathArguments()).equals(Iterables.getLast(identifier2.getPathArguments()));
+    }
 }
 
diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerConfig.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerConfig.java
deleted file mode 100644 (file)
index 0b4714e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.openflowplugin.applications.frm.impl;
-
-/**
- * Created by efiijjp on 10/14/2015.
- */
-public class ForwardingRulesManagerConfig {
-
-    private final boolean m_staleMarkingEnabled;
-    private final int m_reconciliationRetryCount;
-
-    private ForwardingRulesManagerConfig(ForwardingRulesManagerConfigBuilder builder){
-        m_staleMarkingEnabled = builder.isStaleMarkingEnabled();
-        m_reconciliationRetryCount = builder.getReconciliationRetryCount();
-    }
-
-    public boolean isStaleMarkingEnabled(){
-        return m_staleMarkingEnabled;
-    }
-
-    public int getReconciliationRetryCount() {
-        return m_reconciliationRetryCount;
-    }
-
-
-    public static ForwardingRulesManagerConfigBuilder builder(){
-        return new ForwardingRulesManagerConfigBuilder();
-    }
-
-
-
-    public static class ForwardingRulesManagerConfigBuilder {
-        private boolean staleMarkingEnabled ;
-        private int reconciliationRetryCount ;
-
-        public boolean isStaleMarkingEnabled(){
-            return staleMarkingEnabled;
-        }
-        public int getReconciliationRetryCount() {return reconciliationRetryCount;}
-
-        public void setStaleMarkingEnabled(boolean staleMarkingEnabledFlag){
-            staleMarkingEnabled = staleMarkingEnabledFlag;
-        }
-
-        public void setReconciliationRetryCount(int retryCount ){
-            reconciliationRetryCount = retryCount;
-        }
-
-        public ForwardingRulesManagerConfig build(){
-            return new ForwardingRulesManagerConfig(this);
-        }
-    }
-
-}
index cd05e4e58412bba2be7fff9d3672092b3bb0af15..ef7ff256d76824c20c8eb12b5e3e6c7bd8ad28c8 100644 (file)
@@ -11,11 +11,10 @@ package org.opendaylight.openflowplugin.applications.frm.impl;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
-
-import com.google.common.util.concurrent.CheckedFuture;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
@@ -36,8 +35,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -109,7 +109,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
 
         this.tableListener = new TableForwarder(this, dataService);
         this.nodeListener = new FlowNodeReconciliationImpl(this, dataService);
-       flowNodeConnectorInventoryTranslatorImpl = 
+       flowNodeConnectorInventoryTranslatorImpl =
                            new FlowNodeConnectorInventoryTranslatorImpl(this,dataService);
         LOG.info("ForwardingRulesManager has started successfully.");
 
diff --git a/applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml b/applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml
new file mode 100644 (file)
index 0000000..1902cba
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+  <odl:clustered-app-config id="frmConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
+
+  <bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="rpcRegistry"/>
+    <argument ref="frmConfig"/>
+    <argument ref="entityOwnershipService"/>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/applications/forwardingrules-manager/src/main/yang/forwarding-manager.yang b/applications/forwardingrules-manager/src/main/yang/forwarding-manager.yang
deleted file mode 100644 (file)
index 0b40bb0..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-module forwardingrules-manager {
-
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager";
-    prefix "frm";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-    import opendaylight-entity-ownership-service { prefix eos; }
-
-    description
-        "This module contains the base YANG definitions for
-        forwardingrules-manager implementation.";
-
-    revision "2014-09-25" {
-        description
-            "Initial revision.";
-    }
-
-    identity forwardingrules-manager {
-            base config:module-type;
-            config:java-name-prefix ForwardingRulesManager;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case forwardingrules-manager {
-            when "/config:modules/config:module/config:type = 'forwardingrules-manager'";
-
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-rpc-registry;
-                    }
-                }
-            }
-
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity mdsal:binding-async-data-broker;
-                    }
-                }
-            }
-
-            container forwarding-manager-settings {
-                leaf stale-marking-enabled {
-                    type boolean;
-                }
-               leaf reconciliation-retry-count {
-                    type uint16;
-               }
-
-            }
-
-            container entity-ownership-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                            config:required-identity eos:entity-ownership-service;
-                    }
-                }
-            }
-
-        }
-    }
-
-}
diff --git a/applications/forwardingrules-manager/src/main/yang/forwardingrules-manager-config.yang b/applications/forwardingrules-manager/src/main/yang/forwardingrules-manager-config.yang
new file mode 100644 (file)
index 0000000..f2772f8
--- /dev/null
@@ -0,0 +1,25 @@
+module forwarding-rules-manager-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager:config";
+    prefix "frm";
+
+    description
+        "Configuration for Forwarding Rules Manager application..";
+
+    revision "2016-05-11" {
+        description
+            "Initial revision.";
+    }
+
+    container forwarding-rules-manager-config {
+        leaf stale-marking-enabled {
+            type boolean;
+            default false;
+        }
+
+        leaf reconciliation-retry-count {
+            type uint16;
+            default 5;
+        }
+    }
+}
\ No newline at end of file
index 44cc0055163a93ef8545c883348d997011c71fa1..9eedf33a736099f1e57e064cd3016b45c52ba314 100644 (file)
@@ -7,12 +7,14 @@
  */
 package test.mock;
 
+import static org.junit.Assert.assertEquals;
+import java.util.Collections;
+import java.util.List;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
 import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -20,7 +22,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
@@ -33,17 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
 import test.mock.util.EntityOwnershipServiceMock;
 import test.mock.util.FRMTest;
 import test.mock.util.RpcProviderRegistryMock;
 import test.mock.util.SalFlowServiceMock;
 
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
 public class FlowListenerTest extends FRMTest {
     RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
     EntityOwnershipService eos = new EntityOwnershipServiceMock();
index 4d45861a2eaa4ea3505f508c592bc1b07feee060..ca2d80771d9fa91cd47223f17d86e1307ddf6e00 100644 (file)
@@ -1,10 +1,5 @@
 package test.mock.util;
 
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import java.util.Collections;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -12,11 +7,17 @@ import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfigBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public abstract class FRMTest extends AbstractDataBrokerTest {
@@ -56,9 +57,9 @@ public abstract class FRMTest extends AbstractDataBrokerTest {
     }
 
     public ForwardingRulesManagerConfig getConfig(){
-        ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder cfgBuilder =
-                new ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder();
+        ForwardingRulesManagerConfigBuilder cfgBuilder = new ForwardingRulesManagerConfigBuilder();
         cfgBuilder.setStaleMarkingEnabled(false);
+        cfgBuilder.setReconciliationRetryCount(0);
         return cfgBuilder.build();
 
     }
index e9fad3b3163ad9f54a0f633c75b01bfe2107f6a1..067a462f2ee9dccdbbc66a5a3de49400a003ea3d 100644 (file)
             <artifactId>model-inventory</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.model</groupId>
-            <artifactId>model-flow-base</artifactId>
-        </dependency>
-
         <dependency>
             <groupId>org.opendaylight.openflowplugin.model</groupId>
             <artifactId>model-flow-service</artifactId>
index df1bab02168f862c57ff3c57da67dad9545d157a..f3bc24928f31b93f4188d706568c66ae0c9883fd 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync;
 
 import java.util.EventListener;
-
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
index 9a856cc6b946aa2dbb19b373b0cb5fe874084ff7..5e3838978c9627f577a710020ef79d6eb607eb33 100644 (file)
@@ -22,7 +22,8 @@ public interface SyncPlanPushStrategy {
     /**
      * @param resultVehicle bootstrap future - execution will chain it's async calls to this one
      * @param diffInput     wraps all diff data required for any strategy ({add,remove,update} x {flow,group,meter})
-     * @param counters      reference to internal one-shot statistics - summary off successfully pushed items shall be recorded here
+     * @param counters      reference to internal one-shot statistics - summary off successfully pushed items
+     *                      shall be recorded here
      * @return last future of the chain
      */
     ListenableFuture<RpcResult<Void>> executeSyncStrategy(ListenableFuture<RpcResult<Void>> resultVehicle,
index 12cffd1362eb6bdaab84810cba078d04521cf493..cf92bbae60840ff5b1111f0c066ef9a23a6084be 100644 (file)
@@ -8,11 +8,11 @@
 
 package org.opendaylight.openflowplugin.applications.frsync;
 
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Device synchronization API.
  */
@@ -21,9 +21,10 @@ public interface SyncReactor {
      * @param flowcapableNodePath path to openflow augmentation of node
      * @param configTree configured node
      * @param operationalTree device reflection
+     * @param dsType type of DS change
      * @return synchronization outcome
      */
-    ListenableFuture<Boolean> syncup(InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-            FlowCapableNode configTree, FlowCapableNode operationalTree) throws InterruptedException;
-
+    ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                     final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                     final LogicalDatastoreType dsType) throws InterruptedException;
 }
index 0aebb06b0c7bc5c8370f33dbf2bc7cb85379e4a0..b94bc1e4731dade02f50d527c9b895fc59aa6e30 100644 (file)
@@ -1,42 +1,40 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.dao;\r
-\r
-import javax.annotation.Nonnull;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-\r
-import com.google.common.base.Optional;\r
-\r
-/**\r
- * Implementation of data access object for {@link FlowCapableNode}.\r
- * Contains pair of snapshot and odl DAOs.\r
- */\r
-public class FlowCapableNodeCachedDao implements FlowCapableNodeDao {\r
-\r
-    private final FlowCapableNodeDao snapshotDao;\r
-    private final FlowCapableNodeDao odlDao;\r
-\r
-    public FlowCapableNodeCachedDao(FlowCapableNodeDao snapshotDao, FlowCapableNodeDao odlDao) {\r
-        this.snapshotDao = snapshotDao;\r
-        this.odlDao = odlDao;\r
-    }\r
-\r
-    public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {\r
-        final Optional<FlowCapableNode> node = snapshotDao.loadByNodeId(nodeId);\r
-\r
-        if (node.isPresent()) {\r
-            return node;\r
-        }\r
-\r
-        return odlDao.loadByNodeId(nodeId);\r
-    }\r
-\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.dao;
+
+import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+/**
+ * Implementation of data access object for {@link FlowCapableNode}.
+ * Contains pair of snapshot and odl DAOs.
+ */
+public class FlowCapableNodeCachedDao implements FlowCapableNodeDao {
+
+    private final FlowCapableNodeDao snapshotDao;
+    private final FlowCapableNodeDao odlDao;
+
+    public FlowCapableNodeCachedDao(FlowCapableNodeDao snapshotDao, FlowCapableNodeDao odlDao) {
+        this.snapshotDao = snapshotDao;
+        this.odlDao = odlDao;
+    }
+
+    public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {
+        final Optional<FlowCapableNode> node = snapshotDao.loadByNodeId(nodeId);
+
+        if (node.isPresent()) {
+            return node;
+        }
+
+        return odlDao.loadByNodeId(nodeId);
+    }
+
+}
index 0bc6b991ce9ff3e3dbd058c15e6d857e466c95d8..7340fccceee69a95eb53b0a910770c484c2baff5 100644 (file)
@@ -1,23 +1,21 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.dao;\r
-\r
-import javax.annotation.Nonnull;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-\r
-import com.google.common.base.Optional;\r
-\r
-/**\r
- * Data access object for {@link FlowCapableNode}.\r
- */\r
-public interface FlowCapableNodeDao {\r
-    Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId);\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.dao;
+
+import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+/**
+ * Data access object for {@link FlowCapableNode}.
+ */
+public interface FlowCapableNodeDao {
+    Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId);
+}
index 724c43ad67d0f73b7602f76e08bc2793d614aa57..73467086f47cfd969836ba3210037ebd44c07a7c 100644 (file)
@@ -1,58 +1,56 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.dao;\r
-\r
-import com.google.common.base.Optional;\r
-\r
-import java.util.concurrent.TimeUnit;\r
-import java.util.concurrent.TimeoutException;\r
-\r
-import javax.annotation.Nonnull;\r
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;\r
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Implementation of data access object for ODL {@link FlowCapableNode}.\r
- */\r
-public class FlowCapableNodeOdlDao implements FlowCapableNodeDao {\r
-\r
-    private static final Logger LOG = LoggerFactory.getLogger(FlowCapableNodeOdlDao.class);\r
-\r
-    private static final InstanceIdentifier<Nodes> NODES_IID = InstanceIdentifier.create(Nodes.class);\r
-    private final DataBroker dataBroker;\r
-    private final LogicalDatastoreType logicalDatastoreType;\r
-\r
-    public FlowCapableNodeOdlDao(DataBroker dataBroker, LogicalDatastoreType logicalDatastoreType) {\r
-        this.dataBroker = dataBroker;\r
-        this.logicalDatastoreType = logicalDatastoreType;\r
-    }\r
-\r
-    public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {\r
-        try (final ReadOnlyTransaction roTx = dataBroker.newReadOnlyTransaction()) {\r
-            final InstanceIdentifier<FlowCapableNode> path =\r
-                    NODES_IID.child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);\r
-            return roTx.read(logicalDatastoreType, path).checkedGet(5000, TimeUnit.MILLISECONDS);\r
-        } catch (ReadFailedException | TimeoutException e) {\r
-            LOG.error("error reading {}", nodeId, e);\r
-        }\r
-\r
-        return Optional.absent();\r
-    }\r
-\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.dao;
+
+import com.google.common.base.Optional;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+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.common.api.data.ReadFailedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of data access object for ODL {@link FlowCapableNode}.
+ */
+public class FlowCapableNodeOdlDao implements FlowCapableNodeDao {
+
+    private static final Logger LOG = LoggerFactory.getLogger(FlowCapableNodeOdlDao.class);
+
+    private static final InstanceIdentifier<Nodes> NODES_IID = InstanceIdentifier.create(Nodes.class);
+    private final DataBroker dataBroker;
+    private final LogicalDatastoreType logicalDatastoreType;
+
+    public FlowCapableNodeOdlDao(DataBroker dataBroker, LogicalDatastoreType logicalDatastoreType) {
+        this.dataBroker = dataBroker;
+        this.logicalDatastoreType = logicalDatastoreType;
+    }
+
+    public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {
+        try (final ReadOnlyTransaction roTx = dataBroker.newReadOnlyTransaction()) {
+            final InstanceIdentifier<FlowCapableNode> path =
+                    NODES_IID.child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
+            return roTx.read(logicalDatastoreType, path).checkedGet(5000, TimeUnit.MILLISECONDS);
+        } catch (ReadFailedException | TimeoutException e) {
+            LOG.error("error reading {}", nodeId, e);
+        }
+
+        return Optional.absent();
+    }
+
+}
index 2c40af77b91beb73f339f8a41f59c10e5eb1d082..4f7835aaccf9c0f562f2149efef0084e1b723059 100644 (file)
@@ -1,40 +1,37 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.dao;\r
-\r
-import java.util.concurrent.ConcurrentHashMap;\r
-\r
-import javax.annotation.Nonnull;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-\r
-import com.google.common.base.Optional;\r
-\r
-/**\r
- * Adding cache to data access object of {@link FlowCapableNode}.\r
- */\r
-public class FlowCapableNodeSnapshotDao implements FlowCapableNodeDao {\r
-\r
-    private final ConcurrentHashMap<String, FlowCapableNode> cache = new ConcurrentHashMap<>();\r
-\r
-    public void updateCache(@Nonnull NodeId nodeId, Optional<FlowCapableNode> dataAfter) {\r
-        if (dataAfter.isPresent()) {\r
-            cache.put(nodeId.getValue(), dataAfter.get());\r
-        } else {\r
-            cache.remove(nodeId.getValue());\r
-        }\r
-    }\r
-\r
-    public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {\r
-        final FlowCapableNode node = cache.get(nodeId.getValue());\r
-        return Optional.fromNullable(node);\r
-    }\r
-\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.dao;
+
+import com.google.common.base.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+/**
+ * Adding cache to data access object of {@link FlowCapableNode}.
+ */
+public class FlowCapableNodeSnapshotDao implements FlowCapableNodeDao {
+
+    private final ConcurrentHashMap<String, FlowCapableNode> cache = new ConcurrentHashMap<>();
+
+    public void updateCache(@Nonnull NodeId nodeId, Optional<FlowCapableNode> dataAfter) {
+        if (dataAfter.isPresent()) {
+            cache.put(nodeId.getValue(), dataAfter.get());
+        } else {
+            cache.remove(nodeId.getValue());
+        }
+    }
+
+    public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) {
+        final FlowCapableNode node = cache.get(nodeId.getValue());
+        return Optional.fromNullable(node);
+    }
+
+}
index 4d1e53a6932ff16f9fc5671122eb19639aa5a49f..aaf4063bd0f21a6e609d686404383a90a8a7223f 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.applications.frsync.NodeListener;
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -39,22 +38,22 @@ public abstract class AbstractFrmSyncListener<T extends DataObject> implements N
                 if (optFuture.isPresent()) {
                     final ListenableFuture<Boolean> future = optFuture.get();
                     final Boolean ret = future.get(15000, TimeUnit.MILLISECONDS);
-                    LOG.debug("syncup ret {} {} {} thread:{}", dsType(), ret, nodeId, threadName());
+                    LOG.debug("syncup ret {} {} {} thread:{}", dsType(), ret, nodeId.getValue(), threadName());
                 }
             } catch (InterruptedException e) {
-                LOG.warn("permit for forwarding rules sync not acquired: {}", nodeId);
+                LOG.warn("permit for forwarding rules sync not acquired: {}", nodeId.getValue());
             } catch (Exception e) {
-                LOG.error("error processing inventory node modification: {}", nodeId, e);
+                LOG.error("error processing inventory node modification: {}", nodeId.getValue(), e);
             }
         }
     }
 
     protected abstract Optional<ListenableFuture<Boolean>> processNodeModification(
-            DataTreeModification<T> modification) throws ReadFailedException, InterruptedException;
+            DataTreeModification<T> modification) throws InterruptedException;
 
-    public abstract LogicalDatastoreType dsType();
+    protected abstract LogicalDatastoreType dsType();
 
-    static String threadName() {
+    private static String threadName() {
         final Thread currentThread = Thread.currentThread();
         return currentThread.getName();
     }
index f0babcba30af0ae1659b4bfe4a1397e37613f0b7..87237c5f77d8910f00c6de93eb44c2e4ef2bb7f8 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Preconditions;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
@@ -26,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -36,15 +35,13 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 /**
  * Implements {@link ForwardingRulesCommitter} methods for processing add, update and remove of {@link Flow}.
  */
 public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutput, RemoveFlowOutput, UpdateFlowOutput> {
 
     private static final Logger LOG = LoggerFactory.getLogger(FlowForwarder.class);
-    private SalFlowService salFlowService;
+    private final SalFlowService salFlowService;
 
     public FlowForwarder(final SalFlowService salFlowService) {
         this.salFlowService = salFlowService;
@@ -56,7 +53,7 @@ public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutp
                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         LOG.trace("Forwarding Flow REMOVE request Tbl id, node Id {} {}",
                 identifier, nodeIdent);
-        
+
         final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
         if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
             final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
@@ -80,7 +77,7 @@ public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutp
                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         LOG.trace("Forwarding Flow UPDATE request [Tbl id, node Id {} {} {}",
                 identifier, nodeIdent, update);
-        
+
         final Future<RpcResult<UpdateFlowOutput>> output;
         final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
         if (tableIdValidationPrecondition(tableKey, update)) {
@@ -109,7 +106,7 @@ public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutp
                                                 final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         LOG.trace("Forwarding the Flow ADD request [Tbl id, node Id {} {} {}",
                 identifier, nodeIdent, addDataObj);
-        
+
         final Future<RpcResult<AddFlowOutput>> output;
         final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
         if (tableIdValidationPrecondition(tableKey, addDataObj)) {
index 57c404b6d8cca5c7a0913e960e1e8cb5f189aa12..24bfeafe06522d730c736a3bd82a83491562a42e 100644 (file)
@@ -27,16 +27,13 @@ import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDa
 import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeOdlDao;
 import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao;
 import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SyncPlanPushStrategyFlatBatchImpl;
+import org.opendaylight.openflowplugin.applications.frsync.util.RetryRegistry;
 import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
 import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -49,21 +46,17 @@ import org.slf4j.LoggerFactory;
 public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesSyncProvider.class);
-    public static final int STARTUP_LOOP_TICK = 500;
-    public static final int STARTUP_LOOP_MAX_RETRIES = 8;
+    private static final int STARTUP_LOOP_TICK = 500;
+    private static final int STARTUP_LOOP_MAX_RETRIES = 8;
 
     private final DataBroker dataService;
-    private final SalFlowService salFlowService;
-    private final SalGroupService salGroupService;
-    private final SalMeterService salMeterService;
     private final SalTableService salTableService;
-    private final FlowCapableTransactionService transactionService;
     private final SalFlatBatchService flatBatchService;
 
-    /** wildcard path to flow-capable-node augmentation of inventory node */
+    /** Wildcard path to flow-capable-node augmentation of inventory node. */
     private static final InstanceIdentifier<FlowCapableNode> FLOW_CAPABLE_NODE_WC_PATH =
             InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-    /** wildcard path to node (not flow-capable-node augmentation) of inventory node */
+    /** Wildcard path to node (not flow-capable-node augmentation) of inventory node. */
     private static final InstanceIdentifier<Node> NODE_WC_PATH =
             InstanceIdentifier.create(Nodes.class).child(Node.class);
 
@@ -74,31 +67,17 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
     private ListenerRegistration<NodeListener> dataTreeConfigChangeListener;
     private ListenerRegistration<NodeListener> dataTreeOperationalChangeListener;
 
-
     public ForwardingRulesSyncProvider(final BindingAwareBroker broker,
                                        final DataBroker dataBroker,
                                        final RpcConsumerRegistry rpcRegistry) {
-        this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
-
         Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
-
-        this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
-                "RPC SalFlowService not found.");
-        this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
-                "RPC SalGroupService not found.");
-        this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
-                "RPC SalMeterService not found.");
+        this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
         this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
                 "RPC SalTableService not found.");
-        this.transactionService =
-                Preconditions.checkNotNull(rpcRegistry.getRpcService(FlowCapableTransactionService.class),
-                        "RPC SalTableService not found.");
-        this.flatBatchService =
-                Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
-                        "RPC SalFlatBatchService not found.");
-
-        nodeConfigDataTreePath =
-                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
+        this.flatBatchService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
+                "RPC SalFlatBatchService not found.");
+
+        nodeConfigDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
         nodeOperationalDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, NODE_WC_PATH);
 
         broker.registerProvider(this);
@@ -121,69 +100,56 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
 
     @Override
     public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
-        final FlowForwarder flowForwarder = new FlowForwarder(salFlowService);
-        final GroupForwarder groupForwarder = new GroupForwarder(salGroupService);
-        final MeterForwarder meterForwarder = new MeterForwarder(salMeterService);
         final TableForwarder tableForwarder = new TableForwarder(salTableService);
 
-        {
-            //TODO: make is switchable
-//            final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl()
-//                    .setFlowForwarder(flowForwarder)
-//                    .setGroupForwarder(groupForwarder)
-//                    .setMeterForwarder(meterForwarder)
-//                    .setTableForwarder(tableForwarder)
-//                    .setTransactionService(transactionService);
-
-            final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
-                    .setFlatBatchService(flatBatchService)
-                    .setTableForwarder(tableForwarder);
-
-            final SyncReactorImpl syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
-            final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorImpl,
-                    new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
-
-            final SyncReactor cfgReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
-            final SyncReactor operReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
-
-            final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
-            final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
-            final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
-                    new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.CONFIGURATION));
-            final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
-                    new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.OPERATIONAL));
-
-            final NodeListener<FlowCapableNode> nodeListenerConfig =
-                    new SimplifiedConfigListener(
-                            cfgReactor,
-                            configSnapshot, operationalDao);
-            final NodeListener<Node> nodeListenerOperational =
-                    new SimplifiedOperationalListener(operReactor, operationalSnapshot, configDao);
-
-            try {
-                SimpleTaskRetryLooper looper1 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-                dataTreeConfigChangeListener = looper1.loopUntilNoException(
-                        new Callable<ListenerRegistration<NodeListener>>() {
-                            @Override
-                            public ListenerRegistration<NodeListener> call() throws Exception {
-                                return dataService.registerDataTreeChangeListener(
-                                        nodeConfigDataTreePath, nodeListenerConfig);
-                            }
-                        });
-
-                SimpleTaskRetryLooper looper2 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-                dataTreeOperationalChangeListener = looper2.loopUntilNoException(
-                        new Callable<ListenerRegistration<NodeListener>>() {
-                            @Override
-                            public ListenerRegistration<NodeListener> call() throws Exception {
-                                return dataService.registerDataTreeChangeListener(
-                                        nodeOperationalDataTreePath, nodeListenerOperational);
-                            }
-                        });
-            } catch (final Exception e) {
-                LOG.warn("FR-Sync node DataChange listener registration fail!", e);
-                throw new IllegalStateException("FR-Sync startup fail!", e);
-            }
+        final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
+                .setFlatBatchService(flatBatchService)
+                .setTableForwarder(tableForwarder);
+
+        final RetryRegistry retryRegistry = new RetryRegistry();
+
+        final SyncReactor syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
+        final SyncReactor syncReactorRetry = new SyncReactorRetryDecorator(syncReactorImpl, retryRegistry);
+        final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorRetry,
+                new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
+
+        final SyncReactor reactor = new SyncReactorFutureZipDecorator(syncReactorGuard, syncThreadPool);
+
+        final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
+                new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.CONFIGURATION));
+        final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
+                new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.OPERATIONAL));
+
+        final NodeListener<FlowCapableNode> nodeListenerConfig =
+                new SimplifiedConfigListener(reactor, configSnapshot, operationalDao);
+        final NodeListener<Node> nodeListenerOperational =
+                new SimplifiedOperationalRetryListener(reactor, operationalSnapshot, configDao, retryRegistry);
+
+        try {
+            SimpleTaskRetryLooper looper1 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+            dataTreeConfigChangeListener = looper1.loopUntilNoException(
+                    new Callable<ListenerRegistration<NodeListener>>() {
+                        @Override
+                        public ListenerRegistration<NodeListener> call() throws Exception {
+                            return dataService.registerDataTreeChangeListener(
+                                    nodeConfigDataTreePath, nodeListenerConfig);
+                        }
+                    });
+
+            SimpleTaskRetryLooper looper2 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+            dataTreeOperationalChangeListener = looper2.loopUntilNoException(
+                    new Callable<ListenerRegistration<NodeListener>>() {
+                        @Override
+                        public ListenerRegistration<NodeListener> call() throws Exception {
+                            return dataService.registerDataTreeChangeListener(
+                                    nodeOperationalDataTreePath, nodeListenerOperational);
+                        }
+                    });
+        } catch (final Exception e) {
+            LOG.warn("FR-Sync node DataChange listener registration fail!", e);
+            throw new IllegalStateException("FR-Sync startup fail!", e);
         }
         LOG.info("ForwardingRulesSync has started.");
     }
index 44e625dd239a712a896c8bd108b90e7a551567dc..4b8eb4efa8171e108642d8daed78f163943564ee 100644 (file)
@@ -1,44 +1,43 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.impl;\r
-\r
-import java.util.concurrent.ExecutorService;\r
-import java.util.concurrent.Executors;\r
-import java.util.concurrent.ThreadFactory;\r
-\r
-import com.google.common.annotations.VisibleForTesting;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-import com.google.common.util.concurrent.MoreExecutors;\r
-\r
-/**\r
- * Static Factory for creating ExecutorServicess (because there is no dependency injection but\r
- * static getInstance).\r
- */\r
-public final class FrmExecutors {\r
-    public static PceExecursFactory instance() {\r
-        return DEFAULT_EXECUTORS;\r
-    }\r
-\r
-    public interface PceExecursFactory {\r
-\r
-        public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory);\r
-    }\r
-\r
-    /**\r
-     * This will be rewritten in JUnits using SynchronousExecutorService\r
-     */\r
-    @VisibleForTesting // should not be private and final\r
-    static PceExecursFactory DEFAULT_EXECUTORS = new PceExecursFactory() {\r
-\r
-        public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory) {\r
-            final ExecutorService executorService = Executors.newFixedThreadPool(nThreads, factory);\r
-            return MoreExecutors.listeningDecorator(executorService);\r
-        }\r
-    };\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * Static Factory for creating ExecutorServices (because there is no dependency injection but
+ * static getInstance).
+ */
+public final class FrmExecutors {
+    public static PceExecutorsFactory instance() {
+        return DEFAULT_EXECUTORS;
+    }
+
+    public interface PceExecutorsFactory {
+
+        ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory);
+    }
+
+    /**
+     * This will be rewritten in JUnits using SynchronousExecutorService.
+     */
+    @VisibleForTesting // should not be private and final
+    static PceExecutorsFactory DEFAULT_EXECUTORS = new PceExecutorsFactory() {
+
+        public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory) {
+            final ExecutorService executorService = Executors.newFixedThreadPool(nThreads, factory);
+            return MoreExecutors.listeningDecorator(executorService);
+        }
+    };
+}
index 9e69f2c40e078dc6b47d2bd38afef6fdb8b6d6cc..aef44f12b64bf85bf395986d60baaac22fa5e186 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
@@ -48,7 +47,7 @@ public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterO
 
         LOG.trace("Received the Meter REMOVE request [Tbl id, node Id {} {}",
                 identifier, nodeIdent);
-        
+
         final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(removeDataObj);
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
@@ -62,7 +61,7 @@ public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterO
                                                        final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         LOG.trace("Received the Meter UPDATE request [Tbl id, node Id {} {} {}",
                 identifier, nodeIdent, update);
-        
+
         final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder();
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
@@ -78,7 +77,7 @@ public class MeterForwarder implements ForwardingRulesCommitter<Meter, AddMeterO
                                                  final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         LOG.trace("Received the Meter ADD request [Tbl id, node Id {} {} {}",
                 identifier, nodeIdent, addDataObj);
-        
+
         final AddMeterInputBuilder builder = new AddMeterInputBuilder(addDataObj);
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
index 94265eccfc737c3c4c3248429039e538c146bfa9..8cad7e50ed5b1ac36f8b3c32d5b06a1bb043ef3f 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -23,15 +24,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to config changes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapableNode> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedConfigListener.class);
-    protected final SyncReactor reactor;
+    private final SyncReactor reactor;
     private final FlowCapableNodeSnapshotDao configSnaphot;
     private final FlowCapableNodeDao operationalDao;
 
@@ -47,11 +45,10 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
         LOG.trace("Inventory Config changes {}", modifications.size());
         super.onDataTreeChanged(modifications);
     }
-    
+
     /**
      * Compare cached operational with current config modification. If operational is not present
      * skip calling Inventory RPCs.
-     * 
      * @throws InterruptedException from syncup
      */
     protected Optional<ListenableFuture<Boolean>> processNodeModification(
@@ -65,7 +62,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
         final Optional<FlowCapableNode> operationalNode = operationalDao.loadByNodeId(nodeId);
         if (!operationalNode.isPresent()) {
             LOG.info("Skip syncup, {} operational is not present", nodeId.getValue());
-            return Optional.absent();// we try to reconfigure switch is alive
+            return Optional.absent();
         }
 
         final DataObjectModification<FlowCapableNode> configModification = modification.getRootNode();
@@ -73,11 +70,11 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
         final FlowCapableNode dataAfter = configModification.getDataAfter();
         final ListenableFuture<Boolean> endResult;
         if (dataBefore == null && dataAfter != null) {
-            endResult = onNodeAdded(nodePath, dataBefore, dataAfter, operationalNode.get());
+            endResult = onNodeAdded(nodePath, dataAfter, operationalNode.get());
         } else if (dataBefore != null && dataAfter == null) {
-            endResult = onNodeDeleted(nodePath, dataBefore, operationalNode.get());
+            endResult = onNodeDeleted(nodePath, dataBefore);
         } else {
-            endResult = onNodeUpdated(nodePath, dataBefore, dataAfter, operationalNode.get());
+            endResult = onNodeUpdated(nodePath, dataBefore, dataAfter);
         }
 
         return Optional.of(endResult);
@@ -93,13 +90,11 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
      * optimal case (but the switch could be reprogrammed by another person/system.</li>
      * </ul>
      */
-    protected ListenableFuture<Boolean> onNodeAdded(InstanceIdentifier<FlowCapableNode> nodePath,
-            FlowCapableNode dataBefore, FlowCapableNode dataAfter, FlowCapableNode operationalNode)
-                    throws InterruptedException {
-        LOG.trace("onNodeAdded {}", nodePath);
-        
-        final ListenableFuture<Boolean> endResult =
-                reactor.syncup(nodePath, dataAfter, operationalNode);
+    private ListenableFuture<Boolean> onNodeAdded(InstanceIdentifier<FlowCapableNode> nodePath,
+                           FlowCapableNode dataAfter, FlowCapableNode operationalNode) throws InterruptedException {
+        NodeId nodeId = PathUtil.digNodeId(nodePath);
+        LOG.trace("onNodeAdded {}", nodeId);
+        final ListenableFuture<Boolean> endResult = reactor.syncup(nodePath, dataAfter, operationalNode, dsType());
         return endResult;
     }
 
@@ -110,13 +105,11 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
      * system which is updating operational store (that components is also trying to solve
      * scale/performance issues on several layers).
      */
-    protected ListenableFuture<Boolean> onNodeUpdated(InstanceIdentifier<FlowCapableNode> nodePath,
-            FlowCapableNode dataBefore, FlowCapableNode dataAfter, FlowCapableNode operationalNodeNode)
-                    throws InterruptedException {
-        LOG.trace("onNodeUpdated {}", nodePath);
-        
-        final ListenableFuture<Boolean> endResult =
-                reactor.syncup(nodePath, dataAfter, dataBefore);
+    private ListenableFuture<Boolean> onNodeUpdated(InstanceIdentifier<FlowCapableNode> nodePath,
+                          FlowCapableNode dataBefore, FlowCapableNode dataAfter) throws InterruptedException {
+        NodeId nodeId = PathUtil.digNodeId(nodePath);
+        LOG.trace("onNodeUpdated {}", nodeId);
+        final ListenableFuture<Boolean> endResult = reactor.syncup(nodePath, dataAfter, dataBefore, dsType());
         return endResult;
     }
 
@@ -125,12 +118,11 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
      * probably optimized using dedicated wipe-out RPC, but it has impact on switch if it is
      * programmed by two person/system
      */
-    protected ListenableFuture<Boolean> onNodeDeleted(InstanceIdentifier<FlowCapableNode> nodePath,
-            FlowCapableNode dataBefore, FlowCapableNode operationalNode) throws InterruptedException {
-        LOG.trace("onNodeDeleted {}", nodePath);
-        
-        final ListenableFuture<Boolean> endResult =
-                reactor.syncup(nodePath, null, dataBefore);
+    private ListenableFuture<Boolean> onNodeDeleted(InstanceIdentifier<FlowCapableNode> nodePath,
+                                                    FlowCapableNode dataBefore) throws InterruptedException {
+        NodeId nodeId = PathUtil.digNodeId(nodePath);
+        LOG.trace("onNodeDeleted {}", nodeId);
+        final ListenableFuture<Boolean> endResult = reactor.syncup(nodePath, null, dataBefore, dsType());
         return endResult;
     }
 
index e66bf3f25f8f4c5106b6bc70c6099ddf4afc30a2..738a652e5e0e08741a0f47d37d850223e235f573 100644 (file)
@@ -8,14 +8,14 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.List;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao;
 import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao;
@@ -29,25 +29,20 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to operational new nodes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedOperationalListener.class);
 
-    protected final SyncReactor reactor;
+    private final SyncReactor reactor;
+    private final FlowCapableNodeSnapshotDao operationalSnapshot;
+    private final FlowCapableNodeDao configDao;
 
-    private FlowCapableNodeSnapshotDao operationalSnaphot;
-
-    private FlowCapableNodeDao configDao;
-
-    public SimplifiedOperationalListener(SyncReactor reactor,
-            FlowCapableNodeSnapshotDao operationalSnaphot, FlowCapableNodeDao configDao) {
+    public SimplifiedOperationalListener(SyncReactor reactor, FlowCapableNodeSnapshotDao operationalSnapshot,
+                                         FlowCapableNodeDao configDao) {
         this.reactor = reactor;
-        this.operationalSnaphot = operationalSnaphot;
+        this.operationalSnapshot = operationalSnapshot;
         this.configDao = configDao;
     }
 
@@ -68,47 +63,41 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
      * @throws InterruptedException from syncup
      */
     protected Optional<ListenableFuture<Boolean>> processNodeModification(
-            DataTreeModification<Node> modification) throws ReadFailedException, InterruptedException {
-        updateCache(modification);
+            DataTreeModification<Node> modification) throws InterruptedException {
 
-        if (isAdd(modification) || isAddLogical(modification)) {
+        updateCache(modification);
+        if (isReconciliationNeeded(modification)) {
             return reconciliation(modification);
         }
-        // TODO: else = explicit reconciliation required
-
         return skipModification(modification);
     }
 
     /**
      * Remove if delete. Update only if FlowCapableNode Augmentation modified.
      *
-     * @param modification
+     * @param modification Datastore modification
+     * @return true for cache update, false for cache remove
      */
-    protected void updateCache(DataTreeModification<Node> modification) {
-        try {
-            boolean isDelete = isDelete(modification) || isDeleteLogical(modification);
-            if (isDelete) {
-                operationalSnaphot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
-                return;
-            }
-
-            operationalSnaphot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
-        } catch(Exception e) {
-            LOG.error("update cache failed {}", nodeId(modification), e);
+    protected boolean updateCache(DataTreeModification<Node> modification) {
+        if (isDelete(modification) || isDeleteLogical(modification)) {
+            operationalSnapshot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
+            return false;
         }
+        operationalSnapshot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
+        return true;
     }
 
-    protected Optional<ListenableFuture<Boolean>> skipModification(DataTreeModification<Node> modification) {
+    private Optional<ListenableFuture<Boolean>> skipModification(DataTreeModification<Node> modification) {
         LOG.trace("Skipping Inventory Operational modification {}, before {}, after {}", nodeIdValue(modification),
                 modification.getRootNode().getDataBefore() == null ? "null" : "nonnull",
                 modification.getRootNode().getDataAfter() == null ? "null" : "nonnull");
-        return Optional.absent();// skip otherwise event
+        return Optional.absent();
     }
 
     /**
-     * ModificationType.DELETE
+     * ModificationType.DELETE.
      */
-    protected boolean isDelete(DataTreeModification<Node> modification) {
+    private boolean isDelete(DataTreeModification<Node> modification) {
         if (ModificationType.DELETE == modification.getRootNode().getModificationType()) {
             LOG.trace("Delete {} (physical)", nodeIdValue(modification));
             return true;
@@ -120,7 +109,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
     /**
      * All connectors disappeared from operational store (logical delete).
      */
-    protected boolean isDeleteLogical(DataTreeModification<Node> modification) {
+    private boolean isDeleteLogical(DataTreeModification<Node> modification) {
         final DataObjectModification<Node> rootNode = modification.getRootNode();
         if (!safeConnectorsEmpty(rootNode.getDataBefore()) && safeConnectorsEmpty(rootNode.getDataAfter())) {
             LOG.trace("Delete {} (logical)", nodeIdValue(modification));
@@ -130,7 +119,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
         return false;
     }
 
-    protected boolean isAdd(DataTreeModification<Node> modification) {
+    private boolean isAdd(DataTreeModification<Node> modification) {
         final DataObjectModification<Node> rootNode = modification.getRootNode();
         final Node dataAfter = rootNode.getDataAfter();
         final Node dataBefore = rootNode.getDataBefore();
@@ -145,7 +134,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
     /**
      * All connectors appeared in operational store (logical add).
      */
-    protected boolean isAddLogical(DataTreeModification<Node> modification) {
+    private boolean isAddLogical(DataTreeModification<Node> modification) {
         final DataObjectModification<Node> rootNode = modification.getRootNode();
         if (safeConnectorsEmpty(rootNode.getDataBefore()) && !safeConnectorsEmpty(rootNode.getDataAfter())) {
             LOG.trace("Add {} (logical)", nodeIdValue(modification));
@@ -155,21 +144,25 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
         return false;
     }
 
-    protected Optional<ListenableFuture<Boolean>> reconciliation(
-            DataTreeModification<Node> modification) throws InterruptedException {
-        final NodeId nodeId = nodeId(modification);
-
-        LOG.debug("reconciliation {}", nodeId.getValue());
+    protected boolean isReconciliationNeeded(DataTreeModification<Node> modification) {
+        return isAdd(modification) || isAddLogical(modification);
+    }
 
+    private Optional<ListenableFuture<Boolean>> reconciliation(DataTreeModification<Node> modification) throws InterruptedException {
+        final NodeId nodeId = nodeId(modification);
         final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
-        final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, new NodeKey(nodeId(modification))).augmentation(FlowCapableNode.class);
-        final ListenableFuture<Boolean> rpcResult =
-                reactor.syncup(nodePath, nodeConfiguration.orNull(), flowCapableNodeAfter(modification));
-        return Optional.of(rpcResult);
+
+        if (nodeConfiguration.isPresent()) {
+            LOG.debug("Reconciliation: {}", nodeId.getValue());
+            final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class)
+                    .child(Node.class, new NodeKey(nodeId(modification))).augmentation(FlowCapableNode.class);
+            return Optional.of(reactor.syncup(nodePath, nodeConfiguration.get(), flowCapableNodeAfter(modification), dsType()));
+        } else {
+            return skipModification(modification);
+        }
     }
 
-    static FlowCapableNode flowCapableNodeAfter(DataTreeModification<Node> modification) {
+    private static FlowCapableNode flowCapableNodeAfter(DataTreeModification<Node> modification) {
         final Node dataAfter = modification.getRootNode().getDataAfter();
         if (dataAfter == null) {
             return null;
@@ -177,20 +170,17 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
         return dataAfter.getAugmentation(FlowCapableNode.class);
     }
 
-    static boolean safeConnectorsEmpty(Node node) {
+    private static boolean safeConnectorsEmpty(Node node) {
         if (node == null) {
             return true;
         }
 
         final List<NodeConnector> nodeConnectors = node.getNodeConnector();
-        if (nodeConnectors == null || nodeConnectors.isEmpty()) {
-            return true;
-        }
 
-        return false;
+        return nodeConnectors == null || nodeConnectors.isEmpty();
     }
 
-    static String nodeIdValue(DataTreeModification<Node> modification) {
+    private static String nodeIdValue(DataTreeModification<Node> modification) {
         final NodeId nodeId = nodeId(modification);
 
         if (nodeId == null) {
@@ -204,7 +194,6 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
         final DataObjectModification<Node> rootNode = modification.getRootNode();
         final Node dataAfter = rootNode.getDataAfter();
 
-
         if (dataAfter != null) {
             return dataAfter.getId();
         }
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalRetryListener.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalRetryListener.java
new file mode 100644 (file)
index 0000000..924e26f
--- /dev/null
@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao;
+import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.openflowplugin.applications.frsync.util.RetryRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Modified {@link SimplifiedOperationalListener} for usage of retry mechanism.
+ */
+public class SimplifiedOperationalRetryListener extends SimplifiedOperationalListener {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SimplifiedOperationalRetryListener.class);
+    private final RetryRegistry retryRegistry;
+
+    public SimplifiedOperationalRetryListener(SyncReactor reactor, FlowCapableNodeSnapshotDao operationalSnapshot,
+                                              FlowCapableNodeDao configDao, RetryRegistry retryRegistry) {
+        super(reactor, operationalSnapshot, configDao);
+        this.retryRegistry = retryRegistry;
+    }
+
+    /**
+     * Adding condition check for retry.
+     *
+     * @param modification operational datastore modification
+     * @return true if reconciliation is needed, false otherwise
+     */
+    protected boolean isReconciliationNeeded(DataTreeModification<Node> modification) {
+        return super.isReconciliationNeeded(modification) || isRegisteredAndConsistentForRetry(modification);
+    }
+
+    /**
+     * If node is removed unregister for retry in addition.
+     *
+     * @param modification operational datastore modification
+     * @return true for cache update, false for cache remove and retry unregister
+     */
+    protected boolean updateCache(DataTreeModification<Node> modification) {
+        boolean nodeUpdated = super.updateCache(modification);
+        if (!nodeUpdated) { // node removed if not updated
+            retryRegistry.unregisterIfRegistered(nodeId(modification));
+        }
+        return nodeUpdated;
+    }
+
+    /**
+     * Check if retry should be proceeded.
+     *
+     * @param modification operational modification
+     * @return true if device is registered for retry and actual modification is consistent, false otherwise
+     */
+    private boolean isRegisteredAndConsistentForRetry(DataTreeModification<Node> modification) {
+        final NodeId nodeId = PathUtil.digNodeId(modification.getRootPath().getRootIdentifier());
+
+        if (!retryRegistry.isRegistered(nodeId)) {
+            return false;
+        }
+
+        final FlowCapableStatisticsGatheringStatus gatheringStatus = modification.getRootNode().getDataAfter()
+                .getAugmentation(FlowCapableStatisticsGatheringStatus.class);
+
+        if (gatheringStatus == null) {
+            LOG.trace("Statistics gathering never started for: {}", nodeId.getValue());
+            return false;
+        }
+
+        final SnapshotGatheringStatusEnd gatheringStatusEnd = gatheringStatus.getSnapshotGatheringStatusEnd();
+
+        if (gatheringStatusEnd == null) {
+            LOG.trace("Statistics gathering is not over yet for: {}", nodeId.getValue());
+            return false;
+        }
+
+        if (!gatheringStatusEnd.isSucceeded()) {
+            LOG.debug("Statistics gathering was not successful for: {}", nodeId.getValue());
+            return false;
+        }
+
+        try {
+            Date timestampOfRegistration = retryRegistry.getRegistration(nodeId);
+            final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(RetryRegistry.DATE_AND_TIME_FORMAT);
+            Date timestampOfStatistics = simpleDateFormat.parse(gatheringStatusEnd.getEnd().getValue());
+            if (timestampOfStatistics.after(timestampOfRegistration)) {
+                LOG.debug("Fresh operational present for: {} -> going retry!", nodeId.getValue());
+                return true;
+            }
+        } catch (ParseException e) {
+            LOG.error("Timestamp parsing error {}", e);
+        }
+        LOG.debug("Fresh operational not present for: {}", nodeId.getValue());
+        return false;
+    }
+}
index fb0b3e98503f6cb08bd245631e5c10ce338c5edd..f05db11009bb3e718b00e15c9008a893caf3e824 100644 (file)
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.impl;\r
-\r
-import java.util.concurrent.Callable;\r
-import java.util.concurrent.TimeUnit;\r
-import java.util.concurrent.TimeoutException;\r
-\r
-import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
-import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-\r
-/**\r
- * Decorator for running delegate syncup in Future.\r
- */\r
-public class SyncReactorFutureDecorator implements SyncReactor {\r
-\r
-    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureDecorator.class);\r
-\r
-    private final SyncReactor delegate;\r
-    private final ListeningExecutorService executorService;\r
-\r
-    public static final String FRM_RPC_CLIENT_PREFIX = "FRM-RPC-client-";\r
-\r
-    public SyncReactorFutureDecorator(SyncReactor delegate, ListeningExecutorService executorService) {\r
-        this.delegate = delegate;\r
-        this.executorService = executorService;\r
-    }\r
-\r
-    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
-            final FlowCapableNode configTree, final FlowCapableNode operationalTree) throws InterruptedException {\r
-        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
-        LOG.trace("syncup {}", nodeId.getValue());\r
-\r
-        final ListenableFuture<Boolean> syncup = executorService.submit(new Callable<Boolean>() {\r
-            public Boolean call() throws Exception {\r
-                final String oldThreadName = updateThreadName(nodeId);\r
-\r
-                try {\r
-                    final Boolean ret = doSyncupInFuture(flowcapableNodePath, configTree, operationalTree)\r
-                            .get(10000, TimeUnit.MILLISECONDS);\r
-                    LOG.trace("ret {} {}", nodeId.getValue(), ret);\r
-                    return true;\r
-                } catch (TimeoutException e) {\r
-                    LOG.error("doSyncupInFuture timeout occured {}", nodeId.getValue(), e);\r
-                    return false;\r
-                } finally {\r
-                    updateThreadName(oldThreadName);\r
-                }\r
-            }\r
-        });\r
-        \r
-        return syncup;\r
-    }\r
-\r
-    protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
-            final FlowCapableNode configTree, final FlowCapableNode operationalTree)\r
-                    throws InterruptedException {\r
-        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
-        LOG.trace("doSyncupInFuture {}", nodeId.getValue());\r
-\r
-        return delegate.syncup(flowcapableNodePath, configTree, operationalTree);\r
-    }\r
-\r
-    static String threadName() {\r
-        final Thread currentThread = Thread.currentThread();\r
-        return currentThread.getName();\r
-    }\r
-\r
-    protected String updateThreadName(NodeId nodeId) {\r
-        final Thread currentThread = Thread.currentThread();\r
-        final String oldName = currentThread.getName();\r
-        try {\r
-            if (oldName.startsWith(SyncReactorFutureDecorator.FRM_RPC_CLIENT_PREFIX)) {\r
-                currentThread.setName(oldName + "@" + nodeId.getValue());\r
-            } else {\r
-                LOG.warn("try to update foreign thread name {} {}", nodeId, oldName);\r
-            }\r
-        } catch (Exception e) {\r
-            LOG.error("failed updating threadName {}", nodeId, e);\r
-        }\r
-        return oldName;\r
-    }\r
-\r
-    protected String updateThreadName(String name) {\r
-        final Thread currentThread = Thread.currentThread();\r
-        final String oldName = currentThread.getName();\r
-        try {\r
-            if (oldName.startsWith(SyncReactorFutureDecorator.FRM_RPC_CLIENT_PREFIX)) {\r
-                currentThread.setName(name);\r
-            } else {\r
-                LOG.warn("try to update foreign thread name {} {}", oldName, name);\r
-            }\r
-        } catch (Exception e) {\r
-            LOG.error("failed updating threadName {}", name, e);\r
-        }\r
-        return oldName;\r
-    }\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Decorator for running delegate syncup in Future.
+ */
+public class SyncReactorFutureDecorator implements SyncReactor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureDecorator.class);
+    public static final String FRM_RPC_CLIENT_PREFIX = "FRM-RPC-client-";
+    private final SyncReactor delegate;
+    private final ListeningExecutorService executorService;
+
+    public SyncReactorFutureDecorator(SyncReactor delegate, ListeningExecutorService executorService) {
+        this.delegate = delegate;
+        this.executorService = executorService;
+    }
+
+    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                            final LogicalDatastoreType dsType) throws InterruptedException {
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("syncup future {}", nodeId.getValue());
+
+        final ListenableFuture<Boolean> syncup = executorService.submit(new Callable<Boolean>() {
+            public Boolean call() throws Exception {
+                final String oldThreadName = updateThreadName(nodeId);
+
+                try {
+                    final Boolean ret = doSyncupInFuture(flowcapableNodePath, configTree, operationalTree, dsType)
+                            .get(10000, TimeUnit.MILLISECONDS);
+                    LOG.trace("ret {} {}", nodeId.getValue(), ret);
+                    return true;
+                } catch (TimeoutException e) {
+                    LOG.error("doSyncupInFuture timeout occured {}", nodeId.getValue(), e);
+                    return false;
+                } finally {
+                    updateThreadName(oldThreadName);
+                }
+            }
+        });
+
+        return syncup;
+    }
+
+    protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                                         final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                                         final LogicalDatastoreType dsType) throws InterruptedException {
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("doSyncupInFuture future {}", nodeId.getValue());
+
+        return delegate.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+    }
+
+    private String updateThreadName(NodeId nodeId) {
+        final Thread currentThread = Thread.currentThread();
+        final String oldName = currentThread.getName();
+        try {
+            if (oldName.startsWith(SyncReactorFutureDecorator.FRM_RPC_CLIENT_PREFIX)) {
+                currentThread.setName(oldName + "@" + nodeId.getValue());
+            } else {
+                LOG.warn("try to update foreign thread name {} {}", nodeId, oldName);
+            }
+        } catch (Exception e) {
+            LOG.error("failed updating threadName {}", nodeId, e);
+        }
+        return oldName;
+    }
+
+    private String updateThreadName(String name) {
+        final Thread currentThread = Thread.currentThread();
+        final String oldName = currentThread.getName();
+        try {
+            if (oldName.startsWith(SyncReactorFutureDecorator.FRM_RPC_CLIENT_PREFIX)) {
+                currentThread.setName(name);
+            } else {
+                LOG.warn("try to update foreign thread name {} {}", oldName, name);
+            }
+        } catch (Exception e) {
+            LOG.error("failed updating threadName {}", name, e);
+        }
+        return oldName;
+    }
+}
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureWithCompressionDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureWithCompressionDecorator.java
deleted file mode 100644 (file)
index 44f3ee7..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.impl;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.concurrent.Semaphore;\r
-\r
-import javax.annotation.concurrent.GuardedBy;\r
-\r
-import org.apache.commons.lang3.tuple.Pair;\r
-import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
-import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.util.concurrent.Futures;\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-\r
-/**\r
- * Enriches {@link SyncReactorFutureDecorator} with state compression.\r
- */\r
-public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFutureDecorator {\r
-\r
-    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureWithCompressionDecorator.class);\r
-\r
-    @GuardedBy("beforeCompressionGuard")\r
-    final Map<InstanceIdentifier<FlowCapableNode>, Pair<FlowCapableNode, FlowCapableNode>> beforeCompression =\r
-            new HashMap<>();\r
-    final Semaphore beforeCompressionGuard = new Semaphore(1, false);\r
-\r
-    public SyncReactorFutureWithCompressionDecorator(SyncReactor delegate, ListeningExecutorService executorService) {\r
-        super(delegate, executorService);\r
-    }\r
-\r
-    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
-            final FlowCapableNode configTree, final FlowCapableNode operationalTree) throws InterruptedException {\r
-        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
-        LOG.trace("syncup {}", nodeId.getValue());\r
-\r
-        try {\r
-            beforeCompressionGuard.acquire();\r
-\r
-            final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, configTree, operationalTree);\r
-            if (newFutureNecessary) {\r
-                super.syncup(flowcapableNodePath, configTree, operationalTree);\r
-            }\r
-            return Futures.immediateFuture(true);\r
-        } finally {\r
-            beforeCompressionGuard.release();\r
-        }\r
-    }\r
-\r
-    protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
-            final FlowCapableNode configTree, final FlowCapableNode operationalTree)\r
-                    throws InterruptedException {\r
-        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
-        LOG.trace("doSyncupInFuture {}", nodeId.getValue());\r
-\r
-        final Pair<FlowCapableNode, FlowCapableNode> lastCompressionState =\r
-                removeLastCompressionState(flowcapableNodePath);\r
-        if (lastCompressionState == null) {\r
-            return Futures.immediateFuture(true);\r
-        } else {\r
-            return super.doSyncupInFuture(flowcapableNodePath,\r
-                    lastCompressionState.getLeft(), lastCompressionState.getRight());\r
-        }\r
-    }\r
-\r
-    protected boolean updateCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
-            final FlowCapableNode configTree, final FlowCapableNode operationalTree) {\r
-        final Pair<FlowCapableNode, FlowCapableNode> previous = beforeCompression.get(flowcapableNodePath);\r
-        if (previous != null) {\r
-            final FlowCapableNode previousOperational = previous.getRight();\r
-            beforeCompression.put(flowcapableNodePath, Pair.of(configTree, previousOperational));\r
-            return false;\r
-        } else {\r
-            beforeCompression.put(flowcapableNodePath, Pair.of(configTree, operationalTree));\r
-            return true;\r
-        }\r
-    }\r
-\r
-    protected Pair<FlowCapableNode/* config */, FlowCapableNode/* operational */> removeLastCompressionState(\r
-            final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {\r
-        try {\r
-            try {\r
-                beforeCompressionGuard.acquire();\r
-            } catch (InterruptedException e) {\r
-                return null;\r
-            }\r
-\r
-            return beforeCompression.remove(flowcapableNodePath);\r
-        } finally {\r
-            beforeCompressionGuard.release();\r
-        }\r
-    }\r
-}\r
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecorator.java
new file mode 100644 (file)
index 0000000..a3edde0
--- /dev/null
@@ -0,0 +1,120 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.openflowplugin.applications.frsync.util.ZipQueueEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Enriches {@link SyncReactorFutureDecorator} with state compression.
+ */
+public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureZipDecorator.class);
+
+    @GuardedBy("compressionGuard")
+    private final Map<InstanceIdentifier<FlowCapableNode>, ZipQueueEntry> compressionQueue = new HashMap<>();
+    private final Semaphore compressionGuard = new Semaphore(1, false);
+
+    public SyncReactorFutureZipDecorator(SyncReactor delegate, ListeningExecutorService executorService) {
+        super(delegate, executorService);
+    }
+
+    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                            final LogicalDatastoreType dsType) throws InterruptedException {
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("syncup zip {}", nodeId.getValue());
+
+        try {
+            compressionGuard.acquire();
+
+            final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, configTree, operationalTree, dsType);
+            if (newFutureNecessary) {
+                super.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+            }
+            return Futures.immediateFuture(true);
+        } finally {
+            compressionGuard.release();
+        }
+    }
+
+    protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                                         final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                                         final LogicalDatastoreType dsType) throws InterruptedException {
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("doSyncupInFuture zip {}", nodeId.getValue());
+
+        final ZipQueueEntry lastCompressionState = removeLastCompressionState(flowcapableNodePath);
+        if (lastCompressionState == null) {
+            return Futures.immediateFuture(true);
+        } else {
+            return super.doSyncupInFuture(flowcapableNodePath,
+                    lastCompressionState.getLeft(), lastCompressionState.getRight(), dsType);
+        }
+    }
+
+    /**
+     * If there is config delta in compression queue for the device and new configuration is coming,
+     * update its zip queue entry. Create/replace zip queue entry for the device with operational delta otherwise.
+     */
+    private boolean updateCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                           final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                           final LogicalDatastoreType dsType) {
+        final ZipQueueEntry previousEntry = compressionQueue.get(flowcapableNodePath);
+
+        if (previousEntry != null && dsType == LogicalDatastoreType.CONFIGURATION
+                && previousEntry.getDsType() == LogicalDatastoreType.CONFIGURATION) {
+            putOptimizedConfigDelta(flowcapableNodePath, configTree, previousEntry);
+        } else {
+            putLatestOperationalDelta(flowcapableNodePath, configTree, operationalTree, dsType);
+        }
+        return previousEntry == null;
+    }
+
+    private void putOptimizedConfigDelta(InstanceIdentifier<FlowCapableNode> flowcapableNodePath, FlowCapableNode configTree,
+                                         ZipQueueEntry previous) {
+        compressionQueue.put(flowcapableNodePath, new ZipQueueEntry(configTree, previous.getRight(), previous.getDsType()));
+    }
+
+    private void putLatestOperationalDelta(InstanceIdentifier<FlowCapableNode> flowcapableNodePath, FlowCapableNode configTree,
+                                           FlowCapableNode operationalTree, LogicalDatastoreType dsType) {
+        compressionQueue.put(flowcapableNodePath, new ZipQueueEntry(configTree, operationalTree, dsType));
+    }
+
+    private ZipQueueEntry removeLastCompressionState(
+            final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {
+        try {
+            try {
+                compressionGuard.acquire();
+            } catch (InterruptedException e) {
+                return null;
+            }
+
+            return compressionQueue.remove(flowcapableNodePath);
+        } finally {
+            compressionGuard.release();
+        }
+    }
+
+}
\ No newline at end of file
index ea019e5ee6bd72bf2c0266ee24f596014bf362c5..9def21853c861d8d4634ec978cf3499779d7f3e6 100644 (file)
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.impl;\r
-\r
-import java.util.concurrent.Semaphore;\r
-import java.util.concurrent.TimeUnit;\r
-\r
-import javax.annotation.Nullable;\r
-\r
-import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;\r
-import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
-import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.base.Preconditions;\r
-import com.google.common.util.concurrent.FutureCallback;\r
-import com.google.common.util.concurrent.Futures;\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-\r
-/**\r
- * Decorator for NodeId level syncup locking.\r
- */\r
-public class SyncReactorGuardDecorator implements SyncReactor {\r
-\r
-    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorGuardDecorator.class);\r
-\r
-    private final SyncReactor delegate;\r
-    private final SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper;\r
-\r
-    public SyncReactorGuardDecorator(SyncReactor delegate,\r
-            SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper) {\r
-        this.delegate = delegate;\r
-        this.semaphoreKeeper = semaphoreKeeper;\r
-    }\r
-\r
-    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
-            final FlowCapableNode configTree, final FlowCapableNode operationalTree) throws InterruptedException {\r
-        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
-        LOG.trace("syncup {}", nodeId.getValue());\r
-\r
-        final long stampBeforeGuard = System.nanoTime();\r
-        final Semaphore guard = summonGuardAndAcquire(flowcapableNodePath);//TODO handle InteruptedException\r
-\r
-        try {\r
-            final long stampAfterGuard = System.nanoTime();\r
-            if (LOG.isDebugEnabled()) {\r
-                LOG.debug("syncup start {} waiting:{} guard:{} thread:{}", nodeId.getValue(),\r
-                        formatNanos(stampAfterGuard - stampBeforeGuard),\r
-                        guard, threadName());\r
-            }\r
-            \r
-            final ListenableFuture<Boolean> endResult =\r
-                    delegate.syncup(flowcapableNodePath, configTree, operationalTree);//TODO handle InteruptedException\r
-            \r
-            Futures.addCallback(endResult, new FutureCallback<Boolean>() {\r
-                @Override\r
-                public void onSuccess(@Nullable final Boolean result) {\r
-                    if (LOG.isDebugEnabled()) {\r
-                        final long stampFinished = System.nanoTime();\r
-                        LOG.debug("syncup finished {} took:{} rpc:{} wait:{} guard:{}, thread:{}", nodeId.getValue(),\r
-                                formatNanos(stampFinished - stampBeforeGuard),\r
-                                formatNanos(stampFinished - stampAfterGuard),\r
-                                formatNanos(stampAfterGuard - stampBeforeGuard),\r
-                                guard, threadName());\r
-                    }\r
-                    \r
-                    lockReleaseForNodeId(nodeId, guard);\r
-                }\r
-                \r
-                @Override\r
-                public void onFailure(final Throwable t) {\r
-                    if (LOG.isDebugEnabled()) {\r
-                        final long stampFinished = System.nanoTime();\r
-                        LOG.warn("syncup failed {} took:{} rpc:{} wait:{} guard:{} thread:{}", nodeId.getValue(),\r
-                                formatNanos(stampFinished - stampBeforeGuard),\r
-                                formatNanos(stampFinished - stampAfterGuard),\r
-                                formatNanos(stampAfterGuard - stampBeforeGuard),\r
-                                guard, threadName());\r
-                    }\r
-                    \r
-                    lockReleaseForNodeId(nodeId, guard);\r
-                }\r
-            });\r
-            return endResult;\r
-        } catch(InterruptedException e) {\r
-            lockReleaseForNodeId(nodeId, guard);\r
-            throw e;\r
-        }\r
-    }\r
-\r
-    protected String formatNanos(long nanos) {\r
-        return "'" + TimeUnit.NANOSECONDS.toMillis(nanos) + " ms'";\r
-    }\r
-\r
-    /**\r
-     * get guard\r
-     *\r
-     * @param flowcapableNodePath\r
-     * @return\r
-     */\r
-    protected Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath)\r
-            throws InterruptedException {\r
-        final Semaphore guard = Preconditions.checkNotNull(semaphoreKeeper.summonGuard(flowcapableNodePath),\r
-                "no guard for " + flowcapableNodePath);\r
-\r
-        if (LOG.isDebugEnabled()) {\r
-            final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
-            try {\r
-                LOG.debug("syncup summon {} guard:{} thread:{}", nodeId.getValue(), guard, threadName());\r
-            } catch (Exception e) {\r
-                LOG.error("error logging guard after summon before aquiring {}", nodeId);\r
-            }\r
-        }\r
-\r
-        guard.acquire();\r
-        return guard;\r
-    }\r
-\r
-    /**\r
-     * unlock per node\r
-     *\r
-     * @param nodeId\r
-     * @param guard\r
-     */\r
-    protected void lockReleaseForNodeId(final NodeId nodeId,\r
-            final Semaphore guard) {\r
-        if (guard == null) {\r
-            return;\r
-        }\r
-        guard.release();\r
-    }\r
-\r
-    static String threadName() {\r
-        final Thread currentThread = Thread.currentThread();\r
-        return currentThread.getName();\r
-    }\r
-\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+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 java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
+import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Decorator for NodeId level syncup locking.
+ */
+public class SyncReactorGuardDecorator implements SyncReactor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorGuardDecorator.class);
+
+    private final SyncReactor delegate;
+    private final SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper;
+
+    public SyncReactorGuardDecorator(SyncReactor delegate,
+            SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper) {
+        this.delegate = delegate;
+        this.semaphoreKeeper = semaphoreKeeper;
+    }
+
+    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                            final LogicalDatastoreType dsType) throws InterruptedException {
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("syncup guard {}", nodeId.getValue());
+
+        final long stampBeforeGuard = System.nanoTime();
+        final Semaphore guard = summonGuardAndAcquire(flowcapableNodePath);//TODO handle InteruptedException
+
+        try {
+            final long stampAfterGuard = System.nanoTime();
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("syncup start {} waiting:{} guard:{} thread:{}", nodeId.getValue(),
+                        formatNanos(stampAfterGuard - stampBeforeGuard),
+                        guard, threadName());
+            }
+
+            final ListenableFuture<Boolean> endResult =
+                    delegate.syncup(flowcapableNodePath, configTree, operationalTree, dsType);//TODO handle InteruptedException
+
+            Futures.addCallback(endResult, new FutureCallback<Boolean>() {
+                @Override
+                public void onSuccess(@Nullable final Boolean result) {
+                    if (LOG.isDebugEnabled()) {
+                        final long stampFinished = System.nanoTime();
+                        LOG.debug("syncup finished {} took:{} rpc:{} wait:{} guard:{} permits thread:{}", nodeId.getValue(),
+                                formatNanos(stampFinished - stampBeforeGuard),
+                                formatNanos(stampFinished - stampAfterGuard),
+                                formatNanos(stampAfterGuard - stampBeforeGuard),
+                                guard.availablePermits(), threadName());
+                    }
+
+                    releaseGuardForNodeId(guard);
+                }
+
+                @Override
+                public void onFailure(final Throwable t) {
+                    if (LOG.isDebugEnabled()) {
+                        final long stampFinished = System.nanoTime();
+                        LOG.warn("syncup failed {} took:{} rpc:{} wait:{} guard:{} permits thread:{}", nodeId.getValue(),
+                                formatNanos(stampFinished - stampBeforeGuard),
+                                formatNanos(stampFinished - stampAfterGuard),
+                                formatNanos(stampAfterGuard - stampBeforeGuard),
+                                guard.availablePermits(), threadName());
+                    }
+
+                    releaseGuardForNodeId(guard);
+                }
+            });
+            return endResult;
+        } catch(InterruptedException e) {
+            releaseGuardForNodeId(guard);
+            throw e;
+        }
+    }
+
+    private String formatNanos(long nanos) {
+        return "'" + TimeUnit.NANOSECONDS.toMillis(nanos) + " ms'";
+    }
+
+    /**
+     * Get guard and lock for node.
+     * @param flowcapableNodePath II of node for which guard should be acquired
+     * @return semaphore guard
+     */
+    private Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath)
+            throws InterruptedException {
+        final Semaphore guard = Preconditions.checkNotNull(semaphoreKeeper.summonGuard(flowcapableNodePath),
+                "no guard for " + flowcapableNodePath);
+
+        if (LOG.isDebugEnabled()) {
+            final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+            try {
+                LOG.debug("syncup summon {} guard:{} thread:{}", nodeId.getValue(), guard, threadName());
+            } catch (Exception e) {
+                LOG.error("error logging guard after summon before aquiring {}", nodeId);
+            }
+        }
+
+        guard.acquire();
+        return guard;
+    }
+
+    /**
+     * Unlock and release guard.
+     * @param guard semaphore guard which should be unlocked
+     */
+    private void releaseGuardForNodeId(final Semaphore guard) {
+        if (guard == null) {
+            return;
+        }
+        guard.release();
+    }
+
+    private static String threadName() {
+        final Thread currentThread = Thread.currentThread();
+        return currentThread.getName();
+    }
+
+}
index de4819e11d79787886ffb527125f3890ea35ad60..504d583d032f8a02dc029067e20e4cc593265a9f 100644 (file)
@@ -18,6 +18,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput;
@@ -56,10 +57,13 @@ public class SyncReactorImpl implements SyncReactor {
 
     @Override
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree) {
+                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                            final LogicalDatastoreType dsType) {
 
-        LOG.trace("syncup {} cfg:{} oper:{}", nodeIdent, configTree == null ? "is null" : "non null", operationalTree == null ? "is null" : "non null");
+        final NodeId nodeId = PathUtil.digNodeId(nodeIdent);
+        LOG.trace("syncup impl {} cfg:{} oper:{}", nodeId.getValue(), configTree == null ? "is null" : "non null", operationalTree == null ? "is null" : "non null");
         final SyncCrudCounters counters = new SyncCrudCounters();
+
         /**
          * instructions:
          *  - extract diff changes and prepare change steps in safe order
@@ -73,8 +77,6 @@ public class SyncReactorImpl implements SyncReactor {
          *  - flows - meters - groups (reordered)
          **/
 
-        final NodeId nodeId = PathUtil.digNodeId(nodeIdent);
-
         final List<ItemSyncBox<Group>> groupsToAddOrUpdate = extractGroupsToAddOrUpdate(nodeId, configTree, operationalTree);
         final ItemSyncBox<Meter> metersToAddOrUpdate = extractMetersToAddOrUpdate(nodeId, configTree, operationalTree);
         final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate = extractFlowsToAddOrUpdate(nodeId, configTree, operationalTree);
@@ -121,15 +123,16 @@ public class SyncReactorImpl implements SyncReactor {
                     );
                 }
 
+                LOG.trace("syncup errors: {}", input.getErrors());
                 return input.isSuccessful();
             }
         });
     }
 
     @VisibleForTesting
-    static List<ItemSyncBox<Group>> extractGroupsToAddOrUpdate(final NodeId nodeId,
-                                                               final FlowCapableNode flowCapableNodeConfigured,
-                                                               final FlowCapableNode flowCapableNodeOperational) {
+    private static List<ItemSyncBox<Group>> extractGroupsToAddOrUpdate(final NodeId nodeId,
+                                                                       final FlowCapableNode flowCapableNodeConfigured,
+                                                                       final FlowCapableNode flowCapableNodeOperational) {
         final List<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
         final List<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
         final Map<Long, Group> groupOperationalMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsOperational);
@@ -141,9 +144,9 @@ public class SyncReactorImpl implements SyncReactor {
     }
 
     @VisibleForTesting
-    static ItemSyncBox<Meter> extractMetersToAddOrUpdate(final NodeId nodeId,
-                                                         final FlowCapableNode flowCapableNodeConfigured,
-                                                         final FlowCapableNode flowCapableNodeOperational) {
+    private static ItemSyncBox<Meter> extractMetersToAddOrUpdate(final NodeId nodeId,
+                                                                 final FlowCapableNode flowCapableNodeConfigured,
+                                                                 final FlowCapableNode flowCapableNodeOperational) {
         final List<Meter> metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured);
         final List<Meter> metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational);
         final Map<MeterId, Meter> meterOperationalMap = FlowCapableNodeLookups.wrapMetersToMap(metersOperational);
@@ -152,9 +155,9 @@ public class SyncReactorImpl implements SyncReactor {
     }
 
     @VisibleForTesting
-    static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToAddOrUpdate(final NodeId nodeId,
-                                                                      final FlowCapableNode flowCapableNodeConfigured,
-                                                                      final FlowCapableNode flowCapableNodeOperational) {
+    private static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToAddOrUpdate(final NodeId nodeId,
+                                                                              final FlowCapableNode flowCapableNodeConfigured,
+                                                                              final FlowCapableNode flowCapableNodeOperational) {
         final List<Table> tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured);
         if (tablesConfigured.isEmpty()) {
             return Collections.emptyMap();
@@ -167,9 +170,9 @@ public class SyncReactorImpl implements SyncReactor {
     }
 
     @VisibleForTesting
-    static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToRemove(final NodeId nodeId,
-                                                                 final FlowCapableNode flowCapableNodeConfigured,
-                                                                 final FlowCapableNode flowCapableNodeOperational) {
+    private static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToRemove(final NodeId nodeId,
+                                                                         final FlowCapableNode flowCapableNodeConfigured,
+                                                                         final FlowCapableNode flowCapableNodeOperational) {
         final List<Table> tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational);
         if (tablesOperational.isEmpty()) {
             return Collections.emptyMap();
@@ -182,9 +185,9 @@ public class SyncReactorImpl implements SyncReactor {
     }
 
     @VisibleForTesting
-    static ItemSyncBox<Meter> extractMetersToRemove(final NodeId nodeId,
-                                                    final FlowCapableNode flowCapableNodeConfigured,
-                                                    final FlowCapableNode flowCapableNodeOperational) {
+    private static ItemSyncBox<Meter> extractMetersToRemove(final NodeId nodeId,
+                                                            final FlowCapableNode flowCapableNodeConfigured,
+                                                            final FlowCapableNode flowCapableNodeOperational) {
         final List<Meter> metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured);
         final List<Meter> metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational);
         final Map<MeterId, Meter> meterConfiguredMap = FlowCapableNodeLookups.wrapMetersToMap(metersConfigured);
@@ -193,9 +196,9 @@ public class SyncReactorImpl implements SyncReactor {
     }
 
     @VisibleForTesting
-    static List<ItemSyncBox<Group>> extractGroupsToRemove(final NodeId nodeId,
-                                                          final FlowCapableNode flowCapableNodeConfigured,
-                                                          final FlowCapableNode flowCapableNodeOperational) {
+    private static List<ItemSyncBox<Group>> extractGroupsToRemove(final NodeId nodeId,
+                                                                  final FlowCapableNode flowCapableNodeConfigured,
+                                                                  final FlowCapableNode flowCapableNodeOperational) {
         final List<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
         final List<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
         final Map<Long, Group> groupConfiguredMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsConfigured);
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecorator.java
new file mode 100644 (file)
index 0000000..d504855
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.openflowplugin.applications.frsync.util.RetryRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Adding retry mechanism in case of unsuccessful syncup.
+ */
+public class SyncReactorRetryDecorator implements SyncReactor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorRetryDecorator.class);
+
+    private final SyncReactor delegate;
+    private final RetryRegistry retryRegistry;
+
+    public SyncReactorRetryDecorator(final SyncReactor delegate, RetryRegistry retryRegistry) {
+        this.delegate = delegate;
+        this.retryRegistry = retryRegistry;
+    }
+
+    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
+                                            final LogicalDatastoreType dsType) throws InterruptedException {
+
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("syncup retry {}", nodeId.getValue());
+
+        if (dsType == LogicalDatastoreType.CONFIGURATION && retryRegistry.isRegistered(nodeId)) {
+            LOG.trace("Config change ignored because device is in retry [{}]", nodeId);
+            return Futures.immediateFuture(Boolean.FALSE);
+        }
+
+        ListenableFuture<Boolean> syncupResult = delegate.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+
+        return Futures.transform(syncupResult, new Function<Boolean, Boolean>() {
+            @Override
+            public Boolean apply(Boolean result) {
+                LOG.trace("syncup ret in retry {}", result);
+                if (result) {
+                    retryRegistry.unregisterIfRegistered(nodeId);
+                    return true;
+                } else {
+                    retryRegistry.register(nodeId);
+                    // TODO  elicit statistics gathering if not running actually
+                    // triggerStatisticsGathering(nodeId);
+                    return false;
+                }
+            }
+        });
+    }
+}
index f2dc532bb6596369caaef4c5ff22e8c02766ab92..74347b1a8735107de89b32b64e3c355c4eb50999 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import java.util.Collections;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesUpdateCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
index 48560a457581128ec451afe58805d2a9b93dea1a..ed90d2854624002de508eda5556f6ce1b3fca027 100644 (file)
@@ -180,7 +180,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
             @Override
             public void onSuccess(@Nullable final RpcResult<ProcessFlatBatchOutput> result) {
                 if (!result.isSuccessful() && result.getResult() != null && !result.getResult().getBatchFailure().isEmpty()) {
-                    Map<Range<Integer>, Batch> batchMap = mapBachesToRanges(inputBatchBag, failureIndexLimit);
+                    Map<Range<Integer>, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit);
 
                     for (BatchFailure batchFailure : result.getResult().getBatchFailure()) {
                         for (Map.Entry<Range<Integer>, Batch> rangeBatchEntry : batchMap.entrySet()) {
@@ -224,7 +224,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         }
     }
 
-    static Map<Range<Integer>, Batch> mapBachesToRanges(final List<Batch> inputBatchBag, final int failureIndexLimit) {
+    static Map<Range<Integer>, Batch> mapBatchesToRanges(final List<Batch> inputBatchBag, final int failureIndexLimit) {
         final Map<Range<Integer>, Batch> batchMap = new LinkedHashMap<>();
         final PeekingIterator<Batch> batchPeekingIterator = Iterators.peekingIterator(inputBatchBag.iterator());
         while (batchPeekingIterator.hasNext()) {
@@ -248,7 +248,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // process flow remove
         if (flowItemSyncTableMap != null) {
             for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
-                final TableKey tableKey = syncBoxEntry.getKey();
                 final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
 
                 if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
@@ -422,7 +421,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // process flow add+update
         if (flowItemSyncTableMap != null) {
             for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
-                final TableKey tableKey = syncBoxEntry.getKey();
                 final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
 
                 if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
index 4a56acb38b124625ef4dfd9828b864f6d5e7b238..3f4b53efdb850e00fbe6792a3000fc50d54eb415 100644 (file)
@@ -152,7 +152,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
     }
 
 
-    protected ListenableFuture<RpcResult<Void>> addMissingFlows(final NodeId nodeId,
+    ListenableFuture<RpcResult<Void>> addMissingFlows(final NodeId nodeId,
                                                                 final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                 final Map<TableKey, ItemSyncBox<Flow>> flowsInTablesSyncBox,
                                                                 final SyncCrudCounters counters) {
@@ -216,7 +216,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 */
     }
 
-    protected ListenableFuture<RpcResult<Void>> removeRedundantFlows(final NodeId nodeId,
+    ListenableFuture<RpcResult<Void>> removeRedundantFlows(final NodeId nodeId,
                                                                      final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                      final Map<TableKey, ItemSyncBox<Flow>> removalPlan,
                                                                      final SyncCrudCounters counters) {
@@ -249,7 +249,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
 
     }
 
-    protected ListenableFuture<RpcResult<Void>> removeRedundantMeters(final NodeId nodeId,
+    ListenableFuture<RpcResult<Void>> removeRedundantMeters(final NodeId nodeId,
                                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                       final ItemSyncBox<Meter> meterRemovalPlan,
                                                                       final SyncCrudCounters counters) {
@@ -412,7 +412,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                         PathUtil.digNodePath(nodeIdent), transactionService));
     }
 
-    protected ListenableFuture<RpcResult<Void>> addMissingMeters(final NodeId nodeId,
+    ListenableFuture<RpcResult<Void>> addMissingMeters(final NodeId nodeId,
                                                                  final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                  final ItemSyncBox<Meter> syncBox,
                                                                  final SyncCrudCounters counters) {
@@ -463,7 +463,7 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 */
     }
 
-    protected ListenableFuture<RpcResult<Void>> addMissingGroups(final NodeId nodeId,
+    ListenableFuture<RpcResult<Void>> addMissingGroups(final NodeId nodeId,
                                                                  final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                  final List<ItemSyncBox<Group>> groupsAddPlan,
                                                                  final SyncCrudCounters counters) {
index a0b9fde0af446c292cdaad3c09188b48b2d36ebe..f5b86cdc741c57c85ba4ce1c84d6a23492503b67 100644 (file)
@@ -24,12 +24,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 public class SynchronizationDiffInput {
 
     private final InstanceIdentifier<FlowCapableNode> nodeIdent;
-    final List<ItemSyncBox<Group>> groupsToAddOrUpdate;
-    final ItemSyncBox<Meter> metersToAddOrUpdate;
-    final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate;
-    final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove;
-    final ItemSyncBox<Meter> metersToRemove;
-    final List<ItemSyncBox<Group>> groupsToRemove;
+    private final List<ItemSyncBox<Group>> groupsToAddOrUpdate;
+    private final ItemSyncBox<Meter> metersToAddOrUpdate;
+    private final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate;
+    private final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove;
+    private final ItemSyncBox<Meter> metersToRemove;
+    private final List<ItemSyncBox<Group>> groupsToRemove;
 
     public SynchronizationDiffInput(final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                     final List<ItemSyncBox<Group>> groupsToAddOrUpdate,
index 86c8cadbdb7223a65c9ccac5c155ed51171ebf34..3cf70b23c2c2244c2ff3709d6214317d39785c58 100644 (file)
@@ -1,68 +1,68 @@
-/**\r
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowplugin.applications.frsync.markandsweep;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
-\r
-/**\r
- * Identifier of {@link Flow} on device. Switch does not know about flow-id but,\r
- * it uses combination of these unique fields: table-id, priority, match.\r
- */\r
-public class SwitchFlowId {\r
-\r
-    private final Short tableId;\r
-\r
-    private final Integer priority;\r
-\r
-    private final Match match;\r
-\r
-    public SwitchFlowId(Flow flow) {\r
-        this.tableId = flow.getTableId();\r
-        this.priority = flow.getPriority();\r
-        this.match = flow.getMatch();\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + ((match == null) ? 0 : match.hashCode());\r
-        result = prime * result + ((priority == null) ? 0 : priority.hashCode());\r
-        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj)\r
-            return true;\r
-        if (obj == null)\r
-            return false;\r
-        if (getClass() != obj.getClass())\r
-            return false;\r
-        SwitchFlowId other = (SwitchFlowId) obj;\r
-        if (match == null) {\r
-            if (other.match != null)\r
-                return false;\r
-        } else if (!match.equals(other.match))\r
-            return false;\r
-        if (priority == null) {\r
-            if (other.priority != null)\r
-                return false;\r
-        } else if (!priority.equals(other.priority))\r
-            return false;\r
-        if (tableId == null) {\r
-            if (other.tableId != null)\r
-                return false;\r
-        } else if (!tableId.equals(other.tableId))\r
-            return false;\r
-        return true;\r
-    }\r
-}\r
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.markandsweep;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+
+/**
+ * Identifier of {@link Flow} on device. Switch does not know about flow-id but,
+ * it uses combination of these unique fields: table-id, priority, match.
+ */
+public class SwitchFlowId {
+
+    private final Short tableId;
+
+    private final Integer priority;
+
+    private final Match match;
+
+    public SwitchFlowId(Flow flow) {
+        this.tableId = flow.getTableId();
+        this.priority = flow.getPriority();
+        this.match = flow.getMatch();
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((priority == null) ? 0 : priority.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SwitchFlowId other = (SwitchFlowId) obj;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (priority == null) {
+            if (other.priority != null)
+                return false;
+        } else if (!priority.equals(other.priority))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        return true;
+    }
+}
index df3a3db7951c0e3e2641e1d81b51d67fb90b0ff2..52d0623d00d7a35ce044ce464525bdd7ee768b37 100644 (file)
@@ -14,10 +14,8 @@ import java.util.List;
 import java.util.Map;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.openflowplugin.applications.frsync.markandsweep.SwitchFlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
@@ -70,7 +68,7 @@ public final class FlowCapableNodeLookups {
 
         return flowMap;
     }
-    
+
     public static Flow flowMapLookupExisting(Flow flow, Map<SwitchFlowId, Flow> flowConfigMap) {
         return flowConfigMap.get(new SwitchFlowId(flow));
     }
index 6635d0a5d3ddbc4e44c479366fcbdbc69cb51420..1e9b49ea9ae1d1b70ea53cab3e63f0d7b37d6c2f 100644 (file)
@@ -33,8 +33,7 @@ public class ItemSyncBox<I> {
     }
 
     /**
-     * Tuple holder for original and updated item
-     *
+     * Tuple holder for original and updated item.
      * @param <I> basic type
      */
     public static final class ItemUpdateTuple<I> {
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistry.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistry.java
new file mode 100644 (file)
index 0000000..eedc6c1
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.util;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Holder of registration request for fresh operational.
+ */
+public class RetryRegistry {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RetryRegistry.class);
+    private final Map<NodeId, Date> registration = new ConcurrentHashMap<>();
+    public static final String DATE_AND_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
+
+    public Date register(NodeId nodeId) {
+        Date timestamp = new Date();
+        registration.put(nodeId, timestamp);
+        if (timestamp != null) {
+            LOG.debug("Registered for next consistent operational: {}", nodeId.getValue());
+        }
+        return timestamp;
+    }
+
+    public Date unregisterIfRegistered(NodeId nodeId) {
+        Date timestamp = registration.remove(nodeId);
+        if (timestamp != null) {
+            LOG.debug("Unregistered for next consistent operational: {}", nodeId.getValue());
+        }
+        return timestamp;
+    }
+
+    public boolean isRegistered(NodeId nodeId) {
+        return registration.get(nodeId) != null;
+    }
+
+    public Date getRegistration(NodeId nodeId) {
+        return registration.get(nodeId);
+    }
+
+}
index 1a11c9f16fe509eaccfde0df8bada1325db22815..419525a1326b97c4d2e008bb47d3fa8faf1df534 100644 (file)
@@ -8,15 +8,12 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.util;
 
-import java.util.concurrent.Semaphore;
-
-import javax.annotation.Nonnull;
-
-import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
-
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
+import java.util.concurrent.Semaphore;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
 
 /**
  * Key-based semaphore provider.
@@ -43,7 +40,7 @@ public class SemaphoreKeeperGuavaImpl<K> implements SemaphoreKeeper<K> {
     public Semaphore summonGuard(final @Nonnull K key) {
         return semaphoreCache.getUnchecked(key);
     }
-    
+
     @Override
     public String toString() {
         return super.toString() + " size:" + (semaphoreCache == null ? null : semaphoreCache.size()) + " " + semaphoreCache;
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ZipQueueEntry.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ZipQueueEntry.java
new file mode 100644 (file)
index 0000000..ec4d8a8
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.util;
+
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.impl.SyncReactorFutureZipDecorator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+
+/**
+ * Simple compression queue entry for {@link SyncReactorFutureZipDecorator}.
+ */
+public class ZipQueueEntry {
+    private final FlowCapableNode after;
+    private final FlowCapableNode before;
+    private final LogicalDatastoreType dsTypeBefore;
+
+    public ZipQueueEntry(final FlowCapableNode after, final FlowCapableNode before,
+                         final LogicalDatastoreType dsTypeBefore) {
+        this.after = after;
+        this.before = before;
+        this.dsTypeBefore = dsTypeBefore;
+    }
+
+    public FlowCapableNode getLeft() {
+        return after;
+    }
+
+    public FlowCapableNode getRight() {
+        return before;
+    }
+
+    public LogicalDatastoreType getDsType() {
+        return dsTypeBefore;
+    }
+
+}
index 1effafda9442521b74794c7e0a46fc0247aba4e1..7feb84aa58f1324ed504d3bea1b4381a3d263e2d 100644 (file)
@@ -12,7 +12,6 @@ import java.math.BigInteger;
 import java.util.Collections;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 1b1fac25e5f91068fe6239d87c122f0303d6efd2..76fb1fad803b57f91e90879625058f6bb523502f 100644 (file)
@@ -21,11 +21,8 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
@@ -57,13 +54,8 @@ public class ForwardingRulesSyncProviderTest {
                 });
 
         provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry);
-
-        Mockito.verify(rpcRegistry).getRpcService(SalFlowService.class);
-        Mockito.verify(rpcRegistry).getRpcService(SalGroupService.class);
-        Mockito.verify(rpcRegistry).getRpcService(SalMeterService.class);
         Mockito.verify(rpcRegistry).getRpcService(SalTableService.class);
-        Mockito.verify(rpcRegistry).getRpcService(FlowCapableTransactionService.class);
-
+        Mockito.verify(rpcRegistry).getRpcService(SalFlatBatchService.class);
         Mockito.verify(broker).registerProvider(provider);
     }
 
index 2cf2eec9516ef166a8755d256877c538e29eebd4..8e980dcb60bd0bc2b51b9fcb95d3f2b9e99aeba1 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 7c820748d689234a9ca751d2eacfed4bee92b2bb..28ae5dc4c3e637916963a648e30050e3a673f697 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 3b5caeaec036a414671d888f33755d4d35607640..4c20088ded8fa1897bc91bf5c00357c90e348e02 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,42 +37,50 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-
 /**
  * Test for {@link SimplifiedConfigListener}.
  */
-@SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 public class SimplifiedConfigListenerTest {
 
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+    private SimplifiedConfigListener nodeListenerConfig;
+    private LogicalDatastoreType dsType = LogicalDatastoreType.CONFIGURATION;
+
     @Mock
     private SyncReactor reactor;
     @Mock
-    private DataBroker db;
+    private ReadOnlyTransaction roTx;
     @Mock
     private DataTreeModification<FlowCapableNode> dataTreeModification;
     @Mock
-    private ReadOnlyTransaction roTx;
-    @Mock
     private DataObjectModification<FlowCapableNode> configModification;
-
-    private InstanceIdentifier<FlowCapableNode> nodePath;
-    private SimplifiedConfigListener nodeListenerConfig;
+    @Mock
+    private FlowCapableNode dataBefore;
+    @Mock
+    private FlowCapableNode dataAfter;
 
     @Before
     public void setUp() throws Exception {
-        final FlowCapableNodeSnapshotDao configSnaphot = new FlowCapableNodeSnapshotDao();
-        final FlowCapableNodeSnapshotDao operationalSnaphot = new FlowCapableNodeSnapshotDao();
-        final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnaphot,
+        final DataBroker db = Mockito.mock(DataBroker.class);
+        final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
                 new FlowCapableNodeOdlDao(db, LogicalDatastoreType.OPERATIONAL));
 
-        
-        nodeListenerConfig = new SimplifiedConfigListener(reactor, configSnaphot, operationalDao);
-        nodePath = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, new NodeKey(new NodeId("testNode")))
+        nodeListenerConfig = new SimplifiedConfigListener(reactor, configSnapshot, operationalDao);
+        fcNodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID))
                 .augmentation(FlowCapableNode.class);
+
+        final DataTreeIdentifier<FlowCapableNode> dataTreeIdentifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, fcNodePath);
+
+        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
+        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
+        Mockito.when(dataTreeModification.getRootNode()).thenReturn(configModification);
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
     }
 
     @Test
@@ -80,24 +89,53 @@ public class SimplifiedConfigListenerTest {
     }
 
     @Test
-    public void testOnDataTreeChanged() throws Exception {
-        final FlowCapableNode configTree = Mockito.mock(FlowCapableNode.class);
-        final FlowCapableNode operationalTree = Mockito.mock(FlowCapableNode.class);
-        final DataTreeIdentifier<FlowCapableNode> dataTreeIdentifier =
-                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, nodePath);
+    public void testOnDataTreeChangedSyncupAdd() throws InterruptedException {
+        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
+        Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
 
-        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
-        Mockito.when(dataTreeModification.getRootNode()).thenReturn(configModification);
-        Mockito.when(configModification.getDataAfter()).thenReturn(configTree);
-        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
-        Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(operationalTree))).when(
-                roTx).read(LogicalDatastoreType.OPERATIONAL, nodePath);
-        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),Matchers.<FlowCapableNode>any()))
-                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(reactor).syncup(fcNodePath, dataAfter, dataBefore, dsType);
+        Mockito.verifyNoMoreInteractions(reactor);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedSyncupUpdate() throws InterruptedException {
+        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
+        Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
+        Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
+
+        nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(reactor).syncup(fcNodePath, dataAfter, dataBefore, dsType);
+        Mockito.verifyNoMoreInteractions(reactor);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedSyncupDelete() throws InterruptedException {
+        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
+        Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
+
+        nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(reactor).syncup(fcNodePath, null, dataBefore, dsType);
+        Mockito.verifyNoMoreInteractions(reactor);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedSkip() {
+        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath)).
+                thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
 
         nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(nodePath, configTree, operationalTree);
+        Mockito.verifyZeroInteractions(reactor);
         Mockito.verify(roTx).close();
     }
 }
\ No newline at end of file
index 4be870f5e8bd48dc6225ac7639b523b803787146..30383c0a2200dcfce9414281b36e9e343aaa6acc 100644 (file)
@@ -8,8 +8,10 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
-
+import java.util.List;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -20,6 +22,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -32,51 +35,57 @@ import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSn
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.Futures;
 
 /**
  * Test for {@link SimplifiedOperationalListener}.
  */
-@SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 public class SimplifiedOperationalListenerTest {
 
-    public static final NodeId NODE_ID = new NodeId("testNode");
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+    private SimplifiedOperationalListener nodeListenerOperational;
+    private final LogicalDatastoreType dsType = LogicalDatastoreType.OPERATIONAL;
+
     @Mock
     private SyncReactor reactor;
     @Mock
-    private DataBroker db;
+    private ReadOnlyTransaction roTx;
     @Mock
     private DataTreeModification<Node> dataTreeModification;
     @Mock
-    private ReadOnlyTransaction roTx;
-    @Mock
     private DataObjectModification<Node> operationalModification;
+    @Mock
+    private FlowCapableNode configNode;
+    @Mock
+    private Node operationalNode;
+    @Mock
+    private FlowCapableNode fcOperationalNode;
 
-    private InstanceIdentifier<Node> nodePath;
-    private InstanceIdentifier<FlowCapableNode> fcNodePath;
-    private SimplifiedOperationalListener nodeListenerOperational;
-
-    @SuppressWarnings("deprecation")
     @Before
     public void setUp() throws Exception {
-        final FlowCapableNodeSnapshotDao configSnaphot = new FlowCapableNodeSnapshotDao();
-        final FlowCapableNodeSnapshotDao operationalSnaphot = new FlowCapableNodeSnapshotDao();
-        final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnaphot,
+        final DataBroker db = Mockito.mock(DataBroker.class);
+        final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
                 new FlowCapableNodeOdlDao(db, LogicalDatastoreType.CONFIGURATION));
 
-
-        nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnaphot, configDao);
-        nodePath = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, new NodeKey(NODE_ID));
+        nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao);
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final DataTreeIdentifier<Node> dataTreeIdentifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+
+        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
+        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
     }
 
     @Test
@@ -85,29 +94,51 @@ public class SimplifiedOperationalListenerTest {
     }
 
     @Test
-    public void testOnDataTreeChanged() throws Exception {
-        final FlowCapableNode configTree = Mockito.mock(FlowCapableNode.class);
-        final Node mockOperationalNode = Mockito.mock(Node.class);
-        final FlowCapableNode mockOperationalFlowCapableNode = Mockito.mock(FlowCapableNode.class);
-        Mockito.when(mockOperationalNode.getAugmentation(FlowCapableNode.class))
-            .thenReturn(mockOperationalFlowCapableNode);
-        Mockito.when(mockOperationalNode.getId()).thenReturn(NODE_ID);
+    public void testOnDataTreeChangedSyncupAdd() throws InterruptedException {
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
 
-        final DataTreeIdentifier<Node> dataTreeIdentifier =
-                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
-        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
-        Mockito.when(operationalModification.getDataAfter()).thenReturn(mockOperationalNode);
-        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
-        Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(configTree))).when(
-                roTx).read(LogicalDatastoreType.CONFIGURATION, fcNodePath);
-        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),Matchers.<FlowCapableNode>any()))
-                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.verify(reactor).syncup(fcNodePath, configNode, fcOperationalNode, dsType);
+        Mockito.verifyNoMoreInteractions(reactor);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedAddSkip() {
+        // Related to bug 5920 -> https://bugs.opendaylight.org/show_bug.cgi?id=5920
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, configTree, mockOperationalFlowCapableNode);
+        Mockito.verifyZeroInteractions(reactor);
         Mockito.verify(roTx).close();
     }
+
+    @Test
+    public void testOnDataTreeChangedSyncupDeletePhysical() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.DELETE);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedSyncupDeleteLogical() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        List<NodeConnector> nodeConnectorList = Mockito.mock(List.class);
+        Mockito.when(operationalNode.getNodeConnector()).thenReturn(nodeConnectorList);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
 }
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalRetryListenerTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalRetryListenerTest.java
new file mode 100644 (file)
index 0000000..fd23c4a
--- /dev/null
@@ -0,0 +1,205 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCachedDao;
+import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao;
+import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeOdlDao;
+import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao;
+import org.opendaylight.openflowplugin.applications.frsync.util.RetryRegistry;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Test for {@link SimplifiedOperationalRetryListener}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SimplifiedOperationalRetryListenerTest {
+
+    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(RetryRegistry.DATE_AND_TIME_FORMAT);
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+    private SimplifiedOperationalRetryListener nodeListenerOperational;
+    private final String timestampBefore = "0000-12-12T01:01:01.000-07:00";
+    private final String timestampAfter = "9999-12-12T01:01:01.000-07:00";
+    private final LogicalDatastoreType dsType = LogicalDatastoreType.OPERATIONAL;
+
+    @Mock
+    private SyncReactor reactor;
+    @Mock
+    private ReadOnlyTransaction roTx;
+    @Mock
+    private DataTreeModification<Node> dataTreeModification;
+    @Mock
+    private DataObjectModification<Node> operationalModification;
+    @Mock
+    private FlowCapableNode configNode;
+    @Mock
+    private Node operationalNode;
+    @Mock
+    private FlowCapableNode fcOperationalNode;
+    @Mock
+    private RetryRegistry retryRegistry;
+    @Mock
+    private FlowCapableStatisticsGatheringStatus statisticsGatheringStatus;
+    @Mock
+    private SnapshotGatheringStatusEnd snapshotGatheringStatusEnd;
+
+    @Before
+    public void setUp() throws Exception {
+        final DataBroker db = Mockito.mock(DataBroker.class);
+        final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
+                new FlowCapableNodeOdlDao(db, LogicalDatastoreType.CONFIGURATION));
+
+        nodeListenerOperational = new SimplifiedOperationalRetryListener(reactor, operationalSnapshot, configDao, retryRegistry);
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final DataTreeIdentifier<Node> dataTreeIdentifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+
+        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
+        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryNotRegistered() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(false);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryButStaticsGatheringNotStarted() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(null);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryButStaticsGatheringNotFinished() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(null);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryButStaticsGatheringNotSuccessful() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
+        Mockito.when(snapshotGatheringStatusEnd.isSucceeded()).thenReturn(false);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryAndFreshOperationalNotPresent() throws ParseException {
+        final DateAndTime timestamp = Mockito.mock(DateAndTime.class);
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
+        Mockito.when(snapshotGatheringStatusEnd.isSucceeded()).thenReturn(true);
+        Mockito.when(snapshotGatheringStatusEnd.getEnd()).thenReturn(timestamp);
+        Mockito.when(snapshotGatheringStatusEnd.getEnd().getValue()).thenReturn(timestampBefore);
+        Mockito.when(retryRegistry.getRegistration(NODE_ID)).thenReturn(simpleDateFormat.parse(timestampAfter));
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryAndFreshOperationalPresent() throws Exception {
+        final DateAndTime timestamp = Mockito.mock(DateAndTime.class);
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
+        Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
+        Mockito.when(snapshotGatheringStatusEnd.isSucceeded()).thenReturn(true);
+        Mockito.when(snapshotGatheringStatusEnd.getEnd()).thenReturn(timestamp);
+        Mockito.when(snapshotGatheringStatusEnd.getEnd().getValue()).thenReturn(timestampAfter);
+        Mockito.when(retryRegistry.getRegistration(NODE_ID)).thenReturn(simpleDateFormat.parse(timestampBefore));
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(reactor).syncup(fcNodePath, configNode, fcOperationalNode, dsType);
+        Mockito.verifyNoMoreInteractions(reactor);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedRetryAndNodeDeleted() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(dataTreeModification.getRootNode().getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(retryRegistry).unregisterIfRegistered(NODE_ID);
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+}
\ No newline at end of file
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java
new file mode 100644 (file)
index 0000000..f9fb441
--- /dev/null
@@ -0,0 +1,186 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InOrder;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link SyncReactorFutureZipDecorator}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SyncReactorFutureZipDecoratorTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureZipDecoratorTest.class);
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private SyncReactorFutureZipDecorator reactor;
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+    private ListeningExecutorService syncThreadPool;
+
+    @Mock
+    private SyncReactorGuardDecorator delegate;
+
+    @Before
+    public void setUp() {
+        syncThreadPool = FrmExecutors.instance()
+                .newFixedThreadPool(1, new ThreadFactoryBuilder()
+                        .setNameFormat(SyncReactorFutureDecorator.FRM_RPC_CLIENT_PREFIX + "%d")
+                        .setDaemon(false)
+                        .build());
+
+        reactor = new SyncReactorFutureZipDecorator(delegate, syncThreadPool);
+        fcNodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID))
+                .augmentation(FlowCapableNode.class);
+    }
+
+    @Test
+    public void testSyncupWithOptimizedConfigDeltaCompression() throws Exception {
+        final FlowCapableNode dataBefore = Mockito.mock(FlowCapableNode.class);
+        final FlowCapableNode dataAfter = Mockito.mock(FlowCapableNode.class);
+        final FlowCapableNode dataAfter2 = Mockito.mock(FlowCapableNode.class);
+        final CountDownLatch latchForFirst = new CountDownLatch(1);
+        final CountDownLatch latchForNext = new CountDownLatch(1);
+        final LogicalDatastoreType dsType = LogicalDatastoreType.CONFIGURATION;
+
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenAnswer(new Answer<ListenableFuture<Boolean>>() {
+                    @Override
+                    public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
+                        LOG.info("unlocking next configs");
+                        latchForNext.countDown();
+                        latchForFirst.await();
+                        LOG.info("unlocking first delegate");
+                        return Futures.immediateFuture(Boolean.TRUE);
+                    }
+                }).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+
+        final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
+        allResults.add(reactor.syncup(fcNodePath, dataBefore, null, dsType));
+        latchForNext.await();
+
+        allResults.add(reactor.syncup(fcNodePath, dataAfter, dataBefore, dsType));
+        allResults.add(reactor.syncup(fcNodePath, null, dataAfter, dsType));
+        allResults.add(reactor.syncup(fcNodePath, dataAfter2, null, dsType));
+        latchForFirst.countDown();
+
+        Futures.allAsList(allResults).get(1, TimeUnit.SECONDS);
+        LOG.info("all configs done");
+
+        syncThreadPool.shutdown();
+        boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
+        if (!terminated) {
+            LOG.info("thread pool not terminated.");
+            syncThreadPool.shutdownNow();
+        }
+        final InOrder inOrder = Mockito.inOrder(delegate);
+        inOrder.verify(delegate).syncup(fcNodePath, dataBefore, null, dsType);
+        inOrder.verify(delegate).syncup(fcNodePath, dataAfter2, dataBefore, dsType);
+        inOrder.verifyNoMoreInteractions();
+    }
+
+    @Test
+    public void testSyncupConfigEmptyQueue() throws Exception {
+        final FlowCapableNode dataBefore = Mockito.mock(FlowCapableNode.class);
+        final FlowCapableNode dataAfter = Mockito.mock(FlowCapableNode.class);
+        final CountDownLatch latchForNext = new CountDownLatch(1);
+        final LogicalDatastoreType dsType = LogicalDatastoreType.CONFIGURATION;
+
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenAnswer(new Answer<ListenableFuture<Boolean>>() {
+            @Override
+            public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
+                LOG.info("unlocking next config");
+                latchForNext.countDown();
+                return Futures.immediateFuture(Boolean.TRUE);
+            }
+            }).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+
+        reactor.syncup(fcNodePath, dataBefore, null, dsType);
+        latchForNext.await();
+        reactor.syncup(fcNodePath, dataAfter, dataBefore, dsType);
+
+        boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
+        if (!terminated) {
+            LOG.info("thread pool not terminated.");
+            syncThreadPool.shutdownNow();
+        }
+        final InOrder inOrder = Mockito.inOrder(delegate);
+        inOrder.verify(delegate).syncup(fcNodePath, dataBefore, null, dsType);
+        inOrder.verify(delegate).syncup(fcNodePath, dataAfter, dataBefore, dsType);
+        inOrder.verifyNoMoreInteractions();
+
+    }
+
+    @Test
+    public void testSyncupRewriteZipEntryWithOperationalDelta() throws Exception {
+        final FlowCapableNode configBefore = Mockito.mock(FlowCapableNode.class);
+        final FlowCapableNode configAfter = Mockito.mock(FlowCapableNode.class);
+        final FlowCapableNode configActual = Mockito.mock(FlowCapableNode.class);
+        final FlowCapableNode freshOperational = Mockito.mock(FlowCapableNode.class);
+        final CountDownLatch latchForFirst = new CountDownLatch(1);
+        final CountDownLatch latchForNext = new CountDownLatch(1);
+
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenAnswer(new Answer<ListenableFuture<Boolean>>() {
+            @Override
+            public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
+                LOG.info("unlocking for fresh operational");
+                latchForNext.countDown();
+                latchForFirst.await();
+                LOG.info("unlocking first delegate");
+                return Futures.immediateFuture(Boolean.TRUE);
+            }
+        }).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+
+        reactor.syncup(fcNodePath, configAfter, configBefore, LogicalDatastoreType.CONFIGURATION);
+        latchForNext.await();
+
+        reactor.syncup(fcNodePath, configActual, freshOperational, LogicalDatastoreType.OPERATIONAL);
+        latchForFirst.countDown();
+
+        syncThreadPool.shutdown();
+        boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
+        if (!terminated) {
+            LOG.info("thread pool not terminated.");
+            syncThreadPool.shutdownNow();
+        }
+        Mockito.verify(delegate, Mockito.times(1)).syncup(fcNodePath, configActual, freshOperational, LogicalDatastoreType.OPERATIONAL);
+    }
+
+    @After
+    public void tearDown() {
+        syncThreadPool.shutdownNow();
+    }
+}
\ No newline at end of file
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java
new file mode 100644 (file)
index 0000000..d10a228
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.Futures;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Test for {@link SyncReactorGuardDecorator}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SyncReactorGuardDecoratorTest {
+
+    private static final NodeId NODE_ID = new NodeId("test-node");
+    private SyncReactorGuardDecorator reactor;
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+    private final LogicalDatastoreType dsType = LogicalDatastoreType.CONFIGURATION;
+
+    @Mock
+    private SyncReactorRetryDecorator delegate;
+    @Mock
+    private FlowCapableNode fcConfigNode;
+    @Mock
+    private FlowCapableNode fcOperationalNode;
+
+    @Before
+    public void setUp() throws Exception {
+        final SemaphoreKeeperGuavaImpl semaphoreKeeper = new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true);
+        reactor = new SyncReactorGuardDecorator(delegate, semaphoreKeeper);
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final Node operationalNode = Mockito.mock(Node.class);
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+    }
+
+    @Test
+    public void testSyncupSuccess() throws Exception {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verifyNoMoreInteractions(delegate);
+    }
+
+    @Test
+    public void testSyncupFail() throws Exception {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFailedFuture(new Exception()));
+
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verifyNoMoreInteractions(delegate);
+
+    }
+
+}
\ No newline at end of file
index 17f470bb2e363dda02a3760b691ea148f365be78..588a4019369bafdfb9983a4df32ecb11fb5d820d 100644 (file)
@@ -22,6 +22,7 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
 import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput;
 import org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil;
@@ -54,13 +55,12 @@ public class SyncReactorImplTest {
     private static final NodeId NODE_ID = new NodeId("unit-nodeId");
     private static final InstanceIdentifier<FlowCapableNode> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(NODE_ID)).augmentation(FlowCapableNode.class);
-
     private SyncReactorImpl reactor;
+
     @Mock
     private DataBroker db;
     @Mock
     private SyncPlanPushStrategy syncPlanPushStrategy;
-
     @Captor
     private ArgumentCaptor<Group> groupCaptor;
     @Captor
@@ -107,7 +107,7 @@ public class SyncReactorImplTest {
                 Matchers.<SyncCrudCounters>any()))
                 .thenReturn(RpcResultBuilder.<Void>success().buildFuture());
 
-        final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, configFcn, operationalFcn);
+        final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, configFcn, operationalFcn, LogicalDatastoreType.CONFIGURATION);
         try {
             Assert.assertTrue(syncupResult.isDone());
             final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorRetryDecoratorTest.java
new file mode 100644 (file)
index 0000000..1bf41a4
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.Futures;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.util.RetryRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Test for {@link SyncReactorRetryDecorator}
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SyncReactorRetryDecoratorTest {
+
+    private static final NodeId NODE_ID = new NodeId("test-node");
+    private SyncReactorRetryDecorator reactor;
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+    private final LogicalDatastoreType dsType = LogicalDatastoreType.CONFIGURATION;
+
+    @Mock
+    private SyncReactorImpl delegate;
+    @Mock
+    private RetryRegistry retryRegistry;
+    @Mock
+    private FlowCapableNode fcConfigNode;
+    @Mock
+    private FlowCapableNode fcOperationalNode;
+
+    @Before
+    public void setUp() {
+        reactor = new SyncReactorRetryDecorator(delegate, retryRegistry);
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final Node operationalNode = Mockito.mock(Node.class);
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+    }
+
+    @Test
+    public void testSyncupSuccess() throws InterruptedException {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verifyNoMoreInteractions(delegate);
+        Mockito.verify(retryRegistry).unregisterIfRegistered(NODE_ID);
+    }
+
+    @Test
+    public void testSyncupFail() throws InterruptedException {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any(), Matchers.<LogicalDatastoreType>any())).thenReturn(Futures.immediateFuture(Boolean.FALSE));
+
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verifyNoMoreInteractions(delegate);
+        Mockito.verify(retryRegistry).register(NODE_ID);
+    }
+
+    @Test
+    public void testSyncupConfigIgnoreInRetry() throws InterruptedException {
+        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+
+        Mockito.verifyZeroInteractions(delegate);
+    }
+
+}
\ No newline at end of file
index 7e88950e84b7b001c4b4a466bd511eea6e802ce7..86cf17bf4cadf39d11b6b41dee709a0b41b03170 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index a30d600799df016e1c1c8d2dd2bba8239f956b4f..0eadaef2304f7a106a96f14236ae1358035fb9de 100644 (file)
@@ -43,7 +43,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Group createPlainGroup(final long gid) {
+    private static Group createPlainGroup(final long gid) {
         return new GroupBuilder().setGroupId(new GroupId(gid)).build();
     }
 
@@ -67,7 +67,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Meter createPlainMeter(final long mid) {
+    private static Meter createPlainMeter(final long mid) {
         return new MeterBuilder().setMeterId(new MeterId(mid)).build();
     }
 
@@ -91,7 +91,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Flow createPlainFlow(final String fid) {
+    private static Flow createPlainFlow(final String fid) {
         return new FlowBuilder().setId(new FlowId(fid)).build();
     }
 }
index e83d9b036212141eb0c0753d29b10f42440d4d5e..90b7cf8b876e0c0a44a960641d7b1c526be5562e 100644 (file)
@@ -287,7 +287,7 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
                 new BatchBuilder().setBatchOrder(9).build(),
                 new BatchBuilder().setBatchOrder(15).build()
         );
-        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBachesToRanges(inputBatchBag, 42);
+        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBatchesToRanges(inputBatchBag, 42);
 
         Assert.assertEquals(4, rangeBatchMap.size());
         int idx = 0;
index 75a34b81a09920396f4e74a35386c6770217ebd1..99358de3e2b0e71b0b56889bcef398813342af01 100644 (file)
@@ -65,8 +65,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Test for {@link SyncPlanPushStrategyIncrementalImpl}.
@@ -74,8 +72,6 @@ import org.slf4j.LoggerFactory;
 @RunWith(MockitoJUnitRunner.class)
 public class SyncPlanPushStrategyIncrementalImplTest {
 
-    private static final Logger LOG = LoggerFactory.getLogger(SyncPlanPushStrategyIncrementalImplTest.class);
-
     private static final NodeId NODE_ID = new NodeId("unit-nodeId");
     private static final InstanceIdentifier<FlowCapableNode> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(NODE_ID)).augmentation(FlowCapableNode.class);
index b5d68931b916609f0763fd1d82452d87e0536181..61fd6384b828e844fafbb5af1c2bd972a9313799 100644 (file)
@@ -8,9 +8,18 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.util;
 
+import com.google.common.base.Splitter;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
@@ -45,15 +54,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * Test for {@link ReconcileUtil}.
  */
@@ -61,8 +61,9 @@ import java.util.Set;
 public class ReconcileUtilTest {
 
     private static final NodeId NODE_ID = new NodeId("unit-node-id");
-    private InstanceIdentifier<Node> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
+    private final InstanceIdentifier<Node> NODE_IDENT = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(NODE_ID));
+    private static final Splitter COMMA_SPLITTER = Splitter.on(",");
 
     @Rule
     public ExpectedException thrown = ExpectedException.none();
@@ -328,8 +329,8 @@ public class ReconcileUtilTest {
 
     private ItemSyncBox<String> createSyncBox(final String pushes, final String updates) {
         ItemSyncBox<String> syncBox1 = new ItemSyncBox<>();
-        syncBox1.getItemsToPush().addAll(Arrays.asList(pushes.split(",")));
-        for (String orig : updates.split(",")) {
+        syncBox1.getItemsToPush().addAll(COMMA_SPLITTER.splitToList(pushes));
+        for (String orig : COMMA_SPLITTER.splitToList(updates)) {
             syncBox1.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(orig, orig + "_updated"));
         }
         return syncBox1;
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistryTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistryTest.java
new file mode 100644 (file)
index 0000000..115bb2c
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2016 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.openflowplugin.applications.frsync.util;
+
+import java.util.Date;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+/**
+ * Test for {@link RetryRegistry}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class RetryRegistryTest {
+
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private RetryRegistry retryRegistry;
+
+    @Before
+    public void setUp() throws Exception {
+        retryRegistry = new RetryRegistry();
+    }
+
+    @Test
+    public void testRegister() {
+        Date timestamp = retryRegistry.register(NODE_ID);
+        Assert.assertEquals(true, retryRegistry.isRegistered(NODE_ID));
+        Assert.assertNotNull(timestamp);
+    }
+
+    @Test
+    public void testUnregisterIfRegistered() {
+        retryRegistry.register(NODE_ID);
+        Date timestamp = retryRegistry.unregisterIfRegistered(NODE_ID);
+        Assert.assertEquals(false, retryRegistry.isRegistered(NODE_ID));
+        Assert.assertNotNull(timestamp);
+    }
+
+    @Test
+    public void testUnregisterIfNotRegistered() {
+        Date timestamp = retryRegistry.unregisterIfRegistered(NODE_ID);
+        Assert.assertEquals(false, retryRegistry.isRegistered(NODE_ID));
+        Assert.assertNull(timestamp);
+    }
+
+}
index f874eb7b5de3e8de9de6f21f001a4dda637032a7..8affd2a5b2444bed518cfd6019d796c810d42ef8 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory;
 public class SemaphoreKeeperTest {
     private static final Logger LOG = LoggerFactory.getLogger(SemaphoreKeeperTest.class);
     private SemaphoreKeeperGuavaImpl<String> semaphoreKeeper;
-    final String key = "11";
+    private final String key = "11";
 
     @Before
     public void setUp() throws Exception {
@@ -92,7 +91,7 @@ public class SemaphoreKeeperTest {
             for (int i = 0; i < steps; i++) {
                 executorService.submit(task);
             }
-            Thread.sleep(1000L);
+            Thread.sleep(100L);
             System.gc();
 
             executorService.shutdown();
diff --git a/applications/inventory-manager/src/main/config/default-config.xml b/applications/inventory-manager/src/main/config/default-config.xml
deleted file mode 100644 (file)
index cfb992a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<snapshot>
-  <required-capabilities>
-    <!--<capability>urn:opendaylight:params:xml:ns:yang:southbound:impl?module=southbound-impl&amp;revision=2015-01-05</capability>-->
-    <capability>urn:opendaylight:inventory?module=opendaylight-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:flow:inventory?module=flow-node-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:flow:types?module=opendaylight-flow-types&amp;revision=2013-10-26</capability>
-    <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service?module=distributed-entity-ownership-service&amp;revision=2015-08-10</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:inventory-manager:impl">prefix:inventory-manager-impl</type>
-          <name>inventory-manager-default</name>
-          <broker>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <name>binding-osgi-broker</name>
-          </broker>
-          <entity-ownership-service>
-            <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
-            <name>entity-ownership-service</name>
-          </entity-ownership-service>
-        </module>
-      </modules>
-    </data>
-  </configuration>
-</snapshot>
index 3610157774a360893d7bca9c26fd4db3ab9711f6..1ed9397e54bd43a33304b64a0b7c3be40a0fa9ff 100644 (file)
@@ -9,41 +9,30 @@ package org.opendaylight.openflowplugin.applications.inventory.manager;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class InventoryActivator implements BindingAwareProvider, AutoCloseable {
+public class InventoryActivator implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(InventoryActivator.class);
-    private FlowCapableInventoryProvider provider;
-    final private EntityOwnershipService eos;
-
-    public InventoryActivator(EntityOwnershipService eos) {
-        this.eos = eos;
-    }
 
+    private final FlowCapableInventoryProvider provider;
 
-    @Override
-    public void onSessionInitiated(final ProviderContext session) {
-        DataBroker dataBroker = session.getSALService(DataBroker.class);
-        NotificationProviderService salNotifiService =
-                session.getSALService(NotificationProviderService.class);
+    public InventoryActivator(DataBroker dataBroker, NotificationProviderService notificationService,
+            EntityOwnershipService eos) {
+        provider = new FlowCapableInventoryProvider(dataBroker, notificationService, eos);
+    }
 
-        provider = new FlowCapableInventoryProvider(dataBroker, salNotifiService, eos);
+    public void start() {
         provider.start();
     }
 
     @Override
-    public void close() throws Exception {
-        if (provider != null) {
-            try {
-                provider.close();
-            } catch (InterruptedException e) {
-                LOG.warn("Interrupted while waiting for shutdown", e);
-            }
-            provider = null;
+    public void close() {
+        try {
+            provider.close();
+        } catch (InterruptedException e) {
+            LOG.warn("Interrupted while waiting for shutdown", e);
         }
     }
 }
diff --git a/applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModule.java b/applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModule.java
deleted file mode 100644 (file)
index 673aa25..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530;
-
-import org.opendaylight.openflowplugin.applications.inventory.manager.InventoryActivator;
-
-public class InventoryManagerImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530.AbstractInventoryManagerImplModule {
-    public InventoryManagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public InventoryManagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530.InventoryManagerImplModule 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() {
-        InventoryActivator provider = new InventoryActivator(getEntityOwnershipServiceDependency());
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
-}
diff --git a/applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModuleFactory.java b/applications/inventory-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/inventory/manager/impl/rev150530/InventoryManagerImplModuleFactory.java
deleted file mode 100644 (file)
index 49369d4..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: inventory-manager-impl yang module local name: inventory-manager-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Sat May 30 18:52:44 PDT 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530;
-public class InventoryManagerImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.inventory.manager.impl.rev150530.AbstractInventoryManagerImplModuleFactory {
-
-}
diff --git a/applications/inventory-manager/src/main/yang/inventory-manager-impl.yang b/applications/inventory-manager/src/main/yang/inventory-manager-impl.yang
deleted file mode 100644 (file)
index f3483ec..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-module inventory-manager-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:inventory-manager:impl";
-    prefix "inventory-manager-impl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
-    import opendaylight-entity-ownership-service { prefix eos; }
-
-    description
-        "Service definition for inventory manager";
-
-    revision "2015-05-30" {
-        description
-            "Initial revision";
-    }
-
-    identity inventory-manager-impl {
-        base config:module-type;
-        config:java-name-prefix InventoryManagerImpl;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case inventory-manager-impl {
-            when "/config:modules/config:module/config:type = 'inventory-manager-impl'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-
-            container entity-ownership-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity eos:entity-ownership-service;
-                    }
-                }
-            }
-        }
-    }
-}
index 29a8478e204931cb0fafcc85a690f6ef5ae4ff56..8977cf3c4751f4cce8d84c96881dbe712a4e7b39 100644 (file)
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
             </plugin>
-
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/initial/71-lldp-speaker.xml</file>
-                                    <type>xml</type>
-                                    <classifier>config</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
     </build>
 </project>
index a45c69544b92d866d85c5ee7dd525306e5017087..6351d546befb85076142e361e1b64eaca389ec6c 100644 (file)
@@ -46,7 +46,7 @@ public class LLDPSpeaker implements AutoCloseable, NodeConnectorEventsObserver,
     private final Map<InstanceIdentifier<NodeConnector>, TransmitPacketInput> nodeConnectorMap = new ConcurrentHashMap<>();
     private final ScheduledFuture<?> scheduledSpeakerTask;
     private final MacAddress addressDestionation;
-    private OperStatus operationalStatus = OperStatus.RUN;
+    private volatile OperStatus operationalStatus = OperStatus.RUN;
 
     public LLDPSpeaker(final PacketProcessingService packetProcessingService,
             final MacAddress addressDestionation) {
diff --git a/applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModule.java b/applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModule.java
deleted file mode 100644 (file)
index 3d27353..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.openflowplugin.applications.lldpspeaker.LLDPSpeaker;
-import org.opendaylight.openflowplugin.applications.lldpspeaker.NodeConnectorInventoryEventTranslator;
-import org.opendaylight.openflowplugin.applications.lldpspeaker.OperationalStatusChangeService;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LLDPSpeakerModule extends AbstractLLDPSpeakerModule {
-    private static final Logger LOG = LoggerFactory
-            .getLogger(LLDPSpeakerModule.class);
-
-    public LLDPSpeakerModule(ModuleIdentifier identifier,
-            DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public LLDPSpeakerModule(ModuleIdentifier identifier,
-            DependencyResolver dependencyResolver, LLDPSpeakerModule oldModule,
-            AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public AutoCloseable createInstance() {
-        LOG.trace("Creating LLDP speaker.");
-
-        PacketProcessingService packetProcessingService = getRpcRegistryDependency()
-                .getRpcService(PacketProcessingService.class);
-        MacAddress macDestination = getAddressDestination();
-
-        final LLDPSpeaker lldpSpeaker = new LLDPSpeaker(
-                packetProcessingService, macDestination);
-        final NodeConnectorInventoryEventTranslator eventTranslator = new NodeConnectorInventoryEventTranslator(
-                getDataBrokerDependency(), lldpSpeaker);
-
-        OperationalStatusChangeService operationalStatusChangeService = new OperationalStatusChangeService(
-                lldpSpeaker);
-        final BindingAwareBroker.RpcRegistration<LldpSpeakerService> statusServiceRegistration =
-                getRpcRegistryDependency().addRpcImplementation(LldpSpeakerService.class, operationalStatusChangeService);
-
-        return new AutoCloseable() {
-            @Override
-            public void close() {
-                LOG.trace("Closing LLDP speaker.");
-                eventTranslator.close();
-                lldpSpeaker.close();
-                statusServiceRegistration.close();
-            }
-        };
-    }
-
-}
diff --git a/applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModuleFactory.java b/applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModuleFactory.java
deleted file mode 100644 (file)
index a09e921..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: lldp-speaker yang module local name: lldp-speaker
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Oct 23 10:01:14 MSK 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023;
-public class LLDPSpeakerModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.AbstractLLDPSpeakerModuleFactory {
-
-}
diff --git a/applications/lldp-speaker/src/main/resources/initial/71-lldp-speaker.xml b/applications/lldp-speaker/src/main/resources/initial/71-lldp-speaker.xml
deleted file mode 100644 (file)
index 11f33b1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright (c) 2014 Pacnet 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
-  -->
-
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-
-<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:openflow:applications:lldp-speaker">prefix:lldp-speaker</type>
-          <name>lldp-speaker</name>
-          <data-broker>
-            <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>
-          <rpc-registry>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
-            <name>binding-rpc-broker</name>
-          </rpc-registry>
-          <address-destination>01:23:00:00:00:01</address-destination>
-        </module>
-
-      </modules>
-    </data>
-  </configuration>
-
-  <required-capabilities>
-    <capability>urn:opendaylight:flow:inventory?module=flow-node-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&amp;revision=2010-09-24</capability>
-    <capability>urn:opendaylight:inventory?module=opendaylight-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:packet:service?module=packet-processing&amp;revision=2013-07-09</capability>
-    <capability>urn:opendaylight:flow:types:port?module=opendaylight-port-types&amp;revision=2013-09-25</capability>
-  </required-capabilities>
-</snapshot>
diff --git a/applications/lldp-speaker/src/main/resources/org/opendaylight/blueprint/lldp-speaker.xml b/applications/lldp-speaker/src/main/resources/org/opendaylight/blueprint/lldp-speaker.xml
new file mode 100644 (file)
index 0000000..98fd805
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+
+  <odl:clustered-app-config id="lldpSpeakerConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.config.rev160512.LldpSpeakerConfig">
+    <odl:default-config><![CDATA[
+      <lldp-speaker-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:applications:lldp-speaker:config">
+        <address-destination>01:23:00:00:00:01</address-destination>
+      </lldp-speaker-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <odl:rpc-service id="packetProcessingService"
+      interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
+
+  <bean id="lldpSpeaker" class="org.opendaylight.openflowplugin.applications.lldpspeaker.LLDPSpeaker"
+          destroy-method="close">
+    <argument ref="packetProcessingService"/>
+    <argument>
+      <bean factory-ref="lldpSpeakerConfig" factory-method="getAddressDestination"/>
+    </argument>
+  </bean>
+
+  <bean id="nodeConnectorEventTranslator" class="org.opendaylight.openflowplugin.applications.lldpspeaker.NodeConnectorInventoryEventTranslator"
+          destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument>
+      <array>
+        <ref component-id="lldpSpeaker"/>
+      </array>
+    </argument>
+  </bean>
+
+  <bean id="operationalStatusChangeService" class="org.opendaylight.openflowplugin.applications.lldpspeaker.OperationalStatusChangeService">
+    <argument ref="lldpSpeaker"/>
+  </bean>
+
+  <odl:rpc-implementation ref="operationalStatusChangeService"/>
+</blueprint>
\ No newline at end of file
diff --git a/applications/lldp-speaker/src/main/yang/lldp-speaker-config.yang b/applications/lldp-speaker/src/main/yang/lldp-speaker-config.yang
new file mode 100644 (file)
index 0000000..6d02e22
--- /dev/null
@@ -0,0 +1,22 @@
+module lldp-speaker-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflow:applications:lldp-speaker:config";
+    prefix "lldp-speaker-config";
+
+    import ietf-yang-types {prefix yang; revision-date "2010-09-24";}
+
+    description
+        "Configuration for LLDP speaker application.";
+
+    revision "2016-05-12" {
+        description
+            "Initial revision.";
+    }
+
+    container lldp-speaker-config {
+        leaf address-destination {
+            type yang:mac-address;
+            mandatory true;
+        }
+    }
+}
\ No newline at end of file
index 32d0d16a6b415f115ab9443d5c0e1f180558aa6e..b04803217896fe03e468d9822d870ba03d07e984 100644 (file)
@@ -2,11 +2,6 @@ module lldp-speaker {
     yang-version 1;
     namespace "urn:opendaylight:params:xml:ns:yang:openflow:applications:lldp-speaker";
     prefix "lldp-speaker";
-    import ietf-yang-types {prefix yang; revision-date "2010-09-24";}
-    import config {prefix config; revision-date 2013-04-05;}
-    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28;}
-    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-    
 
     description
         "Application that send LLDPDU frames to all Openflow switch ports.";
@@ -16,11 +11,6 @@ module lldp-speaker {
             "Initial revision";
     }
 
-    identity lldp-speaker {
-        base "config:module-type";
-        config:java-name-prefix LLDPSpeaker;
-    }
-
     typedef oper-status {
         type enumeration {
             enum STANDBY {
@@ -32,31 +22,6 @@ module lldp-speaker {
         }
     }
 
-    augment "/config:modules/config:module/config:configuration" {
-        case lldp-speaker {
-            when "/config:modules/config:module/config:type = 'lldp-speaker'";
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-rpc-registry;
-                    }
-                }
-            }
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity mdsal:binding-async-data-broker;
-                    }
-                }
-            }
-            leaf address-destination {
-                     type yang:mac-address;
-                 }
-        }
-    }
-
     rpc change-operational-status {
         input {
             leaf operational-status {
@@ -73,6 +38,4 @@ module lldp-speaker {
             }
          }
     }
-
-
 }
index 33ab30c62e57e485b5369bddafb1919e8939ad2c..cee02afa01a282d4f73d198191eaf73b0a306ed0 100644 (file)
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
             </plugin>
-
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/initial/70-of-switch-config-pusher.xml</file>
-                                    <type>xml</type>
-                                    <classifier>config</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
     </build>
 </project>
index 8f020b46dae075ac3a9b3f3ca2e4a7aa838e9919..40952c6ac779bc0b4f6d49fa98cf2be1aa4592c0 100644 (file)
@@ -9,14 +9,20 @@
 package org.opendaylight.openflowplugin.openflow.ofswitch.config;
 
 import java.util.Set;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -25,15 +31,28 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  */
 public class DefaultConfigPusher implements AutoCloseable, DataChangeListener {
 
-    private NodeConfigService nodeConfigService;
+    private final NodeConfigService nodeConfigService;
+    private final DataBroker dataBroker;
+    private ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
 
-    public DefaultConfigPusher(NodeConfigService nodeConfigService) {
+    public DefaultConfigPusher(NodeConfigService nodeConfigService, DataBroker dataBroker) {
         this.nodeConfigService = nodeConfigService;
+        this.dataBroker = dataBroker;
     }
 
-    @Override
-    public void close() throws Exception {
+    public void start() {
+        InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).
+                augmentation(FlowCapableNode.class);
+        dataChangeListenerRegistration = dataBroker.registerDataChangeListener(
+                LogicalDatastoreType.OPERATIONAL,
+                path, this, AsyncDataBroker.DataChangeScope.BASE);
+    }
 
+    @Override
+    public void close() {
+        if(dataChangeListenerRegistration != null) {
+            dataChangeListenerRegistration.close();
+        }
     }
 
     @Override
diff --git a/applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModule.java b/applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModule.java
deleted file mode 100644 (file)
index ff0ce1e..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.openflow.ofswitch.config.DefaultConfigPusher;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class DefaultConfigPusherModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015.AbstractDefaultConfigPusherModule {
-    public DefaultConfigPusherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public DefaultConfigPusherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015.DefaultConfigPusherModule 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() {
-        InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-        NodeConfigService nodeConfigService = getRpcRegistryDependency().getRpcService(NodeConfigService.class);
-        return getDataBrokerDependency().registerDataChangeListener(
-                LogicalDatastoreType.OPERATIONAL,
-                path,
-                new DefaultConfigPusher(nodeConfigService),
-                AsyncDataBroker.DataChangeScope.BASE);
-    }
-
-}
diff --git a/applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModuleFactory.java b/applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModuleFactory.java
deleted file mode 100644 (file)
index e3150ef..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: of-switch-config-pusher yang module local name: of-switch-config-pusher
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Oct 15 10:43:24 CEST 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015;
-public class DefaultConfigPusherModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015.AbstractDefaultConfigPusherModuleFactory {
-
-}
diff --git a/applications/of-switch-config-pusher/src/main/resources/initial/70-of-switch-config-pusher.xml b/applications/of-switch-config-pusher/src/main/resources/initial/70-of-switch-config-pusher.xml
deleted file mode 100644 (file)
index 4ab4a12..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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
-  -->
-
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-
-<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:openflow:applications:of-switch-config-pusher">prefix:of-switch-config-pusher</type>
-                    <name>of-switch-config-pusher</name>
-                    <data-broker>
-                        <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>
-                    <rpc-registry>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
-                        <name>binding-rpc-broker</name>
-                    </rpc-registry>
-                </module>
-
-            </modules>
-        </data>
-    </configuration>
-</snapshot>
\ No newline at end of file
diff --git a/applications/of-switch-config-pusher/src/main/resources/org/opendaylight/blueprint/of-switch-config-pusher.xml b/applications/of-switch-config-pusher/src/main/resources/org/opendaylight/blueprint/of-switch-config-pusher.xml
new file mode 100644 (file)
index 0000000..39e82e8
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+
+  <odl:rpc-service id="nodeConfigService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService"/>
+
+  <bean id="LLDPPacketPuntEnforcer" class="org.opendaylight.openflowplugin.openflow.ofswitch.config.DefaultConfigPusher"
+          init-method="start" destroy-method="close">
+    <argument ref="nodeConfigService"/>
+    <argument ref="dataBroker"/>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/applications/of-switch-config-pusher/src/main/yang/of-switch-config-pusher.yang b/applications/of-switch-config-pusher/src/main/yang/of-switch-config-pusher.yang
deleted file mode 100644 (file)
index 463edb6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-module of-switch-config-pusher {
-       yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:openflow:applications:of-switch-config-pusher";
-    prefix "of-switch-config-pusher";
-    import config {prefix config; revision-date 2013-04-05;}
-    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-
-    description
-        "of-switch-config-pusher-custom-config-impl";
-
-    revision "2014-10-15" {
-        description
-            "Initial revision";
-    }
-
-    identity of-switch-config-pusher {
-        base "config:module-type";
-        config:java-name-prefix DefaultConfigPusher;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case of-switch-config-pusher {
-            when "/config:modules/config:module/config:type = 'of-switch-config-pusher'";
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-rpc-registry;
-                    }
-                }
-            }
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity mdsal:binding-async-data-broker;
-                    }
-                }
-            }
-        }
-    }
-}
index c7e776a7f6f135f08cc1e42fa4c099134366fefe..5789c1067d10caea1ae9a8c28c43f56601affac2 100644 (file)
         <!-- nsf apps -->
         <module>inventory-manager</module>
         <module>statistics-manager</module>
-        <module>statistics-manager-config</module>
         <module>topology-manager</module>
         <module>forwardingrules-manager</module>
-        <module>forwardingrules-manager-config</module>
         <module>forwardingrules-sync</module>
         <module>topology-lldp-discovery</module>
         <!--<module>features</module>-->
diff --git a/applications/statistics-manager-config/pom.xml b/applications/statistics-manager-config/pom.xml
deleted file mode 100644 (file)
index 09d31a9..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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
--->
-<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.openflowplugin</groupId>
-        <artifactId>applications</artifactId>
-        <version>0.3.0-SNAPSHOT</version>
-    </parent>
-
-    <groupId>org.opendaylight.openflowplugin.applications</groupId>
-    <artifactId>statistics-manager-config</artifactId>
-    <description>Configuration files for statistics manager</description>
-    <packaging>jar</packaging>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/initial/30-statistics-manager.xml</file>
-                                    <type>xml</type>
-                                    <classifier>config</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-    
-    <scm>
-      <connection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</connection>
-      <developerConnection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</developerConnection>
-      <url>https://wiki.opendaylight.org/view/OpenDaylight_OpenFlow_Plugin:Main</url>
-      <tag>HEAD</tag>
-    </scm>
-
-</project>
diff --git a/applications/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml b/applications/statistics-manager-config/src/main/resources/initial/30-statistics-manager.xml
deleted file mode 100644 (file)
index 9962070..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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:statsmanager="urn:opendaylight:params:xml:ns:yang:openflowplugin:app:statistics-manager">
-                        statsmanager:statistics-manager
-                    </type>
-                    <name>statistics-manager</name>
-
-                    <rpc-registry>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
-                        <name>binding-rpc-broker</name>
-                    </rpc-registry>
-
-                    <data-broker>
-                        <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>
-
-                    <notification-service>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
-                            binding:binding-notification-service
-                        </type>
-                        <name>binding-notification-broker</name>
-                    </notification-service>
-
-                    <ownership-service>
-                        <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
-                        <name>entity-ownership-service</name>
-                    </ownership-service>
-
-                    <statistics-manager-settings>
-                        <min-request-net-monitor-interval>3000</min-request-net-monitor-interval>
-                        <max-nodes-for-collector>16</max-nodes-for-collector>
-                    </statistics-manager-settings>
-
-                </module>
-            </modules>
-        </data>
-    </configuration>
-
-    <required-capabilities>
-        <capability>urn:opendaylight:params:xml:ns:yang:openflowplugin:app:statistics-manager?module=statistics-manager&amp;revision=2014-09-25</capability>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service?module=distributed-entity-ownership-service&amp;revision=2015-08-10</capability>
-    </required-capabilities>
-
-</snapshot>
-
index a87ea4f1055dffd97d55a228c4f09e9519cb4d07..0425c4faf3d8e824f3f4a8bfb5213e832a918346 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-config</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-util</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.openflowplugin.model</groupId>
       <artifactId>model-flow-base</artifactId>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-binding-config</artifactId>
       </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>config-api</artifactId>
-      </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModule.java b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModule.java
deleted file mode 100644 (file)
index 93fecc3..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.config.yang.statistics_manager;
-
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
-import org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerConfig;
-import org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StatisticsManagerModule extends org.opendaylight.openflowplugin.applications.config.yang.statistics_manager.AbstractStatisticsManagerModule {
-
-    private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerModule.class);
-
-    private static final int MAX_NODES_FOR_COLLECTOR_DEFAULT = 16;
-    private static final int MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT = 3000;
-
-    public StatisticsManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public StatisticsManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.openflowplugin.applications.config.yang.statistics_manager.StatisticsManagerModule 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() {
-        LOG.info("StatisticsManager module initialization.");
-        final StatisticsManagerConfig config = createConfig();
-        final StatisticsManager statisticsManagerProvider = new StatisticsManagerImpl(getDataBrokerDependency(), config);
-        statisticsManagerProvider.setOwnershipService(getOwnershipServiceDependency());
-        statisticsManagerProvider.start(getNotificationServiceDependency(), getRpcRegistryDependency());
-
-        final StatisticsManager statisticsManagerProviderExposed = statisticsManagerProvider;
-        LOG.info("StatisticsManager started successfully.");
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                try {
-                    statisticsManagerProviderExposed.close();
-                }
-                catch (final Exception e) {
-                    LOG.error("Unexpected error by stopping StatisticsManager module", e);
-                }
-                LOG.info("StatisticsManager module stopped.");
-            }
-        };
-    }
-
-    private StatisticsManagerConfig createConfig() {
-        final StatisticsManagerConfig.StatisticsManagerConfigBuilder builder = StatisticsManagerConfig.builder();
-        if (getStatisticsManagerSettings() != null && getStatisticsManagerSettings().getMaxNodesForCollector() != null) {
-            builder.setMaxNodesForCollector(getStatisticsManagerSettings().getMaxNodesForCollector());
-        } else {
-            LOG.warn("Load the xml ConfigSubsystem input value fail! MaxNodesForCollector value is set to {} ",
-                    MAX_NODES_FOR_COLLECTOR_DEFAULT);
-            builder.setMaxNodesForCollector(MAX_NODES_FOR_COLLECTOR_DEFAULT);
-        }
-        if (getStatisticsManagerSettings() != null &&
-                getStatisticsManagerSettings().getMinRequestNetMonitorInterval() != null) {
-            builder.setMinRequestNetMonitorInterval(getStatisticsManagerSettings().getMinRequestNetMonitorInterval());
-        } else {
-            LOG.warn("Load the xml CofnigSubsystem input value fail! MinRequestNetMonitorInterval value is set to {} ",
-                    MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT);
-            builder.setMinRequestNetMonitorInterval(MIN_REQUEST_NET_MONITOR_INTERVAL_DEFAULT);
-        }
-        return builder.build();
-    }
-}
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModuleFactory.java b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/statistics_manager/StatisticsManagerModuleFactory.java
deleted file mode 100644 (file)
index aad0634..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: statistics-manager yang module local name: statistics-manager
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Jan 22 17:17:48 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.openflowplugin.applications.config.yang.statistics_manager;
-public class StatisticsManagerModuleFactory extends org.opendaylight.openflowplugin.applications.config.yang.statistics_manager.AbstractStatisticsManagerModuleFactory {
-
-}
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManagerFactory.java b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManagerFactory.java
new file mode 100644 (file)
index 0000000..fde568e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.applications.statistics.manager;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.statistics.manager.config.rev160509.StatisticsManagerAppConfig;
+
+/**
+ * Factory for creating StatisticsManager instances.
+ *
+ * @author Thomas Pantelis
+ */
+public interface StatisticsManagerFactory {
+    StatisticsManager newInstance(StatisticsManagerAppConfig statsManagerAppConfig, DataBroker dataBroker,
+            NotificationProviderService notifService, RpcConsumerRegistry rpcRegistry,
+            EntityOwnershipService entityOwnershipService);
+
+}
index 0b91579b5edc914988b65b7970d2e5dcf0729779..b590f3356eb90ba89feadd77f298454dc5848106 100644 (file)
@@ -245,7 +245,6 @@ public class StatNodeRegistrationImpl implements StatNodeRegistration,EntityOwne
         NodeIdentifierWithPredicates niWPredicates = (NodeIdentifierWithPredicates)yId.getLastPathArgument();
         Map<QName, Object> keyValMap = niWPredicates.getKeyValues();
         String nodeIdStr = (String)(keyValMap.get(ENTITY_NAME));
-        BigInteger dpId = new BigInteger(nodeIdStr.split(":")[1]);
         NodeId nodeId = new NodeId(nodeIdStr);
         setNodeOwnership(nodeId, ownershipChange.isOwner());
     }
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerFactoryImpl.java b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerFactoryImpl.java
new file mode 100644 (file)
index 0000000..11fe70d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManagerFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.statistics.manager.config.rev160509.StatisticsManagerAppConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of StatisticsManagerFactory.
+ *
+ * @author Thomas Pantelis
+ */
+public class StatisticsManagerFactoryImpl implements StatisticsManagerFactory {
+    private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerFactoryImpl.class);
+
+    @Override
+    public StatisticsManager newInstance(StatisticsManagerAppConfig statsManagerAppConfig, DataBroker dataBroker,
+            NotificationProviderService notifService, RpcConsumerRegistry rpcRegistry,
+            EntityOwnershipService entityOwnershipService) {
+        LOG.info("StatisticsManager module initialization.");
+
+        StatisticsManagerConfig.StatisticsManagerConfigBuilder configBuilder = StatisticsManagerConfig.builder();
+        configBuilder.setMaxNodesForCollector(statsManagerAppConfig.getMaxNodesForCollector());
+        configBuilder.setMinRequestNetMonitorInterval(statsManagerAppConfig.getMinRequestNetMonitorInterval());
+
+        StatisticsManager statisticsManager = new StatisticsManagerImpl(dataBroker, configBuilder.build());
+        statisticsManager.setOwnershipService(entityOwnershipService);
+        statisticsManager.start(notifService, rpcRegistry);
+
+        LOG.info("StatisticsManager started successfully.");
+
+        return statisticsManager;
+    }
+}
diff --git a/applications/statistics-manager/src/main/resources/org/opendaylight/blueprint/statistics-manager.xml b/applications/statistics-manager/src/main/resources/org/opendaylight/blueprint/statistics-manager.xml
new file mode 100644 (file)
index 0000000..3155c1f
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+  <bean id="statsManagerFactory" class="org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerFactoryImpl"/>
+
+  <service ref="statsManagerFactory" interface="org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManagerFactory"
+          odl:type="default"/>
+</blueprint>
\ No newline at end of file
diff --git a/applications/statistics-manager/src/main/yang/statistics-manager-app-config.yang b/applications/statistics-manager/src/main/yang/statistics-manager-app-config.yang
new file mode 100644 (file)
index 0000000..d824326
--- /dev/null
@@ -0,0 +1,25 @@
+module statistics-manager-app-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:statistics-manager:config";
+    prefix "statistics-manager-app-config";
+
+    description
+        "Configuration for Statistics Manager application.";
+
+    revision "2016-05-09" {
+        description
+            "Initial revision";
+    }
+
+    container statistics-manager-app-config {
+        leaf min-request-net-monitor-interval {
+            type int32;
+            default 3000;
+        }
+
+        leaf max-nodes-for-collector {
+            type int32;
+            default 16;
+        }
+    }
+}
\ No newline at end of file
diff --git a/applications/statistics-manager/src/main/yang/statistics-manager.yang b/applications/statistics-manager/src/main/yang/statistics-manager.yang
deleted file mode 100644 (file)
index d982d35..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-module statistics-manager {
-
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:statistics-manager";
-    prefix "statistics-manager";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-    import opendaylight-entity-ownership-service { prefix ownership-service; }
-
-    description
-        "This module contains the base YANG definitions for
-        statitics-manager implementation.";
-
-    revision "2014-09-25" {
-        description
-            "Initial revision.";
-    }
-
-    identity statistics-manager {
-            base config:module-type;
-            config:java-name-prefix StatisticsManager;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case statistics-manager {
-            when "/config:modules/config:module/config:type = 'statistics-manager'";
-
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-rpc-registry;
-                    }
-                }
-            }
-
-            container notification-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-notification-service;
-                    }
-                }
-            }
-
-            container ownership-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity ownership-service:entity-ownership-service;
-                    }
-                }
-            }
-
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity mdsal:binding-async-data-broker;
-                    }
-                }
-            }
-
-            container statistics-manager-settings {
-                leaf min-request-net-monitor-interval {
-                    type int32;
-                }
-                leaf max-nodes-for-collector {
-                    type int32;
-                }
-            }
-        }
-    }
-
-}
index 0fd4a64e6594afa81e047fe2440f9d6eae06db75..9da7e3419c0dbdc3f377d7a729e4a9581b047df8 100644 (file)
           <artifactId>junit</artifactId>
           <scope>test</scope>
       </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>config-api</artifactId>
-      </dependency>
   </dependencies>
 
     <build>
              <groupId>org.opendaylight.yangtools</groupId>
              <artifactId>yang-maven-plugin</artifactId>
          </plugin>
-
-         <plugin>
-          <groupId>org.codehaus.mojo</groupId>
-          <artifactId>build-helper-maven-plugin</artifactId>
-          <executions>
-            <execution>
-              <id>attach-artifacts</id>
-              <goals>
-                <goal>attach-artifact</goal>
-              </goals>
-              <phase>package</phase>
-              <configuration>
-                <artifacts>
-                  <artifact>
-                    <file>${project.build.directory}/classes/initial/69-table-miss-enforcer.xml</file>
-                    <type>xml</type>
-                    <classifier>config</classifier>
-                  </artifact>
-                </artifacts>
-              </configuration>
-            </execution>
-          </executions>
-        </plugin>
      </plugins>
     </build>
 </project>
index be0c723edc094454e4765cbd99d426fe35a78dd0..f28add7a4f7d99fda4d52b5d9796ef64d257ad43 100644 (file)
@@ -12,15 +12,21 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.Callable;
+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;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
@@ -38,7 +44,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -46,14 +54,42 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * Created by Martin Bobak mbobak@cisco.com on 8/27/14.
  */
 public class LLDPPacketPuntEnforcer implements DataChangeListener {
-
+    private static final long STARTUP_LOOP_TICK = 500L;
+    private static final int STARTUP_LOOP_MAX_RETRIES = 8;
     private static final short TABLE_ID = (short) 0;
     private static final String LLDP_PUNT_WHOLE_PACKET_FLOW = "LLDP_PUNT_WHOLE_PACKET_FLOW";
     private static final String DEFAULT_FLOW_ID = "42";
     private final SalFlowService flowService;
+    private final DataBroker dataBroker;
+    private ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
 
-    public LLDPPacketPuntEnforcer(SalFlowService flowService) {
+    public LLDPPacketPuntEnforcer(SalFlowService flowService, DataBroker dataBroker) {
         this.flowService = flowService;
+        this.dataBroker = dataBroker;
+    }
+
+    public void start() {
+        final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).
+                augmentation(FlowCapableNode.class);
+        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+        try {
+            dataChangeListenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataChangeListener>>() {
+                @Override
+                public ListenerRegistration<DataChangeListener> call() throws Exception {
+                    return dataBroker.registerDataChangeListener(
+                            LogicalDatastoreType.OPERATIONAL,
+                            path, LLDPPacketPuntEnforcer.this, AsyncDataBroker.DataChangeScope.BASE);
+                }
+            });
+        } catch (Exception e) {
+            throw new IllegalStateException("registerDataChangeListener failed", e);
+        }
+    }
+
+    public void close() {
+        if(dataChangeListenerRegistration != null) {
+            dataChangeListenerRegistration.close();
+        }
     }
 
     @Override
diff --git a/applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModule.java b/applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModule.java
deleted file mode 100644 (file)
index 488a63f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326;
-
-import java.util.concurrent.Callable;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.applications.tableMissEnforcer.LLDPPacketPuntEnforcer;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LLDPPacketPuntEnforcerModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326.AbstractLLDPPacketPuntEnforcerModule {
-    private static final long STARTUP_LOOP_TICK = 500L;
-    private static final int STARTUP_LOOP_MAX_RETRIES = 8;
-    private static final Logger LOG = LoggerFactory.getLogger(LLDPPacketPuntEnforcerModule.class);
-
-    public LLDPPacketPuntEnforcerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public LLDPPacketPuntEnforcerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326.LLDPPacketPuntEnforcerModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-        final SalFlowService salFlowService = getRpcRegistryDependency().getRpcService(SalFlowService.class);
-
-        ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
-        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-        try {
-            dataChangeListenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataChangeListener>>() {
-                @Override
-                public ListenerRegistration<DataChangeListener> call() throws Exception {
-                    return getDataBrokerDependency().registerDataChangeListener(
-                            LogicalDatastoreType.OPERATIONAL,
-                            path,
-                            new LLDPPacketPuntEnforcer(salFlowService),
-                            AsyncDataBroker.DataChangeScope.BASE);
-                }
-            });
-        } catch (Exception e) {
-            LOG.warn("data listener registration failed: {}", e.getMessage());
-            LOG.debug("data listener registration failed.. ", e);
-            throw new IllegalStateException("LLDPPacketPuntEnforcer startup fail! System needs restart.", e);
-        }
-        return dataChangeListenerRegistration;
-    }
-
-}
diff --git a/applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModuleFactory.java b/applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModuleFactory.java
deleted file mode 100644 (file)
index 1ebc1f9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: table-miss-enforcer yang module local name: table-miss-enforcer
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Mon Sep 08 15:26:18 CEST 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326;
-public class LLDPPacketPuntEnforcerModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326.AbstractLLDPPacketPuntEnforcerModuleFactory {
-
-}
diff --git a/applications/table-miss-enforcer/src/main/resources/initial/69-table-miss-enforcer.xml b/applications/table-miss-enforcer/src/main/resources/initial/69-table-miss-enforcer.xml
deleted file mode 100644 (file)
index 003b563..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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:openflow:applications:table-miss-enforcer">prefix:table-miss-enforcer</type>
-                    <name>table-miss-enforcer</name>
-                    <data-broker>
-                        <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>
-                    <rpc-registry>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
-                        <name>binding-rpc-broker</name>
-                    </rpc-registry>
-                </module>
-
-            </modules>
-        </data>
-    </configuration>
-</snapshot>
\ No newline at end of file
diff --git a/applications/table-miss-enforcer/src/main/resources/org/opendaylight/blueprint/table-miss-enforcer.xml b/applications/table-miss-enforcer/src/main/resources/org/opendaylight/blueprint/table-miss-enforcer.xml
new file mode 100644 (file)
index 0000000..ff9ff6c
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+
+  <odl:rpc-service id="flowService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService"/>
+
+  <bean id="LLDPPacketPuntEnforcer" class="org.opendaylight.openflowplugin.applications.tableMissEnforcer.LLDPPacketPuntEnforcer"
+          init-method="start" destroy-method="close">
+    <argument ref="flowService"/>
+    <argument ref="dataBroker"/>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/applications/table-miss-enforcer/src/main/yang/table-miss-enforcer.yang b/applications/table-miss-enforcer/src/main/yang/table-miss-enforcer.yang
deleted file mode 100644 (file)
index 139c5dc..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-module table-miss-enforcer {
-       yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:openflow:applications:table-miss-enforcer";
-    prefix "table-miss-enforcer";
-    import config {prefix config; revision-date 2013-04-05;}
-    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-
-    description
-        "table-miss-enforcer-custom-config-impl";
-
-    revision "2014-03-26" {
-        description
-            "Initial revision";
-    }
-
-    identity table-miss-enforcer {
-        base "config:module-type";
-        config:java-name-prefix LLDPPacketPuntEnforcer;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case table-miss-enforcer {
-            when "/config:modules/config:module/config:type = 'table-miss-enforcer'";
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-rpc-registry;
-                    }
-                }
-            }
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity mdsal:binding-async-data-broker;
-                    }
-                }
-            }
-        }
-    }
-}
index 4a05f25e3d9b812296c3b7aa9084021e08c27b9f..94dd5975d6aab86f2f8be4766a95c0e48a42b742 100644 (file)
@@ -34,7 +34,7 @@ public class LLDPDataChangeListenerTest {
      */
     @Test
     public void testCreateFlow() {
-        LLDPPacketPuntEnforcer lldpDataChangeListener = new LLDPPacketPuntEnforcer(flowService);
+        LLDPPacketPuntEnforcer lldpDataChangeListener = new LLDPPacketPuntEnforcer(flowService, null);
         evaluateFlow(lldpDataChangeListener.createFlow());
     }
 
diff --git a/applications/topology-lldp-discovery/src/main/config/default-config.xml b/applications/topology-lldp-discovery/src/main/config/default-config.xml
deleted file mode 100644 (file)
index cf7005a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<snapshot>
-  <required-capabilities>
-    <!--<capability>urn:opendaylight:params:xml:ns:yang:southbound:impl?module=southbound-impl&amp;revision=2015-01-05</capability>-->
-    <capability>urn:opendaylight:inventory?module=opendaylight-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:flow:inventory?module=flow-node-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:flow:types?module=opendaylight-flow-types&amp;revision=2013-10-26</capability>
-    <capability>urn:opendaylight:packet:service?module=packet-processing&amp;revision=2013-07-09</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:topology-lldp-discovery:impl">prefix:topology-lldp-discovery-impl</type>
-          <name>topology-lldp-discovery-default</name>
-          <broker>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <name>binding-osgi-broker</name>
-          </broker>
-          <lldp-secure-key>aa9251f8-c7c0-4322-b8d6-c3a84593bda3</lldp-secure-key>
-        </module>
-      </modules>
-    </data>
-  </configuration>
-</snapshot>
index 79f100fa0730915b80b8aa0238055afe28efc8fe..3e5fb3bf10b96a5f69302b7e73ac259d34ac7b88 100644 (file)
@@ -7,39 +7,35 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.lldp;
 
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class LLDPActivator implements BindingAwareProvider, AutoCloseable {
+public class LLDPActivator implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
-    private static LLDPDiscoveryProvider provider = new LLDPDiscoveryProvider();
+
     private static String lldpSecureKey;
 
-    public LLDPActivator(String secureKey) {
+    private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
+
+    public LLDPActivator(NotificationProviderService notificationService, LLDPDiscoveryListener lldpDiscoveryListener,
+            String secureKey) {
         lldpSecureKey = secureKey;
-    }
 
-    public void onSessionInitiated(final ProviderContext session) {
-        DataProviderService dataService = session.<DataProviderService>getSALService(DataProviderService.class);
-        provider.setDataService(dataService);
-        NotificationProviderService notificationService = session.<NotificationProviderService>getSALService(NotificationProviderService.class);
-        provider.setNotificationService(notificationService);
-        provider.start();
+        LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
+
+        lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
+
+        LOG.info("LLDPDiscoveryListener started.");
     }
 
     @Override
-    public void close() throws Exception {
-        if(provider != null) {
-            try {
-                provider.close();
-            } catch (Exception e) {
-                LOG.warn("Exception when closing down topology-lldp-discovery",e);
-            }
-        }
+    public void close() {
+        lldpNotificationRegistration.close();
+
+        LOG.info("LLDPDiscoveryListener stopped.");
     }
 
     public static String getLldpSecureKey() {
index 08c3c9c4a9b196cb47517fbca2aafe7493efbb9e..097d0edc4ebc0089c11375afa782ad9577ccb387 100644 (file)
@@ -17,16 +17,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Pa
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class LLDPDiscoveryListener implements PacketProcessingListener {
+public class LLDPDiscoveryListener implements PacketProcessingListener {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryListener.class);
 
-    private LLDPLinkAger lldpLinkAger;
-    private NotificationProviderService notificationService;
+    private final LLDPLinkAger lldpLinkAger;
+    private final NotificationProviderService notificationService;
 
-    LLDPDiscoveryListener(NotificationProviderService notificationService) {
+    public LLDPDiscoveryListener(NotificationProviderService notificationService, LLDPLinkAger lldpLinkAger) {
         this.notificationService = notificationService;
+        this.lldpLinkAger = lldpLinkAger;
     }
 
+    @Override
     public void onPacketReceived(PacketReceived lldp) {
         NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload(), true);
         if(src != null) {
@@ -39,8 +41,4 @@ class LLDPDiscoveryListener implements PacketProcessingListener {
             lldpLinkAger.put(ld);
         }
     }
-
-    public void setLldpLinkAger(LLDPLinkAger lldpLinkAger) {
-        this.lldpLinkAger = lldpLinkAger;
-    }
-}
+}
\ No newline at end of file
diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryProvider.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryProvider.java
deleted file mode 100644 (file)
index c6203ef..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.topology.lldp;
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LLDPDiscoveryProvider implements AutoCloseable {
-    private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryProvider.class);
-    private DataProviderService dataService;
-    private NotificationProviderService notificationService;
-
-    private ListenerRegistration<NotificationListener> listenerRegistration;
-    private LLDPLinkAger lldpLinkAger;
-
-    public DataProviderService getDataService() {
-        return this.dataService;
-    }
-
-    public void setDataService(final DataProviderService dataService) {
-        this.dataService = dataService;
-    }
-
-    public NotificationProviderService getNotificationService() {
-        return this.notificationService;
-    }
-
-    public void setNotificationService(final NotificationProviderService notificationService) {
-        this.notificationService = notificationService;
-    }
-
-    public void start() {
-        lldpLinkAger = new LLDPLinkAger(LLDPDiscoveryUtils.LLDP_INTERVAL, LLDPDiscoveryUtils.LLDP_EXPIRATION_TIME);
-        lldpLinkAger.setNotificationService(notificationService);
-
-        LLDPDiscoveryListener committer = new LLDPDiscoveryListener(notificationService);
-        committer.setLldpLinkAger(lldpLinkAger);
-
-        ListenerRegistration<NotificationListener> registerNotificationListener =
-                notificationService.registerNotificationListener(committer);
-        this.listenerRegistration = registerNotificationListener;
-        LOG.info("LLDPDiscoveryListener Started.");
-    }
-
-    public void close() {
-        try {
-            LOG.info("LLDPDiscoveryListener stopped.");
-            if (this.listenerRegistration!=null) {
-                this.listenerRegistration.close();
-            }
-            lldpLinkAger.close();
-        } catch (Exception e) {
-            throw new Error(e);
-        }
-    }
-}
index 67b74995f78d6a0ee5566013ff15cab05628a089..9acd4b2de34251d1a1c4972ffba82cde103bf24d 100644 (file)
@@ -20,15 +20,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev
 
 public class LLDPLinkAger implements AutoCloseable {
     private final long linkExpirationTime;
-    private Map<LinkDiscovered, Date> linkToDate;
-    private Timer timer;
-    private NotificationProviderService notificationService;
+    private final Map<LinkDiscovered, Date> linkToDate;
+    private final Timer timer;
+    private final NotificationProviderService notificationService;
 
     /**
      * default ctor - start timer
      */
-    public LLDPLinkAger(final long lldpInterval, final long linkExpirationTime) {
+    public LLDPLinkAger(final long lldpInterval, final long linkExpirationTime,
+            final NotificationProviderService notificationService) {
         this.linkExpirationTime = linkExpirationTime;
+        this.notificationService = notificationService;
         linkToDate = new ConcurrentHashMap<>();
         timer = new Timer();
         timer.schedule(new LLDPAgingTask(), 0, lldpInterval);
@@ -46,10 +48,6 @@ public class LLDPLinkAger implements AutoCloseable {
         linkToDate.clear();
     }
 
-    public void setNotificationService(NotificationProviderService notificationService) {
-        this.notificationService = notificationService;
-    }
-
     private class LLDPAgingTask extends TimerTask {
 
         @Override
index 8112bcc2df886f11d3f062f0b7f18d2ba60e2052..29c99eca6f725cb52ba6763d9081a3c39dd18b53 100644 (file)
@@ -7,31 +7,31 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.lldp.utils;
 
-import org.apache.commons.lang3.ArrayUtils;
-import java.nio.charset.Charset;
 import com.google.common.hash.HashCode;
+import com.google.common.hash.HashFunction;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
+import java.lang.management.ManagementFactory;
+import java.nio.charset.Charset;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import org.apache.commons.lang3.ArrayUtils;
+import org.opendaylight.controller.liblldp.BitBufferHelper;
+import org.opendaylight.controller.liblldp.CustomTLVKey;
 import org.opendaylight.controller.liblldp.Ethernet;
 import org.opendaylight.controller.liblldp.LLDP;
-import org.opendaylight.controller.liblldp.BitBufferHelper;
 import org.opendaylight.controller.liblldp.LLDPTLV;
 import org.opendaylight.controller.liblldp.NetUtils;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
-import com.google.common.hash.HashFunction;
 import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
 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.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import java.util.Arrays;
-import java.security.NoSuchAlgorithmException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import java.lang.management.ManagementFactory;
 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.opendaylight.controller.liblldp.CustomTLVKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,12 +39,6 @@ import org.slf4j.LoggerFactory;
 public class LLDPDiscoveryUtils {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtils.class);
 
-    // Send LLDP every five seconds
-    public static final Long LLDP_INTERVAL = (long) (1000*5);
-
-    // Let up to three intervals pass before we decide we are expired.
-    public static final Long LLDP_EXPIRATION_TIME = LLDP_INTERVAL*3;
-
     public static String macToString(byte[] mac) {
         StringBuilder b = new StringBuilder();
         for (int i = 0; i < mac.length; i++) {
diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModule.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModule.java
deleted file mode 100644 (file)
index eed30f9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530;
-
-import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
-
-public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.AbstractTopologyLldpDiscoveryImplModule {
-    public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.TopologyLldpDiscoveryImplModule 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() {
-        LLDPActivator provider = new LLDPActivator(getLldpSecureKey());
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
-}
diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java
deleted file mode 100644 (file)
index e9670e2..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: topology-lldp-discovery-impl yang module local name: topology-lldp-discovery-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Sat May 30 20:35:29 PDT 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530;
-public class TopologyLldpDiscoveryImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.AbstractTopologyLldpDiscoveryImplModuleFactory {
-
-}
diff --git a/applications/topology-lldp-discovery/src/main/resources/org/opendaylight/blueprint/topology-lldp-discovery.xml b/applications/topology-lldp-discovery/src/main/resources/org/opendaylight/blueprint/topology-lldp-discovery.xml
new file mode 100644 (file)
index 0000000..12ac129
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+  <odl:clustered-app-config id="topologyLLDPConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig">
+    <odl:default-config><![CDATA[
+      <topology-lldp-discovery-config xmlns="urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:config">
+        <lldp-secure-key>aa9251f8-c7c0-4322-b8d6-c3a84593bda3</lldp-secure-key>
+      </topology-lldp-discovery-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="lldpLinkAger" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPLinkAger"
+          destroy-method="close">
+    <!-- Interval to send LLDP (five seconds) -->
+    <argument value="5000"/>
+    <!-- Expiration interval for aging out links (3 * the interval)  -->
+    <argument value="15000"/>
+    <argument ref="notificationService"/>
+  </bean>
+
+  <bean id="lldpDiscoveryListener" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPDiscoveryListener">
+    <argument ref="notificationService"/>
+    <argument ref="lldpLinkAger"/>
+  </bean>
+
+  <bean id="LLDPActivator" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator"
+         destroy-method="close">
+    <argument ref="notificationService"/>
+    <argument ref="lldpDiscoveryListener"/>
+    <argument>
+      <bean factory-ref="topologyLLDPConfig" factory-method="getLldpSecureKey"/>
+    </argument>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-config.yang b/applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-config.yang
new file mode 100644 (file)
index 0000000..0e1189e
--- /dev/null
@@ -0,0 +1,21 @@
+module topology-lldp-discovery-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:config";
+    prefix "topology-lldp-discovery-config";
+
+    description
+        "Configuration for Topology LLDP discovery application.";
+
+    revision "2016-05-11" {
+        description
+            "Initial revision.";
+    }
+
+    container topology-lldp-discovery-config {
+        leaf lldp-secure-key {
+            description "Provided key will be used to generate LLDP custom security hash";
+            type string;
+            mandatory true;
+        }
+    }
+}
\ No newline at end of file
diff --git a/applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-impl.yang b/applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-impl.yang
deleted file mode 100644 (file)
index 709da19..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-module topology-lldp-discovery-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:impl";
-    prefix "topology-lldp-discovery-impl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
-
-    description
-        "Service definition for topology-lldp-discovery";
-
-    revision "2015-05-30" {
-        description
-            "Initial revision";
-    }
-
-    identity topology-lldp-discovery-impl {
-        base config:module-type;
-        config:java-name-prefix TopologyLldpDiscoveryImpl;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case topology-lldp-discovery-impl {
-            when "/config:modules/config:module/config:type = 'topology-lldp-discovery-impl'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-            leaf lldp-secure-key {
-                description "Provided key will be used to generate LLDP custom security hash";
-                type string;
-            }
-        }
-    }
-}
diff --git a/applications/topology-manager/src/main/config/default-config.xml b/applications/topology-manager/src/main/config/default-config.xml
deleted file mode 100644 (file)
index 4c21c68..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<snapshot>
-  <required-capabilities>
-    <!--<capability>urn:opendaylight:params:xml:ns:yang:southbound:impl?module=southbound-impl&amp;revision=2015-01-05</capability>-->
-    <capability>urn:opendaylight:inventory?module=opendaylight-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:flow:inventory?module=flow-node-inventory&amp;revision=2013-08-19</capability>
-    <capability>urn:opendaylight:flow:types?module=opendaylight-flow-types&amp;revision=2013-10-26</capability>
-    <capability>urn:TBD:params:xml:ns:yang:network-topology?module=network-topology&amp;revision=2013-10-21</capability>
-    <capability>urn:opendaylight:flow:topology:discovery?module=flow-topology-discovery&amp;revision=2013-08-19</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:topology-manager:impl">prefix:topology-manager-impl</type>
-          <name>topology-manager-default</name>
-          <broker>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <name>binding-osgi-broker</name>
-          </broker>
-        </module>
-      </modules>
-    </data>
-  </configuration>
-</snapshot>
index 66168949ff76176ea6b4720a82905c4efd1f1328..f49d0f52c63a72d6ef306e5d704d00c023c887ab 100644 (file)
@@ -7,16 +7,13 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.manager;
 
-import java.util.concurrent.ExecutionException;
-
 import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -29,34 +26,33 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCloseable {
+public class FlowCapableTopologyProvider implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider.class);
-    private ListenerRegistration<NotificationListener> listenerRegistration;
-    private Thread thread;
-    private TerminationPointChangeListenerImpl terminationPointChangeListener;
-    private NodeChangeListenerImpl nodeChangeListener;
     static final String TOPOLOGY_ID = "flow:1";
 
+    private final DataBroker dataBroker;
+    private final NotificationProviderService notificationService;
+    private final OperationProcessor processor;
+    private ListenerRegistration<NotificationListener> listenerRegistration;
+
+    public FlowCapableTopologyProvider(DataBroker dataBroker, NotificationProviderService notificationService,
+            OperationProcessor processor) {
+        this.dataBroker = dataBroker;
+        this.notificationService = notificationService;
+        this.processor = processor;
+    }
+
     /**
      * Gets called on start of a bundle.
-     *
-     * @param session
      */
-    @Override
-    public synchronized void onSessionInitiated(final ProviderContext session) {
-        final DataBroker dataBroker = session.getSALService(DataBroker.class);
-        final NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
-
+    public void start() {
         final TopologyKey key = new TopologyKey(new TopologyId(TOPOLOGY_ID));
         final InstanceIdentifier<Topology> path = InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, key);
 
-        final OperationProcessor processor = new OperationProcessor(dataBroker);
         final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path);
         this.listenerRegistration = notificationService.registerNotificationListener(listener);
-        this.terminationPointChangeListener = new TerminationPointChangeListenerImpl(dataBroker, processor);
-        nodeChangeListener = new NodeChangeListenerImpl(dataBroker, processor);
 
         if(!isFlowTopologyExist(dataBroker, path)){
             final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
@@ -68,14 +64,11 @@ public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCl
             }
         }
 
-        thread = new Thread(processor);
-        thread.setDaemon(true);
-        thread.setName("FlowCapableTopologyExporter-" + TOPOLOGY_ID);
-        thread.start();
+        LOG.info("FlowCapableTopologyProvider started");
     }
 
     @Override
-    public synchronized void close() throws InterruptedException {
+    public void close() {
         LOG.info("FlowCapableTopologyProvider stopped.");
         if (this.listenerRegistration != null) {
             try {
@@ -86,24 +79,6 @@ public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCl
             }
             listenerRegistration = null;
         }
-        unregisterListener(terminationPointChangeListener);
-        unregisterListener(nodeChangeListener);
-        if (thread != null) {
-            thread.interrupt();
-            thread.join();
-            thread = null;
-        }
-    }
-
-    private static void unregisterListener(final AutoCloseable listenerToClose) {
-        if (listenerToClose != null) {
-            try {
-                listenerToClose.close();
-            } catch (Exception e) {
-                LOG.warn("Failed to close listener registration: {}", e.getMessage());
-                LOG.debug("Failed to close listener registration.. ", e);
-            }
-        }
     }
 
     private boolean isFlowTopologyExist(final DataBroker dataBroker,
index 87fb7354debb21ac8a458f3a7c3c7cb3bd6de118..96365a338868467d728dcd204d384633be24c106 100644 (file)
@@ -20,19 +20,24 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
+public final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
     private static final Logger LOG = LoggerFactory.getLogger(OperationProcessor.class);
     private static final int MAX_TRANSACTION_OPERATIONS = 100;
     private static final int OPERATION_QUEUE_DEPTH = 500;
 
     private final BlockingQueue<TopologyOperation> queue = new LinkedBlockingQueue<>(OPERATION_QUEUE_DEPTH);
     private final DataBroker dataBroker;
+    private final Thread thread;
     private BindingTransactionChain transactionChain;
     private volatile boolean finishing = false;
 
-    OperationProcessor(final DataBroker dataBroker) {
+    public OperationProcessor(final DataBroker dataBroker) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         transactionChain = this.dataBroker.createTransactionChain(this);
+
+        thread = new Thread(this);
+        thread.setDaemon(true);
+        thread.setName("FlowCapableTopologyExporter-" + FlowCapableTopologyProvider.TOPOLOGY_ID);
     }
 
     void enqueueOperation(final TopologyOperation task) {
@@ -43,6 +48,10 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
         }
     }
 
+    public void start() {
+        thread.start();
+    }
+
     @Override
     public void run() {
             while (!finishing) {
@@ -84,7 +93,8 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
                     transactionChain = dataBroker.createTransactionChain(this);
                     cleanDataStoreOperQueue();
                 } catch (final InterruptedException e) {
-                    LOG.warn("Stat Manager DS Operation thread interupted!", e);
+                    // This should mean we're shutting down.
+                    LOG.debug("Stat Manager DS Operation thread interupted!", e);
                     finishing = true;
                 } catch (final Exception e) {
                     LOG.warn("Stat DataStore Operation executor fail!", e);
@@ -115,10 +125,18 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
     }
 
     @Override
-    public void close() throws Exception {
+    public void close() {
+        thread.interrupt();
+        try {
+            thread.join();
+        } catch(InterruptedException e) {
+            LOG.debug("Join of thread {} was interrupted", thread.getName(), e);
+        }
+
         if (transactionChain != null) {
             transactionChain.close();
         }
 
+        LOG.debug("OperationProcessor closed");
     }
 }
diff --git a/applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModule.java b/applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModule.java
deleted file mode 100644 (file)
index fb0c504..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530;
-
-import org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableTopologyProvider;
-
-public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.AbstractTopologyLldpDiscoveryImplModule {
-    public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.TopologyLldpDiscoveryImplModule 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() {
-        FlowCapableTopologyProvider provider = new FlowCapableTopologyProvider();
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
-}
diff --git a/applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java b/applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java
deleted file mode 100644 (file)
index a98e380..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: topology-manager-impl yang module local name: topology-manager-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Sat May 30 21:28:43 PDT 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530;
-public class TopologyLldpDiscoveryImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.AbstractTopologyLldpDiscoveryImplModuleFactory {
-
-}
diff --git a/applications/topology-manager/src/main/resources/org/opendaylight/blueprint/topology-manager.xml b/applications/topology-manager/src/main/resources/org/opendaylight/blueprint/topology-manager.xml
new file mode 100644 (file)
index 0000000..97827a9
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+  <bean id="operationProcessor" class="org.opendaylight.openflowplugin.applications.topology.manager.OperationProcessor"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+  </bean>
+
+  <bean id="termPointChangeListener" class="org.opendaylight.openflowplugin.applications.topology.manager.TerminationPointChangeListenerImpl"
+          destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="operationProcessor"/>
+  </bean>
+
+  <bean id="nodeChangeListener" class="org.opendaylight.openflowplugin.applications.topology.manager.NodeChangeListenerImpl"
+          destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="operationProcessor"/>
+  </bean>
+
+  <bean id="topologyProvider" class="org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableTopologyProvider"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="operationProcessor"/>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/applications/topology-manager/src/main/yang/topology-manager-impl.yang b/applications/topology-manager/src/main/yang/topology-manager-impl.yang
deleted file mode 100644 (file)
index e6fe667..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-module topology-manager-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:topology-manager:impl";
-    prefix "topology-manager-impl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
-
-    description
-        "Service definition for topology-manager";
-
-    revision "2015-05-30" {
-        description
-            "Initial revision";
-    }
-
-    identity topology-manager-impl {
-        base config:module-type;
-        config:java-name-prefix TopologyLldpDiscoveryImpl;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case topology-manager-impl {
-            when "/config:modules/config:module/config:type = 'topology-manager-impl'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-        }
-    }
-}
index 82ba5748cd3fd274858de4c74b926e872d333e22..e70f62bddb06542b7009d4fe335941533aecbf3c 100644 (file)
                 <artifactId>forwardingrules-manager</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>forwardingrules-manager-config</artifactId>
-                <version>${project.version}</version>
-                <classifier>config</classifier>
-                <type>xml</type>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}.applications</groupId>
                 <artifactId>forwardingrules-sync</artifactId>
                 <artifactId>inventory-manager</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>inventory-manager</artifactId>
-                <version>${project.version}</version>
-                <type>xml</type>
-                <classifier>config</classifier>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}.applications</groupId>
                 <artifactId>lldp-speaker</artifactId>
                 <artifactId>topology-lldp-discovery</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>topology-lldp-discovery</artifactId>
-                <version>${project.version}</version>
-                <type>xml</type>
-                <classifier>config</classifier>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}.applications</groupId>
                 <artifactId>topology-manager</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>topology-manager</artifactId>
-                <version>${project.version}</version>
-                <type>xml</type>
-                <classifier>config</classifier>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}.applications</groupId>
                 <artifactId>of-switch-config-pusher</artifactId>
                 <version>${project.version}</version>
             </dependency>
 
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>of-switch-config-pusher</artifactId>
-                <version>${project.version}</version>
-                <type>xml</type>
-                <classifier>config</classifier>
-            </dependency>
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>statistics-manager-config</artifactId>
-                <version>${project.version}</version>
-                <classifier>config</classifier>
-                <type>xml</type>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}.applications</groupId>
                 <artifactId>table-miss-enforcer</artifactId>
                 <type>xml</type>
                 <classifier>config</classifier>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}.applications</groupId>
-                <artifactId>lldp-speaker</artifactId>
-                <version>${project.version}</version>
-                <type>xml</type>
-                <classifier>config</classifier>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>openflowplugin-controller-config</artifactId>
 
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>features-openflowplugin</artifactId>
+                <artifactId>features-openflowplugin-he</artifactId>
                 <version>${project.version}</version>
                 <classifier>features</classifier>
                 <type>xml</type>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>features-openflowplugin-li</artifactId>
+                <artifactId>features-openflowplugin</artifactId>
                 <version>${project.version}</version>
                 <classifier>features</classifier>
                 <type>xml</type>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>features-openflowplugin-extension</artifactId>
+                <artifactId>features-openflowplugin-extension-he</artifactId>
                 <version>${project.version}</version>
                 <classifier>features</classifier>
                 <type>xml</type>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>features-openflowplugin-extension-li</artifactId>
+                <artifactId>features-openflowplugin-extension</artifactId>
                 <version>${project.version}</version>
                 <classifier>features</classifier>
                 <type>xml</type>
index 91b1871efacfec1f6e829c093bca9ddd24c4d9ce..22315d8ede5377d83be0f4bc0c2d6e724ad1a603 100644 (file)
     </dependency>
     <!-- openflowplugin feature -->
     <dependency>
-      <artifactId>features-openflowplugin</artifactId>
+      <artifactId>features-openflowplugin-he</artifactId>
       <groupId>org.opendaylight.openflowplugin</groupId>
       <classifier>features</classifier>
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <artifactId>features-openflowplugin-li</artifactId>
+      <artifactId>features-openflowplugin</artifactId>
       <groupId>org.opendaylight.openflowplugin</groupId>
       <classifier>features</classifier>
       <type>xml</type>
     <!-- openflowplugin extension feature -->
     <dependency>
       <groupId>org.opendaylight.openflowplugin</groupId>
-      <artifactId>features-openflowplugin-extension</artifactId>
+      <artifactId>features-openflowplugin-extension-he</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.openflowplugin</groupId>
-      <artifactId>features-openflowplugin-extension-li</artifactId>
+      <artifactId>features-openflowplugin-extension</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
       <scope>runtime</scope>
index 563de788ce3816f6d8eecf510d28da2e11a2fcb8..3cab424da1dc928ca6ee543dd21cdf5bf3e366f9 100644 (file)
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-api</artifactId>
-        </dependency>
 
     </dependencies>
 
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
             </plugin>
-            <plugin>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>generate-sources</goal>
-                        </goals>
-                        <configuration>
-                            <codeGenerators>
-                                <generator>
-                                    <codeGeneratorClass>
-                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-                                    </codeGeneratorClass>
-                                    <outputBaseDir>${project.build.directory}/generated-sources/config</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>${project.build.directory}/generated-sources/sal</outputBaseDir>
-                                </generator>
-                                <generator>
-                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
-                                    <outputBaseDir>${project.build.directory}/site/models</outputBaseDir>
-                                </generator>
-                            </codeGenerators>
-                            <inspectDependencies>true</inspectDependencies>
-                        </configuration>
-                    </execution>
-                </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-jmx-generator-plugin</artifactId>
-                        <version>${config.version}</version>
-                    </dependency>
-                    <dependency>
-                        <groupId>org.opendaylight.mdsal</groupId>
-                        <artifactId>maven-sal-api-gen-plugin</artifactId>
-                        <version>${mdsal.model.version}</version>
-                        <type>jar</type>
-                    </dependency>
-                </dependencies>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/initial/69-drop-test.xml</file>
-                                    <type>xml</type>
-                                    <classifier>config</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/drop-test-karaf/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/test/droptest/rev150327/DropTestProviderModule.java b/drop-test-karaf/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/test/droptest/rev150327/DropTestProviderModule.java
deleted file mode 100644 (file)
index 8571428..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.test.droptest.rev150327;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.openflowplugin.droptestkaraf.DropTestProviderImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DropTestProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.test.droptest.rev150327.AbstractDropTestProviderModule {
-    private static final Logger LOG = LoggerFactory.getLogger(DropTestProviderModule.class);
-
-    public DropTestProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public DropTestProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.test.droptest.rev150327.DropTestProviderModule 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() {
-        LOG.debug("Starting drop-test provider module.");
-        DataBroker dataBroker = getDataBrokerDependency();
-        NotificationService notificationAdapterDependency = getNotificationAdapterDependency();
-        SalFlowService salFlowService = getRpcRegistryDependency().getRpcService(SalFlowService.class);
-        DropTestProviderImpl dropTestProvider = new DropTestProviderImpl(dataBroker, notificationAdapterDependency, salFlowService);
-        LOG.info("Drop-test provider module initialized.");
-        return dropTestProvider;
-    }
-
-}
diff --git a/drop-test-karaf/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/test/droptest/rev150327/DropTestProviderModuleFactory.java b/drop-test-karaf/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/test/droptest/rev150327/DropTestProviderModuleFactory.java
deleted file mode 100644 (file)
index 4039d2a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: drop-test-provider yang module local name: drop-test-provider
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Sun Apr 26 11:04:30 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.test.droptest.rev150327;
-public class DropTestProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.test.droptest.rev150327.AbstractDropTestProviderModuleFactory {
-
-}
diff --git a/drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test.xml b/drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test.xml
new file mode 100644 (file)
index 0000000..855d2d9
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"/>
+
+  <odl:rpc-service id="flowService"
+      interface="org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService"/>
+
+  <bean id="dropTestProvider" class="org.opendaylight.openflowplugin.droptestkaraf.DropTestProviderImpl">
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="flowService"/>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/drop-test-karaf/src/main/resources/initial/69-drop-test.xml b/drop-test-karaf/src/main/resources/initial/69-drop-test.xml
deleted file mode 100644 (file)
index 00a3cd6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
-  ~
-  ~ This program and the accompanying materials are made available under the
-  ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
-  ~ and is available at http://www.eclipse.org/legal/epl-v10.html
-  -->
-
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-
-<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:config:openflow:test:droptest">prefix:drop-test-provider</type>
-                    <name>drop-test-provider</name>
-                    <data-broker>
-                        <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>
-                    <rpc-registry>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
-                        <name>binding-rpc-broker</name>
-                    </rpc-registry>
-                    <notification-adapter>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-new-notification-service</type>
-                        <name>binding-notification-adapter</name>
-                    </notification-adapter>
-                </module>
-            </modules>
-        </data>
-    </configuration>
-</snapshot>
\ No newline at end of file
diff --git a/drop-test-karaf/src/main/yang/drop-test.yang b/drop-test-karaf/src/main/yang/drop-test.yang
deleted file mode 100644 (file)
index 512a37d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-module drop-test-provider {
-       yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:config:openflow:test:droptest";
-    prefix "drop-test-provider";
-
-    import config {prefix config; revision-date 2013-04-05;}
-    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
-    import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28;}
-
-    description
-        "drop-test-provider";
-
-    revision "2015-03-27" {
-        description
-            "Drop test implementation.";
-    }
-
-    identity drop-test-provider {
-        base config:module-type;
-        config:java-name-prefix DropTestProvider;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case drop-test-provider {
-            when "/config:modules/config:module/config:type = 'drop-test-provider'";
-
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-async-data-broker;
-                    }
-                }
-            }
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-rpc-registry;
-                    }
-                }
-            }
-            container notification-adapter {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity sal-broker:binding-new-notification-service;
-                    }
-                }
-            }
-        }
-    }
-}
similarity index 94%
rename from extension/features-li/pom.xml
rename to extension/features-he/pom.xml
index 18632cca21ecff770672c96098a68b67aa00de36..a8b77513becf219a03aa27981414ea31f69f6d10 100644 (file)
@@ -9,7 +9,7 @@
   </parent>
   <groupId>org.opendaylight.openflowplugin</groupId>
   <version>0.3.0-SNAPSHOT</version>
-  <artifactId>features-openflowplugin-extension-li</artifactId>
+  <artifactId>features-openflowplugin-extension-he</artifactId>
 
   <packaging>jar</packaging>
 
@@ -34,7 +34,7 @@
     <!-- feature dependencies -->
     <dependency>
       <groupId>org.opendaylight.openflowplugin</groupId>
-      <artifactId>features-openflowplugin-li</artifactId>
+      <artifactId>features-openflowplugin-he</artifactId>
       <classifier>features</classifier>
       <type>xml</type>
     </dependency>
similarity index 82%
rename from extension/features-li/src/main/features/features.xml
rename to extension/features-he/src/main/features/features.xml
index f0434f0b4b21c90043098eb624445d38e2e0d148..52869fa1c117124ae7a60443149c2ce7b87b9533 100644 (file)
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<features name="openflowplugin-extension-li-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+<features name="openflowplugin-extension-he-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
-    <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-li/${project.version}/xml/features</repository>
+    <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-he/${project.version}/xml/features</repository>
 
-    <feature name="odl-openflowplugin-nxm-extensions-li" description="OpenDaylight :: Openflow Plugin :: Nicira Extensions" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
+    <feature name="odl-openflowplugin-nxm-extensions-he" description="OpenDaylight :: Openflow Plugin :: Nicira Extensions" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
         <configfile finalname="etc/opendaylight/karaf/43-openflowjava-nx-config.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-extension-nicira-config/{{VERSION}}/xml/config</configfile>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowjava-extension-nicira-api/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowjava-extension-nicira/{{VERSION}}</bundle>
index 50e4d98563588353248c658e43673aed18128c95..d5dd73e4cf4866031f19a306c143f7072a6a1149 100644 (file)
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>config-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
index 761dc649cf880ccf6de44cad6339033db84e2e2c..61b4a7248fae8dfcaea28834280dbfde504efd0d 100644 (file)
@@ -83,16 +83,21 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.registerActionSerializer(SetNspCodec.SERIALIZER_KEY, NiciraActionCodecs.SET_NSP_CODEC);
         registrator.registerActionDeserializer(SetNshc1Codec.DESERIALIZER_KEY, NiciraActionCodecs.SET_NSC1_CODEC);
         registrator.registerActionSerializer(SetNshc1Codec.SERIALIZER_KEY, NiciraActionCodecs.SET_NSC1_CODEC);
+        //BUG nshc2 codec is registered with same subtype as Conntrack codec
         registrator.registerActionDeserializer(SetNshc2Codec.DESERIALIZER_KEY, NiciraActionCodecs.SET_NSC2_CODEC);
         registrator.registerActionSerializer(SetNshc2Codec.SERIALIZER_KEY, NiciraActionCodecs.SET_NSC2_CODEC);
+        //Continue
         registrator.registerActionDeserializer(SetNshc3Codec.DESERIALIZER_KEY, NiciraActionCodecs.SET_NSC3_CODEC);
         registrator.registerActionSerializer(SetNshc3Codec.SERIALIZER_KEY, NiciraActionCodecs.SET_NSC3_CODEC);
         registrator.registerActionDeserializer(SetNshc4Codec.DESERIALIZER_KEY, NiciraActionCodecs.SET_NSC4_CODEC);
         registrator.registerActionSerializer(SetNshc4Codec.SERIALIZER_KEY, NiciraActionCodecs.SET_NSC4_CODEC);
         registrator.registerActionDeserializer(SetNsiCodec.DESERIALIZER_KEY, NiciraActionCodecs.SET_NSI_CODEC);
         registrator.registerActionSerializer(SetNsiCodec.SERIALIZER_KEY, NiciraActionCodecs.SET_NSI_CODEC);
+        //BUG Conntrack codec is registered with same subtype as Nshc2 codec
         registrator.registerActionSerializer(ConntrackCodec.SERIALIZER_KEY, NiciraActionCodecs.CONNTRACK_CODEC);
         registrator.registerActionDeserializer(ConntrackCodec.DESERIALIZER_KEY, NiciraActionCodecs.CONNTRACK_CODEC);
+        //Continue
+
 
         registrator.registerMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC);
         registrator.registerMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC);
@@ -174,6 +179,8 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.unregisterActionSerializer(SetNsiCodec.SERIALIZER_KEY);
         registrator.unregisterActionDeserializer(SetNspCodec.DESERIALIZER_KEY);
         registrator.unregisterActionSerializer(SetNspCodec.SERIALIZER_KEY);
+        //Added this line (unregisterDeserialize was missing)
+        registrator.unregisterActionDeserializer(SetNshc1Codec.DESERIALIZER_KEY);
         registrator.unregisterActionSerializer(SetNshc1Codec.SERIALIZER_KEY);
         registrator.unregisterActionDeserializer(SetNshc2Codec.DESERIALIZER_KEY);
         registrator.unregisterActionSerializer(SetNshc2Codec.SERIALIZER_KEY);
@@ -181,9 +188,10 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.unregisterActionSerializer(SetNshc3Codec.SERIALIZER_KEY);
         registrator.unregisterActionDeserializer(SetNshc4Codec.DESERIALIZER_KEY);
         registrator.unregisterActionSerializer(SetNshc4Codec.SERIALIZER_KEY);
+        //BUG unregistering with same subtype as Nshc2
         registrator.unregisterActionSerializer(ConntrackCodec.SERIALIZER_KEY);
         registrator.unregisterActionDeserializer(ConntrackCodec.DESERIALIZER_KEY);
-
+        //CONTINUE
         registrator.unregisterMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY);
         registrator.unregisterMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY);
         registrator.unregisterMatchEntrySerializer(Reg1Codec.SERIALIZER_KEY);
index 38d3fd208f4d97f45aaf88af436095869862dcb7..ad46e6abf94abcfb1366423de4b86d4cc1269a49 100644 (file)
@@ -44,20 +44,15 @@ public class TcpDstCodec extends AbstractMatchCodec {
         serializeHeader(input, outBuffer);
         TcpDstCaseValue tcpDstCase = ((TcpDstCaseValue) input.getMatchEntryValue());
         outBuffer.writeShort(tcpDstCase.getTcpDstValues().getPort().getValue());
-        outBuffer.writeShort(tcpDstCase.getTcpDstValues().getMask());
     }
 
     @Override
     public MatchEntry deserialize(ByteBuf message) {
         MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
-        matchEntryBuilder.setHasMask(true);
         int portNo = message.readUnsignedShort();
-        int mask = message.readUnsignedShort();
-        message.readBytes(mask);
         TcpDstCaseValueBuilder caseBuilder = new TcpDstCaseValueBuilder();
         TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder();
         tcpDstValuesBuilder.setPort(new PortNumber(portNo));
-        tcpDstValuesBuilder.setMask(portNo);
         caseBuilder.setTcpDstValues(tcpDstValuesBuilder.build());
         matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
         return matchEntryBuilder.build();
@@ -79,9 +74,7 @@ public class TcpDstCodec extends AbstractMatchCodec {
     }
 
     @Override
-    public Class<? extends MatchField> getNxmField() {
-        return NxmOfTcpDst.class;
-    }
+    public Class<? extends MatchField> getNxmField() { return NxmOfTcpDst.class; }
 
     @Override
     public Class<? extends OxmClassBase> getOxmClass() {
index 5c483870a09dc64ed3a07ae5cd467f6bd98e14cb..ec7f57c2be5991da1b9d06b6ee10a25938f09f91 100644 (file)
@@ -43,20 +43,16 @@ public class TcpSrcCodec extends AbstractMatchCodec {
         serializeHeader(input, outBuffer);
         TcpSrcCaseValue tcpSrcCase = ((TcpSrcCaseValue) input.getMatchEntryValue());
         outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getPort().getValue());
-        outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getMask());
     }
 
     @Override
     public MatchEntry deserialize(ByteBuf message) {
         MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
-        matchEntryBuilder.setHasMask(true);
+        matchEntryBuilder.setHasMask(false);
         int portNo = message.readUnsignedShort();
-        int mask = message.readUnsignedShort();
-        message.readBytes(mask);
         TcpSrcCaseValueBuilder caseBuilder = new TcpSrcCaseValueBuilder();
         TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder();
         tcpSrcValuesBuilder.setPort(new PortNumber(portNo));
-        tcpSrcValuesBuilder.setMask(portNo);
         caseBuilder.setTcpSrcValues(tcpSrcValuesBuilder.build());
         matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
         return matchEntryBuilder.build();
index 9347dcd7d0fa5b2ee8ec5d3b080bf9eba9c16c88..3bf3d374fea87678f37ea8048f85aa53ac4def9a 100644 (file)
@@ -45,20 +45,16 @@ public class UdpDstCodec extends AbstractMatchCodec {
         serializeHeader(input, outBuffer);
         UdpDstCaseValue udpDstCase = ((UdpDstCaseValue) input.getMatchEntryValue());
         outBuffer.writeShort(udpDstCase.getUdpDstValues().getPort().getValue());
-        outBuffer.writeShort(udpDstCase.getUdpDstValues().getMask());
     }
 
     @Override
     public MatchEntry deserialize(ByteBuf message) {
         MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
-        matchEntryBuilder.setHasMask(true);
+        matchEntryBuilder.setHasMask(false);
         int portNo = message.readUnsignedShort();
-        int mask = message.readUnsignedShort();
-        message.readBytes(mask);
         UdpDstCaseValueBuilder caseBuilder = new UdpDstCaseValueBuilder();
         UdpDstValuesBuilder udpDstValuesBuilder = new UdpDstValuesBuilder();
         udpDstValuesBuilder.setPort(new PortNumber(portNo));
-        udpDstValuesBuilder.setMask(portNo);
         caseBuilder.setUdpDstValues(udpDstValuesBuilder.build());
         matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
         return matchEntryBuilder.build();
index 44c2e64ea76a811c2125760f0c8a89b9ab371112..0e1ba3ee3d16dce5915039e2615ed03861f96547 100644 (file)
@@ -45,20 +45,16 @@ public class UdpSrcCodec extends AbstractMatchCodec {
         serializeHeader(input, outBuffer);
         UdpSrcCaseValue udpSrcCase = ((UdpSrcCaseValue) input.getMatchEntryValue());
         outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getPort().getValue());
-        outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getMask());
     }
 
     @Override
     public MatchEntry deserialize(ByteBuf message) {
         MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
-        matchEntryBuilder.setHasMask(true);
+        matchEntryBuilder.setHasMask(false);
         int portNo = message.readUnsignedShort();
-        int mask = message.readUnsignedShort();
-        message.readBytes(mask);
         UdpSrcCaseValueBuilder caseBuilder = new UdpSrcCaseValueBuilder();
         UdpSrcValuesBuilder udpSrcValuesBuilder = new UdpSrcValuesBuilder();
         udpSrcValuesBuilder.setPort(new PortNumber(portNo));
-        udpSrcValuesBuilder.setMask(portNo);
         caseBuilder.setUdpSrcValues(udpSrcValuesBuilder.build());
         matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
         return matchEntryBuilder.build();
diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistratorTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistratorTest.java
new file mode 100644 (file)
index 0000000..04c45f0
--- /dev/null
@@ -0,0 +1,301 @@
+/**
+ * Copyright (c) 2016 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.openflowjava.nx;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey;
+import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey;
+import org.opendaylight.openflowjava.nx.api.NiciraExtensionCodecRegistrator;
+import org.opendaylight.openflowjava.nx.codec.action.MultipathCodec;
+import org.opendaylight.openflowjava.nx.codec.action.OutputRegCodec;
+import org.opendaylight.openflowjava.nx.codec.action.RegLoadCodec;
+import org.opendaylight.openflowjava.nx.codec.action.RegMoveCodec;
+import org.opendaylight.openflowjava.nx.codec.action.ResubmitCodec;
+import org.opendaylight.openflowjava.nx.codec.action.SetNshc1Codec;
+import org.opendaylight.openflowjava.nx.codec.action.SetNshc3Codec;
+import org.opendaylight.openflowjava.nx.codec.action.SetNshc4Codec;
+import org.opendaylight.openflowjava.nx.codec.action.SetNsiCodec;
+import org.opendaylight.openflowjava.nx.codec.action.SetNspCodec;
+import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec;
+import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec;
+import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec;
+import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec;
+import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec;
+import org.opendaylight.openflowjava.nx.codec.match.CtStateCodec;
+import org.opendaylight.openflowjava.nx.codec.match.CtZoneCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec;
+import org.opendaylight.openflowjava.nx.codec.match.Nshc1Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Nshc2Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Nshc3Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Nshc4Codec;
+import org.opendaylight.openflowjava.nx.codec.match.NsiCodec;
+import org.opendaylight.openflowjava.nx.codec.match.NspCodec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg3Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec;
+import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpSrcCodec;
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionOutputReg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMove;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionResubmit;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNshc1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNshc3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNshc4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxArpSha;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxArpTha;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtZone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg5;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunIpv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunIpv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpOp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpSpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpTpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfEthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfEthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfEthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfUdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfUdpSrc;
+
+@RunWith(MockitoJUnitRunner.class)
+public class NiciraExtensionsRegistratorTest {
+
+    NiciraExtensionsRegistrator niciraExtensionsRegistrator;
+
+    @Mock
+    NiciraExtensionCodecRegistrator registrator;
+
+    @Before
+    public void setUp() {
+        niciraExtensionsRegistrator = new NiciraExtensionsRegistrator(registrator);
+    }
+
+    @Test
+    public void registerNiciraExtensionsTest() {
+        niciraExtensionsRegistrator.registerNiciraExtensions();
+
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 7)), Matchers.any(RegLoadCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionRegLoad.class)), Matchers.any(RegLoadCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 6)), Matchers.any(RegMoveCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionRegMove.class)), Matchers.any(RegMoveCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 15)), Matchers.any(OutputRegCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionOutputReg.class)), Matchers.any(OutputRegCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionResubmit.class)), Matchers.any(ResubmitCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 1)), Matchers.any(ResubmitCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 14)), Matchers.any(ResubmitCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionMultipath.class)), Matchers.any(MultipathCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 10)), Matchers.any(MultipathCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 32)), Matchers.any(SetNspCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNsp.class)), Matchers.any(SetNspCodec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 34)), Matchers.any(SetNshc1Codec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNshc1.class)), Matchers.any(SetNshc1Codec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 36)), Matchers.any(SetNshc3Codec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNshc3.class)), Matchers.any(SetNshc3Codec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 37)), Matchers.any(SetNshc4Codec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNshc4.class)), Matchers.any(SetNshc4Codec.class));
+        Mockito.verify(registrator).registerActionDeserializer(Matchers.eq(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 33)), Matchers.any(SetNsiCodec.class));
+        Mockito.verify(registrator).registerActionSerializer(Matchers.eq(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNsi.class)), Matchers.any(SetNsiCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg0.class)), Matchers.any(Reg0Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 0)), Matchers.any(Reg0Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg1.class)), Matchers.any(Reg1Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 1)), Matchers.any(Reg1Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg2.class)), Matchers.any(Reg2Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 2)), Matchers.any(Reg2Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg3.class)), Matchers.any(Reg3Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 3)), Matchers.any(Reg3Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg4.class)), Matchers.any(Reg4Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 4)), Matchers.any(Reg4Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg5.class)), Matchers.any(Reg5Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 5)), Matchers.any(Reg5Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg6.class)), Matchers.any(Reg6Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 6)), Matchers.any(Reg6Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg7.class)), Matchers.any(Reg7Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 7)), Matchers.any(Reg7Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunId.class)), Matchers.any(TunIdCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 16)), Matchers.any(TunIdCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpOp.class)), Matchers.any(ArpOpCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 15)), Matchers.any(ArpOpCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpSha.class)), Matchers.any(ArpShaCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 17)), Matchers.any(ArpShaCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpSpa.class)), Matchers.any(ArpSpaCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 16)), Matchers.any(ArpSpaCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpTha.class)), Matchers.any(ArpThaCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 18)), Matchers.any(ArpThaCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class)), Matchers.any(ArpTpaCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 17)), Matchers.any(ArpTpaCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class)), Matchers.any(EthDstCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 1)), Matchers.any(EthDstCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthSrc.class)), Matchers.any(EthSrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 2)), Matchers.any(EthSrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class)), Matchers.any(EthTypeCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 3)), Matchers.any(EthTypeCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsp.class)), Matchers.any(NspCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 37)), Matchers.any(NspCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc1.class)), Matchers.any(Nshc1Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 39)), Matchers.any(Nshc1Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc2.class)), Matchers.any(Nshc2Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 40)), Matchers.any(Nshc2Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc3.class)), Matchers.any(Nshc3Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 41)), Matchers.any(Nshc3Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc4.class)), Matchers.any(Nshc4Codec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 42)), Matchers.any(Nshc4Codec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsi.class)), Matchers.any(NsiCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 38)), Matchers.any(NsiCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Dst.class)), Matchers.any(TunIpv4DstCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 32)), Matchers.any(TunIpv4DstCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Src.class)), Matchers.any(TunIpv4SrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 31)), Matchers.any(TunIpv4SrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpSrc.class)), Matchers.any(TcpSrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 9)), Matchers.any(TcpSrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpDst.class)), Matchers.any(TcpDstCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 10)), Matchers.any(TcpDstCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfUdpSrc.class)), Matchers.any(UdpSrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 11)), Matchers.any(UdpSrcCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfUdpDst.class)), Matchers.any(UdpDstCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 12)), Matchers.any(UdpDstCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxCtState.class)), Matchers.any(CtStateCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 105)), Matchers.any(CtStateCodec.class));
+        Mockito.verify(registrator).registerMatchEntrySerializer(Matchers.eq(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxCtZone.class)), Matchers.any(CtZoneCodec.class));
+        Mockito.verify(registrator).registerMatchEntryDeserializer(Matchers.eq(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 106)), Matchers.any(CtZoneCodec.class));
+    }
+
+    @Test
+    public void unregisterExtensionsTest() {
+        niciraExtensionsRegistrator.unregisterExtensions();
+
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 7));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionRegLoad.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 6));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionRegMove.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 15));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionOutputReg.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 1));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 14));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionResubmit.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 10));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionMultipath.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 33));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNsi.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 32));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNsp.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 34));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNshc1.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 36));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNshc3.class));
+        Mockito.verify(registrator).unregisterActionDeserializer(new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 37));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionSetNshc4.class));
+        Mockito.verify(registrator).unregisterActionSerializer(new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionConntrack.class));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg0.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 0));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg1.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 1));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg2.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 2));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg3.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 3));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg4.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 4));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg5.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 5));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg6.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 6));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg7.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 7));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunId.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 16));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpOp.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 15));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpSha.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 17));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpSpa.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 16));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpTha.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 18));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 17));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 1));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthSrc.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 2));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 3));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsp.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 37));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsi.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 38));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc1.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 39));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc2.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 40));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc3.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 41));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc4.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 42));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Dst.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 32));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Src.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 31));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpSrc.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 9));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpDst.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 10));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfUdpSrc.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 11));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfUdpDst.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, 12));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxCtState.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 105));
+        Mockito.verify(registrator).unregisterMatchEntrySerializer(new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxCtZone.class));
+        Mockito.verify(registrator).unregisterMatchEntryDeserializer(new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, 106));
+    }
+}
index 2054f24bc7089cf16732e1f128d81e68d60b7e43..de26eb09c47e087ca557690dd620daa42b522922 100644 (file)
@@ -7,8 +7,13 @@
  */
 package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor;
 
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 
+import java.util.List;
+import java.util.ListIterator;
+
 /**
  * @author msunal
  *
@@ -16,11 +21,19 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 public final class IpConverter {
 
     public static long Ipv4AddressToLong(Ipv4Address ipv4Address) {
-        String ipAddress = ipv4Address.getValue();
-        long result = 0;
-        String[] atoms = ipAddress.split("\\.");
-        for (int i = 3; i >= 0; i--) {
-            result |= (Long.parseLong(atoms[3 - i]) << (i * 8));
+        long result = 0 ;
+        Iterable<String> splitted = Splitter.on('.')
+                .trimResults()
+                .omitEmptyStrings()
+                .split(ipv4Address.getValue());
+
+        List<String> splittedAddress = Lists.newArrayList(splitted.iterator());
+        int maxIndex = splittedAddress.size() - 1;
+        ListIterator<String> listIter = splittedAddress.listIterator();
+        while(listIter.hasNext()) {
+            String current = listIter.next();
+            int i = splittedAddress.indexOf(current);
+            result |= (Long.parseLong(current) << ((maxIndex-i) * 8));
         }
         return result & 0xFFFFFFFF;
     }
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverterTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverterTest.java
new file mode 100644 (file)
index 0000000..f8e27ff
--- /dev/null
@@ -0,0 +1,24 @@
+package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+
+public class IpConverterTest {
+
+    @Test
+    public void testIpv4AddressToLong() {
+        Ipv4Address ipAddress = new Ipv4Address("192.168.1.2");
+        long address = 0xc0a80102L;
+        assertEquals(address, IpConverter.Ipv4AddressToLong(ipAddress));
+    }
+
+    @Test
+    public void testIpv4AddressToLong2() {
+        Ipv4Address ipAddress = new Ipv4Address("10.168.1.2");
+        long address = 0x0aa80102L;
+        assertEquals(address, IpConverter.Ipv4AddressToLong(ipAddress));
+    }
+
+}
index 1195d5eb3b419df0c58be9148347100a3080a837..f71839f4fb2e42ce0719c579fc168dbcd69e91c3 100644 (file)
@@ -18,8 +18,8 @@
         <module>openflowplugin-extension-api</module>
         <module>openflowplugin-extension-nicira</module>
         <module>openflowplugin-extension-nicira-config</module>
+        <module>features-he</module>
         <module>features</module>
-        <module>features-li</module>
         <module>test-extension</module>
     </modules>
 </project>
similarity index 78%
rename from features-li/pom.xml
rename to features-he/pom.xml
index 62d49173bbe057832a356a4773a5c3ef93028174..ef1ceec9f72414bcbff242940db58ca88b3e42aa 100644 (file)
@@ -10,7 +10,7 @@
     </parent>
 
     <groupId>org.opendaylight.openflowplugin</groupId>
-    <artifactId>features-openflowplugin-li</artifactId>
+    <artifactId>features-openflowplugin-he</artifactId>
     <packaging>jar</packaging>
     <version>0.3.0-SNAPSHOT</version>
 
@@ -22,9 +22,7 @@
         <openflowplugin.version>0.3.0-SNAPSHOT</openflowplugin.version>
         <dlux.version>0.4.0-SNAPSHOT</dlux.version>
         <lldp.version>0.11.0-SNAPSHOT</lldp.version>
-
         <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
-        <config.statistics.manager.configfile>30-statistics-manager.xml</config.statistics.manager.configfile>
         <restconf.version>1.4.0-SNAPSHOT</restconf.version>
         <mdsal.model.version>0.9.0-SNAPSHOT</mdsal.model.version>
     </properties>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>forwardingrules-manager</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>forwardingrules-manager-config</artifactId>
-            <classifier>config</classifier>
-            <type>xml</type>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>forwardingrules-sync</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>inventory-manager</artifactId>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>statistics-manager</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>statistics-manager-config</artifactId>
-            <classifier>config</classifier>
-            <type>xml</type>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.dlux</groupId>
             <artifactId>openflowplugin-impl</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>table-miss-enforcer</artifactId>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-blueprint-config-he</artifactId>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>table-miss-enforcer</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
         </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>topology-lldp-discovery</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>topology-lldp-discovery</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>topology-manager</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>topology-manager</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>of-switch-config-pusher</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>of-switch-config-pusher</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>lldp-speaker</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>drop-test-karaf</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin</groupId>
-            <artifactId>drop-test-karaf</artifactId>
-            <classifier>config</classifier>
-            <type>xml</type>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>test-common</artifactId>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowplugin-controller-config</artifactId>
             <type>xml</type>
-            <classifier>config-Li</classifier>
+            <classifier>config-He</classifier>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <type>xml</type>
             <classifier>config</classifier>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>notification-supplier</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>notification-supplier</artifactId>
-        </dependency>
     </dependencies>
 </project>
similarity index 58%
rename from features-li/src/main/features/features.xml
rename to features-he/src/main/features/features.xml
index 9872cf47ca44d1960827f6417618694cbe9fc379..a581af2ef2cfb7d5ac66633876db4e80e226c449 100644 (file)
@@ -8,9 +8,9 @@
   ~ and is available at http://www.eclipse.org/legal/epl-v10.html
   -->
 
-<features name="openflowplugin-li-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+<features name="openflowplugin-he-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
     <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.openflowjava/features-openflowjava/${openflowjava.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features</repository>
 
-
-    <feature name='odl-openflowplugin-all-li' description="OpenDaylight :: Openflow Plugin :: All" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
-        <feature version="${project.version}">odl-openflowplugin-flow-services-li</feature>
-        <feature version="${project.version}">odl-openflowplugin-flow-services-rest-li</feature>
-        <feature version="${project.version}">odl-openflowplugin-flow-services-ui-li</feature>
+    <feature name='odl-openflowplugin-all-he' description="OpenDaylight :: Openflow Plugin :: All" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
+        <feature version="${project.version}">odl-openflowplugin-flow-services-he</feature>
+        <feature version="${project.version}">odl-openflowplugin-flow-services-rest-he</feature>
+        <feature version="${project.version}">odl-openflowplugin-flow-services-ui-he</feature>
     </feature>
 
-    <feature name='odl-openflowplugin-southbound-li' description="OpenDaylight :: Openflow Plugin :: Li southBound API implementation " version='${project.version}'>
+    <feature name='odl-openflowplugin-southbound-he' description="OpenDaylight :: Openflow Plugin :: SouthBound" version='${project.version}'>
         <feature version="${mdsal.version}">odl-mdsal-broker</feature>
-        <feature version="${project.version}">odl-openflowplugin-nsf-services-li</feature>
+        <feature version="${project.version}">odl-openflowplugin-nsf-model-he</feature>
         <feature version="${openflowjava.version}">odl-openflowjava-protocol</feature>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-common/{{VERSION}}</bundle>
-        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-api/{{VERSION}}</bundle>
-        <!-- TODO : remove dependency on openflowplugin in the future -->
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/{{VERSION}}</bundle>
-        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-impl/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-api/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-extension-api/{{VERSION}}</bundle>
-       <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/42-openflowplugin-Li.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/config-Li</configfile>
+        <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/inventory-manager/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/statistics-manager/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-blueprint-config-he/{{VERSION}}</bundle>
+        <configfile finalname="etc/opendaylight/karaf/42-openflowplugin-He.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/config-He</configfile>
+        <configfile finalname="etc/opendaylight/karaf/43-msg-spy.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/configmsgspy</configfile>
     </feature>
 
-    <feature name='odl-openflowplugin-flow-services-li' description="OpenDaylight :: Openflow Plugin :: Flow Services" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
-        <feature version="${project.version}">odl-openflowplugin-app-config-pusher-li</feature>
-        <feature version="${project.version}">odl-openflowplugin-app-lldp-speaker-li</feature>
-        <feature version="${project.version}">odl-openflowplugin-nsf-services-li</feature>
-
+    <feature name='odl-openflowplugin-flow-services-he' description="OpenDaylight :: Openflow Plugin :: Flow Services" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
+        <feature version="${project.version}">odl-openflowplugin-app-config-pusher-he</feature>
+        <feature version="${project.version}">odl-openflowplugin-app-lldp-speaker-he</feature>
+        <feature version="${project.version}">odl-openflowplugin-nsf-services-he</feature>
     </feature>
 
-    <feature name='odl-openflowplugin-nsf-services-li' version='${project.version}'
-             description="OpenDaylight :: OpenflowPlugin :: NSF :: Services">
+    <feature name='odl-openflowplugin-nsf-services-he' version='${project.version}'
+        description="OpenDaylight :: OpenflowPlugin :: NSF :: Services">
         <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
-        <feature version='${project.version}'>odl-openflowplugin-nsf-model-li</feature>
+        <feature version='${project.version}'>odl-openflowplugin-nsf-model-he</feature>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-common/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/topology-manager/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/forwardingrules-manager/{{VERSION}}</bundle>
-       <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/30-forwardingrules-manager.xml">mvn:org.opendaylight.openflowplugin.applications/forwardingrules-manager-config/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/72-topology-lldp-discovery.xml">mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/73-topology-manager.xml">mvn:org.opendaylight.openflowplugin.applications/topology-manager/{{VERSION}}/xml/config</configfile>
+        <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
     </feature>
 
-    <feature name='odl-openflowplugin-nsf-model-li' version='${project.version}'
-             description="OpenDaylight :: OpenflowPlugin :: NSF :: Model">
+    <feature name='odl-openflowplugin-nsf-model-he' version='${project.version}'
+        description="OpenDaylight :: OpenflowPlugin :: NSF :: Model">
         <!-- general models -->
         <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
        <bundle>mvn:org.opendaylight.controller.model/model-inventory/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.model/model-flow-service/{{VERSION}}</bundle>
     </feature>
 
-    <feature name='odl-openflowplugin-flow-services-rest-li' description="OpenDaylight :: Openflow Plugin :: Flow Services :: REST" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-flow-services-li</feature>
+    <feature name='odl-openflowplugin-flow-services-rest-he' description="OpenDaylight :: Openflow Plugin :: Flow Services :: REST" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-flow-services-he</feature>
         <feature version="${restconf.version}">odl-restconf</feature>
     </feature>
-    <feature name='odl-openflowplugin-flow-services-ui-li' description="OpenDaylight :: Openflow Plugin :: Flow Services :: UI" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-flow-services-rest-li</feature>
+    <feature name='odl-openflowplugin-flow-services-ui-he' description="OpenDaylight :: Openflow Plugin :: Flow Services :: UI" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-flow-services-rest-he</feature>
         <feature version="${dlux.version}">odl-dlux-core</feature>
         <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
         <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
     </feature>
 
     <!-- CBENCH TESTING -->
-    <feature name='odl-openflowplugin-drop-test-li' description="OpenDaylight :: Openflow Plugin :: Drop Test" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-flow-services-li</feature>
+    <feature name='odl-openflowplugin-drop-test-he' description="OpenDaylight :: Openflow Plugin :: Drop Test" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-flow-services-he</feature>
         <bundle>mvn:org.opendaylight.openflowplugin/test-common/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/drop-test-karaf/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/69-drop-test.xml">mvn:org.opendaylight.openflowplugin/drop-test-karaf/{{VERSION}}/xml/config</configfile>
     </feature>
 
     <!-- APPLICATIONS -->
-    <feature name='odl-openflowplugin-app-table-miss-enforcer-li' description="OpenDaylight :: Openflow Plugin :: Application - table-miss-enforcer" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
+    <feature name='odl-openflowplugin-app-table-miss-enforcer-he' description="OpenDaylight :: Openflow Plugin :: Application - table-miss-enforcer" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/table-miss-enforcer/{{VERSION}}</bundle>
-       <configfile finalname="etc/opendaylight/karaf/69-table-miss-enforcer.xml">mvn:org.opendaylight.openflowplugin.applications/table-miss-enforcer/{{VERSION}}/xml/config</configfile>
     </feature>
-    <feature name='odl-openflowplugin-app-config-pusher-li' description="OpenDaylight :: Openflow Plugin :: app - default config-pusher" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
+    <feature name='odl-openflowplugin-app-config-pusher-he' description="OpenDaylight :: Openflow Plugin :: app - default config-pusher" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/of-switch-config-pusher/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/70-of-switch-config-pusher.xml">mvn:org.opendaylight.openflowplugin.applications/of-switch-config-pusher/{{VERSION}}/xml/config</configfile>
     </feature>
 
-    <feature name='odl-openflowplugin-app-lldp-speaker-li' description="OpenDaylight :: Openflow Plugin :: app lldp-speaker" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
+    <feature name='odl-openflowplugin-app-lldp-speaker-he' description="OpenDaylight :: Openflow Plugin :: app lldp-speaker" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/lldp-speaker/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/71-lldp-speaker.xml">mvn:org.opendaylight.openflowplugin.applications/lldp-speaker/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/72-topology-lldp-discovery.xml">mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}/xml/config</configfile>
-    </feature>
-
-    <feature name='odl-openflowplugin-app-bulk-o-matic-li' description="OpenDaylight :: Openflow Plugin :: app bulk flow operations support" version='${project.version}'>
-        <feature version="${project.version}">odl-openflowplugin-southbound-li</feature>
-        <bundle>mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/${project.version}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/71-bulk-o-matic.xml">mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/${project.version}/xml/config</configfile>
     </feature>
 
-    <feature name='odl-openflowplugin-notifications-li' description="OpenDaylight :: Openflow Plugin :: app notifications supplier" version='${project.version}'>
-        <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
-        <feature version="${project.version}">odl-openflowplugin-nsf-model-li</feature>
-        <bundle>mvn:org.opendaylight.openflowplugin.applications/notification-supplier/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/73-notification-supplier.xml">mvn:org.opendaylight.openflowplugin.applications/notification-supplier/{{VERSION}}/xml/config</configfile>
+    <feature name='odl-openflowplugin-app-bulk-o-matic-he' description="OpenDaylight :: Openflow Plugin :: app bulk flow operations support" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/{{VERSION}}</bundle>
+        <configfile finalname="etc/opendaylight/karaf/71-bulk-o-matic.xml">mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/{{VERSION}}/xml/config</configfile>
     </feature>
 
 </features>
index c02e3c1d8a21be6f033fe23fe272dc226769d7ac..f375253e25d77663c9d8ce4b669e622ba5b90dd5 100644 (file)
         <openflowplugin.version>0.3.0-SNAPSHOT</openflowplugin.version>
         <dlux.version>0.4.0-SNAPSHOT</dlux.version>
         <lldp.version>0.11.0-SNAPSHOT</lldp.version>
-
         <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
-        <config.statistics.manager.configfile>30-statistics-manager.xml</config.statistics.manager.configfile>
-        <config.inventory.manager.configfile>40-inventory-manager.xml</config.inventory.manager.configfile>
         <restconf.version>1.4.0-SNAPSHOT</restconf.version>
         <mdsal.model.version>0.9.0-SNAPSHOT</mdsal.model.version>
     </properties>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>forwardingrules-manager-config</artifactId>
-            <classifier>config</classifier>
-            <type>xml</type>
+            <artifactId>forwardingrules-sync</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>inventory-manager</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>inventory-manager</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>lldp-speaker</artifactId>
             <artifactId>statistics-manager</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>statistics-manager-config</artifactId>
-            <classifier>config</classifier>
-            <type>xml</type>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-blueprint-config</artifactId>
+            <version>${project.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>table-miss-enforcer</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>table-miss-enforcer</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>topology-lldp-discovery</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>topology-lldp-discovery</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
+
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>topology-manager</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>topology-manager</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>of-switch-config-pusher</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>of-switch-config-pusher</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
-
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin.applications</groupId>
-            <artifactId>lldp-speaker</artifactId>
-            <type>xml</type>
-            <classifier>config</classifier>
-        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>drop-test-karaf</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin</groupId>
-            <artifactId>drop-test-karaf</artifactId>
-            <classifier>config</classifier>
-            <type>xml</type>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>test-common</artifactId>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowplugin-controller-config</artifactId>
             <type>xml</type>
-            <classifier>config-He</classifier>
+            <classifier>config-Li</classifier>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <type>xml</type>
             <classifier>config</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin.applications</groupId>
+            <artifactId>notification-supplier</artifactId>
+            <type>xml</type>
+            <classifier>config</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin.applications</groupId>
+            <artifactId>notification-supplier</artifactId>
+        </dependency>
     </dependencies>
 
-    <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</url>
-    </scm>
 </project>
index 36e80a25b53b7d085655c8c229f7763d3fd82dd8..02dc31fa816a0e7830a23dd691a4dcfcc29423ec 100644 (file)
@@ -9,8 +9,8 @@
   -->
 
 <features name="openflowplugin-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
-   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-   xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
     <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.openflowjava/features-openflowjava/${openflowjava.version}/xml/features</repository>
@@ -18,6 +18,7 @@
     <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features</repository>
 
+
     <feature name='odl-openflowplugin-all' description="OpenDaylight :: Openflow Plugin :: All" version='${project.version}'>
         <feature version="${project.version}">odl-openflowplugin-southbound</feature>
         <feature version="${project.version}">odl-openflowplugin-flow-services</feature>
         <feature version="${project.version}">odl-openflowplugin-flow-services-ui</feature>
     </feature>
 
-    <feature name='odl-openflowplugin-southbound' description="OpenDaylight :: Openflow Plugin :: SouthBound" version='${project.version}'>
+    <feature name='odl-openflowplugin-southbound' description="OpenDaylight :: Openflow Plugin :: Li southBound API implementation " version='${project.version}'>
         <feature version="${mdsal.version}">odl-mdsal-broker</feature>
-        <feature version="${project.version}">odl-openflowplugin-nsf-model</feature>
+        <feature version="${project.version}">odl-openflowplugin-nsf-services</feature>
         <feature version="${openflowjava.version}">odl-openflowjava-protocol</feature>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-common/{{VERSION}}</bundle>
-        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-api/{{VERSION}}</bundle>
+        <!-- TODO : remove dependency on openflowplugin in the future -->
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-impl/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-extension-api/{{VERSION}}</bundle>
-       <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
-        <bundle>mvn:org.opendaylight.openflowplugin.applications/inventory-manager/{{VERSION}}</bundle>
-        <bundle>mvn:org.opendaylight.openflowplugin.applications/statistics-manager/{{VERSION}}</bundle>
-        <configfile finalname="${config.configfile.directory}/${config.statistics.manager.configfile}">mvn:org.opendaylight.openflowplugin.applications/statistics-manager-config/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="${config.configfile.directory}/${config.inventory.manager.configfile}">mvn:org.opendaylight.openflowplugin.applications/inventory-manager/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/42-openflowplugin-He.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/config-He</configfile>
-        <configfile finalname="etc/opendaylight/karaf/43-msg-spy.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/configmsgspy</configfile>
+        <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-blueprint-config/{{VERSION}}</bundle>
+        <configfile finalname="etc/opendaylight/karaf/42-openflowplugin-Li.xml">mvn:org.opendaylight.openflowplugin/openflowplugin-controller-config/{{VERSION}}/xml/config-Li</configfile>
     </feature>
 
     <feature name='odl-openflowplugin-flow-services' description="OpenDaylight :: Openflow Plugin :: Flow Services" version='${project.version}'>
         <feature version="${project.version}">odl-openflowplugin-app-config-pusher</feature>
         <feature version="${project.version}">odl-openflowplugin-app-lldp-speaker</feature>
         <feature version="${project.version}">odl-openflowplugin-nsf-services</feature>
+
     </feature>
 
     <feature name='odl-openflowplugin-nsf-services' version='${project.version}'
-        description="OpenDaylight :: OpenflowPlugin :: NSF :: Services">
+             description="OpenDaylight :: OpenflowPlugin :: NSF :: Services">
         <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
         <feature version='${project.version}'>odl-openflowplugin-nsf-model</feature>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-common/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/topology-manager/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/forwardingrules-manager/{{VERSION}}</bundle>
-       <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/30-forwardingrules-manager.xml">mvn:org.opendaylight.openflowplugin.applications/forwardingrules-manager-config/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/72-topology-lldp-discovery.xml">mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/73-topology-manager.xml">mvn:org.opendaylight.openflowplugin.applications/topology-manager/{{VERSION}}/xml/config</configfile>
+        <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
     </feature>
 
     <feature name='odl-openflowplugin-nsf-model' version='${project.version}'
-        description="OpenDaylight :: OpenflowPlugin :: NSF :: Model">
+             description="OpenDaylight :: OpenflowPlugin :: NSF :: Model">
         <!-- general models -->
         <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
        <bundle>mvn:org.opendaylight.controller.model/model-inventory/{{VERSION}}</bundle>
         <feature version="${project.version}">odl-openflowplugin-flow-services</feature>
         <bundle>mvn:org.opendaylight.openflowplugin/test-common/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/drop-test-karaf/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/69-drop-test.xml">mvn:org.opendaylight.openflowplugin/drop-test-karaf/{{VERSION}}/xml/config</configfile>
     </feature>
 
     <!-- APPLICATIONS -->
     <feature name='odl-openflowplugin-app-table-miss-enforcer' description="OpenDaylight :: Openflow Plugin :: Application - table-miss-enforcer" version='${project.version}'>
         <feature version="${project.version}">odl-openflowplugin-southbound</feature>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/table-miss-enforcer/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/69-table-miss-enforcer.xml">mvn:org.opendaylight.openflowplugin.applications/table-miss-enforcer/{{VERSION}}/xml/config</configfile>
     </feature>
     <feature name='odl-openflowplugin-app-config-pusher' description="OpenDaylight :: Openflow Plugin :: app - default config-pusher" version='${project.version}'>
         <feature version="${project.version}">odl-openflowplugin-southbound</feature>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/of-switch-config-pusher/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/70-of-switch-config-pusher.xml">mvn:org.opendaylight.openflowplugin.applications/of-switch-config-pusher/{{VERSION}}/xml/config</configfile>
     </feature>
 
     <feature name='odl-openflowplugin-app-lldp-speaker' description="OpenDaylight :: Openflow Plugin :: app lldp-speaker" version='${project.version}'>
         <feature version="${project.version}">odl-openflowplugin-southbound</feature>
-        <bundle>mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin.applications/lldp-speaker/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/71-lldp-speaker.xml">mvn:org.opendaylight.openflowplugin.applications/lldp-speaker/{{VERSION}}/xml/config</configfile>
-        <configfile finalname="etc/opendaylight/karaf/72-topology-lldp-discovery.xml">mvn:org.opendaylight.openflowplugin.applications/topology-lldp-discovery/{{VERSION}}/xml/config</configfile>
     </feature>
 
     <feature name='odl-openflowplugin-app-bulk-o-matic' description="OpenDaylight :: Openflow Plugin :: app bulk flow operations support" version='${project.version}'>
         <feature version="${project.version}">odl-openflowplugin-southbound</feature>
-        <bundle>mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/{{VERSION}}</bundle>
-        <configfile finalname="etc/opendaylight/karaf/71-bulk-o-matic.xml">mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/{{VERSION}}/xml/config</configfile>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/${project.version}</bundle>
+        <configfile finalname="etc/opendaylight/karaf/71-bulk-o-matic.xml">mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/${project.version}/xml/config</configfile>
+    </feature>
+
+    <feature name='odl-openflowplugin-notifications' description="OpenDaylight :: Openflow Plugin :: app notifications supplier" version='${project.version}'>
+        <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
+        <feature version="${project.version}">odl-openflowplugin-nsf-model</feature>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/notification-supplier/{{VERSION}}</bundle>
+        <configfile finalname="etc/opendaylight/karaf/73-notification-supplier.xml">mvn:org.opendaylight.openflowplugin.applications/notification-supplier/{{VERSION}}/xml/config</configfile>
     </feature>
 
 </features>
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java
new file mode 100644 (file)
index 0000000..788f0c5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow;
+
+/**
+ * General API for all OFP Context
+ */
+public interface OFPContext {
+
+    /**
+     * distinguished device context states
+     */
+    enum CONTEXT_STATE {
+        /**
+         * initial phase
+         */
+        INITIALIZATION,
+        /**
+         * standard phase
+         */
+        WORKING,
+        /**
+         * termination phase
+         */
+        TERMINATION
+    }
+
+    CONTEXT_STATE getState();
+
+}
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPManager.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPManager.java
new file mode 100644 (file)
index 0000000..1879a4c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+
+/**
+ * Generic API for all managers
+ */
+public interface OFPManager {
+
+    <T extends OFPContext> T gainContext(final DeviceInfo deviceInfo);
+
+}
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java
new file mode 100644 (file)
index 0000000..d5caf2d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow;
+
+import java.util.List;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
+
+/**
+ * Factory for creating OpenFlowPluginProvider instances.
+ *
+ * @author Thomas Pantelis
+ */
+public interface OpenFlowPluginProviderFactory {
+    OpenFlowPluginProvider newInstance(OpenflowProviderConfig providerConfig, DataBroker dataBroker,
+            RpcProviderRegistry rpcRegistry, NotificationService notificationService,
+            NotificationPublishService notificationPublishService,
+            EntityOwnershipService entityOwnershipService,
+            List<SwitchConnectionProvider> switchConnectionProviders);
+}
index 839541d4e3193300d3884edc3ea28dffc290a94c..88e1c9174f379e9f9b63dbb74cd2650afcc4a073 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.api.openflow.connection;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
@@ -20,7 +21,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * Each OpenFlow session is tracked by a Connection Context. These attach to a particular Device Context in such a way,
  * that there is at most one primary session associated with a Device Context.
  * </p>
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
 public interface ConnectionContext {
 
@@ -136,4 +136,15 @@ public interface ConnectionContext {
      * change internal state to {@link ConnectionContext.CONNECTION_STATE#WORKING}
      */
     void changeStateToWorking();
+
+    /**
+     * Create and return basic device info
+     * @return
+     */
+    DeviceInfo getDeviceInfo();
+
+    /**
+     * This method creates a basic device information. Should be called after nodeId and features are set in connection context
+     */
+    void handshakeSuccessful();
 }
index b2c70f70535cd40d58c6e22fb07a6199f927c3af..c5baf45cf6dade2d5cfdbc072af403f4efb421ee 100644 (file)
@@ -12,21 +12,14 @@ import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.Timeout;
 import java.math.BigInteger;
 import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
-import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
-import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
-import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * <p>
@@ -43,40 +36,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpR
  * Context can have at any point in time. Should this quota be exceeded, any further attempt to make
  * a request to the switch will fail immediately, with proper error indication.
  * </p>
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
 public interface DeviceContext extends AutoCloseable,
         DeviceReplyProcessor,
-        PortNumberCache,
         TxFacade,
-        XidSequencer {
-
-    void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
-
-    /**
-     * distinguished device context states
-     */
-    enum DEVICE_CONTEXT_STATE {
-        /**
-         * initial phase of talking to switch
-         */
-        INITIALIZATION,
-        /**
-         * standard phase - interacting with switch
-         */
-        WORKING,
-        /**
-         * termination phase of talking to switch
-         */
-        TERMINATION
-    }
-
-    /**
-     * Method returns current device context state.
-     *
-     * @return {@link DeviceContext.DEVICE_CONTEXT_STATE}
-     */
-    DEVICE_CONTEXT_STATE getDeviceContextState();
+        XidSequencer,
+        OFPContext,
+        DeviceRegistry{
 
     /**
      * Method close all auxiliary connections and primary connection.
@@ -104,34 +70,7 @@ public interface DeviceContext extends AutoCloseable,
      */
     DeviceState getDeviceState();
 
-    /**
-     * Method has to activate (MASTER) or deactivate (SLAVE) TransactionChainManager.
-     * TransactionChainManager represents possibility to write or delete Node subtree data
-     * for actual Controller Cluster Node. We are able to have an active TxManager only if
-     * newRole is {@link OfpRole#BECOMESLAVE}.
-     * Parameters are used as marker to be sure it is change to SLAVE from MASTER or from
-     * MASTER to SLAVE and the last parameter "cleanDataStore" is used for validation only.
-     * @param oldRole - old role for quick validation for needed processing
-     * @param role - NewRole expect to be {@link OfpRole#BECOMESLAVE} or {@link OfpRole#BECOMEMASTER}
-     * @return RoleChangeTxChainManager future for activation/deactivation
-     * @deprecated replaced by method onDeviceTakeClusterLeadership and onDevicLostClusterLeadership
-     */
-    @Deprecated
-    ListenableFuture<Void> onClusterRoleChange(@Nullable OfpRole oldRole, @CheckForNull OfpRole role);
-
-    /**
-     * Method has to activate TransactionChainManager and prepare all Contexts from Device Contects suite
-     * to Taking ClusterLeadership role {@link OfpRole#BECOMEMASTER} (e.g. Routed RPC registration, StatPolling ...)
-     * @return DeviceInitialization furure
-     */
-    ListenableFuture<Void> onDeviceTakeClusterLeadership();
-
-    /**
-     * Method has to deactivate TransactionChainManager and prepare all Contexts from Device Contects suite
-     * to Lost ClusterLeadership role {@link OfpRole#BECOMESLAVE} (e.g. Stop RPC rounting, stop StatPolling ...)
-     * @return RoleChangeTxChainManager future for deactivation
-     */
-    ListenableFuture<Void> onDeviceLostClusterLeadership();
+    DeviceInfo getDeviceInfo();
 
     /**
      * Method has to close TxManager ASAP we are notified about Closed Connection
@@ -153,27 +92,6 @@ public interface DeviceContext extends AutoCloseable,
      */
     ConnectionContext getAuxiliaryConnectiobContexts(BigInteger cookie);
 
-    /**
-     * Method exposes flow registry used for storing flow ids identified by calculated flow hash.
-     *
-     * @return
-     */
-    DeviceFlowRegistry getDeviceFlowRegistry();
-
-    /**
-     * Method exposes device group registry used for storing group ids.
-     *
-     * @return
-     */
-    DeviceGroupRegistry getDeviceGroupRegistry();
-
-    /**
-     * Method exposes device meter registry used for storing meter ids.
-     *
-     * @return
-     */
-    DeviceMeterRegistry getDeviceMeterRegistry();
-
 
     /**
      * @return translator library
@@ -213,14 +131,6 @@ public interface DeviceContext extends AutoCloseable,
      */
     ItemLifeCycleRegistry getItemLifeCycleSourceRegistry();
 
-    void setRpcContext(RpcContext rpcContext);
-
-    RpcContext getRpcContext();
-
-    void setStatisticsContext(StatisticsContext statisticsContext);
-
-    StatisticsContext getStatisticsContext();
-
     @Override
     void close();
 }
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java
new file mode 100644 (file)
index 0000000..75b0f13
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.api.openflow.device;
+
+import java.math.BigInteger;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+
+/**
+ * API defining basic device information
+ */
+public interface DeviceInfo {
+
+    /**
+     * @return id of encapsulated node
+     */
+    NodeId getNodeId();
+
+    /**
+     * @return {@link Node} instance identifier
+     */
+    KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier();
+
+    /**
+     * @return version
+     */
+    Short getVersion();
+
+    /**
+     * @return datapathId
+     */
+    BigInteger getDatapathId();
+
+}
index 3af5e496428bf83d98bb3f948ae68d1eb52dad49..55f68da8b7efe3689563127cd383cae4a10ff3a8 100644 (file)
@@ -8,46 +8,69 @@
 
 package org.opendaylight.openflowplugin.api.openflow.device;
 
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * This interface is responsible for instantiating DeviceContext and
  * registering transaction chain for each DeviceContext. Each device
  * has its own device context managed by this manager.
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
 public interface DeviceManager extends DeviceConnectedHandler, DeviceDisconnectedHandler, DeviceLifecycleSupervisor,
-        DeviceInitializationPhaseHandler, DeviceTerminationPhaseHandler, TranslatorLibrarian, AutoCloseable {
+        DeviceInitializationPhaseHandler, DeviceTerminationPhaseHandler, TranslatorLibrarian, AutoCloseable, OFPManager {
+
 
     /**
-     * Sets notification publish service
+     * invoked after all services injected
+     */
+    void initialize();
+
+    /**
+     * Method has to activate (MASTER) or deactivate (SLAVE) TransactionChainManager.
+     * TransactionChainManager represents possibility to write or delete Node subtree data
+     * for actual Controller Cluster Node. We are able to have an active TxManager only if
+     * newRole is {@link OfpRole#BECOMESLAVE}.
+     * Parameters are used as marker to be sure it is change to SLAVE from MASTER or from
+     * MASTER to SLAVE and the last parameter "cleanDataStore" is used for validation only.
      *
-     * @param notificationPublishService
+     * @param deviceInfo which device
+     * @param role - NewRole expect to be {@link OfpRole#BECOMESLAVE} or {@link OfpRole#BECOMEMASTER}
+     * @return RoleChangeTxChainManager future for activation/deactivation
      */
-    void setNotificationPublishService(NotificationPublishService notificationPublishService);
+    ListenableFuture<Void> onClusterRoleChange(final DeviceInfo deviceInfo, final OfpRole role);
 
     /**
-     * invoked after all services injected
+     * Register device synchronize listeners
+     * @param deviceSynchronizeListener are notified if device is synchronized or not
      */
-    void initialize();
+    void addDeviceSynchronizeListener(final DeviceSynchronizeListener deviceSynchronizeListener);
+
+    /**
+     * Notify all registered listeners about synchronized status
+     * @param deviceInfo which device
+     * @param deviceSynchronized true if device is synchronized
+     */
+    void notifyDeviceSynchronizeListeners(final DeviceInfo deviceInfo, final boolean deviceSynchronized);
+
+    /**
+     * Register device valid listeners
+     * @param deviceValidListener are notified if device is valid or not
+     */
+    void addDeviceValidListener(final DeviceValidListener deviceValidListener);
 
     /**
-     * Returning device context from map maintained in device manager
-     * This prevent to send whole device context to another context
-     * If device context not exists for nodeId it will return null
-     * @param nodeId
-     * @return device context or null
+     * Notify all registered listeners about valid status
+     * @param deviceInfo which device
+     * @param deviceValid true if device is valid
      */
-    DeviceContext getDeviceContextFromNodeId(NodeId nodeId);
+    void notifyDeviceValidListeners(final DeviceInfo deviceInfo, final boolean deviceValid);
 
-    void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
 }
 
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceRegistry.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceRegistry.java
new file mode 100644 (file)
index 0000000..9d50835
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow.device;
+
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
+import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
+import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
+
+/**
+ * Flows, Groups and Meter registry
+ */
+public interface DeviceRegistry {
+
+    /**
+     * Method exposes flow registry used for storing flow ids identified by calculated flow hash.
+     *
+     * @return
+     */
+    DeviceFlowRegistry getDeviceFlowRegistry();
+
+    /**
+     * Method exposes device group registry used for storing group ids.
+     *
+     * @return
+     */
+    DeviceGroupRegistry getDeviceGroupRegistry();
+
+    /**
+     * Method exposes device meter registry used for storing meter ids.
+     *
+     * @return
+     */
+    DeviceMeterRegistry getDeviceMeterRegistry();
+
+}
index 1cbc3c28039dbaaba0b9cb5ca884e4a12b81f494..0ca7e2df60eb99d58c089dde12e859b1ff83e81d 100644 (file)
@@ -8,50 +8,16 @@
 
 package org.opendaylight.openflowplugin.api.openflow.device;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
 /**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
+ * Holder of device's structure
  */
-public interface DeviceState {
-
-    /**
-     * @return id of encapsulated node
-     */
-    NodeId getNodeId();
-
-    /**
-     * @return {@link Node} instance identifier
-     */
-    KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier();
-
-    /**
-     * @return the features of corresponding switch
-     */
-    GetFeaturesOutput getFeatures();
+public interface DeviceState extends DeviceSynchronizeListener, DeviceValidListener {
 
     /**
      * @return true if this session is valid
      */
     boolean isValid();
 
-    /**
-     * @param valid the valid to set
-     */
-    void setValid(boolean valid);
-
-    /**
-     * Return node current OF protocol version
-     *
-     * @return
-     */
-    short getVersion();
-
     /**
      * Return true if we have relevant meter information
      * from device
@@ -121,8 +87,6 @@ public interface DeviceState {
 
     void setQueueStatisticsAvailable(boolean available);
 
-    void setDeviceSynchronized(boolean deviceSynchronized);
-
     boolean isStatisticsPollingEnabled();
 
     void setStatisticsPollingEnabledProp(boolean statPollEnabled);
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceSynchronizeListener.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceSynchronizeListener.java
new file mode 100644 (file)
index 0000000..6c49c52
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow.device;
+
+/**
+ * API for device synchronized listeners
+ */
+public interface DeviceSynchronizeListener {
+
+    void deviceIsSynchronized(final DeviceInfo deviceInfo, final boolean isSynchronized);
+
+}
@@ -5,12 +5,13 @@
  * 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.openflowplugin.applications.bulk.o.matic;
+package org.opendaylight.openflowplugin.api.openflow.device;
 
 /**
- * Created by mirehak on 6/8/15.
+ * API for device synchronized listeners
  */
-public interface BulkOMaticProvider extends AutoCloseable {
-    // NOBODY
+public interface DeviceValidListener {
+
+    void deviceIsValid(final DeviceInfo deviceInfo, final boolean isValid);
+
 }
index 4738218827153ce24a9390523a25dc4cee0a0d1d..2dea3a85ee8a2891f67adc9318757475ebf5dcce 100644 (file)
@@ -18,10 +18,10 @@ public interface MessageTranslator<I, O> {
     /**
      * Translates from input to output
      * @param input
-     * @param deviceState
+     * @param deviceInfo
      * @param connectionDistinguisher
      * @return message of output type
      */
-    O translate(I input, DeviceState deviceState, Object connectionDistinguisher);
+    O translate(I input, DeviceInfo deviceInfo, Object connectionDistinguisher);
 
 }
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/PortNumberCache.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/PortNumberCache.java
deleted file mode 100644 (file)
index 83655b4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.api.openflow.device;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
-
-/**
- * keeps mapping between port number (protocol based) and {@link NodeConnectorRef}
- */
-public interface PortNumberCache {
-
-    /**
-     * @param portNumber
-     * @return corresponding nodeConnectorRef if present
-     */
-    @Nullable
-    @Deprecated
-    NodeConnectorRef lookupNodeConnectorRef(Long portNumber);
-
-    /**
-     * @param portNumber       protocol port number
-     * @param nodeConnectorRef corresponding value of {@link NodeConnectorRef}
-     */
-    @Deprecated
-    void storeNodeConnectorRef(@Nonnull Long portNumber, @Nonnull NodeConnectorRef nodeConnectorRef);
-}
index 3e7bf34298fe063ec52d6219074001c24486470c..41884c9d490143c2693f74e715ea2676e8a40479 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.api.openflow.device.handlers;
 
 import javax.annotation.CheckForNull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * openflowplugin-api
@@ -26,8 +26,8 @@ public interface DeviceInitializationPhaseHandler {
     /**
      * Method represents an initialization cycle for {@link DeviceContext} preparation for use.
      *
-     * @param nodeId
+     * @param deviceInfo
      * @throws Exception - needs to be catch in ConnectionHandler implementation
      */
-    void onDeviceContextLevelUp(@CheckForNull NodeId nodeId) throws Exception;
+    void onDeviceContextLevelUp(@CheckForNull DeviceInfo deviceInfo) throws Exception;
 }
index 2ef28f0ce276a9dc17e825d3df3a969ab822940b..e1c140e92bb82afe1de48c90aea43c8ea5d4fca9 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.api.openflow.device.handlers;
 
 import javax.annotation.CheckForNull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * Interface represent handler for dead device connection annihilating cycle.
@@ -21,7 +22,7 @@ public interface DeviceTerminationPhaseHandler {
     /**
      * Method represents a termination cycle for {@link DeviceContext}.
      *
-     * @param deviceContext - {@link DeviceContext}
+     * @param deviceInfo - {@link DeviceInfo}
      */
-    void onDeviceContextLevelDown(@CheckForNull DeviceContext deviceContext);
+    void onDeviceContextLevelDown(@CheckForNull DeviceInfo deviceInfo);
 }
index a3ca90d6bd1828976e9c28b9ff1cb501de5c4097..33d63b78617a330ad83ba6030325e45ade03a3da 100644 (file)
@@ -8,8 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * This API is for all listeners who wish to know about device context in cluster
@@ -18,16 +17,16 @@ public interface DeviceContextChangeListener {
 
     /**
      * Notification about start phase in device context, right after successful handshake
-     * @param nodeId
+     * @param deviceInfo
      * @param success or failure
      */
-    void deviceStartInitializationDone(final NodeId nodeId, final boolean success);
+    void deviceStartInitializationDone(final DeviceInfo deviceInfo, final boolean success);
 
     /**
      * Notification about start phase in device context, after all other contexts initialized properly
-     * @param nodeId
+     * @param deviceInfo
      * @param success
      */
-    void deviceInitializationDone(final NodeId nodeId, final boolean success);
+    void deviceInitializationDone(final DeviceInfo deviceInfo, final boolean success);
 
 }
index 879bd63acd20635160c810159ac55ed850263225..fcddb2cd4bfff4d83388de0cd527e795463f1700 100644 (file)
@@ -10,14 +10,15 @@ package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
 import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
+import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-
-import javax.annotation.Nonnull;
-import java.util.concurrent.TimeUnit;
 
 /**
  * This class is a binder between all managers
@@ -27,24 +28,31 @@ public interface LifecycleConductor {
 
     /**
      * Returns device context from device manager device contexts maps
-     * @param nodeId node identification
-     * @return null if context doesn't exists
+     *
+     * @param deviceInfo@return null if context doesn't exists
+     */
+    DeviceContext getDeviceContext(DeviceInfo deviceInfo);
+
+
+    /**
+     * Setter for device manager once set it cant be unset or overwritten
+     * @param manager
      */
-    DeviceContext getDeviceContext(final NodeId nodeId);
+    void setSafelyManager(OFPManager manager);
 
     /**
      * Registers ont time listener for notify when services rpc, statistics are done stop or start
      * @param manager service change listener
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      */
-    void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final NodeId nodeId);
+    void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final DeviceInfo deviceInfo);
 
     /**
-     * Returns device of version
-     * @param nodeId node identification
-     * @return null if device context doesn't exists
+     * Returns statistics context from statistics managers contexts maps
+     *
+     * @param deviceInfo@return null if context doesn't exists
      */
-    Short gainVersionSafely(final NodeId nodeId);
+    StatisticsContext getStatisticsContext(DeviceInfo deviceInfo);
 
     /**
      * Set new timeout for {@link io.netty.util.HashedWheelTimer}
@@ -63,26 +71,20 @@ public interface LifecycleConductor {
 
     /**
      * Interrupt connection for the node
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      */
-    void closeConnection(final NodeId nodeId);
+    void closeConnection(final DeviceInfo deviceInfo);
 
-    /**
-     * Setter for device manager once set it cant be unset or overwritten
-     * @param deviceManager should be set in OpenFlowPluginProviderImpl
-     */
-    void setSafelyDeviceManager(final DeviceManager deviceManager);
-
-    /**
-     * Setter for statistics manager once set it cant be unset or overwritten
-     * @param statisticsManager should be set in OpenFlowPluginProviderImpl
-     */
-    void setSafelyStatisticsManager(final StatisticsManager statisticsManager);
+    ConnectionContext.CONNECTION_STATE gainConnectionStateSafely(DeviceInfo deviceInfo);
 
     /**
      * Xid from outboundqueue
-     * @param nodeId
+     * @param deviceInfo
      * @return
      */
-    Long reserveXidForDeviceMessage(final NodeId nodeId);
+    Long reserveXidForDeviceMessage(final DeviceInfo deviceInfo);
+
+    NotificationPublishService getNotificationPublishService();
+
+    void setNotificationPublishService(NotificationPublishService notificationPublishService);
 }
index f830966234d3889cff9bef183ebc3e0d54249d88..77ad9fa3e62dc43d626fbbad986eb786808e2262 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
@@ -18,18 +18,18 @@ public interface RoleChangeListener {
 
     /**
      * Notification when initialization for role context is done
-     * @param nodeId
+     * @param deviceInfo
      * @param success or failure
      */
-    void roleInitializationDone(final NodeId nodeId, final boolean success);
+    void roleInitializationDone(final DeviceInfo deviceInfo, final boolean success);
 
     /**
      * Notification when the role change on device is done
-     * @param nodeId
+     * @param deviceInfo
      * @param success
      * @param newRole
      * @param initializationPhase
      */
-    void roleChangeOnDevice(final NodeId nodeId, final boolean success, final OfpRole newRole, final boolean initializationPhase);
+    void roleChangeOnDevice(final DeviceInfo deviceInfo, final boolean success, final OfpRole newRole, final boolean initializationPhase);
 
 }
index 5afe5bba906f3711621ea42a8136bc50df8129d2..ae94d4be7cd5d9fe2b17ff051ba2914090b46543 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * This API is defined for listening when services (Statistics and RPCs) are fully stopped
@@ -18,9 +18,9 @@ public interface ServiceChangeListener {
 
     /**
      * Notification when services (rpc, statistics) are started or stopped working
-     * @param nodeId
+     * @param deviceInfo
      * @param success
      */
-    void servicesChangeDone(NodeId nodeId, boolean success);
+    void servicesChangeDone(DeviceInfo deviceInfo, boolean success);
 
 }
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/AbstractModelDrivenSwitchRegistration.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/AbstractModelDrivenSwitchRegistration.java
new file mode 100644 (file)
index 0000000..e710c60
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * 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.openflowplugin.api.openflow.md;
+
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+
+public abstract class AbstractModelDrivenSwitchRegistration extends AbstractObjectRegistration<ModelDrivenSwitch>
+    implements ModelDrivenSwitchRegistration {
+
+    protected AbstractModelDrivenSwitchRegistration(final ModelDrivenSwitch instance) {
+        super(instance);
+    }
+
+}
index 0120d9004f226ab95a92fd5e6f9f450980d4fdfc..90270c6326ffa39317e73571a727e1fb255c3fba 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.openflowplugin.api.openflow.md;
 
 import com.google.common.base.Optional;
+import java.math.BigInteger;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
@@ -25,12 +26,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalP
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.math.BigInteger;
-
 /**
  * interface concatenating all md-sal services provided by OF-switch
  */
@@ -47,7 +45,7 @@ public interface ModelDrivenSwitch
      * @param rpcProviderRegistry
      * @return wrapped list of {service provider + path} registration couples
      */
-    CompositeObjectRegistration<ModelDrivenSwitch> register(RpcProviderRegistry rpcProviderRegistry);
+    ModelDrivenSwitchRegistration register(RpcProviderRegistry rpcProviderRegistry);
 
     /**
      * @return id of encapsulated node (served by this impl)
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitchRegistration.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitchRegistration.java
new file mode 100644 (file)
index 0000000..9da85b3
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * 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.openflowplugin.api.openflow.md;
+
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+
+public interface ModelDrivenSwitchRegistration extends ObjectRegistration<ModelDrivenSwitch> {
+    @Override
+    void close();
+}
index a4a0abeda5f5a67d1cf16da4e5a60fb2bd1f120e..e1ea51f563f2db37dec124dfd9ef0bd2c50fed86 100644 (file)
@@ -8,17 +8,15 @@
 
 package org.opendaylight.openflowplugin.api.openflow.md.core;
 
+import com.google.common.collect.Lists;
 import java.util.List;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.api.openflow.md.queue.QueueProcessor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
-import com.google.common.collect.Lists;
-
 
 /**
  * @author mirehak
index 3ba708e08714f995dde6cba48c2a380d971602b5..81d740fea96c6320730b575e73a45ec83c60489d 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.md.core;
 
+import com.google.common.base.Preconditions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
-import com.google.common.base.Preconditions;
-
 /**
  * 
  */
index 4d8e2bf2593f3f8584bab610e769faceaf4445c6..5272498d74daaa53943bb4fa2bb1cc48c80f8fbd 100644 (file)
@@ -9,8 +9,9 @@
 package org.opendaylight.openflowplugin.api.openflow.md.core.session;
 
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
@@ -35,8 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 /**
index 221055b4aa847cc592901b25dda28d2b24f3efba..9de1dd7ad4dab0f7594603b54ed8b5ac5039871b 100644 (file)
@@ -12,7 +12,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
@@ -20,7 +20,6 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDist
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 
 /**
  * @author mirehak
@@ -160,12 +159,12 @@ public interface SessionContext {
     /**
      * @param registration provider composite registration
      */
-    void setProviderRegistration(CompositeObjectRegistration<ModelDrivenSwitch> registration);
+    void setProviderRegistration(ModelDrivenSwitchRegistration registration);
 
     /**
      * @return provider composite registration
      */
-    CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration();
+    ModelDrivenSwitchRegistration getProviderRegistration();
 
     /**
      * @return seed value for random operations
index 863031a582417fff0ec472c55e29ecd8da892c1a..c7685e56ea2ca0fb0b7660dfe025e24989dcbcbd 100644 (file)
@@ -18,9 +18,9 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
-import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.api.openflow.md.queue.PopListener;
+import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
index 441bb9b0a22a0164bd5be130ee6f944abcac4026..e1f0e38c4add2e56063e3ecf143a82aa6da21d47 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.api.openflow.md.queue;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 
index 4de64b31f3d1383c04f3e0a4f45d69618225376d..7ba8317607234afd97a10d7b535708e6af437135 100644 (file)
@@ -7,13 +7,12 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.md.util;
 
+import com.google.common.collect.Iterators;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Queue;
 
-import com.google.common.collect.Iterators;
-
 /**
  * Zipper groups together a list of queues and exposes one poll method. Polling iterates through
  * all groups and returns first not-null result of poll method on each queue. If after polling each 
index 5b9bbfdb331ead46ea1caa1e2bbb6ea18906ba07..ea3d2435993e031b1842666b9e17f73e888ab82b 100644 (file)
@@ -7,17 +7,17 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.role;
 
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
 
-import javax.annotation.Nonnull;
-
 /**
- * Rewrote whole role context to prevent errors to change role on cluster
+ * Role context for change role on cluster
  */
-public interface RoleContext extends  RequestContextStack, AutoCloseable {
+public interface RoleContext extends  RequestContextStack, AutoCloseable, OFPContext {
 
     /**
      * Initialization method is responsible for a registration of
@@ -68,7 +68,7 @@ public interface RoleContext extends  RequestContextStack, AutoCloseable {
      * Actual nodeId
      * @return
      */
-    NodeId getNodeId();
+    DeviceInfo getDeviceInfo();
 
     /**
      * Returns true if main entity is registered
index 5a1bb0dbacc884d02ec9487f88a966cadb05f4aa..bc851df3b64418560240a4003d06ccb90a541377 100644 (file)
@@ -7,18 +7,17 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.role;
 
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.RoleChangeListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * Created by kramesha on 8/31/15.
  */
 public interface RoleManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler, AutoCloseable,
-        DeviceTerminationPhaseHandler {
+        DeviceTerminationPhaseHandler, OFPManager {
     String ENTITY_TYPE = "openflow";
     String TX_ENTITY_TYPE = "ofTransaction";
 
index 4be56a094e788718ca86d5801819a6a9210ef5b2..36965c38eeb119b96beb5398e582c7bfec62bcc9 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.rpc;
 
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
@@ -15,9 +16,8 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
  * tracks the state of any user requests and how they map onto protocol requests. It uses
  * {@link org.opendaylight.openflowplugin.api.openflow.device.RequestContext} to perform requests.
  * <p>
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
-public interface RpcContext extends RequestContextStack, AutoCloseable {
+public interface RpcContext extends RequestContextStack, AutoCloseable, OFPContext {
     <S extends RpcService> void registerRpcServiceImplementation(Class<S> serviceClass, S serviceInstance);
 
     <S extends RpcService> S lookupRpcService(Class<S> serviceClass);
@@ -25,4 +25,8 @@ public interface RpcContext extends RequestContextStack, AutoCloseable {
 
     @Override
     void close();
+
+    void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
+
+    boolean isStatisticsRpcEnabled();
 }
index f5c8e2894e91eb9d5910b64d9da9f00d1b53b479..0339f8435edc07a7bcb7110c1c9a32690c6a9128 100644 (file)
@@ -8,19 +8,19 @@
 
 package org.opendaylight.openflowplugin.api.openflow.rpc;
 
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 
 /**
  * The RPC Manager will maintain an RPC Context for each online switch. RPC context for device is created when
- * {@link org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler#onDeviceContextLevelUp(NodeId)}
+ * {@link org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler#onDeviceContextLevelUp(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)}
  * is called.
  * <p>
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
-public interface RpcManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler, AutoCloseable, DeviceTerminationPhaseHandler {
+public interface RpcManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler, AutoCloseable, DeviceTerminationPhaseHandler, OFPManager {
 
+    void setStatisticsRpcEnabled(boolean statisticsRpcEnabled);
 }
index 9bc2cda8293d1d403459345922d1de590057ec22..22e975231a5edc7a410878546c6602819c3c4ac7 100644 (file)
@@ -8,20 +8,30 @@
 
 package org.opendaylight.openflowplugin.api.openflow.statistics;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.Timeout;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import java.util.Optional;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 
 /**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 27.2.2015.
+ * Context for statistics
  */
-public interface StatisticsContext extends RequestContextStack, AutoCloseable {
+public interface StatisticsContext extends RequestContextStack, AutoCloseable, OFPContext {
 
+    /**
+     * Gather data from device
+     * @return true if gathering was successful
+     */
     ListenableFuture<Boolean> gatherDynamicData();
 
+    /**
+     * Initial data gathering
+     * @return true if gathering was successful
+     */
+    ListenableFuture<Boolean> initialGatherDynamicData();
+
     /**
      * Method has to be called from DeviceInitialization Method, otherwise
      * we are not able to poll anything. Statistics Context normally initialize
@@ -47,12 +57,6 @@ public interface StatisticsContext extends RequestContextStack, AutoCloseable {
      */
     ItemLifecycleListener getItemLifeCycleListener();
 
-    /**
-     * Statistics Context has to be able to return own DeviceCtx
-     * @return {@link DeviceContext}
-     */
-    DeviceContext getDeviceContext();
-
     @Override
     void close();
 
index e1588be274db166ca8e3adf085dd9f251afd417e..ee4f67273b6d02a28ce0ad1bc90819db3052a8ed 100644 (file)
@@ -8,19 +8,20 @@
 
 package org.opendaylight.openflowplugin.api.openflow.statistics;
 
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 
 /**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 26.2.2015.
+ * Manager to start or stop scheduling statistics
  */
 public interface StatisticsManager extends DeviceLifecycleSupervisor, DeviceInitializationPhaseHandler,
-        DeviceTerminationPhaseHandler, AutoCloseable {
+        DeviceTerminationPhaseHandler, AutoCloseable, OFPManager {
 
-    void startScheduling(NodeId nodeId);
-    void stopScheduling(NodeId nodeId);
+    void startScheduling(DeviceInfo deviceInfo);
+    void stopScheduling(DeviceInfo deviceInfo);
 
     @Override
     void close();
diff --git a/openflowplugin-api/src/main/yang/openflow-provider-config.yang b/openflowplugin-api/src/main/yang/openflow-provider-config.yang
new file mode 100644 (file)
index 0000000..2d180ac
--- /dev/null
@@ -0,0 +1,86 @@
+module openflow-provider-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflow:provider:config";
+    prefix "openflow-provider-config";
+
+    description
+        "Configuration for an Openflow provider.";
+
+    revision "2016-05-10" {
+        description
+            "Initial revision";
+    }
+
+    typedef non-zero-uint32-type {
+        type uint32 {
+            range "1..max";
+        }
+    }
+
+    typedef non-zero-uint16-type {
+        type uint16 {
+            range "1..max";
+        }
+    }
+
+    container openflow-provider-config {
+        leaf rpc-requests-quota {
+            type uint32;
+            default 20000;
+        }
+
+        leaf switch-features-mandatory {
+            type boolean;
+            default false;
+        }
+
+        leaf global-notification-quota {
+            type uint32;
+            default 64000;
+        }
+
+        leaf is-statistics-polling-off {
+            type boolean;
+            default "false";
+        }
+
+        leaf is-statistics-rpc-enabled {
+            description "Deprecated - exposing backward compatible statistics rpcs providing result in form of async notification";
+            type boolean;
+            default "false";
+        }
+
+        leaf barrier-interval-timeout-limit {
+            type non-zero-uint32-type;
+            default 500;
+        }
+
+        leaf barrier-count-limit {
+            type non-zero-uint16-type;
+            default 25600;
+        }
+
+        leaf echo-reply-timeout {
+            type non-zero-uint32-type;
+            default 2000;
+        }
+
+        leaf thread-pool-min-threads {
+            description "Mininum (starting) number of threads in thread pool";
+            type uint16;
+            default 1;
+        }
+
+        leaf thread-pool-max-threads {
+            description "Maximum number of threads in thread pool";
+            type non-zero-uint16-type;
+            default 32000;
+        }
+
+        leaf thread-pool-timeout {
+            description "After how much time (in seconds) of inactivity will be threads in pool terminated";
+            type uint32;
+            default 60;
+        }
+    }
+}
\ No newline at end of file
index fa640fe401c0a6ec34ddefee2c4f325d758d4049..cb020ef858dac66f0aeb8d732977dfe08eddc133 100644 (file)
@@ -16,5 +16,7 @@ module openflow-provider {
     identity openflow-provider{
         base config:service-type;
         config:java-class "org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 }
\ No newline at end of file
diff --git a/openflowplugin-blueprint-config-he/pom.xml b/openflowplugin-blueprint-config-he/pom.xml
new file mode 100644 (file)
index 0000000..0e1bf7f
--- /dev/null
@@ -0,0 +1,31 @@
+<?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.openflowplugin</groupId>
+      <artifactId>openflowplugin-parent</artifactId>
+      <version>0.3.0-SNAPSHOT</version>
+      <relativePath>../parent</relativePath>
+    </parent>
+
+    <artifactId>openflowplugin-blueprint-config-he</artifactId>
+    <description>Blueprint configuration for the Helium openflowplugin</description>
+    <packaging>bundle</packaging>
+
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+            <instructions>
+              <DynamicImport-Package>*</DynamicImport-Package>
+           </instructions>
+         </configuration>
+       </plugin>
+     </plugins>
+   </build>
+</project>
diff --git a/openflowplugin-blueprint-config-he/src/main/resources/org/opendaylight/blueprint/openflowplugin-helium.xml b/openflowplugin-blueprint-config-he/src/main/resources/org/opendaylight/blueprint/openflowplugin-helium.xml
new file mode 100644 (file)
index 0000000..6ef2961
--- /dev/null
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+  <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+  <!-- Create the StatisticsManager -->
+  <reference id="statsManagerFactory"
+          interface="org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManagerFactory"/>
+
+  <odl:clustered-app-config id="statsManagerAppConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.statistics.manager.config.rev160509.StatisticsManagerAppConfig"/>
+
+  <bean id="statsManager" factory-ref="statsManagerFactory" factory-method="newInstance">
+    <argument ref="statsManagerAppConfig"/>
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="rpcRegistry"/>
+    <argument ref="entityOwnershipService"/>
+  </bean>
+
+  <!-- Create the Inventory manager/provider -->
+  <bean id="inventoryManager" class="org.opendaylight.openflowplugin.applications.inventory.manager.InventoryActivator"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="entityOwnershipService"/>
+  </bean>
+
+  <reference id="switchConnProviderFactory"
+          interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory"/>
+
+  <!-- Create OF switch connection provider on port 6633 -->
+  <odl:clustered-app-config id="defaultSwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-default-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-default-impl</instance-name>
+        <port>6633</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="defaultSwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="defaultSwitchConnConfig"/>
+  </bean>
+
+  <service ref="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-default-impl"/>
+
+  <!-- Create OF switch connection provider on port 6653 -->
+  <odl:clustered-app-config id="legacySwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-legacy-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-legacy-impl</instance-name>
+        <port>6653</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="legacySwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="legacySwitchConnConfig"/>
+  </bean>
+
+  <service ref="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-legacy-impl"/>
+
+  <!-- Create OpenflowPluginProvider instance -->
+
+  <bean id="openflowPluginProvider" class="org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider"
+          init-method="initialization" destroy-method="close" depends-on="statsManager inventoryManager">
+    <property name="dataBroker" ref="dataBroker"/>
+    <property name="rpcRegistry" ref="rpcRegistry"/>
+    <property name="notificationService" ref="notificationService"/>
+    <property name="entityOwnershipService" ref="entityOwnershipService"/>
+    <property name="role" value="NOCHANGE"/>
+    <property name="skipTableFeatures" value="false" />
+    <property name="switchConnectionProviders">
+      <list>
+        <ref component-id="defaultSwitchConnProvider"/>
+        <ref component-id="legacySwitchConnProvider"/>
+      </list>
+    </property>
+  </bean>
+
+  <service ref="openflowPluginProvider" odl:type="openflow-provider-impl">
+    <interfaces>
+      <value>org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider</value>
+      <value>org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider</value>
+    </interfaces>
+  </service>
+
+</blueprint>
\ No newline at end of file
diff --git a/openflowplugin-blueprint-config/pom.xml b/openflowplugin-blueprint-config/pom.xml
new file mode 100644 (file)
index 0000000..61dd36f
--- /dev/null
@@ -0,0 +1,31 @@
+<?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.openflowplugin</groupId>
+      <artifactId>openflowplugin-parent</artifactId>
+      <version>0.3.0-SNAPSHOT</version>
+      <relativePath>../parent</relativePath>
+    </parent>
+
+    <artifactId>openflowplugin-blueprint-config</artifactId>
+    <description>Blueprint configuration for the openflowplugin</description>
+    <packaging>bundle</packaging>
+
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+            <instructions>
+              <DynamicImport-Package>*</DynamicImport-Package>
+           </instructions>
+         </configuration>
+       </plugin>
+     </plugins>
+   </build>
+</project>
diff --git a/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml b/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml
new file mode 100644 (file)
index 0000000..db68c3b
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"/>
+  <reference id="notificationPublishService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"/>
+  <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+  <reference id="switchConnProviderFactory"
+          interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory"/>
+
+  <!-- Create OF switch connection provider on port 6633 -->
+  <odl:clustered-app-config id="defaultSwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-default-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-default-impl</instance-name>
+        <port>6633</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="defaultSwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="defaultSwitchConnConfig"/>
+  </bean>
+
+  <service ref="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-default-impl"/>
+
+  <!-- Create OF switch connection provider on port 6653 -->
+  <odl:clustered-app-config id="legacySwitchConnConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
+      list-key-value="openflow-switch-connection-provider-legacy-impl">
+    <odl:default-config><![CDATA[
+      <switch-connection-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config">
+        <instance-name>openflow-switch-connection-provider-legacy-impl</instance-name>
+        <port>6653</port>
+        <transport-protocol>TCP</transport-protocol>
+      </switch-connection-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="legacySwitchConnProvider" factory-ref="switchConnProviderFactory" factory-method="newInstance">
+    <argument ref="legacySwitchConnConfig"/>
+  </bean>
+
+  <service ref="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
+          odl:type="openflow-switch-connection-provider-legacy-impl"/>
+
+  <!-- Create OpenflowPluginProvider instance -->
+
+  <odl:clustered-app-config id="openflowProviderConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig"/>
+
+  <reference id="openflowPluginProviderFactory"
+          interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"/>
+
+  <bean id="openflowPluginProvider" factory-ref="openflowPluginProviderFactory" factory-method="newInstance">
+    <argument ref="openflowProviderConfig"/>
+    <argument ref="dataBroker"/>
+    <argument ref="rpcRegistry"/>
+    <argument ref="notificationService"/>
+    <argument ref="notificationPublishService"/>
+    <argument ref="entityOwnershipService"/>
+    <argument>
+      <list>
+        <ref component-id="defaultSwitchConnProvider"/>
+        <ref component-id="legacySwitchConnProvider"/>
+      </list>
+    </argument>
+  </bean>
+
+  <service ref="openflowPluginProvider" odl:type="openflow-plugin-provider-impl">
+    <interfaces>
+      <value>org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider</value>
+      <value>org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider</value>
+    </interfaces>
+  </service>
+
+</blueprint>
\ No newline at end of file
index 7a282c09dc0b9c53b21cdc95064bb181b91f8f20..0c9db146a83f134650d5da12538282b19ba1a98b 100644 (file)
@@ -6,6 +6,9 @@ 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
 -->
 <snapshot>
     <required-capabilities>
index ddf73a75cc468af369bcfa7fa373c5f024d6c1b2..74c7f39d5422164f6d6ae66e08746da9bd8cb7d8 100644 (file)
@@ -16,134 +16,189 @@ import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.DeviceContextChangeListener;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.RoleChangeListener;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ServiceChangeListener;
+import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
+import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
+import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
+import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
 /**
  */
-public final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeListener, DeviceContextChangeListener {
+final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeListener, DeviceContextChangeListener, ExtensionConverterProviderKeeper {
 
     private static final Logger LOG = LoggerFactory.getLogger(LifecycleConductorImpl.class);
     private static final int TICKS_PER_WHEEL = 500;
     private static final long TICK_DURATION = 10; // 0.5 sec.
 
     private final HashedWheelTimer hashedWheelTimer = new HashedWheelTimer(TICK_DURATION, TimeUnit.MILLISECONDS, TICKS_PER_WHEEL);
+    private ExtensionConverterProvider extensionConverterProvider;
     private DeviceManager deviceManager;
-    private final MessageIntelligenceAgency messageIntelligenceAgency;
-    private ConcurrentHashMap<NodeId, ServiceChangeListener> serviceChangeListeners = new ConcurrentHashMap<>();
     private StatisticsManager statisticsManager;
+    private RpcManager rpcManager;
+    private final MessageIntelligenceAgency messageIntelligenceAgency;
+    private ConcurrentHashMap<DeviceInfo, ServiceChangeListener> serviceChangeListeners = new ConcurrentHashMap<>();
+    private NotificationPublishService notificationPublishService;
 
-    public LifecycleConductorImpl(final MessageIntelligenceAgency messageIntelligenceAgency) {
-        Preconditions.checkNotNull(messageIntelligenceAgency);
-        this.messageIntelligenceAgency = messageIntelligenceAgency;
+    LifecycleConductorImpl(final MessageIntelligenceAgency messageIntelligenceAgency) {
+        this.messageIntelligenceAgency = Preconditions.checkNotNull(messageIntelligenceAgency);
     }
 
-    public void setSafelyDeviceManager(final DeviceManager deviceManager) {
-        if (this.deviceManager == null) {
-            this.deviceManager = deviceManager;
-        }
+    @Override
+    public ExtensionConverterProvider getExtensionConverterProvider() {
+        return extensionConverterProvider;
     }
 
-    public void setSafelyStatisticsManager(final StatisticsManager statisticsManager) {
-        if (this.statisticsManager == null) {
-            this.statisticsManager = statisticsManager;
+    @Override
+    public void setExtensionConverterProvider(ExtensionConverterProvider extensionConverterProvider) {
+        this.extensionConverterProvider = extensionConverterProvider;
+    }
+
+    @Override
+    public void setSafelyManager(final OFPManager manager){
+        if (manager instanceof RpcManager) {
+            if (rpcManager != null) {
+                LOG.info("RPC manager {} is already defined in conductor. ", manager);
+                return;
+            }
+            this.rpcManager = (RpcManager) manager;
+        } else {
+            if (manager instanceof StatisticsManager) {
+                if (statisticsManager != null) {
+                    LOG.info("Statistics manager {} is already defined in conductor. ", manager);
+                    return;
+                }
+                this.statisticsManager = (StatisticsManager) manager;
+            } else {
+                if (manager instanceof DeviceManager) {
+                    if (deviceManager != null) {
+                        LOG.info("Device manager {} is already defined in conductor. ", manager);
+                        return;
+                    }
+                    this.deviceManager = (DeviceManager) manager;
+                }
+            }
         }
     }
 
-    public void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final NodeId nodeId){
-        LOG.debug("Listener {} for service change for node {} registered.", manager, nodeId);
-        serviceChangeListeners.put(nodeId, manager);
+    @Override
+    public void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final DeviceInfo deviceInfo){
+        LOG.debug("Listener {} for service change for node {} registered.", manager, deviceInfo.getNodeId());
+        serviceChangeListeners.put(deviceInfo, manager);
     }
 
     @VisibleForTesting
-    void notifyServiceChangeListeners(final NodeId nodeId, final boolean success){
+    void notifyServiceChangeListeners(final DeviceInfo deviceInfo, final boolean success){
         if (serviceChangeListeners.size() == 0) {
             return;
         }
         LOG.debug("Notifying registered listeners for service change, no. of listeners {}", serviceChangeListeners.size());
-        for (final Map.Entry<NodeId, ServiceChangeListener> nodeIdServiceChangeListenerEntry : serviceChangeListeners.entrySet()) {
-            if (nodeIdServiceChangeListenerEntry.getKey().equals(nodeId)) {
-                LOG.debug("Listener {} for service change for node {} was notified. Success was set on {}", nodeIdServiceChangeListenerEntry.getValue(), nodeId, success);
-                nodeIdServiceChangeListenerEntry.getValue().servicesChangeDone(nodeId, success);
-                serviceChangeListeners.remove(nodeId);
+        for (final Map.Entry<DeviceInfo, ServiceChangeListener> nodeIdServiceChangeListenerEntry : serviceChangeListeners.entrySet()) {
+            if (nodeIdServiceChangeListenerEntry.getKey().equals(deviceInfo)) {
+                LOG.debug("Listener {} for service change for node {} was notified. Success was set on {}", nodeIdServiceChangeListenerEntry.getValue(), deviceInfo, success);
+                nodeIdServiceChangeListenerEntry.getValue().servicesChangeDone(deviceInfo, success);
+                serviceChangeListeners.remove(deviceInfo);
             }
         }
     }
 
     @Override
-    public void roleInitializationDone(final NodeId nodeId, final boolean success) {
+    public void roleInitializationDone(final DeviceInfo deviceInfo, final boolean success) {
         if (!success) {
-            LOG.warn("Initialization phase for node {} in role context was NOT successful, closing connection.", nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Initialization phase for node {} in role context was NOT successful, closing connection.", deviceInfo);
+            closeConnection(deviceInfo);
         } else {
-            LOG.info("initialization phase for node {} in role context was successful, continuing to next context.", nodeId);
+            LOG.info("initialization phase for node {} in role context was successful, continuing to next context.", deviceInfo);
         }
     }
 
-    public void closeConnection(final NodeId nodeId) {
-        LOG.debug("Close connection called for node {}", nodeId);
-        final DeviceContext deviceContext = getDeviceContext(nodeId);
+    public void closeConnection(final DeviceInfo deviceInfo) {
+        LOG.debug("Close connection called for node {}", deviceInfo);
+        final DeviceContext deviceContext = getDeviceContext(deviceInfo);
         if (null != deviceContext) {
+            deviceManager.notifyDeviceValidListeners(deviceInfo, false);
             deviceContext.shutdownConnection();
         }
     }
 
     @Override
-    public void roleChangeOnDevice(final NodeId nodeId, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
+    public void roleChangeOnDevice(final DeviceInfo deviceInfo, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
 
-        final DeviceContext deviceContext = getDeviceContext(nodeId);
+        final DeviceContext deviceContext = getDeviceContext(deviceInfo);
 
         if (null == deviceContext) {
             LOG.warn("Something went wrong, device context for nodeId: {} doesn't exists");
             return;
         }
         if (!success) {
-            LOG.warn("Role change to {} in role context for node {} was NOT successful, closing connection", newRole, nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Role change to {} in role context for node {} was NOT successful, closing connection", newRole, deviceInfo);
+            closeConnection(deviceInfo);
         } else {
             if (initializationPhase) {
                 LOG.debug("Initialization phase skipping starting services.");
                 return;
             }
 
-            LOG.info("Role change to {} in role context for node {} was successful, starting/stopping services.", newRole, nodeId);
+            LOG.info("Role change to {} in role context for node {} was successful.", newRole, deviceInfo);
+
+            final String logText;
 
             if (OfpRole.BECOMEMASTER.equals(newRole)) {
-                statisticsManager.startScheduling(nodeId);
+                logText = "Start";
+                statisticsManager.startScheduling(deviceInfo);
+                MdSalRegistrationUtils.registerMasterServices(
+                        rpcManager.gainContext(deviceInfo),
+                        deviceContext,
+                        OfpRole.BECOMEMASTER,
+                        this.extensionConverterProvider);
+                if (((RpcContext)rpcManager.gainContext(deviceInfo)).isStatisticsRpcEnabled()) {
+                    MdSalRegistrationUtils.registerStatCompatibilityServices(
+                            rpcManager.gainContext(deviceInfo),
+                            deviceManager.gainContext(deviceInfo),
+                            notificationPublishService,
+                            new AtomicLong());
+                }
             } else {
-                statisticsManager.stopScheduling(nodeId);
+                logText = "Stopp";
+                statisticsManager.stopScheduling(deviceInfo);
+                MdSalRegistrationUtils.registerSlaveServices(
+                        rpcManager.gainContext(deviceInfo),
+                        OfpRole.BECOMESLAVE);
             }
 
-            final ListenableFuture<Void> onClusterRoleChange = deviceContext.onClusterRoleChange(null, newRole);
+            final ListenableFuture<Void> onClusterRoleChange = deviceManager.onClusterRoleChange(deviceInfo, newRole);
             Futures.addCallback(onClusterRoleChange, new FutureCallback<Void>() {
                 @Override
                 public void onSuccess(@Nullable final Void aVoid) {
-                    LOG.info("Starting/Stopping services for node {} was successful", nodeId);
-                    if (newRole.equals(OfpRole.BECOMESLAVE)) notifyServiceChangeListeners(nodeId, true);
+                    LOG.info("{}ing services for node {} was successful", logText, deviceInfo);
+                    if (newRole.equals(OfpRole.BECOMESLAVE)) notifyServiceChangeListeners(deviceInfo, true);
                 }
 
                 @Override
                 public void onFailure(final Throwable throwable) {
-                    LOG.warn("Starting/Stopping services for node {} was NOT successful, closing connection", nodeId);
-                    closeConnection(nodeId);
+                    LOG.warn("{}ing services for node {} was NOT successful, closing connection", logText, deviceInfo);
+                    closeConnection(deviceInfo);
                 }
             });
         }
@@ -154,49 +209,61 @@ public final class LifecycleConductorImpl implements LifecycleConductor, RoleCha
     }
 
     @Override
-    public DeviceContext getDeviceContext(final NodeId nodeId){
-         return deviceManager.getDeviceContextFromNodeId(nodeId);
+    public DeviceContext getDeviceContext(DeviceInfo deviceInfo){
+         return deviceManager.gainContext(deviceInfo);
     }
 
-    public Short gainVersionSafely(final NodeId nodeId) {
-        return (null != getDeviceContext(nodeId)) ? getDeviceContext(nodeId).getPrimaryConnectionContext().getFeatures().getVersion() : null;
+    @Override
+    public StatisticsContext getStatisticsContext(DeviceInfo deviceInfo){
+        return statisticsManager.gainContext(deviceInfo);
     }
 
     public Timeout newTimeout(@Nonnull TimerTask task, long delay, @Nonnull TimeUnit unit) {
         return hashedWheelTimer.newTimeout(task, delay, unit);
     }
 
-    public ConnectionContext.CONNECTION_STATE gainConnectionStateSafely(final NodeId nodeId){
-        return (null != getDeviceContext(nodeId)) ? getDeviceContext(nodeId).getPrimaryConnectionContext().getConnectionState() : null;
+    @Override
+    public ConnectionContext.CONNECTION_STATE gainConnectionStateSafely(final DeviceInfo deviceInfo){
+        return (null != getDeviceContext(deviceInfo)) ? getDeviceContext(deviceInfo).getPrimaryConnectionContext().getConnectionState() : null;
     }
 
-    public Long reserveXidForDeviceMessage(final NodeId nodeId){
-        return null != getDeviceContext(nodeId) ? getDeviceContext(nodeId).reserveXidForDeviceMessage() : null;
+    @Override
+    public Long reserveXidForDeviceMessage(final DeviceInfo deviceInfo){
+        return null != getDeviceContext(deviceInfo) ? getDeviceContext(deviceInfo).reserveXidForDeviceMessage() : null;
     }
 
     @Override
-    public void deviceStartInitializationDone(final NodeId nodeId, final boolean success) {
+    public void deviceStartInitializationDone(final DeviceInfo deviceInfo, final boolean success) {
         if (!success) {
-            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", deviceInfo);
+            closeConnection(deviceInfo);
         } else {
-            LOG.info("initialization phase for node {} in device context was successful. Continuing to next context.", nodeId);
+            LOG.info("initialization phase for node {} in device context was successful. Continuing to next context.", deviceInfo);
         }
     }
 
     @Override
-    public void deviceInitializationDone(final NodeId nodeId, final boolean success) {
+    public void deviceInitializationDone(final DeviceInfo deviceInfo, final boolean success) {
         if (!success) {
-            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", deviceInfo);
+            closeConnection(deviceInfo);
         } else {
-            LOG.info("initialization phase for node {} in device context was successful. All phases initialized OK.", nodeId);
+            LOG.info("initialization phase for node {} in device context was successful. All phases initialized OK.", deviceInfo);
         }
     }
 
     @VisibleForTesting
-    public boolean isServiceChangeListenersEmpty() {
+    boolean isServiceChangeListenersEmpty() {
         return this.serviceChangeListeners.isEmpty();
     }
 
+    @Override
+    public NotificationPublishService getNotificationPublishService() {
+        return notificationPublishService;
+    }
+
+    @Override
+    public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+    }
 }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java
new file mode 100644 (file)
index 0000000..0ad6129
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl;
+
+import java.util.List;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
+import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of OpenFlowPluginProviderFactory.
+ *
+ * @author Thomas Pantelis
+ */
+public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProviderFactory {
+    private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderFactoryImpl.class);
+
+    @Override
+    public OpenFlowPluginProvider newInstance(OpenflowProviderConfig providerConfig, DataBroker dataBroker,
+            RpcProviderRegistry rpcRegistry, NotificationService notificationService,
+            NotificationPublishService notificationPublishService,
+            EntityOwnershipService entityOwnershipService,
+            List<SwitchConnectionProvider> switchConnectionProviders) {
+
+        LOG.info("Initializing new OFP southbound.");
+
+        OpenflowPortsUtil.init();
+        OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(
+                providerConfig.getRpcRequestsQuota(),
+                providerConfig.getGlobalNotificationQuota(),
+                providerConfig.getThreadPoolMinThreads(),
+                providerConfig.getThreadPoolMaxThreads().getValue(),
+                providerConfig.getThreadPoolTimeout());
+
+        openflowPluginProvider.setSwitchConnectionProviders(switchConnectionProviders);
+        openflowPluginProvider.setDataBroker(dataBroker);
+        openflowPluginProvider.setRpcProviderRegistry(rpcRegistry);
+        openflowPluginProvider.setNotificationProviderService(notificationService);
+        openflowPluginProvider.setNotificationPublishService(notificationPublishService);
+        openflowPluginProvider.setEntityOwnershipService(entityOwnershipService);
+        openflowPluginProvider.setSwitchFeaturesMandatory(providerConfig.isSwitchFeaturesMandatory());
+        openflowPluginProvider.setIsStatisticsPollingOff(providerConfig.isIsStatisticsPollingOff());
+        openflowPluginProvider.setIsStatisticsRpcEnabled(providerConfig.isIsStatisticsRpcEnabled());
+        openflowPluginProvider.setBarrierCountLimit(providerConfig.getBarrierCountLimit().getValue());
+        openflowPluginProvider.setBarrierInterval(providerConfig.getBarrierIntervalTimeoutLimit().getValue());
+        openflowPluginProvider.setEchoReplyTimeout(providerConfig.getEchoReplyTimeout().getValue());
+
+        openflowPluginProvider.initialize();
+
+        LOG.info("Configured values, " +
+                "StatisticsPollingOff:{}, " +
+                "SwitchFeaturesMandatory:{}, " +
+                "BarrierCountLimit:{}, " +
+                "BarrierTimeoutLimit:{}, " +
+                "EchoReplyTimeout:{}, " +
+                "ThreadPoolMinThreads:{}, " +
+                "ThreadPoolMaxThreads:{}, " +
+                "ThreadPoolTimeout:{}",
+                providerConfig.isIsStatisticsPollingOff(),
+                providerConfig.isSwitchFeaturesMandatory(),
+                providerConfig.getBarrierCountLimit().getValue(),
+                providerConfig.getBarrierIntervalTimeoutLimit().getValue(),
+                providerConfig.getEchoReplyTimeout().getValue(),
+                providerConfig.getThreadPoolMinThreads(),
+                providerConfig.getThreadPoolMaxThreads().getValue(),
+                providerConfig.getThreadPoolTimeout());
+
+        return openflowPluginProvider;
+    }
+}
index ab64a090c49b745e31b2bd889fe93d98afbe428b..7d1fc5caea5677e9beba38cd415d6255284d2f65 100644 (file)
@@ -17,6 +17,9 @@ import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanRegistrationException;
@@ -51,6 +54,7 @@ import org.opendaylight.openflowplugin.impl.statistics.StatisticsManagerImpl;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntelligenceAgencyImpl;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntelligenceAgencyMXBean;
 import org.opendaylight.openflowplugin.impl.util.TranslatorLibraryUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.slf4j.Logger;
@@ -85,11 +89,26 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
     private boolean isStatisticsRpcEnabled;
 
     private final LifecycleConductor conductor;
+    private final ThreadPoolExecutor threadPool;
 
-    public OpenFlowPluginProviderImpl(final long rpcRequestsQuota, final Long globalNotificationQuota) {
+    public OpenFlowPluginProviderImpl(final long rpcRequestsQuota,
+                                      final long globalNotificationQuota,
+                                      final int threadPoolMinThreads,
+                                      final int threadPoolMaxThreads,
+                                      final long threadPoolTimeout) {
         Preconditions.checkArgument(rpcRequestsQuota > 0 && rpcRequestsQuota <= Integer.MAX_VALUE, "rpcRequestQuota has to be in range <1,%s>", Integer.MAX_VALUE);
         this.rpcRequestsQuota = (int) rpcRequestsQuota;
         this.globalNotificationQuota = Preconditions.checkNotNull(globalNotificationQuota);
+
+        // Creates a thread pool that creates new threads as needed, but will reuse previously
+        // constructed threads when they are available.
+        // Threads that have not been used for x seconds are terminated and removed from the cache.
+        threadPool = new ThreadPoolLoggingExecutor(
+                Preconditions.checkNotNull(threadPoolMinThreads),
+                Preconditions.checkNotNull(threadPoolMaxThreads),
+                Preconditions.checkNotNull(threadPoolTimeout), TimeUnit.SECONDS,
+                new SynchronousQueue<>(), "ofppool");
+
         conductor = new LifecycleConductorImpl(messageIntelligenceAgency);
     }
 
@@ -178,7 +197,6 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
 
     @Override
     public void initialize() {
-
         Preconditions.checkNotNull(dataBroker, "missing data broker");
         Preconditions.checkNotNull(rpcProviderRegistry, "missing RPC provider registry");
         Preconditions.checkNotNull(notificationProviderService, "missing notification provider service");
@@ -188,7 +206,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         // TODO: rewrite later!
         OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterManager);
 
-        connectionManager = new ConnectionManagerImpl(echoReplyTimeout);
+        connectionManager = new ConnectionManagerImpl(echoReplyTimeout, threadPool);
 
         registerMXBean(messageIntelligenceAgency);
 
@@ -198,14 +216,18 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
                 barrierInterval,
                 barrierCountLimit,
                 conductor);
+        ((ExtensionConverterProviderKeeper) conductor).setExtensionConverterProvider(extensionConverterManager);
         ((ExtensionConverterProviderKeeper) deviceManager).setExtensionConverterProvider(extensionConverterManager);
 
-        conductor.setSafelyDeviceManager(deviceManager);
+        conductor.setSafelyManager(deviceManager);
+        conductor.setNotificationPublishService(notificationPublishService);
 
         roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker, conductor);
         statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, isStatisticsPollingOff, conductor);
-        conductor.setSafelyStatisticsManager(statisticsManager);
+        conductor.setSafelyManager(statisticsManager);
+
         rpcManager = new RpcManagerImpl(rpcProviderRegistry, rpcRequestsQuota, conductor);
+        conductor.setSafelyManager(rpcManager);
 
         roleManager.addRoleChangeListener((RoleChangeListener) conductor);
 
@@ -223,8 +245,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         statisticsManager.setDeviceTerminationPhaseHandler(roleManager);
         roleManager.setDeviceTerminationPhaseHandler(deviceManager);
 
-        deviceManager.setStatisticsRpcEnabled(isStatisticsRpcEnabled);
-        deviceManager.setNotificationPublishService(notificationPublishService);
+        rpcManager.setStatisticsRpcEnabled(isStatisticsRpcEnabled);
 
         TranslatorLibraryUtil.setBasicTranslatorLibrary(deviceManager);
         deviceManager.initialize();
@@ -278,5 +299,8 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         // TODO: needs to close org.opendaylight.openflowplugin.impl.role.OpenflowOwnershipListener after RoleContexts are down
         // TODO: must not be executed prior to all living RoleContexts have been closed (via closing living DeviceContexts)
         roleManager.close();
+
+        // Manually shutdown all remaining running threads in pool
+        threadPool.shutdown();
     }
 }
index 191ea623ff3315e0dfc397a9cb1f1c03008bcbe1..c21a973948fc09a4a2ab0cceb2fd86834e09b534 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.connection;
 
+import com.google.common.base.Preconditions;
 import java.math.BigInteger;
 import java.net.InetSocketAddress;
 import java.util.concurrent.Callable;
@@ -16,17 +17,21 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.SessionStatistics;
+import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,6 +49,7 @@ public class ConnectionContextImpl implements ConnectionContext {
     private OutboundQueueProvider outboundQueueProvider;
     private OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration;
     private HandshakeContext handshakeContext;
+    private DeviceInfo deviceInfo;
 
     /**
      * @param connectionAdapter
@@ -219,8 +225,87 @@ public class ConnectionContextImpl implements ConnectionContext {
         connectionState = CONNECTION_STATE.WORKING;
     }
 
+    @Override
+    public DeviceInfo getDeviceInfo() {
+        return this.deviceInfo;
+    }
+
+    @Override
+    public void handshakeSuccessful() {
+        Preconditions.checkNotNull(nodeId, "Cannot create DeviceInfo if 'NodeId' is not set!");
+        Preconditions.checkNotNull(featuresReply, "Cannot create DeviceInfo if 'features' is not set!");
+        this.deviceInfo = new DeviceInfoImpl(
+                nodeId,
+                DeviceStateUtil.createNodeInstanceIdentifier(nodeId),
+                featuresReply.getVersion(),
+                featuresReply.getDatapathId());
+    }
+
     @Override
     public void setHandshakeContext(HandshakeContext handshakeContext) {
         this.handshakeContext = handshakeContext;
     }
+
+
+    private class DeviceInfoImpl implements DeviceInfo {
+
+        final private NodeId nodeId;
+        final private KeyedInstanceIdentifier<Node, NodeKey> nodeII;
+        final private Short version;
+        final private BigInteger datapathId;
+
+        DeviceInfoImpl(
+                final NodeId nodeId,
+                final KeyedInstanceIdentifier<Node, NodeKey> nodeII,
+                final Short version,
+                final BigInteger datapathId) {
+            this.nodeId = nodeId;
+            this.nodeII = nodeII;
+            this.version = version;
+            this.datapathId = datapathId;
+        }
+
+        @Override
+        public NodeId getNodeId() {
+            return nodeId;
+        }
+
+        @Override
+        public KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier() {
+            return nodeII;
+        }
+
+        @Override
+        public Short getVersion() {
+            return version;
+        }
+
+        @Override
+        public BigInteger getDatapathId() {
+            return datapathId;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            DeviceInfoImpl that = (DeviceInfoImpl) o;
+
+            if (!nodeId.equals(that.nodeId)) return false;
+            if (!nodeII.equals(that.nodeII)) return false;
+            if (!version.equals(that.version)) return false;
+            return datapathId.equals(that.datapathId);
+
+        }
+
+        @Override
+        public int hashCode() {
+            int result = nodeId.hashCode();
+            result = 31 * result + nodeII.hashCode();
+            result = 31 * result + version.hashCode();
+            result = 31 * result + datapathId.hashCode();
+            return result;
+        }
+    }
 }
index 31d986c2fc224046827df46db140fd8910986c37..6450e6d647087359314de308a9a52ce740ee40ed 100644 (file)
@@ -9,8 +9,7 @@
 package org.opendaylight.openflowplugin.impl.connection;
 
 import java.net.InetAddress;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ThreadPoolExecutor;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
@@ -26,7 +25,6 @@ import org.opendaylight.openflowplugin.impl.connection.listener.OpenflowProtocol
 import org.opendaylight.openflowplugin.impl.connection.listener.SystemNotificationsListenerImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.ErrorHandlerSimpleImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.HandshakeManagerImpl;
-import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
 import org.slf4j.Logger;
@@ -42,21 +40,15 @@ public class ConnectionManagerImpl implements ConnectionManager {
     private final boolean bitmapNegotiationEnabled = true;
     private DeviceConnectedHandler deviceConnectedHandler;
     private final long echoReplyTimeout;
+    private final ThreadPoolExecutor threadPool;
 
-    public ConnectionManagerImpl(long echoReplyTimeout) {
+    public ConnectionManagerImpl(long echoReplyTimeout, final ThreadPoolExecutor threadPool) {
         this.echoReplyTimeout = echoReplyTimeout;
+        this.threadPool = threadPool;
     }
 
-
     @Override
     public void onSwitchConnected(final ConnectionAdapter connectionAdapter) {
-
-        LOG.trace("preparing handshake: {}", connectionAdapter.getRemoteAddress());
-
-        final int handshakeThreadLimit = 1;
-        final ThreadPoolLoggingExecutor handshakePool = createHandshakePool(
-                connectionAdapter.getRemoteAddress().toString(), handshakeThreadLimit);
-
         LOG.trace("prepare connection context");
         final ConnectionContext connectionContext = new ConnectionContextImpl(connectionAdapter);
 
@@ -64,7 +56,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
         final HandshakeManager handshakeManager = createHandshakeManager(connectionAdapter, handshakeListener);
 
         LOG.trace("prepare handshake context");
-        HandshakeContext handshakeContext = new HandshakeContextImpl(handshakePool, handshakeManager);
+        HandshakeContext handshakeContext = new HandshakeContextImpl(threadPool, handshakeManager);
         handshakeListener.setHandshakeContext(handshakeContext);
         connectionContext.setHandshakeContext(handshakeContext);
 
@@ -77,24 +69,12 @@ public class ConnectionManagerImpl implements ConnectionManager {
                 new OpenflowProtocolListenerInitialImpl(connectionContext, handshakeContext);
         connectionAdapter.setMessageListener(ofMessageListener);
 
-        final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, echoReplyTimeout);
+        final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, echoReplyTimeout, threadPool);
         connectionAdapter.setSystemListener(systemListener);
 
         LOG.trace("connection ballet finished");
     }
 
-    /**
-     * @param connectionIdentifier
-     * @param handshakeThreadLimit
-     * @return
-     */
-    private static ThreadPoolLoggingExecutor createHandshakePool(
-            final String connectionIdentifier, final int handshakeThreadLimit) {
-        return new ThreadPoolLoggingExecutor(handshakeThreadLimit,
-                handshakeThreadLimit, 0L, TimeUnit.MILLISECONDS,
-                new LinkedBlockingQueue<>(HELLO_LIMIT), "OFHandshake-" + connectionIdentifier);
-    }
-
     /**
      * @param connectionAdapter
      * @param handshakeListener
@@ -119,7 +99,6 @@ public class ConnectionManagerImpl implements ConnectionManager {
         return bitmapNegotiationEnabled;
     }
 
-
     @Override
     public boolean accept(final InetAddress switchAddress) {
         // TODO add connection accept logic based on address
index e7142642b85c6010eaac4735bbb8de3e379c771f..1efadcc18b3a70c5a1c432201b5b4da13f129b14 100644 (file)
@@ -8,19 +8,13 @@
 package org.opendaylight.openflowplugin.impl.connection;
 
 import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
 import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  *
  */
 public class HandshakeContextImpl implements HandshakeContext {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HandshakeContextImpl.class);
-
     private ThreadPoolExecutor handshakePool;
     private HandshakeManager handshakeManager;
 
@@ -44,23 +38,6 @@ public class HandshakeContextImpl implements HandshakeContext {
     }
 
     @Override
-    public void close() throws Exception {
-        shutdownPoolPolitely();
-    }
-
-    private void shutdownPoolPolitely() {
-        LOG.debug("terminating handshake pool");
-        handshakePool.shutdown();
-        try {
-            handshakePool.awaitTermination(1, TimeUnit.SECONDS);
-        } catch (InterruptedException e) {
-            LOG.error("Error while awaiting termination on pool. Will use shutdownNow method.");
-        } finally {
-            handshakePool.purge();
-            if (! handshakePool.isTerminated()) {
-                handshakePool.shutdownNow();
-            }
-            LOG.debug("pool is terminated: {}", handshakePool.isTerminated());
-        }
+    public void close() {
     }
 }
index f843f59194289cc08368722d94636621fe8d68c0..3760ff79f2ba54c1ff2cd9c234e046a705b1eec5 100644 (file)
@@ -54,6 +54,7 @@ public class HandshakeListenerImpl implements HandshakeListener {
         connectionContext.changeStateToWorking();
         connectionContext.setFeatures(featureOutput);
         connectionContext.setNodeId(InventoryDataServiceUtil.nodeIdFromDatapathId(featureOutput.getDatapathId()));
+        connectionContext.handshakeSuccessful();
 
         // fire barrier in order to sweep all handshake and posthandshake messages before continue
         final ListenableFuture<RpcResult<BarrierOutput>> barrier = fireBarrier(version, 0L);
index 1d99f8073fddbddf78c19527150f086ac4efad7c..ae169a021f8e78730c5031d73eb768b4c7b2d826 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.Preconditions;
 import java.net.InetSocketAddress;
 import java.util.Date;
 import java.util.concurrent.Future;
+import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
@@ -37,8 +38,12 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
     @VisibleForTesting
     static final long MAX_ECHO_REPLY_TIMEOUT = 2000;
     private final long echoReplyTimeout;
+    private final ThreadPoolExecutor threadPool;
 
-    public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext, long echoReplyTimeout) {
+    public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext,
+                                           long echoReplyTimeout,
+                                           @Nonnull final ThreadPoolExecutor threadPool) {
+        this.threadPool = threadPool;
         this.connectionContext = Preconditions.checkNotNull(connectionContext);
         this.echoReplyTimeout = echoReplyTimeout;
     }
@@ -52,62 +57,59 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
 
     @Override
     public void onSwitchIdleEvent(final SwitchIdleEvent notification) {
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                boolean shouldBeDisconnected = true;
+        threadPool.execute(() -> {
+            boolean shouldBeDisconnected = true;
 
-                final InetSocketAddress remoteAddress = connectionContext.getConnectionAdapter().getRemoteAddress();
+            final InetSocketAddress remoteAddress = connectionContext.getConnectionAdapter().getRemoteAddress();
 
-                if (ConnectionContext.CONNECTION_STATE.WORKING.equals(connectionContext.getConnectionState())) {
-                    FeaturesReply features = connectionContext.getFeatures();
-                    LOG.info("Switch Idle state occurred, node={}|auxId={}", remoteAddress, features.getAuxiliaryId());
-                    connectionContext.changeStateToTimeouting();
-                    EchoInputBuilder builder = new EchoInputBuilder();
-                    builder.setVersion(features.getVersion());
-                    Xid xid = new Xid(0L);
-                    builder.setXid(xid.getValue());
+            if (ConnectionContext.CONNECTION_STATE.WORKING.equals(connectionContext.getConnectionState())) {
+                FeaturesReply features = connectionContext.getFeatures();
+                LOG.info("Switch Idle state occurred, node={}|auxId={}", remoteAddress, features.getAuxiliaryId());
+                connectionContext.changeStateToTimeouting();
+                EchoInputBuilder builder = new EchoInputBuilder();
+                builder.setVersion(features.getVersion());
+                Xid xid = new Xid(0L);
+                builder.setXid(xid.getValue());
 
-                    Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build());
+                Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build());
 
-                    try {
-                        RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS);
-                        if (echoReplyValue.isSuccessful()) {
-                            connectionContext.changeStateToWorking();
-                            shouldBeDisconnected = false;
-                        } else {
-                            for (RpcError replyError : echoReplyValue.getErrors()) {
-                                Throwable cause = replyError.getCause();
-                                if (LOG.isWarnEnabled()) {
-                                    LOG.warn("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause.getMessage());
-                                }
-
-                                if (LOG.isTraceEnabled()) {
-                                    LOG.trace("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause);
-                                }
+                try {
+                    RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS);
+                    if (echoReplyValue.isSuccessful()) {
+                        connectionContext.changeStateToWorking();
+                        shouldBeDisconnected = false;
+                    } else {
+                        for (RpcError replyError : echoReplyValue.getErrors()) {
+                            Throwable cause = replyError.getCause();
+                            if (LOG.isWarnEnabled()) {
+                                LOG.warn("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause.getMessage());
+                            }
 
+                            if (LOG.isTraceEnabled()) {
+                                LOG.trace("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause);
                             }
-                        }
-                    } catch (Exception e) {
-                        if (LOG.isWarnEnabled()) {
-                            LOG.warn("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e.getMessage());
-                        }
 
-                        if (LOG.isTraceEnabled()) {
-                            LOG.trace("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e);
                         }
-
                     }
-                }
-                if (shouldBeDisconnected) {
-                    if (LOG.isInfoEnabled()) {
-                        LOG.info("ConnectionEvent:Closing connection as device is idle. Echo sent at {}. Device:{}, NodeId:{}",
-                                new Date(System.currentTimeMillis() - echoReplyTimeout), remoteAddress, connectionContext.getNodeId());
+                } catch (Exception e) {
+                    if (LOG.isWarnEnabled()) {
+                        LOG.warn("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e.getMessage());
+                    }
+
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e);
                     }
 
-                    connectionContext.closeConnection(true);
                 }
             }
-        }).start();
+            if (shouldBeDisconnected) {
+                if (LOG.isInfoEnabled()) {
+                    LOG.info("ConnectionEvent:Closing connection as device is idle. Echo sent at {}. Device:{}, NodeId:{}",
+                            new Date(System.currentTimeMillis() - echoReplyTimeout), remoteAddress, connectionContext.getNodeId());
+                }
+
+                connectionContext.closeConnection(true);
+            }
+        });
     }
 }
index 441725723740f439ac10f78b1f03bc1e5d2c5028..bcf4259fc9632f3fcdb507737f14fc0255bc380d 100644 (file)
@@ -8,10 +8,8 @@
 package org.opendaylight.openflowplugin.impl.device;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
-import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -20,9 +18,6 @@ import java.math.BigInteger;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
@@ -34,6 +29,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -50,9 +46,7 @@ import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKe
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleKeeper;
-import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
 import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper;
@@ -66,9 +60,6 @@ import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
 import org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl;
 import org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl;
-import org.opendaylight.openflowplugin.impl.rpc.RpcContextImpl;
-import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtils;
-import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -77,8 +68,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 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.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
@@ -99,7 +88,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -138,19 +126,12 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     private final MessageTranslator<PacketInMessage, PacketReceived> packetInTranslator;
     private final MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> flowRemovedTranslator;
     private final TranslatorLibrary translatorLibrary;
-    private final Map<Long, NodeConnectorRef> nodeConnectorCache;
     private final ItemLifeCycleRegistry itemLifeCycleSourceRegistry;
-    private RpcContext rpcContext;
     private ExtensionConverterProvider extensionConverterProvider;
 
-    private final boolean switchFeaturesMandatory;
-    private StatisticsContext statisticsContext;
-
-    private final NodeId nodeId;
-
-    private volatile DEVICE_CONTEXT_STATE deviceCtxState;
-    private boolean isStatisticsRpcEnabled;
+    private final DeviceInfo deviceInfo;
 
+    private volatile CONTEXT_STATE contextState;
 
     @VisibleForTesting
     DeviceContextImpl(@Nonnull final ConnectionContext primaryConnectionContext,
@@ -158,41 +139,36 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                       @Nonnull final DataBroker dataBroker,
                       @Nonnull final LifecycleConductor conductor,
                       @Nonnull final OutboundQueueProvider outboundQueueProvider,
-                      @Nonnull final TranslatorLibrary translatorLibrary,
-                      final boolean switchFeaturesMandatory) {
-        this.switchFeaturesMandatory = switchFeaturesMandatory;
+                      @Nonnull final TranslatorLibrary translatorLibrary) {
         this.primaryConnectionContext = Preconditions.checkNotNull(primaryConnectionContext);
         this.deviceState = Preconditions.checkNotNull(deviceState);
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         Preconditions.checkNotNull(conductor);
         this.outboundQueueProvider = Preconditions.checkNotNull(outboundQueueProvider);
-        this.transactionChainManager = new TransactionChainManager(dataBroker, deviceState, conductor);
+        deviceInfo = primaryConnectionContext.getDeviceInfo();
+        this.transactionChainManager = new TransactionChainManager(dataBroker, deviceInfo, conductor);
         auxiliaryConnectionContexts = new HashMap<>();
         deviceFlowRegistry = new DeviceFlowRegistryImpl();
         deviceGroupRegistry = new DeviceGroupRegistryImpl();
         deviceMeterRegistry = new DeviceMeterRegistryImpl();
         messageSpy = conductor.getMessageIntelligenceAgency();
 
+
         packetInLimiter = new PacketInRateLimiter(primaryConnectionContext.getConnectionAdapter(),
                 /*initial*/ 1000, /*initial*/2000, messageSpy, REJECTED_DRAIN_FACTOR);
 
         this.translatorLibrary = translatorLibrary;
         portStatusTranslator = translatorLibrary.lookupTranslator(
-                new TranslatorKey(deviceState.getVersion(), PortGrouping.class.getName()));
+                new TranslatorKey(deviceInfo.getVersion(), PortGrouping.class.getName()));
         packetInTranslator = translatorLibrary.lookupTranslator(
-                new TranslatorKey(deviceState.getVersion(), PacketIn.class.getName()));
+                new TranslatorKey(deviceInfo.getVersion(), PacketIn.class.getName()));
         flowRemovedTranslator = translatorLibrary.lookupTranslator(
-                new TranslatorKey(deviceState.getVersion(), FlowRemoved.class.getName()));
-
-
-        nodeConnectorCache = new ConcurrentHashMap<>();
+                new TranslatorKey(deviceInfo.getVersion(), FlowRemoved.class.getName()));
 
         itemLifeCycleSourceRegistry = new ItemLifeCycleRegistryImpl();
         flowLifeCycleKeeper = new ItemLifeCycleSourceImpl();
         itemLifeCycleSourceRegistry.registerLifeCycleSource(flowLifeCycleKeeper);
-        deviceCtxState = DEVICE_CONTEXT_STATE.INITIALIZATION;
-
-        nodeId = primaryConnectionContext.getNodeId();
+        contextState = CONTEXT_STATE.INITIALIZATION;
     }
 
     /**
@@ -222,7 +198,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     public void removeAuxiliaryConnectionContext(final ConnectionContext connectionContext) {
         final SwitchConnectionDistinguisher connectionDistinguisher = createConnectionDistinguisher(connectionContext);
         LOG.debug("auxiliary connection dropped: {}, nodeId:{}", connectionContext.getConnectionAdapter()
-                .getRemoteAddress(), nodeId);
+                .getRemoteAddress(), deviceInfo.getNodeId());
         auxiliaryConnectionContexts.remove(connectionDistinguisher);
     }
 
@@ -232,102 +208,13 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     @Override
-    public ReadOnlyTransaction getReadTransaction() {
-        return dataBroker.newReadOnlyTransaction();
-    }
-
-    @Override
-    public ListenableFuture<Void> onClusterRoleChange(final OfpRole oldRole, @CheckForNull final OfpRole role) {
-        LOG.trace("onClusterRoleChange {} for node:", role, nodeId);
-        Preconditions.checkArgument(role != null);
-        if (role.equals(oldRole)) {
-            LOG.debug("Demanded role change for device {} is not changed. OldRole: {}, NewRole {}", nodeId, oldRole, role);
-            return Futures.immediateFuture(null);
-        }
-        if (OfpRole.BECOMEMASTER.equals(role)) {
-            return onDeviceTakeClusterLeadership();
-        } else if (OfpRole.BECOMESLAVE.equals(role)) {
-            return onDeviceLostClusterLeadership();
-        } else {
-            LOG.warn("Unknown OFCluster Role {} for Node {}", role, nodeId);
-            if (null != rpcContext) {
-                MdSalRegistrationUtils.unregisterServices(rpcContext);
-            }
-            return transactionChainManager.deactivateTransactionManager();
-        }
+    public DeviceInfo getDeviceInfo() {
+        return this.deviceInfo;
     }
 
     @Override
-    public ListenableFuture<Void> onDeviceLostClusterLeadership() {
-        LOG.trace("onDeviceLostClusterLeadership for node: {}", nodeId);
-        if (null != rpcContext) {
-            MdSalRegistrationUtils.registerSlaveServices(rpcContext, OfpRole.BECOMESLAVE);
-        }
-        return transactionChainManager.deactivateTransactionManager();
-    }
-
-    @Override
-    public ListenableFuture<Void> onDeviceTakeClusterLeadership() {
-        LOG.trace("onDeviceTakeClusterLeadership for node: {}", nodeId);
-        /* validation */
-        if (statisticsContext == null) {
-            final String errMsg = String.format("DeviceCtx %s is up but we are missing StatisticsContext", nodeId);
-            LOG.warn(errMsg);
-            return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
-        }
-        if (rpcContext == null) {
-            final String errMsg = String.format("DeviceCtx %s is up but we are missing RpcContext", nodeId);
-            LOG.warn(errMsg);
-            return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
-        }
-        /* Routed RPC registration */
-        MdSalRegistrationUtils.registerMasterServices(getRpcContext(), DeviceContextImpl.this, OfpRole.BECOMEMASTER);
-
-        if (isStatisticsRpcEnabled) {
-            MdSalRegistrationUtils.registerStatCompatibilityServices(getRpcContext(), this,
-                    notificationPublishService, new AtomicLong());
-        }
-
-        /* Prepare init info collecting */
-        getDeviceState().setDeviceSynchronized(false);
-        transactionChainManager.activateTransactionManager();
-        /* Init Collecting NodeInfo */
-        final ListenableFuture<Void> initCollectingDeviceInfo = DeviceInitializationUtils.initializeNodeInformation(
-                DeviceContextImpl.this, switchFeaturesMandatory);
-        /* Init Collecting StatInfo */
-        final ListenableFuture<Boolean> statPollFuture = Futures.transform(initCollectingDeviceInfo,
-                new AsyncFunction<Void, Boolean>() {
-
-                    @Override
-                    public ListenableFuture<Boolean> apply(@Nonnull final Void input) throws Exception {
-                        getStatisticsContext().statListForCollectingInitialization();
-                        return getStatisticsContext().gatherDynamicData();
-                    }
-                });
-
-        return Futures.transform(statPollFuture, new Function<Boolean, Void>() {
-
-            @Override
-            public Void apply(final Boolean input) {
-                if (ConnectionContext.CONNECTION_STATE.RIP.equals(getPrimaryConnectionContext().getConnectionState())) {
-                    final String errMsg = String.format("We lost connection for Device %s, context has to be closed.",
-                            getDeviceState().getNodeId());
-                    LOG.warn(errMsg);
-                    throw new IllegalStateException(errMsg);
-                }
-                if (!input) {
-                    final String errMsg = String.format("Get Initial Device %s information fails",
-                            getDeviceState().getNodeId());
-                    LOG.warn(errMsg);
-                    throw new IllegalStateException(errMsg);
-                }
-                LOG.debug("Get Initial Device {} information is successful", nodeId);
-                getDeviceState().setDeviceSynchronized(true);
-                initialSubmitTransaction();
-                getDeviceState().setStatisticsPollingEnabledProp(true);
-                return null;
-            }
-        });
+    public ReadOnlyTransaction getReadTransaction() {
+        return dataBroker.newReadOnlyTransaction();
     }
 
     @Override
@@ -398,7 +285,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         if (itemLifecycleListener != null) {
             //1. translate to general flow (table, priority, match, cookie)
             final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
-                    flowRemovedTranslator.translate(flowRemoved, this.getDeviceState(), null);
+                    flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
             //2. create registry key
             final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(flowRemovedNotification);
             //3. lookup flowId
@@ -406,7 +293,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
             //4. if flowId present:
             if (flowDescriptor != null) {
                 // a) construct flow path
-                final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = getDeviceState().getNodeInstanceIdentifier()
+                final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = getDeviceInfo().getNodeInstanceIdentifier()
                         .augmentation(FlowCapableNode.class)
                         .child(Table.class, flowDescriptor.getTableKey())
                         .child(Flow.class, new FlowKey(flowDescriptor.getFlowId()));
@@ -416,7 +303,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                 notificationPublishService.offerNotification(flowRemovedNotification);
             } else {
                 LOG.debug("flow id not found: nodeId={} tableId={}, priority={}",
-                        getDeviceState().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
+                        getDeviceInfo().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
             }
         }
     }
@@ -424,7 +311,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     @Override
     public void processPortStatusMessage(final PortStatusMessage portStatus) {
         messageSpy.spyMessage(portStatus.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
-        final FlowCapableNodeConnector flowCapableNodeConnector = portStatusTranslator.translate(portStatus, this.getDeviceState(), null);
+        final FlowCapableNodeConnector flowCapableNodeConnector = portStatusTranslator.translate(portStatus, deviceInfo, null);
 
         final KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> iiToNodeConnector = provideIIToNodeConnector(portStatus.getPortNo(), portStatus.getVersion());
         try {
@@ -444,8 +331,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     private KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> provideIIToNodeConnector(final long portNo, final short version) {
-        final InstanceIdentifier<Node> iiToNodes = deviceState.getNodeInstanceIdentifier();
-        final BigInteger dataPathId = deviceState.getFeatures().getDatapathId();
+        final InstanceIdentifier<Node> iiToNodes = deviceInfo.getNodeInstanceIdentifier();
+        final BigInteger dataPathId = deviceInfo.getDatapathId();
         final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(dataPathId.toString(), portNo, version);
         return iiToNodes.child(NodeConnector.class, new NodeConnectorKey(nodeConnectorId));
     }
@@ -454,7 +341,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     public void processPacketInMessage(final PacketInMessage packetInMessage) {
         messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH);
         final ConnectionAdapter connectionAdapter = getPrimaryConnectionContext().getConnectionAdapter();
-        final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, this.getDeviceState(), null);
+        final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, deviceInfo, null);
 
         if (packetReceived == null) {
             LOG.debug("Received a null packet from switch {}", connectionAdapter.getRemoteAddress());
@@ -502,13 +389,13 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         // lookup converter
         final ExperimenterDataOfChoice vendorData = notification.getExperimenterDataOfChoice();
         final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(
-                deviceState.getVersion(),
+                deviceInfo.getVersion(),
                 (Class<? extends ExperimenterDataOfChoice>) vendorData.getImplementedInterface());
         final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> messageConverter = extensionConverterProvider.getMessageConverter(key);
         if (messageConverter == null) {
             LOG.warn("custom converter for {}[OF:{}] not found",
                     notification.getExperimenterDataOfChoice().getImplementedInterface(),
-                    deviceState.getVersion());
+                    deviceInfo.getVersion());
             return;
         }
         // build notification
@@ -516,7 +403,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         try {
             messageOfChoice = messageConverter.convert(vendorData, MessagePath.MESSAGE_NOTIFICATION);
             final ExperimenterMessageFromDevBuilder experimenterMessageFromDevBld = new ExperimenterMessageFromDevBuilder()
-                .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier()))
                     .setExperimenterMessageOfChoice(messageOfChoice);
             // publish
             notificationPublishService.offerNotification(experimenterMessageFromDevBld.build());
@@ -534,7 +421,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     public synchronized void close() {
         LOG.debug("closing deviceContext: {}, nodeId:{}",
                 getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress(),
-                getDeviceState().getNodeId());
+                getDeviceInfo().getNodeId());
         // NOOP
         throw new UnsupportedOperationException("Autocloseble.close will be removed soon");
     }
@@ -561,8 +448,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
     @Override
     public void onPublished() {
-        Verify.verify(DEVICE_CONTEXT_STATE.INITIALIZATION.equals(deviceCtxState));
-        deviceCtxState = DEVICE_CONTEXT_STATE.WORKING;
+        Verify.verify(CONTEXT_STATE.INITIALIZATION.equals(contextState));
+        contextState = CONTEXT_STATE.WORKING;
         primaryConnectionContext.getConnectionAdapter().setPacketInFiltering(false);
         for (final ConnectionContext switchAuxConnectionContext : auxiliaryConnectionContexts.values()) {
             switchAuxConnectionContext.getConnectionAdapter().setPacketInFiltering(false);
@@ -574,18 +461,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         return new MultiMsgCollectorImpl(this, requestContext);
     }
 
-    @Override
-    public NodeConnectorRef lookupNodeConnectorRef(final Long portNumber) {
-        return nodeConnectorCache.get(portNumber);
-    }
-
-    @Override
-    public void storeNodeConnectorRef(@Nonnull final Long portNumber, @Nonnull final NodeConnectorRef nodeConnectorRef) {
-        nodeConnectorCache.put(
-                Preconditions.checkNotNull(portNumber),
-                Preconditions.checkNotNull(nodeConnectorRef));
-    }
-
     @Override
     public void updatePacketInRateLimit(final long upperBound) {
         packetInLimiter.changeWaterMarks((int) (LOW_WATERMARK_FACTOR * upperBound), (int) (HIGH_WATERMARK_FACTOR * upperBound));
@@ -596,16 +471,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         return itemLifeCycleSourceRegistry;
     }
 
-    @Override
-    public void setRpcContext(final RpcContext rpcContext) {
-        this.rpcContext = rpcContext;
-    }
-
-    @Override
-    public RpcContext getRpcContext() {
-        return rpcContext;
-    }
-
     @Override
     public void setExtensionConverterProvider(final ExtensionConverterProvider extensionConverterProvider) {
         this.extensionConverterProvider = extensionConverterProvider;
@@ -616,28 +481,17 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         return extensionConverterProvider;
     }
 
-    @Override
-    public void setStatisticsContext(final StatisticsContext statisticsContext) {
-        this.statisticsContext = statisticsContext;
-    }
-
-    @Override
-    public StatisticsContext getStatisticsContext() {
-        return statisticsContext;
-    }
-
     @Override
     public synchronized void shutdownConnection() {
-        LOG.debug("Shutdown method for node {}", nodeId);
-        deviceState.setValid(false);
-        if (DEVICE_CONTEXT_STATE.TERMINATION.equals(deviceCtxState)) {
-            LOG.debug("DeviceCtx for Node {} is in termination process.", nodeId);
+        LOG.debug("Shutdown method for node {}", deviceInfo.getNodeId());
+        if (CONTEXT_STATE.TERMINATION.equals(contextState)) {
+            LOG.debug("DeviceCtx for Node {} is in termination process.", deviceInfo.getNodeId());
             return;
         }
-        deviceCtxState = DEVICE_CONTEXT_STATE.TERMINATION;
+        contextState = CONTEXT_STATE.TERMINATION;
 
         if (ConnectionContext.CONNECTION_STATE.RIP.equals(getPrimaryConnectionContext().getConnectionState())) {
-            LOG.debug("ConnectionCtx for Node {} is in RIP state.", deviceState.getNodeId());
+            LOG.debug("ConnectionCtx for Node {} is in RIP state.", deviceInfo.getNodeId());
             return;
         }
         /* Terminate Auxiliary Connection */
@@ -653,19 +507,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         deviceMeterRegistry.close();
     }
 
-    @Override
-    public void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled) {
-        this.isStatisticsRpcEnabled = isStatisticsRpcEnabled;
-    }
-
-    @Override
-    public DEVICE_CONTEXT_STATE getDeviceContextState() {
-        return deviceCtxState;
-    }
-
     @Override
     public ListenableFuture<Void> shuttingDownDataStoreTransactions() {
-        deviceState.setValid(false);
         return transactionChainManager.shuttingDown();
     }
 
@@ -673,4 +516,9 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     TransactionChainManager getTransactionChainManager() {
         return this.transactionChainManager;
     }
+
+    @Override
+    public CONTEXT_STATE getState() {
+        return this.contextState;
+    }
 }
index 31df880261d5dd668047c2b57febe1142531ca44..fce73471c7327f91a309f3c8ebe97ead412a4911 100644 (file)
@@ -8,16 +8,19 @@
 package org.opendaylight.openflowplugin.impl.device;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Iterators;
+import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
@@ -26,28 +29,33 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceSynchronizeListener;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceValidListener;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
+import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper;
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.impl.connection.OutboundQueueProviderImpl;
 import org.opendaylight.openflowplugin.impl.device.listener.OpenflowProtocolListenerFullImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,17 +76,17 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private TranslatorLibrary translatorLibrary;
     private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
-    private NotificationPublishService notificationPublishService;
 
-    private final ConcurrentMap<NodeId, DeviceContext> deviceContexts = new ConcurrentHashMap<>();
+    private final ConcurrentMap<DeviceInfo, DeviceContext> deviceContexts = new ConcurrentHashMap<>();
 
     private final long barrierIntervalNanos;
     private final int barrierCountLimit;
     private ExtensionConverterProvider extensionConverterProvider;
     private ScheduledThreadPoolExecutor spyPool;
+    private Set<DeviceSynchronizeListener> deviceSynchronizedListeners;
+    private Set<DeviceValidListener> deviceValidListeners;
 
     private final LifecycleConductor conductor;
-    private boolean isStatisticsRpcEnabled;
 
     public DeviceManagerImpl(@Nonnull final DataBroker dataBroker,
                              final long globalNotificationQuota, final boolean switchFeaturesMandatory,
@@ -105,6 +113,8 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
         this.conductor = lifecycleConductor;
         spyPool = new ScheduledThreadPoolExecutor(1);
+        this.deviceSynchronizedListeners = new HashSet<>();
+        this.deviceValidListeners = new HashSet<>();
     }
 
 
@@ -114,10 +124,10 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     @Override
-    public void onDeviceContextLevelUp(final NodeId nodeId) throws Exception {
+    public void onDeviceContextLevelUp(@CheckForNull DeviceInfo deviceInfo) throws Exception {
         // final phase - we have to add new Device to MD-SAL DataStore
-        LOG.debug("Final phase of DeviceContextLevelUp for Node: {} ", nodeId);
-        DeviceContext deviceContext = Preconditions.checkNotNull(deviceContexts.get(nodeId));
+        LOG.debug("Final phase of DeviceContextLevelUp for Node: {} ", deviceInfo.getNodeId());
+        DeviceContext deviceContext = Preconditions.checkNotNull(deviceContexts.get(deviceInfo));
         ((DeviceContextImpl) deviceContext).initialSubmitTransaction();
         deviceContext.onPublished();
     }
@@ -126,19 +136,19 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     public boolean deviceConnected(@CheckForNull final ConnectionContext connectionContext) throws Exception {
         Preconditions.checkArgument(connectionContext != null);
 
-        NodeId nodeId = connectionContext.getNodeId();
+        DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
         /**
          * This part prevent destroy another device context. Throwing here an exception result to propagate close connection
          * in {@link org.opendaylight.openflowplugin.impl.connection.org.opendaylight.openflowplugin.impl.connection.HandshakeContextImpl}
          * If context already exist we are in state closing process (connection flapping) and we should not propagate connection close
          */
-         if (deviceContexts.containsKey(nodeId)) {
+         if (deviceContexts.containsKey(deviceInfo)) {
             LOG.warn("Rejecting connection from node which is already connected and there exist deviceContext for it: {}", connectionContext.getNodeId());
              return false;
          }
 
         LOG.info("ConnectionEvent: Device connected to controller, Device:{}, NodeId:{}",
-                connectionContext.getConnectionAdapter().getRemoteAddress(), nodeId);
+                connectionContext.getConnectionAdapter().getRemoteAddress(), deviceInfo.getNodeId());
 
         // Add Disconnect handler
         connectionContext.setDeviceDisconnectedHandler(DeviceManagerImpl.this);
@@ -148,43 +158,41 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         //FIXME: as soon as auxiliary connection are fully supported then this is needed only before device context published
         connectionAdapter.setPacketInFiltering(true);
 
-        final Short version = connectionContext.getFeatures().getVersion();
-        final OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(version);
+        final OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(deviceInfo.getVersion());
 
         connectionContext.setOutboundQueueProvider(outboundQueueProvider);
         final OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration =
                 connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, barrierCountLimit, barrierIntervalNanos);
         connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration);
 
-        final DeviceState deviceState = createDeviceState(connectionContext);
+        final DeviceState deviceState = new DeviceStateImpl(deviceInfo);
+        this.addDeviceSynchronizeListener(deviceState);
+        this.addDeviceValidListener(deviceState);
+
         final DeviceContext deviceContext = new DeviceContextImpl(connectionContext,
                 deviceState,
                 dataBroker,
                 conductor,
                 outboundQueueProvider,
-                translatorLibrary,
-                switchFeaturesMandatory);
+                translatorLibrary);
 
-        Verify.verify(deviceContexts.putIfAbsent(nodeId, deviceContext) == null, "DeviceCtx still not closed.");
+        Verify.verify(deviceContexts.putIfAbsent(deviceInfo, deviceContext) == null, "DeviceCtx still not closed.");
 
         ((ExtensionConverterProviderKeeper) deviceContext).setExtensionConverterProvider(extensionConverterProvider);
-        deviceContext.setStatisticsRpcEnabled(isStatisticsRpcEnabled);
-        deviceContext.setNotificationPublishService(notificationPublishService);
+        deviceContext.setNotificationPublishService(conductor.getNotificationPublishService());
 
         updatePacketInRateLimiters();
 
         final OpenflowProtocolListenerFullImpl messageListener = new OpenflowProtocolListenerFullImpl(
                 connectionAdapter, deviceContext);
         connectionAdapter.setMessageListener(messageListener);
-        deviceState.setValid(true);
+        notifyDeviceValidListeners(deviceInfo, true);
 
-        deviceInitPhaseHandler.onDeviceContextLevelUp(nodeId);
+        deviceInitPhaseHandler.onDeviceContextLevelUp(connectionContext.getDeviceInfo());
 
-        return true;
-    }
+        notifyDeviceSynchronizeListeners(deviceInfo, true);
 
-    private static DeviceStateImpl createDeviceState(final @Nonnull ConnectionContext connectionContext) {
-        return new DeviceStateImpl(connectionContext.getFeatures(), connectionContext.getNodeId());
+        return true;
     }
 
     private void updatePacketInRateLimiters() {
@@ -213,16 +221,12 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         this.translatorLibrary = translatorLibrary;
     }
 
-    @Override
-    public void setNotificationPublishService(final NotificationPublishService notificationService) {
-        notificationPublishService = notificationService;
-    }
-
     @Override
     public void close() {
         for (final Iterator<DeviceContext> iterator = Iterators.consumingIterator(deviceContexts.values().iterator());
                 iterator.hasNext();) {
             final DeviceContext deviceCtx = iterator.next();
+            notifyDeviceValidListeners(deviceCtx.getDeviceInfo(), false);
             deviceCtx.shutdownConnection();
             deviceCtx.shuttingDownDataStoreTransactions();
         }
@@ -234,9 +238,9 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     @Override
-    public void onDeviceContextLevelDown(final DeviceContext deviceContext) {
-        LOG.debug("onDeviceContextClosed for Node {}", deviceContext.getDeviceState().getNodeId());
-        deviceContexts.remove(deviceContext.getPrimaryConnectionContext().getNodeId(), deviceContext);
+    public void onDeviceContextLevelDown(final DeviceInfo deviceInfo) {
+        LOG.debug("onDeviceContextClosed for Node {}", deviceInfo.getNodeId());
+        deviceContexts.remove(deviceInfo);
         updatePacketInRateLimiters();
     }
 
@@ -245,16 +249,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         spyPool.scheduleAtFixedRate(conductor.getMessageIntelligenceAgency(), spyRate, spyRate, TimeUnit.SECONDS);
     }
 
-    @Override
-    public DeviceContext getDeviceContextFromNodeId(final NodeId nodeId) {
-        return deviceContexts.get(nodeId);
-    }
-
-    @Override
-    public void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled) {
-        this.isStatisticsRpcEnabled = isStatisticsRpcEnabled;
-    }
-
     @Override
     public void setExtensionConverterProvider(final ExtensionConverterProvider extensionConverterProvider) {
         this.extensionConverterProvider = extensionConverterProvider;
@@ -273,11 +267,11 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     @Override
     public void onDeviceDisconnected(final ConnectionContext connectionContext) {
         LOG.trace("onDeviceDisconnected method call for Node: {}", connectionContext.getNodeId());
-        final NodeId nodeId = connectionContext.getNodeId();
-        final DeviceContext deviceCtx = this.deviceContexts.get(nodeId);
+        final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
+        final DeviceContext deviceCtx = this.deviceContexts.get(deviceInfo);
 
         if (null == deviceCtx) {
-            LOG.info("DeviceContext for Node {} was not found. Connection is terminated without OFP context suite.", nodeId);
+            LOG.info("DeviceContext for Node {} was not found. Connection is terminated without OFP context suite.", deviceInfo.getNodeId());
             return;
         }
 
@@ -285,31 +279,28 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
             /* Connection is not PrimaryConnection so try to remove from Auxiliary Connections */
             deviceCtx.removeAuxiliaryConnectionContext(connectionContext);
         } else {
+            notifyDeviceValidListeners(deviceInfo, false);
             /* Device is disconnected and so we need to close TxManager */
             final ListenableFuture<Void> future = deviceCtx.shuttingDownDataStoreTransactions();
             Futures.addCallback(future, new FutureCallback<Void>() {
 
                 @Override
                 public void onSuccess(final Void result) {
-                    LOG.debug("TxChainManager for device {} is closed successful.", nodeId);
-                    deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceCtx);
+                    LOG.debug("TxChainManager for device {} is closed successful.", deviceInfo.getNodeId());
+                    deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceInfo);
                 }
 
                 @Override
                 public void onFailure(final Throwable t) {
-                    LOG.warn("TxChainManager for device {} failed by closing.", nodeId, t);
-                    deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceCtx);
+                    LOG.warn("TxChainManager for device {} failed by closing.", deviceInfo.getNodeId(), t);
+                    deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceInfo);
                 }
             });
             /* Add timer for Close TxManager because it could fain ind cluster without notification */
-            final TimerTask timerTask = new TimerTask() {
-
-                @Override
-                public void run(final Timeout timeout) throws Exception {
-                    if (!future.isDone()) {
-                        LOG.info("Shutting down TxChain for node {} not completed during 10 sec. Continue anyway.", nodeId);
-                        future.cancel(false);
-                    }
+            final TimerTask timerTask = timeout -> {
+                if (!future.isDone()) {
+                    LOG.info("Shutting down TxChain for node {} not completed during 10 sec. Continue anyway.", deviceInfo.getNodeId());
+                    future.cancel(false);
                 }
             };
             conductor.newTimeout(timerTask, 10, TimeUnit.SECONDS);
@@ -317,7 +308,99 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     @VisibleForTesting
-    void addDeviceContextToMap(final NodeId nodeId, final DeviceContext deviceContext){
-        deviceContexts.put(nodeId, deviceContext);
+    void addDeviceContextToMap(final DeviceInfo deviceInfo, final DeviceContext deviceContext){
+        deviceContexts.put(deviceInfo, deviceContext);
+    }
+
+    @Override
+    public <T extends OFPContext> T gainContext(final DeviceInfo deviceInfo) {
+        return (T) deviceContexts.get(deviceInfo);
+    }
+
+    @Override
+    public ListenableFuture<Void> onClusterRoleChange(final DeviceInfo deviceInfo, final OfpRole role) {
+        DeviceContext deviceContext = conductor.getDeviceContext(deviceInfo);
+        LOG.trace("onClusterRoleChange {} for node:", role, deviceInfo.getNodeId());
+        if (OfpRole.BECOMEMASTER.equals(role)) {
+            return onDeviceTakeClusterLeadership(deviceInfo);
+        }
+        return ((DeviceContextImpl)deviceContext).getTransactionChainManager().deactivateTransactionManager();
     }
+
+    @Override
+    public void addDeviceSynchronizeListener(final DeviceSynchronizeListener deviceSynchronizeListener) {
+        this.deviceSynchronizedListeners.add(deviceSynchronizeListener);
+    }
+
+    @Override
+    public void notifyDeviceSynchronizeListeners(final DeviceInfo deviceInfo, final boolean deviceSynchronized) {
+        for (DeviceSynchronizeListener listener : deviceSynchronizedListeners) {
+            listener.deviceIsSynchronized(deviceInfo, deviceSynchronized);
+        }
+    }
+
+    @Override
+    public void addDeviceValidListener(final DeviceValidListener deviceValidListener) {
+        this.deviceValidListeners.add(deviceValidListener);
+    }
+
+    @Override
+    public void notifyDeviceValidListeners(final DeviceInfo deviceInfo, final boolean deviceValid) {
+        for (DeviceValidListener listener : deviceValidListeners) {
+            listener.deviceIsValid(deviceInfo, deviceValid);
+        }
+    }
+
+    private ListenableFuture<Void> onDeviceTakeClusterLeadership(final DeviceInfo deviceInfo) {
+        LOG.trace("onDeviceTakeClusterLeadership for node: {}", deviceInfo.getNodeId());
+        /* validation */
+        StatisticsContext statisticsContext = conductor.getStatisticsContext(deviceInfo);
+        if (statisticsContext == null) {
+            final String errMsg = String.format("DeviceCtx %s is up but we are missing StatisticsContext", deviceInfo.getDatapathId());
+            LOG.warn(errMsg);
+            return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
+        }
+        DeviceContext deviceContext = conductor.getDeviceContext(deviceInfo);
+        /* Prepare init info collecting */
+        notifyDeviceSynchronizeListeners(deviceInfo, false);
+        ((DeviceContextImpl)deviceContext).getTransactionChainManager().activateTransactionManager();
+        /* Init Collecting NodeInfo */
+        final ListenableFuture<Void> initCollectingDeviceInfo = DeviceInitializationUtils.initializeNodeInformation(
+                deviceContext, switchFeaturesMandatory);
+        /* Init Collecting StatInfo */
+        final ListenableFuture<Boolean> statPollFuture = Futures.transform(initCollectingDeviceInfo,
+                new AsyncFunction<Void, Boolean>() {
+
+                    @Override
+                    public ListenableFuture<Boolean> apply(@Nonnull final Void input) throws Exception {
+                        statisticsContext.statListForCollectingInitialization();
+                        return statisticsContext.initialGatherDynamicData();
+                    }
+                });
+
+        return Futures.transform(statPollFuture, new Function<Boolean, Void>() {
+
+            @Override
+            public Void apply(final Boolean input) {
+                if (ConnectionContext.CONNECTION_STATE.RIP.equals(conductor.gainConnectionStateSafely(deviceInfo))) {
+                    final String errMsg = String.format("We lost connection for Device %s, context has to be closed.",
+                            deviceInfo.getNodeId());
+                    LOG.warn(errMsg);
+                    throw new IllegalStateException(errMsg);
+                }
+                if (!input) {
+                    final String errMsg = String.format("Get Initial Device %s information fails",
+                            deviceInfo.getNodeId());
+                    LOG.warn(errMsg);
+                    throw new IllegalStateException(errMsg);
+                }
+                LOG.debug("Get Initial Device {} information is successful", deviceInfo.getNodeId());
+                notifyDeviceSynchronizeListeners(deviceInfo, true);
+                ((DeviceContextImpl)deviceContext).getTransactionChainManager().initialSubmitWriteTransaction();
+                deviceContext.getDeviceState().setStatisticsPollingEnabledProp(true);
+                return null;
+            }
+        });
+    }
+
 }
index 16864cd33978183ee249314dbfa55eca8800c892..42162c8ab85e528d039cd3c0f07925d784793561 100644 (file)
@@ -8,19 +8,10 @@
 
 package org.opendaylight.openflowplugin.impl.device;
 
-import com.google.common.base.Preconditions;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 /**
  * openflowplugin-impl
@@ -29,16 +20,10 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
  * DeviceState is builded from {@link FeaturesReply} and {@link NodeId}. Both values are inside
  * {@link org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext}
  *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *         <p/>
- *         Created: Mar 29, 2015
  */
 class DeviceStateImpl implements DeviceState {
 
-    private final GetFeaturesOutput featuresOutput;
-    private final NodeId nodeId;
-    private final KeyedInstanceIdentifier<Node, NodeKey> nodeII;
-    private final short version;
+    private final DeviceInfo deviceInfo;
     private boolean valid;
     private boolean meterIsAvailable;
     private boolean groupIsAvailable;
@@ -49,46 +34,17 @@ class DeviceStateImpl implements DeviceState {
     private boolean statPollEnabled;
     private boolean queueStatisticsAvailable;
 
-    public DeviceStateImpl(@CheckForNull final FeaturesReply featuresReply, @Nonnull final NodeId nodeId) {
-        Preconditions.checkArgument(featuresReply != null);
-        featuresOutput = new GetFeaturesOutputBuilder(featuresReply).build();
-        this.nodeId = Preconditions.checkNotNull(nodeId);
-        nodeII = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
-        version = featuresReply.getVersion();
+    public DeviceStateImpl(final DeviceInfo deviceInfo) {
+        this.deviceInfo = deviceInfo;
         statPollEnabled = false;
         deviceSynchronized = false;
     }
 
-    @Override
-    public NodeId getNodeId() {
-        return nodeId;
-    }
-
-    @Override
-    public KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier() {
-        return nodeII;
-    }
-
-    @Override
-    public GetFeaturesOutput getFeatures() {
-        return featuresOutput;
-    }
-
     @Override
     public boolean isValid() {
         return valid;
     }
 
-    @Override
-    public void setValid(final boolean valid) {
-        this.valid = valid;
-    }
-
-    @Override
-    public short getVersion() {
-        return version;
-    }
-
     @Override
     public boolean isMetersAvailable() {
         return meterIsAvailable;
@@ -155,11 +111,6 @@ class DeviceStateImpl implements DeviceState {
 
     }
 
-    @Override
-    public void setDeviceSynchronized(final boolean _deviceSynchronized) {
-        deviceSynchronized = _deviceSynchronized;
-    }
-
     @Override
     public boolean isStatisticsPollingEnabled() {
         return statPollEnabled;
@@ -169,4 +120,18 @@ class DeviceStateImpl implements DeviceState {
     public void setStatisticsPollingEnabledProp(final boolean statPollEnabled) {
         this.statPollEnabled = statPollEnabled;
     }
+
+    @Override
+    public void deviceIsSynchronized(final DeviceInfo deviceInfo, final boolean isSynchronized) {
+        if (this.deviceInfo.equals(deviceInfo)) {
+            this.deviceSynchronized = isSynchronized;
+        }
+    }
+
+    @Override
+    public void deviceIsValid(final DeviceInfo deviceInfo, final boolean isValid) {
+        if (this.deviceInfo.equals(deviceInfo)) {
+            this.valid = isValid;
+        }
+    }
 }
index d85dab8f59632457938b55b0344792df1767e0c4..b782688d02e4dac3f738d506bfa6cadda587d93a 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@@ -55,6 +55,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
 
     private final Object txLock = new Object();
     private final KeyedInstanceIdentifier<Node, NodeKey> nodeII;
+    private final DeviceInfo deviceInfo;
     private final DataBroker dataBroker;
     private final LifecycleConductor conductor;
 
@@ -77,14 +78,15 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
     private TransactionChainManagerStatus transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING;
 
     TransactionChainManager(@Nonnull final DataBroker dataBroker,
-                            @Nonnull final DeviceState deviceState,
+                            @Nonnull final DeviceInfo deviceInfo,
                             @Nonnull final LifecycleConductor conductor) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         this.conductor = Preconditions.checkNotNull(conductor);
-        this.nodeII = Preconditions.checkNotNull(deviceState.getNodeInstanceIdentifier());
+        this.deviceInfo = deviceInfo;
+        this.nodeII = deviceInfo.getNodeInstanceIdentifier();
         this.transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING;
         lastSubmittedFuture = Futures.immediateFuture(null);
-        LOG.debug("created txChainManager for {}", nodeII);
+        LOG.debug("created txChainManager for {}", this.nodeII);
     }
 
     private NodeId nodeId() {
@@ -109,7 +111,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
      * registration for this class instance as {@link TransactionChainListener} to provide possibility a make DS
      * transactions. Call this method for MASTER role only.
      */
-    public void activateTransactionManager() {
+    void activateTransactionManager() {
         LOG.trace("activateTransactionManager for node {} transaction submit is set to {}", nodeId(), submitIsEnabled);
         synchronized (txLock) {
             if (TransactionChainManagerStatus.SLEEPING.equals(transactionChainManagerStatus)) {
@@ -132,7 +134,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
      * Call this method for SLAVE only.
      * @return Future
      */
-    public ListenableFuture<Void> deactivateTransactionManager() {
+    ListenableFuture<Void> deactivateTransactionManager() {
         final ListenableFuture<Void> future;
         synchronized (txLock) {
             if (TransactionChainManagerStatus.WORKING.equals(transactionChainManagerStatus)) {
@@ -192,7 +194,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
                     }
                     if (initCommit) {
                         LOG.error("Initial commit failed. {}", t);
-                        conductor.closeConnection(nodeId());
+                        conductor.closeConnection(deviceInfo);
                     }
                 }
             });
index 8cd41133159384c3f360f5538b085a2086590388..5ddf504fbb066de0a50927683df0f363e042e2c9 100644 (file)
@@ -8,22 +8,20 @@
 package org.opendaylight.openflowplugin.impl.role;
 
 import com.google.common.base.Preconditions;
-
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
-import org.opendaylight.openflowplugin.impl.LifecycleConductorImpl;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,7 +35,7 @@ class RoleContextImpl implements RoleContext {
     private static final Logger LOG = LoggerFactory.getLogger(RoleContextImpl.class);
     private static final int TIMEOUT = 12;
 
-    private final NodeId nodeId;
+    private final DeviceInfo deviceInfo;
     private final EntityOwnershipService entityOwnershipService;
     private volatile EntityOwnershipCandidateRegistration entityOwnershipCandidateRegistration = null;
     private volatile EntityOwnershipCandidateRegistration txEntityOwnershipCandidateRegistration = null;
@@ -50,24 +48,27 @@ class RoleContextImpl implements RoleContext {
     private final Semaphore roleChangeGuard = new Semaphore(1, true);
 
     private final LifecycleConductor conductor;
+    private volatile CONTEXT_STATE contextState;
 
-    public RoleContextImpl(final NodeId nodeId, final EntityOwnershipService entityOwnershipService, final Entity entity, final Entity txEntity, final LifecycleConductor lifecycleConductor) {
+    RoleContextImpl(final DeviceInfo deviceInfo, final EntityOwnershipService entityOwnershipService, final Entity entity, final Entity txEntity, final LifecycleConductor lifecycleConductor) {
         this.entityOwnershipService = entityOwnershipService;
         this.entity = entity;
         this.txEntity = txEntity;
-        this.nodeId = nodeId;
+        this.deviceInfo = deviceInfo;
         this.conductor = lifecycleConductor;
+        contextState = CONTEXT_STATE.INITIALIZATION;
     }
 
     @Override
     public boolean initialization() {
-        LOG.info("Initialization main candidate for node {}", nodeId);
+        LOG.info("Initialization main candidate for node {}", deviceInfo.getNodeId());
+        contextState = CONTEXT_STATE.WORKING;
         return registerCandidate(this.entity);
     }
 
     @Override
     public void unregisterAllCandidates() {
-        LOG.info("Role context closed, unregistering all candidates for ownership for node {}", nodeId);
+        LOG.info("Role context closed, unregistering all candidates for ownership for node {}", deviceInfo.getNodeId());
         if (isMainCandidateRegistered()) {
             unregisterCandidate(this.entity);
         }
@@ -79,7 +80,7 @@ class RoleContextImpl implements RoleContext {
     @Nullable
     @Override
     public <T> RequestContext<T> createRequestContext() {
-        return new AbstractRequestContext<T>(conductor.reserveXidForDeviceMessage(nodeId)) {
+        return new AbstractRequestContext<T>(conductor.reserveXidForDeviceMessage(deviceInfo)) {
             @Override
             public void close() {
             }
@@ -108,8 +109,8 @@ class RoleContextImpl implements RoleContext {
     }
 
     @Override
-    public NodeId getNodeId() {
-        return nodeId;
+    public DeviceInfo getDeviceInfo() {
+        return deviceInfo;
     }
 
     @Override
@@ -186,10 +187,16 @@ class RoleContextImpl implements RoleContext {
 
     @Override
     public void close() {
+        contextState = CONTEXT_STATE.TERMINATION;
         unregisterAllCandidates();
     }
 
     public boolean isMaster(){
         return (txEntityOwnershipCandidateRegistration != null && entityOwnershipCandidateRegistration != null);
     }
+
+    @Override
+    public CONTEXT_STATE getState() {
+        return contextState;
+    }
 }
index ce2040ce5e58c0a754bfe8c2209dc25b7ecab71c..07c74c30e26e54a23c0fe1363fdd2af12bc406f7 100644 (file)
@@ -16,9 +16,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
-import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -29,7 +27,6 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
@@ -40,7 +37,9 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
@@ -69,11 +68,14 @@ import org.slf4j.LoggerFactory;
 public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, ServiceChangeListener {
     private static final Logger LOG = LoggerFactory.getLogger(RoleManagerImpl.class);
 
+    // Maximum limit of timeout retries when cleaning DS, to prevent infinite recursive loops
+    private static final int MAX_CLEAN_DS_RETRIES = 3;
+
     private DeviceInitializationPhaseHandler deviceInitializationPhaseHandler;
     private DeviceTerminationPhaseHandler deviceTerminationPhaseHandler;
     private final DataBroker dataBroker;
     private final EntityOwnershipService entityOwnershipService;
-    private final ConcurrentMap<NodeId, RoleContext> contexts = new ConcurrentHashMap<>();
+    private final ConcurrentMap<DeviceInfo, RoleContext> contexts = new ConcurrentHashMap<>();
     private final ConcurrentMap<Entity, RoleContext> watchingEntities = new ConcurrentHashMap<>();
     private final EntityOwnershipListenerRegistration entityOwnershipListenerRegistration;
     private final EntityOwnershipListenerRegistration txEntityOwnershipListenerRegistration;
@@ -96,15 +98,16 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     }
 
     @Override
-    public void onDeviceContextLevelUp(@CheckForNull final NodeId nodeId) throws Exception {
-        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(nodeId));
-        final RoleContext roleContext = new RoleContextImpl(nodeId, entityOwnershipService, makeEntity(nodeId), makeTxEntity(nodeId), conductor);
+    public void onDeviceContextLevelUp(@CheckForNull final DeviceInfo deviceInfo) throws Exception {
+        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
+        final RoleContext roleContext = new RoleContextImpl(deviceInfo, entityOwnershipService, makeEntity(deviceInfo.getNodeId()), makeTxEntity(deviceInfo.getNodeId()), conductor);
         roleContext.setSalRoleService(new SalRoleServiceImpl(roleContext, deviceContext));
-        Verify.verify(contexts.putIfAbsent(nodeId, roleContext) == null, "Role context for master Node %s is still not closed.", nodeId);
+        Verify.verify(contexts.putIfAbsent(deviceInfo, roleContext) == null, "Role context for master Node %s is still not closed.", deviceInfo.getNodeId());
         makeDeviceRoleChange(OfpRole.BECOMESLAVE, roleContext, true);
-        notifyListenersRoleInitializationDone(roleContext.getNodeId(), roleContext.initialization());
+        /* First start to watch entity so we don't miss any notification, and then try to register in EOS */
         watchingEntities.put(roleContext.getEntity(), roleContext);
-        deviceInitializationPhaseHandler.onDeviceContextLevelUp(nodeId);
+        notifyListenersRoleInitializationDone(roleContext.getDeviceInfo(), roleContext.initialization());
+        deviceInitializationPhaseHandler.onDeviceContextLevelUp(deviceInfo);
     }
 
     @Override
@@ -117,10 +120,10 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
             final RoleContext roleContext = iterator.next();
             watchingEntities.remove(roleContext.getEntity());
             watchingEntities.remove(roleContext.getTxEntity());
-            contexts.remove(roleContext.getNodeId());
+            contexts.remove(roleContext.getDeviceInfo());
             if (roleContext.isTxCandidateRegistered()) {
                 LOG.info("Node {} was holder txEntity, so trying to remove device from operational DS.");
-                removeDeviceFromOperationalDS(roleContext.getNodeId());
+                removeDeviceFromOperationalDS(roleContext.getDeviceInfo(), MAX_CLEAN_DS_RETRIES);
             } else {
                 roleContext.close();
             }
@@ -128,20 +131,19 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     }
 
     @Override
-    public void onDeviceContextLevelDown(final DeviceContext deviceContext) {
-        final NodeId nodeId = deviceContext.getPrimaryConnectionContext().getNodeId();
-        LOG.trace("onDeviceContextLevelDown for node {}", nodeId);
-        final RoleContext roleContext = contexts.get(nodeId);
+    public void onDeviceContextLevelDown(final DeviceInfo deviceInfo) {
+        LOG.trace("onDeviceContextLevelDown for node {}", deviceInfo.getNodeId());
+        final RoleContext roleContext = contexts.get(deviceInfo);
         if (roleContext != null) {
-            LOG.debug("Found roleContext associated to deviceContext: {}, now trying close the roleContext", nodeId);
+            LOG.debug("Found roleContext associated to deviceContext: {}, now trying close the roleContext", deviceInfo.getNodeId());
             if (roleContext.isMainCandidateRegistered()) {
                 roleContext.unregisterCandidate(roleContext.getEntity());
             } else {
-                contexts.remove(nodeId, roleContext);
+                contexts.remove(deviceInfo.getNodeId(), roleContext);
                 roleContext.close();
             }
         }
-        deviceTerminationPhaseHandler.onDeviceContextLevelDown(deviceContext);
+        deviceTerminationPhaseHandler.onDeviceContextLevelDown(deviceInfo);
     }
 
     @VisibleForTesting
@@ -160,10 +162,10 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
         Preconditions.checkArgument(ownershipChange != null);
         final RoleContext roleContext = watchingEntities.get(ownershipChange.getEntity());
 
-        LOG.debug("Received EOS message: wasOwner:{} isOwner:{} hasOwner:{} for entity type {} and node {}",
-                ownershipChange.wasOwner(), ownershipChange.isOwner(), ownershipChange.hasOwner(),
+        LOG.debug("Received EOS message: wasOwner:{} isOwner:{} hasOwner:{} inJeopardy:{} for entity type {} and node {}",
+                ownershipChange.wasOwner(), ownershipChange.isOwner(), ownershipChange.hasOwner(), ownershipChange.inJeopardy(),
                 ownershipChange.getEntity().getType(),
-                roleContext != null ? roleContext.getNodeId() : "-> no watching entity, disregarding notification <-");
+                roleContext != null ? roleContext.getDeviceInfo().getNodeId() : "-> no watching entity, disregarding notification <-");
 
         if (roleContext != null) {
             if (ownershipChange.getEntity().equals(roleContext.getEntity())) {
@@ -182,36 +184,35 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
 
         if (roleContext.isMainCandidateRegistered()) {
             LOG.debug("Main-EntityOwnershipRegistration is active for entity type {} and node {}",
-                    ownershipChange.getEntity().getType(), roleContext.getNodeId());
-            if (!ownershipChange.wasOwner() && ownershipChange.isOwner()) {
+                    ownershipChange.getEntity().getType(), roleContext.getDeviceInfo().getNodeId());
+            if (!ownershipChange.wasOwner() && ownershipChange.isOwner() && !ownershipChange.inJeopardy()) {
                 // SLAVE -> MASTER
-                LOG.debug("SLAVE to MASTER for node {}", roleContext.getNodeId());
+                LOG.debug("SLAVE to MASTER for node {}", roleContext.getDeviceInfo().getNodeId());
                 if (roleContext.registerCandidate(roleContext.getTxEntity())) {
-                    LOG.debug("Starting watching tx entity for node {}", roleContext.getNodeId());
+                    LOG.debug("Starting watching tx entity for node {}", roleContext.getDeviceInfo().getNodeId());
                     watchingEntities.putIfAbsent(roleContext.getTxEntity(), roleContext);
                 }
-            } else if (ownershipChange.wasOwner() && !ownershipChange.isOwner()) {
+            } else if ((ownershipChange.wasOwner() && !ownershipChange.isOwner()) || (ownershipChange.inJeopardy())) {
                 // MASTER -> SLAVE
-                LOG.debug("MASTER to SLAVE for node {}", roleContext.getNodeId());
-                conductor.addOneTimeListenerWhenServicesChangesDone(this, roleContext.getNodeId());
+                LOG.debug("MASTER to SLAVE for node {}", roleContext.getDeviceInfo().getNodeId());
+                conductor.addOneTimeListenerWhenServicesChangesDone(this, roleContext.getDeviceInfo());
                 makeDeviceRoleChange(OfpRole.BECOMESLAVE, roleContext, false);
             }
         } else {
             LOG.debug("Main-EntityOwnershipRegistration is not active for entity type {} and node {}",
-                    ownershipChange.getEntity(), roleContext.getNodeId());
+                    ownershipChange.getEntity(), roleContext.getDeviceInfo().getNodeId());
             watchingEntities.remove(ownershipChange.getEntity(), roleContext);
             if (roleContext.isTxCandidateRegistered()) {
-                LOG.debug("tx candidate still registered for node {}, probably connection lost, trying to unregister tx candidate", roleContext.getNodeId());
+                LOG.debug("tx candidate still registered for node {}, probably connection lost, trying to unregister tx candidate", roleContext.getDeviceInfo().getNodeId());
                 roleContext.unregisterCandidate(roleContext.getTxEntity());
                 if (ownershipChange.wasOwner() && !ownershipChange.isOwner() && !ownershipChange.hasOwner()) {
-                    LOG.debug("Trying to remove from operational node: {}", roleContext.getNodeId());
-                    removeDeviceFromOperationalDS(roleContext.getNodeId());
+                    LOG.debug("Trying to remove from operational node: {}", roleContext.getDeviceInfo().getNodeId());
+                    removeDeviceFromOperationalDS(roleContext.getDeviceInfo(), MAX_CLEAN_DS_RETRIES);
                 }
             } else {
-                final NodeId nodeId = roleContext.getNodeId();
-                contexts.remove(nodeId, roleContext);
+                contexts.remove(roleContext.getDeviceInfo(), roleContext);
                 roleContext.close();
-                conductor.closeConnection(nodeId);
+                conductor.closeConnection(roleContext.getDeviceInfo());
             }
         }
     }
@@ -223,37 +224,42 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
         if (roleContext.isTxCandidateRegistered()) {
             LOG.debug("Tx-EntityOwnershipRegistration is active for entity type {} and node {}",
                     ownershipChange.getEntity().getType(),
-                    roleContext.getNodeId());
-            if (!ownershipChange.wasOwner() && ownershipChange.isOwner()) {
-                // SLAVE -> MASTER
-                LOG.debug("SLAVE to MASTER for node {}", roleContext.getNodeId());
-                makeDeviceRoleChange(OfpRole.BECOMEMASTER, roleContext,false);
-            } else if (ownershipChange.wasOwner() && !ownershipChange.isOwner()) {
-                // MASTER -> SLAVE
-                LOG.debug("MASTER to SLAVE for node {}", roleContext.getNodeId());
-                LOG.warn("Tx-EntityOwnershipRegistration lost leadership entity type {} and node {}",
-                        ownershipChange.getEntity().getType(),roleContext.getNodeId());
-                watchingEntities.remove(roleContext.getTxEntity(), roleContext);
-                watchingEntities.remove(roleContext.getEntity(), roleContext);
-                roleContext.unregisterCandidate(roleContext.getEntity());
+                    roleContext.getDeviceInfo().getNodeId());
+            if (ownershipChange.inJeopardy()) {
+                LOG.warn("Getting 'inJeopardy' flag from EOS. Removing txCandidate and stopping watching txCandidate.");
+                watchingEntities.remove(roleContext.getTxEntity());
                 roleContext.unregisterCandidate(roleContext.getTxEntity());
-                if (!ownershipChange.hasOwner()) {
-                    LOG.debug("Trying to remove from operational node: {}", roleContext.getNodeId());
-                    removeDeviceFromOperationalDS(roleContext.getNodeId());
-                } else {
-                    final NodeId nodeId = roleContext.getNodeId();
-                    contexts.remove(nodeId, roleContext);
-                    roleContext.close();
-                    conductor.closeConnection(nodeId);
+            } else {
+                if (!ownershipChange.wasOwner() && ownershipChange.isOwner()) {
+                    // SLAVE -> MASTER
+                    LOG.debug("SLAVE to MASTER for node {}", roleContext.getDeviceInfo().getNodeId());
+                    makeDeviceRoleChange(OfpRole.BECOMEMASTER, roleContext, false);
+                } else if (ownershipChange.wasOwner() && !ownershipChange.isOwner()) {
+                    // MASTER -> SLAVE
+                    LOG.debug("MASTER to SLAVE for node {}", roleContext.getDeviceInfo().getNodeId());
+                    LOG.warn("Tx-EntityOwnershipRegistration lost leadership entity type {} and node {}",
+                            ownershipChange.getEntity().getType(), roleContext.getDeviceInfo().getNodeId());
+                    watchingEntities.remove(roleContext.getTxEntity(), roleContext);
+                    watchingEntities.remove(roleContext.getEntity(), roleContext);
+                    roleContext.unregisterCandidate(roleContext.getEntity());
+                    roleContext.unregisterCandidate(roleContext.getTxEntity());
+                    if (!ownershipChange.hasOwner()) {
+                        LOG.debug("Trying to remove from operational node: {}", roleContext.getDeviceInfo().getNodeId());
+                        removeDeviceFromOperationalDS(roleContext.getDeviceInfo(), MAX_CLEAN_DS_RETRIES);
+                    } else {
+                        final NodeId nodeId = roleContext.getDeviceInfo().getNodeId();
+                        contexts.remove(roleContext.getDeviceInfo(), roleContext);
+                        roleContext.close();
+                        conductor.closeConnection(roleContext.getDeviceInfo());
+                    }
                 }
             }
         } else {
-            LOG.debug("Tx-EntityOwnershipRegistration is not active for entity {}", ownershipChange.getEntity().getType());
+            LOG.debug("Tx-EntityOwnershipRegistration is not active for entity type {} and node {}", ownershipChange.getEntity().getType(), roleContext.getDeviceInfo().getNodeId());
             watchingEntities.remove(roleContext.getTxEntity(), roleContext);
-            final NodeId nodeId = roleContext.getNodeId();
-            contexts.remove(nodeId, roleContext);
+            contexts.remove(roleContext.getDeviceInfo(), roleContext);
             roleContext.close();
-            conductor.closeConnection(nodeId);
+            conductor.closeConnection(roleContext.getDeviceInfo());
         }
     }
 
@@ -263,23 +269,23 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
         Futures.addCallback(roleChangeFuture, new FutureCallback<RpcResult<SetRoleOutput>>() {
             @Override
             public void onSuccess(@Nullable final RpcResult<SetRoleOutput> setRoleOutputRpcResult) {
-                LOG.info("Role {} successfully set on device {}", role, roleContext.getNodeId());
-                notifyListenersRoleChangeOnDevice(roleContext.getNodeId(), true, role, init);
+                LOG.info("Role {} successfully set on device {}", role, roleContext.getDeviceInfo().getNodeId());
+                notifyListenersRoleChangeOnDevice(roleContext.getDeviceInfo(), true, role, init);
             }
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
-                LOG.warn("Unable to set role {} on device {}", role, roleContext.getNodeId());
-                notifyListenersRoleChangeOnDevice(roleContext.getNodeId(), false, role, init);
+                LOG.warn("Unable to set role {} on device {}", role, roleContext.getDeviceInfo().getNodeId());
+                notifyListenersRoleChangeOnDevice(roleContext.getDeviceInfo(), false, role, init);
             }
         });
     }
 
     @VisibleForTesting
     ListenableFuture<RpcResult<SetRoleOutput>> sendRoleChangeToDevice(final OfpRole newRole, final RoleContext roleContext) {
-        LOG.debug("Sending new role {} to device {}", newRole, roleContext.getNodeId());
+        LOG.debug("Sending new role {} to device {}", newRole, roleContext.getDeviceInfo().getNodeId());
         final Future<RpcResult<SetRoleOutput>> setRoleOutputFuture;
-        final Short version = conductor.gainVersionSafely(roleContext.getNodeId());
+        final Short version = roleContext.getDeviceInfo().getVersion();
         if (null == version) {
             LOG.debug("Device version is null");
             return Futures.immediateFuture(null);
@@ -289,16 +295,12 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
             return Futures.immediateFuture(null);
         } else {
             final SetRoleInput setRoleInput = (new SetRoleInputBuilder()).setControllerRole(newRole)
-                    .setNode(new NodeRef(DeviceStateUtil.createNodeInstanceIdentifier(roleContext.getNodeId()))).build();
+                    .setNode(new NodeRef(DeviceStateUtil.createNodeInstanceIdentifier(roleContext.getDeviceInfo().getNodeId()))).build();
             setRoleOutputFuture = roleContext.getSalRoleService().setRole(setRoleInput);
-            final TimerTask timerTask = new TimerTask() {
-
-                @Override
-                public void run(final Timeout timeout) throws Exception {
-                    if (!setRoleOutputFuture.isDone()) {
-                        LOG.warn("New role {} was not propagated to device {} during 10 sec", newRole, roleContext.getNodeId());
-                        setRoleOutputFuture.cancel(true);
-                    }
+            final TimerTask timerTask = timeout -> {
+                if (!setRoleOutputFuture.isDone()) {
+                    LOG.warn("New role {} was not propagated to device {} during 10 sec", newRole, roleContext.getDeviceInfo().getNodeId());
+                    setRoleOutputFuture.cancel(true);
                 }
             };
             conductor.newTimeout(timerTask, 10, TimeUnit.SECONDS);
@@ -307,17 +309,16 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     }
 
     @VisibleForTesting
-    CheckedFuture<Void, TransactionCommitFailedException> removeDeviceFromOperationalDS(final NodeId nodeId) {
-
+    CheckedFuture<Void, TransactionCommitFailedException> removeDeviceFromOperationalDS(final DeviceInfo deviceInfo, final int numRetries) {
         final WriteTransaction delWtx = dataBroker.newWriteOnlyTransaction();
-        delWtx.delete(LogicalDatastoreType.OPERATIONAL, DeviceStateUtil.createNodeInstanceIdentifier(nodeId));
+        delWtx.delete(LogicalDatastoreType.OPERATIONAL, DeviceStateUtil.createNodeInstanceIdentifier(deviceInfo.getNodeId()));
         final CheckedFuture<Void, TransactionCommitFailedException> delFuture = delWtx.submit();
-        Futures.addCallback(delFuture, new FutureCallback<Void>() {
 
+        Futures.addCallback(delFuture, new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
-                LOG.debug("Delete Node {} was successful", nodeId);
-                final RoleContext roleContext = contexts.remove(nodeId);
+                LOG.debug("Delete Node {} was successful", deviceInfo);
+                final RoleContext roleContext = contexts.remove(deviceInfo);
                 if (roleContext != null) {
                     roleContext.close();
                 }
@@ -325,14 +326,25 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
 
             @Override
             public void onFailure(@Nonnull final Throwable t) {
-                LOG.warn("Delete Node {} failed. {}", nodeId, t);
-                contexts.remove(nodeId);
-                final RoleContext roleContext = contexts.remove(nodeId);
+                // If we have any retries left, we will try to clean the datastore again
+                if (numRetries > 0) {
+                    // We "used" one retry here, so decrement it
+                    final int curRetries = numRetries - 1;
+                    LOG.debug("Delete node {} failed with exception {}. Trying again (retries left: {})", deviceInfo.getNodeId(), t, curRetries);
+                    // Recursive call to this method with "one less" retry
+                    removeDeviceFromOperationalDS(deviceInfo, curRetries);
+                    return;
+                }
+
+                // No retries left, so we will just close the role context, and ignore datastore cleanup
+                LOG.warn("Delete node {} failed with exception {}. No retries left, aborting", deviceInfo.getNodeId(), t);
+                final RoleContext roleContext = contexts.remove(deviceInfo);
                 if (roleContext != null) {
                     roleContext.close();
                 }
             }
         });
+
         return delFuture;
     }
 
@@ -342,9 +354,9 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     }
 
     @Override
-    public void servicesChangeDone(final NodeId nodeId, final boolean success) {
-        LOG.debug("Services stopping done for node {} as " + (success ? "successful" : "unsuccessful"), nodeId);
-        final RoleContext roleContext = contexts.get(nodeId);
+    public void servicesChangeDone(final DeviceInfo deviceInfo, final boolean success) {
+        LOG.debug("Services stopping done for node {} as " + (success ? "successful" : "unsuccessful"), deviceInfo);
+        final RoleContext roleContext = contexts.get(deviceInfo);
         if (null != roleContext) {
             /* Services stopped or failure */
             roleContext.unregisterCandidate(roleContext.getTxEntity());
@@ -352,17 +364,17 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     }
 
     @VisibleForTesting
-    RoleContext getRoleContext(final NodeId nodeId){
-        return contexts.get(nodeId);
+    RoleContext getRoleContext(final DeviceInfo deviceInfo){
+        return contexts.get(deviceInfo);
     }
 
     /**
      * This method is only for testing
      */
     @VisibleForTesting
-    void setRoleContext(NodeId nodeId, RoleContext roleContext){
-        if(!contexts.containsKey(nodeId)) {
-            contexts.put(nodeId, roleContext);
+    void setRoleContext(DeviceInfo deviceInfo, RoleContext roleContext){
+        if(!contexts.containsKey(deviceInfo)) {
+            contexts.put(deviceInfo, roleContext);
         }
     }
 
@@ -373,30 +385,35 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
 
     /**
      * Invoked when initialization phase is done
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      * @param success true if initialization done ok, false otherwise
      */
     @VisibleForTesting
-    void notifyListenersRoleInitializationDone(final NodeId nodeId, final boolean success){
+    void notifyListenersRoleInitializationDone(final DeviceInfo deviceInfo, final boolean success){
         LOG.debug("Notifying registered listeners for role initialization done, no. of listeners {}", listeners.size());
         for (final RoleChangeListener listener : listeners) {
-            listener.roleInitializationDone(nodeId, success);
+            listener.roleInitializationDone(deviceInfo, success);
         }
     }
 
     /**
      * Notifies registered listener on role change. Role is the new role on device
      * If initialization phase is true, we may skip service starting
+     * @param deviceInfo
      * @param success true if role change on device done ok, false otherwise
      * @param role new role meant to be set on device
      * @param initializationPhase if true, then skipp services start
      */
     @VisibleForTesting
-    void notifyListenersRoleChangeOnDevice(final NodeId nodeId, final boolean success, final OfpRole role, final boolean initializationPhase){
+    void notifyListenersRoleChangeOnDevice(final DeviceInfo deviceInfo, final boolean success, final OfpRole role, final boolean initializationPhase){
         LOG.debug("Notifying registered listeners for role change, no. of listeners {}", listeners.size());
         for (final RoleChangeListener listener : listeners) {
-            listener.roleChangeOnDevice(nodeId, success, role, initializationPhase);
+            listener.roleChangeOnDevice(deviceInfo, success, role, initializationPhase);
         }
     }
 
+    @Override
+    public <T extends OFPContext> T gainContext(DeviceInfo deviceInfo) {
+        return (T) contexts.get(deviceInfo);
+    }
 }
index 91feab60f6580be9199c1d9046cb845fde4c3780..c91a1346754ff0168e5025fb40bae76f075ddf74 100644 (file)
@@ -15,15 +15,14 @@ import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.Semaphore;
-
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.XidSequencer;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 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.KeyedInstanceIdentifier;
@@ -31,18 +30,21 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RpcContextImpl implements RpcContext {
+class RpcContextImpl implements RpcContext {
     private static final Logger LOG = LoggerFactory.getLogger(RpcContextImpl.class);
     private final RpcProviderRegistry rpcProviderRegistry;
     private final MessageSpy messageSpy;
     private final Semaphore tracker;
     private final XidSequencer xidSequencer;
+    private boolean isStatisticsRpcEnabled;
+
+    private volatile CONTEXT_STATE contextState;
 
     // TODO: add private Sal salBroker
     private final ConcurrentMap<Class<?>, RoutedRpcRegistration<?>> rpcRegistrations = new ConcurrentHashMap<>();
     private final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
 
-    public RpcContextImpl(final RpcProviderRegistry rpcProviderRegistry,
+    RpcContextImpl(final RpcProviderRegistry rpcProviderRegistry,
                           final XidSequencer xidSequencer,
                           final MessageSpy messageSpy,
                           final int maxRequests,
@@ -53,6 +55,7 @@ public class RpcContextImpl implements RpcContext {
         this.nodeInstanceIdentifier = nodeInstanceIdentifier;
 
         tracker = new Semaphore(maxRequests, true);
+        contextState = CONTEXT_STATE.WORKING;
     }
 
     /**
@@ -85,13 +88,20 @@ public class RpcContextImpl implements RpcContext {
      */
     @Override
     public void close() {
-        for (final Iterator<Entry<Class<?>, RoutedRpcRegistration<?>>> iterator = Iterators
-                .consumingIterator(rpcRegistrations.entrySet().iterator()); iterator.hasNext();) {
-            final RoutedRpcRegistration<?> rpcRegistration = iterator.next().getValue();
-            rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier);
-            rpcRegistration.close();
-            LOG.debug("Closing RPC Registration of service {} for device {}.", rpcRegistration.getServiceType(),
-                    nodeInstanceIdentifier);
+        if (CONTEXT_STATE.TERMINATION.equals(contextState)){
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("RpcContext is already in TERMINATION state.");
+            }
+        } else {
+            contextState = CONTEXT_STATE.TERMINATION;
+            for (final Iterator<Entry<Class<?>, RoutedRpcRegistration<?>>> iterator = Iterators
+                    .consumingIterator(rpcRegistrations.entrySet().iterator()); iterator.hasNext(); ) {
+                final RoutedRpcRegistration<?> rpcRegistration = iterator.next().getValue();
+                rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier);
+                rpcRegistration.close();
+                LOG.debug("Closing RPC Registration of service {} for device {}.", rpcRegistration.getServiceType(),
+                        nodeInstanceIdentifier);
+            }
         }
     }
 
@@ -134,9 +144,22 @@ public class RpcContextImpl implements RpcContext {
     }
 
     @VisibleForTesting
-    public boolean isEmptyRpcRegistrations() {
+    boolean isEmptyRpcRegistrations() {
         return this.rpcRegistrations.isEmpty();
     }
 
+    @Override
+    public void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled) {
+        this.isStatisticsRpcEnabled = isStatisticsRpcEnabled;
+    }
 
+    @Override
+    public boolean isStatisticsRpcEnabled() {
+        return isStatisticsRpcEnabled;
+    }
+
+    @Override
+    public CONTEXT_STATE getState() {
+        return contextState;
+    }
 }
index 3619e66e914d0f15eeaf0ba0940fc4b27ddac12f..645409047168083448dd1fe076bf1a99812217fd 100644 (file)
@@ -14,15 +14,15 @@ import com.google.common.collect.Iterators;
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,7 +33,8 @@ public class RpcManagerImpl implements RpcManager {
     private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
     private final int maxRequestsQuota;
-    private final ConcurrentMap<NodeId, RpcContext> contexts = new ConcurrentHashMap<>();
+    private final ConcurrentMap<DeviceInfo, RpcContext> contexts = new ConcurrentHashMap<>();
+    private boolean isStatisticsRpcEnabled;
 
     private final LifecycleConductor conductor;
 
@@ -51,23 +52,23 @@ public class RpcManagerImpl implements RpcManager {
     }
 
     @Override
-    public void onDeviceContextLevelUp(final NodeId nodeId) throws Exception {
+    public void onDeviceContextLevelUp(final DeviceInfo deviceInfo) throws Exception {
 
-        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(nodeId));
+        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
 
         final RpcContext rpcContext = new RpcContextImpl(
                 rpcProviderRegistry,
                 deviceContext,
                 deviceContext.getMessageSpy(),
                 maxRequestsQuota,
-                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                deviceInfo.getNodeInstanceIdentifier());
 
-        deviceContext.setRpcContext(rpcContext);
+        Verify.verify(contexts.putIfAbsent(deviceInfo, rpcContext) == null, "RpcCtx still not closed for node {}", deviceInfo.getNodeId());
 
-        Verify.verify(contexts.putIfAbsent(nodeId, rpcContext) == null, "RpcCtx still not closed for node {}", nodeId);
+        rpcContext.setStatisticsRpcEnabled(isStatisticsRpcEnabled);
 
         // finish device initialization cycle back to DeviceManager
-        deviceInitPhaseHandler.onDeviceContextLevelUp(nodeId);
+        deviceInitPhaseHandler.onDeviceContextLevelUp(deviceInfo);
     }
 
     @Override
@@ -79,13 +80,13 @@ public class RpcManagerImpl implements RpcManager {
     }
 
     @Override
-    public void onDeviceContextLevelDown(final DeviceContext deviceContext) {
-        final RpcContext removedContext = contexts.remove(deviceContext.getDeviceState().getNodeId());
+    public void onDeviceContextLevelDown(final DeviceInfo deviceInfo) {
+        final RpcContext removedContext = contexts.remove(deviceInfo);
         if (removedContext != null) {
             LOG.info("Unregister RPCs services for device context closure");
             removedContext.close();
         }
-        deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceContext);
+        deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceInfo);
     }
 
     @Override
@@ -97,9 +98,20 @@ public class RpcManagerImpl implements RpcManager {
      * This method is only for testing
      */
     @VisibleForTesting
-    void addRecordToContexts(NodeId nodeId, RpcContext rpcContexts) {
-        if(!contexts.containsKey(nodeId)) {
-            this.contexts.put(nodeId,rpcContexts);
+    void addRecordToContexts(DeviceInfo deviceInfo, RpcContext rpcContexts) {
+        if(!contexts.containsKey(deviceInfo)) {
+            this.contexts.put(deviceInfo,rpcContexts);
         }
     }
+
+    @Override
+    public <T extends OFPContext> T gainContext(DeviceInfo deviceInfo) {
+        return (T) contexts.get(deviceInfo);
+    }
+
+
+    @Override
+    public void setStatisticsRpcEnabled(boolean statisticsRpcEnabled) {
+        isStatisticsRpcEnabled = statisticsRpcEnabled;
+    }
 }
index 0d7020030500355cfdb59ed37a07cae73f2b83b7..e20a48dd6ea89d99d372db6be3afc50b2bf115c7 100644 (file)
@@ -24,8 +24,8 @@ public abstract class AbstractMultipartOnTheFlyService<I> extends AbstractServic
     @Override
     protected final FutureCallback<OfHeader> createCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType) {
         return new MultipartRequestOnTheFlyCallback(context, requestType,
-                getDeviceContext().getMessageSpy(), getEventIdentifier(), getDeviceContext().getDeviceState(),
-                getDeviceContext().getDeviceFlowRegistry(), getDeviceContext());
+                getMessageSpy(), getEventIdentifier(), getDeviceInfo(),
+                getDeviceContext().getDeviceFlowRegistry(), getTxFacade());
     }
 
 
index f1bdbf116da899234e9f5a02b5c49e90875194a6..73f098da9eb4241931cae4fc64709f503a85e0cc 100644 (file)
@@ -16,14 +16,14 @@ import java.math.BigInteger;
 import javax.annotation.Nonnull;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceRegistry;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.common.RpcError;
@@ -42,19 +42,16 @@ abstract class AbstractService<I, O> {
     private final RequestContextStack requestContextStack;
     private final DeviceContext deviceContext;
     private final MessageSpy messageSpy;
-    private final NodeId nodeId;
     private EventIdentifier eventIdentifier;
 
-    public AbstractService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        final DeviceState deviceState = deviceContext.getDeviceState();
-        final GetFeaturesOutput features = deviceState.getFeatures();
+    AbstractService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        final DeviceInfo deviceInfo = deviceContext.getDeviceInfo();
 
         this.requestContextStack = requestContextStack;
         this.deviceContext = deviceContext;
-        this.datapathId = features.getDatapathId();
-        this.version = features.getVersion();
+        this.datapathId = deviceInfo.getDatapathId();
+        this.version = deviceInfo.getVersion();
         this.messageSpy = deviceContext.getMessageSpy();
-        this.nodeId = deviceState.getNodeId();
     }
 
     public EventIdentifier getEventIdentifier() {
@@ -73,18 +70,21 @@ abstract class AbstractService<I, O> {
         return datapathId;
     }
 
-    public NodeId getNodeId() {
-        return nodeId;
-    }
-
     public RequestContextStack getRequestContextStack() {
         return requestContextStack;
     }
 
+    @Deprecated
     public DeviceContext getDeviceContext() {
         return deviceContext;
     }
 
+    protected DeviceRegistry getDeviceRegistry() {return deviceContext;}
+
+    public DeviceInfo getDeviceInfo() {return deviceContext.getDeviceInfo();}
+
+    public TxFacade getTxFacade() {return deviceContext;}
+
     public MessageSpy getMessageSpy() {
         return messageSpy;
     }
index c00d092f96273335af1233e70141f3213a3a2ce5..dcb445b11e03db4717fcc91d1ab4f5b865730695 100644 (file)
@@ -12,8 +12,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.List;
-
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
@@ -36,7 +35,7 @@ import org.slf4j.LoggerFactory;
 final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<List<MultipartReply>> {
     private static final Logger LOG = LoggerFactory.getLogger(MultipartRequestOnTheFlyCallback.class);
     private static final SinglePurposeMultipartReplyTranslator MULTIPART_REPLY_TRANSLATOR = new SinglePurposeMultipartReplyTranslator();
-    private final DeviceState deviceState;
+    private final DeviceInfo deviceInfo;
     private final DeviceFlowRegistry registry;
     private boolean virgin = true;
     private boolean finished = false;
@@ -48,17 +47,17 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
                                             final Class<?> requestType,
                                             final MessageSpy messageSpy,
                                             final EventIdentifier eventIdentifier,
-                                            final DeviceState deviceState,
+                                            final DeviceInfo deviceInfo,
                                             final DeviceFlowRegistry registry,
                                             final TxFacade txFacade) {
         super(context, requestType, messageSpy, eventIdentifier);
 
-        this.deviceState = deviceState;
+        this.deviceInfo = deviceInfo;
         this.registry = registry;
         this.txFacade = txFacade;
 
         //TODO: this is focused on flow stats only - need more general approach if used for more than flow stats
-        doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceState.getNodeId().toString());
+        doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceInfo.getNodeId().toString());
     }
 
     public EventIdentifier getDoneEventIdentifier() {
@@ -90,13 +89,13 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
 
             final MultipartReply singleReply = multipartReply;
             final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
-                    deviceState.getFeatures().getDatapathId(), deviceState.getFeatures().getVersion(), singleReply);
+                    deviceInfo.getDatapathId(), deviceInfo.getVersion(), singleReply);
             final Iterable<? extends DataObject> allMultipartData = multipartDataList;
 
             //TODO: following part is focused on flow stats only - need more general approach if used for more than flow stats
             ListenableFuture<Void> future;
             if (virgin) {
-                future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceState, registry, txFacade);
+                future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, registry, txFacade);
                 virgin = false;
             } else {
                 future = Futures.immediateFuture(null);
@@ -107,7 +106,7 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
                 @Override
                 public Void apply(final Void input) {
                     StatisticsGatheringUtils.writeFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData,
-                            deviceState, registry, txFacade);
+                            deviceInfo, registry, txFacade);
 
                     if (!multipartReply.getFlags().isOFPMPFREQMORE()) {
                         endCollecting();
@@ -123,8 +122,8 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
         EventsTimeCounter.markEnd(getEventIdentifier());
         final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build();
         spyMessage(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);
-        setResult(rpcResult);
         txFacade.submitTransaction();
+        setResult(rpcResult);
         finished = true;
     }
 }
index c677c53a68247079504cb9a8664125eb798020f6..c0c0a6544f190c69cae2bb3fc0dd157a95b5b6b6 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.role.RoleChangeException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;
@@ -54,7 +53,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
     }
 
     public Future<BigInteger> getGenerationIdFromDevice(final Short version) {
-        LOG.info("getGenerationIdFromDevice called for device:{}", getNodeId().getValue());
+        LOG.info("getGenerationIdFromDevice called for device:{}", getDeviceInfo().getNodeId().getValue());
 
         // send a dummy no-change role request to get the generation-id of the switch
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
@@ -74,7 +73,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
                         finalFuture.set(roleRequestOutput.getGenerationId());
                     } else {
                         LOG.info("roleRequestOutput is null in getGenerationIdFromDevice");
-                        finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + getNodeId().getValue()));
+                        finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + getDeviceInfo().getNodeId().getValue()));
                     }
 
                 } else {
@@ -97,7 +96,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
 
     public Future<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole, final Short version, final BigInteger generationId) {
         LOG.info("submitRoleChange called for device:{}, role:{}",
-                getNodeId(), ofpRole);
+                getDeviceInfo().getNodeId(), ofpRole);
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
         roleRequestInputBuilder.setRole(toOFJavaRole(ofpRole));
         roleRequestInputBuilder.setVersion(version);
@@ -110,7 +109,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
             @Override
             public void onSuccess(final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
                 LOG.info("submitRoleChange onSuccess for device:{}, role:{}",
-                        getNodeId(), ofpRole);
+                        getDeviceInfo().getNodeId(), ofpRole);
                 final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
                 final Collection<RpcError> rpcErrors = roleRequestOutputRpcResult.getErrors();
                 if (roleRequestOutput != null) {
@@ -132,7 +131,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
             @Override
             public void onFailure(final Throwable throwable) {
                 LOG.error("submitRoleChange onFailure for device:{}, role:{}",
-                        getNodeId(), ofpRole, throwable);
+                        getDeviceInfo().getNodeId(), ofpRole, throwable);
                 finalFuture.setException(throwable);
             }
         });
index c2b3dc122cafb466be890f9850b030b2d5628a11..6baeda6c3a784ead8f9730620a20a841c271389f 100644 (file)
@@ -12,8 +12,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageToOFJava;
-import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper;
 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.extension.api.exception.ConversionException;
 import org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SalExperimenterMessageService;
@@ -27,16 +27,20 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public class SalExperimenterMessageServiceImpl extends AbstractVoidService<SendExperimenterInput> implements SalExperimenterMessageService {
 
-    public SalExperimenterMessageServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    private final ExtensionConverterProvider extensionConverterProvider;
+
+    public SalExperimenterMessageServiceImpl(final RequestContextStack requestContextStack,
+                                             final DeviceContext deviceContext,
+                                             final ExtensionConverterProvider extensionConverterProvider) {
         super(requestContextStack, deviceContext);
+        this.extensionConverterProvider = extensionConverterProvider;
     }
 
     @Override
     protected OfHeader buildRequest(Xid xid, SendExperimenterInput input) throws ConversionException {
         final TypeVersionKey key = new TypeVersionKey(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
         final ConvertorMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter =
-                ((ExtensionConverterProviderKeeper) getDeviceContext())
-                        .getExtensionConverterProvider().getMessageConverter(key);
+                extensionConverterProvider.getMessageConverter(key);
 
         if (messageConverter == null) {
             throw new ConverterNotFoundException(key.toString());
index d89b59781cb53b3e4f6d9655182541062618d11e..cf2a160998321f1077b310cbbf79b142acebecb7 100644 (file)
@@ -97,7 +97,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     }
                     if (itemLifecycleListener != null) {
                         KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                         final FlowBuilder flowBuilder = new FlowBuilder(input).setId(flowDescriptor.getFlowId());
                         itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
                     }
@@ -136,7 +136,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                                 deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
                         if (flowDescriptor != null) {
                             KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                             itemLifecycleListener.onRemoved(flowPath);
                         }
                     }
@@ -203,7 +203,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     final FlowDescriptor flowDescriptor = deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
                     if (flowDescriptor != null) {
                         KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                         itemLifecycleListener.onRemoved(flowPath);
                     }
                 }
@@ -215,7 +215,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
 
                     if (itemLifecycleListener != null) {
                         KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                         final FlowBuilder flowBuilder = new FlowBuilder(input.getUpdatedFlow()).setId(flowDescriptor.getFlowId());
                         itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
                     }
index 0179f8e3f09112ebe945144dab64893f2b3b78f7..cdbc10b6f08f0083cf503a734154994c0ca60c6a 100644 (file)
@@ -7,24 +7,17 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import java.util.Collection;
-import java.util.concurrent.Future;
-
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
@@ -44,8 +37,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nullable;
-
 public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource {
     private static final Logger LOG = LoggerFactory.getLogger(SalGroupServiceImpl.class);
     private final GroupService<AddGroupInput, AddGroupOutput> addGroup;
@@ -68,7 +59,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
-        addGroup.getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
+        addGroup.getDeviceRegistry().getDeviceGroupRegistry().store(input.getGroupId());
         final ListenableFuture<RpcResult<AddGroupOutput>> resultFuture = addGroup.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddGroupOutput>>() {
             @Override
@@ -124,7 +115,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
-        removeGroup.getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+        removeGroup.getDeviceRegistry().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
         final ListenableFuture<RpcResult<RemoveGroupOutput>> resultFuture = removeGroup.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<RemoveGroupOutput>>() {
             @Override
@@ -153,7 +144,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
                     = createGroupPath(groupId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onRemoved(groupPath);
         }
     }
@@ -162,7 +153,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
                     = createGroupPath(groupId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onAdded(groupPath, new GroupBuilder(data).build());
         }
     }
index 946669043a64676799b0c3ad28689bd403c3d086..b053d99cb8fc361361d93ccbebe1d0be955b5f36 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import java.util.Collection;
-import java.util.concurrent.Future;
-
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
@@ -20,7 +20,6 @@ import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleLi
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
@@ -38,8 +37,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nullable;
-
 public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource {
     private static final Logger LOG = LoggerFactory.getLogger(SalMeterServiceImpl.class);
     private final MeterService<AddMeterInput, AddMeterOutput> addMeter;
@@ -62,7 +59,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
-        addMeter.getDeviceContext().getDeviceMeterRegistry().store(input.getMeterId());
+        addMeter.getDeviceRegistry().getDeviceMeterRegistry().store(input.getMeterId());
 
         final ListenableFuture<RpcResult<AddMeterOutput>> resultFuture = addMeter.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddMeterOutput>>() {
@@ -122,7 +119,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
-        removeMeter.getDeviceContext().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
+        removeMeter.getDeviceRegistry().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
         final ListenableFuture<RpcResult<RemoveMeterOutput>> resultFuture = removeMeter.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<RemoveMeterOutput>>() {
 
@@ -152,7 +149,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> meterPath
                     = createMeterPath(meterId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onRemoved(meterPath);
         }
     }
@@ -161,7 +158,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> groupPath
                     = createMeterPath(meterId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onAdded(groupPath, new MeterBuilder(data).build());
         }
     }
index 32aa20c843413c61f63c9c9ac28f11d45c71c877..ed500030d018ce42676a32fe9707225ddbfbf03e 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.role.RoleChangeException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
@@ -158,14 +157,14 @@ public final class SalRoleServiceImpl extends AbstractSimpleService<SetRoleInput
     }
 
     private ListenableFuture<RpcResult<SetRoleOutput>> tryToChangeRole(final OfpRole role) {
-        LOG.info("RoleChangeTask called on device:{} OFPRole:{}", getNodeId().getValue(), role);
+        LOG.info("RoleChangeTask called on device:{} OFPRole:{}", getDeviceInfo().getNodeId().getValue(), role);
 
         final Future<BigInteger> generationFuture = roleService.getGenerationIdFromDevice(getVersion());
 
         return Futures.transform(JdkFutureAdapters.listenInPoolThread(generationFuture), (AsyncFunction<BigInteger, RpcResult<SetRoleOutput>>) generationId -> {
-            LOG.debug("RoleChangeTask, GenerationIdFromDevice from device {} is {}", getNodeId().getValue(), generationId);
+            LOG.debug("RoleChangeTask, GenerationIdFromDevice from device {} is {}", getDeviceInfo().getNodeId().getValue(), generationId);
             final BigInteger nextGenerationId = getNextGenerationId(generationId);
-            LOG.debug("nextGenerationId received from device:{} is {}", getNodeId().getValue(), nextGenerationId);
+            LOG.debug("nextGenerationId received from device:{} is {}", getDeviceInfo().getNodeId().getValue(), nextGenerationId);
             final Future<RpcResult<SetRoleOutput>> submitRoleFuture = roleService.submitRoleChange(role, getVersion(), nextGenerationId);
             return JdkFutureAdapters.listenInPoolThread(submitRoleFuture);
         });
index 90d5dc62cf24ad8573559705d5f579023a6355b2..bd38f2836a82402d362a66cac1dd7b137ecec609 100644 (file)
@@ -120,7 +120,7 @@ public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTa
         final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeatures = convertToSalTableFeatures(multipartReplies);
 
         final InstanceIdentifier<FlowCapableNode> flowCapableNodeII = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, new NodeKey(getNodeId())).augmentation(FlowCapableNode.class);
+                .child(Node.class, new NodeKey(getDeviceInfo().getNodeId())).augmentation(FlowCapableNode.class);
         for (final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
             final Short tableId = tableFeatureData.getTableId();
             final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
index 6c8d587854bb42d827dccaa50427e3a449201445..e58ea89b17ff0f09662d2951c10ba636715a2eed 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.statistics;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
@@ -53,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
index eafdc7a4aaf53c144ca115520458f5b870accd3f..362fbb6b1300dddf2777fc56e46cebf5e3ea92e1 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.impl.statistics;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterators;
@@ -23,12 +22,15 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
@@ -39,12 +41,11 @@ import org.opendaylight.openflowplugin.impl.rpc.listener.ItemLifecycleListenerIm
 import org.opendaylight.openflowplugin.impl.services.RequestContextUtil;
 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringOnTheFlyService;
 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class StatisticsContextImpl implements StatisticsContext {
+class StatisticsContextImpl implements StatisticsContext {
 
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsContextImpl.class);
     private static final String CONNECTION_CLOSED = "Connection closed.";
@@ -63,12 +64,11 @@ public class StatisticsContextImpl implements StatisticsContext {
     private StatisticsGatheringOnTheFlyService statisticsGatheringOnTheFlyService;
     private Timeout pollTimeout;
 
-    private final LifecycleConductor conductor;
     private volatile boolean schedulingEnabled;
+    private volatile CONTEXT_STATE contextState;
 
-    public StatisticsContextImpl(@CheckForNull final NodeId nodeId, final boolean shuttingDownStatisticsPolling, final LifecycleConductor lifecycleConductor) {
-        this.conductor = lifecycleConductor;
-        this.deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(nodeId));
+    StatisticsContextImpl(@CheckForNull final DeviceInfo deviceInfo, final boolean shuttingDownStatisticsPolling, final LifecycleConductor lifecycleConductor) {
+        this.deviceContext = Preconditions.checkNotNull(lifecycleConductor.getDeviceContext(deviceInfo));
         this.devState = Preconditions.checkNotNull(deviceContext.getDeviceState());
         this.shuttingDownStatisticsPolling = shuttingDownStatisticsPolling;
         emptyFuture = Futures.immediateFuture(false);
@@ -76,7 +76,7 @@ public class StatisticsContextImpl implements StatisticsContext {
         statisticsGatheringOnTheFlyService = new StatisticsGatheringOnTheFlyService(this, deviceContext);
         itemLifeCycleListener = new ItemLifecycleListenerImpl(deviceContext);
         statListForCollectingInitialization();
-        this.deviceContext.setStatisticsContext(StatisticsContextImpl.this);
+        contextState = CONTEXT_STATE.WORKING;
     }
 
     @Override
@@ -107,10 +107,20 @@ public class StatisticsContextImpl implements StatisticsContext {
         }
     }
 
+
+    @Override
+    public ListenableFuture<Boolean> initialGatherDynamicData() {
+        return gatherDynamicData(true);
+    }
+
     @Override
-    public ListenableFuture<Boolean> gatherDynamicData() {
+    public ListenableFuture<Boolean> gatherDynamicData(){
+        return gatherDynamicData(false);
+    }
+
+    private ListenableFuture<Boolean> gatherDynamicData(final boolean initial) {
         if (shuttingDownStatisticsPolling) {
-            LOG.debug("Statistics for device {} is not enabled.", deviceContext.getDeviceState().getNodeId());
+            LOG.debug("Statistics for device {} is not enabled.", deviceContext.getDeviceInfo().getNodeId());
             return Futures.immediateFuture(Boolean.TRUE);
         }
         final ListenableFuture<Boolean> errorResultFuture = deviceConnectionCheck();
@@ -124,7 +134,7 @@ public class StatisticsContextImpl implements StatisticsContext {
             // write start timestamp to state snapshot container
             StatisticsGatheringUtils.markDeviceStateSnapshotStart(deviceContext);
 
-            statChainFuture(statIterator, settableStatResultFuture);
+            statChainFuture(statIterator, settableStatResultFuture, initial);
 
             // write end timestamp to state snapshot container
             Futures.addCallback(settableStatResultFuture, new FutureCallback<Boolean>() {
@@ -141,10 +151,10 @@ public class StatisticsContextImpl implements StatisticsContext {
         }
     }
 
-    private ListenableFuture<Boolean> chooseStat(final MultipartType multipartType){
+    private ListenableFuture<Boolean> chooseStat(final MultipartType multipartType, final boolean initial){
         switch (multipartType) {
             case OFPMPFLOW:
-                return collectFlowStatistics(multipartType);
+                return collectFlowStatistics(multipartType, initial);
             case OFPMPTABLE:
                 return collectTableStatistics(multipartType);
             case OFPMPPORTSTATS:
@@ -180,13 +190,20 @@ public class StatisticsContextImpl implements StatisticsContext {
 
     @Override
     public void close() {
-        schedulingEnabled = false;
-        for (final Iterator<RequestContext<?>> iterator = Iterators.consumingIterator(requestContexts.iterator());
-                iterator.hasNext();) {
-            RequestContextUtil.closeRequestContextWithRpcError(iterator.next(), CONNECTION_CLOSED);
-        }
-        if (null != pollTimeout && !pollTimeout.isExpired()) {
-            pollTimeout.cancel();
+        if (CONTEXT_STATE.TERMINATION.equals(contextState)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Statistics context is already in state TERMINATION.");
+            }
+        } else {
+            contextState = CONTEXT_STATE.TERMINATION;
+            schedulingEnabled = false;
+            for (final Iterator<RequestContext<?>> iterator = Iterators.consumingIterator(requestContexts.iterator());
+                 iterator.hasNext(); ) {
+                RequestContextUtil.closeRequestContextWithRpcError(iterator.next(), CONNECTION_CLOSED);
+            }
+            if (null != pollTimeout && !pollTimeout.isExpired()) {
+                pollTimeout.cancel();
+            }
         }
     }
 
@@ -207,31 +224,31 @@ public class StatisticsContextImpl implements StatisticsContext {
 
     @Override
     public Optional<Timeout> getPollTimeout() {
-        return Optional.fromNullable(pollTimeout);
+        return Optional.ofNullable(pollTimeout);
     }
 
-    private void statChainFuture(final Iterator<MultipartType> iterator, final SettableFuture<Boolean> resultFuture) {
+    private void statChainFuture(final Iterator<MultipartType> iterator, final SettableFuture<Boolean> resultFuture, final boolean initial) {
         if (ConnectionContext.CONNECTION_STATE.RIP.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
             final String errMsg = String.format("Device connection is closed for Node : %s.",
-                    deviceContext.getDeviceState().getNodeId());
+                    deviceContext.getDeviceInfo().getNodeId());
             LOG.debug(errMsg);
             resultFuture.setException(new IllegalStateException(errMsg));
             return;
         }
         if ( ! iterator.hasNext()) {
             resultFuture.set(Boolean.TRUE);
-            LOG.debug("Stats collection successfully finished for node {}", deviceContext.getDeviceState().getNodeId());
+            LOG.debug("Stats collection successfully finished for node {}", deviceContext.getDeviceInfo().getNodeId());
             return;
         }
 
         final MultipartType nextType = iterator.next();
-        LOG.debug("Stats iterating to next type for node {} of type {}", deviceContext.getDeviceState().getNodeId(), nextType);
+        LOG.debug("Stats iterating to next type for node {} of type {}", deviceContext.getDeviceInfo().getNodeId(), nextType);
 
-        final ListenableFuture<Boolean> deviceStatisticsCollectionFuture = chooseStat(nextType);
+        final ListenableFuture<Boolean> deviceStatisticsCollectionFuture = chooseStat(nextType, initial);
         Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
             @Override
             public void onSuccess(final Boolean result) {
-                statChainFuture(iterator, resultFuture);
+                statChainFuture(iterator, resultFuture, initial);
             }
             @Override
             public void onFailure(@Nonnull final Throwable t) {
@@ -249,7 +266,7 @@ public class StatisticsContextImpl implements StatisticsContext {
     @VisibleForTesting
     ListenableFuture<Boolean> deviceConnectionCheck() {
         if (!ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
-            ListenableFuture<Boolean> resultingFuture = SettableFuture.create();
+            ListenableFuture<Boolean> resultingFuture;
             switch (deviceContext.getPrimaryConnectionContext().getConnectionState()) {
                 case RIP:
                     final String errMsg = String.format("Device connection doesn't exist anymore. Primary connection status : %s",
@@ -265,44 +282,85 @@ public class StatisticsContextImpl implements StatisticsContext {
         return null;
     }
 
-    private ListenableFuture<Boolean> collectFlowStatistics(final MultipartType multipartType) {
+    //TODO: Refactor twice sending deviceContext into gatheringStatistics
+    private ListenableFuture<Boolean> collectFlowStatistics(final MultipartType multipartType, final boolean initial) {
         return devState.isFlowStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringOnTheFlyService, deviceContext, /*MultipartType.OFPMPFLOW*/ multipartType) : emptyFuture;
+                statisticsGatheringOnTheFlyService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPFLOW*/ multipartType,
+                deviceContext,
+                deviceContext,
+                initial) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectTableStatistics(final MultipartType multipartType) {
         return devState.isTableStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPTABLE*/ multipartType) : emptyFuture;
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPTABLE*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectPortStatistics(final MultipartType multipartType) {
         return devState.isPortStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPPORTSTATS*/ multipartType) : emptyFuture;
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPPORTSTATS*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectQueueStatistics(final MultipartType multipartType) {
-        return devState.isQueueStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPQUEUE*/ multipartType) : emptyFuture;
+        return !devState.isQueueStatisticsAvailable() ? emptyFuture : StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPQUEUE*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false);
     }
 
     private ListenableFuture<Boolean> collectGroupDescStatistics(final MultipartType multipartType) {
         return devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPGROUPDESC*/ multipartType) : emptyFuture;
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPGROUPDESC*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectGroupStatistics(final MultipartType multipartType) {
         return devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPGROUP*/ multipartType) : emptyFuture;
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPGROUP*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectMeterConfigStatistics(final MultipartType multipartType) {
         return devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPMETERCONFIG*/ multipartType) : emptyFuture;
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPMETERCONFIG*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectMeterStatistics(final MultipartType multipartType) {
         return devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(
-                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPMETER*/ multipartType) : emptyFuture;
+                statisticsGatheringService,
+                deviceContext.getDeviceInfo(),
+                /*MultipartType.OFPMPMETER*/ multipartType,
+                deviceContext,
+                deviceContext,
+                false) : emptyFuture;
     }
 
     @VisibleForTesting
@@ -321,9 +379,8 @@ public class StatisticsContextImpl implements StatisticsContext {
         return itemLifeCycleListener;
     }
 
-
     @Override
-    public DeviceContext getDeviceContext() {
-        return deviceContext;
+    public CONTEXT_STATE getState() {
+        return contextState;
     }
 }
index 4933f28374008e089049c67978ba84ae55fe0756..afe4d0085a704ae165c3c870da2ee33f424c7c2d 100644 (file)
@@ -26,10 +26,13 @@ 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.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceRegistry;
 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
+import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
+import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
@@ -109,47 +112,53 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 2.4.2015.
+ * Utils for gatherig statistics
  */
 public final class StatisticsGatheringUtils {
 
-    public static String DATE_AND_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
+    private static String DATE_AND_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
 
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringUtils.class);
     private static final SinglePurposeMultipartReplyTranslator MULTIPART_REPLY_TRANSLATOR = new SinglePurposeMultipartReplyTranslator();
-    public static final String QUEUE2_REQCTX = "QUEUE2REQCTX-";
+    private static final String QUEUE2_REQCTX = "QUEUE2REQCTX-";
 
     private StatisticsGatheringUtils() {
         throw new IllegalStateException("This class should not be instantiated.");
     }
 
-
-    public static ListenableFuture<Boolean> gatherStatistics(final StatisticsGatherer statisticsGatheringService,
-                                                             final DeviceContext deviceContext,
-                                                             final MultipartType type) {
-        final String deviceId = deviceContext.getPrimaryConnectionContext().getNodeId().toString();
+    //TODO: Flow-,Group- and Meter- registry should be not in device context, consider move it in separate class
+    static ListenableFuture<Boolean> gatherStatistics(final StatisticsGatherer statisticsGatheringService,
+                                                      final DeviceInfo deviceInfo,
+                                                      final MultipartType type,
+                                                      final TxFacade txFacade,
+                                                      final DeviceRegistry registry,
+                                                      final Boolean initial) {
         EventIdentifier wholeProcessEventIdentifier = null;
         if (MultipartType.OFPMPFLOW.equals(type)) {
-            wholeProcessEventIdentifier = new EventIdentifier(type.toString(), deviceId);
+            wholeProcessEventIdentifier = new EventIdentifier(type.toString(), deviceInfo.getNodeId().getValue());
             EventsTimeCounter.markStart(wholeProcessEventIdentifier);
         }
-        final EventIdentifier ofpQueuToRequestContextEventIdentifier = new EventIdentifier(QUEUE2_REQCTX + type.toString(), deviceId);
+        final EventIdentifier ofpQueuToRequestContextEventIdentifier = new EventIdentifier(QUEUE2_REQCTX + type.toString(), deviceInfo.getNodeId().toString());
         final ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
                 JdkFutureAdapters.listenInPoolThread(statisticsGatheringService.getStatisticsOfType(
                         ofpQueuToRequestContextEventIdentifier, type));
-        return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext, wholeProcessEventIdentifier, type);
+        return transformAndStoreStatisticsData(statisticsDataInFuture, deviceInfo, wholeProcessEventIdentifier, type, txFacade, registry, initial);
     }
 
     private static ListenableFuture<Boolean> transformAndStoreStatisticsData(final ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture,
-                                                                             final DeviceContext deviceContext,
-                                                                             final EventIdentifier eventIdentifier, final MultipartType type) {
+                                                                             final DeviceInfo deviceInfo,
+                                                                             final EventIdentifier eventIdentifier,
+                                                                             final MultipartType type,
+                                                                             final TxFacade txFacade,
+                                                                             final DeviceRegistry registry,
+                                                                             final boolean initial) {
         return Futures.transform(statisticsDataInFuture, new AsyncFunction<RpcResult<List<MultipartReply>>, Boolean>() {
             @Nullable
             @Override
             public ListenableFuture<Boolean> apply(final RpcResult<List<MultipartReply>> rpcResult) {
                 boolean isMultipartProcessed = Boolean.TRUE;
                 if (rpcResult.isSuccessful()) {
-                    LOG.debug("Stats reply successfully received for node {} of type {}", deviceContext.getDeviceState().getNodeId(), type);
+                    LOG.debug("Stats reply successfully received for node {} of type {}", deviceInfo.getNodeId(), type);
 
                     // TODO: in case the result value is null then multipart data probably got processed on the fly -
                     // TODO: this contract should by clearly stated and enforced - now simple true value is returned
@@ -161,56 +170,56 @@ public final class StatisticsGatheringUtils {
                         try {
                             for (final MultipartReply singleReply : rpcResult.getResult()) {
                                 final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
-                                        deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
-                                        deviceContext.getPrimaryConnectionContext().getFeatures().getVersion(), singleReply);
+                                        deviceInfo.getDatapathId(),
+                                        deviceInfo.getVersion(), singleReply);
                                 multipartData = multipartDataList.get(0);
                                 allMultipartData = Iterables.concat(allMultipartData, multipartDataList);
                             }
                         } catch (final Exception e) {
                             LOG.warn("stats processing of type {} for node {} failed during transfomation step",
-                                    type, deviceContext.getDeviceState().getNodeId(), e);
+                                    type, deviceInfo.getNodeId(), e);
                             return Futures.immediateFailedFuture(e);
                         }
 
 
                         try {
                             if (multipartData instanceof GroupStatisticsUpdated) {
-                                processGroupStatistics((Iterable<GroupStatisticsUpdated>) allMultipartData, deviceContext);
+                                processGroupStatistics((Iterable<GroupStatisticsUpdated>) allMultipartData, deviceInfo, txFacade);
                             } else if (multipartData instanceof MeterStatisticsUpdated) {
-                                processMetersStatistics((Iterable<MeterStatisticsUpdated>) allMultipartData, deviceContext);
+                                processMetersStatistics((Iterable<MeterStatisticsUpdated>) allMultipartData, deviceInfo, txFacade);
                             } else if (multipartData instanceof NodeConnectorStatisticsUpdate) {
-                                processNodeConnectorStatistics((Iterable<NodeConnectorStatisticsUpdate>) allMultipartData, deviceContext);
+                                processNodeConnectorStatistics((Iterable<NodeConnectorStatisticsUpdate>) allMultipartData, deviceInfo, txFacade);
                             } else if (multipartData instanceof FlowTableStatisticsUpdate) {
-                                processFlowTableStatistics((Iterable<FlowTableStatisticsUpdate>) allMultipartData, deviceContext);
+                                processFlowTableStatistics((Iterable<FlowTableStatisticsUpdate>) allMultipartData, deviceInfo, txFacade);
                             } else if (multipartData instanceof QueueStatisticsUpdate) {
-                                processQueueStatistics((Iterable<QueueStatisticsUpdate>) allMultipartData, deviceContext);
+                                processQueueStatistics((Iterable<QueueStatisticsUpdate>) allMultipartData, deviceInfo, txFacade);
                             } else if (multipartData instanceof FlowsStatisticsUpdate) {
                                 /* FlowStat Processing is realized by NettyThread only by initPhase, otherwise it is realized
                                  * by MD-SAL thread */
-                                return processFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData, deviceContext, eventIdentifier);
+                                return processFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData, deviceInfo, txFacade, registry.getDeviceFlowRegistry(), initial, eventIdentifier);
 
                             } else if (multipartData instanceof GroupDescStatsUpdated) {
-                                processGroupDescStats((Iterable<GroupDescStatsUpdated>) allMultipartData, deviceContext);
+                                processGroupDescStats((Iterable<GroupDescStatsUpdated>) allMultipartData, deviceInfo, txFacade, registry.getDeviceGroupRegistry());
                             } else if (multipartData instanceof MeterConfigStatsUpdated) {
-                                processMeterConfigStatsUpdated((Iterable<MeterConfigStatsUpdated>) allMultipartData, deviceContext);
+                                processMeterConfigStatsUpdated((Iterable<MeterConfigStatsUpdated>) allMultipartData, deviceInfo, txFacade, registry.getDeviceMeterRegistry());
                             } else {
                                 isMultipartProcessed = Boolean.FALSE;
                             }
                         } catch (final Exception e) {
                             LOG.warn("stats processing of type {} for node {} failed during write-to-tx step",
-                                    type, deviceContext.getDeviceState().getNodeId(), e);
+                                    type, deviceInfo.getNodeId(), e);
                             return Futures.immediateFailedFuture(e);
                         }
 
-                        LOG.debug("Stats reply added to transaction for node {} of type {}", deviceContext.getDeviceState().getNodeId(), type);
+                        LOG.debug("Stats reply added to transaction for node {} of type {}", deviceInfo.getNodeId(), type);
 
                         //TODO : implement experimenter
                     } else {
-                        LOG.debug("Stats reply was empty for node {} of type {}", deviceContext.getDeviceState().getNodeId(), type);
+                        LOG.debug("Stats reply was empty for node {} of type {}", deviceInfo.getNodeId(), type);
                     }
 
                 } else {
-                    LOG.debug("Stats reply FAILED for node {} of type {}: {}", deviceContext.getDeviceState().getNodeId(), type, rpcResult.getErrors());
+                    LOG.debug("Stats reply FAILED for node {} of type {}: {}", deviceInfo.getNodeId(), type, rpcResult.getErrors());
                     isMultipartProcessed = Boolean.FALSE;
                 }
                 return Futures.immediateFuture(isMultipartProcessed);
@@ -218,9 +227,12 @@ public final class StatisticsGatheringUtils {
         });
     }
 
-    private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
-        deleteAllKnownMeters(deviceContext, fNodeIdent);
+    private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data,
+                                                       final DeviceInfo deviceInfo,
+                                                       final TxFacade txFacade,
+                                                       final DeviceMeterRegistry meterRegistry) throws Exception {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
+        deleteAllKnownMeters(meterRegistry, fNodeIdent, txFacade);
         for (final MeterConfigStatsUpdated meterConfigStatsUpdated : data) {
             for (final MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
                 final MeterId meterId = meterConfigStats.getMeterId();
@@ -229,24 +241,27 @@ public final class StatisticsGatheringUtils {
                 final MeterBuilder meterBuilder = new MeterBuilder(meterConfigStats);
                 meterBuilder.setKey(new MeterKey(meterId));
                 meterBuilder.addAugmentation(NodeMeterStatistics.class, new NodeMeterStatisticsBuilder().build());
-                deviceContext.getDeviceMeterRegistry().store(meterId);
-                deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, meterInstanceIdentifier, meterBuilder.build());
+                meterRegistry.store(meterId);
+                txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, meterInstanceIdentifier, meterBuilder.build());
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
     private static ListenableFuture<Boolean> processFlowStatistics(final Iterable<FlowsStatisticsUpdate> data,
-                                                                   final DeviceContext deviceContext, final EventIdentifier eventIdentifier) {
-        final ListenableFuture<Void> deleFuture = deleteAllKnownFlows(deviceContext.getDeviceState(),
-                deviceContext.getDeviceFlowRegistry(), deviceContext);
-        return Futures.transform(deleFuture, new Function<Void, Boolean>() {
+                                                                   final DeviceInfo deviceInfo,
+                                                                   final TxFacade txFacade,
+                                                                   final DeviceFlowRegistry flowRegistry,
+                                                                   final boolean initial,
+                                                                   final EventIdentifier eventIdentifier) {
+        final ListenableFuture<Void> deleteFuture = initial ? Futures.immediateFuture(null) : deleteAllKnownFlows(deviceInfo,
+                flowRegistry, txFacade);
+        return Futures.transform(deleteFuture, new Function<Void, Boolean>() {
 
             @Override
             public Boolean apply(final Void input) {
-                writeFlowStatistics(data, deviceContext.getDeviceState(), deviceContext.getDeviceFlowRegistry(),
-                        deviceContext);
-                deviceContext.submitTransaction();
+                writeFlowStatistics(data, deviceInfo, flowRegistry, txFacade);
+                txFacade.submitTransaction();
                 EventsTimeCounter.markEnd(eventIdentifier);
                 return Boolean.TRUE;
             }
@@ -254,10 +269,10 @@ public final class StatisticsGatheringUtils {
     }
 
     public static void writeFlowStatistics(final Iterable<FlowsStatisticsUpdate> data,
-                                           final DeviceState deviceState,
+                                           final DeviceInfo deviceInfo,
                                            final DeviceFlowRegistry registry,
                                            final TxFacade txFacade) {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceState);
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
         try {
             for (final FlowsStatisticsUpdate flowsStatistics : data) {
                 for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) {
@@ -292,53 +307,49 @@ public final class StatisticsGatheringUtils {
         return flowStatisticsDataBld;
     }
 
-    public static ListenableFuture<Void> deleteAllKnownFlows(final DeviceState deviceState,
+    public static ListenableFuture<Void> deleteAllKnownFlows(final DeviceInfo deviceInfo,
                                                              final DeviceFlowRegistry registry,
                                                              final TxFacade txFacade) {
-        /* DeviceState.deviceSynchronized is a marker for actual phase - false means initPhase, true means noInitPhase */
-        if (deviceState.deviceSynchronized()) {
-            final InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceState);
-            final ReadOnlyTransaction readTx = txFacade.getReadTransaction();
-            final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowCapableNodeFuture = readTx.read(
-                    LogicalDatastoreType.OPERATIONAL, flowCapableNodePath);
-
-            /* we wish to close readTx for fallBack */
-            Futures.withFallback(flowCapableNodeFuture, new FutureFallback<Optional<FlowCapableNode>>() {
-
-                @Override
-                public ListenableFuture<Optional<FlowCapableNode>> create(final Throwable t) throws Exception {
-                    readTx.close();
-                    return Futures.immediateFailedFuture(t);
-                }
-            });
-            /*
-             * we have to read actual tables with all information before we set empty Flow list, merge is expensive and
-             * not applicable for lists
-             */
-            return Futures.transform(flowCapableNodeFuture, new AsyncFunction<Optional<FlowCapableNode>, Void>() {
-
-                @Override
-                public ListenableFuture<Void> apply(final Optional<FlowCapableNode> flowCapNodeOpt) throws Exception {
-                    if (flowCapNodeOpt.isPresent()) {
-                        for (final Table tableData : flowCapNodeOpt.get().getTable()) {
-                            final Table table = new TableBuilder(tableData).setFlow(Collections.<Flow>emptyList()).build();
-                            final InstanceIdentifier<Table> iiToTable = flowCapableNodePath.child(Table.class, tableData.getKey());
-                            txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
-                        }
+        final InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
+        final ReadOnlyTransaction readTx = txFacade.getReadTransaction();
+        final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowCapableNodeFuture = readTx.read(
+                LogicalDatastoreType.OPERATIONAL, flowCapableNodePath);
+
+        /* we wish to close readTx for fallBack */
+        Futures.withFallback(flowCapableNodeFuture, new FutureFallback<Optional<FlowCapableNode>>() {
+
+            @Override
+            public ListenableFuture<Optional<FlowCapableNode>> create(final Throwable t) throws Exception {
+                readTx.close();
+                return Futures.immediateFailedFuture(t);
+            }
+        });
+        /*
+         * we have to read actual tables with all information before we set empty Flow list, merge is expensive and
+         * not applicable for lists
+         */
+        return Futures.transform(flowCapableNodeFuture, new AsyncFunction<Optional<FlowCapableNode>, Void>() {
+
+            @Override
+            public ListenableFuture<Void> apply(final Optional<FlowCapableNode> flowCapNodeOpt) throws Exception {
+                if (flowCapNodeOpt.isPresent()) {
+                    for (final Table tableData : flowCapNodeOpt.get().getTable()) {
+                        final Table table = new TableBuilder(tableData).setFlow(Collections.<Flow>emptyList()).build();
+                        final InstanceIdentifier<Table> iiToTable = flowCapableNodePath.child(Table.class, tableData.getKey());
+                        txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
                     }
-                    registry.removeMarked();
-                    readTx.close();
-                    return Futures.immediateFuture(null);
                 }
+                registry.removeMarked();
+                readTx.close();
+                return Futures.immediateFuture(null);
+            }
 
-            });
-        }
-        return Futures.immediateFuture(null);
+        });
     }
 
-    private static void processQueueStatistics(final Iterable<QueueStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
+    private static void processQueueStatistics(final Iterable<QueueStatisticsUpdate> data, final DeviceInfo deviceInfo, final TxFacade txFacade) throws Exception {
         // TODO: clean all queues of all node-connectors before writing up-to-date stats
-        final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodeIdent = deviceInfo.getNodeInstanceIdentifier();
         for (final QueueStatisticsUpdate queueStatisticsUpdate : data) {
             for (final QueueIdAndStatisticsMap queueStat : queueStatisticsUpdate.getQueueIdAndStatisticsMap()) {
                 if (queueStat.getQueueId() != null) {
@@ -357,29 +368,29 @@ public final class StatisticsGatheringUtils {
                             .setQueueId(queueStat.getQueueId())
                             // node-connector-id is already contained in parent node and the port-id here is of incompatible format
                             .addAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class, statBuild.build());
-                    deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, queueIdent, queueBuilder.build());
+                    txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, queueIdent, queueBuilder.build());
                 }
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
-    private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+    private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceInfo deviceInfo, final TxFacade txFacade) throws Exception {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
         for (final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
 
             for (final FlowTableAndStatisticsMap tableStat : flowTableStatisticsUpdate.getFlowTableAndStatisticsMap()) {
                 final InstanceIdentifier<FlowTableStatistics> tStatIdent = fNodeIdent.child(Table.class, new TableKey(tableStat.getTableId().getValue()))
                         .augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
                 final FlowTableStatistics stats = new FlowTableStatisticsBuilder(tableStat).build();
-                deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tStatIdent, stats);
+                txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tStatIdent, stats);
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
-    private static void processNodeConnectorStatistics(final Iterable<NodeConnectorStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceState().getNodeInstanceIdentifier();
+    private static void processNodeConnectorStatistics(final Iterable<NodeConnectorStatisticsUpdate> data, final DeviceInfo deviceInfo, final TxFacade txFacade) throws Exception {
+        final InstanceIdentifier<Node> nodeIdent = deviceInfo.getNodeInstanceIdentifier();
         for (final NodeConnectorStatisticsUpdate nodeConnectorStatisticsUpdate : data) {
             for (final NodeConnectorStatisticsAndPortNumberMap nConnectPort : nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap()) {
                 final FlowCapableNodeConnectorStatistics stats = new FlowCapableNodeConnectorStatisticsBuilder(nConnectPort).build();
@@ -389,15 +400,16 @@ public final class StatisticsGatheringUtils {
                         .augmentation(FlowCapableNodeConnectorStatisticsData.class);
                 final InstanceIdentifier<FlowCapableNodeConnectorStatistics> flowCapNodeConnStatIdent =
                         nodeConnStatIdent.child(FlowCapableNodeConnectorStatistics.class);
-                deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowCapNodeConnStatIdent, stats);
+                txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowCapNodeConnStatIdent, stats);
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
     private static void processMetersStatistics(final Iterable<MeterStatisticsUpdated> data,
-                                                final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+                                                final DeviceInfo deviceInfo,
+                                                final TxFacade txFacade) throws Exception {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
         for (final MeterStatisticsUpdated meterStatisticsUpdated : data) {
             for (final MeterStats mStat : meterStatisticsUpdated.getMeterStats()) {
                 final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build();
@@ -406,24 +418,23 @@ public final class StatisticsGatheringUtils {
                 final InstanceIdentifier<NodeMeterStatistics> nodeMeterStatIdent = meterIdent
                         .augmentation(NodeMeterStatistics.class);
                 final InstanceIdentifier<MeterStatistics> msIdent = nodeMeterStatIdent.child(MeterStatistics.class);
-                deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, msIdent, stats);
+                txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, msIdent, stats);
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
-    private static void deleteAllKnownMeters(final DeviceContext deviceContext, final InstanceIdentifier<FlowCapableNode> fNodeIdent) throws Exception {
-        for (final MeterId meterId : deviceContext.getDeviceMeterRegistry().getAllMeterIds()) {
+    private static void deleteAllKnownMeters(final DeviceMeterRegistry meterRegistry, final InstanceIdentifier<FlowCapableNode> fNodeIdent, final TxFacade txFacade) throws Exception {
+        for (final MeterId meterId : meterRegistry.getAllMeterIds()) {
             final InstanceIdentifier<Meter> meterIdent = fNodeIdent.child(Meter.class, new MeterKey(meterId));
-            deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, meterIdent);
+            txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, meterIdent);
         }
-        deviceContext.getDeviceMeterRegistry().removeMarked();
+        meterRegistry.removeMarked();
     }
 
-    private static void processGroupDescStats(final Iterable<GroupDescStatsUpdated> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent =
-                deviceContext.getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
-        deleteAllKnownGroups(deviceContext, fNodeIdent);
+    private static void processGroupDescStats(final Iterable<GroupDescStatsUpdated> data, final DeviceInfo deviceInfo, final TxFacade txFacade, final DeviceGroupRegistry groupRegistry) throws Exception {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
+        deleteAllKnownGroups(txFacade, fNodeIdent, groupRegistry);
 
         for (final GroupDescStatsUpdated groupDescStatsUpdated : data) {
             for (final GroupDescStats groupDescStats : groupDescStatsUpdated.getGroupDescStats()) {
@@ -435,23 +446,23 @@ public final class StatisticsGatheringUtils {
 
                 final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupId));
 
-                deviceContext.getDeviceGroupRegistry().store(groupId);
-                deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, groupIdent, groupBuilder.build());
+                groupRegistry.store(groupId);
+                txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, groupIdent, groupBuilder.build());
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
-    private static void deleteAllKnownGroups(final DeviceContext deviceContext, final InstanceIdentifier<FlowCapableNode> fNodeIdent) throws Exception {
-        for (final GroupId groupId : deviceContext.getDeviceGroupRegistry().getAllGroupIds()) {
+    private static void deleteAllKnownGroups(final TxFacade txFacade, final InstanceIdentifier<FlowCapableNode> fNodeIdent, final DeviceGroupRegistry groupRegistry) throws Exception {
+        for (final GroupId groupId : groupRegistry.getAllGroupIds()) {
             final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupId));
-            deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, groupIdent);
+            txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, groupIdent);
         }
-        deviceContext.getDeviceGroupRegistry().removeMarked();
+        groupRegistry.removeMarked();
     }
 
-    private static void processGroupStatistics(final Iterable<GroupStatisticsUpdated> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+    private static void processGroupStatistics(final Iterable<GroupStatisticsUpdated> data, final DeviceInfo deviceInfo, final TxFacade txFacade) throws Exception {
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
         for (final GroupStatisticsUpdated groupStatistics : data) {
             for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
 
@@ -461,14 +472,14 @@ public final class StatisticsGatheringUtils {
 
                 final InstanceIdentifier<GroupStatistics> gsIdent = nGroupStatIdent.child(GroupStatistics.class);
                 final GroupStatistics stats = new GroupStatisticsBuilder(groupStats).build();
-                deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gsIdent, stats);
+                txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gsIdent, stats);
             }
         }
-        deviceContext.submitTransaction();
+        txFacade.submitTransaction();
     }
 
-    private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceState deviceState) {
-        return deviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+    private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceInfo deviceInfo) {
+        return deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
     }
 
     /**
@@ -477,7 +488,7 @@ public final class StatisticsGatheringUtils {
      * @param deviceContext txManager + node path keeper
      */
     static void markDeviceStateSnapshotStart(final DeviceContext deviceContext) {
-        final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceContext.getDeviceState()
+        final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceContext.getDeviceInfo()
                 .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class);
 
         final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
@@ -503,7 +514,7 @@ public final class StatisticsGatheringUtils {
      * @param succeeded     outcome of currently finished gathering
      */
     static void markDeviceStateSnapshotEnd(final DeviceContext deviceContext, final boolean succeeded) {
-        final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceContext.getDeviceState()
+        final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceContext.getDeviceInfo()
                 .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class)
                 .child(SnapshotGatheringStatusEnd.class);
 
index ca217555cf0e4699935c1bbdcad9433b4e0c000d..8aa3c7aa537d248bc8b58a1cb78991f180fc450b 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.impl.statistics;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Iterators;
@@ -18,16 +17,29 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Future;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutputBuilder;
@@ -39,16 +51,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import java.util.Iterator;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Future;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
 public class StatisticsManagerImpl implements StatisticsManager, StatisticsManagerControlService {
 
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class);
@@ -58,7 +60,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
 
-    private final ConcurrentMap<NodeId, StatisticsContext> contexts = new ConcurrentHashMap<>();
+    private final ConcurrentMap<DeviceInfo, StatisticsContext> contexts = new ConcurrentHashMap<>();
 
     private static final long basicTimerDelay = 3000;
     private static long currentTimerDelay = basicTimerDelay;
@@ -87,41 +89,39 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     }
 
     @Override
-    public void onDeviceContextLevelUp(final NodeId nodeId) throws Exception {
+    public void onDeviceContextLevelUp(final DeviceInfo deviceInfo) throws Exception {
 
-        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(nodeId));
+        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
 
-        final StatisticsContext statisticsContext = new StatisticsContextImpl(nodeId, shuttingDownStatisticsPolling, conductor);
-        Verify.verify(contexts.putIfAbsent(nodeId, statisticsContext) == null, "StatisticsCtx still not closed for Node {}", nodeId);
+        final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceInfo, shuttingDownStatisticsPolling, conductor);
+        Verify.verify(contexts.putIfAbsent(deviceInfo, statisticsContext) == null, "StatisticsCtx still not closed for Node {}", deviceInfo.getNodeId());
 
-        deviceContext.getDeviceState().setDeviceSynchronized(true);
-        deviceInitPhaseHandler.onDeviceContextLevelUp(nodeId);
+        deviceInitPhaseHandler.onDeviceContextLevelUp(deviceInfo);
     }
 
     @VisibleForTesting
-    void pollStatistics(final DeviceContext deviceContext,
-                                final StatisticsContext statisticsContext,
-                                final TimeCounter timeCounter) {
-
-        final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+    void pollStatistics(final DeviceState deviceState,
+                        final StatisticsContext statisticsContext,
+                        final TimeCounter timeCounter,
+                        final DeviceInfo deviceInfo) {
 
         if (!statisticsContext.isSchedulingEnabled()) {
-            LOG.debug("Disabling statistics scheduling for device: {}", nodeId);
+            LOG.debug("Disabling statistics scheduling for device: {}", deviceInfo.getNodeId());
             return;
         }
         
-        if (!deviceContext.getDeviceState().isValid()) {
-            LOG.debug("Session is not valid for device: {}", nodeId);
+        if (!deviceState.isValid()) {
+            LOG.debug("Session is not valid for device: {}", deviceInfo.getNodeId());
             return;
         }
 
-        if (!deviceContext.getDeviceState().isStatisticsPollingEnabled()) {
-            LOG.debug("Statistics polling is currently disabled for device: {}", nodeId);
-            scheduleNextPolling(deviceContext, statisticsContext, timeCounter);
+        if (!deviceState.isStatisticsPollingEnabled()) {
+            LOG.debug("Statistics polling is currently disabled for device: {}", deviceInfo.getNodeId());
+            scheduleNextPolling(deviceState, deviceInfo, statisticsContext, timeCounter);
             return;
         }
 
-        LOG.debug("POLLING ALL STATISTICS for device: {}", nodeId);
+        LOG.debug("POLLING ALL STATISTICS for device: {}", deviceInfo.getNodeId());
         timeCounter.markStart();
         final ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
         Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
@@ -129,7 +129,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
             public void onSuccess(final Boolean o) {
                 timeCounter.addTimeMark();
                 calculateTimerDelay(timeCounter);
-                scheduleNextPolling(deviceContext, statisticsContext, timeCounter);
+                scheduleNextPolling(deviceState, deviceInfo, statisticsContext, timeCounter);
             }
 
             @Override
@@ -140,40 +140,32 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
                 calculateTimerDelay(timeCounter);
                 if (throwable instanceof CancellationException) {
                     /** This often happens when something wrong with akka or DS, so closing connection will help to restart device **/
-                    conductor.closeConnection(deviceContext.getDeviceState().getNodeId());
+                    conductor.closeConnection(deviceInfo);
                 } else {
-                    scheduleNextPolling(deviceContext, statisticsContext, timeCounter);
+                    scheduleNextPolling(deviceState, deviceInfo, statisticsContext, timeCounter);
                 }
             }
         });
 
         final long averageTime = TimeUnit.MILLISECONDS.toSeconds(timeCounter.getAverageTimeBetweenMarks());
         final long STATS_TIMEOUT_SEC = averageTime > 0 ? 3 * averageTime : DEFAULT_STATS_TIMEOUT_SEC;
-        final TimerTask timerTask = new TimerTask() {
-
-            @Override
-            public void run(final Timeout timeout) throws Exception {
-                if (!deviceStatisticsCollectionFuture.isDone()) {
-                    LOG.info("Statistics collection for node {} still in progress even after {} secs", nodeId, STATS_TIMEOUT_SEC);
-                    deviceStatisticsCollectionFuture.cancel(true);
-                }
+        final TimerTask timerTask = timeout -> {
+            if (!deviceStatisticsCollectionFuture.isDone()) {
+                LOG.info("Statistics collection for node {} still in progress even after {} secs", deviceInfo.getNodeId(), STATS_TIMEOUT_SEC);
+                deviceStatisticsCollectionFuture.cancel(true);
             }
         };
 
         conductor.newTimeout(timerTask, STATS_TIMEOUT_SEC, TimeUnit.SECONDS);
     }
 
-    private void scheduleNextPolling(final DeviceContext deviceContext,
+    private void scheduleNextPolling(final DeviceState deviceState,
+                                     final DeviceInfo deviceInfo,
                                      final StatisticsContext statisticsContext,
                                      final TimeCounter timeCounter) {
-        LOG.debug("SCHEDULING NEXT STATISTICS POLLING for device: {}", deviceContext.getDeviceState().getNodeId());
+        LOG.debug("SCHEDULING NEXT STATISTICS POLLING for device: {}", deviceInfo.getNodeId());
         if (!shuttingDownStatisticsPolling) {
-            final Timeout pollTimeout = conductor.newTimeout(new TimerTask() {
-                @Override
-                public void run(final Timeout timeout) throws Exception {
-                    pollStatistics(deviceContext, statisticsContext, timeCounter);
-                }
-            }, currentTimerDelay, TimeUnit.MILLISECONDS);
+            final Timeout pollTimeout = conductor.newTimeout(timeout -> pollStatistics(deviceState, statisticsContext, timeCounter, deviceInfo), currentTimerDelay, TimeUnit.MILLISECONDS);
             statisticsContext.setPollTimeout(pollTimeout);
         }
     }
@@ -201,13 +193,13 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     }
 
     @Override
-    public void onDeviceContextLevelDown(final DeviceContext deviceContext) {
-        final StatisticsContext statisticsContext = contexts.remove(deviceContext.getDeviceState().getNodeId());
+    public void onDeviceContextLevelDown(final DeviceInfo deviceInfo) {
+        final StatisticsContext statisticsContext = contexts.remove(deviceInfo);
         if (null != statisticsContext) {
-            LOG.trace("Removing device context from stack. No more statistics gathering for device: {}", deviceContext.getDeviceState().getNodeId());
+            LOG.trace("Removing device context from stack. No more statistics gathering for device: {}", deviceInfo.getNodeId());
             statisticsContext.close();
         }
-        deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceContext);
+        deviceTerminPhaseHandler.onDeviceContextLevelDown(deviceInfo);
     }
 
     @Override
@@ -226,22 +218,21 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
             if (!workMode.equals(targetWorkMode)) {
                 shuttingDownStatisticsPolling = StatisticsWorkMode.FULLYDISABLED.equals(targetWorkMode);
                 // iterate through stats-ctx: propagate mode
-                for (final StatisticsContext statisticsContext : contexts.values()) {
-                    final DeviceContext deviceContext = statisticsContext.getDeviceContext();
+                for (Map.Entry<DeviceInfo, StatisticsContext> entry : contexts.entrySet()) {
                     switch (targetWorkMode) {
                         case COLLECTALL:
-                            scheduleNextPolling(deviceContext, statisticsContext, new TimeCounter());
-                            for (final ItemLifeCycleSource lifeCycleSource : deviceContext.getItemLifeCycleSourceRegistry().getLifeCycleSources()) {
+                            scheduleNextPolling(conductor.getDeviceContext(entry.getKey()).getDeviceState(), entry.getKey(), entry.getValue(), new TimeCounter());
+                            for (final ItemLifeCycleSource lifeCycleSource : conductor.getDeviceContext(entry.getKey()).getItemLifeCycleSourceRegistry().getLifeCycleSources()) {
                                 lifeCycleSource.setItemLifecycleListener(null);
                             }
                             break;
                         case FULLYDISABLED:
-                            final Optional<Timeout> pollTimeout = statisticsContext.getPollTimeout();
+                            final Optional<Timeout> pollTimeout = entry.getValue().getPollTimeout();
                             if (pollTimeout.isPresent()) {
                                 pollTimeout.get().cancel();
                             }
-                            for (final ItemLifeCycleSource lifeCycleSource : deviceContext.getItemLifeCycleSourceRegistry().getLifeCycleSources()) {
-                                lifeCycleSource.setItemLifecycleListener(statisticsContext.getItemLifeCycleListener());
+                            for (final ItemLifeCycleSource lifeCycleSource : conductor.getDeviceContext(entry.getKey()).getItemLifeCycleSourceRegistry().getLifeCycleSources()) {
+                                lifeCycleSource.setItemLifecycleListener(entry.getValue().getItemLifeCycleListener());
                             }
                             break;
                         default:
@@ -261,43 +252,37 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     }
 
     @Override
-    public void startScheduling(final NodeId nodeId) {
+    public void startScheduling(final DeviceInfo deviceInfo) {
         if (shuttingDownStatisticsPolling) {
-            LOG.info("Statistics are shut down for device: {}", nodeId);
+            LOG.info("Statistics are shut down for device: {}", deviceInfo.getNodeId());
             return;
         }
 
-        final StatisticsContext statisticsContext = contexts.get(nodeId);
+        final StatisticsContext statisticsContext = contexts.get(deviceInfo);
 
         if (statisticsContext == null) {
-            LOG.warn("Statistics context not found for device: {}", nodeId);
+            LOG.warn("Statistics context not found for device: {}", deviceInfo.getNodeId());
             return;
         }
 
         if (statisticsContext.isSchedulingEnabled()) {
-            LOG.debug("Statistics scheduling is already enabled for device: {}", nodeId);
+            LOG.debug("Statistics scheduling is already enabled for device: {}", deviceInfo.getNodeId());
             return;
         }
 
-        LOG.info("Scheduling statistics poll for device: {}", nodeId);
-        final DeviceContext deviceContext = conductor.getDeviceContext(nodeId);
-
-        if (deviceContext == null) {
-            LOG.warn("Device context not found for device: {}", nodeId);
-            return;
-        }
+        LOG.info("Scheduling statistics poll for device: {}", deviceInfo.getNodeId());
 
         statisticsContext.setSchedulingEnabled(true);
-        scheduleNextPolling(deviceContext, statisticsContext, new TimeCounter());
+        scheduleNextPolling(conductor.getDeviceContext(deviceInfo).getDeviceState(), deviceInfo, statisticsContext, new TimeCounter());
     }
 
     @Override
-    public void stopScheduling(final NodeId nodeId) {
-        LOG.debug("Stopping statistics scheduling for device: {}", nodeId);
-        final StatisticsContext statisticsContext = contexts.get(nodeId);
+    public void stopScheduling(final DeviceInfo deviceInfo) {
+        LOG.debug("Stopping statistics scheduling for device: {}", deviceInfo.getNodeId());
+        final StatisticsContext statisticsContext = contexts.get(deviceInfo);
 
         if (statisticsContext == null) {
-            LOG.warn("Statistics context not found for device: {}", nodeId);
+            LOG.warn("Statistics context not found for device: {}", deviceInfo.getNodeId());
             return;
         }
 
@@ -320,4 +305,9 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     public void setDeviceTerminationPhaseHandler(final DeviceTerminationPhaseHandler handler) {
         this.deviceTerminPhaseHandler = handler;
     }
+
+    @Override
+    public <T extends OFPContext> T gainContext(DeviceInfo deviceInfo) {
+        return (T) contexts.get(deviceInfo);
+    }
 }
index af49302a778ed1c4fe1d69aae8d01050ec8fcfb3..45a19e1ae56add3299a60952f6b4e908655757d1 100644 (file)
@@ -91,9 +91,9 @@ public final class AggregateFlowsInTableService extends AbstractCompatibleStatSe
         final TranslatorKey translatorKey = new TranslatorKey(mpReply.getVersion(), MultipartReplyAggregateCase.class.getName());
         final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
 
-        final AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceContext().getDeviceState(), null);
+        final AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceInfo(), null);
         final AggregateFlowStatisticsUpdateBuilder notification = new AggregateFlowStatisticsUpdateBuilder(flowStatistics)
-                .setId(getDeviceContext().getDeviceState().getNodeId())
+                .setId(getDeviceInfo().getNodeId())
                 .setMoreReplies(Boolean.FALSE)
                 .setTransactionId(emulatedTxId);
 
index 5801f43a6145e152e753b873b7f74784393d16a4..d49c00b6966fe3b60935089b2ae5602f6925da8b 100644 (file)
@@ -67,6 +67,6 @@ public final class AllFlowsInAllTablesService extends AbstractCompatibleStatServ
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 8c9262f3996e503a693f23a9e9d56de5e4e58d98..cdd22569049220317bedb11bf974bbbdf9eea2b3 100644 (file)
@@ -72,6 +72,6 @@ public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAll
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> mpResult, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index e33c2100562fc1b14ee0f3187480c07d27c42726..5cf5db31ef1f61fb106178fa1185ffdf59181234 100644 (file)
@@ -71,6 +71,6 @@ final class AllGroupsStatsService extends
 
     @Override
     public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), emulatedTxId);
     }
 }
index f7667e8116432c84efc4228767f1b7d4ba273846..1fc57caca09c4873ada8a46c069e2dfc8f819405 100644 (file)
@@ -73,7 +73,7 @@ final class AllMeterConfigStatsService
     @Override
     public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
         MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
-        message.setId(getDeviceContext().getDeviceState().getNodeId());
+        message.setId(getDeviceInfo().getNodeId());
         message.setMoreReplies(Boolean.FALSE);
         message.setTransactionId(emulatedTxId);
 
index fb3b2d90fa6641533e65345224b2c24abc3f54ce..aae79faed6afe89965b3c65df720cd0fad6d2af2 100644 (file)
@@ -65,6 +65,6 @@ final class AllMeterStatsService
 
     @Override
     public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index d2ca4400443c908e06abff59a4053d4ebeee3d70..20be7f9433deefcd7e451bcc20a8e34e54089687 100644 (file)
@@ -65,6 +65,6 @@ final class AllPortStatsService
 
     @Override
     public NodeConnectorStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+        return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index b9da4288af81f7c1f54004435c9eeba86d5e4e72..ca34feb4c5dbecbcaf51ad09652ef1c176269564 100644 (file)
@@ -66,6 +66,6 @@ final class AllQueuesAllPortsService
 
     @Override
     public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 1f6f6b3232d4bf2dd08853f9facb7f68b6b15e5e..697edecaa01525037769cc80bf430cd323ac8ec7 100644 (file)
@@ -65,6 +65,6 @@ final class AllQueuesOnePortService
 
     @Override
     public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index f063b2ef51d69511fc26f61ba722e84eabb3e2a6..70b458daaa3084d42b8e6c87564aaf6a9f2d8ca5 100644 (file)
@@ -73,9 +73,8 @@ public final class FlowsInTableService extends AbstractCompatibleStatService<Get
 
         // convert and inject match
         final short version = getVersion();
-        final DeviceContext deviceContext = getDeviceContext();
         MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
-                deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+                getDeviceInfo().getDatapathId());
 
         // Set request body to main multipart request
         multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
@@ -93,6 +92,6 @@ public final class FlowsInTableService extends AbstractCompatibleStatService<Get
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 46e2588be17e56b501b7d3707f8291862354938c..bb6c9f7b5318d9bd466e58ffc1180a2ef4ce3fb6 100644 (file)
@@ -58,7 +58,7 @@ final class GroupDescriptionService
     @Override
     public GroupDescStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
         GroupDescStatsUpdatedBuilder notification = new GroupDescStatsUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 22c8d6d465c3e8c07031ed15c1a5840e199839a5..008429797eff41b0cb774dee8f2cc4c7cc71face 100644 (file)
@@ -74,7 +74,7 @@ final class GroupFeaturesService
         Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
 
         GroupFeaturesUpdatedBuilder notification = new GroupFeaturesUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index e0e04f95c92df1b534b9451ae9c1b105e2885cd2..77ec5014cc1ff689413de02781d333f9eaae81d0 100644 (file)
@@ -56,6 +56,6 @@ final class GroupStatsService
 
     @Override
     public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), emulatedTxId);
     }
 }
index 3de2abdba19144abd0289e9ca620cd206f7191d5..6456c89fad3b0bcc0d6731a984766f1063f9769a 100644 (file)
@@ -31,7 +31,6 @@ final class MatchingFlowsInTableService extends AbstractMultipartService<GetAggr
 
     @Override
     protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
-        final DeviceContext deviceContext = getDeviceContext();
         final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
         final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
         final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL).shortValue();
index 142b3c0c85f6859c05b256e202a285966c3bc8bb..e3f2d3149f4202b41dffbfdb62181d4ffb07acea 100644 (file)
@@ -70,7 +70,7 @@ final class MeterFeaturesService
         Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
 
         MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 33d36ffbba9f9ef21cd62865e3d7c336202b9365..841adf203903edf7c5bceb7df119f0c193bd8544 100644 (file)
@@ -57,6 +57,6 @@ final class MeterStatsService
 
     @Override
     public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 867d10b79307e589eaa165ec201d3c9750162dac..469c91362e5dabba9e1a9763a0b987c6a1e63610 100644 (file)
@@ -62,6 +62,6 @@ final class OneQueueOnePortService
 
     @Override
     public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index cabe1cffa40ced08d7025e5d7264d39d285a590f..d028ad976cb9734697e9ca1be0edd8f0eb34d1f6 100644 (file)
@@ -13,6 +13,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
@@ -49,7 +50,7 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
             new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
                 @Override
                 public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(final RpcResult<List<MultipartReply>> input) {
-                    final DeviceContext deviceContext = matchingFlowsInTable.getDeviceContext();
+                    final DeviceInfo deviceInfo = matchingFlowsInTable.getDeviceInfo();
                     final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
                     if (input.isSuccessful()) {
                         MultipartReply reply = input.getResult().get(0);
@@ -58,7 +59,7 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
                         List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
 
                         for (MultipartReply multipartReply : input.getResult()) {
-                            aggregStats.add(messageTranslator.translate(multipartReply, deviceContext.getDeviceState(), null));
+                            aggregStats.add(messageTranslator.translate(multipartReply, deviceInfo, null));
                         }
 
                         GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
index a6f6b2b197455ea1f8fbdb9748f5541553966e6f..2f4483b7e0953fabe2a2ebd5dfd3b35dd9ed5087 100644 (file)
@@ -85,7 +85,7 @@ public final class OpendaylightFlowTableStatisticsServiceImpl extends
     @Override
     public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
         FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index ed8caa2c6525325359518da4530e3159e2b631f2..8354c3df762237e089208818159c10c9174fd617 100644 (file)
@@ -64,6 +64,6 @@ final class PortStatsService
 
     @Override
     public NodeConnectorStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+        return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 6ba60dcbb661fce089eedb11ec65c7f269133a63..c3e2a91c828995e311f8c71cf52fc3f4915749b0 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
@@ -32,18 +32,18 @@ public class FlowStatisticsToNotificationTransformer {
 
     /**
      * @param mpResult      raw multipart response from device
-     * @param deviceState   device state
+     * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static FlowsStatisticsUpdate transformToNotification(final List<MultipartReply> mpResult,
-                                                                final DeviceState deviceState,
+                                                                final DeviceInfo deviceInfo,
                                                                 final OpenflowVersion ofVersion,
                                                                 final TransactionId emulatedTxId) {
         final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
         final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setFlowAndStatisticsMapList(statsList);
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
@@ -55,7 +55,7 @@ public class FlowStatisticsToNotificationTransformer {
             MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
             List<FlowAndStatisticsMapList> outStatsItem = flowStatsConvertor.toSALFlowStatsList(
                     replyBody.getFlowStats(),
-                    deviceState.getFeatures().getDatapathId(),
+                    deviceInfo.getDatapathId(),
                     ofVersion);
             statsList.addAll(outStatsItem);
         }
index 2dcef59d0ff855fe0086a6348cb652c44f870fe7..5df1440ec25dbc89c66741d593d661ad94735c55 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
@@ -30,18 +29,16 @@ public class GroupStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceState   device state
-     * @param ofVersion     device version
+     * @param deviceInfo   device state
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static GroupStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                 final DeviceState deviceState,
-                                                                 final OpenflowVersion ofVersion,
+                                                                 final DeviceInfo deviceInfo,
                                                                  final TransactionId emulatedTxId) {
 
         GroupStatisticsUpdatedBuilder notification = new GroupStatisticsUpdatedBuilder();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 4bf30e29cebfbd197cab9d03b2ff17d3195b1125..f4f09234fb4b7a08e311145e5cd151a76b18af1d 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
@@ -30,18 +30,18 @@ public class MeterStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceState   device state
+     * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static MeterStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                 final DeviceState deviceState,
+                                                                 final DeviceInfo deviceInfo,
                                                                  final OpenflowVersion ofVersion,
                                                                  final TransactionId emulatedTxId) {
 
         MeterStatisticsUpdatedBuilder notification = new MeterStatisticsUpdatedBuilder();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 3649a252988567560be1b328f9da4cfc11e61934..4b1c398b1838328401385f9eb2a476201d481463 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
@@ -36,18 +36,18 @@ public class NodeConnectorStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceContext device context
+     * @param deviceInfo    device basic info
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static NodeConnectorStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                        final DeviceContext deviceContext,
+                                                                        final DeviceInfo deviceInfo,
                                                                         final OpenflowVersion ofVersion,
                                                                         final TransactionId emulatedTxId) {
 
         NodeConnectorStatisticsUpdateBuilder notification = new NodeConnectorStatisticsUpdateBuilder();
-        notification.setId(deviceContext.getDeviceState().getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
@@ -58,7 +58,7 @@ public class NodeConnectorStatisticsToNotificationTransformer {
             MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
             for (PortStats portStats : replyBody.getPortStats()) {
                 NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder =
-                        processSingleNodeConnectorStats(deviceContext, ofVersion, portStats);
+                        processSingleNodeConnectorStats(deviceInfo, ofVersion, portStats);
                 notification.getNodeConnectorStatisticsAndPortNumberMap().add(statsBuilder.build());
             }
         }
@@ -66,12 +66,12 @@ public class NodeConnectorStatisticsToNotificationTransformer {
     }
 
     @VisibleForTesting
-    static NodeConnectorStatisticsAndPortNumberMapBuilder processSingleNodeConnectorStats(DeviceContext deviceContext, OpenflowVersion ofVersion, PortStats portStats) {
+    static NodeConnectorStatisticsAndPortNumberMapBuilder processSingleNodeConnectorStats(DeviceInfo deviceInfo, OpenflowVersion ofVersion, PortStats portStats) {
         NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder =
                 new NodeConnectorStatisticsAndPortNumberMapBuilder();
         statsBuilder.setNodeConnectorId(
                 InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(
-                        deviceContext.getDeviceState().getFeatures().getDatapathId(),
+                        deviceInfo.getDatapathId(),
                         portStats.getPortNo(), ofVersion));
 
         BytesBuilder bytesBuilder = new BytesBuilder();
index fc4f6c08e11b5056d7a9ee327146b168cc7d9f8e..fe94327f6da2cfffae196d9fdfc4ed123a983095 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
@@ -34,18 +34,18 @@ public class QueueStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceState   device state
+     * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                final DeviceState deviceState,
+                                                                final DeviceInfo deviceInfo,
                                                                 final OpenflowVersion ofVersion,
                                                                 final TransactionId emulatedTxId) {
 
         QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
@@ -61,7 +61,7 @@ public class QueueStatisticsToNotificationTransformer {
                         new QueueIdAndStatisticsMapBuilder();
                 statsBuilder.setNodeConnectorId(
                         InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(
-                                deviceState.getFeatures().getDatapathId(),
+                                deviceInfo.getDatapathId(),
                                 queueStats.getPortNo(), ofVersion));
                 statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
                 statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
index 6dfcfa05405cccad2982993b662de6a5a6777185..60f7b03f29dcfcd03314392bcfbeae6534f7e372 100644 (file)
@@ -38,7 +38,7 @@ public class StatisticsGatheringOnTheFlyService extends AbstractMultipartOnTheFl
 
     @Override
     public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final EventIdentifier eventIdentifier, final MultipartType type) {
-        LOG.debug("Getting statistics (onTheFly) for node {} of type {}", getNodeId(), type);
+        LOG.debug("Getting statistics (onTheFly) for node {} of type {}", getDeviceInfo().getNodeId(), type);
         EventsTimeCounter.markStart(eventIdentifier);
         setEventIdentifier(eventIdentifier);
         return handleServiceCall(type);
index c43ae604fc8af3fee422d8b2e9ef5d61055285ba..b6f1b10f33c0c102ac85f5741d45a40616fc6e43 100644 (file)
@@ -38,7 +38,7 @@ public class StatisticsGatheringService extends AbstractMultipartService<Multipa
 
     @Override
     public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final EventIdentifier eventIdentifier, final MultipartType type) {
-        LOG.debug("Getting statistics for node {} of type {}", getNodeId(), type);
+        LOG.debug("Getting statistics for node {} of type {}", getDeviceInfo().getNodeId(), type);
         EventsTimeCounter.markStart(eventIdentifier);
         setEventIdentifier(eventIdentifier);
         return handleServiceCall(type);
index e809ebf9a05b759d250fafcfddbeba1533893124..9c200a990a90e0277ed149f0fad0ce1eba8ad837 100644 (file)
@@ -13,6 +13,9 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -27,10 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import javax.annotation.Nullable;
-import java.util.List;
-import java.util.concurrent.Future;
-
 /**
  * The abstract direct statistics service.
  * This abstract service provides wrappers and tools for all other derived statistics services.
@@ -60,7 +59,7 @@ public abstract class AbstractDirectStatisticsService<I extends StoreStatsGroupi
 
                     if (input.isSuccessful()) {
                         storeStatistics(input.getResult());
-                        getDeviceContext().submitTransaction(); // TODO: If submitTransaction will ever return future, chain it
+                        getTxFacade().submitTransaction(); // TODO: If submitTransaction will ever return future, chain it
                     }
 
                     return Futures.immediateFuture(input);
index 72066b0395f578dc3f72600e121d2b347f04ba93..edfede1aef7d0df584a168d6177ec7db3242db2d 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -41,9 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * The Flow direct statistics service.
  */
@@ -131,8 +130,7 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
 
     @Override
     protected void storeStatistics(GetFlowStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceContext()
-                .getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
 
         for (final FlowAndStatisticsMapList flowStatistics : output.getFlowAndStatisticsMapList()) {
             final FlowId flowId = generateFlowId(flowStatistics);
@@ -149,7 +147,7 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
                     .child(Table.class, new TableKey(flowStatistics.getTableId()))
                     .child(Flow.class, flowKey);
 
-            getDeviceContext().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, flowStatisticsPath, flowBuilder.build());
+            getTxFacade().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, flowStatisticsPath, flowBuilder.build());
         }
     }
 
@@ -162,6 +160,6 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
 
         final short tableId = flowStatistics.getTableId();
         final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(flowBuilder.build());
-        return getDeviceContext().getDeviceFlowRegistry().storeIfNecessary(flowRegistryKey, tableId);
+        return getDeviceRegistry().getDeviceFlowRegistry().storeIfNecessary(flowRegistryKey, tableId);
     }
 }
index b7c650a03a4d8e4e91934aca7b7af3a4d4f96a2a..75579a18c0ac606a678083ad6b5f6df50e3a12cc 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -33,9 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * The Group direct statistics service.
  */
@@ -86,8 +85,7 @@ public class GroupDirectStatisticsService extends AbstractDirectStatisticsServic
 
     @Override
     protected void storeStatistics(GetGroupStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceContext()
-                .getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
 
         for (final GroupStats groupStatistics : output.getGroupStats()) {
             final InstanceIdentifier<GroupStatistics> groupStatisticsPath = nodePath
@@ -96,7 +94,7 @@ public class GroupDirectStatisticsService extends AbstractDirectStatisticsServic
                     .child(GroupStatistics.class);
 
             final GroupStatistics stats = new GroupStatisticsBuilder(groupStatistics).build();
-            getDeviceContext().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, groupStatisticsPath, stats);
+            getTxFacade().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, groupStatisticsPath, stats);
         }
     }
 }
index da6475ec5ce32e26096bc6c9471eaafd310bf6fe..55e0fab0cc7bddfa8483901168506c97d9693cf2 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -33,9 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * The Meter direct statistics service.
  */
@@ -86,8 +85,7 @@ public class MeterDirectStatisticsService extends AbstractDirectStatisticsServic
 
     @Override
     protected void storeStatistics(GetMeterStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceContext()
-                .getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
 
         for (final MeterStats meterStatistics : output.getMeterStats()) {
             final InstanceIdentifier<MeterStatistics> meterPath = nodePath
@@ -96,7 +94,7 @@ public class MeterDirectStatisticsService extends AbstractDirectStatisticsServic
                     .child(MeterStatistics.class);
 
             final MeterStatistics stats = new MeterStatisticsBuilder(meterStatistics).build();
-            getDeviceContext().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, meterPath, stats);
+            getTxFacade().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, meterPath, stats);
         }
     }
 }
index 6f6f496cbe66283a939843aa2340986c9a546bfa..f38600ca8e184098288f5570062263f1c50172e9 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -40,9 +42,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.n
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * The Node connector direct statistics service.
  */
@@ -130,7 +129,7 @@ public class NodeConnectorDirectStatisticsService extends AbstractDirectStatisti
 
     @Override
     protected void storeStatistics(GetNodeConnectorStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<Node> nodePath = getDeviceContext().getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodePath = getDeviceInfo().getNodeInstanceIdentifier();
 
         for (final NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatistics : output.getNodeConnectorStatisticsAndPortNumberMap()) {
             final InstanceIdentifier<FlowCapableNodeConnectorStatistics> nodeConnectorPath = nodePath
@@ -139,7 +138,7 @@ public class NodeConnectorDirectStatisticsService extends AbstractDirectStatisti
                     .child(FlowCapableNodeConnectorStatistics.class);
 
             final FlowCapableNodeConnectorStatistics stats = new FlowCapableNodeConnectorStatisticsBuilder(nodeConnectorStatistics).build();
-            getDeviceContext().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, nodeConnectorPath, stats);
+            getTxFacade().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, nodeConnectorPath, stats);
         }
     }
 }
index b96ae21ec102bc81bc997823ff2a73253f134ff8..3f5af2f8e6edf9ffd4bad53a2288a5c1ba2d2802 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import java.util.Optional;
+import java.util.concurrent.Future;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput;
@@ -24,9 +26,6 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.util.Optional;
-import java.util.concurrent.Future;
-
 /**
  * The Opendaylight direct statistics service.
  * This service handles RPC requests, sends them to registered handlers and returns their replies.
index 88f97dcbabcf65c7e410e368bb88d4de4442e7f2..0d2805b05cf29e42bc85d1923516a7195898297c 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -43,9 +45,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * The Queue direct statistics service.
  */
@@ -116,7 +115,7 @@ public class QueueDirectStatisticsService extends AbstractDirectStatisticsServic
 
     @Override
     protected void storeStatistics(GetQueueStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<Node> nodePath = getDeviceContext().getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodePath = getDeviceInfo().getNodeInstanceIdentifier();
 
         for (final QueueIdAndStatisticsMap queueStatistics : output.getQueueIdAndStatisticsMap()) {
             if (queueStatistics.getQueueId() != null) {
@@ -139,7 +138,7 @@ public class QueueDirectStatisticsService extends AbstractDirectStatisticsServic
                         .setQueueId(queueStatistics.getQueueId())
                         .addAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class, statBuild.build()).build();
 
-                getDeviceContext().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, queueStatisticsPath, stats);
+                getTxFacade().writeToTransactionWithParentsSlow(LogicalDatastoreType.OPERATIONAL, queueStatisticsPath, stats);
             }
         }
     }
index 1381bf9a2d57a5a934483c62291261de8ad76b8d..c00e01bcd3fb7f6b777a2f4f559882fe20274a29 100644 (file)
@@ -8,8 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
@@ -24,7 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class AggregatedFlowStatisticsTranslator implements MessageTranslator<MultipartReply, AggregatedFlowStatistics> {
     @Override
-    public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceState deviceState, final Object connectionDistinguisher) {
+    public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
         AggregatedFlowStatisticsBuilder aggregatedFlowStatisticsBuilder = new AggregatedFlowStatisticsBuilder();
 
         MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase)input.getMultipartReplyBody();
index 956389a10362294c029f8d2901c5b707538d7b35..c5683d2ebc171a071b446bbae668efa65be1a9e5 100644 (file)
@@ -7,8 +7,7 @@
  */
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
@@ -24,19 +23,29 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
 
     @Override
-    public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceState deviceState, Object connectionDistinguisher) {
+    public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceInfo deviceInfo, Object connectionDistinguisher) {
         FlowRemovedBuilder flowRemovedBld = new FlowRemovedBuilder()
-                .setMatch(translateMatch(input, deviceState).build())
+                .setMatch(translateMatch(input, deviceInfo).build())
                 .setCookie(new FlowCookie(input.getCookie()))
-                .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier()))
                 .setPriority(input.getPriority())
-                .setTableId(input.getTableId().getValue().shortValue());
+                .setTableId(translateTableId(input));
 
         return flowRemovedBld.build();
     }
 
-    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceState deviceState) {
+    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
         return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
-                deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13);
+                deviceInfo.getDatapathId(), OpenflowVersion.OF13);
+    }
+
+    /**
+     * Translate the table ID in the FLOW_REMOVED message to SAL table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  SAL table ID.
+     */
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return flowRemoved.getTableId().getValue().shortValue();
     }
 }
index 2436faeaebd3908b79a123a378fb478100f9e753..e5904310c5288618b29f0a8529834a91d5391fd0 100644 (file)
@@ -8,8 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
@@ -21,8 +20,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class FlowRemovedV10Translator extends FlowRemovedTranslator {
 
     @Override
-    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceState deviceState) {
+    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
         return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
-                deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF10);
+                deviceInfo.getDatapathId(), OpenflowVersion.OF10);
+    }
+
+    /**
+     * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  Zero.
+     */
+    @Override
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return Short.valueOf((short)0);
     }
 }
index 9e9793d66ca62f02a4e624f7bcf0549b7fff268e..9b5f76069f1d38d303bf27c4365ad7d6335be526 100644 (file)
@@ -10,9 +10,7 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import com.google.common.annotations.VisibleForTesting;
 import java.math.BigInteger;
-import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
@@ -24,8 +22,6 @@ import org.opendaylight.openflowplugin.openflow.md.util.PacketInUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder;
@@ -37,10 +33,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Table
  */
 public class PacketReceivedTranslator implements MessageTranslator<PacketInMessage, PacketReceived> {
     @Override
-    public PacketReceived translate(final PacketInMessage input, final DeviceState deviceState, final Object connectionDistinguisher) {
+    public PacketReceived translate(final PacketInMessage input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
 
         PacketReceivedBuilder packetReceivedBuilder = new PacketReceivedBuilder();
-        BigInteger datapathId = deviceState.getFeatures().getDatapathId();
+        BigInteger datapathId = deviceInfo.getDatapathId();
 
         // TODO: connection cookie from connection distinguisher
         // packetReceivedBuilder.setConnectionCookie(new ConnectionCookie(input.getCookie().longValue()));
@@ -53,7 +49,7 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
         }
 
         // Try to create the NodeConnectorRef
-        BigInteger dataPathId = deviceState.getFeatures().getDatapathId();
+        BigInteger dataPathId = deviceInfo.getDatapathId();
         NodeConnectorRef nodeConnectorRef = NodeConnectorRefToPortTranslator.toNodeConnectorRef(input, dataPathId);
 
         // If we was able to create NodeConnectorRef, use it
index 6c35a2a50ec6692c994ef4fe15d72e3329549289..61ef3344851a38b1fc5a5658003a26f699989064 100644 (file)
@@ -9,8 +9,7 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import java.util.Collections;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -25,17 +24,17 @@ public class PortUpdateTranslator implements MessageTranslator<PortGrouping, Flo
 
     @Override
     public FlowCapableNodeConnector translate(final PortGrouping input,
-                                              final DeviceState deviceState, final Object connectionDistinguisher) {
+                                              final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
         final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder();
         //OF1.0
-        if (deviceState.getVersion() == OFConstants.OFP_VERSION_1_0) {
+        if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_0) {
             builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeaturesV10()));
             builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfigV10()));
             builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeaturesV10()));
             builder.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(input.getPeerFeaturesV10()));
             builder.setState(PortTranslatorUtil.translatePortState(input.getStateV10()));
             builder.setSupported(PortTranslatorUtil.translatePortFeatures(input.getSupportedFeaturesV10()));
-        } else if (deviceState.getVersion() == OFConstants.OFP_VERSION_1_3) {
+        } else if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_3) {
             builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeatures()));
             builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfig()));
             builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeatures()));
index d4da3cc131c277265c5705d961d0e16dcd444c47..3543a692b24dd33449f3b08da476aaf3d775b310 100644 (file)
@@ -15,9 +15,6 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.Arrays;
 import java.util.Collection;
@@ -30,6 +27,7 @@ import org.opendaylight.openflowplugin.api.ConnectionException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -100,9 +98,10 @@ public class DeviceInitializationUtils {
     public static ListenableFuture<Void> initializeNodeInformation(final DeviceContext deviceContext, final boolean switchFeaturesMandatory) {
         Preconditions.checkArgument(deviceContext != null);
         final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
+        final DeviceInfo deviceInfo = deviceContext.getDeviceInfo();
         final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
-        final short version = deviceState.getVersion();
-        LOG.trace("initalizeNodeInformation for node {}", deviceState.getNodeId());
+        final short version = deviceInfo.getVersion();
+        LOG.trace("initalizeNodeInformation for node {}", deviceInfo.getNodeId());
         final SettableFuture<Void> returnFuture = SettableFuture.<Void>create();
         addNodeToOperDS(deviceContext, returnFuture);
         final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture;
@@ -115,14 +114,14 @@ public class DeviceInitializationUtils {
             // create empty tables after device description is processed
             chainTableTrunkWriteOF10(deviceContext, deviceFeaturesFuture);
 
-            final short ofVersion = deviceContext.getDeviceState().getVersion();
+            final short ofVersion = deviceInfo.getVersion();
             final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
             final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = deviceContext.oook()
                     .lookupTranslator(translatorKey);
-            final BigInteger dataPathId = deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId();
+            final BigInteger dataPathId = deviceContext.getDeviceInfo().getDatapathId();
 
             for (final PortGrouping port : connectionContext.getFeatures().getPhyPort()) {
-                final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, deviceContext.getDeviceState(), null);
+                final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, deviceContext.getDeviceInfo(), null);
 
                 final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(
                         dataPathId.toString(), port.getPortNo(), ofVersion);
@@ -131,19 +130,19 @@ public class DeviceInitializationUtils {
                 ncBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class,
                         new FlowCapableNodeConnectorStatisticsDataBuilder().build());
                 final NodeConnector connector = ncBuilder.build();
-                final InstanceIdentifier<NodeConnector> connectorII = deviceState.getNodeInstanceIdentifier().child(
+                final InstanceIdentifier<NodeConnector> connectorII = deviceInfo.getNodeInstanceIdentifier().child(
                         NodeConnector.class, connector.getKey());
                 try {
                     deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, connectorII, connector);
                 } catch (final Exception e) {
-                    LOG.debug("Failed to write node {} to DS ", deviceContext.getDeviceState().getNodeId().toString(),
+                    LOG.debug("Failed to write node {} to DS ", deviceInfo.getNodeId().toString(),
                             e);
                 }
 
             }
         } else if (OFConstants.OFP_VERSION_1_3 == version) {
             final Capabilities capabilities = connectionContext.getFeatures().getCapabilities();
-            LOG.debug("Setting capabilities for device {}", deviceContext.getDeviceState().getNodeId());
+            LOG.debug("Setting capabilities for device {}", deviceInfo.getNodeId());
             DeviceStateUtil.setDeviceStateBasedOnV13Capabilities(deviceState, capabilities);
             deviceFeaturesFuture = createDeviceFeaturesForOF13(deviceContext, deviceState, switchFeaturesMandatory);
         } else {
@@ -154,7 +153,7 @@ public class DeviceInitializationUtils {
         Futures.addCallback(deviceFeaturesFuture, new FutureCallback<List<RpcResult<List<MultipartReply>>>>() {
             @Override
             public void onSuccess(final List<RpcResult<List<MultipartReply>>> result) {
-                LOG.debug("All init data for node {} is in submited.", deviceState.getNodeId());
+                LOG.debug("All init data for node {} is in submited.", deviceInfo.getNodeId());
                 returnFuture.set(null);
             }
 
@@ -163,7 +162,7 @@ public class DeviceInitializationUtils {
                 // FIXME : remove session
                 LOG.trace("Device capabilities gathering future failed.");
                 LOG.trace("more info in exploration failure..", t);
-                LOG.debug("All init data for node {} was not submited correctly - connection has to go down.", deviceState.getNodeId());
+                LOG.debug("All init data for node {} was not submited correctly - connection has to go down.", deviceInfo.getNodeId());
                 returnFuture.setException(t);
             }
         });
@@ -173,13 +172,13 @@ public class DeviceInitializationUtils {
     private static void addNodeToOperDS(final DeviceContext deviceContext, final SettableFuture<Void> future) {
         Preconditions.checkArgument(deviceContext != null);
         final DeviceState deviceState = deviceContext.getDeviceState();
-        final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(
+        final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceContext.getDeviceInfo().getNodeId()).setNodeConnector(
                 Collections.<NodeConnector>emptyList());
         try {
-            deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(),
+            deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
                     nodeBuilder.build());
         } catch (final Exception e) {
-            LOG.warn("Failed to write node {} to DS ", deviceState.getNodeId(), e);
+            LOG.warn("Failed to write node {} to DS ", deviceContext.getDeviceInfo().getNodeId(), e);
             future.cancel(true);
         }
     }
@@ -187,7 +186,7 @@ public class DeviceInitializationUtils {
     private static ListenableFuture<List<RpcResult<List<MultipartReply>>>> createDeviceFeaturesForOF10(
             final DeviceContext deviceContext, final DeviceState deviceState) {
         final ListenableFuture<RpcResult<List<MultipartReply>>> replyDesc = getNodeStaticInfo(MultipartType.OFPMPDESC,
-                deviceContext, deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
         return Futures.allAsList(Arrays.asList(replyDesc));
     }
@@ -196,7 +195,7 @@ public class DeviceInitializationUtils {
             final DeviceContext deviceContext, final DeviceState deviceState, final boolean switchFeaturesMandatory) {
 
         final ListenableFuture<RpcResult<List<MultipartReply>>> replyDesc = getNodeStaticInfo(MultipartType.OFPMPDESC,
-                deviceContext, deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
         //first process description reply, write data to DS and write consequent data if successful
         return Futures.transform(replyDesc,
@@ -206,32 +205,32 @@ public class DeviceInitializationUtils {
                             final RpcResult<List<MultipartReply>> rpcResult) throws Exception {
 
                         translateAndWriteReply(MultipartType.OFPMPDESC, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), rpcResult.getResult());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), rpcResult.getResult());
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyMeterFeature = getNodeStaticInfo(
                                 MultipartType.OFPMPMETERFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
                         createSuccessProcessingCallback(MultipartType.OFPMPMETERFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyMeterFeature);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyMeterFeature);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyGroupFeatures = getNodeStaticInfo(
                                 MultipartType.OFPMPGROUPFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPGROUPFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyGroupFeatures);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyGroupFeatures);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyTableFeatures = getNodeStaticInfo(
                                 MultipartType.OFPMPTABLEFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPTABLEFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyTableFeatures);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyTableFeatures);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyPortDescription = getNodeStaticInfo(
-                                MultipartType.OFPMPPORTDESC, deviceContext, deviceState.getNodeInstanceIdentifier(),
-                                deviceState.getVersion());
+                                MultipartType.OFPMPPORTDESC, deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
+                                deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPPORTDESC, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyPortDescription);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyPortDescription);
                         if (switchFeaturesMandatory) {
                             return Futures.allAsList(Arrays.asList(replyMeterFeature, replyGroupFeatures,
                                     replyTableFeatures, replyPortDescription));
@@ -314,11 +313,11 @@ public class DeviceInitializationUtils {
                         final MultipartReplyPortDesc portDesc = ((MultipartReplyPortDescCase) body)
                                 .getMultipartReplyPortDesc();
                         for (final PortGrouping port : portDesc.getPorts()) {
-                            final short ofVersion = dContext.getDeviceState().getVersion();
+                            final short ofVersion = dContext.getDeviceInfo().getVersion();
                             final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
                             final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = dContext.oook()
                                     .lookupTranslator(translatorKey);
-                            final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext.getDeviceState(), null);
+                            final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext.getDeviceInfo(), null);
 
                             final BigInteger dataPathId = dContext.getPrimaryConnectionContext().getFeatures()
                                     .getDatapathId();
@@ -343,18 +342,18 @@ public class DeviceInitializationUtils {
                 }
             }
         } catch (final Exception e) {
-            LOG.debug("Failed to write node {} to DS ", dContext.getDeviceState().getNodeId().toString(), e);
+            LOG.debug("Failed to write node {} to DS ", dContext.getDeviceInfo().getNodeId().toString(), e);
         }
     }
 
     private static void createEmptyFlowCapableNodeInDs(final DeviceContext deviceContext) {
         final FlowCapableNodeBuilder flowCapableNodeBuilder = new FlowCapableNodeBuilder();
-        final InstanceIdentifier<FlowCapableNode> fNodeII = deviceContext.getDeviceState().getNodeInstanceIdentifier()
+        final InstanceIdentifier<FlowCapableNode> fNodeII = deviceContext.getDeviceInfo().getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class);
         try {
             deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, flowCapableNodeBuilder.build());
         } catch (final Exception e) {
-            LOG.debug("Failed to write node {} to DS ", deviceContext.getDeviceState().getNodeId().toString(), e);
+            LOG.debug("Failed to write node {} to DS ", deviceContext.getDeviceInfo().getNodeId().toString(), e);
         }
     }
 
@@ -365,7 +364,7 @@ public class DeviceInitializationUtils {
 
         if (remoteAddress == null) {
             LOG.warn("IP address of the node {} cannot be obtained. No connection with switch.", deviceContext
-                    .getDeviceState().getNodeId());
+                    .getDeviceInfo().getNodeId());
             return null;
         }
         LOG.info("IP address of switch is: {}", remoteAddress);
@@ -387,7 +386,7 @@ public class DeviceInitializationUtils {
             try {
                 dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableII, tableBuilder.build());
             } catch (final Exception e) {
-                LOG.debug("Failed to write node {} to DS ", dContext.getDeviceState().getNodeId().toString(), e);
+                LOG.debug("Failed to write node {} to DS ", dContext.getDeviceInfo().getNodeId().toString(), e);
             }
 
         }
@@ -401,7 +400,7 @@ public class DeviceInitializationUtils {
             public void onSuccess(final RpcResult<List<MultipartReply>> rpcResult) {
                 final List<MultipartReply> result = rpcResult.getResult();
                 if (result != null) {
-                    LOG.info("Static node {} info: {} collected", deviceContext.getDeviceState().getNodeId(), type);
+                    LOG.info("Static node {} info: {} collected", deviceContext.getDeviceInfo().getNodeId(), type);
                     translateAndWriteReply(type, deviceContext, nodeII, result);
                 } else {
                     final Iterator<RpcError> rpcErrorIterator = rpcResult.getErrors().iterator();
@@ -489,8 +488,8 @@ public class DeviceInitializationUtils {
                 }
                 if (allSucceeded) {
                     createEmptyFlowCapableNodeInDs(deviceContext);
-                    makeEmptyTables(deviceContext, deviceContext.getDeviceState().getNodeInstanceIdentifier(),
-                            deviceContext.getDeviceState().getFeatures().getTables());
+                    makeEmptyTables(deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
+                            deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
                 }
             }
 
index 05806e9b9a120077b26bfd59ab8a2572e43e2602..3dd74d15e5928a6b02812a572d0dc2e33b15c9b6 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.impl.services.FlowCapableTransactionServiceImpl;
 import org.opendaylight.openflowplugin.impl.services.NodeConfigServiceImpl;
 import org.opendaylight.openflowplugin.impl.services.PacketProcessingServiceImpl;
@@ -85,7 +86,9 @@ public class MdSalRegistrationUtils {
      * @param newRole       - role validation for {@link OfpRole#BECOMEMASTER}
      */
     public static void registerMasterServices(@CheckForNull final RpcContext rpcContext,
-                                              @CheckForNull final DeviceContext deviceContext, @CheckForNull final OfpRole newRole) {
+                                              @CheckForNull final DeviceContext deviceContext,
+                                              @CheckForNull final OfpRole newRole,
+                                              final ExtensionConverterProvider extensionConverterProvider) {
         Preconditions.checkArgument(rpcContext != null);
         Preconditions.checkArgument(deviceContext != null);
         Preconditions.checkArgument(newRole != null);
@@ -127,7 +130,8 @@ public class MdSalRegistrationUtils {
         rpcContext.registerRpcServiceImplementation(SalFlatBatchService.class, salFlatBatchService);
 
         // TODO: experimenter symmetric and multipart message services
-        rpcContext.registerRpcServiceImplementation(SalExperimenterMessageService.class, new SalExperimenterMessageServiceImpl(rpcContext, deviceContext));
+        rpcContext.registerRpcServiceImplementation(SalExperimenterMessageService.class,
+                new SalExperimenterMessageServiceImpl(rpcContext, deviceContext, extensionConverterProvider));
     }
 
     /**
index 4c71ea59e7ed4510d3c9f4f1996d80539ad4170c..477d73ab7ac7fc6fdcdd82afe0f30d30789e2fa9 100644 (file)
@@ -10,26 +10,22 @@ package org.opendaylight.openflowplugin.impl.util;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
+import java.math.BigInteger;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 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.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.math.BigInteger;
-import java.util.List;
-import java.util.Objects;
-
 /**
  * Created by Tomas Slusny on 23.3.2016.
  */
index 4717561f7de4d8af3d5837bc0e87466bde33ff7c..b3096bb666b935815a69e226c16a0b59950a80ff 100644 (file)
@@ -1,14 +1,20 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327;
 
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
-import org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderImpl;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider;
+import org.osgi.framework.BundleContext;
 
-public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.AbstractOpenFlowProviderModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class OpenFlowProviderModule extends AbstractOpenFlowProviderModule {
 
-    private static final Logger LOG = LoggerFactory.getLogger(OpenFlowProviderModule.class);
+    private BundleContext bundleContext;
 
     public OpenFlowProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
@@ -19,37 +25,38 @@ public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.ope
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
+    public AutoCloseable createInstance() {
+        // The service is provided via blueprint so wait for and return it here for backwards compatibility.
+        String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName());
+        final WaitingServiceTracker<OpenFlowPluginProvider> tracker = WaitingServiceTracker.create(
+                OpenFlowPluginProvider.class, bundleContext, typeFilter);
+        final OpenFlowPluginProvider openflowPluginProvider = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        // We don't want to call close on the actual service as its life cycle is controlled by blueprint but
+        // we do want to close the tracker so create a proxy to override close appropriately.
+        return Reflection.newProxy(OpenFlowPluginProviderProxyInterface.class, new AbstractInvocationHandler() {
+            @Override
+            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+                if (method.getName().equals("close")) {
+                    tracker.close();
+                    return null;
+                } else {
+                    return method.invoke(openflowPluginProvider, args);
+                }
+            }
+        });
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
     }
 
     @Override
-    public java.lang.AutoCloseable createInstance() {
-        LOG.info("Initializing new OFP southbound.");
-        OpenflowPortsUtil.init();
-        final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
-
-        openflowPluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
-        openflowPluginProvider.setDataBroker(getDataBrokerDependency());
-        openflowPluginProvider.setRpcProviderRegistry(getRpcRegistryDependency());
-        openflowPluginProvider.setNotificationProviderService(getNotificationAdapterDependency());
-        openflowPluginProvider.setNotificationPublishService(getNotificationPublishAdapterDependency());
-        openflowPluginProvider.setSwitchFeaturesMandatory(getSwitchFeaturesMandatory());
-        openflowPluginProvider.setIsStatisticsPollingOff(getIsStatisticsPollingOff());
-        openflowPluginProvider.setEntityOwnershipService(getEntityOwnershipServiceDependency());
-        openflowPluginProvider.setIsStatisticsRpcEnabled(getIsStatisticsRpcEnabled());
-        openflowPluginProvider.setBarrierCountLimit(getBarrierCountLimit().getValue());
-        openflowPluginProvider.setBarrierInterval(getBarrierIntervalTimeoutLimit().getValue());
-        openflowPluginProvider.setEchoReplyTimeout(getEchoReplyTimeout().getValue());
-
-        openflowPluginProvider.initialize();
-
-        LOG.info("Configured values, StatisticsPollingOff:{}, SwitchFeaturesMandatory:{}, BarrierCountLimit:{}, BarrierTimeoutLimit:{}, EchoReplyTimeout:{}",
-                getIsStatisticsPollingOff(), getSwitchFeaturesMandatory(), getBarrierCountLimit().getValue(),
-                getBarrierIntervalTimeoutLimit().getValue(), getEchoReplyTimeout().getValue());
-
-
-        return openflowPluginProvider;
+    public boolean canReuseInstance(AbstractOpenFlowProviderModule oldModule) {
+        return true;
     }
 
+    private static interface OpenFlowPluginProviderProxyInterface extends OpenFlowPluginProvider,
+            OpenFlowPluginExtensionRegistratorProvider {
+    }
 }
index e7448330741b378ee1124bf136fb4478f046f4bf..454ba6b5a6e2ab076c0f23ba55ce62f555a5c2d7 100644 (file)
@@ -8,6 +8,29 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327;
-public class OpenFlowProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.AbstractOpenFlowProviderModuleFactory {
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class OpenFlowProviderModuleFactory extends AbstractOpenFlowProviderModuleFactory {
+    @Override
+    public OpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            OpenFlowProviderModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        OpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public OpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            BundleContext bundleContext) {
+        OpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }
diff --git a/openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml b/openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml
new file mode 100644 (file)
index 0000000..20b907b
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+  <bean id="ofPluginProviderFactory" class="org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderFactoryImpl"/>
+
+  <service ref="ofPluginProviderFactory" interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"
+          odl:type="default"/>
+</blueprint>
\ No newline at end of file
index 63c28cdb6349a2d60513a7602fe119c8f39cfda4..39d4e4c917c279e9819fa23bac850d7777636226 100644 (file)
@@ -11,31 +11,34 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.TimerTask;
+import java.math.BigInteger;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ServiceChangeListener;
+import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
+import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
 @RunWith(MockitoJUnitRunner.class)
 public class LifecycleConductorImplTest {
 
@@ -46,7 +49,7 @@ public class LifecycleConductorImplTest {
     @Mock
     private ServiceChangeListener serviceChangeListener;
     @Mock
-    private ConcurrentHashMap<NodeId, ServiceChangeListener> serviceChangeListeners;
+    private ConcurrentHashMap<DeviceInfo, ServiceChangeListener> serviceChangeListeners;
     @Mock
     private DeviceContext deviceContext;
     @Mock
@@ -67,6 +70,12 @@ public class LifecycleConductorImplTest {
     private ListenableFuture<Void> listenableFuture;
     @Mock
     private StatisticsManager statisticsManager;
+    @Mock
+    private RpcManager rpcManager;
+    @Mock
+    private RpcContext rpcContext;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     private NodeId nodeId = new NodeId("openflow-junit:1");
     private OfpRole ofpRole = OfpRole.NOCHANGE;
@@ -74,21 +83,27 @@ public class LifecycleConductorImplTest {
 
     @Before
     public void setUp() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
 
         lifecycleConductor = new LifecycleConductorImpl(messageIntelligenceAgency);
-        lifecycleConductor.setSafelyDeviceManager(deviceManager);
-        lifecycleConductor.setSafelyStatisticsManager(statisticsManager);
+        lifecycleConductor.setSafelyManager(deviceManager);
+        lifecycleConductor.setSafelyManager(statisticsManager);
+        lifecycleConductor.setSafelyManager(rpcManager);
 
-        when(connectionContext.getFeatures()).thenReturn(featuresReply);
+        when(deviceManager.gainContext(Mockito.<DeviceInfo>any())).thenReturn(deviceContext);
+        when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
+        when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        when(rpcManager.gainContext(Mockito.<DeviceInfo>any())).thenReturn(rpcContext);
+        when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
+        when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        when(rpcManager.gainContext(Mockito.<DeviceInfo>any())).thenReturn(rpcContext);
     }
 
 
 
     @Test
     public void addOneTimeListenerWhenServicesChangesDoneTest() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
         assertEquals(false,lifecycleConductor.isServiceChangeListenersEmpty());
     }
 
@@ -98,9 +113,9 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void notifyServiceChangeListenersTest1() {
-        lifecycleConductor.notifyServiceChangeListeners(nodeId,true);
+        lifecycleConductor.notifyServiceChangeListeners(deviceInfo,true);
         when(serviceChangeListeners.size()).thenReturn(0);
-        verify(serviceChangeListeners,times(0)).remove(nodeId);
+        verify(serviceChangeListeners,times(0)).remove(deviceInfo);
     }
 
     /**
@@ -108,9 +123,9 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void notifyServiceChangeListenersTest2() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
         assertEquals(false,lifecycleConductor.isServiceChangeListenersEmpty());
-        lifecycleConductor.notifyServiceChangeListeners(nodeId,true);
+        lifecycleConductor.notifyServiceChangeListeners(deviceInfo,true);
         assertEquals(true,lifecycleConductor.isServiceChangeListenersEmpty());
     }
 
@@ -120,8 +135,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleInitializationDoneTest1() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
-        lifecycleConductor.roleInitializationDone(nodeId,false);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
+        lifecycleConductor.roleInitializationDone(deviceInfo,false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 
@@ -130,8 +145,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleInitializationDoneTest2() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
-        lifecycleConductor.roleInitializationDone(nodeId,true);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
+        lifecycleConductor.roleInitializationDone(deviceInfo,true);
         verify(deviceContext,times(0)).shutdownConnection();
     }
 
@@ -140,10 +155,10 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleChangeOnDeviceTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,ofpRole,false);
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(null);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,ofpRole,false);
         verify(deviceContext,times(0)).shutdownConnection();
-        lifecycleConductor.roleChangeOnDevice(nodeId,false,ofpRole,false);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,false,ofpRole,false);
         verify(deviceContext,times(0)).shutdownConnection();
     }
 
@@ -152,8 +167,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleChangeOnDeviceTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.roleChangeOnDevice(nodeId,false,ofpRole,false);
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,false,ofpRole,false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 
@@ -163,8 +178,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleChangeOnDeviceTest3() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,ofpRole,true);
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,ofpRole,true);
         verify(deviceContext,times(0)).shutdownConnection();
     }
 
@@ -174,10 +189,10 @@ public class LifecycleConductorImplTest {
     @Test
     public void roleChangeOnDeviceTest4() {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        when(deviceContext.onClusterRoleChange(null, OfpRole.BECOMEMASTER)).thenReturn(listenableFuture);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,OfpRole.BECOMEMASTER,false);
-        verify(statisticsManager).startScheduling(nodeId);
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(deviceContext);
+        when(deviceManager.onClusterRoleChange(deviceInfo, OfpRole.BECOMEMASTER)).thenReturn(listenableFuture);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,OfpRole.BECOMEMASTER,false);
+        verify(statisticsManager).startScheduling(Mockito.<DeviceInfo>any());
     }
 
     /**
@@ -186,29 +201,10 @@ public class LifecycleConductorImplTest {
     @Test
     public void roleChangeOnDeviceTest5() {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        when(deviceContext.onClusterRoleChange(null, OfpRole.BECOMESLAVE)).thenReturn(listenableFuture);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,OfpRole.BECOMESLAVE,false);
-        verify(statisticsManager).stopScheduling(nodeId);
-    }
-
-    /**
-     * If getDeviceContext returns null nothing should happen
-     */
-    @Test
-    public void gainVersionSafelyTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        assertNull(lifecycleConductor.gainVersionSafely(nodeId));
-    }
-
-    /**
-     * If getDeviceContext returns deviceContext getPrimaryConnectionContext() should be called
-     */
-    @Test
-    public void gainVersionSafelyTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.gainVersionSafely(nodeId);
-        verify(deviceContext,times(1)).getPrimaryConnectionContext();
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(deviceContext);
+        when(deviceManager.onClusterRoleChange(deviceInfo, OfpRole.BECOMESLAVE)).thenReturn(listenableFuture);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,OfpRole.BECOMESLAVE,false);
+        verify(statisticsManager).stopScheduling(Mockito.<DeviceInfo>any());
     }
 
     /**
@@ -216,8 +212,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void gainConnectionStateSafelyTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        assertNull(lifecycleConductor.gainConnectionStateSafely(nodeId));
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(null);
+        assertNull(lifecycleConductor.gainConnectionStateSafely(deviceInfo));
     }
 
     /**
@@ -225,8 +221,7 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void gainConnectionStateSafelyTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.gainConnectionStateSafely(nodeId);
+        lifecycleConductor.gainConnectionStateSafely(deviceInfo);
         verify(deviceContext,times(1)).getPrimaryConnectionContext();
     }
 
@@ -235,8 +230,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void reserveXidForDeviceMessageTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        assertNull(lifecycleConductor.reserveXidForDeviceMessage(nodeId));
+        when(deviceManager.gainContext(deviceInfo)).thenReturn(null);
+        assertNull(lifecycleConductor.reserveXidForDeviceMessage(deviceInfo));
     }
 
     /**
@@ -244,8 +239,7 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void reserveXidForDeviceMessageTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.reserveXidForDeviceMessage(nodeId);
+        lifecycleConductor.reserveXidForDeviceMessage(deviceInfo);
         verify(deviceContext,times(1)).reserveXidForDeviceMessage();
     }
 
@@ -254,7 +248,7 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void deviceStartInitializationDoneTest() {
-        lifecycleConductor.deviceStartInitializationDone(nodeId, false);
+        lifecycleConductor.deviceStartInitializationDone(deviceInfo, false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 
@@ -263,7 +257,7 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void deviceInitializationDoneTest() {
-        lifecycleConductor.deviceInitializationDone(nodeId, false);
+        lifecycleConductor.deviceInitializationDone(deviceInfo, false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 }
index 3b6f0086ea80fba8467ee7f80f4089ba72718d1b..cb7c958b5c239f34926e5eb6fb5b54e112c69183 100644 (file)
@@ -8,8 +8,11 @@
 
 package org.opendaylight.openflowplugin.impl;
 
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.Futures;
@@ -23,9 +26,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService;
 
@@ -58,6 +61,9 @@ public class OpenFlowPluginProviderImplTest {
 
     private static final long RPC_REQUESTS_QUOTA = 500;
     private static final long GLOBAL_NOTIFICATION_QUOTA = 131072;
+    private static final int THREAD_POOL_MIN_THREADS = 1;
+    private static final int THREAD_POOL_MAX_THREADS = 32000;
+    private static final long THREAD_POOL_TIMEOUT = 60;
 
     private OpenFlowPluginProviderImpl provider;
 
@@ -69,7 +75,13 @@ public class OpenFlowPluginProviderImplTest {
         when(rpcProviderRegistry.addRpcImplementation(eq(StatisticsManagerControlService.class), any())).thenReturn(controlServiceRegistration);
         when(switchConnectionProvider.startup()).thenReturn(Futures.immediateCheckedFuture(null));
 
-        provider = new OpenFlowPluginProviderImpl(RPC_REQUESTS_QUOTA, GLOBAL_NOTIFICATION_QUOTA);
+        provider = new OpenFlowPluginProviderImpl(
+                RPC_REQUESTS_QUOTA,
+                GLOBAL_NOTIFICATION_QUOTA,
+                THREAD_POOL_MIN_THREADS,
+                THREAD_POOL_MAX_THREADS,
+                THREAD_POOL_TIMEOUT);
+
         provider.setDataBroker(dataBroker);
         provider.setRpcProviderRegistry(rpcProviderRegistry);
         provider.setNotificationProviderService(notificationService);
index 813c1bd372a04084d63bc47ff05d8e098847a437..9a4338ea621c0d1b01336bbe72697f051c2f0531 100644 (file)
@@ -9,7 +9,11 @@ package org.opendaylight.openflowplugin.impl.connection;
 
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.TimeUnit;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -25,6 +29,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyList
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
+import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
@@ -62,7 +67,11 @@ public class ConnectionManagerImplTest {
      */
     @Before
     public void setUp() {
-        connectionManagerImpl = new ConnectionManagerImpl(ECHO_REPLY_TIMEOUT);
+        final ThreadPoolLoggingExecutor threadPool = new ThreadPoolLoggingExecutor(0, Integer.MAX_VALUE,
+                60L, TimeUnit.SECONDS,
+                new SynchronousQueue<>(), "ofppool");
+
+        connectionManagerImpl = new ConnectionManagerImpl(ECHO_REPLY_TIMEOUT, threadPool);
         connectionManagerImpl.setDeviceConnectedHandler(deviceConnectedHandler);
         final InetSocketAddress deviceAddress = InetSocketAddress.createUnresolved("yahoo", 42);
         Mockito.when(connection.getRemoteAddress()).thenReturn(deviceAddress);
index 7a2764be510d40bd3ea220eb9a59c3538bbc9937..ef5aa3063f41edbf41b909fead6f7d6cbd97771a 100644 (file)
@@ -1,14 +1,14 @@
 package org.opendaylight.openflowplugin.impl.connection;
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import junit.framework.TestCase;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 public class OutboundQueueProviderImplTest extends TestCase {
 
     private static final Long DUMMY_ENTRY_NUMBER = 44L;
index 90d908b6b460ccf609c6ed3ec34107f0b13c3b66..b20a4f999e6b915a71e22e681c486e91844afa9a 100644 (file)
@@ -63,6 +63,7 @@ public class HandshakeListenerImplTest {
         connectionContextSpy = Mockito.spy(new ConnectionContextImpl(connectionAdapter));
         Mockito.when(connectionContextSpy.getConnectionAdapter()).thenReturn(connectionAdapter);
         Mockito.when(features.getDatapathId()).thenReturn(BigInteger.TEN);
+        Mockito.doNothing().when(connectionContextSpy).handshakeSuccessful();
         handshakeListener = new HandshakeListenerImpl(connectionContextSpy, deviceConnectedHandler);
         handshakeListener.setHandshakeContext(handshakeContext);
     }
@@ -78,6 +79,7 @@ public class HandshakeListenerImplTest {
         Mockito.verify(connectionContextSpy).changeStateToWorking();
         Mockito.verify(connectionContextSpy).setFeatures(Matchers.any(FeaturesReply.class));
         Mockito.verify(connectionContextSpy).setNodeId(nodeIdCaptor.capture());
+        Mockito.verify(connectionContextSpy).handshakeSuccessful();
         Mockito.verify(deviceConnectedHandler).deviceConnected(connectionContextSpy);
         Mockito.verify(handshakeContext).close();
 
index a361d61ac9ca60eeda8a1d0ea438a5ec88f60382..3b051fc25e2b5d9f3d61dbdd72c521ec08d9494a 100644 (file)
@@ -11,6 +11,9 @@ package org.opendaylight.openflowplugin.impl.connection.listener;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.SettableFuture;
 import java.net.InetSocketAddress;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.TimeUnit;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -21,6 +24,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.impl.connection.ConnectionContextImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
@@ -66,7 +70,11 @@ public class SystemNotificationsListenerImplTest {
         Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
 
-        systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext, ECHO_REPLY_TIMEOUT);
+        final ThreadPoolLoggingExecutor threadPool = new ThreadPoolLoggingExecutor(0, Integer.MAX_VALUE,
+                60L, TimeUnit.SECONDS,
+                new SynchronousQueue<>(), "opfpool");
+
+        systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext, ECHO_REPLY_TIMEOUT, threadPool);
     }
 
     @After
index 07e345168a52e4d77b538a2b47bf6a9f0e84cdda..f6298433c6b7afbd7aab4c60a029c3acee5c8237 100644 (file)
@@ -29,16 +29,13 @@ import io.netty.util.Timeout;
 import java.math.BigInteger;
 import java.net.InetSocketAddress;
 import java.util.concurrent.atomic.AtomicLong;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
 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.NotificationPublishService;
@@ -53,6 +50,7 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -67,9 +65,7 @@ import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKe
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
-import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
@@ -89,18 +85,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -119,14 +124,14 @@ public class DeviceContextImplTest {
     private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("55");
     Xid xid;
     Xid xidMulti;
-    DeviceContextImpl deviceContext;
+
+    DeviceContext deviceContext;
     @Mock
     TransactionChainManager txChainManager;
     @Mock
     RequestContext<GetAsyncReply> requestContext;
     @Mock
     RequestContext<MultipartReply> requestContextMultiReply;
-
     @Mock
     ConnectionContext connectionContext;
     @Mock
@@ -163,6 +168,8 @@ public class DeviceContextImplTest {
     private MessageTranslator<Object, Object> messageTranslatorFlowRemoved;
     @Mock
     private LifecycleConductor lifecycleConductor;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     private InOrder inOrderDevState;
 
@@ -171,49 +178,41 @@ public class DeviceContextImplTest {
     private DeviceContext deviceContextSpy;
 
     @Before
-    public void setUp() {
+    public void setUp() throws Exception{
         final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures.immediateCheckedFuture(Optional.<Node>absent());
         Mockito.when(rTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
         Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(rTx);
         Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
-        Mockito.when(deviceState.getNodeId()).thenReturn(nodeId);
-//        txChainManager = new TransactionChainManager(dataBroker, deviceState);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE);
         final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
         final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
         Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
-        Mockito.doAnswer(new Answer<Object>() {
-            @SuppressWarnings("unchecked")
-            @Override
-            public Object answer(final InvocationOnMock invocation) {
-                settableFuture.set((RpcResult<GetAsyncReply>) invocation.getArguments()[0]);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            settableFuture.set((RpcResult<GetAsyncReply>) invocation.getArguments()[0]);
+            return null;
         }).when(requestContext).setResult(any(RpcResult.class));
 
         Mockito.when(requestContextMultiReply.getFuture()).thenReturn(settableFutureMultiReply);
-        Mockito.doAnswer(new Answer<Object>() {
-            @SuppressWarnings("unchecked")
-            @Override
-            public Object answer(final InvocationOnMock invocation) {
-                settableFutureMultiReply.set((RpcResult<MultipartReply>) invocation.getArguments()[0]);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            settableFutureMultiReply.set((RpcResult<MultipartReply>) invocation.getArguments()[0]);
+            return null;
         }).when(requestContextMultiReply).setResult(any(RpcResult.class));
         Mockito.when(txChainFactory.newWriteOnlyTransaction()).thenReturn(wTx);
         Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(rTx);
         Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
         Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
+        Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo);
         final FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
         when(connectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
         when(connectionContext.getFeatures().getCapabilities()).thenReturn(mock(Capabilities.class));
 
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.when(featuresOutput.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
         Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
-        Mockito.when(messageTranslatorPacketReceived.translate(any(Object.class), any(DeviceState.class), any(Object.class))).thenReturn(mock(PacketReceived.class));
-        Mockito.when(messageTranslatorFlowCapableNodeConnector.translate(any(Object.class), any(DeviceState.class), any(Object.class))).thenReturn(mock(FlowCapableNodeConnector.class));
+        Mockito.when(messageTranslatorPacketReceived.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(mock(PacketReceived.class));
+        Mockito.when(messageTranslatorFlowCapableNodeConnector.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(mock(FlowCapableNodeConnector.class));
         Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PacketIn.class.getName())))).thenReturn(messageTranslatorPacketReceived);
         Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PortGrouping.class.getName())))).thenReturn(messageTranslatorFlowCapableNodeConnector);
         Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3,
@@ -221,27 +220,28 @@ public class DeviceContextImplTest {
                 .thenReturn(messageTranslatorFlowRemoved);
         Mockito.when(lifecycleConductor.getMessageIntelligenceAgency()).thenReturn(messageIntelligenceAgency);
 
-        deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary, false);
-
+        deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary);
         deviceContextSpy = Mockito.spy(deviceContext);
 
         xid = new Xid(atomicLong.incrementAndGet());
         xidMulti = new Xid(atomicLong.incrementAndGet());
+
+        Mockito.doNothing().when(deviceContextSpy).writeToTransaction(Mockito.<LogicalDatastoreType>any(), Mockito.<InstanceIdentifier>any(), any());
     }
 
     @Test(expected = NullPointerException.class)
     public void testDeviceContextImplConstructorNullDataBroker() throws Exception {
-        new DeviceContextImpl(connectionContext, deviceState, null, lifecycleConductor, outboundQueueProvider, translatorLibrary, false).close();
+        new DeviceContextImpl(connectionContext, deviceState, null, lifecycleConductor, outboundQueueProvider, translatorLibrary).close();
     }
 
     @Test(expected = NullPointerException.class)
     public void testDeviceContextImplConstructorNullDeviceState() throws Exception {
-        new DeviceContextImpl(connectionContext, null, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary, false).close();
+        new DeviceContextImpl(connectionContext, null, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary).close();
     }
 
     @Test(expected = NullPointerException.class)
     public void testDeviceContextImplConstructorNullTimer() throws Exception {
-        new DeviceContextImpl(null, deviceState, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary, false).close();
+        new DeviceContextImpl(null, deviceState, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary).close();
     }
 
     @Test
@@ -265,10 +265,10 @@ public class DeviceContextImplTest {
     public void testInitialSubmitTransaction() throws Exception {
         Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
         final InstanceIdentifier<Nodes> dummyII = InstanceIdentifier.create(Nodes.class);
-        deviceContext.getTransactionChainManager().activateTransactionManager() ;
-        deviceContext.getTransactionChainManager().enableSubmit();
+        ((DeviceContextImpl) deviceContext).getTransactionChainManager().activateTransactionManager() ;
+        ((DeviceContextImpl) deviceContext).getTransactionChainManager().enableSubmit();
         deviceContext.addDeleteToTxChain(LogicalDatastoreType.CONFIGURATION, dummyII);
-        deviceContext.initialSubmitTransaction();
+        ((DeviceContextImpl) deviceContext).initialSubmitTransaction();
         verify(wTx).submit();
     }
 
@@ -316,8 +316,8 @@ public class DeviceContextImplTest {
     @Test
     public void testAddDeleteToTxChain() throws Exception{
         final InstanceIdentifier<Nodes> dummyII = InstanceIdentifier.create(Nodes.class);
-        deviceContext.getTransactionChainManager().activateTransactionManager() ;
-        deviceContext.getTransactionChainManager().enableSubmit();
+        ((DeviceContextImpl) deviceContext).getTransactionChainManager().activateTransactionManager() ;
+        ((DeviceContextImpl) deviceContext).getTransactionChainManager().enableSubmit();
         deviceContext.addDeleteToTxChain(LogicalDatastoreType.CONFIGURATION, dummyII);
         verify(wTx).delete(eq(LogicalDatastoreType.CONFIGURATION), eq(dummyII));
     }
@@ -327,8 +327,8 @@ public class DeviceContextImplTest {
      */
     @Test
     public void testSubmitTransaction() throws Exception {
-        deviceContext.getTransactionChainManager().activateTransactionManager() ;
-        deviceContext.getTransactionChainManager().enableSubmit();
+        ((DeviceContextImpl) deviceContext).getTransactionChainManager().activateTransactionManager() ;
+        ((DeviceContextImpl) deviceContext).getTransactionChainManager().enableSubmit();
         assertTrue(deviceContext.submitTransaction());
     }
 
@@ -356,13 +356,6 @@ public class DeviceContextImplTest {
         assertNotNull(deviceMeterRegistry);
     }
 
-    @Test
-    public void testGetRpcContext() {
-        final RpcContext rpcContext = mock(RpcContext.class);
-        deviceContext.setRpcContext(rpcContext);
-        assertNotNull(deviceContext.getRpcContext());
-    }
-
     @Test
     public void testProcessReply() {
         final Error mockedError = mock(Error.class);
@@ -419,7 +412,7 @@ public class DeviceContextImplTest {
         when(connectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
 
         final NodeId dummyNodeId = new NodeId("dummyNodeId");
-        when(deviceState.getNodeId()).thenReturn(dummyNodeId);
+        when(deviceInfo.getNodeId()).thenReturn(dummyNodeId);
 
         final ConnectionContext mockedAuxiliaryConnectionContext = prepareConnectionContext();
         deviceContext.addAuxiliaryConnectionContext(mockedAuxiliaryConnectionContext);
@@ -443,15 +436,6 @@ public class DeviceContextImplTest {
         assertEquals(messageIntelligenceAgency, pickedMessageSpy);
     }
 
-    @Test
-    public void testNodeConnector() {
-        final NodeConnectorRef mockedNodeConnectorRef = mock(NodeConnectorRef.class);
-        deviceContext.storeNodeConnectorRef(DUMMY_PORT_NUMBER, mockedNodeConnectorRef);
-        final NodeConnectorRef nodeConnectorRef = deviceContext.lookupNodeConnectorRef(DUMMY_PORT_NUMBER);
-        assertEquals(mockedNodeConnectorRef, nodeConnectorRef);
-
-    }
-
     @Test
     public void testOnPublished() {
         final ConnectionContext auxiliaryConnectionContext = addDummyAuxiliaryConnectionContext();
@@ -468,7 +452,7 @@ public class DeviceContextImplTest {
     }
 
     @Test
-    public void testPortStatusMessage() {
+    public void testPortStatusMessage() throws Exception{
         final PortStatusMessage mockedPortStatusMessage = mock(PortStatusMessage.class);
         final Class dummyClass = Class.class;
         when(mockedPortStatusMessage.getImplementedInterface()).thenReturn(dummyClass);
@@ -476,14 +460,15 @@ public class DeviceContextImplTest {
 
         final GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class);
         when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
-        when(deviceState.getFeatures()).thenReturn(mockedFeature);
 
         when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD);
+        when(mockedPortStatusMessage.getPortNo()).thenReturn(42L);
 
         OpenflowPortsUtil.init();
-        deviceContext.processPortStatusMessage(mockedPortStatusMessage);
-//        verify(txChainManager).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(DataObject.class));
+        deviceContextSpy.processPortStatusMessage(mockedPortStatusMessage);
+        verify(deviceContextSpy).writeToTransaction(Mockito.<LogicalDatastoreType>any(), Mockito.<InstanceIdentifier>any(), any());
+        verify(deviceContextSpy).submitTransaction();
     }
 
     @Test
@@ -496,7 +481,7 @@ public class DeviceContextImplTest {
                 .setMatch(new MatchBuilder().build());
         final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
 
-        Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceState.class), any(Object.class)))
+        Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceInfo.class), any(Object.class)))
                 .thenReturn(flowRemovedMdsalBld.build());
 
         // insert flow+flowId into local registry
@@ -537,7 +522,7 @@ public class DeviceContextImplTest {
         final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
 
         deviceContext.setNotificationPublishService(mockedNotificationPublishService);
-        deviceContext.setExtensionConverterProvider(mockedExtensionConverterProvider);
+        ((DeviceContextImpl) deviceContext).setExtensionConverterProvider(mockedExtensionConverterProvider);
         deviceContext.processExperimenterMessage(experimenterMessage);
 
         verify(mockedNotificationPublishService).offerNotification(any(ExperimenterMessageFromDev.class));
@@ -552,28 +537,4 @@ public class DeviceContextImplTest {
         assertEquals(0, deviceContext.getDeviceMeterRegistry().getAllMeterIds().size());
 
     }
-
-    @Test
-    public void testOnClusterRoleChange() throws Exception {
-        // test role.equals(oldRole)
-        Assert.assertNull(deviceContextSpy.onClusterRoleChange(OfpRole.BECOMEMASTER, OfpRole.BECOMEMASTER).get());
-
-        // test call transactionChainManager.deactivateTransactionManager()
-        Assert.assertNull(deviceContextSpy.onClusterRoleChange(OfpRole.BECOMESLAVE, OfpRole.NOCHANGE).get());
-
-        // test call MdSalRegistrationUtils.unregisterServices(rpcContext)
-        final RpcContext rpcContext = mock(RpcContext.class);
-        deviceContextSpy.setRpcContext(rpcContext);
-        Assert.assertNull(deviceContextSpy.onClusterRoleChange(OfpRole.BECOMESLAVE, OfpRole.NOCHANGE).get());
-
-        final StatisticsContext statisticsContext = mock(StatisticsContext.class);
-        deviceContextSpy.setStatisticsContext(statisticsContext);
-
-        deviceContextSpy.onClusterRoleChange(OfpRole.NOCHANGE, OfpRole.BECOMEMASTER);
-        verify(deviceContextSpy).onDeviceTakeClusterLeadership();
-
-        Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
-        deviceContextSpy.onClusterRoleChange(OfpRole.NOCHANGE, OfpRole.BECOMESLAVE);
-        verify(deviceContextSpy).onDeviceLostClusterLeadership();
-    }
 }
index 0d61ca0c7bb3633579f80899ac5b4720fdd153bd..1a7ddd1847b0247e0d136ab309d5c555e4f83d6a 100644 (file)
@@ -20,14 +20,13 @@ import static org.mockito.Mockito.when;
 
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import io.netty.util.TimerTask;
 import java.lang.reflect.Field;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
-
-import com.google.common.util.concurrent.Futures;
-import io.netty.util.TimerTask;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -52,6 +51,7 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
@@ -68,7 +68,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 @RunWith(MockitoJUnitRunner.class)
 public class DeviceManagerImplTest {
@@ -76,6 +75,7 @@ public class DeviceManagerImplTest {
     private static final long TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA = 2000l;
     private static final int barrierCountLimit = 25600;
     private static final int barrierIntervalNanos = 500;
+    public static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId");
 
     @Mock
     CheckedFuture<Void, TransactionCommitFailedException> mockedFuture;
@@ -101,15 +101,19 @@ public class DeviceManagerImplTest {
     private LifecycleConductor lifecycleConductor;
     @Mock
     private MessageIntelligenceAgency messageIntelligenceAgency;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     @Before
     public void setUp() throws Exception {
         OpenflowPortsUtil.init();
 
-        when(mockConnectionContext.getNodeId()).thenReturn(new NodeId("dummyNodeId"));
+        when(mockConnectionContext.getNodeId()).thenReturn(DUMMY_NODE_ID);
         when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures);
         when(mockConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
+        when(mockConnectionContext.getDeviceInfo()).thenReturn(deviceInfo);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
+        when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID);
 
         final Capabilities capabilitiesV13 = mock(Capabilities.class);
         final CapabilitiesV10 capabilitiesV10 = mock(CapabilitiesV10.class);
@@ -160,13 +164,12 @@ public class DeviceManagerImplTest {
         final DeviceManagerImpl deviceManager = prepareDeviceManager(withException);
         final DeviceState mockedDeviceState = mock(DeviceState.class);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
-        when(mockedDeviceState.getNodeId()).thenReturn(mockedNodeId);
 
         if (withException) {
             doThrow(new IllegalStateException("dummy")).when(mockedDeviceContext).initialSubmitTransaction();
         }
-        deviceManager.addDeviceContextToMap(mockedNodeId, mockedDeviceContext);
-        deviceManager.onDeviceContextLevelUp(mockedDeviceContext.getDeviceState().getNodeId());
+        deviceManager.addDeviceContextToMap(deviceInfo, mockedDeviceContext);
+        deviceManager.onDeviceContextLevelUp(deviceInfo);
         if (withException) {
             verify(mockedDeviceContext).close();
         } else {
@@ -184,12 +187,10 @@ public class DeviceManagerImplTest {
         deviceManager.deviceConnected(mockConnectionContext);
 
         final InOrder order = inOrder(mockConnectionContext);
-        order.verify(mockConnectionContext).getFeatures();
         order.verify(mockConnectionContext).setOutboundQueueProvider(any(OutboundQueueProvider.class));
         order.verify(mockConnectionContext).setOutboundQueueHandleRegistration(
                 Mockito.<OutboundQueueHandlerRegistration<OutboundQueueProvider>>any());
-        order.verify(mockConnectionContext).getNodeId();
-        verify(deviceInitPhaseHandler).onDeviceContextLevelUp(Matchers.<NodeId>any());
+        verify(deviceInitPhaseHandler).onDeviceContextLevelUp(Matchers.<DeviceInfo>any());
     }
 
     @Test
@@ -202,19 +203,17 @@ public class DeviceManagerImplTest {
                 .setPortNo(41L);
         when(mockFeatures.getPhyPort()).thenReturn(Collections.singletonList(phyPort.build()));
         final MessageTranslator<Object, Object> mockedTranslator = mock(MessageTranslator.class);
-        when(mockedTranslator.translate(Matchers.<Object>any(), Matchers.<DeviceState>any(), Matchers.any()))
+        when(mockedTranslator.translate(Matchers.<Object>any(), Matchers.<DeviceInfo>any(), Matchers.any()))
                 .thenReturn(null);
         when(translatorLibrary.lookupTranslator(Matchers.<TranslatorKey>any())).thenReturn(mockedTranslator);
 
         deviceManager.deviceConnected(mockConnectionContext);
 
         final InOrder order = inOrder(mockConnectionContext);
-        order.verify(mockConnectionContext).getFeatures();
         order.verify(mockConnectionContext).setOutboundQueueProvider(any(OutboundQueueProvider.class));
         order.verify(mockConnectionContext).setOutboundQueueHandleRegistration(
                 Mockito.<OutboundQueueHandlerRegistration<OutboundQueueProvider>>any());
-        order.verify(mockConnectionContext).getNodeId();
-        verify(deviceInitPhaseHandler).onDeviceContextLevelUp(Matchers.<NodeId>any());
+        verify(deviceInitPhaseHandler).onDeviceContextLevelUp(Matchers.<DeviceInfo>any());
     }
 
     @Test
@@ -232,8 +231,8 @@ public class DeviceManagerImplTest {
         when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
 
-        final ConcurrentHashMap<NodeId, DeviceContext> deviceContexts = getContextsCollection(deviceManager);
-        deviceContexts.put(mockedNodeId, deviceContext);
+        final ConcurrentHashMap<DeviceInfo, DeviceContext> deviceContexts = getContextsCollection(deviceManager);
+        deviceContexts.put(deviceInfo, deviceContext);
 
         deviceManager.onDeviceDisconnected(connectionContext);
 
@@ -276,8 +275,8 @@ public class DeviceManagerImplTest {
     public void testClose() throws Exception {
         final DeviceContext deviceContext = mock(DeviceContext.class);
         final DeviceManagerImpl deviceManager = prepareDeviceManager();
-        final ConcurrentHashMap<NodeId, DeviceContext> deviceContexts = getContextsCollection(deviceManager);
-        deviceContexts.put(mockedNodeId, deviceContext);
+        final ConcurrentHashMap<DeviceInfo, DeviceContext> deviceContexts = getContextsCollection(deviceManager);
+        deviceContexts.put(deviceInfo, deviceContext);
         Assert.assertEquals(1, deviceContexts.size());
 
         deviceManager.close();
@@ -286,12 +285,12 @@ public class DeviceManagerImplTest {
         verify(deviceContext, Mockito.never()).close();
     }
 
-    private static ConcurrentHashMap<NodeId, DeviceContext> getContextsCollection(final DeviceManagerImpl deviceManager) throws NoSuchFieldException, IllegalAccessException {
+    private static ConcurrentHashMap<DeviceInfo, DeviceContext> getContextsCollection(final DeviceManagerImpl deviceManager) throws NoSuchFieldException, IllegalAccessException {
         // HACK: contexts collection for testing shall be accessed in some more civilized way
         final Field contextsField = DeviceManagerImpl.class.getDeclaredField("deviceContexts");
         Assert.assertNotNull(contextsField);
         contextsField.setAccessible(true);
-        return (ConcurrentHashMap<NodeId, DeviceContext>) contextsField.get(deviceManager);
+        return (ConcurrentHashMap<DeviceInfo, DeviceContext>) contextsField.get(deviceManager);
     }
 
 }
index fad7eb67927a5713a1d170aa4ea7a7c1b2166765..5170dd75d64d088b0ace332bd524ef9f36e966c4 100644 (file)
@@ -8,91 +8,31 @@
 
 package org.opendaylight.openflowplugin.impl.device;
 
-import java.util.Arrays;
-import java.util.List;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * openflowplugin-impl
  * org.opendaylight.openflowplugin.impl.device
  *
  * test of {@link DeviceStateImpl} - lightweight version, using basic ways (TDD)
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Mar 29, 2015
  */
 @RunWith(MockitoJUnitRunner.class)
 public class DeviceStateImplTest {
 
-    private NodeId nodeId;
     @Mock
-    private FeaturesReply featuresReply;
-    private DeviceStateImpl deviceState;
+    private DeviceInfo deviceInfo;
 
-    private final short version = 13;
-    private final long portNr = 10L;
-    private final Long portBandwidth = 1024L;
-    private final List<PhyPort> pPort = Arrays.asList(new PhyPortBuilder()
-                    .setPortNo(portNr).setMaxSpeed(portBandwidth).build());
+    private DeviceStateImpl deviceState;
 
     @Before
     public void initialization() {
-        nodeId = new NodeId("test-node-id");
-        Mockito.when(featuresReply.getVersion()).thenReturn(version);
-        Mockito.when(featuresReply.getPhyPort()).thenReturn(pPort);
-        deviceState = new DeviceStateImpl(featuresReply, nodeId);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#DeviceStateImpl(FeaturesReply, NodeId)}.
-     */
-    @Test(expected=NullPointerException.class)
-    public void testDeviceStateImplNullNodeId(){
-        new DeviceStateImpl(featuresReply, null);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#DeviceStateImpl(FeaturesReply, NodeId)}.
-     */
-    @Test(expected=IllegalArgumentException.class)
-    public void testDeviceStateImplNullFeaturesReply(){
-        new DeviceStateImpl(null, nodeId);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#getNodeId()}.
-     */
-    @Test
-    public void testGetNodeId(){
-        final NodeId getNodeId = deviceState.getNodeId();
-        Assert.assertNotNull(getNodeId);
-        Assert.assertEquals(nodeId, getNodeId);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#getFeatures()}.
-     */
-    @Test
-    public void testGetFeatures(){
-        final GetFeaturesOutputBuilder expetedResult = new GetFeaturesOutputBuilder(featuresReply);
-        final GetFeaturesOutput getFeatures = deviceState.getFeatures();
-        Assert.assertNotNull(getFeatures);
-        Assert.assertEquals(expetedResult.getVersion(), getFeatures.getVersion());
-        Assert.assertEquals(expetedResult.getPhyPort(), getFeatures.getPhyPort());
+        deviceState = new DeviceStateImpl(deviceInfo);
     }
 
     @Test
index cd3a89bc3836509af4441a2a8788753d7c51576b..68c07e23539f6a3931ab5ac3f7780cc63ad1100b 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.util.concurrent.Futures;
 import io.netty.util.HashedWheelTimer;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
@@ -32,6 +31,7 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
@@ -67,6 +67,8 @@ public class TransactionChainManagerTest {
     @Mock
     DeviceState deviceState;
     @Mock
+    DeviceInfo deviceInfo;
+    @Mock
     LifecycleConductor conductor;
 
     @Mock
@@ -86,9 +88,9 @@ public class TransactionChainManagerTest {
                 .thenReturn(txChain);
         nodeId = new NodeId("h2g2:42");
         nodeKeyIdent = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
-        Mockito.when(deviceState.getNodeId()).thenReturn(nodeId);
-        txChainManager = new TransactionChainManager(dataBroker, deviceState, conductor);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        txChainManager = new TransactionChainManager(dataBroker, deviceInfo, conductor);
         Mockito.when(txChain.newWriteOnlyTransaction()).thenReturn(writeTx);
 
         path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
index 2df7f6edbe9b48ab7b59b8a563246f32904d13a0..cf60cb5e71ef7c91c7e99af799b73c1f531bd684 100644 (file)
@@ -24,6 +24,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
@@ -49,6 +50,8 @@ public class FlowRegistryKeyFactoryTest {
     private DeviceContext deviceContext;
     @Mock
     private DeviceState deviceState;
+    @Mock
+    private DeviceInfo deviceInfo;
 
 
     @Before
@@ -59,7 +62,7 @@ public class FlowRegistryKeyFactoryTest {
         }
         FLOWS_STATISTICS_UPDATE_BUILDER.setFlowAndStatisticsMapList(flowAndStatisticsMapListList);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
     }
 
     @Test
index a427fbbe0bb3ee90cc72309599f3ad20e74a3b36..8349f477a7053abf2224da79a308f856d9a09dbe 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlready
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
 import org.opendaylight.openflowplugin.api.openflow.role.RoleManager;
@@ -42,6 +43,9 @@ public class RoleContextImplTest {
     @Mock
     private LifecycleConductor conductor;
 
+    @Mock
+    private DeviceInfo deviceInfo;
+
     private final NodeId nodeId = NodeId.getDefaultInstance("openflow:1");
     private final Entity entity = new Entity(RoleManager.ENTITY_TYPE, nodeId.getValue());
     private final Entity txEntity = new Entity(RoleManager.TX_ENTITY_TYPE, nodeId.getValue());
@@ -49,9 +53,10 @@ public class RoleContextImplTest {
 
     @Before
     public void setup() throws CandidateAlreadyRegisteredException {
-        roleContext = new RoleContextImpl(nodeId, entityOwnershipService, entity, txEntity, conductor);
+        roleContext = new RoleContextImpl(deviceInfo, entityOwnershipService, entity, txEntity, conductor);
         Mockito.when(entityOwnershipService.registerCandidate(entity)).thenReturn(entityOwnershipCandidateRegistration);
         Mockito.when(entityOwnershipService.registerCandidate(txEntity)).thenReturn(entityOwnershipCandidateRegistration);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
     }
 
     //@Test
@@ -108,7 +113,7 @@ public class RoleContextImplTest {
     @Test
     public void testCreateRequestContext() throws Exception {
         roleContext.createRequestContext();
-        Mockito.verify(conductor).reserveXidForDeviceMessage(nodeId);
+        Mockito.verify(conductor).reserveXidForDeviceMessage(deviceInfo);
     }
 
     @Test(expected = NullPointerException.class)
@@ -128,7 +133,7 @@ public class RoleContextImplTest {
 
     @Test
     public void testGetNodeId() throws Exception {
-        Assert.assertTrue(roleContext.getNodeId().equals(nodeId));
+        Assert.assertTrue(roleContext.getDeviceInfo().getNodeId().equals(nodeId));
     }
 
     @Test
index 3febe5466ccd088dd1f7727ba3abffa370f0536e..e4fc2c16e8c8f112dda2c2e2424715a931ea2a3e 100644 (file)
@@ -9,11 +9,13 @@
 package org.opendaylight.openflowplugin.impl.role;
 
 
-import java.math.BigInteger;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
 
 import com.google.common.base.VerifyException;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -32,9 +34,11 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipL
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
@@ -42,16 +46,12 @@ import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTermin
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.RoleChangeListener;
 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
 @RunWith(MockitoJUnitRunner.class)
 public class RoleManagerImplTest {
 
@@ -97,6 +97,18 @@ public class RoleManagerImplTest {
     @Mock
     DeviceState deviceState;
 
+    @Mock
+    DeviceInfo deviceInfo;
+
+    @Mock
+    DeviceInfo deviceInfo2;
+
+    @Mock
+    MessageSpy messageSpy;
+
+    @Mock
+    OutboundQueue outboundQueue;
+
     @Mock
     GetFeaturesOutput featuresOutput;
 
@@ -104,40 +116,50 @@ public class RoleManagerImplTest {
     private RoleManagerImpl roleManagerSpy;
     private RoleContext roleContextSpy;
     private final NodeId nodeId = NodeId.getDefaultInstance("openflow:1");
+    private final NodeId nodeId2 = NodeId.getDefaultInstance("openflow:2");
 
-    private final EntityOwnershipChange masterEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), false, true, true);
-    private final EntityOwnershipChange masterTxEntity = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), false, true, true);
-    private final EntityOwnershipChange slaveEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true);
-    private final EntityOwnershipChange slaveTxEntityLast = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), true, false, false);
-    private final EntityOwnershipChange masterEntityNotOwner = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true);
+
+    private final EntityOwnershipChange masterEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), false, true, true, false);
+    private final EntityOwnershipChange masterTxEntity = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), false, true, true, false);
+    private final EntityOwnershipChange slaveEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true, false);
+    private final EntityOwnershipChange slaveTxEntityLast = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), true, false, false, false);
+    private final EntityOwnershipChange masterEntityNotOwner = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true, false);
 
     private InOrder inOrder;
 
     @Before
     public void setUp() throws Exception {
         CheckedFuture<Void, TransactionCommitFailedException> future = Futures.immediateCheckedFuture(null);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
         Mockito.when(entityOwnershipService.registerListener(Mockito.anyString(), Mockito.any(EntityOwnershipListener.class))).thenReturn(entityOwnershipListenerRegistration);
         Mockito.when(entityOwnershipService.registerCandidate(Mockito.any(Entity.class))).thenReturn(entityOwnershipCandidateRegistration);
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
+        Mockito.when(deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider()).thenReturn(outboundQueue);
         Mockito.when(connectionContext.getFeatures()).thenReturn(featuresReply);
         Mockito.when(connectionContext.getNodeId()).thenReturn(nodeId);
         Mockito.when(connectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
-        Mockito.when(featuresReply.getDatapathId()).thenReturn(new BigInteger("1"));
-        Mockito.when(featuresReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.doNothing().when(deviceInitializationPhaseHandler).onDeviceContextLevelUp(Mockito.<NodeId>any());
-        Mockito.doNothing().when(deviceTerminationPhaseHandler).onDeviceContextLevelDown(Mockito.<DeviceContext>any());
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(new BigInteger("1"));
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        Mockito.doNothing().when(deviceInitializationPhaseHandler).onDeviceContextLevelUp(Mockito.<DeviceInfo>any());
+        Mockito.doNothing().when(deviceTerminationPhaseHandler).onDeviceContextLevelDown(Mockito.<DeviceInfo>any());
         Mockito.when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
         Mockito.when(writeTransaction.submit()).thenReturn(future);
-        Mockito.when(deviceManager.getDeviceContextFromNodeId(Mockito.<NodeId>any())).thenReturn(deviceContext);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        Mockito.when(deviceInfo2.getNodeId()).thenReturn(nodeId2);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker, conductor);
         roleManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
         roleManager.setDeviceTerminationPhaseHandler(deviceTerminationPhaseHandler);
-        Mockito.when(conductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(deviceContext);
+        Mockito.when(conductor.getDeviceContext(deviceInfo)).thenReturn(deviceContext);
         roleManagerSpy = Mockito.spy(roleManager);
-        roleManagerSpy.onDeviceContextLevelUp(nodeId);
-        roleContextSpy = Mockito.spy(roleManager.getRoleContext(nodeId));
+        roleManagerSpy.onDeviceContextLevelUp(deviceInfo);
+        Mockito.doNothing().when(roleManagerSpy).makeDeviceRoleChange(Mockito.<OfpRole>any(), Mockito.<RoleContext>any(), Mockito.anyBoolean());
+        roleContextSpy = Mockito.spy(roleManager.getRoleContext(deviceInfo));
+        Mockito.when(roleContextSpy.getDeviceInfo()).thenReturn(deviceInfo);
+        Mockito.when(roleContextSpy.getDeviceInfo().getNodeId()).thenReturn(nodeId);
         inOrder = Mockito.inOrder(entityOwnershipListenerRegistration, roleManagerSpy, roleContextSpy);
     }
 
@@ -147,8 +169,8 @@ public class RoleManagerImplTest {
 
     @Test(expected = VerifyException.class)
     public void testOnDeviceContextLevelUp() throws Exception {
-        roleManagerSpy.onDeviceContextLevelUp(nodeId);
-        inOrder.verify(roleManagerSpy).onDeviceContextLevelUp(nodeId);
+        roleManagerSpy.onDeviceContextLevelUp(deviceInfo);
+        inOrder.verify(roleManagerSpy).onDeviceContextLevelUp(deviceInfo);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -158,7 +180,7 @@ public class RoleManagerImplTest {
         roleManagerSpy.ownershipChanged(masterTxEntity);
         roleManagerSpy.close();
         inOrder.verify(entityOwnershipListenerRegistration, Mockito.calls(2)).close();
-        inOrder.verify(roleManagerSpy).removeDeviceFromOperationalDS(nodeId);
+        inOrder.verify(roleManagerSpy).removeDeviceFromOperationalDS(Mockito.eq(deviceInfo), Mockito.anyInt());
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -167,14 +189,14 @@ public class RoleManagerImplTest {
         roleManagerSpy.ownershipChanged(slaveEntity);
         roleManagerSpy.close();
         inOrder.verify(entityOwnershipListenerRegistration, Mockito.calls(2)).close();
-        inOrder.verify(roleManagerSpy, Mockito.never()).removeDeviceFromOperationalDS(nodeId);
+        inOrder.verify(roleManagerSpy, Mockito.never()).removeDeviceFromOperationalDS(Mockito.eq(deviceInfo), Mockito.anyInt());
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testOnDeviceContextLevelDown() throws Exception {
-        roleManagerSpy.onDeviceContextLevelDown(deviceContext);
-        inOrder.verify(roleManagerSpy).onDeviceContextLevelDown(deviceContext);
+        roleManagerSpy.onDeviceContextLevelDown(deviceInfo);
+        inOrder.verify(roleManagerSpy).onDeviceContextLevelDown(deviceInfo);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -216,7 +238,7 @@ public class RoleManagerImplTest {
         inOrder.verify(roleContextSpy, Mockito.atLeastOnce()).isTxCandidateRegistered();
         inOrder.verify(roleContextSpy, Mockito.calls(1)).unregisterCandidate(Mockito.<Entity>any());
         inOrder.verify(roleContextSpy, Mockito.never()).close();
-        inOrder.verify(roleManagerSpy, Mockito.calls(1)).removeDeviceFromOperationalDS(Mockito.<NodeId>any());
+        inOrder.verify(roleManagerSpy, Mockito.calls(1)).removeDeviceFromOperationalDS(Mockito.any(), Mockito.anyInt());
     }
 
     @Test
@@ -234,8 +256,7 @@ public class RoleManagerImplTest {
         Mockito.when(roleContextSpy.isTxCandidateRegistered()).thenReturn(false);
         roleManagerSpy.changeOwnershipForTxEntity(slaveTxEntityLast, roleContextSpy);
         verify(roleContextSpy).close();
-        verify(roleContextSpy).getNodeId();
-        verify(conductor).closeConnection(nodeId);
+        verify(conductor).closeConnection(deviceInfo);
     }
 
     @Test
@@ -243,50 +264,41 @@ public class RoleManagerImplTest {
         Mockito.when(roleContextSpy.isTxCandidateRegistered()).thenReturn(true);
         roleManagerSpy.changeOwnershipForTxEntity(masterEntityNotOwner, roleContextSpy);
         verify(roleContextSpy).close();
-        verify(conductor).closeConnection(nodeId);
+        verify(conductor).closeConnection(deviceInfo);
     }
 
     @Test
     public void testAddListener() throws Exception {
         roleManager.addRoleChangeListener((new RoleChangeListener() {
             @Override
-            public void roleInitializationDone(final NodeId nodeId, final boolean success) {
-                Assert.assertTrue(nodeId.equals(nodeId));
+            public void roleInitializationDone(final DeviceInfo deviceInfo_, final boolean success) {
+                Assert.assertTrue(deviceInfo.equals(deviceInfo_));
                 Assert.assertTrue(success);
             }
 
             @Override
-            public void roleChangeOnDevice(final NodeId nodeId_, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
-                Assert.assertTrue(nodeId.equals(nodeId_));
+            public void roleChangeOnDevice(final DeviceInfo deviceInfo_, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
+                Assert.assertTrue(RoleManagerImplTest.this.deviceInfo.equals(deviceInfo_));
                 Assert.assertTrue(success);
                 Assert.assertFalse(initializationPhase);
                 Assert.assertTrue(newRole.equals(OfpRole.BECOMEMASTER));
             }
         }));
-        roleManager.notifyListenersRoleInitializationDone(nodeId, true);
-        roleManager.notifyListenersRoleChangeOnDevice(nodeId, true, OfpRole.BECOMEMASTER, false);
-    }
-
-    @Test
-    public void testMakeDeviceRoleChange() throws Exception{
-        roleManagerSpy.makeDeviceRoleChange(OfpRole.BECOMEMASTER, roleContextSpy, true);
-        verify(roleManagerSpy, atLeastOnce()).sendRoleChangeToDevice(Mockito.<OfpRole>any(), Mockito.<RoleContext>any());
-        verify(roleManagerSpy, atLeastOnce()).notifyListenersRoleChangeOnDevice(Mockito.<NodeId>any(), eq(true), Mockito.<OfpRole>any(), eq(true));
+        roleManager.notifyListenersRoleInitializationDone(deviceInfo, true);
+        roleManager.notifyListenersRoleChangeOnDevice(deviceInfo, true, OfpRole.BECOMEMASTER, false);
     }
 
     @Test
     public void testServicesChangeDone() throws Exception {
-        final NodeId nodeId2 = NodeId.getDefaultInstance("openflow:2");
-        roleManagerSpy.setRoleContext(nodeId2, roleContextSpy);
-        roleManagerSpy.servicesChangeDone(nodeId2, true);
+        roleManagerSpy.setRoleContext(deviceInfo2, roleContextSpy);
+        roleManagerSpy.servicesChangeDone(deviceInfo2, true);
         verify(roleContextSpy).unregisterCandidate(Mockito.<Entity>any());
     }
 
     @Test
     public void testServicesChangeDoneContextIsNull() throws Exception {
-        final NodeId nodeId2 = NodeId.getDefaultInstance("openflow:2");
-        roleManagerSpy.setRoleContext(nodeId, roleContextSpy);
-        roleManagerSpy.servicesChangeDone(nodeId2, true);
+        roleManagerSpy.setRoleContext(deviceInfo, roleContextSpy);
+        roleManagerSpy.servicesChangeDone(deviceInfo2, true);
         verify(roleContextSpy, never()).unregisterCandidate(Mockito.<Entity>any());
     }
 }
\ No newline at end of file
index ad31e8000460ff837fc1c8071c27ea7a7a4031a8..1e311581f60bcfcec5a51d5808a02df7c4c4eeb2 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.rpc;
 
 import static org.junit.Assert.assertNotNull;
+
 import java.util.concurrent.Future;
 import org.junit.Before;
 import org.junit.Test;
index 18a7942eb808679e8ed786e69b4c04a8c096fba6..bf3a977815ab430758f97b128ed71aedfef73bf5 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.impl.rpc;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
index 854d4d3269ac9fdb7317802680025cc123f28189..9d982028a88f49c8b6dfae2d0115cdc99cc43537 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.openflowplugin.impl.rpc;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.junit.Assert.assertEquals;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -20,8 +21,8 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.XidSequencer;
@@ -35,7 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
-import java.util.concurrent.Semaphore;
 
 @RunWith(MockitoJUnitRunner.class)
 public class RpcContextImplTest {
@@ -60,6 +60,8 @@ public class RpcContextImplTest {
     private NotificationPublishService notificationPublishService;
     @Mock
     private TestRpcService serviceInstance;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     private KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
 
@@ -69,7 +71,7 @@ public class RpcContextImplTest {
         nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
 
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
         when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
 
         rpcContext = new RpcContextImpl(rpcProviderRegistry,deviceContext, messageSpy, MAX_REQUESTS,nodeInstanceIdentifier);
index fe01124d6c94ab26c7fd4ccd7e398da7e40eccb3..415d443580ff2ec95fafa459a1c29e9437be2890 100644 (file)
@@ -7,7 +7,13 @@
  */
 package org.opendaylight.openflowplugin.impl.rpc;
 
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
 import com.google.common.base.VerifyException;
+import java.util.concurrent.ConcurrentMap;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -22,6 +28,7 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
@@ -35,17 +42,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
-import java.util.concurrent.ConcurrentMap;
-
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
 
 @RunWith(MockitoJUnitRunner.class)
 public class RpcManagerImplTest {
@@ -78,7 +77,9 @@ public class RpcManagerImplTest {
     @Mock
     private RpcContext removedContexts;
     @Mock
-    private ConcurrentMap<NodeId, RpcContext> contexts;
+    private ConcurrentMap<DeviceInfo, RpcContext> contexts;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     @Rule
     public ExpectedException expectedException = ExpectedException.none();
@@ -103,58 +104,57 @@ public class RpcManagerImplTest {
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
         Mockito.when(deviceContext.getItemLifeCycleSourceRegistry()).thenReturn(itemLifeCycleRegistry);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
         rpcManager.setDeviceTerminationPhaseHandler(deviceTerminationPhaseHandler);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
         Mockito.when(deviceContext.getItemLifeCycleSourceRegistry()).thenReturn(itemLifeCycleRegistry);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
         Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
-        Mockito.when(deviceState.getNodeId()).thenReturn(nodeKey.getId());
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeKey.getId());
         Mockito.when(rpcProviderRegistry.addRoutedRpcImplementation(
                 Matchers.<Class<RpcService>>any(), Matchers.any(RpcService.class)))
                 .thenReturn(routedRpcRegistration);
-        Mockito.when(conductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(deviceContext);
-        Mockito.when(contexts.remove(nodeId)).thenReturn(removedContexts);
+        Mockito.when(conductor.getDeviceContext(deviceInfo)).thenReturn(deviceContext);
+        Mockito.when(contexts.remove(deviceInfo)).thenReturn(removedContexts);
     }
 
     @Test
     public void onDeviceContextLevelUp() throws Exception {
-        rpcManager.onDeviceContextLevelUp(nodeId);
-        verify(conductor).getDeviceContext(Mockito.<NodeId>any());
+        rpcManager.onDeviceContextLevelUp(deviceInfo);
+        verify(conductor).getDeviceContext(deviceInfo);
     }
 
     @Test
     public void onDeviceContextLevelUpTwice() throws Exception {
-        rpcManager.onDeviceContextLevelUp(nodeId);
+        rpcManager.onDeviceContextLevelUp(deviceInfo);
         expectedException.expect(VerifyException.class);
-        rpcManager.onDeviceContextLevelUp(nodeId);
+        rpcManager.onDeviceContextLevelUp(deviceInfo);
     }
 
     @Test
     public void testOnDeviceContextLevelUpMaster() throws Exception {
-        rpcManager.onDeviceContextLevelUp(nodeId);
-        verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(nodeId);
+        rpcManager.onDeviceContextLevelUp(deviceInfo);
+        verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(deviceInfo);
     }
 
     @Test
     public void testOnDeviceContextLevelUpSlave() throws Exception {
-        rpcManager.onDeviceContextLevelUp(nodeId);
-        verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(nodeId);
+        rpcManager.onDeviceContextLevelUp(deviceInfo);
+        verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(deviceInfo);
     }
 
     @Test
     public void testOnDeviceContextLevelUpOther() throws Exception {
-        rpcManager.onDeviceContextLevelUp(nodeId);
-        verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(nodeId);
+        rpcManager.onDeviceContextLevelUp(deviceInfo);
+        verify(deviceINitializationPhaseHandler).onDeviceContextLevelUp(deviceInfo);
     }
 
     @Test
     public void testOnDeviceContextLevelDown() throws Exception {
-        rpcManager.onDeviceContextLevelDown(deviceContext);
-        verify(deviceTerminationPhaseHandler).onDeviceContextLevelDown(deviceContext);
+        rpcManager.onDeviceContextLevelDown(deviceInfo);
+        verify(deviceTerminationPhaseHandler).onDeviceContextLevelDown(deviceInfo);
     }
 
     /**
@@ -162,10 +162,10 @@ public class RpcManagerImplTest {
      */
     @Test
     public void onDeviceContextLevelDown1() {
-        rpcManager.addRecordToContexts(nodeId,removedContexts);
-        rpcManager.onDeviceContextLevelDown(deviceContext);
+        rpcManager.addRecordToContexts(deviceInfo,removedContexts);
+        rpcManager.onDeviceContextLevelDown(deviceInfo);
         verify(removedContexts,times(1)).close();
-        verify(deviceTerminationPhaseHandler,times(1)).onDeviceContextLevelDown(deviceContext);
+        verify(deviceTerminationPhaseHandler,times(1)).onDeviceContextLevelDown(deviceInfo);
     }
 
 
@@ -174,15 +174,15 @@ public class RpcManagerImplTest {
      */
     @Test
     public void onDeviceContextLevelDown2() {
-        rpcManager.onDeviceContextLevelDown(deviceContext);
+        rpcManager.onDeviceContextLevelDown(deviceInfo);
         verify(removedContexts,never()).close();
-        verify(deviceTerminationPhaseHandler,times(1)).onDeviceContextLevelDown(deviceContext);
+        verify(deviceTerminationPhaseHandler,times(1)).onDeviceContextLevelDown(deviceInfo);
 
     }
 
     @Test
     public void close() {
-        rpcManager.addRecordToContexts(nodeId,removedContexts);
+        rpcManager.addRecordToContexts(deviceInfo,removedContexts);
         rpcManager.close();
         verify(removedContexts,atLeastOnce()).close();
     }
index d39f9f558c368455ca6d57e659e2da567dbd2548..ca01864b3624a250a07eca0c712049155af72334 100644 (file)
@@ -1,6 +1,10 @@
 package org.opendaylight.openflowplugin.impl.services;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
@@ -12,13 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
 public class AbstractRequestCallbackTest {
 
     private static final Class<?> DUMMY_REQUEST_TYPE = String.class;
index 5239335897abfc319efdd9000ddc8f41bf5b1a7a..8916519edd590054bc3119a31156895c452ddeb8 100644 (file)
@@ -51,6 +51,6 @@ public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
 
     private SendBarrierInput buildSendBarrierInput() {
         return new SendBarrierInputBuilder()
-                .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier())).build();
+                .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();
     }
 }
\ No newline at end of file
index 756b1ee4371b6cb5a0a85521d5b9823f6100199a..7b3bcd26615e29838ce4bd00e9b56e03f9b68950 100644 (file)
@@ -8,6 +8,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -28,6 +29,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
@@ -88,6 +90,8 @@ public class MultipartRequestOnTheFlyCallbackTest {
     @Mock
     private DeviceState mockedDeviceState;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private GetFeaturesOutput mocketGetFeaturesOutput;
     @Mock
     private DeviceFlowRegistry mockedFlowRegistry;
@@ -113,15 +117,16 @@ public class MultipartRequestOnTheFlyCallbackTest {
         when(mocketGetFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
-        when(mockedDeviceState.getFeatures()).thenReturn(mocketGetFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
         when(mockedDeviceState.deviceSynchronized()).thenReturn(true);
-        when(mockedDeviceState.getNodeId()).thenReturn(mockedNodeId);
+        when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
 
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(mockedFlowRegistry);
 
-        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
         flowNodeBuilder.setTable(Collections.<Table> emptyList());
         final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
@@ -137,7 +142,7 @@ public class MultipartRequestOnTheFlyCallbackTest {
             }
         };
         multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class,
-                mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceContext.getDeviceState(),
+                mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceInfo,
                 mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext);
     }
 
@@ -205,7 +210,7 @@ public class MultipartRequestOnTheFlyCallbackTest {
                 .setMultipartReplyBody(multipartReplyFlowCaseBuilder.build())
                 .setXid(21L);
 
-        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceState.getNodeInstanceIdentifier()
+        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
         final TableBuilder tableDataBld = new TableBuilder();
index cad3b6968dd0fb9c072b8b0012eddb4e081eea14..7647e5c3367aadadd079c52a0dbd7777d2a1211b 100644 (file)
@@ -79,7 +79,7 @@ public class PacketProcessingServiceImplTest extends ServiceMocking {
     private TransmitPacketInput buildTransmitPacketInput() {
         TransmitPacketInputBuilder transmitPacketInputBld = new TransmitPacketInputBuilder()
                 .setBufferId(OFConstants.OFP_NO_BUFFER)
-                .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier()))
                 .setPayload(ULTIMATE_PAYLOAD.getBytes())
                 .setEgress(new NodeConnectorRef(pathToNodeconnector));
         return transmitPacketInputBld.build();
index 62f00d19ad000a83b90640ffa12b8450dfb92934..af336d62c7ee983f05f4d48dd4c21669865d67db 100644 (file)
@@ -43,7 +43,7 @@ public class SalExperimenterMessageServiceImplTest extends ServiceMocking {
 
     @Override
     protected void setup() {
-        salExperimenterMessageService = new SalExperimenterMessageServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        salExperimenterMessageService = new SalExperimenterMessageServiceImpl(mockedRequestContextStack, mockedDeviceContext, extensionConverterProvider);
         Mockito.when(mockedDeviceContext.getExtensionConverterProvider()).thenReturn(extensionConverterProvider);
         Mockito.when(extensionConverterProvider.getMessageConverter(Matchers.<TypeVersionKey>any()))
                 .thenReturn(extensionConverter);
@@ -74,7 +74,7 @@ public class SalExperimenterMessageServiceImplTest extends ServiceMocking {
 
     private SendExperimenterInput buildSendExperimenterInput() {
         SendExperimenterInputBuilder sendExperimenterInputBld = new SendExperimenterInputBuilder()
-                .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier()))
                 .setExperimenterMessageOfChoice(new DummyExperimenter());
         return sendExperimenterInputBld.build();
     }
index 3cf72599f8d30a8a62c97fbb72f70289e10788f5..53e422c7c5a84fac01b65d0fea11cdf7b542f502 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -95,6 +96,8 @@ public class SalFlowServiceImplTest extends TestCase {
     @Mock
     private DeviceState mockedDeviceState;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private DeviceFlowRegistry deviceFlowRegistry;
     @Mock
     private GetFeaturesOutput mockedFeaturesOutput;
@@ -119,9 +122,11 @@ public class SalFlowServiceImplTest extends TestCase {
         when(requestContext.getXid()).thenReturn(new Xid(84L));
         when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success().buildFuture());
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_II);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
+        when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
 
         salFlowService = new SalFlowServiceImpl(mockedRequestContextStack, mockedDeviceContext);
     }
index cdafaca8fb7850203ff4d57537cb4efabc77121b..0b224bf95191b8e85121def50f5e5df652f3a830 100644 (file)
@@ -1,13 +1,24 @@
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import org.junit.Test;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
@@ -16,13 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 public class SalGroupServiceImplTest extends ServiceMocking {
 
index faf1d13f50d601d7c4a4b56606a96f916919a2f9..e9658b19ec0a17fb9fceb0196cd1920a4bad7c11 100644 (file)
@@ -5,29 +5,27 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import org.junit.Test;
 import org.mockito.Matchers;
 import org.mockito.Mock;
-import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 public class SalMeterServiceImplTest extends ServiceMocking {
 
index 5f21b80eab864ee71a2a8002a22208c920c11f1a..8b47976735fc92f4be177d2dc5804a630bf2c521 100644 (file)
@@ -3,6 +3,7 @@ package org.opendaylight.openflowplugin.impl.services;
 import static org.mockito.Mockito.verify;
 
 import com.google.common.collect.Lists;
+import java.util.List;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
@@ -18,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
-import java.util.List;
 
 @RunWith(MockitoJUnitRunner.class)
 public class SalPortServiceImplTest extends ServiceMocking {
index 35c702a5126ee290bd3d5c40c46c890fc29ed9a3..d3041e08abe4f860fd255838b18cd37c610f424e 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.services;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
@@ -23,6 +24,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -76,6 +78,9 @@ public class SalRoleServiceImplTest {
     @Mock
     private DeviceState mockDeviceState;
 
+    @Mock
+    private DeviceInfo mockDeviceInfo;
+
     @Mock
     private GetFeaturesOutput mockFeaturesOutput;
 
@@ -93,10 +98,11 @@ public class SalRoleServiceImplTest {
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        Mockito.when(mockDeviceState.getNodeId()).thenReturn(testNodeId);
-        Mockito.when(mockDeviceState.getFeatures()).thenReturn(mockFeaturesOutput);
+        Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
+        Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
         Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
+        Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
         Mockito.when(mockDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
         Mockito.when(mockConnectionContext.getFeatures()).thenReturn(mockFeaturesReply);
         Mockito.when(mockConnectionContext.getNodeId()).thenReturn(testNodeId);
index d6edde72994d8f0a5e04ff2bc29c229e9926b131..63d55df295f394c343e56797889506fd2266d336 100644 (file)
@@ -1,11 +1,9 @@
 package org.opendaylight.openflowplugin.impl.services;
 
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import io.netty.util.HashedWheelTimer;
 import java.math.BigInteger;
 import java.util.List;
 import org.junit.Before;
@@ -17,6 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -67,6 +66,8 @@ public abstract class ServiceMocking {
     @Mock
     protected DeviceState mockedDeviceState;
     @Mock
+    protected DeviceInfo mockedDeviceInfo;
+    @Mock
     protected DeviceInitializationPhaseHandler mockedDevicePhaseHandler;
     @Mock
     protected RequestContext mockedRequestContext;
@@ -91,13 +92,15 @@ public abstract class ServiceMocking {
         when(mockedPrimConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
         when(mockedPrimConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_II);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
+        when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION);
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl());
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getMultiMsgCollector(Matchers.<RequestContext<List<MultipartReply>>>any())).thenReturn(multiMessageCollector);
 
         setup();
index 46414d6c822c6315dee8f751c6a87a207e890bf5..7e2c5a9257705a448ec154696d51f9cc9e236d0b 100644 (file)
@@ -1,64 +1,55 @@
 package org.opendaylight.openflowplugin.impl.statistics;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
 import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
-import javax.sql.rowset.spi.TransactionalWriter;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 public class SinglePurposeMultipartReplyTranslatorTest {
 
     private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("21");
index bce92039e282e2d7942734dcb955d89693989bd7..f94d43f7e73cdf5c4cddff3b91e2dde3311b83b3 100644 (file)
@@ -14,11 +14,12 @@ package org.opendaylight.openflowplugin.impl.statistics;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.math.BigInteger;
 import org.junit.Before;
-import org.mockito.Mockito;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
@@ -30,7 +31,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
@@ -49,6 +49,7 @@ class StatisticsContextImpMockInitiation {
     StatisticsGatheringService mockedStatisticsGatheringService;
     StatisticsGatheringOnTheFlyService mockedStatisticsOnFlyGatheringService;
     ConnectionContext mockedConnectionContext;
+    DeviceInfo mockedDeviceInfo;
 
     static final KeyedInstanceIdentifier<Node, NodeKey> dummyNodeII = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(new NodeId("dummyNodeId")));
@@ -62,36 +63,42 @@ class StatisticsContextImpMockInitiation {
         mockedStatisticsOnFlyGatheringService = mock(StatisticsGatheringOnTheFlyService.class);
         mockedConnectionContext = mock(ConnectionContext.class);
         mockedDeviceState = mock(DeviceState.class);
+        mockedDeviceInfo = mock(DeviceInfo.class);
 
         final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
         final MessageSpy mockedMessageSpy = mock(MessageSpy.class);
         final OutboundQueue mockedOutboundQueue = mock(OutboundQueue.class);
         final DeviceManager mockedDeviceManager = mock(DeviceManager.class);
-        final GetFeaturesOutput mockedFeaturesOutput = mock(GetFeaturesOutput.class);
 
         mockConductor = mock(LifecycleConductor.class);
 
+        when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
+        when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
+        when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
+
         when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(isTable);
         when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(isFlow);
         when(mockedDeviceState.isGroupAvailable()).thenReturn(isGroup);
         when(mockedDeviceState.isMetersAvailable()).thenReturn(isMeter);
         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(isPort);
         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(isQueue);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
 
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
+        when(mockedDeviceInfo.getNodeId()).thenReturn(dummyNodeII.getKey().getId());
 
         when(mockedConnectionContext.getNodeId()).thenReturn(dummyNodeII.getKey().getId());
         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
         when(mockedConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
         when(mockedConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
 
-        when(mockedDeviceManager.getDeviceContextFromNodeId(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
-        mockConductor.setSafelyDeviceManager(mockedDeviceManager);
-        when(mockConductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        mockConductor.setSafelyManager(mockedDeviceManager);
+        when(mockConductor.getDeviceContext(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
 
     }
 }
index 22e5bc44dd914a36eb5117aba0caa099be3a5803..c88578b1d83d114ef2cab1dc3048eb468ba4d36e 100644 (file)
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.when;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Arrays;
 import java.util.Collections;
@@ -24,9 +25,7 @@ import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
-import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -66,7 +65,7 @@ public class StatisticsContextImplParamTest extends StatisticsContextImpMockInit
     public void gatherDynamicDataTest() {
 
 
-        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceContext.getDeviceState().getNodeId(), false, mockConductor);
+        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor);
 
         final ListenableFuture<RpcResult<List<MultipartReply>>> rpcResult = immediateFuture(RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build());
         when(mockedStatisticsGatheringService.getStatisticsOfType(any(EventIdentifier.class), any(MultipartType
index 05cd073993a75c3e41d917ab122b48574183a81c..7d813b0e18d0f9490390601b343eb8c87ca0086d 100644 (file)
@@ -13,7 +13,6 @@ package org.opendaylight.openflowplugin.impl.statistics;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -32,9 +31,7 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -52,12 +49,12 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
     @Before
     public void setUp() throws Exception {
         when(mockedDeviceContext.reserveXidForDeviceMessage()).thenReturn(TEST_XID);
-        when(mockConductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        when(mockConductor.getDeviceContext(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
         initStatisticsContext();
     }
 
     private void initStatisticsContext() {
-        statisticsContext = new StatisticsContextImpl(mockedDeviceContext.getDeviceState().getNodeId(), false, mockConductor);
+        statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor);
         statisticsContext.setStatisticsGatheringService(mockedStatisticsGatheringService);
         statisticsContext.setStatisticsGatheringOnTheFlyService(mockedStatisticsOnFlyGatheringService);
     }
@@ -75,7 +72,7 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
      */
     @Test
     public void testClose() throws Exception {
-        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceContext.getDeviceState().getNodeId(), false, mockConductor);
+        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor);
         final RequestContext<Object> requestContext = statisticsContext.createRequestContext();
         statisticsContext.close();
         try {
@@ -100,14 +97,13 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
     @Test
     public void testGatherDynamicData_all() throws Exception {
         Mockito.reset(mockedDeviceState);
-        when(mockedDeviceState.getFeatures()).thenReturn(mock(GetFeaturesOutput.class));
         when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isGroupAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isMetersAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(Boolean.TRUE);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
         initStatisticsContext();
 
         when(mockedStatisticsGatheringService.getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.any(MultipartType.class)))
index b1c389eca913baf3743cfd57f16c42968dfcbf64..64fa767cca3a2022ea6aab3f114f84ff0cc35219 100644 (file)
@@ -13,6 +13,7 @@ package org.opendaylight.openflowplugin.impl.statistics;
 
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
@@ -40,7 +41,9 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
@@ -136,8 +139,8 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 @RunWith(MockitoJUnitRunner.class)
 public class StatisticsGatheringUtilsTest {
 
-    public static final String DUMMY_NODE_ID_VALUE = "1";
-    public static final NodeId DUMMY_NODE_ID = new NodeId(DUMMY_NODE_ID_VALUE);
+    static final String DUMMY_NODE_ID_VALUE = "1";
+    static final NodeId DUMMY_NODE_ID = new NodeId(DUMMY_NODE_ID_VALUE);
 
     private final KeyedInstanceIdentifier<Node, NodeKey> dummyNodePath = InstanceIdentifier.create(Nodes.class)
             .child(Node.class, new NodeKey(DUMMY_NODE_ID));
@@ -159,6 +162,10 @@ public class StatisticsGatheringUtilsTest {
     private ConnectionContext connectionAdapter;
     @Mock
     private StatisticsGatherer statisticsService;
+    @Mock
+    private DeviceInfo deviceInfo;
+    @Mock
+    private TxFacade txFacade;
 
     public StatisticsGatheringUtilsTest() {
         OpenflowPortsUtil.init();
@@ -167,19 +174,22 @@ public class StatisticsGatheringUtilsTest {
     @Before
     public void setUp() throws Exception {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry);
         when(deviceContext.getDeviceGroupRegistry()).thenReturn(deviceGroupRegistry);
         when(deviceContext.getDeviceMeterRegistry()).thenReturn(deviceMeterRegistry);
         when(deviceContext.getReadTransaction()).thenReturn(readTx);
+        when(txFacade.getReadTransaction()).thenReturn(readTx);
         when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionAdapter);
         when(connectionAdapter.getNodeId()).thenReturn(DUMMY_NODE_ID);
-        when(deviceState.getFeatures()).thenReturn(features);
         when(connectionAdapter.getFeatures()).thenReturn(features);
-
-        when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         when(features.getDatapathId()).thenReturn(BigInteger.ONE);
+        when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
 
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodePath);
+        when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodePath);
+        when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID);
     }
 
     @After
@@ -194,7 +204,7 @@ public class StatisticsGatheringUtilsTest {
         final ArgumentCaptor<Flow> flow = ArgumentCaptor.forClass(Flow.class);
 
         StatisticsGatheringUtils.writeFlowStatistics(prepareFlowStatisticsData(),
-                deviceContext.getDeviceState(), deviceContext.getDeviceFlowRegistry(), deviceContext);
+                deviceInfo, deviceContext.getDeviceFlowRegistry(), deviceContext);
 
         Mockito.verify(deviceContext).writeToTransaction(
                 dataStoreType.capture(), flowPath.capture(), flow.capture());
@@ -243,7 +253,7 @@ public class StatisticsGatheringUtilsTest {
                 .child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue)))
                 .augmentation(NodeGroupStatistics.class)
                 .child(GroupStatistics.class);
-        verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL),
+        verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.eq(groupPath), Matchers.any(GroupStatistics.class));
     }
 
@@ -274,7 +284,7 @@ public class StatisticsGatheringUtilsTest {
         verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>> any());
         verify(deviceGroupRegistry).removeMarked();
         verify(deviceGroupRegistry).store(storedGroupId);
-        verify(deviceContext).writeToTransaction(
+        verify(txFacade).writeToTransaction(
                 Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(Group.class));
     }
 
@@ -308,7 +318,7 @@ public class StatisticsGatheringUtilsTest {
                 .child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue)))
                 .augmentation(NodeMeterStatistics.class)
                 .child(MeterStatistics.class);
-        verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL),
+        verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.eq(meterPath), Matchers.any(MeterStatistics.class));
     }
 
@@ -332,7 +342,7 @@ public class StatisticsGatheringUtilsTest {
                 .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
                 .augmentation(FlowCapableNodeConnectorStatisticsData.class)
                 .child(FlowCapableNodeConnectorStatistics.class);
-        verify(deviceContext).writeToTransaction(
+        verify(txFacade).writeToTransaction(
                 Matchers.eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.eq(portPath),
                 Matchers.any(FlowCapableNodeConnectorStatistics.class));
@@ -362,7 +372,7 @@ public class StatisticsGatheringUtilsTest {
                 .child(Table.class, new TableKey((short) 0))
                 .augmentation(FlowTableStatisticsData.class)
                 .child(FlowTableStatistics.class);
-        verify(deviceContext).writeToTransaction(
+        verify(txFacade).writeToTransaction(
                 Matchers.eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.eq(tablePath),
                 Matchers.any(FlowTableStatistics.class));
@@ -396,7 +406,7 @@ public class StatisticsGatheringUtilsTest {
                 .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11")))
                 .augmentation(FlowCapableNodeConnector.class)
                 .child(Queue.class, new QueueKey(new QueueId(queueIdValue)));
-        verify(deviceContext).writeToTransaction(
+        verify(txFacade).writeToTransaction(
                 Matchers.eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.eq(queuePath),
                 Matchers.any(Queue.class));
@@ -404,10 +414,20 @@ public class StatisticsGatheringUtilsTest {
 
     @Test
     public void testGatherStatistics_flow() throws Exception {
+        final short tableId = 0;
         final MultipartType type = MultipartType.OFPMPFLOW;
         when(deviceFlowRegistry.storeIfNecessary(Matchers.any(FlowRegistryKey.class), Matchers.anyShort()))
                 .thenReturn(new FlowId("openflow:21"));
 
+        final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final TableBuilder tableDataBld = new TableBuilder();
+        tableDataBld.setId(tableId);
+        final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
+        flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
+        final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
+        final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
+        when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
+
         final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder matchBld =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder()
                         .setMatchEntry(Collections.<MatchEntry>emptyList());
@@ -437,7 +457,7 @@ public class StatisticsGatheringUtilsTest {
                 .child(Flow.class, new FlowKey(new FlowId("openflow:21")));
         verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
         verify(deviceFlowRegistry).storeIfNecessary(FlowRegistryKeyFactory.create(flowBld.build()), (short) 0);
-        verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(flowPath), Matchers.any(Flow.class));
+        verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(flowPath), Matchers.any(Flow.class));
     }
 
     @Test
@@ -466,16 +486,22 @@ public class StatisticsGatheringUtilsTest {
                 .child(Meter.class, new MeterKey(meterId));
         verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
         verify(deviceMeterRegistry).store(meterId);
-        verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class));
+        verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class));
     }
 
     private void fireAndCheck(final MultipartType type, final List<MultipartReply> statsData) throws InterruptedException, ExecutionException, TimeoutException {
         when(statisticsService.getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.eq(type)))
                 .thenReturn(Futures.immediateFuture(RpcResultBuilder.success(statsData).build()));
 
-        final ListenableFuture<Boolean> gatherStatisticsResult = StatisticsGatheringUtils.gatherStatistics(statisticsService, deviceContext, type);
+        final ListenableFuture<Boolean> gatherStatisticsResult = StatisticsGatheringUtils.gatherStatistics(
+                statisticsService,
+                deviceInfo,
+                type,
+                txFacade,
+                deviceContext,
+                false);
         Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS).booleanValue());
-        verify(deviceContext).submitTransaction();
+        verify(txFacade).submitTransaction();
     }
 
     private static MultipartReplyMessage assembleMPReplyMessage(final MultipartType type, final MultipartReplyBody mpReplyGroupCaseBld) {
@@ -491,19 +517,11 @@ public class StatisticsGatheringUtilsTest {
         return new BucketStatsBuilder().setByteCount(BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build();
     }
 
-    @Test
-    public void testDeleteAllKnownFlowsNotSync() throws Exception {
-        when(deviceState.deviceSynchronized()).thenReturn(false);
-        StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext.getDeviceState(),
-                deviceContext.getDeviceFlowRegistry(), deviceContext);
-        Mockito.verifyNoMoreInteractions(deviceFlowRegistry);
-    }
-
     @Test
     public void testDeleteAllKnownFlows() throws Exception {
         final short tableId = 0;
         when(deviceState.deviceSynchronized()).thenReturn(true);
-        final InstanceIdentifier<FlowCapableNode> nodePath = deviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         final TableBuilder tableDataBld = new TableBuilder();
         tableDataBld.setId(tableId);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
@@ -511,13 +529,13 @@ public class StatisticsGatheringUtilsTest {
         final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
         final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
         when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
-        final KeyedInstanceIdentifier<Table, TableKey> tablePath = deviceState.getNodeInstanceIdentifier()
+        final KeyedInstanceIdentifier<Table, TableKey> tablePath = deviceInfo.getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId));
 
-        StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext.getDeviceState(),
-                deviceContext.getDeviceFlowRegistry(), deviceContext);
+        StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo,
+                deviceContext.getDeviceFlowRegistry(), txFacade);
 
-        verify(deviceContext).writeToTransaction(
+        verify(txFacade).writeToTransaction(
                 LogicalDatastoreType.OPERATIONAL,
                 tablePath,
                 tableDataBld.setFlow(Collections.<Flow>emptyList()).build());
index f203cfbbc113236b86298b8d3fd77ea37249645b..24e040cd300e75b6208857a0611dac6e24a18510 100644 (file)
@@ -7,12 +7,10 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics;
 
-import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import io.netty.util.HashedWheelTimer;
@@ -22,8 +20,9 @@ import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -43,6 +42,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -55,7 +55,6 @@ import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegist
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -71,7 +70,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsWorkMode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -86,6 +84,7 @@ public class StatisticsManagerImplTest {
 
     private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444");
     private static final Short DUMMY_VERSION = OFConstants.OFP_VERSION_1_3;
+    public static final NodeId NODE_ID = new NodeId("ofp-unit-dummy-node-id");
 
     @Mock
     RequestContextStack mockedRequestContextStack;
@@ -104,6 +103,8 @@ public class StatisticsManagerImplTest {
     @Mock
     DeviceState mockedDeviceState;
     @Mock
+    DeviceInfo mockedDeviceInfo;
+    @Mock
     DeviceInitializationPhaseHandler mockedDevicePhaseHandler;
     @Mock
     DeviceTerminationPhaseHandler mockedTerminationPhaseHandler;
@@ -129,6 +130,8 @@ public class StatisticsManagerImplTest {
     private GetFeaturesOutput featuresOutput;
     @Mock
     private DeviceInitializationPhaseHandler deviceInitializationPhaseHandler;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     private RequestContext<List<MultipartReply>> currentRequestContext;
     private StatisticsManagerImpl statisticsManager;
@@ -140,15 +143,10 @@ public class StatisticsManagerImplTest {
                 .create(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId("openflow:10")));
 
-        when(mockedFeatures.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
-        when(mockedFeatures.getVersion()).thenReturn(DUMMY_VERSION);
-        when(mockedFeaturesOutput.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
-        when(mockedFeaturesOutput.getVersion()).thenReturn(DUMMY_VERSION);
-
         when(mockedPrimConnectionContext.getFeatures()).thenReturn(mockedFeatures);
         when(mockedPrimConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
         when(mockedPrimConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
-        when(mockedPrimConnectionContext.getNodeId()).thenReturn(new NodeId("ut-node:123"));
+        when(mockedPrimConnectionContext.getNodeId()).thenReturn(NODE_ID);
         when(mockedPrimConnectionContext.getOutboundQueueProvider()).thenReturn(outboundQueue);
 
         when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(Boolean.TRUE);
@@ -157,11 +155,11 @@ public class StatisticsManagerImplTest {
         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE);
-        when(mockedDeviceState.getFeatures()).thenReturn(featuresOutput);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
-
-        when(mockedDeviceState.getNodeId()).thenReturn(new NodeId("ofp-unit-dummy-node-id"));
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
+        when(mockedDeviceInfo.getNodeId()).thenReturn(new NodeId("ofp-unit-dummy-node-id"));
 
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl());
@@ -183,8 +181,7 @@ public class StatisticsManagerImplTest {
 
         statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, conductor);
         statisticsManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
-        when(deviceManager.getDeviceContextFromNodeId(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
-        when(conductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        when(conductor.getDeviceContext(deviceInfo)).thenReturn(mockedDeviceContext);
     }
 
     @Test
@@ -202,32 +199,32 @@ public class StatisticsManagerImplTest {
                 .commitEntry(Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
 
         statisticsManager.setDeviceInitializationPhaseHandler(mockedDevicePhaseHandler);
-        statisticsManager.onDeviceContextLevelUp(mockedDeviceContext.getDeviceState().getNodeId());
-        verify(mockedDevicePhaseHandler).onDeviceContextLevelUp(mockedDeviceContext.getDeviceState().getNodeId());
+        statisticsManager.onDeviceContextLevelUp(deviceInfo);
+        verify(mockedDevicePhaseHandler).onDeviceContextLevelUp(deviceInfo);
     }
 
     @Test
     public void testOnDeviceContextClosed() throws Exception {
         final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
-        final Map<NodeId, StatisticsContext> contextsMap = getContextsMap(statisticsManager);
+        final Map<DeviceInfo, StatisticsContext> contextsMap = getContextsMap(statisticsManager);
 
-        contextsMap.put(mockedDeviceContext.getDeviceState().getNodeId(), statisticContext);
+        contextsMap.put(deviceInfo, statisticContext);
         Assert.assertEquals(1, contextsMap.size());
 
         statisticsManager.setDeviceTerminationPhaseHandler(mockedTerminationPhaseHandler);
-        statisticsManager.onDeviceContextLevelDown(mockedDeviceContext);
+        statisticsManager.onDeviceContextLevelDown(deviceInfo);
         verify(statisticContext).close();
-        verify(mockedTerminationPhaseHandler).onDeviceContextLevelDown(mockedDeviceContext);
+        verify(mockedTerminationPhaseHandler).onDeviceContextLevelDown(deviceInfo);
         Assert.assertEquals(0, contextsMap.size());
     }
 
-    private static Map<NodeId, StatisticsContext> getContextsMap(final StatisticsManagerImpl statisticsManager)
+    private static Map<DeviceInfo, StatisticsContext> getContextsMap(final StatisticsManagerImpl statisticsManager)
             throws NoSuchFieldException, IllegalAccessException {
         // HACK: contexts map for testing shall be accessed in some more civilized way
         final Field contextsField = StatisticsManagerImpl.class.getDeclaredField("contexts");
         Assert.assertNotNull(contextsField);
         contextsField.setAccessible(true);
-        return (Map<NodeId, StatisticsContext>) contextsField.get(statisticsManager);
+        return (Map<DeviceInfo, StatisticsContext>) contextsField.get(statisticsManager);
     }
 
     @Test
@@ -247,13 +244,12 @@ public class StatisticsManagerImplTest {
     @Test
     public void testChangeStatisticsWorkMode1() throws Exception {
         final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
-        when(statisticContext.getDeviceContext()).thenReturn(mockedDeviceContext);
         when(statisticContext.getPollTimeout()).thenReturn(
-                Optional.<Timeout>absent());
+                Optional.<Timeout>empty());
         when(itemLifeCycleRegistry.getLifeCycleSources()).thenReturn(
                 Collections.<ItemLifeCycleSource>emptyList());
 
-        getContextsMap(statisticsManager).put(mockedDeviceContext.getDeviceState().getNodeId(), statisticContext);
+        getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
 
         final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
                 new ChangeStatisticsWorkModeInputBuilder()
@@ -267,7 +263,7 @@ public class StatisticsManagerImplTest {
         Mockito.verify(statisticContext).getPollTimeout();
     }
 
-    private static void checkWorkModeChangeOutcome(Future<RpcResult<Void>> workMode) throws InterruptedException, java.util.concurrent.ExecutionException {
+    private static void checkWorkModeChangeOutcome(Future<RpcResult<Void>> workMode) throws InterruptedException, ExecutionException {
         Assert.assertTrue(workMode.isDone());
         Assert.assertTrue(workMode.get().isSuccessful());
     }
@@ -283,13 +279,12 @@ public class StatisticsManagerImplTest {
         final Timeout pollTimeout = Mockito.mock(Timeout.class);
         final ItemLifeCycleSource itemLifecycleSource = Mockito.mock(ItemLifeCycleSource.class);
         final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
-        when(statisticContext.getDeviceContext()).thenReturn(mockedDeviceContext);
         when(statisticContext.getPollTimeout()).thenReturn(
                 Optional.of(pollTimeout));
         when(itemLifeCycleRegistry.getLifeCycleSources()).thenReturn(
                 Collections.singletonList(itemLifecycleSource));
 
-        getContextsMap(statisticsManager).put(mockedDeviceContext.getDeviceState().getNodeId(), statisticContext);
+        getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
 
         final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
                 new ChangeStatisticsWorkModeInputBuilder()
@@ -318,7 +313,6 @@ public class StatisticsManagerImplTest {
                 .setItemLifecycleListener(itemLifeCycleListenerCapt.capture());
 
         final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
-        when(statisticContext.getDeviceContext()).thenReturn(mockedDeviceContext);
         when(statisticContext.getPollTimeout()).thenReturn(
                 Optional.of(pollTimeout));
         when(statisticContext.getItemLifeCycleListener()).thenReturn(
@@ -326,7 +320,7 @@ public class StatisticsManagerImplTest {
         when(itemLifeCycleRegistry.getLifeCycleSources()).thenReturn(
                 Collections.singletonList(itemLifecycleSource));
 
-        getContextsMap(statisticsManager).put(mockedDeviceContext.getDeviceState().getNodeId(), statisticContext);
+        getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
 
         final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
                 new ChangeStatisticsWorkModeInputBuilder()
@@ -361,7 +355,7 @@ public class StatisticsManagerImplTest {
     @Test
     public void testCalculateTimerDelay() throws Exception {
         final TimeCounter timeCounter = Mockito.mock(TimeCounter.class);
-        when(timeCounter.getAverageTimeBetweenMarks()).thenReturn((Long)2000L, (Long)4000L);
+        when(timeCounter.getAverageTimeBetweenMarks()).thenReturn(2000L, (Long)4000L);
 
         statisticsManager.calculateTimerDelay(timeCounter);
         Assert.assertEquals(3000L, StatisticsManagerImpl.getCurrentTimerDelay());
@@ -374,25 +368,23 @@ public class StatisticsManagerImplTest {
         final StatisticsContext statisticsContext = Mockito.mock(StatisticsContext.class);
         final TimeCounter mockTimerCounter = Mockito.mock(TimeCounter.class);
 
-        statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
+        statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
         verify(mockedDeviceContext).getDeviceState();
 
         when(mockedDeviceContext.getDeviceState().isValid()).thenReturn(true);
-        statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
-        // TODO Make scheduleNextPolling visible for tests?
+        statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
 
         when(mockedDeviceContext.getDeviceState().isStatisticsPollingEnabled()).thenReturn(true);
-        statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
-        // TODO Make scheduleNextPolling visible for tests?
+        statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
 
         when(statisticsContext.gatherDynamicData()).thenReturn(Futures.immediateCheckedFuture(Boolean.TRUE));
         when(statisticsContext.isSchedulingEnabled()).thenReturn(Boolean.TRUE);
-        statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
+        statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
         Mockito.verify(mockTimerCounter).markStart();
         Mockito.verify(mockTimerCounter).addTimeMark();
 
         when(statisticsContext.gatherDynamicData()).thenReturn(Futures.immediateFailedFuture(new Throwable("error msg")));
-        statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
+        statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
         Mockito.verify(mockTimerCounter,times(2)).addTimeMark();
     }
 }
\ No newline at end of file
index d599b860b46b84dca3ddee04e168eeedce6e7f32..8b3f29465c41dc04d6003ec9074c96c8a9d54679 100644 (file)
@@ -1,12 +1,10 @@
 package org.opendaylight.openflowplugin.impl.statistics.ofpspecific;
 
-import junit.framework.TestCase;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import static org.junit.Assert.assertTrue;
 
 import java.util.List;
-
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 
 
 public class MessageIntelligenceAgencyImplTest {
index a3480ed9ad9775bdc4890d643e19b9a7b4c59bb3..bd25110f4a528f2efaa7e5cf161251c1b6130ab7 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -64,6 +65,8 @@ public abstract class AbstractStatsServiceTest {
     protected TranslatorLibrary translatorLibrary;
     @Mock
     protected DeviceState deviceState;
+    @Mock
+    protected DeviceInfo deviceInfo;
 
 
     public static final NodeId NODE_ID = new NodeId("unit-test-node:123");
@@ -91,9 +94,10 @@ public abstract class AbstractStatsServiceTest {
         Mockito.when(deviceContext.getMultiMsgCollector(Matchers.any(RequestContext.class))).thenReturn(multiMsgCollector);
         Mockito.when(deviceContext.oook()).thenReturn(translatorLibrary);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
         Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
         Mockito.when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
index 236e50577a1d81e77995b223aac88199de7c48bf..8c3d71dbb6debce9ebdcba942fc22549578c7f6b 100644 (file)
@@ -82,7 +82,7 @@ public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsSer
                          }
         ).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
         Mockito.when(translator.translate(
-                        Matchers.any(MultipartReply.class), Matchers.same(deviceState), Matchers.isNull())
+                        Matchers.any(MultipartReply.class), Matchers.same(deviceInfo), Matchers.isNull())
         ).thenReturn(new AggregatedFlowStatisticsBuilder().build());
 
 
index d6dccf17037816a9bc6fbe6ac31442043455be0a..598ddbcad2d596f49e0df0d6b907daaa8eebd50a 100644 (file)
@@ -24,6 +24,7 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
@@ -64,6 +65,8 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest
     @Mock
     private DeviceState deviceState;
     @Mock
+    private DeviceInfo deviceInfo;
+    @Mock
     private MessageTranslator<Object, Object> translator;
     @Mock
     private GetFeaturesOutput featuresOutput;
@@ -95,9 +98,9 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest
         Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting();
         Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
 
@@ -140,7 +143,7 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest
                 .setFlowCount(new Counter32(12L))
                 .setPacketCount(new Counter64(BigInteger.valueOf(13L)))
                 .build();
-        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceState), Matchers.any()))
+        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any()))
                 .thenReturn(aggregatedStats);
 
 
index 835e489101cbd5b2987bd6448445c44a9194b59e..2e08295b19c60269c2ab3177295dead2c64ad1ec 100644 (file)
@@ -95,7 +95,7 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS
                 .setNode(createNodeRef("unitProt:123"))
                 .setTableId(new TableId((short) 1));
 
-        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceState), Matchers.any()))
+        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any()))
                 .thenReturn(new AggregatedFlowStatisticsBuilder()
                         .setByteCount(new Counter64(BigInteger.valueOf(50L)))
                         .setPacketCount(new Counter64(BigInteger.valueOf(51L)))
index ab611e216afbb57f0e163a8732e748d2acccd267..eb17d48ae775499080e9c194199cc91b54c3bacd 100644 (file)
@@ -31,7 +31,8 @@ public class StatisticsGatheringOnTheFlyServiceTest extends ServiceMocking {
     protected void setup() {
         statisticsGatheringService = new StatisticsGatheringOnTheFlyService(mockedRequestContextStack, mockedDeviceContext);
         Mockito.doReturn(NODE_ID).when(mockedPrimConnectionContext).getNodeId();
-        Mockito.when(mockedDeviceContext.getDeviceState().getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(mockedDeviceInfo.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(mockedDeviceContext.getDeviceInfo().getNodeId()).thenReturn(NODE_ID);
     }
 
     @Test
index 7263b980c7841715982f7bbe0b032355e22ec180..024d08762f64275293470e516b35ab30b6dcc555 100644 (file)
@@ -8,6 +8,10 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -17,6 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
@@ -36,11 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
-import java.math.BigInteger;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
 @RunWith(MockitoJUnitRunner.class)
 public abstract class AbstractDirectStatisticsServiceTest {
     protected static final Long PORT_NO = 1L;
@@ -67,6 +67,8 @@ public abstract class AbstractDirectStatisticsServiceTest {
     @Mock
     protected DeviceState deviceState;
     @Mock
+    protected DeviceInfo deviceInfo;
+    @Mock
     protected GetFeaturesOutput getFeaturesOutput;
 
     protected NodeConnectorId nodeConnectorId;
@@ -95,11 +97,11 @@ public abstract class AbstractDirectStatisticsServiceTest {
         when(deviceContext.getMultiMsgCollector(any())).thenReturn(multiMsgCollector);
         when(deviceContext.oook()).thenReturn(translatorLibrary);
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
-        when(deviceState.getNodeId()).thenReturn(new NodeId(NODE_ID));
-        when(deviceState.getVersion()).thenReturn(OF_VERSION);
-        when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+        when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
+        when(deviceInfo.getNodeId()).thenReturn(new NodeId(NODE_ID));
+        when(deviceInfo.getVersion()).thenReturn(OF_VERSION);
+        when(deviceInfo.getDatapathId()).thenReturn(DATAPATH_ID);
         when(getFeaturesOutput.getVersion()).thenReturn(OF_VERSION);
         when(getFeaturesOutput.getDatapathId()).thenReturn(DATAPATH_ID);
         when(connectionContext.getFeatures()).thenReturn(features);
index 11b2b63c47927546eb30ba1aa05c47cbcc077dfa..1a12318a0ababc1c7301e446d35fb8d631cbc752 100644 (file)
@@ -8,6 +8,18 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput;
@@ -24,19 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlow;
 
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
     static final Short TABLE_NO = 1;
     private FlowDirectStatisticsService service;
index e948929855611bb12b55667d83ebed0f7e843be2..87811f1b92eeed7e1dd621700040dee457873577 100644 (file)
@@ -8,6 +8,17 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput;
@@ -19,18 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroup;
 
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
     static final Long GROUP_NO = 1L;
     private GroupDirectStatisticsService service;
index 7c837035be86c98e099c1e1dccea71e8df1c0ef7..b923cff06871a636161f0e638563b75991896774 100644 (file)
@@ -8,6 +8,17 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput;
@@ -19,18 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeter;
 
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
     static final Long METER_NO = 1L;
     private MeterDirectStatisticsService service;
index 9296347130668a9fc8a8cc92d84f7ed60c42862f..d95595e08205e6c4fb109fbb57ae782ab3275dad 100644 (file)
@@ -8,6 +8,17 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput;
@@ -19,18 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
 
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
     private NodeConnectorDirectStatisticsService service;
 
index c3a2c26a178656b7404a6835c28034dc80ab8e5b..33b0746aa9635cb325a976aa2853d2d4bd4ea930 100644 (file)
@@ -8,6 +8,11 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -27,11 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
 @RunWith(MockitoJUnitRunner.class)
 public class OpendaylightDirectStatisticsServiceImplTest {
     @Mock
index 3df2f25f70ba127e4e4b3a3ef308684ca5de3e6b..c8ae34a06bab366bdbb20e0e0735975d3f60012e 100644 (file)
@@ -8,6 +8,17 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutput;
@@ -21,18 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
 
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
     static final Long QUEUE_NO = 1L;
     private QueueDirectStatisticsService service;
index a840fa9a4ae386fee01e45b4237938827ffd5cf6..270582ca0bd55bc870444be893804297b8be9487 100644 (file)
@@ -15,8 +15,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
@@ -30,7 +29,7 @@ public class AggregatedFlowStatisticsTranslatorTest {
 
     private AggregatedFlowStatisticsTranslator translator;
     @Mock
-    private DeviceState deviceState;
+    private DeviceInfo deviceInfo;
 
     @Before
     public void setUp() throws Exception {
@@ -48,7 +47,7 @@ public class AggregatedFlowStatisticsTranslatorTest {
         MultipartReplyMessageBuilder mpInputBld = new MultipartReplyMessageBuilder()
                 .setMultipartReplyBody(inputBld.build());
 
-        final AggregatedFlowStatistics statistics = translator.translate(mpInputBld.build(), deviceState, null);
+        final AggregatedFlowStatistics statistics = translator.translate(mpInputBld.build(), deviceInfo, null);
 
         Assert.assertEquals(aggregateStatsValueBld.getByteCount(), statistics.getByteCount().getValue());
         Assert.assertEquals(aggregateStatsValueBld.getFlowCount(), statistics.getFlowCount().getValue());
index a695ef097017dbdde2df959cea31b6d0ac9061cd..d3e95982193122398c65b6cd178982502ff927a1 100644 (file)
@@ -13,21 +13,21 @@ import static org.mockito.Mockito.when;
 
 import java.math.BigInteger;
 import java.util.Collections;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
@@ -52,6 +52,9 @@ public class FlowRemovedTranslatorTest {
     @Mock
     private DeviceState deviceState;
 
+    @Mock
+    private DeviceInfo deviceInfo;
+
     @Mock
     private GetFeaturesOutput features;
 
@@ -69,15 +72,14 @@ public class FlowRemovedTranslatorTest {
         translatorV10 = new FlowRemovedV10Translator();
 
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeId);
-        when(deviceState.getFeatures()).thenReturn(features);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeId);
         when(features.getDatapathId()).thenReturn(BigInteger.TEN);
     }
 
     @Test
     public void testTranslate() throws Exception {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved flowRemovedMessage = buildMessage(false);
-        final FlowRemoved flowRemoved = translator.translate(flowRemovedMessage, deviceState, null);
+        final FlowRemoved flowRemoved = translator.translate(flowRemovedMessage, deviceInfo, null);
 
         assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
         assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
@@ -87,25 +89,25 @@ public class FlowRemovedTranslatorTest {
     @Test
     public void testTranslateV10() throws Exception {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved flowRemovedMessage = buildMessage(true);
-        final FlowRemoved flowRemoved = translatorV10.translate(flowRemovedMessage, deviceState, null);
+        final FlowRemoved flowRemoved = translatorV10.translate(flowRemovedMessage, deviceInfo, null);
 
         assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
         assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
-        assertEquals((long)flowRemovedMessage.getTableId().getValue(), (long)flowRemoved.getTableId());
+        assertEquals((short)0, flowRemoved.getTableId().shortValue());
     }
 
     private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved buildMessage(boolean isV10) {
         FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder()
                 .setCookie(BigInteger.ONE)
-                .setPriority(1)
-                .setTableId(new TableId(42l));
+                .setPriority(1);
 
         if (isV10) {
             builder.setMatchV10(new MatchV10Builder().setWildcards(flowWildcards).build());
         } else {
-            builder.setMatch(new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList()).build());
+            builder.setMatch(new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList()).build())
+                .setTableId(new TableId(42L));
         }
 
         return builder.build();
     }
-}
\ No newline at end of file
+}
index f6358fad05462f83e37d6ae8eaf8eebcd4c374cf..62bbe22aa9b2153d0f92e59f806dda05198f23d9 100644 (file)
@@ -4,7 +4,6 @@ import com.google.common.collect.Lists;
 import java.math.BigInteger;
 import java.util.Arrays;
 import java.util.List;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -16,6 +15,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -63,6 +63,8 @@ public class PacketReceivedTranslatorTest {
     @Mock
     DeviceContext deviceContext;
     @Mock
+    DeviceInfo deviceInfo;
+    @Mock
     List<PhyPort> phyPorts;
     @Mock
     PhyPort phyPort;
@@ -84,8 +86,8 @@ public class PacketReceivedTranslatorTest {
         Mockito.when(connectionContext.getFeatures()).thenReturn(featuresReply);
         Mockito.when(featuresReply.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(getFeaturesOutput.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(getFeaturesOutput.getPhyPort()).thenReturn(phyPorts);
         Mockito.when(phyPort.getPortNo()).thenReturn(PORT_NO_DS);
@@ -98,9 +100,9 @@ public class PacketReceivedTranslatorTest {
                 .child(Node.class, new NodeKey(new NodeId("openflow:10")));
         final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator();
         final PacketInMessage packetInMessage = createPacketInMessage(DATA.getBytes(), PORT_NO);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
 
-        final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceState, null);
+        final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceInfo, null);
 
         Assert.assertArrayEquals(packetInMessage.getData(), packetReceived.getPayload());
         Assert.assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController",
index c4a1f2a285ff76ddac21c96ec5126f12e32a81b7..5500dea5ee8cca73858cc82da691fe1d6c59c57e 100644 (file)
@@ -17,6 +17,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -40,6 +41,8 @@ public class PortUpdateTranslatorTest {
     private DeviceContext deviceContext;
     @Mock
     private DeviceState deviceState;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig portConfig;
     private StateBuilder portStateBld;
@@ -47,7 +50,7 @@ public class PortUpdateTranslatorTest {
 
     @Before
     public void setUp() throws Exception {
-        Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         portUpdateTranslator = new PortUpdateTranslator();
 
         portStateBld = new StateBuilder().setLive(true);
@@ -59,13 +62,13 @@ public class PortUpdateTranslatorTest {
 
     @Test
     public void testTranslate_13() throws Exception {
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures portFeatures =
                 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures
                         .getDefaultInstance("hundredGbFd");
 
 
-        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceState, null);
+        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceInfo, null);
 
         commonCheck(nodeConnector);
 
@@ -88,14 +91,14 @@ public class PortUpdateTranslatorTest {
 
     @Test
     public void testTranslate_10() throws Exception {
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures portFeatures =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures(
                         null, null, null, false, false, true, null, null,
                         null, false, false, null, null, null, null, null
                 );
 
-        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceState, null);
+        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceInfo, null);
 
         commonCheck(nodeConnector);
 
index e20beab46b23393a8b9df81efbe0586376b5b0a7..71da6bd8c1388382fe4e228959e041d9e50fbd3a 100644 (file)
@@ -16,18 +16,17 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -46,6 +45,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandle
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -130,7 +130,11 @@ public class DeviceInitializationUtilsTest {
     @Mock
     private DeviceContextImpl mockedDeviceContext;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private DeviceInitializationUtils deviceInitializationUtils;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     @Before
     public void setUp() throws Exception {
@@ -140,6 +144,7 @@ public class DeviceInitializationUtilsTest {
         when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures);
         when(mockConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
 
         final Capabilities capabilitiesV13 = mock(Capabilities.class);
         final CapabilitiesV10 capabilitiesV10 = mock(CapabilitiesV10.class);
@@ -156,10 +161,9 @@ public class DeviceInitializationUtilsTest {
 
         GetFeaturesOutput mockedFeatures = mock(GetFeaturesOutput.class);
         when(mockedFeatures.getTables()).thenReturn((short) 2);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeatures);
-        when(mockedDeviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
+        when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
         when(mockedDeviceContext.getMultiMsgCollector(Mockito.any(RequestContext.class))).thenReturn(msgCollector);
         when(mockedDeviceContext.oook()).thenReturn(tLibrary);
@@ -179,9 +183,9 @@ public class DeviceInitializationUtilsTest {
 
         final GetFeaturesOutput mockedFeatures = mock(GetFeaturesOutput.class);
         when(mockedFeatures.getTables()).thenReturn((short) 2);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeatures);
+        when(mockConnectionContext.getFeatures()).thenReturn(mockedFeatures);
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
 
         final RpcResult<List<MultipartReply>> mockedRpcResult = mock(RpcResult.class);
@@ -280,7 +284,7 @@ public class DeviceInitializationUtilsTest {
         when(mockedPrimaryConnectionContext.getFeatures()).thenReturn(mockedFeatures);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnectionContext);
         final DeviceState mockedDeviceState = mock(DeviceState.class);
-        when(mockedDeviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
+        when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
         final MessageTranslator mockedTranslator = mock(MessageTranslator.class);
         when(translatorLibrary.lookupTranslator(any(TranslatorKey.class))).thenReturn(mockedTranslator);
index cf0149cd79ffea230d337755f76834bdb7e5be30..0430590a31bd25400679f43019b075347fb74a59 100644 (file)
@@ -17,15 +17,17 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.math.BigInteger;
 import org.junit.Test;
 import org.mockito.Matchers;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
@@ -45,20 +47,21 @@ public class MdSalRegistrationUtilsTest {
         final ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
 
         final DeviceState mockedDeviceState = mock(DeviceState.class);
+        final DeviceInfo mockedDeviceInfo = mock(DeviceInfo.class);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
 
         final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
 
-        final GetFeaturesOutput mockedFeaturesOutput = mock(GetFeaturesOutput.class);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
-
         final BigInteger mockedDataPathId = mock(BigInteger.class);
         when(mockedFeatures.getDatapathId()).thenReturn(mockedDataPathId);
-        when(mockedFeaturesOutput.getDatapathId()).thenReturn(mockedDataPathId);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(mockedDataPathId);
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
-        MdSalRegistrationUtils.registerMasterServices(mockedRpcContext, mockedDeviceContext, OfpRole.BECOMEMASTER);
+
+        final ExtensionConverterProvider extensionConverterProvider = mock(ExtensionConverterProvider.class);
+        MdSalRegistrationUtils.registerMasterServices(mockedRpcContext, mockedDeviceContext, OfpRole.BECOMEMASTER, extensionConverterProvider);
         verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(
                 Matchers.<Class<RpcService>> any(), any(RpcService.class));
     }
index 9245bbbe01a4ca8308bd7d8b53e5551fd80caf37..c376457b733add008b2c10a3478ef9b4b31831ff 100644 (file)
@@ -1,20 +1,15 @@
 package org.opendaylight.openflowplugin.impl.util;
 
 import com.google.common.collect.Lists;
+import java.math.BigInteger;
 import junit.framework.TestCase;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
@@ -24,18 +19,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-import static org.mockito.Mockito.*;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * Created by Tomas Slusny on 24.3.2016.
diff --git a/openflowplugin/.gitignore b/openflowplugin/.gitignore
deleted file mode 100644 (file)
index ea8c4bf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target
index 9963aaa8da6c6e7f814122d7fc5fc56a3443ed84..4f446b58a1349af89fcfabe17511b2d1ab21c92a 100644 (file)
@@ -23,9 +23,9 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
@@ -80,6 +80,19 @@ public class OfEntityManager implements TransactionChainListener{
         this.dataBroker = dbBroker;
     }
 
+    public void init(){
+        registerEntityOwnershipChangeListener();
+    }
+
+    public void registerEntityOwnershipChangeListener() {
+        if(entityOwnershipService!=null) {
+            if(LOG.isDebugEnabled()) {
+                LOG.debug("registerEntityOwnershipChangeListener: Registering entity ownership change listener for entitier of type {}", DEVICE_TYPE);
+            }
+        entityOwnershipService.registerListener(DEVICE_TYPE, ownershipListener);
+        }
+    }
+
     public void requestOpenflowEntityOwnership(final ModelDrivenSwitch ofSwitch,
                                                final SessionContext context,
                                                final NotificationQueueWrapper wrappedNotification,
@@ -87,9 +100,6 @@ public class OfEntityManager implements TransactionChainListener{
         MDSwitchMetaData entityMetaData =
                 new MDSwitchMetaData(ofSwitch,context,wrappedNotification,rpcProviderRegistry);
 
-        if (registeredListener.compareAndSet(false, true)) {
-            entityOwnershipService.registerListener(DEVICE_TYPE, ownershipListener);
-        }
         final Entity entity = new Entity(DEVICE_TYPE, ofSwitch.getNodeId().getValue());
         entsession.put(entity, entityMetaData);
 
@@ -338,13 +348,13 @@ public class OfEntityManager implements TransactionChainListener{
        // NOOP
     }
 
-    private void registerRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
+    private static void registerRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
         // Routed RPC registration is only done when *this* instance is owner of
         // the entity.
         if(entityMetadata.getOfSwitch().isEntityOwner()) {
             if (!entityMetadata.isRPCRegistrationDone.get()) {
                 entityMetadata.setIsRPCRegistrationDone(true);
-                CompositeObjectRegistration<ModelDrivenSwitch> registration =
+                ModelDrivenSwitchRegistration registration =
                         entityMetadata.getOfSwitch().register(entityMetadata.getRpcProviderRegistry());
 
                 entityMetadata.getContext().setProviderRegistration(registration);
@@ -358,9 +368,9 @@ public class OfEntityManager implements TransactionChainListener{
         }
     }
 
-    private void deregisterRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
+    private static void deregisterRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
 
-        CompositeObjectRegistration<ModelDrivenSwitch> registration = entityMetadata.getContext().getProviderRegistration();
+        ModelDrivenSwitchRegistration registration = entityMetadata.getContext().getProviderRegistration();
         if (null != registration) {
             registration.close();
             entityMetadata.getContext().setProviderRegistration(null);
@@ -370,7 +380,7 @@ public class OfEntityManager implements TransactionChainListener{
                 entityMetadata.getOfSwitch().getNodeId().getValue());
     }
 
-    private void sendNodeAddedNotification(MDSwitchMetaData entityMetadata) {
+    private static void sendNodeAddedNotification(MDSwitchMetaData entityMetadata) {
         //Node added notification need to be sent irrespective of whether
         // *this* instance is owner of the entity or not. Because yang notifications
         // are local, and we should maintain the behavior across the application.
index ad4bdbc3ffa3a62df25e9eea6eaecc934af13b4b..088bc74800e7238a973bf1d78b2ca5f6c2fad935 100644 (file)
@@ -7,9 +7,14 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+import java.util.Collection;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.md.AbstractModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
@@ -26,8 +31,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalP
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
@@ -52,9 +55,8 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
     }
 
     @Override
-    public CompositeObjectRegistration<ModelDrivenSwitch> register(RpcProviderRegistry rpcProviderRegistry) {
-        CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
-                .<ModelDrivenSwitch> builderFor(this);
+    public ModelDrivenSwitchRegistration register(RpcProviderRegistry rpcProviderRegistry) {
+        final Builder<RoutedRpcRegistration<?>> builder = ImmutableList.builder();
 
         final RoutedRpcRegistration<SalFlowService> flowRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalFlowService.class, this);
         flowRegistration.registerPath(NodeContext.class, getIdentifier());
@@ -108,7 +110,15 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
         queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
         builder.add(queueStatisticsRegistration);
 
-        return builder.build();
+        final Collection<RoutedRpcRegistration<?>> registrations = builder.build();
+        return new AbstractModelDrivenSwitchRegistration(this) {
+            @Override
+            protected void removeRegistration() {
+                for (RoutedRpcRegistration<?> r : registrations) {
+                    r.close();
+                }
+            }
+        };
     }
 
     /**
index 24b6533ea72e0f0bd90a4c277dde10a1c89fbaac..58754980b056e55a3ea56f20250fa08864831720 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
@@ -20,13 +21,12 @@ import org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegi
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterManager;
 import org.opendaylight.openflowplugin.openflow.md.core.MDController;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFRoleManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.statistics.MessageSpyCounterImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.OfpRole;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,6 +37,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginProvider.class);
 
+    private static final boolean SKIP_TABLE_FEATURES = false;
+
     private Collection<SwitchConnectionProvider> switchConnectionProviders;
 
     private MDController mdController;
@@ -48,6 +50,7 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     private ExtensionConverterManager extensionConverterManager;
 
     private OfpRole role;
+    private Boolean skipTableFeatures;
 
     private OFRoleManager roleManager;
     private OfEntityManager entManager;
@@ -58,6 +61,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
 
     private OpenflowPluginConfig openflowPluginConfig;
 
+
+
     /**
      * Initialization of services and msgSpy counter
      */
@@ -65,8 +70,10 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         messageCountProvider = new MessageSpyCounterImpl();
         extensionConverterManager = new ExtensionConverterManagerImpl();
         roleManager = new OFRoleManager(OFSessionUtil.getSessionManager());
+        openflowPluginConfig = readConfig(skipTableFeatures);
         entManager = new OfEntityManager(entityOwnershipService,getOpenflowPluginConfig());
         entManager.setDataBroker(dataBroker);
+        entManager.init();
 
         LOG.debug("dependencies gathered..");
         registrationManager = new SalRegistrationManager();
@@ -94,10 +101,16 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     @Override
     public void close() {
         LOG.debug("close");
-        mdController.stop();
-        mdController = null;
-        registrationManager.close();
-        registrationManager = null;
+
+        if(mdController != null) {
+            mdController.stop();
+            mdController = null;
+        }
+
+        if(registrationManager != null) {
+            registrationManager.close();
+            registrationManager = null;
+        }
     }
 
     public MessageCountDumper getMessageCountDumper() {
@@ -146,6 +159,20 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         }
     }
 
+    private OpenflowPluginConfig readConfig(Boolean skipTableFeatures){
+
+        final OpenflowPluginConfig.OpenflowPluginConfigBuilder openflowCfgBuilder = OpenflowPluginConfig.builder();
+
+        if(skipTableFeatures !=null){
+            openflowCfgBuilder.setSkipTableFeatures(skipTableFeatures.booleanValue());
+        } else{
+            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
+            openflowCfgBuilder.setSkipTableFeatures(SKIP_TABLE_FEATURES);
+        }
+
+        return openflowCfgBuilder.build();
+    }
+
     public void setDataBroker(DataBroker dataBroker) {
         this.dataBroker = dataBroker;
     }
@@ -162,8 +189,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         this.entityOwnershipService = entityOwnershipService;
     }
 
-    public void setOpenflowPluginConfig(OpenflowPluginConfig openflowPluginConfig) {
-        this.openflowPluginConfig = openflowPluginConfig;
+    public void setSkipTableFeatures(Boolean skipTableFeatures) {
+        this.skipTableFeatures = skipTableFeatures;
     }
 
     @VisibleForTesting
index 46463f1c7098076e337d2c8c5b20a4c60687a147..8b45aba2a2d6ab5980125e8da52e16d1ddc10e81 100644 (file)
@@ -17,15 +17,18 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionListener;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionManager;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessionKeyOF;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -38,12 +41,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -129,7 +129,7 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         unregOpenflowEntityOwnership(nodeId);
         NodeRemoved nodeRemoved = nodeRemoved(nodeRef);
 
-        CompositeObjectRegistration<ModelDrivenSwitch> registration = context.getProviderRegistration();
+        ModelDrivenSwitchRegistration registration = context.getProviderRegistration();
         if (null != registration) {
             registration.close();
             context.setProviderRegistration(null);
@@ -149,8 +149,9 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder();
         try {
             builder2.setIpAddress(getIpAddressOf(sw));
+            builder2.setPortNumber(getPortNumberOf(sw));
         } catch (Exception e) {
-            LOG.warn("IP address of the node {} cannot be obtained.", sw.getNodeId(), e);
+            LOG.warn("IP address/Port Number of the node {} cannot be obtained.", sw.getNodeId(), e);
         }
         builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features));
         builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build());
@@ -184,6 +185,27 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         throw new IllegalArgumentException("Unsupported IP address type!");
     }
 
+    private static PortNumber getPortNumberOf(ModelDrivenSwitch sw) {
+        SessionContext sessionContext = sw.getSessionContext();
+
+        Preconditions.checkNotNull(sessionContext.getPrimaryConductor(),
+                "primary conductor must not be NULL -> " + sw.getNodeId());
+        Preconditions.checkNotNull(sessionContext.getPrimaryConductor().getConnectionAdapter(),
+                "connection adapter of primary conductor must not be NULL -> " + sw.getNodeId());
+        InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter()
+                .getRemoteAddress();
+        if (remoteAddress == null) {
+            LOG.warn("Port Number of the node {} cannot be obtained. No connection with switch.", sw.getNodeId());
+            return null;
+        }
+        return resolvePortNumber(remoteAddress.getPort());
+    }
+
+    private static PortNumber resolvePortNumber(int port) {
+        PortNumber portNo = new PortNumber(port);
+        return portNo;
+    }
+
     private static NodeRemoved nodeRemoved(final NodeRef nodeRef) {
         NodeRemovedBuilder builder = new NodeRemovedBuilder();
         builder.setNodeRef(nodeRef);
index 9a09033db747031aff64dae8db29d6b554e9086f..fbf9e8cdf4d022cb52ca60a5f703d0ba9a500420 100644 (file)
@@ -15,6 +15,9 @@ import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.List;
+
+import com.google.common.collect.Lists;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
@@ -224,7 +227,11 @@ public final class IpConversionUtil {
          * the input is validated via regexps in Ipv6Prefix()
          */
 
-        String [] address =  (ipv6Address.getValue()).split("%");
+       Iterable<String> splittedV6Address = Splitter.on("%")
+                .trimResults()
+                .omitEmptyStrings()
+                .split(ipv6Address.getValue());
+        List<String> partsV6Address = Lists.newArrayList(splittedV6Address.iterator());
 
         int colonp;
         char ch;
@@ -234,7 +241,7 @@ public final class IpConversionUtil {
 
         int val;
 
-        char[] src = address[0].toCharArray();
+        char[] src = partsV6Address.get(0).toCharArray();
 
         byte[] dst = new byte[INADDR6SZ];
 
@@ -307,7 +314,7 @@ public final class IpConversionUtil {
 
                 Preconditions.checkArgument(j != (INADDR6SZ - INADDR4SZ - 1), "Invalid v4 in v6 mapping");
 
-                InetAddress _inet_form = InetAddresses.forString(address[0].substring(curtok, src_length));
+                InetAddress _inet_form = InetAddresses.forString(partsV6Address.get(0).substring(curtok, src_length));
 
                 Preconditions.checkArgument(_inet_form instanceof Inet4Address);
                 System.arraycopy(_inet_form.getAddress(), 0, dst, j, INADDR4SZ);
@@ -372,13 +379,16 @@ public final class IpConversionUtil {
 
         int mask = 128;
 
-        String [] address = null;
+        Iterable<String> splittedV6Prefix = Splitter.on("/")
+                .trimResults()
+                .omitEmptyStrings()
+                .split(ipv6Prefix.getValue());
+        List<String> partsV6Prefix = Lists.newArrayList(splittedV6Prefix.iterator());
 
         boolean valid = true;
 
-        address =  (ipv6Prefix.getValue()).split("/");
         try {
-            mask = Integer.parseInt(address[1]);
+            mask = Integer.parseInt(partsV6Prefix.get(1));
             if (mask > 128) {
                 valid = false;
             }
@@ -397,7 +407,7 @@ public final class IpConversionUtil {
 
         int val;
 
-        char[] src = address[0].toCharArray();
+        char[] src = partsV6Prefix.get(0).toCharArray();
 
         byte[] dst = new byte[INADDR6SZ + 1];
 
@@ -485,7 +495,7 @@ public final class IpConversionUtil {
 
                 Preconditions.checkArgument(j != (INADDR6SZ - INADDR4SZ - 1), "Invalid v4 in v6 mapping");
 
-                InetAddress _inet_form = InetAddresses.forString(address[0].substring(curtok, src_length));
+                InetAddress _inet_form = InetAddresses.forString(partsV6Prefix.get(0).substring(curtok, src_length));
 
                 Preconditions.checkArgument(_inet_form instanceof Inet4Address);
                 System.arraycopy(_inet_form.getAddress(), 0, dst, j, INADDR4SZ);
@@ -645,6 +655,7 @@ public final class IpConversionUtil {
             String maskInBits;
             // converting byte array to bits
             maskInBits = new BigInteger(1, byteMask).toString(2);
+
             ArrayList<String> stringMaskArrayList = new ArrayList<String>(Arrays.asList(maskInBits.split("(?!^)")));
             for (String string:stringMaskArrayList) {
                 integerMaskArrayList.add(Integer.parseInt(string));
index 1558524eccd6c03fbbf19fb8a828be4b8332e64e..bc002d1409e58e85ce9f4d7d7fdecef3f8dc0a59 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 import org.opendaylight.controller.sal.common.util.Arguments;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
@@ -123,8 +124,8 @@ public final class PacketOutConvertor {
         InstanceIdentifier.IdentifiableItem<?, ?> item = Arguments.checkInstanceOf(pathArgument,
                 InstanceIdentifier.IdentifiableItem.class);
         NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
-        String[] split = key.getId().getValue().split(":");
-        Long port = OpenflowPortsUtil.getPortFromLogicalName(OpenflowVersion.get(ofVersion), split[split.length - 1]);
+        Long port =  InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                OpenflowVersion.get(ofVersion), key.getId());
         return new PortNumber(port);
     }
 }
index 899e1f66c5874d5fb61ff94b7d15fc758a7da6d9..803f41bd7dbda22fec30e2ab6bd7c2fb154e3774 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
@@ -29,7 +29,6 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessio
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 
 /**
  * @author mirehak
@@ -46,7 +45,7 @@ public class SessionContextOFImpl implements SessionContext {
     private final AtomicLong xid;
     private final Map<Long, PortGrouping> physicalPorts;
     private final Map<Long, Boolean> portBandwidth;
-    private CompositeObjectRegistration<ModelDrivenSwitch> providerRegistration;
+    private ModelDrivenSwitchRegistration providerRegistration;
     private int seed;
     private ControllerRole roleOnDevice = ControllerRole.OFPCRROLEEQUAL;
 
@@ -212,13 +211,12 @@ public class SessionContextOFImpl implements SessionContext {
     }
 
     @Override
-    public void setProviderRegistration(
-            CompositeObjectRegistration<ModelDrivenSwitch> providerRegistration) {
-                this.providerRegistration = providerRegistration;
+    public void setProviderRegistration(ModelDrivenSwitchRegistration providerRegistration) {
+        this.providerRegistration = providerRegistration;
     }
 
     @Override
-    public CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration() {
+    public ModelDrivenSwitchRegistration getProviderRegistration() {
         return providerRegistration;
     }
 
index e4cb1c0c85afb33e433384a4f49f9385acad6e2b..fa2b8a8177827c6b6f8f089e15bda6cb957cfeb7 100644 (file)
@@ -11,6 +11,8 @@ import com.google.common.base.Optional;
 import java.math.BigInteger;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
+
+import com.google.common.base.Splitter;
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory;
 
 public abstract class InventoryDataServiceUtil {
     public static final  String OF_URI_PREFIX = "openflow:";
+    private static final Splitter COLON_SPLITTER = Splitter.on(":");
     private static final Logger LOG = LoggerFactory.getLogger(InventoryDataServiceUtil.class);
 
     /*
@@ -132,13 +135,14 @@ public abstract class InventoryDataServiceUtil {
     }
 
     public static String portNoStringfromNodeConnectorID(final String ncID) {
-       String[] split = ncID.split(":");
+
+        List<String> splitStringList = COLON_SPLITTER.splitToList(ncID);
 
         // It can happen that token length will be just 1 i.e 2 or CONTROLLER
         // If the length is just one then this cannot be the new MD-SAL style node connector Id which
         // is of the form openflow:1:3.
 
-        return split[split.length - 1];
+        return splitStringList.get(splitStringList.size()-1);
     }
 
     public static Long portNumberfromNodeConnectorId(final OpenflowVersion ofVersion, final String ncId) {
index f335f11ebd1ea38859f3bedbbb3fae55d491bd2d..1189a2befafb5d4b160e255450c985ec67660de8 100644 (file)
@@ -9,10 +9,10 @@ package org.opendaylight.openflowplugin.openflow.md.util;
 
 import com.google.common.base.Function;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.util.concurrent.ExecutionException;
@@ -27,7 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import java.util.Date;
 
 /**
  *
index 1542d5444bacf717e81ed154717b3f9987528975..3fd3e045f0598fd8dacdf1b3e994475d9b9d6718 100644 (file)
@@ -9,24 +9,30 @@
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
 
-import com.google.common.base.MoreObjects;
-import javax.management.ObjectName;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
+import java.util.Collection;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.openflow.statistics.MessageCountDumper;
+import org.opendaylight.openflowplugin.extension.api.ExtensionConverterRegistrator;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
+import org.osgi.framework.BundleContext;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
-*
-*/
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
 public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
 
     private static final Logger LOG = LoggerFactory.getLogger(ConfigurableOpenFlowProviderModule.class);
 
-    private OpenflowPluginProvider pluginProvider;
-
-    private static final boolean SKIP_TABLE_FEATURES = false;
+    private BundleContext bundleContext;
 
     /**
      * @param identifier module identifier
@@ -54,58 +60,84 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
     }
 
     @Override
-    public java.lang.AutoCloseable createInstance() {
-        pluginProvider =  new OpenflowPluginProvider();
-        pluginProvider.setDataBroker(getDataBrokerDependency());
-        pluginProvider.setNotificationService(getNotificationServiceDependency());
-        pluginProvider.setRpcRegistry(getRpcRegistryDependency());
-        pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
-        pluginProvider.setEntityOwnershipService(getOwnershipServiceDependency());
-        pluginProvider.setRole(getRole());
-        pluginProvider.setOpenflowPluginConfig(readConfig());
-        pluginProvider.initialization();
-        return pluginProvider;
+    public AutoCloseable createInstance() {
+        // The service is provided via blueprint so wait for and return it here for backwards compatibility.
+        String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName());
+        final WaitingServiceTracker<OpenflowPluginProvider> tracker = WaitingServiceTracker.create(
+                OpenflowPluginProvider.class, bundleContext, typeFilter);
+        final OpenflowPluginProvider actualService = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        return new OpenflowPluginProvider() {
+            @Override
+            public void close() {
+                // Don't close the actual service as its life cycle is controlled by blueprint.
+                tracker.close();
+            }
+
+            @Override
+            public void initialization() {
+                actualService.initialization();
+            }
+
+            @Override
+            public void setSwitchConnectionProviders(Collection<SwitchConnectionProvider> switchConnectionProvider) {
+                actualService.setSwitchConnectionProviders(switchConnectionProvider);
+            }
+
+            @Override
+            public MessageCountDumper getMessageCountDumper() {
+                return actualService.getMessageCountDumper();
+            }
+
+            @Override
+            public ExtensionConverterRegistrator getExtensionConverterRegistrator() {
+                return actualService.getExtensionConverterRegistrator();
+            }
+
+            @Override
+            public void setRole(OfpRole role) {
+                actualService.setRole(role);
+            }
+
+            @Override
+            public void setSkipTableFeatures(Boolean skipTableFeatures) {
+                actualService.setSkipTableFeatures(skipTableFeatures);
+            }
+
+            @Override
+            public void fireRoleChange(OfpRole newRole) {
+                actualService.fireRoleChange(newRole);
+            }
+
+            @Override
+            public void setDataBroker(DataBroker dataBroker) {
+                actualService.setDataBroker(dataBroker);
+            }
+
+            @Override
+            public void setNotificationService(NotificationProviderService notificationService) {
+                actualService.setNotificationService(notificationService);
+            }
+
+            @Override
+            public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
+                actualService.setRpcRegistry(rpcRegistry);
+            }
+
+            @Override
+            public void setEntityOwnershipService(EntityOwnershipService entityOwnershipService) {
+                actualService.setEntityOwnershipService(entityOwnershipService);
+            }
+        };
     }
 
-    @Override
-    public boolean canReuseInstance(
-            AbstractConfigurableOpenFlowProviderModule oldModule) {
-        // we can reuse if only the role field changed
-        boolean noChangeExceptRole = true;
-        noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                getDataBroker(), dataBrokerJmxAttribute);
-        noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                getNotificationService(), notificationServiceJmxAttribute);
-        noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                getRpcRegistry(), rpcRegistryJmxAttribute);
-
-        for (ObjectName ofSwitchProvider : getOpenflowSwitchConnectionProvider()) {
-            noChangeExceptRole &= dependencyResolver.canReuseDependency(
-                    ofSwitchProvider, openflowSwitchConnectionProviderJmxAttribute);
-        }
-        return noChangeExceptRole;
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
     }
 
     @Override
-    public AutoCloseable reuseInstance(AutoCloseable oldInstance) {
-        OpenflowPluginProvider recycled = (OpenflowPluginProvider) super.reuseInstance(oldInstance);
-        // change role if different
-        recycled.fireRoleChange(MoreObjects.firstNonNull(getRole(), getRole()));
-
-        return recycled;
+    public boolean canReuseInstance(AbstractConfigurableOpenFlowProviderModule oldModule) {
+        return true;
     }
 
-    private OpenflowPluginConfig readConfig(){
-
-        final OpenflowPluginConfig.OpenflowPluginConfigBuilder openflowCfgBuilder = OpenflowPluginConfig.builder();
-
-        if(getSkipTableFeatures()!=null){
-            openflowCfgBuilder.setSkipTableFeatures(getSkipTableFeatures().booleanValue());
-        } else{
-            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
-            openflowCfgBuilder.setSkipTableFeatures(SKIP_TABLE_FEATURES);
-        }
-
-        return openflowCfgBuilder.build();
-    }
 }
index dfa132202d5aa309c13967e47917d412d73bc21f..77f24c93ded99d08a5bc835d8072e529ae10212e 100644 (file)
@@ -9,11 +9,28 @@
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
 
 /**
- * the only purpose of this overwritings is to deliver bundleContext from osgi to module
+ * @deprecated Replaced by blueprint wiring
  */
-public class ConfigurableOpenFlowProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModuleFactory
-{
-    // nothing to override
+@Deprecated
+public class ConfigurableOpenFlowProviderModuleFactory extends AbstractConfigurableOpenFlowProviderModuleFactory {
+    @Override
+    public ConfigurableOpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            ConfigurableOpenFlowProviderModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        ConfigurableOpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public ConfigurableOpenFlowProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            BundleContext bundleContext) {
+        ConfigurableOpenFlowProviderModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }
index 2848c293ca34a812b3a44f9189213a1acc0a3d99..306638f2c1600892163f44af22c5245f720e4826 100644 (file)
@@ -16,5 +16,6 @@ module openflow-provider {
     identity openflow-provider{
         base config:service-type;
         config:java-class "org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider";
+        config:disable-osgi-service-registration;
     }
 }
\ No newline at end of file
index fd13ed0f6e4a250999547a86cf775ee50f236bee..3c21f40734afa74718a6753bfb51541f8baff54e 100644 (file)
@@ -26,6 +26,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
@@ -154,8 +155,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 
 /**
  * simple NPE smoke test
index 367f0a0917be5f2df0da62a7364dbb962cec5e77..120107b547a497acf1392c50d58219ff9b039cf5 100644 (file)
@@ -10,11 +10,9 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.math.BigInteger;
-import java.util.Collections;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -24,16 +22,20 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.AbstractModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessionKeyOF;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContextOFImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
@@ -43,14 +45,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 
 /**
  * Created by Martin Bobak mbobak@cisco.com on 8/26/14.
@@ -90,8 +88,7 @@ public class SalRegistrationManagerTest {
 
     private ModelDrivenSwitch mdSwitchOF13;
 
-    CompositeObjectRegistration<ModelDrivenSwitch> registration;
-
+    ModelDrivenSwitchRegistration registration;
 
     @Before
     public void setUp() {
@@ -107,7 +104,12 @@ public class SalRegistrationManagerTest {
 
        OfEntityManager entManager = new OfEntityManager(entityOwnershipService,getConfig());
         mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
-        registration = new CompositeObjectRegistration<>(mdSwitchOF13, Collections.<Registration>emptyList());
+        registration = new AbstractModelDrivenSwitchRegistration(mdSwitchOF13) {
+            @Override
+            protected void removeRegistration() {
+                // no-op
+            }
+        };
         context.setProviderRegistration(registration);
 
         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
index 383cd9c47b4f6355479023a7cbf94f4ec1fe1f18..6779145b00ffc9d45bdcf98c6be37d60b6b50023 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
@@ -47,7 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;\r
 \r
 /**\r
index ad4bf7eb3a0f981946da2152be11bf6f4c239770..9f0409efb8472e0e5c8df51d0d55763f6f1155bc 100644 (file)
@@ -17,6 +17,7 @@ import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
 import org.opendaylight.openflowplugin.api.OFConstants;\r
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;\r
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;\r
@@ -215,9 +216,8 @@ public class PacketOutConvertorTest {
      */\r
     private static PortNumber getPortNumber(final NodeConnectorKey nConKey,\r
                                             final Short ofVersion) {\r
-        String[] split = nConKey.getId().getValue().split(":");\r
-        Long port = OpenflowPortsUtil.getPortFromLogicalName(\r
-                OpenflowVersion.get(ofVersion), split[split.length - 1]);\r
+        Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(\r
+                OpenflowVersion.get(ofVersion), nConKey.getId());\r
         return new PortNumber(port);\r
     }\r
 \r
index 448fb45ac3d7849739636d116a00a926b0cc42c3..2db23adaaf1c8bc951cd491b1e9cef83d7d37a28 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyList
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
@@ -75,7 +75,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -323,7 +322,7 @@ class MockSessionContext implements SessionContext {
     private Map<SwitchConnectionDistinguisher, ConnectionConductor> map;
     private IMessageDispatchService messageService;
     private boolean isValid = true;
-    private CompositeObjectRegistration<ModelDrivenSwitch> registration;
+    private ModelDrivenSwitchRegistration registration;
     private int seed;
     private SwitchSessionKeyOF sessionKey;
 
@@ -450,13 +449,12 @@ class MockSessionContext implements SessionContext {
     }
 
     @Override
-    public CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration() {
+    public ModelDrivenSwitchRegistration getProviderRegistration() {
         return registration;
     }
 
     @Override
-    public void setProviderRegistration(
-            CompositeObjectRegistration<ModelDrivenSwitch> registration) {
+    public void setProviderRegistration(ModelDrivenSwitchRegistration registration) {
         this.registration = registration;
     }
 
index f49db254ae36615c8155b76475298ddce8903d05..c1ff9bcfb83dd8d2416e344a36a419352bfac1a8 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.session;
 import com.google.common.util.concurrent.Futures;
 import java.math.BigInteger;
 import java.util.Collections;
-import java.util.List;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
index 1737475ab175dd8026bba2de52ded078bca4c2bd..6aff6c3f8324332ce145024bd9145b1a68a0e3b4 100644 (file)
@@ -194,13 +194,10 @@ public class OpenflowPortsUtilTest {
         portNumber = new PortNumberUni(OutputPortValues.FLOOD.toString());
         Assert.assertEquals("FLOOD", OpenflowPortsUtil.portNumberToString(portNumber));
 
-        try {
-            portNumber = new PortNumberUni((String) null);
-            Assert.fail("NPE was expected - due to value type");
-        } catch (Exception e) {
-            // expected
-            Assert.assertEquals(NullPointerException.class, e.getClass());
-        }
+
+        portNumber = new PortNumberUni((String) null);
+        Assert.assertNotNull(portNumber);
+
     }
 
 }
index 55d68f818b8a1bf8d15f87c72aa93cae3cb4d4d0..52abd0da085ef574423c37220d85046f4e0a9b76 100644 (file)
@@ -34,8 +34,8 @@
         <openflowjava.version>0.8.0-SNAPSHOT</openflowjava.version>
         <openflowplugin.version>0.3.0-SNAPSHOT</openflowplugin.version>
         <sal.api.version>0.11.0-SNAPSHOT</sal.api.version>
-        <jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>
-        <salGeneratorPath>src/main/yang-gen-sal</salGeneratorPath>
+        <jmxGeneratorPath>target/generated-sources/config</jmxGeneratorPath>
+        <salGeneratorPath>target/generated-sources/sal</salGeneratorPath>
         <exi.nagasena.version>0000.0002.0053.0</exi.nagasena.version>
         <controller.distribution.version>0.4.0-SNAPSHOT</controller.distribution.version>
 
                                         <ignore/>
                                     </action>
                                 </pluginExecution>
-                                <pluginExecution>
-                                    <pluginExecutionFilter>
-                                        <groupId>org.opendaylight.yangtools</groupId>
-                                        <artifactId>yang-maven-plugin</artifactId>
-                                        <versionRange>[0.5,)</versionRange>
-                                        <goals>
-                                            <goal>generate-sources</goal>
-                                        </goals>
-                                    </pluginExecutionFilter>
-                                    <action>
-                                        <execute/>
-                                    </action>
-                                </pluginExecution>
                                 <pluginExecution>
                                     <pluginExecutionFilter>
                                         <groupId>org.codehaus.groovy.maven</groupId>
diff --git a/pom.xml b/pom.xml
index bfd108b2d85eaf8850f6af41f31bfe5d0d7d0f20..45f69cab60453e7ab4b3ff75bfec562de4fcbf35 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,8 @@
       <module>extension</module>
       <module>distribution/karaf</module>
       <module>openflowplugin-controller-config</module>
+      <module>openflowplugin-blueprint-config-he</module>
+      <module>openflowplugin-blueprint-config</module>
       <!--
       <module>openflowplugin-it</module>
       -->
@@ -39,7 +41,7 @@
       <module>drop-test-karaf</module>
       <module>test-common</module>
       <module>features</module>
-      <module>features-li</module>
+      <module>features-he</module>
       <module>samples/sample-consumer</module>
       <module>samples/learning-switch</module>
       <module>applications</module>
index 3a3e29ff4a3e10f88427aa14dd71e3f49a146c23..6bef0c1926ae316ffc1d8eb103cf8d60df327114 100644 (file)
@@ -13,14 +13,10 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
@@ -77,7 +73,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleContext;
 
 public class OpenflowpluginGroupTestCommandProvider implements CommandProvider {
index 3308b94b2199512327d18ba9d49309f7a99667b3..fb75736a36a0a4ac67ac9005dc97dd05f8771dc8 100644 (file)
@@ -24,8 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -147,13 +147,10 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginGroupTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginGroupTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx
                 .<SalGroupService> addRoutedRpcImplementation(
                         SalGroupService.class, this);
@@ -171,8 +168,12 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
         groupRegistration.registerPath(NodeContext.class, instance);
         RoutedRpcRegistration<SalGroupService> groupRegistration1 = this
                 .getGroupRegistration();
-        builder.add(groupRegistration1);
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                groupRegistration1.close();
+            }
+        };
     }
 
 }
index a560f657c7ee27aa09c92428fb158c94e31e0faf..b4b5438efaf206b7916c92120961529c66557597 100644 (file)
@@ -25,8 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Rem
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -162,12 +162,10 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginMeterTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginMeterTestServiceProvider> builderFor(this);
 
         RoutedRpcRegistration<SalMeterService> addRoutedRpcImplementation = ctx
                 .<SalMeterService> addRoutedRpcImplementation(
@@ -191,9 +189,13 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable,
         RoutedRpcRegistration<SalMeterService> meterRegistration1 = this
                 .getMeterRegistration();
 
-        builder.add(meterRegistration1);
+        return new AbstractObjectRegistration<OpenflowpluginMeterTestServiceProvider>(this) {
 
-        return builder.build();
+            @Override
+            protected void removeRegistration() {
+                meterRegistration1.close();
+            }
+        };
     }
 
 }
index b73ecc76282fb367ec855c05cabe60e47c305a83..f88053808dd32dc4ad769cd28da9a910e7f0e328 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.test;
 
 import java.util.Iterator;
 import java.util.List;
-
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -44,8 +43,6 @@ import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
 
  private static final Logger LOG = LoggerFactory
index 261a29cba84971be666fea8b31dc847cca1acbf3..9a0e554b6c746be8569fe917035ec0540afa0340 100644 (file)
@@ -20,8 +20,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -110,13 +110,10 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginTableFeaturesTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginTableFeaturesTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx
                 .<SalTableService> addRoutedRpcImplementation(
                         SalTableService.class, this);
@@ -139,9 +136,12 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements
         RoutedRpcRegistration<SalTableService> tableRegistration1 = this
                 .getTableRegistration();
 
-        builder.add(tableRegistration1);
-
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                tableRegistration1.close();
+            }
+        };
     }
 
 }
index ec67835b82f8cc184188086fb601c415ed959000..1464509c06d7af4566394f1f4eb83b9b8dcf87e6 100644 (file)
@@ -25,8 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -166,13 +166,10 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx
                 .<SalFlowService> addRoutedRpcImplementation(
                         SalFlowService.class, this);
@@ -194,8 +191,11 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
 
         RoutedRpcRegistration<SalFlowService> flowRegistration2 = getFlowRegistration();
 
-        builder.add(flowRegistration2);
-
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                flowRegistration2.close();
+            }
+        };
     }
 }
diff --git a/test-scripts/.gitignore b/test-scripts/.gitignore
deleted file mode 100644 (file)
index 129a6a7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-*.pyc
-/.pydevproject
-*.log
-.tox/