Merge "Sonar issues"
authorJozef Bacigal <jozef.bacigal@pantheon.tech>
Fri, 5 Aug 2016 08:52:53 +0000 (08:52 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 5 Aug 2016 08:52:53 +0000 (08:52 +0000)
381 files changed:
applications/forwardingrules-sync/pom.xml
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/ForwardingRulesAddCommitter.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/ForwardingRulesRemoveCommitter.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/ForwardingRulesUpdateCommitter.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.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/FlowCapableNodeOdlDao.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/ForwardingRulesSyncProvider.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 [deleted file]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecorator.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/SyncReactorFutureZipDecorator.java
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
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManager.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarder.java [moved from applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarder.java with 97% similarity]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/GroupForwarder.java [moved from applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/GroupForwarder.java with 98% similarity]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/MeterForwarder.java [moved from applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarder.java with 98% similarity]
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/TableForwarder.java [moved from applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarder.java with 97% similarity]
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/FxChainUtil.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/ModificationUtil.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconciliationRegistry.java [moved from applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistry.java with 78% similarity]
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/SwitchFlowId.java [moved from applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/markandsweep/SwitchFlowId.java with 96% similarity]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java [new file with mode: 0644]
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ZipQueueEntry.java [deleted file]
applications/forwardingrules-sync/src/main/resources/org/opendaylight/blueprint/forwardingrules-sync.xml
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/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 [deleted file]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecoratorTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java
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
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManagerTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/FlowForwarderTest.java [moved from applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarderTest.java with 99% similarity]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/GroupForwarderTest.java [moved from applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/GroupForwarderTest.java with 99% similarity]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/MeterForwarderTest.java [moved from applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarderTest.java with 99% similarity]
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/impl/strategy/TableForwarderTest.java [moved from applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarderTest.java with 99% similarity]
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/ReconciliationRegistryTest.java [moved from applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/RetryRegistryTest.java with 60% similarity]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperTest.java
applications/inventory-manager/src/main/java/org/opendaylight/openflowplugin/applications/inventory/manager/FlowCapableInventoryProvider.java
applications/inventory-manager/src/main/java/org/opendaylight/openflowplugin/applications/inventory/manager/NodeChangeCommiter.java
features/src/main/features/features.xml
model/model-flow-base/src/main/yang/opendaylight-match-types.yang
model/model-flow-base/src/main/yang/opendaylight-table-types.yang
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/NodeStaticReplyTranslatorUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartOnTheFlyService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/GroupService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MeterService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallback.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/PacketProcessingServiceImpl.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/SalPortServiceImpl.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/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/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/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/MeterStatsService.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/OpendaylightGroupStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.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/OpendaylightFlowStatisticsServiceDelegateImpl.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/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/QueueDirectStatisticsService.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/util/DeviceInitializationUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/IntegerIpAddress.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchComparatorFactory.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchComparatorHelper.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/SimpleComparator.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/TranslatorLibraryUtil.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.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/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/SalTableServiceImplTest.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/services/AbstractStatsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.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/OpendaylightFlowStatisticsServiceImpl3Test.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImplTest.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/QueueDirectStatisticsServiceTest.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/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/TranslatorLibratyUtilTest.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskFactory.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/ActionConvertor.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerFactory.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorRegistrator.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowStatsResponseConvertor.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/OFApprovedExperimenterIds.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionUtil.java with 52% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertor.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesReplyConvertor.java with 72% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionResponseConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorImpl.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactor.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorMappingFactory.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorImpl.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorV10Impl.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactor.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorMappingFactory.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalCopyTtlInCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalCopyTtlOutCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalDecMplsTtlCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalDecNwTtlCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalGroupCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalOutputActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopMplsCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopPbbCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopVlanCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushMplsCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushPbbCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushVlanCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetFieldCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetMplsTtlCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwTtlCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetQueueCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalStripVlanCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfCopyTtlInCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfCopyTtlOutCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDecMplsTtlCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDecNwTtlCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDropActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfGeneralExtensionGroupingCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfGroupActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfOutputActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopMplsActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopPbbActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopVlanActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopVlanActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushMplsActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushPbbActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushVlanActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlDstActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlDstActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlSrcActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlSrcActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetFieldCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetFieldV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetMplsTtlActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwDstActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwDstActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwSrcActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwSrcActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTosActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTosActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTtlActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetQueueActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpDstActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpDstActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpSrcActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpSrcActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanIdActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanIdActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanPcpActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanPcpActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfStripVlanActionCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfStripVlanActionV10Case.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfVendorCodecCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionResponseConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertReactor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertReactorConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/Convertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorKey.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/InjectionKey.java with 85% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorProcessor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IPProtocols.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java with 93% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/InjectionResultTargetKey.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtil.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtil.java with 99% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/PacketOutConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/VersionConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/VersionDatapathIdConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java with 63% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorUtil.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowInstructionResponseConvertor.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/OFToMDSalFlowConvertor.java with 64% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/ApplyActionsCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/ClearActionsCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/GoToTableCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/MeterCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/WriteActionsCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/WriteMetadataCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/flowflag/FlowFlagConvertor.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagConvertor.java with 64% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/flowflag/FlowFlagReactor.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagReactor.java with 81% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/flowflag/FlowFlagReactorMappingFactory.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagReactorMappingFactory.java with 66% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/flowflag/FlowFlagsConvertorImpl.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagsConvertorImpl.java with 73% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/flowflag/FlowFlagsConvertorV10Impl.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagsConvertorV10Impl.java with 69% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorUtil.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchReactor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchReactorMappingFactory.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpOpCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpShaCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpSpaCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpThaCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpTpaCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthTypeCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalExperimenterIdCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv4CodeCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv4TypeCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv6CodeCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv6TypeCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalInPhyPortCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalInPortCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpDscpCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpEcnCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpProtoCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv4DstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv4SrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6DstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6ExthdrCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6FlabelCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdSllCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdTargetCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdTllCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6SrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMetadataCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsBosCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsLabelCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsTcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPbbIsidCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalSctpDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalSctpSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTcpDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTcpSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIdCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIpv4DstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIpv4SrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalUdpDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalUdpSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalVlanPcpCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalVlanVidCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfArpMatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv4MatchArbitraryBitMaskCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv4MatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchArbitraryBitMaskCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfSctpMatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfTcpMatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfTunnelIpv4MatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfUdpMatchCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/data/MatchResponseConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowRemovedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTableFeaturesToTableUpdatedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/FlowCreatorUtil.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ConnectionConductorImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/MDControllerTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ConcurrentSalRegistrationManagerTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskUtilTest.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/ActionConvertorTest.java [deleted file]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerTest.java [new file with mode: 0644]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConverterTest.java [deleted file]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertorTest2.java with 69% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertorTest.java [new file with mode: 0644]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.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/sal/convertor/PortConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesReplyConvertorTest.java with 94% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertorTest.java [new file with mode: 0644]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertorV10Test.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV10Test.java with 77% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertorV13Test.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV13Test.java with 89% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorTest.java [deleted file]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorTest.java [deleted file]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtilTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtilTest.java with 96% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertorTest.java with 60% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/OFToMDSalFlowConvertorTest.java with 81% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/flowflag/FlowFlagReactorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagReactorTest.java with 80% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl2Test.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10ImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchReactorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java with 86% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplTest.java with 83% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV10Test.java with 83% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionManagerOFImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowRemovedTranslatorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTableFeaturesToTableUpdatedTranslatorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslatorFifthTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslatorFirstTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslatorFourthTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslatorSecondTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslatorThirdTest.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

index 067a462f2ee9dccdbbc66a5a3de49400a003ea3d..02b725fc27beccbc72ad3160ac6c22914aad3ebe 100644 (file)
             <artifactId>model-flow-service</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.opendaylight.openflowplugin</groupId>
-            <artifactId>openflowplugin-common</artifactId>
-        </dependency>
-
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-common</artifactId>
             <artifactId>sal-common-util</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-singleton-common-api</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
index 7b227fd8153423a0e3e65bf8dc0b4c1a52304379..11e399c62e22bb409384f01eeae77f4e32abcabd 100644 (file)
@@ -26,6 +26,7 @@ public interface ForwardingRulesAddCommitter<D extends DataObject, A extends Dat
      * @param identifier - the whole path to new DataObject
      * @param add        - new DataObject
      * @param nodeIdent  - Node InstanceIdentifier
+     * @return RpcResult of action
      */
     Future<RpcResult<A>> add(InstanceIdentifier<D> identifier, D add, InstanceIdentifier<FlowCapableNode> nodeIdent);
 
index f21bf98a39ae2255926a7cbbbcd0dbb682079613..04f6554ad1fc7a8b4c3565c79ad833be5e6278ee 100644 (file)
@@ -26,6 +26,7 @@ public interface ForwardingRulesRemoveCommitter<D extends DataObject, R extends
      * @param identifier - the whole path to DataObject
      * @param del        - DataObject for removing
      * @param nodeIdent  - Node InstanceIdentifier
+     * @return RpcResult of action
      */
     Future<RpcResult<R>> remove(InstanceIdentifier<D> identifier, D del, InstanceIdentifier<FlowCapableNode> nodeIdent);
 
index d1b3eead9ac6f074065f4d932d3781f8b66e41be..3302a28ad62b7a8333d4db18a9bcf95763d97452 100644 (file)
@@ -27,6 +27,7 @@ public interface ForwardingRulesUpdateCommitter<D extends DataObject, U extends
      * @param original   - original DataObject (for update)
      * @param update     - changed DataObject (contain updates)
      * @param nodeIdent  - Node InstanceIdentifier
+     * @return RpcResult of action
      */
     Future<RpcResult<U>> update(InstanceIdentifier<D> identifier, D original, D update,
                                 InstanceIdentifier<FlowCapableNode> nodeIdent);
index f3bc24928f31b93f4188d706568c66ae0c9883fd..05ca0c20f6ee73838a4b4ea454dc26055ad308a6 100644 (file)
@@ -9,11 +9,11 @@
 package org.opendaylight.openflowplugin.applications.frsync;
 
 import java.util.EventListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
  * Unifying listener for data and event changes on node.
  */
-public interface NodeListener<T extends DataObject> extends EventListener, DataTreeChangeListener<T> {
+public interface NodeListener<T extends DataObject> extends EventListener, ClusteredDataTreeChangeListener<T> {
 }
index cf92bbae60840ff5b1111f0c066ef9a23a6084be..d38d7844323b0e370ab6e3186192b35a00e2b769 100644 (file)
@@ -9,7 +9,7 @@
 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.openflowplugin.applications.frsync.util.SyncupEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -19,12 +19,10 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 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
+     * @param syncupEntry configured node + device reflection
      * @return synchronization outcome
+     * @throws InterruptedException
      */
     ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                     final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                     final LogicalDatastoreType dsType) throws InterruptedException;
+                                     final SyncupEntry syncupEntry) throws InterruptedException;
 }
index 73467086f47cfd969836ba3210037ebd44c07a7c..062f1d4299aafe506212b199ef9ea1dfab780a3d 100644 (file)
@@ -47,7 +47,7 @@ public class FlowCapableNodeOdlDao implements FlowCapableNodeDao {
                     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);
+            LOG.error("error reading {} -> {}", nodeId.getValue(), e);
         }
 
         return Optional.absent();
index aaf4063bd0f21a6e609d686404383a90a8a7223f..744b531e1f61317cc3f6cd3aed2de2e053cec919 100644 (file)
@@ -38,7 +38,7 @@ 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.getValue(), threadName());
+                    LOG.debug("syncup return in {} listener for: {} [{}] thread:{}", dsType(), nodeId.getValue(), ret, threadName());
                 }
             } catch (InterruptedException e) {
                 LOG.warn("permit for forwarding rules sync not acquired: {}", nodeId.getValue());
index 0e5ae5e568439bec77f662be6b8920c537ab698e..996f3ef4c06d3a40e81d82fc32d831d8e32474a2 100644 (file)
@@ -14,13 +14,14 @@ import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowplugin.applications.frsync.NodeListener;
 import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
@@ -28,8 +29,10 @@ import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCa
 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.impl.clustering.DeviceMastershipManager;
 import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SyncPlanPushStrategyFlatBatchImpl;
-import org.opendaylight.openflowplugin.applications.frsync.util.RetryRegistry;
+import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.TableForwarder;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
 import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
 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;
@@ -49,6 +52,7 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
     private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesSyncProvider.class);
 
     private final DataBroker dataService;
+    private final ClusterSingletonServiceProvider clusterSingletonService;
     private final SalTableService salTableService;
     private final SalFlatBatchService flatBatchService;
 
@@ -69,9 +73,12 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
 
     public ForwardingRulesSyncProvider(final BindingAwareBroker broker,
                                        final DataBroker dataBroker,
-                                       final RpcConsumerRegistry rpcRegistry) {
-        Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
+                                       final RpcConsumerRegistry rpcRegistry,
+                                       final ClusterSingletonServiceProvider clusterSingletonService) {
+        Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null!");
         this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
+        this.clusterSingletonService = Preconditions.checkNotNull(clusterSingletonService,
+                "ClusterSingletonServiceProvider can not be null!");
         this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
                 "RPC SalTableService not found.");
         this.flatBatchService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
@@ -86,26 +93,28 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
                 .setUncaughtExceptionHandler((thread, e) -> LOG.error("Uncaught exception {}", thread, e))
                 .build());
         syncThreadPool = MoreExecutors.listeningDecorator(executorService);
-
         broker.registerProvider(this);
     }
 
     @Override
-    public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
+    public void onSessionInitiated(final ProviderContext providerContext) {
         final TableForwarder tableForwarder = new TableForwarder(salTableService);
 
         final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
                 .setFlatBatchService(flatBatchService)
                 .setTableForwarder(tableForwarder);
 
-        final RetryRegistry retryRegistry = new RetryRegistry();
+        final ReconciliationRegistry reconciliationRegistry = new ReconciliationRegistry();
+        final DeviceMastershipManager deviceMastershipManager =
+                new DeviceMastershipManager(clusterSingletonService, reconciliationRegistry);
 
         final SyncReactor syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
-        final SyncReactor syncReactorRetry = new SyncReactorRetryDecorator(syncReactorImpl, retryRegistry);
+        final SyncReactor syncReactorRetry = new SyncReactorRetryDecorator(syncReactorImpl, reconciliationRegistry);
         final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorRetry,
-                new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
+                new SemaphoreKeeperGuavaImpl<>(1, true));
+        final SyncReactor syncReactorFutureZip = new SyncReactorFutureZipDecorator(syncReactorGuard, syncThreadPool);
 
-        final SyncReactor reactor = new SyncReactorFutureZipDecorator(syncReactorGuard, syncThreadPool);
+        final SyncReactor reactor = new SyncReactorClusterDecorator(syncReactorFutureZip, deviceMastershipManager);
 
         final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
         final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
@@ -117,7 +126,7 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
         final NodeListener<FlowCapableNode> nodeListenerConfig =
                 new SimplifiedConfigListener(reactor, configSnapshot, operationalDao);
         final NodeListener<Node> nodeListenerOperational =
-                new SimplifiedOperationalRetryListener(reactor, operationalSnapshot, configDao, retryRegistry);
+                new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao, reconciliationRegistry, deviceMastershipManager);
 
         dataTreeConfigChangeListener =
                 dataService.registerDataTreeChangeListener(nodeConfigDataTreePath, nodeListenerConfig);
@@ -140,4 +149,5 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
 
         syncThreadPool.shutdown();
     }
+
 }
index 8cad7e50ed5b1ac36f8b3c32d5b06a1bb043ef3f..f4188e2926aa8767ef6111b6849d1a5cf491011a 100644 (file)
@@ -18,6 +18,7 @@ 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.SyncupEntry;
 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;
@@ -30,19 +31,20 @@ import org.slf4j.LoggerFactory;
 public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapableNode> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedConfigListener.class);
     private final SyncReactor reactor;
-    private final FlowCapableNodeSnapshotDao configSnaphot;
+    private final FlowCapableNodeSnapshotDao configSnapshot;
     private final FlowCapableNodeDao operationalDao;
 
-    public SimplifiedConfigListener(final SyncReactor reactor, FlowCapableNodeSnapshotDao configSnaphot,
-            FlowCapableNodeDao operationalDao) {
+    public SimplifiedConfigListener(final SyncReactor reactor,
+                                    final FlowCapableNodeSnapshotDao configSnapshot,
+                                    final FlowCapableNodeDao operationalDao) {
         this.reactor = reactor;
-        this.configSnaphot = configSnaphot;
+        this.configSnapshot = configSnapshot;
         this.operationalDao = operationalDao;
     }
 
     @Override
     public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNode>> modifications) {
-        LOG.trace("Inventory Config changes {}", modifications.size());
+        LOG.trace("Config changes: {}", modifications.size());
         super.onDataTreeChanged(modifications);
     }
 
@@ -56,8 +58,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
         final InstanceIdentifier<FlowCapableNode> nodePath = modification.getRootPath().getRootIdentifier();
         final NodeId nodeId = PathUtil.digNodeId(nodePath);
 
-        configSnaphot.updateCache(nodeId, Optional.fromNullable(modification.getRootNode().getDataAfter()));
-
+        configSnapshot.updateCache(nodeId, Optional.fromNullable(modification.getRootNode().getDataAfter()));
 
         final Optional<FlowCapableNode> operationalNode = operationalDao.loadByNodeId(nodeId);
         if (!operationalNode.isPresent()) {
@@ -90,12 +91,13 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
      * optimal case (but the switch could be reprogrammed by another person/system.</li>
      * </ul>
      */
-    private ListenableFuture<Boolean> onNodeAdded(InstanceIdentifier<FlowCapableNode> nodePath,
-                           FlowCapableNode dataAfter, FlowCapableNode operationalNode) throws InterruptedException {
+    private ListenableFuture<Boolean> onNodeAdded(final InstanceIdentifier<FlowCapableNode> nodePath,
+                                                  final FlowCapableNode dataAfter,
+                                                  final 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;
+        LOG.trace("onNodeAdded {}", nodeId.getValue());
+        final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), operationalNode, LogicalDatastoreType.OPERATIONAL);
+        return reactor.syncup(nodePath, syncupEntry);
     }
 
     /**
@@ -105,12 +107,13 @@ 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).
      */
-    private ListenableFuture<Boolean> onNodeUpdated(InstanceIdentifier<FlowCapableNode> nodePath,
-                          FlowCapableNode dataBefore, FlowCapableNode dataAfter) throws InterruptedException {
+    private ListenableFuture<Boolean> onNodeUpdated(final InstanceIdentifier<FlowCapableNode> nodePath,
+                                                    final FlowCapableNode dataBefore,
+                                                    final 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;
+        LOG.trace("onNodeUpdated {}", nodeId.getValue());
+        final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), dataBefore, dsType());
+        return reactor.syncup(nodePath, syncupEntry);
     }
 
     /**
@@ -118,16 +121,17 @@ 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
      */
-    private ListenableFuture<Boolean> onNodeDeleted(InstanceIdentifier<FlowCapableNode> nodePath,
-                                                    FlowCapableNode dataBefore) throws InterruptedException {
+    private ListenableFuture<Boolean> onNodeDeleted(final InstanceIdentifier<FlowCapableNode> nodePath,
+                                                    final 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;
+        LOG.trace("onNodeDeleted {}", nodeId.getValue());
+        final SyncupEntry syncupEntry = new SyncupEntry(null, dsType(), dataBefore, dsType());
+        return reactor.syncup(nodePath, syncupEntry);
     }
 
     @Override
     public LogicalDatastoreType dsType() {
         return LogicalDatastoreType.CONFIGURATION;
     }
+
 }
index 738a652e5e0e08741a0f47d37d850223e235f573..eb70f5d4931a61acb897a1799ebabefd6b8063c1 100644 (file)
@@ -10,7 +10,10 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Collection;
+import java.util.Date;
 import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
@@ -19,7 +22,14 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 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.impl.clustering.DeviceMastershipManager;
+import org.opendaylight.openflowplugin.applications.frsync.util.ModificationUtil;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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.node.NodeConnector;
@@ -34,21 +44,29 @@ import org.slf4j.LoggerFactory;
  */
 public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedOperationalListener.class);
+    public static final String DATE_AND_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
 
     private final SyncReactor reactor;
     private final FlowCapableNodeSnapshotDao operationalSnapshot;
     private final FlowCapableNodeDao configDao;
-
-    public SimplifiedOperationalListener(SyncReactor reactor, FlowCapableNodeSnapshotDao operationalSnapshot,
-                                         FlowCapableNodeDao configDao) {
+    private final ReconciliationRegistry reconciliationRegistry;
+    private final DeviceMastershipManager deviceMastershipManager;
+
+    public SimplifiedOperationalListener(final SyncReactor reactor,
+                                         final FlowCapableNodeSnapshotDao operationalSnapshot,
+                                         final FlowCapableNodeDao configDao,
+                                         final ReconciliationRegistry reconciliationRegistry,
+                                         final DeviceMastershipManager deviceMastershipManager) {
         this.reactor = reactor;
         this.operationalSnapshot = operationalSnapshot;
         this.configDao = configDao;
+        this.reconciliationRegistry = reconciliationRegistry;
+        this.deviceMastershipManager = deviceMastershipManager;
     }
 
     @Override
     public void onDataTreeChanged(Collection<DataTreeModification<Node>> modifications) {
-        LOG.trace("Inventory Operational changes {}", modifications.size());
+        LOG.trace("Operational changes: {}", modifications.size());
         super.onDataTreeChanged(modifications);
     }
 
@@ -64,31 +82,38 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
      */
     protected Optional<ListenableFuture<Boolean>> processNodeModification(
             DataTreeModification<Node> modification) throws InterruptedException {
-
+        final NodeId nodeId = ModificationUtil.nodeId(modification);
         updateCache(modification);
-        if (isReconciliationNeeded(modification)) {
+
+        if (isAdd(modification) || isAddLogical(modification)) {
+            deviceMastershipManager.onDeviceConnected(nodeId);
+        }
+
+        if (isRegisteredAndConsistentForReconcile(modification)) {
             return reconciliation(modification);
+        } else {
+            return skipModification(modification);
         }
-        return skipModification(modification);
     }
 
     /**
      * Remove if delete. Update only if FlowCapableNode Augmentation modified.
      *
      * @param modification Datastore modification
-     * @return true for cache update, false for cache remove
      */
-    protected boolean updateCache(DataTreeModification<Node> modification) {
+    private void updateCache(DataTreeModification<Node> modification) {
+        NodeId nodeId = ModificationUtil.nodeId(modification);
         if (isDelete(modification) || isDeleteLogical(modification)) {
-            operationalSnapshot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
-            return false;
+            operationalSnapshot.updateCache(nodeId, Optional.absent());
+            deviceMastershipManager.onDeviceDisconnected(nodeId);
+            return;
         }
-        operationalSnapshot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
-        return true;
+        operationalSnapshot.updateCache(nodeId, Optional.fromNullable(ModificationUtil.flowCapableNodeAfter(modification)));
     }
 
     private Optional<ListenableFuture<Boolean>> skipModification(DataTreeModification<Node> modification) {
-        LOG.trace("Skipping Inventory Operational modification {}, before {}, after {}", nodeIdValue(modification),
+        LOG.trace("Skipping operational modification: {}, before {}, after {}",
+                ModificationUtil.nodeIdValue(modification),
                 modification.getRootNode().getDataBefore() == null ? "null" : "nonnull",
                 modification.getRootNode().getDataAfter() == null ? "null" : "nonnull");
         return Optional.absent();
@@ -99,7 +124,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
      */
     private boolean isDelete(DataTreeModification<Node> modification) {
         if (ModificationType.DELETE == modification.getRootNode().getModificationType()) {
-            LOG.trace("Delete {} (physical)", nodeIdValue(modification));
+            LOG.trace("Delete {} (physical)", ModificationUtil.nodeIdValue(modification));
             return true;
         }
 
@@ -112,7 +137,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
     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));
+            LOG.trace("Delete {} (logical)", ModificationUtil.nodeIdValue(modification));
             return true;
         }
 
@@ -126,7 +151,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
 
         final boolean nodeAppearedInOperational = dataBefore == null && dataAfter != null;
         if (nodeAppearedInOperational) {
-            LOG.trace("Add {} (physical)", nodeIdValue(modification));
+            LOG.trace("Add {} (physical)", ModificationUtil.nodeIdValue(modification));
         }
         return nodeAppearedInOperational;
     }
@@ -137,77 +162,87 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
     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));
+            LOG.trace("Add {} (logical)", ModificationUtil.nodeIdValue(modification));
             return true;
         }
 
         return false;
     }
 
-    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 NodeId nodeId = ModificationUtil.nodeId(modification);
         final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
 
         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()));
+                    .child(Node.class, new NodeKey(ModificationUtil.nodeId(modification)))
+                    .augmentation(FlowCapableNode.class);
+            final FlowCapableNode fcOperationalNode = ModificationUtil.flowCapableNodeAfter(modification);
+            final SyncupEntry syncupEntry = new SyncupEntry(nodeConfiguration.get(), LogicalDatastoreType.CONFIGURATION,
+                                                            fcOperationalNode, dsType());
+            return Optional.of(reactor.syncup(nodePath, syncupEntry));
         } else {
+            LOG.debug("Config not present for reconciliation: {}", nodeId.getValue());
             return skipModification(modification);
         }
     }
 
-    private static FlowCapableNode flowCapableNodeAfter(DataTreeModification<Node> modification) {
-        final Node dataAfter = modification.getRootNode().getDataAfter();
-        if (dataAfter == null) {
-            return null;
-        }
-        return dataAfter.getAugmentation(FlowCapableNode.class);
-    }
+    private boolean isRegisteredAndConsistentForReconcile(DataTreeModification<Node> modification) {
+        final NodeId nodeId = PathUtil.digNodeId(modification.getRootPath().getRootIdentifier());
 
-    private static boolean safeConnectorsEmpty(Node node) {
-        if (node == null) {
-            return true;
+        if (!reconciliationRegistry.isRegistered(nodeId)) {
+            return false;
         }
 
-        final List<NodeConnector> nodeConnectors = node.getNodeConnector();
+        final FlowCapableStatisticsGatheringStatus gatheringStatus = modification.getRootNode().getDataAfter()
+                .getAugmentation(FlowCapableStatisticsGatheringStatus.class);
 
-        return nodeConnectors == null || nodeConnectors.isEmpty();
-    }
+        if (gatheringStatus == null) {
+            LOG.trace("Statistics gathering never started: {}", nodeId.getValue());
+            return false;
+        }
 
-    private static String nodeIdValue(DataTreeModification<Node> modification) {
-        final NodeId nodeId = nodeId(modification);
+        final SnapshotGatheringStatusEnd gatheringStatusEnd = gatheringStatus.getSnapshotGatheringStatusEnd();
 
-        if (nodeId == null) {
-            return null;
+        if (gatheringStatusEnd == null) {
+            LOG.trace("Statistics gathering is not over yet: {}", nodeId.getValue());
+            return false;
         }
 
-        return nodeId.getValue();
-    }
-
-    static NodeId nodeId(DataTreeModification<Node> modification) {
-        final DataObjectModification<Node> rootNode = modification.getRootNode();
-        final Node dataAfter = rootNode.getDataAfter();
+        if (!gatheringStatusEnd.isSucceeded()) {
+            LOG.trace("Statistics gathering was not successful: {}", nodeId.getValue());
+            return false;
+        }
 
-        if (dataAfter != null) {
-            return dataAfter.getId();
+        try {
+            Date timestampOfRegistration = reconciliationRegistry.getRegistrationTimestamp(nodeId);
+            final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
+            Date timestampOfStatistics = simpleDateFormat.parse(gatheringStatusEnd.getEnd().getValue());
+            if (timestampOfStatistics.after(timestampOfRegistration)) {
+                LOG.debug("Fresh operational present: {}", nodeId.getValue());
+                return true;
+            }
+        } catch (ParseException e) {
+            LOG.error("Timestamp parsing error {}", e);
         }
+        LOG.debug("Fresh operational not present: {}", nodeId.getValue());
+        return false;
+    }
 
-        final Node dataBefore = rootNode.getDataBefore();
-        if (dataBefore != null) {
-            return dataBefore.getId();
+    private static boolean safeConnectorsEmpty(Node node) {
+        if (node == null) {
+            return true;
         }
 
-        return null;
+        final List<NodeConnector> nodeConnectors = node.getNodeConnector();
+
+        return nodeConnectors == null || nodeConnectors.isEmpty();
     }
 
     @Override
     public LogicalDatastoreType dsType() {
         return LogicalDatastoreType.OPERATIONAL;
     }
+    
 }
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
deleted file mode 100644 (file)
index 924e26f..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * 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;
-    }
-}
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecorator.java
new file mode 100644 (file)
index 0000000..e508e27
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * 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 org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.impl.clustering.DeviceMastershipManager;
+import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
+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 cluster related issues.
+ */
+public class SyncReactorClusterDecorator implements SyncReactor {
+    private static final Logger LOG = LoggerFactory.getLogger(SyncReactorClusterDecorator.class);
+    private final SyncReactor delegate;
+    private final DeviceMastershipManager deviceMastershipManager;
+
+    public SyncReactorClusterDecorator(final SyncReactor delegate,
+                                       final DeviceMastershipManager deviceMastershipManager) {
+        this.delegate = delegate;
+        this.deviceMastershipManager = deviceMastershipManager;
+    }
+
+    @Override
+    public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
+                                            final SyncupEntry syncupEntry) throws InterruptedException {
+        final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
+        LOG.trace("Syncup cluster decorator: {}", nodeId.getValue());
+
+        if (!deviceMastershipManager.isDeviceMastered(nodeId)) {
+            LOG.debug("Skip syncup since not master for: {}", nodeId.getValue());
+            return Futures.immediateFuture(Boolean.TRUE);
+        } else {
+            return delegate.syncup(flowcapableNodePath, syncupEntry);
+        }
+    }
+}
index f05db11009bb3e718b00e15c9008a893caf3e824..ba3a1d8c59e9d858a8c85b78f70b047ecb9c3226 100644 (file)
@@ -10,12 +10,11 @@ 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.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -38,39 +37,33 @@ public class SyncReactorFutureDecorator implements SyncReactor {
     }
 
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                            final LogicalDatastoreType dsType) throws InterruptedException {
+                                            final SyncupEntry syncupEntry) throws InterruptedException {
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("syncup future {}", nodeId.getValue());
+        LOG.trace("syncup future decorator: {}", nodeId.getValue());
 
-        final ListenableFuture<Boolean> syncup = executorService.submit(new Callable<Boolean>() {
-            public Boolean call() throws Exception {
-                final String oldThreadName = updateThreadName(nodeId);
+        return executorService.submit(() -> {
+            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);
-                }
+            try {
+                final Boolean ret = doSyncupInFuture(flowcapableNodePath, syncupEntry)
+                        .get(10000, TimeUnit.MILLISECONDS);
+                LOG.trace("syncup return in future decorator: {} [{}]", 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 SyncupEntry syncupEntry) throws InterruptedException {
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("doSyncupInFuture future {}", nodeId.getValue());
+        LOG.trace("doSyncupInFuture future decorator: {}", nodeId.getValue());
 
-        return delegate.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+        return delegate.syncup(flowcapableNodePath, syncupEntry);
     }
 
     private String updateThreadName(NodeId nodeId) {
@@ -88,7 +81,7 @@ public class SyncReactorFutureDecorator implements SyncReactor {
         return oldName;
     }
 
-    private String updateThreadName(String name) {
+    private void updateThreadName(String name) {
         final Thread currentThread = Thread.currentThread();
         final String oldName = currentThread.getName();
         try {
@@ -100,6 +93,5 @@ public class SyncReactorFutureDecorator implements SyncReactor {
         } catch (Exception e) {
             LOG.error("failed updating threadName {}", name, e);
         }
-        return oldName;
     }
 }
index a3edde05a884882b7f86eaa5029012346f1af9af..060a04964c02aff5ba2f9a5ca79604e9bc67c87c 100644 (file)
@@ -15,10 +15,9 @@ 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.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -33,7 +32,7 @@ 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 Map<InstanceIdentifier<FlowCapableNode>, SyncupEntry> compressionQueue = new HashMap<>();
     private final Semaphore compressionGuard = new Semaphore(1, false);
 
     public SyncReactorFutureZipDecorator(SyncReactor delegate, ListeningExecutorService executorService) {
@@ -41,17 +40,16 @@ public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
     }
 
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                            final LogicalDatastoreType dsType) throws InterruptedException {
+                                            final SyncupEntry syncupEntry) throws InterruptedException {
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("syncup zip {}", nodeId.getValue());
+        LOG.trace("syncup zip decorator: {}", nodeId.getValue());
 
         try {
             compressionGuard.acquire();
 
-            final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, configTree, operationalTree, dsType);
+            final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, syncupEntry);
             if (newFutureNecessary) {
-                super.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+                super.syncup(flowcapableNodePath, syncupEntry);
             }
             return Futures.immediateFuture(true);
         } finally {
@@ -60,17 +58,15 @@ public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
     }
 
     protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                                         final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                                         final LogicalDatastoreType dsType) throws InterruptedException {
+                                                         final SyncupEntry syncupEntry) throws InterruptedException {
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("doSyncupInFuture zip {}", nodeId.getValue());
+        LOG.trace("doSyncupInFuture zip decorator: {}", nodeId.getValue());
 
-        final ZipQueueEntry lastCompressionState = removeLastCompressionState(flowcapableNodePath);
+        final SyncupEntry lastCompressionState = removeLastCompressionState(flowcapableNodePath);
         if (lastCompressionState == null) {
             return Futures.immediateFuture(true);
         } else {
-            return super.doSyncupInFuture(flowcapableNodePath,
-                    lastCompressionState.getLeft(), lastCompressionState.getRight(), dsType);
+            return super.doSyncupInFuture(flowcapableNodePath, lastCompressionState);
         }
     }
 
@@ -79,30 +75,24 @@ public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
      * 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);
+                                           final SyncupEntry syncupEntry) {
+        final SyncupEntry previousEntry = compressionQueue.get(flowcapableNodePath);
 
-        if (previousEntry != null && dsType == LogicalDatastoreType.CONFIGURATION
-                && previousEntry.getDsType() == LogicalDatastoreType.CONFIGURATION) {
-            putOptimizedConfigDelta(flowcapableNodePath, configTree, previousEntry);
+        if (previousEntry != null && syncupEntry.isOptimizedConfigDelta() && previousEntry.isOptimizedConfigDelta()) {
+            updateOptimizedConfigDelta(flowcapableNodePath, syncupEntry, previousEntry);
         } else {
-            putLatestOperationalDelta(flowcapableNodePath, configTree, operationalTree, dsType);
+            compressionQueue.put(flowcapableNodePath, syncupEntry);
         }
         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 updateOptimizedConfigDelta(InstanceIdentifier<FlowCapableNode> flowcapableNodePath, SyncupEntry actual,
+                                            SyncupEntry previous) {
+        compressionQueue.put(flowcapableNodePath, new SyncupEntry(actual.getAfter(), actual.getDsTypeAfter(),
+                                                                  previous.getBefore(), previous.getDsTypeBefore()));
     }
 
-    private void putLatestOperationalDelta(InstanceIdentifier<FlowCapableNode> flowcapableNodePath, FlowCapableNode configTree,
-                                           FlowCapableNode operationalTree, LogicalDatastoreType dsType) {
-        compressionQueue.put(flowcapableNodePath, new ZipQueueEntry(configTree, operationalTree, dsType));
-    }
-
-    private ZipQueueEntry removeLastCompressionState(
+    private SyncupEntry removeLastCompressionState(
             final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {
         try {
             try {
index e40b3b2200a1eda0fd070ea7553a6f8ba75e5f49..c51f0bb6e0a6df346efe2024a49cb776cfeba5f2 100644 (file)
@@ -15,10 +15,10 @@ 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.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -42,10 +42,9 @@ public class SyncReactorGuardDecorator implements SyncReactor {
     }
 
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                            final LogicalDatastoreType dsType) throws InterruptedException {
+                                            final SyncupEntry syncupEntry) throws InterruptedException {
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("syncup guard {}", nodeId.getValue());
+        LOG.trace("syncup guard decorator: {}", nodeId.getValue());
 
         final long stampBeforeGuard = System.nanoTime();
         final Semaphore guard = summonGuardAndAcquire(flowcapableNodePath);
@@ -62,7 +61,7 @@ public class SyncReactorGuardDecorator implements SyncReactor {
             }
 
             final ListenableFuture<Boolean> endResult =
-                    delegate.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+                    delegate.syncup(flowcapableNodePath, syncupEntry);
 
             Futures.addCallback(endResult, new FutureCallback<Boolean>() {
                 @Override
index 504d583d032f8a02dc029067e20e4cc593265a9f..5eb8860f884ebb35dcb609f414f5e77898bb4d85 100644 (file)
@@ -18,7 +18,6 @@ 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;
@@ -29,6 +28,7 @@ import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
 import org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil;
 import org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -57,11 +57,15 @@ public class SyncReactorImpl implements SyncReactor {
 
     @Override
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                            final LogicalDatastoreType dsType) {
-
+                                            final SyncupEntry syncupEntry) {
         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");
+        FlowCapableNode configTree = syncupEntry.getAfter();
+        FlowCapableNode operationalTree = syncupEntry.getBefore();
+
+        LOG.trace("syncup reactor {} cfg:{} oper:{}",
+                nodeId.getValue(),
+                configTree == null ? "is null" : "non null",
+                operationalTree == null ? "is null" : "non null");
         final SyncCrudCounters counters = new SyncCrudCounters();
 
         /**
@@ -108,7 +112,7 @@ public class SyncReactorImpl implements SyncReactor {
                     final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
                     final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
                     final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
-                    LOG.debug("sync-outcome[{}] (added/updated/removed): flow={}/{}/{}, meter={}/{}/{}, group={}/{}/{}, took={} ms",
+                    LOG.debug("syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, meter={}/{}/{}, group={}/{}/{}, took={} ms",
                             nodeId.getValue(),
                             flowCrudCounts.getAdded(),
                             flowCrudCounts.getUpdated(),
index d504855c9283077bb032c7457b3115e48e7aa84b..9ab76dfe19847b074e9949f694039d78b808005f 100644 (file)
@@ -11,10 +11,10 @@ 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.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -29,38 +29,35 @@ public class SyncReactorRetryDecorator implements SyncReactor {
     private static final Logger LOG = LoggerFactory.getLogger(SyncReactorRetryDecorator.class);
 
     private final SyncReactor delegate;
-    private final RetryRegistry retryRegistry;
+    private final ReconciliationRegistry reconciliationRegistry;
 
-    public SyncReactorRetryDecorator(final SyncReactor delegate, RetryRegistry retryRegistry) {
+    public SyncReactorRetryDecorator(final SyncReactor delegate, final ReconciliationRegistry reconciliationRegistry) {
         this.delegate = delegate;
-        this.retryRegistry = retryRegistry;
+        this.reconciliationRegistry = reconciliationRegistry;
     }
 
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                            final FlowCapableNode configTree, final FlowCapableNode operationalTree,
-                                            final LogicalDatastoreType dsType) throws InterruptedException {
+                                            final SyncupEntry syncupEntry) throws InterruptedException {
 
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("syncup retry {}", nodeId.getValue());
+        LOG.trace("syncup retry decorator: {}", nodeId.getValue());
 
-        if (dsType == LogicalDatastoreType.CONFIGURATION && retryRegistry.isRegistered(nodeId)) {
-            LOG.trace("Config change ignored because device is in retry [{}]", nodeId);
+        if (syncupEntry.isOptimizedConfigDelta() && reconciliationRegistry.isRegistered(nodeId)) {
+            LOG.debug("Config change ignored because {} is in reconcile.", nodeId.getValue());
             return Futures.immediateFuture(Boolean.FALSE);
         }
 
-        ListenableFuture<Boolean> syncupResult = delegate.syncup(flowcapableNodePath, configTree, operationalTree, dsType);
+        ListenableFuture<Boolean> syncupResult = delegate.syncup(flowcapableNodePath,syncupEntry);
 
         return Futures.transform(syncupResult, new Function<Boolean, Boolean>() {
             @Override
             public Boolean apply(Boolean result) {
-                LOG.trace("syncup ret in retry {}", result);
+                LOG.trace("syncup return in retry decorator: {} [{}]", nodeId.getValue(), result);
                 if (result) {
-                    retryRegistry.unregisterIfRegistered(nodeId);
+                    reconciliationRegistry.unregisterIfRegistered(nodeId);
                     return true;
                 } else {
-                    retryRegistry.register(nodeId);
-                    // TODO  elicit statistics gathering if not running actually
-                    // triggerStatisticsGathering(nodeId);
+                    reconciliationRegistry.register(nodeId);
                     return false;
                 }
             }
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastership.java
new file mode 100644 (file)
index 0000000..211b4f4
--- /dev/null
@@ -0,0 +1,71 @@
+/**
+ * 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.clustering;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link ClusterSingletonService} clusterSingletonServiceRegistration per connected device.
+ */
+public class DeviceMastership implements ClusterSingletonService {
+    private static final Logger LOG = LoggerFactory.getLogger(DeviceMastership.class);
+    private final NodeId nodeId;
+    private final ServiceGroupIdentifier identifier;
+    private final ReconciliationRegistry reconciliationRegistry;
+    private ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
+    private boolean deviceMastered;
+
+    public DeviceMastership(final NodeId nodeId, final ReconciliationRegistry reconciliationRegistry) {
+        this.nodeId = nodeId;
+        this.identifier = ServiceGroupIdentifier.create(nodeId.getValue());
+        this.reconciliationRegistry = reconciliationRegistry;
+        this.deviceMastered = false;
+    }
+
+    @Override
+    public void instantiateServiceInstance() {
+        LOG.debug("FRS started for: {}", nodeId.getValue());
+        deviceMastered = true;
+        reconciliationRegistry.register(nodeId);
+    }
+
+    @Override
+    public ListenableFuture<Void> closeServiceInstance() {
+        LOG.debug("FRS stopped for: {}", nodeId.getValue());
+        deviceMastered = false;
+        reconciliationRegistry.unregisterIfRegistered(nodeId);
+        return Futures.immediateFuture(null);
+    }
+
+    @Override
+    public ServiceGroupIdentifier getIdentifier() {
+        return identifier;
+    }
+
+    public boolean isDeviceMastered() {
+        return deviceMastered;
+    }
+
+    public void setClusterSingletonServiceRegistration(final ClusterSingletonServiceRegistration registration) {
+        this.clusterSingletonServiceRegistration = registration;
+    }
+
+    public ClusterSingletonServiceRegistration getClusterSingletonServiceRegistration() {
+        return clusterSingletonServiceRegistration;
+    }
+
+}
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManager.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManager.java
new file mode 100644 (file)
index 0000000..41f736c
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.clustering;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Manager for clustering service registrations of {@link DeviceMastership}.
+ */
+public class DeviceMastershipManager {
+    private static final Logger LOG = LoggerFactory.getLogger(DeviceMastershipManager.class);
+    private final ClusterSingletonServiceProvider clusterSingletonService;
+    private final ConcurrentHashMap<NodeId, DeviceMastership> deviceMasterships = new ConcurrentHashMap();
+    private final ReconciliationRegistry reconciliationRegistry;
+
+    public DeviceMastershipManager(final ClusterSingletonServiceProvider clusterSingletonService,
+                                   final ReconciliationRegistry reconciliationRegistry) {
+        this.clusterSingletonService = clusterSingletonService;
+        this.reconciliationRegistry = reconciliationRegistry;
+    }
+
+    public void onDeviceConnected(final NodeId nodeId) {
+        final DeviceMastership mastership = new DeviceMastership(nodeId, reconciliationRegistry);
+        final ClusterSingletonServiceRegistration registration = clusterSingletonService.registerClusterSingletonService(mastership);
+        mastership.setClusterSingletonServiceRegistration(registration);
+        deviceMasterships.put(nodeId, mastership);
+        LOG.debug("FRS service registered for: {}", nodeId.getValue());
+    }
+
+
+    public void onDeviceDisconnected(final NodeId nodeId) {
+        final DeviceMastership mastership = deviceMasterships.remove(nodeId);
+        final ClusterSingletonServiceRegistration registration = mastership.getClusterSingletonServiceRegistration();
+        if (registration != null) {
+            try {
+                registration.close();
+            } catch (Exception e) {
+                LOG.error("FRS cluster service close fail: {}", nodeId.getValue());
+            }
+        }
+        LOG.debug("FRS service unregistered for: {}", nodeId.getValue());
+    }
+
+    public boolean isDeviceMastered(final NodeId nodeId) {
+        return deviceMasterships.get(nodeId) != null && deviceMasterships.get(nodeId).isDeviceMastered();
+    }
+
+    @VisibleForTesting
+    ConcurrentHashMap<NodeId, DeviceMastership> getDeviceMasterships() {
+        return deviceMasterships;
+    }
+}
@@ -1,12 +1,12 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import com.google.common.base.Preconditions;
 import java.util.concurrent.Future;
@@ -126,7 +126,7 @@ public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutp
         Preconditions.checkNotNull(tableKey, "TableKey can not be null or empty!");
         Preconditions.checkNotNull(flow, "Flow can not be null or empty!");
         if (!tableKey.getId().equals(flow.getTableId())) {
-            LOG.warn("TableID in URI tableId={} and in palyload tableId={} is not same.",
+            LOG.warn("TableID in URI tableId={} and in payload tableId={} is not same.",
                     flow.getTableId(), tableKey.getId());
             return false;
         }
@@ -1,12 +1,12 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
@@ -1,12 +1,12 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
index ed90d2854624002de508eda5556f6ce1b3fca027..70ce219708a1480efdca8f214dd9e51898e689f9 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Map;
 import java.util.concurrent.Future;
 import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
-import org.opendaylight.openflowplugin.applications.frsync.impl.TableForwarder;
 import org.opendaylight.openflowplugin.applications.frsync.util.FxChainUtil;
 import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
@@ -129,13 +128,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         resultVehicle = Futures.transform(resultVehicle, new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
             @Override
             public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                if (!input.isSuccessful()) {
-                    //TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
-                    //final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(
-                    //        Futures.asList Arrays.asList(input, output),
-                    //        ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("TODO"));
-                }
-
                 final List<Batch> batchBag = new ArrayList<>();
                 int batchOrder = 0;
 
@@ -151,7 +143,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
 
                 final ProcessFlatBatchInput flatBatchInput = new ProcessFlatBatchInputBuilder()
                         .setNode(new NodeRef(PathUtil.digNodePath(diffInput.getNodeIdent())))
-                        .setExitOnFirstError(false) // TODO: propagate from input
+                        // TODO: propagate from input
+                        .setExitOnFirstError(false)
                         .setBatch(batchBag)
                         .build();
 
@@ -237,12 +230,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         return batchMap;
     }
 
-    private int getNextBatchLimit(final PeekingIterator<Batch> inputBatchIterator, final int failureIndexLimit) {
-        return inputBatchIterator.hasNext()
-                ? inputBatchIterator.peek().getBatchOrder()
-                : failureIndexLimit;
-    }
-
     @VisibleForTesting
     static int assembleRemoveFlows(final List<Batch> batchBag, int batchOrder, final Map<TableKey, ItemSyncBox<Flow>> flowItemSyncTableMap) {
         // process flow remove
@@ -395,23 +382,21 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
     @VisibleForTesting
     static int assembleRemoveMeters(final List<Batch> batchBag, int batchOrder, final ItemSyncBox<Meter> meterItemSyncBox) {
         // process meter remove
-        if (meterItemSyncBox != null) {
-            if (!meterItemSyncBox.getItemsToPush().isEmpty()) {
-                final List<FlatBatchRemoveMeter> flatBatchRemoveMeterBag =
-                        new ArrayList<>(meterItemSyncBox.getItemsToUpdate().size());
-                int itemOrder = 0;
-                for (Meter meter : meterItemSyncBox.getItemsToPush()) {
-                    flatBatchRemoveMeterBag.add(new FlatBatchRemoveMeterBuilder(meter).setBatchOrder(itemOrder++).build());
-                }
-                final Batch batch = new BatchBuilder()
-                        .setBatchChoice(new FlatBatchRemoveMeterCaseBuilder()
-                                .setFlatBatchRemoveMeter(flatBatchRemoveMeterBag)
-                                .build())
-                        .setBatchOrder(batchOrder)
-                        .build();
-                batchOrder += itemOrder;
-                batchBag.add(batch);
+        if (meterItemSyncBox != null && !meterItemSyncBox.getItemsToPush().isEmpty()) {
+            final List<FlatBatchRemoveMeter> flatBatchRemoveMeterBag =
+                    new ArrayList<>(meterItemSyncBox.getItemsToUpdate().size());
+            int itemOrder = 0;
+            for (Meter meter : meterItemSyncBox.getItemsToPush()) {
+                flatBatchRemoveMeterBag.add(new FlatBatchRemoveMeterBuilder(meter).setBatchOrder(itemOrder++).build());
             }
+            final Batch batch = new BatchBuilder()
+                    .setBatchChoice(new FlatBatchRemoveMeterCaseBuilder()
+                            .setFlatBatchRemoveMeter(flatBatchRemoveMeterBag)
+                            .build())
+                    .setBatchOrder(batchOrder)
+                    .build();
+            batchOrder += itemOrder;
+            batchBag.add(batch);
         }
         return batchOrder;
     }
index 3f4b53efdb850e00fbe6792a3000fc50d54eb415..6d8ca69066e8ae0e1bc80e2ee0ed498d06231340 100644 (file)
@@ -18,10 +18,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
-import org.opendaylight.openflowplugin.applications.frsync.impl.FlowForwarder;
-import org.opendaylight.openflowplugin.applications.frsync.impl.GroupForwarder;
-import org.opendaylight.openflowplugin.applications.frsync.impl.MeterForwarder;
-import org.opendaylight.openflowplugin.applications.frsync.impl.TableForwarder;
 import org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts;
 import org.opendaylight.openflowplugin.applications.frsync.util.FxChainUtil;
 import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
@@ -67,9 +63,9 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
     private static final Logger LOG = LoggerFactory.getLogger(SyncPlanPushStrategyIncrementalImpl.class);
 
     private FlowForwarder flowForwarder;
-    private TableForwarder tableForwarder;
     private MeterForwarder meterForwarder;
     private GroupForwarder groupForwarder;
+    private TableForwarder tableForwarder;
     private FlowCapableTransactionService transactionService;
 
     @Override
@@ -153,9 +149,9 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
 
 
     ListenableFuture<RpcResult<Void>> addMissingFlows(final NodeId nodeId,
-                                                                final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                                                final Map<TableKey, ItemSyncBox<Flow>> flowsInTablesSyncBox,
-                                                                final SyncCrudCounters counters) {
+                                                      final InstanceIdentifier<FlowCapableNode> nodeIdent,
+                                                      final Map<TableKey, ItemSyncBox<Flow>> flowsInTablesSyncBox,
+                                                      final SyncCrudCounters counters) {
         if (flowsInTablesSyncBox.isEmpty()) {
             LOG.trace("no tables in config for node: {} -> SKIPPING", nodeId.getValue());
             return RpcResultBuilder.<Void>success().buildFuture();
@@ -204,22 +200,14 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 Futures.allAsList(allUpdateResults),
                 ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("flow updating"));
 
-        final ListenableFuture<RpcResult<Void>> summaryResult = Futures.transform(
-                Futures.allAsList(singleVoidAddResult, singleVoidUpdateResult),
+        return Futures.transform(Futures.allAsList(singleVoidAddResult, singleVoidUpdateResult),
                 ReconcileUtil.<Void>createRpcResultCondenser("flow add/update"));
-
-        return summaryResult;
-
-        /*
-        return Futures.transform(summaryResult,
-                ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService));
-                */
     }
 
     ListenableFuture<RpcResult<Void>> removeRedundantFlows(final NodeId nodeId,
-                                                                     final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                                                     final Map<TableKey, ItemSyncBox<Flow>> removalPlan,
-                                                                     final SyncCrudCounters counters) {
+                                                           final InstanceIdentifier<FlowCapableNode> nodeIdent,
+                                                           final Map<TableKey, ItemSyncBox<Flow>> removalPlan,
+                                                           final SyncCrudCounters counters) {
         if (removalPlan.isEmpty()) {
             LOG.trace("no tables in operational for node: {} -> SKIPPING", nodeId.getValue());
             return RpcResultBuilder.<Void>success().buildFuture();
@@ -250,9 +238,9 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
     }
 
     ListenableFuture<RpcResult<Void>> removeRedundantMeters(final NodeId nodeId,
-                                                                      final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                                                      final ItemSyncBox<Meter> meterRemovalPlan,
-                                                                      final SyncCrudCounters counters) {
+                                                            final InstanceIdentifier<FlowCapableNode> nodeIdent,
+                                                            final ItemSyncBox<Meter> meterRemovalPlan,
+                                                            final SyncCrudCounters counters) {
         if (meterRemovalPlan.isEmpty()) {
             LOG.trace("no meters on device for node: {} -> SKIPPING", nodeId.getValue());
             return RpcResultBuilder.<Void>success().buildFuture();
@@ -271,14 +259,8 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
             meterCrudCounts.incRemoved();
         }
 
-        final ListenableFuture<RpcResult<Void>> singleVoidResult = Futures.transform(
-                Futures.allAsList(allResults),
+        return Futures.transform(Futures.allAsList(allResults),
                 ReconcileUtil.<RemoveMeterOutput>createRpcResultCondenser("meter remove"));
-        return singleVoidResult;
-        /*
-        return Futures.transform(singleVoidResult,
-                ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService));
-                */
     }
 
     ListenableFuture<RpcResult<Void>> removeRedundantGroups(final NodeId nodeId,
@@ -407,15 +389,14 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 ReconcileUtil.<Void>createRpcResultCondenser("group add/update"));
 
 
-        return Futures.transform(summaryResult,
-                ReconcileUtil.chainBarrierFlush(
-                        PathUtil.digNodePath(nodeIdent), transactionService));
+        return Futures.transform(summaryResult, ReconcileUtil.chainBarrierFlush(
+                PathUtil.digNodePath(nodeIdent), transactionService));
     }
 
     ListenableFuture<RpcResult<Void>> addMissingMeters(final NodeId nodeId,
-                                                                 final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                                                 final ItemSyncBox<Meter> syncBox,
-                                                                 final SyncCrudCounters counters) {
+                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent,
+                                                       final ItemSyncBox<Meter> syncBox,
+                                                       final SyncCrudCounters counters) {
         if (syncBox.isEmpty()) {
             LOG.trace("no meters configured for node: {} -> SKIPPING", nodeId.getValue());
             return RpcResultBuilder.<Void>success().buildFuture();
@@ -451,22 +432,14 @@ public class SyncPlanPushStrategyIncrementalImpl implements SyncPlanPushStrategy
                 Futures.allAsList(allUpdateResults),
                 ReconcileUtil.<UpdateMeterOutput>createRpcResultCondenser("meter update"));
 
-        final ListenableFuture<RpcResult<Void>> summaryResults = Futures.transform(
-                Futures.allAsList(singleVoidUpdateResult, singleVoidAddResult),
+        return Futures.transform(Futures.allAsList(singleVoidUpdateResult, singleVoidAddResult),
                 ReconcileUtil.<Void>createRpcResultCondenser("meter add/update"));
-
-        return summaryResults;
-
-        /*
-        return Futures.transform(summaryResults,
-                ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService));
-                */
     }
 
     ListenableFuture<RpcResult<Void>> addMissingGroups(final NodeId nodeId,
-                                                                 final InstanceIdentifier<FlowCapableNode> nodeIdent,
-                                                                 final List<ItemSyncBox<Group>> groupsAddPlan,
-                                                                 final SyncCrudCounters counters) {
+                                                       final InstanceIdentifier<FlowCapableNode> nodeIdent,
+                                                       final List<ItemSyncBox<Group>> groupsAddPlan,
+                                                       final SyncCrudCounters counters) {
         if (groupsAddPlan.isEmpty()) {
             LOG.trace("no groups configured for node: {} -> SKIPPING", nodeId.getValue());
             return RpcResultBuilder.<Void>success().buildFuture();
@@ -1,12 +1,12 @@
-/**
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.util.Collections;
 import java.util.concurrent.Future;
index 52d0623d00d7a35ce044ce464525bdd7ee768b37..cd92bb083e3f6771e32fe6fc84edb0ac68c6f62a 100644 (file)
@@ -14,7 +14,6 @@ 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.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
index 7eddebb01eb6cc566debf741015b5170aaa66ca8..903dd207f018b2de94fcf6e503d7927d7b464648 100644 (file)
@@ -40,13 +40,13 @@ public class FxChainUtil {
                         LOG.debug(prefix + " failed: {} -> {}", nodeId.getValue(), Arrays.toString(errors.toArray()));
                     }
                 } else {
-                    LOG.debug(prefix + "reconciliation failed: {} -> null result", nodeId.getValue());
+                    LOG.debug(prefix + " reconciliation failed: {} -> null result", nodeId.getValue());
                 }
             }
 
             @Override
             public void onFailure(final Throwable t) {
-                LOG.debug(prefix + "reconciliation failed seriously: {}", nodeId.getValue(), t);
+                LOG.debug(prefix + " reconciliation failed seriously: {}", nodeId.getValue(), t);
             }
         };
     }
index 1e9b49ea9ae1d1b70ea53cab3e63f0d7b37d6c2f..5067a13523e0f81c10f52f3ae5155f5c8658cc88 100644 (file)
@@ -17,8 +17,8 @@ import java.util.Set;
  */
 public class ItemSyncBox<I> {
 
-    private Set<I> itemsToPush = new LinkedHashSet<>();
-    private Set<ItemUpdateTuple<I>> itemsToUpdate = new LinkedHashSet<>();
+    private final Set<I> itemsToPush = new LinkedHashSet<>();
+    private final Set<ItemUpdateTuple<I>> itemsToUpdate = new LinkedHashSet<>();
 
     public Set<I> getItemsToPush() {
         return itemsToPush;
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java
new file mode 100644 (file)
index 0000000..1df1f7c
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * 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.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+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.Node;
+
+/**
+ * Basic {@link DataTreeModification} related tools.
+ */
+public class ModificationUtil {
+    public static String nodeIdValue(DataTreeModification<Node> modification) {
+        final NodeId nodeId = nodeId(modification);
+
+        if (nodeId == null) {
+            return null;
+        }
+
+        return nodeId.getValue();
+    }
+
+    public static NodeId nodeId(DataTreeModification<Node> modification) {
+        final DataObjectModification<Node> rootNode = modification.getRootNode();
+        final Node dataAfter = rootNode.getDataAfter();
+
+        if (dataAfter != null) {
+            return dataAfter.getId();
+        }
+
+        final Node dataBefore = rootNode.getDataBefore();
+        if (dataBefore != null) {
+            return dataBefore.getId();
+        }
+
+        return null;
+    }
+
+    public static FlowCapableNode flowCapableNodeAfter(DataTreeModification<Node> modification) {
+        final Node dataAfter = modification.getRootNode().getDataAfter();
+        if (dataAfter == null) {
+            return null;
+        }
+        return dataAfter.getAugmentation(FlowCapableNode.class);
+    }
+}
index e339ccdd4a7f181077a8e25bdf8dde17e7d9c753..79fd17a69774be0ca6c2587ab4009fcfd2fa83b7 100644 (file)
@@ -8,14 +8,12 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.util;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.JdkFutureAdapters;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -26,7 +24,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import javax.annotation.Nullable;
-import org.opendaylight.openflowplugin.applications.frsync.markandsweep.SwitchFlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
 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;
@@ -129,14 +126,11 @@ public class ReconcileUtil {
     public static AsyncFunction<RpcResult<Void>, RpcResult<Void>> chainBarrierFlush(
             final InstanceIdentifier<Node> nodeIdent,
             final FlowCapableTransactionService flowCapableTransactionService) {
-        return new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RpcResult<Void> input) throws Exception {
-                final SendBarrierInput barrierInput = new SendBarrierInputBuilder()
-                        .setNode(new NodeRef(nodeIdent))
-                        .build();
-                return JdkFutureAdapters.listenInPoolThread(flowCapableTransactionService.sendBarrier(barrierInput));
-            }
+        return input -> {
+            final SendBarrierInput barrierInput = new SendBarrierInputBuilder()
+                    .setNode(new NodeRef(nodeIdent))
+                    .build();
+            return JdkFutureAdapters.listenInPoolThread(flowCapableTransactionService.sendBarrier(barrierInput));
         };
     }
 
@@ -262,7 +256,7 @@ public class ReconcileUtil {
                                                        final Map<MeterId, Meter> meterOperationalMap,
                                                        final List<Meter> metersConfigured,
                                                        final boolean gatherUpdates) {
-        LOG.trace("resolving meters for {}", nodeId);
+        LOG.trace("resolving meters for {}", nodeId.getValue());
         final ItemSyncBox<Meter> syncBox = new ItemSyncBox<>();
         for (Meter meter : metersConfigured) {
             final Meter existingMeter = meterOperationalMap.get(meter.getMeterId());
@@ -284,8 +278,7 @@ public class ReconcileUtil {
      * @param gatherUpdates      check content of pending item if present on device (and create update task eventually)
      * @return list of safe synchronization steps
      */
-    @VisibleForTesting
-    static ItemSyncBox<Flow> resolveFlowDiffsInTable(final List<Flow> flowsConfigured,
+    public static ItemSyncBox<Flow> resolveFlowDiffsInTable(final List<Flow> flowsConfigured,
                                                      final Map<SwitchFlowId, Flow> flowOperationalMap,
                                                      final boolean gatherUpdates) {
         final ItemSyncBox<Flow> flowsSyncBox = new ItemSyncBox<>();
@@ -316,7 +309,7 @@ public class ReconcileUtil {
                                                                                final Map<Short, Table> tableOperationalMap,
                                                                                final List<Table> tablesConfigured,
                                                                                final boolean gatherUpdates) {
-        LOG.trace("resolving flows in tables for {}", nodeId);
+        LOG.trace("resolving flows in tables for {}", nodeId.getValue());
         final Map<TableKey, ItemSyncBox<Flow>> tableFlowSyncBoxes = new HashMap<>();
         for (final Table tableConfigured : tablesConfigured) {
             final List<Flow> flowsConfigured = tableConfigured.getFlow();
@@ -16,20 +16,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Holder of registration request for fresh operational.
+ * Holder of registration request for reconciliation (fresh operational).
  */
-public class RetryRegistry {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RetryRegistry.class);
+public class ReconciliationRegistry {
+    private static final Logger LOG = LoggerFactory.getLogger(ReconciliationRegistry.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());
-        }
+        LOG.debug("Registered for next consistent operational: {}", nodeId.getValue());
+        // TODO  elicit statistics gathering if not running actually
         return timestamp;
     }
 
@@ -45,7 +42,7 @@ public class RetryRegistry {
         return registration.get(nodeId) != null;
     }
 
-    public Date getRegistration(NodeId nodeId) {
+    public Date getRegistrationTimestamp(NodeId nodeId) {
         return registration.get(nodeId);
     }
 
index 419525a1326b97c4d2e008bb47d3fa8faf1df534..240905bdf28929a5b9083bfd6a5d827487660f67 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
  */
 public class SemaphoreKeeperGuavaImpl<K> implements SemaphoreKeeper<K> {
 
-    private LoadingCache<K, Semaphore> semaphoreCache;
+    private final LoadingCache<K, Semaphore> semaphoreCache;
 
     public SemaphoreKeeperGuavaImpl(final int permits, final boolean fair) {
         semaphoreCache = CacheBuilder.newBuilder()
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.applications.frsync.markandsweep;
+package org.opendaylight.openflowplugin.applications.frsync.util;
 
 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;
diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java
new file mode 100644 (file)
index 0000000..151724c
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * 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.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+
+/**
+ * Data entry of before and after data for syncup in {@link org.opendaylight.openflowplugin.applications.frsync.SyncReactor}.
+ */
+public class SyncupEntry {
+    private final FlowCapableNode after;
+    private final LogicalDatastoreType dsTypeAfter;
+    private final FlowCapableNode before;
+    private final LogicalDatastoreType dsTypeBefore;
+
+    public SyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
+                       final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
+        this.after = after;
+        this.dsTypeAfter = dsTypeAfter;
+        this.before = before;
+        this.dsTypeBefore = dsTypeBefore;
+    }
+
+    public FlowCapableNode getAfter() {
+        return after;
+    }
+
+    public FlowCapableNode getBefore() {
+        return before;
+    }
+
+    public LogicalDatastoreType getDsTypeAfter() {
+        return dsTypeAfter;
+    }
+
+    public LogicalDatastoreType getDsTypeBefore() {
+        return dsTypeBefore;
+    }
+
+    public boolean isOptimizedConfigDelta() {
+        return dsTypeAfter == LogicalDatastoreType.CONFIGURATION && dsTypeBefore == LogicalDatastoreType.CONFIGURATION;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        SyncupEntry that = (SyncupEntry) o;
+
+        if (after != null ? !after.equals(that.after) : that.after != null) {
+            return false;
+        }
+        if (dsTypeAfter != that.dsTypeAfter) {
+            return false;
+        }
+        if (before != null ? !before.equals(that.before) : that.before != null) {
+            return false;
+        }
+        return dsTypeBefore == that.dsTypeBefore;
+    }
+
+}
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
deleted file mode 100644 (file)
index ec4d8a8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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 c60e9600e736638782cea112a49c5651e5506602..e1f24449239d298a1f222537faa40fbfe5317d58 100644 (file)
            odl:use-default-for-reference-types="true">
 
     <reference id="broker" interface="org.opendaylight.controller.sal.binding.api.BindingAwareBroker"/>
-    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+    <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="clusterSingletonService" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
 
     <bean id="frSync" class="org.opendaylight.openflowplugin.applications.frsync.impl.ForwardingRulesSyncProvider"
           destroy-method="close">
         <argument ref="broker"/>
         <argument ref="dataBroker"/>
         <argument ref="rpcRegistry"/>
+        <argument ref="clusterSingletonService"/>
     </bean>
 
 </blueprint>
\ No newline at end of file
index 76fb1fad803b57f91e90879625058f6bb523502f..b795b2f728b73f8059ec48a185f2a90e14c6397a 100644 (file)
@@ -20,7 +20,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 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.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 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.table.service.rev131026.SalTableService;
@@ -40,7 +42,9 @@ public class ForwardingRulesSyncProviderTest {
     @Mock
     private BindingAwareBroker broker;
     @Mock
-    private BindingAwareBroker.ProviderContext providerContext;
+    private ProviderContext providerContext;
+    @Mock
+    private ClusterSingletonServiceProvider clusterSingletonService;
 
     @Before
     public void setUp() throws Exception {
@@ -53,7 +57,7 @@ public class ForwardingRulesSyncProviderTest {
                     }
                 });
 
-        provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry);
+        provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry, clusterSingletonService);
         Mockito.verify(rpcRegistry).getRpcService(SalTableService.class);
         Mockito.verify(rpcRegistry).getRpcService(SalFlatBatchService.class);
         Mockito.verify(broker).registerProvider(provider);
index 4c20088ded8fa1897bc91bf5c00357c90e348e02..888f31776109fed27b87a1b78235cf6107b371f9 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCa
 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.SyncupEntry;
 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;
@@ -46,7 +47,8 @@ public class SimplifiedConfigListenerTest {
     private static final NodeId NODE_ID = new NodeId("testNode");
     private InstanceIdentifier<FlowCapableNode> fcNodePath;
     private SimplifiedConfigListener nodeListenerConfig;
-    private LogicalDatastoreType dsType = LogicalDatastoreType.CONFIGURATION;
+    private final LogicalDatastoreType confgDS = LogicalDatastoreType.CONFIGURATION;
+    private final LogicalDatastoreType operationalDS = LogicalDatastoreType.OPERATIONAL;
 
     @Mock
     private SyncReactor reactor;
@@ -79,8 +81,6 @@ public class SimplifiedConfigListenerTest {
         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
@@ -89,41 +89,40 @@ public class SimplifiedConfigListenerTest {
     }
 
     @Test
-    public void testOnDataTreeChangedSyncupAdd() throws InterruptedException {
-        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
-                .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
+    public void testOnDataTreeChangedAdd() throws InterruptedException {
+        Mockito.when(configModification.getDataBefore()).thenReturn(null);
         Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
+        final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, operationalDS);
 
         nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, dataAfter, dataBefore, dsType);
+        Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
         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)));
+    public void testOnDataTreeChangedUpdate() throws InterruptedException {
         Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
         Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
+        final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, confgDS);
 
         nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, dataAfter, dataBefore, dsType);
+        Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
         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)));
+    public void testOnDataTreeChangedDelete() throws InterruptedException {
         Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
+        Mockito.when(configModification.getDataAfter()).thenReturn(null);
+        final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(null, confgDS, dataBefore, confgDS);
 
         nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, null, dataBefore, dsType);
+        Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
         Mockito.verifyNoMoreInteractions(reactor);
         Mockito.verify(roTx).close();
     }
@@ -138,4 +137,15 @@ public class SimplifiedConfigListenerTest {
         Mockito.verifyZeroInteractions(reactor);
         Mockito.verify(roTx).close();
     }
+
+    private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
+                                                               final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) throws InterruptedException {
+        Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
+        final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry)))
+                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        return syncupEntry;
+    }
+
 }
\ No newline at end of file
index bd106a81cc94ecb6aaf2c02ba9ffabbc662ac9c9..4eb2e5b9685e7c6fc6d33c789f717af64a2fdebe 100644 (file)
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+/**
+ * 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,
@@ -10,6 +10,8 @@ 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 java.util.List;
 import org.junit.Assert;
@@ -32,7 +34,13 @@ import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCa
 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.impl.clustering.DeviceMastershipManager;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.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.node.NodeConnector;
@@ -49,7 +57,9 @@ public class SimplifiedOperationalListenerTest {
     private static final NodeId NODE_ID = new NodeId("testNode");
     private InstanceIdentifier<FlowCapableNode> fcNodePath;
     private SimplifiedOperationalListener nodeListenerOperational;
-    private final LogicalDatastoreType dsType = LogicalDatastoreType.OPERATIONAL;
+    private final LogicalDatastoreType configDS = LogicalDatastoreType.CONFIGURATION;
+    private final LogicalDatastoreType operationalDS = LogicalDatastoreType.OPERATIONAL;
+    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(SimplifiedOperationalListener.DATE_AND_TIME_FORMAT);
 
     @Mock
     private SyncReactor reactor;
@@ -65,6 +75,14 @@ public class SimplifiedOperationalListenerTest {
     private Node operationalNode;
     @Mock
     private FlowCapableNode fcOperationalNode;
+    @Mock
+    private FlowCapableStatisticsGatheringStatus statisticsGatheringStatus;
+    @Mock
+    private SnapshotGatheringStatusEnd snapshotGatheringStatusEnd;
+    @Mock
+    private ReconciliationRegistry reconciliationRegistry;
+    @Mock
+    private DeviceMastershipManager deviceMastershipManager;
 
     @Before
     public void setUp() throws Exception {
@@ -74,7 +92,7 @@ public class SimplifiedOperationalListenerTest {
         final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
                 new FlowCapableNodeOdlDao(db, LogicalDatastoreType.CONFIGURATION));
 
-        nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao);
+        nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnapshot, configDao, reconciliationRegistry, deviceMastershipManager);
         InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
 
@@ -94,51 +112,165 @@ public class SimplifiedOperationalListenerTest {
     }
 
     @Test
-    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);
+    public void testOnDataTreeChangeAddSyncup() throws Exception {
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalAdd();
+        prepareFreshOperational(true);
+        final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, configNode, fcOperationalNode, dsType);
-        Mockito.verifyNoMoreInteractions(reactor);
+        Mockito.verify(deviceMastershipManager).onDeviceConnected(NODE_ID);
+        Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
         Mockito.verify(roTx).close();
     }
 
     @Test
-    public void testOnDataTreeChangedAddSkip() {
+    public void testOnDataTreeChangedAddSkip() throws Exception {
         // Related to bug 5920 -> https://bugs.opendaylight.org/show_bug.cgi?id=5920
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalAdd();
+        prepareFreshOperational(true);
+
         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(deviceMastershipManager).onDeviceConnected(NODE_ID);
         Mockito.verifyZeroInteractions(reactor);
         Mockito.verify(roTx).close();
     }
 
     @Test
-    public void testOnDataTreeChangedSyncupDeletePhysical() {
+    public void testOnDataTreeChangedDeletePhysical() throws Exception {
         Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(null);
         Mockito.when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.DELETE);
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(false);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
+        Mockito.verify(deviceMastershipManager).onDeviceDisconnected(NODE_ID);
         Mockito.verifyZeroInteractions(reactor);
     }
 
     @Test
-    public void testOnDataTreeChangedSyncupDeleteLogical() {
+    public void testOnDataTreeChangedDeleteLogical() {
         Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
         List<NodeConnector> nodeConnectorList = Mockito.mock(List.class);
         Mockito.when(operationalNode.getNodeConnector()).thenReturn(nodeConnectorList);
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(false);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(deviceMastershipManager).onDeviceDisconnected(NODE_ID);
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedReconcileNotRegistered() {
+        operationalUpdate();
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(false);
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
         Mockito.verifyZeroInteractions(reactor);
     }
+
+    @Test
+    public void testOnDataTreeChangedReconcileButStaticsGatheringNotStarted() {
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalUpdate();
+        Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(null);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedReconcileButStaticsGatheringNotFinished() {
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalUpdate();
+        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 testOnDataTreeChangedReconcileButStaticsGatheringNotSuccessful() {
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalUpdate();
+        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 testOnDataTreeChangedReconcileAndFreshOperationalNotPresent() throws ParseException {
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalUpdate();
+        prepareFreshOperational(false);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verifyZeroInteractions(reactor);
+    }
+
+    @Test
+    public void testOnDataTreeChangedReconcileAndFreshOperationalPresent() throws Exception {
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        operationalUpdate();
+        prepareFreshOperational(true);
+        final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
+
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+        Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
+        Mockito.verify(roTx).close();
+    }
+
+    private void prepareFreshOperational(final boolean afterRegistration) throws ParseException {
+        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(Mockito.mock(DateAndTime.class));
+        final String timestampBefore = "0000-12-12T01:01:01.000-07:00";
+        final String timestampAfter = "9999-12-12T01:01:01.000-07:00";
+        if (afterRegistration) {
+            Mockito.when(snapshotGatheringStatusEnd.getEnd().getValue()).thenReturn(timestampAfter);
+            Mockito.when(reconciliationRegistry.getRegistrationTimestamp(NODE_ID)).thenReturn(simpleDateFormat.parse(timestampBefore));
+        } else {
+            Mockito.when(snapshotGatheringStatusEnd.getEnd().getValue()).thenReturn(timestampBefore);
+            Mockito.when(reconciliationRegistry.getRegistrationTimestamp(NODE_ID)).thenReturn(simpleDateFormat.parse(timestampAfter));
+        }
+    }
+
+    private void operationalAdd() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(null);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+    }
+
+    private void operationalUpdate() {
+        Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
+    }
+
+    private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
+                                                          final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) throws InterruptedException {
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
+        final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry)))
+                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        return syncupEntry;
+    }
 }
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
deleted file mode 100644 (file)
index a2e6cc5..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
- * 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.rev130715.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);
-    }
-
-}
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorClusterDecoratorTest.java
new file mode 100644 (file)
index 0000000..3330dd4
--- /dev/null
@@ -0,0 +1,71 @@
+/**
+ * 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 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.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.impl.clustering.DeviceMastershipManager;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
+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 SyncReactorClusterDecorator}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SyncReactorClusterDecoratorTest {
+
+    private static final NodeId NODE_ID = new NodeId("test-node");
+    private SyncReactorClusterDecorator reactor;
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+
+    @Mock
+    private SyncReactor delegate;
+    @Mock
+    private DeviceMastershipManager deviceMastershipManager;
+    @Mock
+    private SyncupEntry syncupEntry;
+
+    @Before
+    public void setUp() {
+        reactor = new SyncReactorClusterDecorator(delegate, deviceMastershipManager);
+
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+    }
+
+    @Test
+    public void testSyncupMaster() throws InterruptedException {
+        Mockito.when(deviceMastershipManager.isDeviceMastered(NODE_ID)).thenReturn(true);
+
+        reactor.syncup(fcNodePath, syncupEntry);
+
+        Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
+        Mockito.verifyNoMoreInteractions(delegate);
+    }
+
+    @Test
+    public void testSyncupSlave() throws InterruptedException {
+        Mockito.when(deviceMastershipManager.isDeviceMastered(NODE_ID)).thenReturn(false);
+
+        reactor.syncup(fcNodePath, syncupEntry);
+
+        Mockito.verifyZeroInteractions(delegate);
+    }
+
+}
\ No newline at end of file
index 6a059bc1da7caaee7b6e693f82ef6b29510bf9e3..9180e62b87e06813a6a25c5d923526ae3537f463 100644 (file)
@@ -31,6 +31,8 @@ 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.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -51,9 +53,13 @@ public class SyncReactorFutureZipDecoratorTest {
     private SyncReactorFutureZipDecorator reactor;
     private InstanceIdentifier<FlowCapableNode> fcNodePath;
     private ListeningExecutorService syncThreadPool;
+    private final LogicalDatastoreType configDS = LogicalDatastoreType.CONFIGURATION;
+    private final LogicalDatastoreType operationalDS = LogicalDatastoreType.OPERATIONAL;
 
     @Mock
-    private SyncReactorGuardDecorator delegate;
+    private SyncReactor delegate;
+    @Mock
+    private SyncupEntry syncupEntry;
 
     @Before
     public void setUp() {
@@ -75,10 +81,16 @@ public class SyncReactorFutureZipDecoratorTest {
         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>>() {
+        final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, configDS);
+        final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
+        final SyncupEntry third = new SyncupEntry(null, configDS, dataAfter, configDS);
+        final SyncupEntry fourth = new SyncupEntry(dataAfter2, configDS, null, configDS);
+        final SyncupEntry zipped = new SyncupEntry(dataAfter2, configDS, dataBefore, configDS);
+        final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
+
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
+                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
                     @Override
                     public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
                         LOG.info("unlocking next configs");
@@ -87,15 +99,17 @@ public class SyncReactorFutureZipDecoratorTest {
                         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));
+        allResults.add(reactor.syncup(fcNodePath, first));
         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));
+        mockSyncupWithEntry(second);
+        allResults.add(reactor.syncup(fcNodePath, second));
+        mockSyncupWithEntry(third);
+        allResults.add(reactor.syncup(fcNodePath, third));
+        mockSyncupWithEntry(fourth);
+        allResults.add(reactor.syncup(fcNodePath, fourth));
         latchForFirst.countDown();
 
         Futures.allAsList(allResults).get(1, TimeUnit.SECONDS);
@@ -108,8 +122,8 @@ public class SyncReactorFutureZipDecoratorTest {
             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.verify(delegate).syncup(fcNodePath, first);
+        inOrder.verify(delegate).syncup(fcNodePath, zipped);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -118,21 +132,24 @@ public class SyncReactorFutureZipDecoratorTest {
         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>>() {
+        final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, configDS);
+        final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
+
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
+                .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);
+        reactor.syncup(fcNodePath, first);
         latchForNext.await();
-        reactor.syncup(fcNodePath, dataAfter, dataBefore, dsType);
+        mockSyncupWithEntry(second);
+        reactor.syncup(fcNodePath, second);
 
         boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
         if (!terminated) {
@@ -140,10 +157,9 @@ public class SyncReactorFutureZipDecoratorTest {
             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.verify(delegate).syncup(fcNodePath, first);
+        inOrder.verify(delegate).syncup(fcNodePath, second);
         inOrder.verifyNoMoreInteractions();
-
     }
 
     @Test
@@ -155,8 +171,11 @@ public class SyncReactorFutureZipDecoratorTest {
         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>>() {
+        final SyncupEntry first = new SyncupEntry(configAfter, configDS, configBefore, configDS);
+        final SyncupEntry second = new SyncupEntry(configActual, configDS, freshOperational, operationalDS);
+
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
+                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
             @Override
             public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
                 LOG.info("unlocking for fresh operational");
@@ -165,12 +184,13 @@ public class SyncReactorFutureZipDecoratorTest {
                 LOG.info("unlocking first delegate");
                 return Futures.immediateFuture(Boolean.TRUE);
             }
-        }).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        });
 
-        reactor.syncup(fcNodePath, configAfter, configBefore, LogicalDatastoreType.CONFIGURATION);
+        reactor.syncup(fcNodePath, first);
         latchForNext.await();
 
-        reactor.syncup(fcNodePath, configActual, freshOperational, LogicalDatastoreType.OPERATIONAL);
+        mockSyncupWithEntry(second);
+        reactor.syncup(fcNodePath, second);
         latchForFirst.countDown();
 
         syncThreadPool.shutdown();
@@ -179,7 +199,12 @@ public class SyncReactorFutureZipDecoratorTest {
             LOG.info("thread pool not terminated.");
             syncThreadPool.shutdownNow();
         }
-        Mockito.verify(delegate, Mockito.times(1)).syncup(fcNodePath, configActual, freshOperational, LogicalDatastoreType.OPERATIONAL);
+        Mockito.verify(delegate, Mockito.times(1)).syncup(fcNodePath, second);
+    }
+
+    private void mockSyncupWithEntry(final SyncupEntry entry) throws InterruptedException {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(entry)))
+                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
     }
 
     @After
index d10a228bb7c94c0fa831a19b624807d2c19a9b52..5b43181d65d6bdedc117abcc9713ecb2d763728e 100644 (file)
@@ -16,8 +16,9 @@ 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.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -34,14 +35,15 @@ 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;
+    private SyncReactor delegate;
     @Mock
     private FlowCapableNode fcConfigNode;
     @Mock
     private FlowCapableNode fcOperationalNode;
+    @Mock
+    private SyncupEntry syncupEntry;
 
     @Before
     public void setUp() throws Exception {
@@ -57,23 +59,23 @@ public class SyncReactorGuardDecoratorTest {
 
     @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));
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
+                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
 
-        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        reactor.syncup(fcNodePath, syncupEntry);
 
-        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
         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()));
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
+                .thenReturn(Futures.immediateFailedFuture(new Exception()));
 
-        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        reactor.syncup(fcNodePath, syncupEntry);
 
-        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
         Mockito.verifyNoMoreInteractions(delegate);
 
     }
index 588a4019369bafdfb9983a4df32ecb11fb5d820d..5e6112ee12473aa686eba3d81fde8e7b6f2aeeab 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
 import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput;
 import org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil;
 import org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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.meters.Meter;
@@ -101,13 +102,16 @@ public class SyncReactorImplTest {
                 .setMeter(Collections.singletonList(DSInputFactory.createMeter(2L)))
                 .build();
 
+        final SyncupEntry syncupEntry = new SyncupEntry(configFcn, LogicalDatastoreType.CONFIGURATION,
+                                                        operationalFcn, LogicalDatastoreType.OPERATIONAL);
+
         Mockito.when(syncPlanPushStrategy.executeSyncStrategy(
                 Matchers.<ListenableFuture<RpcResult<Void>>>any(),
                 Matchers.<SynchronizationDiffInput>any(),
                 Matchers.<SyncCrudCounters>any()))
                 .thenReturn(RpcResultBuilder.<Void>success().buildFuture());
 
-        final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, configFcn, operationalFcn, LogicalDatastoreType.CONFIGURATION);
+        final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, syncupEntry);
         try {
             Assert.assertTrue(syncupResult.isDone());
             final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
index 1bf41a49cbb9ec9c20d63761c999f8638a6ae6c5..8151e620df889e0ebe4cb74e5e329f64d25ba88f 100644 (file)
@@ -16,8 +16,9 @@ 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.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
 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;
@@ -34,57 +35,51 @@ 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;
+    private SyncReactor delegate;
     @Mock
-    private RetryRegistry retryRegistry;
+    private ReconciliationRegistry reconciliationRegistry;
     @Mock
-    private FlowCapableNode fcConfigNode;
-    @Mock
-    private FlowCapableNode fcOperationalNode;
+    private SyncupEntry syncupEntry;
 
     @Before
     public void setUp() {
-        reactor = new SyncReactorRetryDecorator(delegate, retryRegistry);
+        reactor = new SyncReactorRetryDecorator(delegate, reconciliationRegistry);
         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));
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
+                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
 
-        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        reactor.syncup(fcNodePath, syncupEntry);
 
-        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
         Mockito.verifyNoMoreInteractions(delegate);
-        Mockito.verify(retryRegistry).unregisterIfRegistered(NODE_ID);
+        Mockito.verify(reconciliationRegistry).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));
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
+                .thenReturn(Futures.immediateFuture(Boolean.FALSE));
 
-        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        reactor.syncup(fcNodePath, syncupEntry);
 
-        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
         Mockito.verifyNoMoreInteractions(delegate);
-        Mockito.verify(retryRegistry).register(NODE_ID);
+        Mockito.verify(reconciliationRegistry).register(NODE_ID);
     }
 
     @Test
     public void testSyncupConfigIgnoreInRetry() throws InterruptedException {
-        Mockito.when(retryRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+        Mockito.when(syncupEntry.isOptimizedConfigDelta()).thenReturn(true);
 
-        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode, dsType);
+        reactor.syncup(fcNodePath, syncupEntry);
 
         Mockito.verifyZeroInteractions(delegate);
     }
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManagerTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipManagerTest.java
new file mode 100644 (file)
index 0000000..d73df5b
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.clustering;
+
+import org.junit.Assert;
+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.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+/**
+ * Test for {@link DeviceMastershipManager}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class DeviceMastershipManagerTest {
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private DeviceMastershipManager deviceMastershipManager;
+    @Mock
+    private ClusterSingletonServiceRegistration registration;
+    @Mock
+    private ClusterSingletonServiceProvider clusterSingletonService;
+
+    @Before
+    public void setUp() throws Exception {
+        deviceMastershipManager = new DeviceMastershipManager(clusterSingletonService, new ReconciliationRegistry());
+        Mockito.when(clusterSingletonService.registerClusterSingletonService(Matchers.<ClusterSingletonService>any()))
+                .thenReturn(registration);
+    }
+
+    @Test
+    public void testOnDeviceConnectedAndDisconnected() {
+        // no context
+        Assert.assertNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
+        // create context - register
+        deviceMastershipManager.onDeviceConnected(NODE_ID);
+        DeviceMastership registration = deviceMastershipManager.getDeviceMasterships().get(NODE_ID);
+        Assert.assertNotNull(registration);
+        Mockito.verify(clusterSingletonService).registerClusterSingletonService(registration);
+        // destroy context - unregister
+        deviceMastershipManager.onDeviceDisconnected(NODE_ID);
+        Assert.assertNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
+    }
+
+    @Test
+    public void testIsDeviceMasteredOrSlaved() {
+        // no context
+        Assert.assertFalse(deviceMastershipManager.isDeviceMastered(NODE_ID));
+        deviceMastershipManager.onDeviceConnected(NODE_ID);
+        // is master
+        deviceMastershipManager.getDeviceMasterships().get(NODE_ID).instantiateServiceInstance();
+        Assert.assertTrue(deviceMastershipManager.isDeviceMastered(NODE_ID));
+        // is not master
+        deviceMastershipManager.getDeviceMasterships().get(NODE_ID).closeServiceInstance();
+        Assert.assertFalse(deviceMastershipManager.isDeviceMastered(NODE_ID));
+    }
+
+}
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/clustering/DeviceMastershipTest.java
new file mode 100644 (file)
index 0000000..be45a9d
--- /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.impl.clustering;
+
+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.openflowplugin.applications.frsync.util.ReconciliationRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
+/**
+ * Test for {@link DeviceMastership}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class DeviceMastershipTest {
+    private static final NodeId NODE_ID = new NodeId("testNode");
+    private DeviceMastership deviceMastership;
+
+    @Mock
+    private DeviceMastershipManager deviceMastershipManager;
+    @Mock
+    private ReconciliationRegistry reconciliationRegistry;
+
+    @Before
+    public void setUp() throws Exception {
+        deviceMastership = new DeviceMastership(NODE_ID, reconciliationRegistry);
+    }
+
+    @Test
+    public void instantiateServiceInstance() {
+        deviceMastership.instantiateServiceInstance();
+        Mockito.verify(reconciliationRegistry).register(NODE_ID);
+        Assert.assertTrue(deviceMastership.isDeviceMastered());
+    }
+
+    @Test
+    public void closeServiceInstance() {
+        deviceMastership.closeServiceInstance();
+        Mockito.verify(reconciliationRegistry).unregisterIfRegistered(NODE_ID);
+        Assert.assertFalse(deviceMastership.isDeviceMastered());
+    }
+}
\ No newline at end of file
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.applications.frsync.impl;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.math.BigInteger;
 import java.util.Collections;
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.applications.frsync.impl;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.math.BigInteger;
 import java.util.concurrent.Future;
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.applications.frsync.impl;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.math.BigInteger;
 import java.util.concurrent.Future;
index 90b7cf8b876e0c0a44a960641d7b1c526be5562e..4bea89fd48c2f248841135bbdf2ca90ea001b79a 100644 (file)
@@ -25,7 +25,6 @@ import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.openflowplugin.applications.frsync.impl.TableForwarder;
 import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
 import org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput;
@@ -81,12 +80,12 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
     @Captor
     private ArgumentCaptor<ProcessFlatBatchInput> processFlatBatchInputCpt;
 
-    private List<ItemSyncBox<Group>> groupsToAddOrUpdate;
-    private List<ItemSyncBox<Group>> groupsToRemove;
-    private ItemSyncBox<Meter> metersToAddOrUpdate;
-    private ItemSyncBox<Meter> metersToRemove;
-    private Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate;
-    private Map<TableKey, ItemSyncBox<Flow>> flowsToRemove;
+    private final List<ItemSyncBox<Group>> groupsToAddOrUpdate;
+    private final List<ItemSyncBox<Group>> groupsToRemove;
+    private final ItemSyncBox<Meter> metersToAddOrUpdate;
+    private final ItemSyncBox<Meter> metersToRemove;
+    private final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate;
+    private final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove;
     private List<Batch> batchBag;
 
     private SyncPlanPushStrategyFlatBatchImpl syncPlanPushStrategy;
@@ -280,7 +279,7 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
     }
 
     @Test
-    public void testMapBachesToRanges() throws Exception {
+    public void testMapBatchesToRanges() throws Exception {
         final List<Batch> inputBatchBag = Lists.newArrayList(
                 new BatchBuilder().setBatchOrder(0).build(),
                 new BatchBuilder().setBatchOrder(5).build(),
index 99358de3e2b0e71b0b56889bcef398813342af01..a0d84c429f229fa4ab4663141c57859ef68d9509 100644 (file)
@@ -26,15 +26,10 @@ 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.binding.api.DataBroker;
 import org.opendaylight.openflowplugin.applications.frsync.impl.DSInputFactory;
-import org.opendaylight.openflowplugin.applications.frsync.impl.FlowForwarder;
-import org.opendaylight.openflowplugin.applications.frsync.impl.GroupForwarder;
-import org.opendaylight.openflowplugin.applications.frsync.impl.MeterForwarder;
-import org.opendaylight.openflowplugin.applications.frsync.impl.TableForwarder;
 import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
 import org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -108,12 +103,12 @@ public class SyncPlanPushStrategyIncrementalImplTest {
 
     private SyncCrudCounters counters;
 
-    private List<ItemSyncBox<Group>> groupsToAddOrUpdate;
-    private List<ItemSyncBox<Group>> groupsToRemove;
-    private ItemSyncBox<Meter> metersToAddOrUpdate;
-    private ItemSyncBox<Meter> metersToRemove;
-    private Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate;
-    private Map<TableKey, ItemSyncBox<Flow>> flowsToRemove;
+    private final List<ItemSyncBox<Group>> groupsToAddOrUpdate;
+    private final List<ItemSyncBox<Group>> groupsToRemove;
+    private final ItemSyncBox<Meter> metersToAddOrUpdate;
+    private final ItemSyncBox<Meter> metersToRemove;
+    private final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate;
+    private final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove;
 
     public SyncPlanPushStrategyIncrementalImplTest() {
         groupsToAddOrUpdate = Lists.newArrayList(DiffInputFactory.createGroupSyncBox(1, 2, 3),
@@ -226,12 +221,7 @@ public class SyncPlanPushStrategyIncrementalImplTest {
     }
 
     private <O> Answer<Future<RpcResult<O>>> createSalServiceFutureAnswer() {
-        return new Answer<Future<RpcResult<O>>>() {
-            @Override
-            public Future<RpcResult<O>> answer(final InvocationOnMock invocation) throws Throwable {
-                return RpcResultBuilder.<O>success().buildFuture();
-            }
-        };
+        return invocation -> RpcResultBuilder.<O>success().buildFuture();
     }
 
     @Test
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.applications.frsync.impl;
+package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
 
 import java.math.BigInteger;
 import java.util.concurrent.Future;
index 61fd6384b828e844fafbb5af1c2bd972a9313799..727510286481bba5781b416fa926765b4546cd09 100644 (file)
@@ -89,11 +89,6 @@ public class ReconcileUtilTest {
         Assert.assertTrue(vehicle.get().isSuccessful());
     }
 
-    @Test
-    public void testCreateRpcResultCondenser() throws Exception {
-
-    }
-
     /**
      * add one missing group
      *
@@ -335,19 +330,4 @@ public class ReconcileUtilTest {
         }
         return syncBox1;
     }
-
-    @Test
-    public void testResolveMeterDiffs() throws Exception {
-
-    }
-
-    @Test
-    public void testResolveFlowDiffsInTable() throws Exception {
-
-    }
-
-    @Test
-    public void testResolveFlowDiffsInAllTables() throws Exception {
-
-    }
 }
\ No newline at end of file
@@ -17,38 +17,38 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 
 /**
- * Test for {@link RetryRegistry}.
+ * Test for {@link ReconciliationRegistry}.
  */
 @RunWith(MockitoJUnitRunner.class)
-public class RetryRegistryTest {
+public class ReconciliationRegistryTest {
 
     private static final NodeId NODE_ID = new NodeId("testNode");
-    private RetryRegistry retryRegistry;
+    private ReconciliationRegistry reconciliationRegistry;
 
     @Before
     public void setUp() throws Exception {
-        retryRegistry = new RetryRegistry();
+        reconciliationRegistry = new ReconciliationRegistry();
     }
 
     @Test
     public void testRegister() {
-        Date timestamp = retryRegistry.register(NODE_ID);
-        Assert.assertEquals(true, retryRegistry.isRegistered(NODE_ID));
+        Date timestamp = reconciliationRegistry.register(NODE_ID);
+        Assert.assertEquals(true, reconciliationRegistry.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));
+        reconciliationRegistry.register(NODE_ID);
+        Date timestamp = reconciliationRegistry.unregisterIfRegistered(NODE_ID);
+        Assert.assertEquals(false, reconciliationRegistry.isRegistered(NODE_ID));
         Assert.assertNotNull(timestamp);
     }
 
     @Test
     public void testUnregisterIfNotRegistered() {
-        Date timestamp = retryRegistry.unregisterIfRegistered(NODE_ID);
-        Assert.assertEquals(false, retryRegistry.isRegistered(NODE_ID));
+        Date timestamp = reconciliationRegistry.unregisterIfRegistered(NODE_ID);
+        Assert.assertEquals(false, reconciliationRegistry.isRegistered(NODE_ID));
         Assert.assertNull(timestamp);
     }
 
index 8affd2a5b2444bed518cfd6019d796c810d42ef8..510dce07d168d05dc5933b45fa3d093bcedb84eb 100644 (file)
@@ -111,7 +111,7 @@ public class SemaphoreKeeperTest {
     private static class Worker implements Runnable {
         private final SemaphoreKeeper<String> keeper;
         private final String key;
-        private ConcurrentMap<Integer, Integer> counter = new ConcurrentHashMap<>();
+        private final ConcurrentMap<Integer, Integer> counter = new ConcurrentHashMap<>();
         private volatile int index = 0;
 
         public Worker(SemaphoreKeeper<String> keeper, final String key) {
index c7dd08e20661128bdb59c65f7e167d59617c983c..afcf1fd4c244d8edf1147378121b660fc06cf4cc 100644 (file)
@@ -51,7 +51,8 @@ class FlowCapableInventoryProvider implements AutoCloseable, Runnable, Transacti
     }
 
     void start() {
-        final NodeChangeCommiter changeCommiter = new NodeChangeCommiter(FlowCapableInventoryProvider.this);
+        final NodeChangeCommiter changeCommiter = new NodeChangeCommiter(FlowCapableInventoryProvider.this, eos);
+        changeCommiter.init();
         this.listenerRegistration = this.notificationService.registerNotificationListener(changeCommiter);
 
         final NodeTablesFeatureCommitter nodeTablesFeatureCommitter =
index 35b6b3d717dc345e93926e33198820587f74607d..24d2968c615337a7bb4e0676f3abd1fedd9e0f46 100644 (file)
@@ -14,8 +14,16 @@ import com.google.common.cache.CacheBuilder;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 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.FlowCapableNodeConnector;
@@ -29,15 +37,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class NodeChangeCommiter implements OpendaylightInventoryListener {
+class NodeChangeCommiter implements OpendaylightInventoryListener,EntityOwnershipListener {
     private static final Logger LOG = LoggerFactory.getLogger(NodeChangeCommiter.class);
 
     private final FlowCapableInventoryProvider manager;
+    private final EntityOwnershipService entityOwnershipService;
+
+    private final String DEVICE_TYPE = "openflow";
 
     // cache for nodes which were deleted, we get more than one nodeRemoved notification
     private Cache<NodeRef, Boolean> deletedNodeCache =
@@ -47,13 +61,28 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
     private Cache<NodeConnectorRef, Boolean> deletedNodeConnectorCache =
             CacheBuilder.newBuilder().maximumSize(1000000).expireAfterWrite(10, TimeUnit.SECONDS).build();
 
-    public NodeChangeCommiter(final FlowCapableInventoryProvider manager) {
+    public NodeChangeCommiter(final FlowCapableInventoryProvider manager, final EntityOwnershipService entityOwnershipService) {
         this.manager = Preconditions.checkNotNull(manager);
+        this.entityOwnershipService = Preconditions.checkNotNull(entityOwnershipService);
+    }
+
+    public void init(){
+        registerEntityOwnershipChangeListener();
+    }
+
+    public void registerEntityOwnershipChangeListener() {
+        if(entityOwnershipService!=null) {
+            if(LOG.isDebugEnabled()) {
+                LOG.debug("registerEntityOwnershipChangeListener:" +
+                        " Registering entity ownership change listener for entities of type {}", DEVICE_TYPE);
+            }
+            entityOwnershipService.registerListener(DEVICE_TYPE, this);
+        }
     }
 
     @Override
     public synchronized void onNodeConnectorRemoved(final NodeConnectorRemoved connector) {
-        if(deletedNodeConnectorCache.getIfPresent(connector.getNodeConnectorRef()) == null){
+        if (deletedNodeConnectorCache.getIfPresent(connector.getNodeConnectorRef()) == null) {
             deletedNodeConnectorCache.put(connector.getNodeConnectorRef(), Boolean.TRUE);
         } else {
             //its been noted that creating an operation for already removed node-connectors, fails
@@ -63,7 +92,9 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
             return;
         }
 
-        if(!manager.deviceDataDeleteAllowed(getNodeId(connector.getNodeConnectorRef().getValue()))) { return; }
+        if (!manager.deviceDataDeleteAllowed(getNodeId(connector.getNodeConnectorRef().getValue()))) {
+            return;
+        }
 
         LOG.debug("Node connector removed notification received, {}", connector.getNodeConnectorRef().getValue());
         manager.enqueue(new InventoryOperation() {
@@ -78,7 +109,7 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
 
     @Override
     public synchronized void onNodeConnectorUpdated(final NodeConnectorUpdated connector) {
-        if (deletedNodeConnectorCache.getIfPresent(connector.getNodeConnectorRef()) != null){
+        if (deletedNodeConnectorCache.getIfPresent(connector.getNodeConnectorRef()) != null) {
             deletedNodeConnectorCache.invalidate(connector.getNodeConnectorRef());
         }
 
@@ -107,7 +138,7 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
     @Override
     public synchronized void onNodeRemoved(final NodeRemoved node) {
 
-        if(deletedNodeCache.getIfPresent(node.getNodeRef()) == null){
+        if (deletedNodeCache.getIfPresent(node.getNodeRef()) == null) {
             deletedNodeCache.put(node.getNodeRef(), Boolean.TRUE);
         } else {
             //its been noted that creating an operation for already removed node, fails
@@ -117,7 +148,9 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
             return;
         }
 
-        if(!manager.deviceDataDeleteAllowed(getNodeId(node.getNodeRef().getValue()))) { return; }
+        if (!manager.deviceDataDeleteAllowed(getNodeId(node.getNodeRef().getValue()))) {
+            return;
+        }
 
         LOG.debug("Node removed notification received, {}", node.getNodeRef().getValue());
         manager.enqueue(new InventoryOperation() {
@@ -132,7 +165,7 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
 
     @Override
     public synchronized void onNodeUpdated(final NodeUpdated node) {
-        if (deletedNodeCache.getIfPresent(node.getNodeRef()) != null){
+        if (deletedNodeCache.getIfPresent(node.getNodeRef()) != null) {
             deletedNodeCache.invalidate(node.getNodeRef());
         }
 
@@ -196,7 +229,54 @@ class NodeChangeCommiter implements OpendaylightInventoryListener {
         });
     }
 
+    @Override
+    public void ownershipChanged(final EntityOwnershipChange entityOwnershipChange) {
+        final Entity entity = entityOwnershipChange.getEntity();
+        NodeId nodeId = getNodeID(entity.getId());
+        InstanceIdentifier<Node> identifier = identifierFromNodeId(nodeId);
+
+        if (!entityOwnershipChange.hasOwner()) {
+            //NodeChangeCommitter : entityOwnershipChange - hasOwner,is false for node
+            LOG.debug("Node: {} is not owned by any controller instance, cleaning up the inventory data store ",nodeId);
+            NodeRef nodeRef = new NodeRef(identifier);
+            NodeRemoved nodeRemoved = nodeRemoved(nodeRef);
+            onNodeRemoved(nodeRemoved);
+
+        }else{
+            //
+            LOG.debug("Node {} is currently owned by other controller instance", nodeId);
+        }
+    }
+
+
+
+    private static NodeId getNodeID(YangInstanceIdentifier yangInstanceIdentifier) {
+
+        QName ENTITY_QNAME =
+                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.
+                        controller.md.sal.core.general.entity.rev150820.Entity.QNAME;
+        QName ENTITY_NAME = QName.create(ENTITY_QNAME, "name");
+
+        YangInstanceIdentifier.NodeIdentifierWithPredicates niWPredicates =
+                (YangInstanceIdentifier.NodeIdentifierWithPredicates) yangInstanceIdentifier.getLastPathArgument();
+        Map<QName, Object> keyValMap = niWPredicates.getKeyValues();
+        String nodeIdStr = (String) (keyValMap.get(ENTITY_NAME));
+        return new NodeId(nodeIdStr);
+    }
+
+    private static InstanceIdentifier<Node> identifierFromNodeId(NodeId nodeId) {
+        NodeKey nodeKey = new NodeKey(nodeId);
+        InstanceIdentifier.InstanceIdentifierBuilder<Node> builder =
+                InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
+        return builder.build();
+    }
+
+    private static NodeRemoved nodeRemoved(final NodeRef nodeRef) {
+        NodeRemovedBuilder builder = new NodeRemovedBuilder();
+        builder.setNodeRef(nodeRef);
+        return builder.build();
+    }
     private NodeId getNodeId(InstanceIdentifier<?> iid) {
         return iid.firstKeyOf(Node.class).getId();
     }
-}
+}
\ No newline at end of file
index 8af29876c3588353ca84822619be65aff6c8da01..4a17a37b372b8e030a10c7d85778b4b7ba630a64 100644 (file)
         <bundle>mvn:org.opendaylight.openflowplugin.applications/forwardingrules-manager/{{VERSION}}</bundle>
     </feature>
 
+    <feature name='odl-openflowplugin-app-forwardingrules-sync' description="OpenDaylight :: Openflow Plugin :: Application - FRS" version='${project.version}'>
+        <feature version="${project.version}">odl-openflowplugin-southbound</feature>
+        <bundle>mvn:org.opendaylight.openflowplugin.applications/forwardingrules-sync/{{VERSION}}</bundle>
+    </feature>
+
 </features>
index 7414eb977b99ec9d7ba5444bc3ae9239ecc7fb55..3c6d79ab2ccb0f269ffa7ad679bc8651c29fd728 100644 (file)
@@ -271,8 +271,13 @@ module opendaylight-match-types {
         }
     }
 
-    grouping "tcp-flag-match-fields" {
-        leaf tcp-flag {
+    grouping "tcp-flags-match-fields" {
+        leaf tcp-flags {
+            description "Tcp flags for match";
+            type uint16;
+        }
+        leaf tcp-flags-mask {
+            description "Mask for tcp flags";
             type uint16;
         }
     }
@@ -369,8 +374,8 @@ module opendaylight-match-types {
             uses "protocol-match-fields";
         }
 
-        container tcp-flag-match {
-            uses "tcp-flag-match-fields";
+        container tcp-flags-match {
+            uses "tcp-flags-match-fields";
         }
     }
 }
index 91224ef93e88e5d59b2765a9aefe1328ddc0f43b..e236287807e5403098f98b2d3ce966c96ef0a900 100644 (file)
@@ -188,9 +188,9 @@ module opendaylight-table-types {
         base match-field;
         description "Match for IPv6 Extension Header pseudo-field";
     }
-    identity tcp_flag {
+    identity tcp_flags {
         base match-field;
-        description "TCP Flag Match";
+        description "TCP Flags Match";
     }
     identity tunnel_ipv4_dst {
         base match-field;
@@ -200,7 +200,7 @@ module opendaylight-table-types {
         base match-field;
         description "IPv4 source tunnel endpoint address.";
     }
-        
+
     grouping set-field-match {
         list set-field-match {
            key "match-type";
index af2efaf21f8ea67b4589fd2b959614ea8cf6d8ba..24e1d7e2ef07af03214fea9890b1004c976484e8 100644 (file)
@@ -43,6 +43,7 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Messa
 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.slf4j.Logger;
@@ -62,11 +63,13 @@ final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeList
     private StatisticsManager statisticsManager;
     private RpcManager rpcManager;
     private final MessageIntelligenceAgency messageIntelligenceAgency;
+    private final ConvertorExecutor convertorExecutor;
     private ConcurrentHashMap<DeviceInfo, ServiceChangeListener> serviceChangeListeners = new ConcurrentHashMap<>();
     private NotificationPublishService notificationPublishService;
 
-    LifecycleConductorImpl(final MessageIntelligenceAgency messageIntelligenceAgency) {
+    LifecycleConductorImpl(final MessageIntelligenceAgency messageIntelligenceAgency, ConvertorExecutor convertorExecutor) {
         this.messageIntelligenceAgency = Preconditions.checkNotNull(messageIntelligenceAgency);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -166,13 +169,13 @@ final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeList
         if (OfpRole.BECOMEMASTER.equals(newRole)) {
             logText = "Start";
             fillDeviceFlowRegistry(deviceInfo, deviceContext.getDeviceFlowRegistry());
-            MdSalRegistrationUtils.registerServices(rpcContext, deviceContext, this.extensionConverterProvider);
+            MdSalRegistrationUtils.registerServices(rpcContext, deviceContext, this.extensionConverterProvider, convertorExecutor);
 
             if (rpcContext.isStatisticsRpcEnabled()) {
                 MdSalRegistrationUtils.registerStatCompatibilityServices(
                         rpcContext,
                         deviceContext,
-                        notificationPublishService);
+                        notificationPublishService, convertorExecutor);
             }
         } else {
             logText = "Stopp";
index 70c4da81bd5bb4f74b1e7f19fdd58a6d53d59287..7215fa6ab34103f6b8921dec50367570ce72e363 100644 (file)
@@ -57,6 +57,8 @@ import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntell
 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.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,6 +70,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
 
     private final int rpcRequestsQuota;
     private final long globalNotificationQuota;
+    private final ConvertorManager convertorManager;
     private long barrierInterval;
     private int barrierCountLimit;
     private long echoReplyTimeout;
@@ -112,7 +115,8 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
                 Preconditions.checkNotNull(threadPoolTimeout), TimeUnit.SECONDS,
                 new SynchronousQueue<>(), "ofppool");
 
-        conductor = new LifecycleConductorImpl(messageIntelligenceAgency);
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
+        conductor = new LifecycleConductorImpl(messageIntelligenceAgency, convertorManager);
     }
 
     @Override
@@ -224,7 +228,8 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
                 barrierInterval,
                 barrierCountLimit,
                 conductor,
-                isNotificationFlowRemovedOff);
+                isNotificationFlowRemovedOff,
+                convertorManager);
         ((ExtensionConverterProviderKeeper) conductor).setExtensionConverterProvider(extensionConverterManager);
         ((ExtensionConverterProviderKeeper) deviceManager).setExtensionConverterProvider(extensionConverterManager);
 
@@ -232,7 +237,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         conductor.setNotificationPublishService(notificationPublishService);
 
         roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker, conductor);
-        statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, isStatisticsPollingOff, conductor);
+        statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, isStatisticsPollingOff, conductor, convertorManager);
         conductor.setSafelyManager(statisticsManager);
 
         rpcManager = new RpcManagerImpl(rpcProviderRegistry, rpcRequestsQuota, conductor);
@@ -256,7 +261,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
 
         rpcManager.setStatisticsRpcEnabled(isStatisticsRpcEnabled);
 
-        TranslatorLibraryUtil.setBasicTranslatorLibrary(deviceManager);
+        TranslatorLibraryUtil.injectBasicTranslatorLibrary(deviceManager, convertorManager);
         deviceManager.initialize();
 
         startSwitchConnections();
index 449c24cfe2deb67e81a7ac3aca0fd2a886376162..9828888c835f2feb83d22047e21cb96122e3490b 100644 (file)
@@ -12,9 +12,11 @@ import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.CheckForNull;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
@@ -216,12 +218,16 @@ public class NodeStaticReplyTranslatorUtil {
      * table can have List of TableFeatures so add it directly to
      * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder}
      *
-     * @param reply
-     * @return
+     * @param reply reply
+     * @param version Openflow version
+     * @param convertorExecutor convertor executor
+     * @return list of table features
      */
-    public static List<TableFeatures> nodeTableFeatureTranslator(@CheckForNull final MultipartReplyTableFeatures reply) {
+    public static List<TableFeatures> nodeTableFeatureTranslator(@CheckForNull final MultipartReplyTableFeatures reply, final short version, @CheckForNull final ConvertorExecutor convertorExecutor) {
         Preconditions.checkArgument(reply != null);
-        return TableFeaturesReplyConvertor.toTableFeaturesReply(reply);
+        Preconditions.checkArgument(convertorExecutor != null);
+        final Optional<List<TableFeatures>> tableFeaturesList = convertorExecutor.convert(reply, new VersionConvertorData(version));
+        return tableFeaturesList.orElse(Collections.emptyList());
     }
 
     /**
index f9ee7ce84f222e5a5f585b43c873231ea5f3da1a..154c226fa9ca2ad95e8a07a8505ab4d4265500a1 100644 (file)
@@ -52,6 +52,7 @@ import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionCon
 import org.opendaylight.openflowplugin.impl.connection.OutboundQueueProviderImpl;
 import org.opendaylight.openflowplugin.impl.device.listener.OpenflowProtocolListenerFullImpl;
 import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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;
@@ -74,6 +75,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private static final int SPY_RATE = 10;
 
     private final DataBroker dataBroker;
+    private final ConvertorExecutor convertorExecutor;
     private TranslatorLibrary translatorLibrary;
     private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
@@ -92,11 +94,13 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     public DeviceManagerImpl(@Nonnull final DataBroker dataBroker,
                              final long globalNotificationQuota, final boolean switchFeaturesMandatory,
                              final long barrierInterval, final int barrierCountLimit,
-                             final LifecycleConductor lifecycleConductor, boolean isNotificationFlowRemovedOff) {
+                             final LifecycleConductor lifecycleConductor, boolean isNotificationFlowRemovedOff,
+                             final ConvertorExecutor convertorExecutor) {
         this.switchFeaturesMandatory = switchFeaturesMandatory;
         this.globalNotificationQuota = globalNotificationQuota;
         this.isNotificationFlowRemovedOff = isNotificationFlowRemovedOff;
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
+        this.convertorExecutor = convertorExecutor;
         /* merge empty nodes to oper DS to predict any problems with missing parent for Node */
         final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
 
@@ -379,7 +383,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         ((DeviceContextImpl)deviceContext).getTransactionChainManager().activateTransactionManager();
         /* Init Collecting NodeInfo */
         final ListenableFuture<Void> initCollectingDeviceInfo = DeviceInitializationUtils.initializeNodeInformation(
-                deviceContext, switchFeaturesMandatory);
+                deviceContext, switchFeaturesMandatory, convertorExecutor);
         /* Init Collecting StatInfo */
         final ListenableFuture<Boolean> statPollFuture = Futures.transform(initCollectingDeviceInfo,
                 new AsyncFunction<Void, Boolean>() {
index cab75a4f096da076b6bc0d95203fefbaa9bc535f..0f051f7230588392a5c1aa3068b3a80654bbab0e 100644 (file)
@@ -146,9 +146,18 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
     @Override
     public FlowDescriptor retrieveIdForFlow(final FlowRegistryKey flowRegistryKey) {
         LOG.trace("Retrieving flowDescriptor for flow hash: {}", flowRegistryKey.hashCode());
-
+        FlowDescriptor flowDescriptor = flowRegistry.get(flowRegistryKey);
+        if(flowDescriptor == null){
+            LOG.info("Triggered the loop");
+            for(Map.Entry<FlowRegistryKey, FlowDescriptor> fd : flowRegistry.entrySet()) {
+                if (fd.getKey().equals(flowRegistryKey)) {
+                    flowDescriptor = fd.getValue();
+                    break;
+                }
+            }
+        }
         // Get FlowDescriptor from flow registry
-        return flowRegistry.get(flowRegistryKey);
+        return flowDescriptor;
     }
 
     @Override
@@ -162,7 +171,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
         LOG.trace("Trying to retrieve flowDescriptor for flow hash: {}", flowRegistryKey.hashCode());
 
         // First, try to get FlowDescriptor from flow registry
-        FlowDescriptor flowDescriptor = flowRegistry.get(flowRegistryKey);
+        FlowDescriptor flowDescriptor = retrieveIdForFlow(flowRegistryKey);
 
         // We was not able to retrieve FlowDescriptor, so we will at least try to generate it
         if (flowDescriptor == null) {
index 3919aa3c7553bc3d8cb1af2c7526ae92f029ac98..889e30a2c21f606852e154ce7ca14394973ee74b 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.base.Preconditions;
 import java.math.BigInteger;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
+import org.opendaylight.openflowplugin.impl.util.MatchComparatorFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
@@ -58,13 +59,15 @@ public class FlowRegistryKeyFactory {
 
             return getPriority() == that.getPriority() &&
                     getTableId() == that.getTableId() &&
-                    getMatch().equals(that.getMatch());
+                    getCookie().equals(that.getCookie()) &&
+                    MatchComparatorFactory.createMatch().areObjectsEqual(getMatch(), that.getMatch());
         }
 
         @Override
         public int hashCode() {
             int result = tableId;
             result = 31 * result + priority;
+            result = 31 * result + cookie.hashCode();
             result = 31 * result + match.hashCode();
             return result;
         }
index e20a48dd6ea89d99d372db6be3afc50b2bf115c7..06ccafd774f1d90495b6d0e7158206bf8d3fd9e8 100644 (file)
@@ -13,19 +13,24 @@ import java.util.List;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 
 public abstract class AbstractMultipartOnTheFlyService<I> extends AbstractService<I, List<MultipartReply>> {
-    protected AbstractMultipartOnTheFlyService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    private final ConvertorExecutor convertorExecutor;
+
+    protected AbstractMultipartOnTheFlyService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
     protected final FutureCallback<OfHeader> createCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType) {
         return new MultipartRequestOnTheFlyCallback(context, requestType,
                 getMessageSpy(), getEventIdentifier(), getDeviceInfo(),
-                getDeviceContext().getDeviceFlowRegistry(), getTxFacade());
+                getDeviceContext().getDeviceFlowRegistry(), getTxFacade(),
+                convertorExecutor);
     }
 
 
index ab05258539511614ca2c1df0f9d32e43db021471..e3fbb01c027ddf5ceea8bcdf758d98de160974c7 100644 (file)
@@ -12,12 +12,15 @@ 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.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.openflowplugin.api.OFConstants;
 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.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -28,8 +31,14 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 final class FlowService<O extends DataObject> extends AbstractSimpleService<FlowModInputBuilder, O> {
 
-    protected FlowService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+    private final ConvertorExecutor convertorExecutor;
+    private final VersionDatapathIdConvertorData data;
+
+    protected FlowService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, clazz);
+        this.convertorExecutor = convertorExecutor;
+        data = new VersionDatapathIdConvertorData(getVersion());
+        data.setDatapathId(getDatapathId());
     }
 
     @Override
@@ -39,7 +48,8 @@ final class FlowService<O extends DataObject> extends AbstractSimpleService<Flow
     }
 
     List<FlowModInputBuilder> toFlowModInputs(final Flow input) {
-        return FlowConvertor.toFlowModInputs(input, getVersion(), getDatapathId());
+        final Optional<List<FlowModInputBuilder>> flowModInputBuilders = convertorExecutor.convert(input, data);
+        return flowModInputBuilders.orElse(Collections.emptyList());
     }
 
     ListenableFuture<RpcResult<O>> processFlowModInputBuilders(final List<FlowModInputBuilder> ofFlowModInputs) {
index 431fea1e23c52b63ae5e59032f96bd22394ea367..d0f50eaa74a0de2792473859c680a050509ad25d 100644 (file)
@@ -7,25 +7,37 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
+import java.util.Optional;
 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.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 final class GroupService<I extends Group, O extends DataObject> extends AbstractSimpleService<I, O> {
-    GroupService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+    private final ConvertorExecutor convertorExecutor;
+    private final VersionDatapathIdConvertorData data;
+
+    GroupService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, clazz);
+        this.convertorExecutor = convertorExecutor;
+        data = new VersionDatapathIdConvertorData(getVersion());
+        data.setDatapathId(getDatapathId());
     }
 
     @Override
     protected OfHeader buildRequest(final Xid xid, final I input) {
-        final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(input, getVersion(), getDatapathId());
-        ofGroupModInput.setXid(xid.getValue());
+        final Optional<GroupModInputBuilder> ofGroupModInput = convertorExecutor.convert(input, data);
+
+        final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                .orElse(GroupConvertor.defaultResult(getVersion()))
+                .setXid(xid.getValue());
 
-        return ofGroupModInput.build();
+        return groupModInputBuilder.build();
     }
 }
index 73cf63f4ec0b3f0daa924f3b87aeb059b69b5233..91d4abbacbdca82c53c9c2b27cd837ef2477c752 100644 (file)
@@ -7,10 +7,13 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
+import java.util.Optional;
 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.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -18,14 +21,22 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 
 final class MeterService<I extends Meter, O extends DataObject> extends AbstractSimpleService<I, O> {
 
-    MeterService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+    private final ConvertorExecutor convertorExecutor;
+    private final VersionConvertorData data;
+
+    MeterService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, clazz);
+        this.convertorExecutor = convertorExecutor;
+        data = new VersionConvertorData(getVersion());
     }
 
     @Override
     protected OfHeader buildRequest(final Xid xid, final I input) {
-        final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(input, getVersion());
-        ofMeterModInput.setXid(xid.getValue());
-        return ofMeterModInput.build();
+        final Optional<MeterModInputBuilder> ofMeterModInput = convertorExecutor.convert(input, data);
+        final MeterModInputBuilder meterModInputBuilder = ofMeterModInput
+                .orElse(MeterConvertor.defaultResult(getVersion()));
+
+        meterModInputBuilder.setXid(xid.getValue());
+        return meterModInputBuilder.build();
     }
-}
+}
\ No newline at end of file
index dcb445b11e03db4717fcc91d1ab4f5b865730695..9b1c0e729158ba831b4fe13ce4dcd379f13501fe 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Messa
 import org.opendaylight.openflowplugin.impl.statistics.SinglePurposeMultipartReplyTranslator;
 import org.opendaylight.openflowplugin.impl.statistics.StatisticsGatheringUtils;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 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;
@@ -34,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 SinglePurposeMultipartReplyTranslator multipartReplyTranslator;
     private final DeviceInfo deviceInfo;
     private final DeviceFlowRegistry registry;
     private boolean virgin = true;
@@ -49,13 +50,16 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
                                             final EventIdentifier eventIdentifier,
                                             final DeviceInfo deviceInfo,
                                             final DeviceFlowRegistry registry,
-                                            final TxFacade txFacade) {
+                                            final TxFacade txFacade,
+                                            final ConvertorExecutor convertorExecutor) {
         super(context, requestType, messageSpy, eventIdentifier);
 
         this.deviceInfo = deviceInfo;
         this.registry = registry;
         this.txFacade = txFacade;
 
+        multipartReplyTranslator = new SinglePurposeMultipartReplyTranslator(convertorExecutor);
+
         //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(), deviceInfo.getNodeId().toString());
     }
@@ -88,7 +92,7 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
             final MultipartReply multipartReply = (MultipartReply) result;
 
             final MultipartReply singleReply = multipartReply;
-            final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
+            final List<? extends DataObject> multipartDataList = multipartReplyTranslator.translate(
                     deviceInfo.getDatapathId(), deviceInfo.getVersion(), singleReply);
             final Iterable<? extends DataObject> allMultipartData = multipartDataList;
 
index 85e198ef24c6fd8c53ce1ec88e882451927be904..b8449e49545e50faba0a24de2fa137847750fe35 100644 (file)
@@ -7,20 +7,27 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
+import java.util.Optional;
 import java.util.concurrent.Future;
 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.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public final class PacketProcessingServiceImpl extends AbstractVoidService<TransmitPacketInput> implements PacketProcessingService {
 
-    public PacketProcessingServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    private final ConvertorExecutor convertorExecutor;
+
+    public PacketProcessingServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -30,6 +37,11 @@ public final class PacketProcessingServiceImpl extends AbstractVoidService<Trans
 
     @Override
     protected OfHeader buildRequest(final Xid xid, final TransmitPacketInput input) {
-        return PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(), getDatapathId());
+        final PacketOutConvertorData data = new PacketOutConvertorData(getVersion());
+        data.setDatapathId(getDatapathId());
+        data.setXid(xid.getValue());
+
+        final Optional<PacketOutInput> result = convertorExecutor.convert(input, data);
+        return result.orElse(PacketOutConvertor.defaultResult(getVersion()));
     }
 }
index c0ab557425994f2d06426f6820db02fdbb4099ab..8609c1192f2656d4c29651e4369fcfdedce2c29d 100644 (file)
@@ -26,6 +26,7 @@ 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.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
@@ -62,11 +63,11 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
     private final DeviceContext deviceContext;
     private ItemLifecycleListener itemLifecycleListener;
 
-    public SalFlowServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    public SalFlowServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         this.deviceContext = deviceContext;
-        flowRemove = new FlowService(requestContextStack, deviceContext, RemoveFlowOutput.class);
-        flowAdd = new FlowService<>(requestContextStack, deviceContext, AddFlowOutput.class);
-        flowUpdate = new FlowService<>(requestContextStack, deviceContext, UpdateFlowOutput.class);
+        flowRemove = new FlowService<>(requestContextStack, deviceContext, RemoveFlowOutput.class, convertorExecutor);
+        flowAdd = new FlowService<>(requestContextStack, deviceContext, AddFlowOutput.class, convertorExecutor);
+        flowUpdate = new FlowService<>(requestContextStack, deviceContext, UpdateFlowOutput.class, convertorExecutor);
     }
 
     @Override
index cdbc10b6f08f0083cf503a734154994c0ca60c6a..41ea6d5181a021fb98a51951b1f189157ad250a8 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
@@ -45,11 +46,11 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
     private final DeviceContext deviceContext;
     private ItemLifecycleListener itemLifecycleListener;
 
-    public SalGroupServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    public SalGroupServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         this.deviceContext = deviceContext;
-        addGroup = new GroupService<>(requestContextStack, deviceContext, AddGroupOutput.class);
-        updateGroup = new GroupService<>(requestContextStack, deviceContext, UpdateGroupOutput.class);
-        removeGroup = new GroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class);
+        addGroup = new GroupService<>(requestContextStack, deviceContext, AddGroupOutput.class, convertorExecutor);
+        updateGroup = new GroupService<>(requestContextStack, deviceContext, UpdateGroupOutput.class, convertorExecutor);
+        removeGroup = new GroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class, convertorExecutor);
     }
 
     @Override
index b053d99cb8fc361361d93ccbebe1d0be955b5f36..2ed7df5f8441bb953abc7dba3ad208074647c786 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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;
@@ -45,11 +46,11 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
     private ItemLifecycleListener itemLifecycleListener;
     private final DeviceContext deviceContext;
 
-    public SalMeterServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    public SalMeterServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         this.deviceContext = deviceContext;
-        addMeter = new MeterService<>(requestContextStack, deviceContext, AddMeterOutput.class);
-        updateMeter = new MeterService<>(requestContextStack, deviceContext, UpdateMeterOutput.class);
-        removeMeter = new MeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class);
+        addMeter = new MeterService<>(requestContextStack, deviceContext, AddMeterOutput.class, convertorExecutor);
+        updateMeter = new MeterService<>(requestContextStack, deviceContext, UpdateMeterOutput.class, convertorExecutor);
+        removeMeter = new MeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class, convertorExecutor);
     }
 
     @Override
index 3bd932bd0f04b145783a49609b82cabc57cc8f82..86f9afe8e98174c068903c4db3aeca90ec5aed66 100644 (file)
@@ -7,11 +7,14 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
+import java.util.Optional;
 import java.util.concurrent.Future;
 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.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
@@ -22,8 +25,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.Upda
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public final class SalPortServiceImpl extends AbstractSimpleService<UpdatePortInput, UpdatePortOutput> implements SalPortService {
-    public SalPortServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    private final ConvertorExecutor convertorExecutor;
+    private final VersionConvertorData data;
+
+    public SalPortServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, UpdatePortOutput.class);
+        this.convertorExecutor = convertorExecutor;
+        data = new VersionConvertorData(getVersion());
     }
 
     @Override
@@ -34,9 +42,11 @@ public final class SalPortServiceImpl extends AbstractSimpleService<UpdatePortIn
     @Override
     protected OfHeader buildRequest(final Xid xid, final UpdatePortInput input) {
         final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
-        final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
-        final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
-        mdInput.setXid(xid.getValue());
+        final Optional<PortModInput> ofPortModInput = convertorExecutor.convert(inputPort, data);
+
+        final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput
+                .orElse(PortConvertor.defaultResult(getVersion())))
+                .setXid(xid.getValue());
 
         return mdInput.build();
     }
index bd38f2836a82402d362a66cac1dd7b137ecec609..25ccd243ae49e1b9a44628d91b963349e881bd56 100644 (file)
@@ -13,18 +13,19 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 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.openflow.md.core.sal.convertor.TableFeaturesConvertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 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.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;
@@ -54,13 +55,14 @@ import org.slf4j.Logger;
 public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTableInput> implements SalTableService {
     private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalTableServiceImpl.class);
     private final TxFacade txFacade;
-    private final NodeId nodeId;
+    private final ConvertorExecutor convertorExecutor;
+    private final VersionConvertorData data;
 
-    public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
-                               final NodeId nodeId) {
+    public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext);
         this.txFacade = deviceContext;
-        this.nodeId = nodeId;
+        this.convertorExecutor = convertorExecutor;
+        data = new VersionConvertorData(getVersion());
     }
 
     @Override
@@ -133,7 +135,7 @@ public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTa
         txFacade.submitTransaction();
     }
 
-    protected static List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
+    protected List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
             final List<MultipartReply> multipartReplies) {
         final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
         for (final MultipartReply multipartReply : multipartReplies) {
@@ -143,9 +145,14 @@ public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTa
                     final MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
                     final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
                             .getMultipartReplyTableFeatures();
-                    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
-                            .toTableFeaturesReply(salTableFeatures);
-                    salTableFeaturesAll.addAll(salTableFeaturesPartial);
+
+                    final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>> salTableFeaturesPartial =
+                            convertorExecutor.convert(salTableFeatures, data);
+
+                    if (salTableFeaturesPartial.isPresent()) {
+                        salTableFeaturesAll.addAll(salTableFeaturesPartial.get());
+                    }
+
                     LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
                 }
             }
@@ -166,9 +173,9 @@ public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTa
     protected OfHeader buildRequest(final Xid xid, final UpdateTableInput input) {
         final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
         final MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
-        final List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input
-            .getUpdatedTable());
-        requestBuilder.setTableFeatures(ofTableFeatureList);
+
+        final Optional<List<TableFeatures>> ofTableFeatureList = convertorExecutor.convert(input.getUpdatedTable(), data);
+        requestBuilder.setTableFeatures(ofTableFeatureList.orElse(Collections.emptyList()));
         caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
 
         // Set request body to main multipart request
index 732bc4f465ba2cce2f0a1213424fbacc0bd56810..80c9d42cfa5854435303737d7338918756d2d937 100644 (file)
@@ -9,16 +9,18 @@ package org.opendaylight.openflowplugin.impl.statistics;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 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;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
@@ -37,6 +39,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectLiveness;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectWeight;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder;
@@ -49,6 +53,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
 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;
@@ -104,30 +109,31 @@ public class SinglePurposeMultipartReplyTranslator {
 
     protected static final Logger logger = LoggerFactory
             .getLogger(SinglePurposeMultipartReplyTranslator.class);
+    private final ConvertorExecutor convertorExecutor;
 
-    private static FlowStatsResponseConvertor flowStatsConvertor = new FlowStatsResponseConvertor();
-    private static GroupStatsResponseConvertor groupStatsConvertor = new GroupStatsResponseConvertor();
-    private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
-
+    public SinglePurposeMultipartReplyTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
 
     public List<DataObject> translate(final BigInteger datapathId, final short version, final OfHeader msg) {
 
         List<DataObject> listDataObject = new ArrayList<>();
 
-        OpenflowVersion ofVersion = OpenflowVersion.get(version);
-
         if (msg instanceof MultipartReplyMessage) {
             MultipartReplyMessage mpReply = (MultipartReplyMessage) msg;
-            NodeId node = SinglePurposeMultipartReplyTranslator.nodeIdFromDatapathId(datapathId);
+            OpenflowVersion ofVersion = OpenflowVersion.get(version);
+            NodeId node = nodeIdFromDatapathId(datapathId);
+            VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(version);
+            data.setDatapathId(datapathId);
 
-            translateFlow(listDataObject, mpReply, node, ofVersion, datapathId);
+            translateFlow(listDataObject, mpReply, node, data);
             translateAggregate(listDataObject, mpReply, node);
             translatePortStats(listDataObject, mpReply, node, ofVersion, datapathId);
-            translateGroup(listDataObject, mpReply, node);
-            translateGroupDesc(listDataObject, mpReply, node, ofVersion);
+            translateGroup(listDataObject, mpReply, node, data);
+            translateGroupDesc(listDataObject, mpReply, node, data);
             translateGroupFeatures(listDataObject, mpReply, node);
-            translateMeter(listDataObject, mpReply, node);
-            translateMeterConfig(listDataObject, mpReply, node);
+            translateMeter(listDataObject, mpReply, node, data);
+            translateMeterConfig(listDataObject, mpReply, node, data);
             translateMeterFeatures(listDataObject, mpReply, node);
             translateTable(listDataObject, mpReply, node);
             translateQueue(listDataObject, mpReply, node, ofVersion, datapathId);
@@ -136,11 +142,9 @@ public class SinglePurposeMultipartReplyTranslator {
         return listDataObject;
     }
 
-    private static void translateFlow(final List<DataObject> listDataObject,
-                                      final MultipartReplyMessage mpReply,
-                                      final NodeId node,
-                                      final OpenflowVersion ofVersion,
-                                      final BigInteger datapathId) {
+    private void translateFlow(final List<DataObject> listDataObject,
+                               final MultipartReplyMessage mpReply,
+                               final NodeId node, VersionDatapathIdConvertorData data) {
         if (!MultipartType.OFPMPFLOW.equals(mpReply.getType())) {
             return;
         }
@@ -151,14 +155,17 @@ public class SinglePurposeMultipartReplyTranslator {
         message.setTransactionId(generateTransactionId(mpReply.getXid()));
         MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpReply.getMultipartReplyBody();
         MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
-        message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats(), datapathId, ofVersion));
+        final Optional<List<FlowAndStatisticsMapList>> flowAndStatisticsMapLists =
+                convertorExecutor.convert(replyBody.getFlowStats(), data);
+
+        message.setFlowAndStatisticsMapList(flowAndStatisticsMapLists.orElse(Collections.emptyList()));
 
         listDataObject.add(message.build());
     }
 
-    private static void translateAggregate(final List<DataObject> listDataObject,
-                                           final MultipartReplyMessage mpReply,
-                                           final NodeId node) {
+    private void translateAggregate(final List<DataObject> listDataObject,
+                                    final MultipartReplyMessage mpReply,
+                                    final NodeId node) {
         if (!MultipartType.OFPMPAGGREGATE.equals(mpReply.getType())) {
             return;
         }
@@ -177,11 +184,11 @@ public class SinglePurposeMultipartReplyTranslator {
         listDataObject.add(message.build());
     }
 
-    private static void translatePortStats(final List<DataObject> listDataObject,
-                                           final MultipartReplyMessage mpReply,
-                                           final NodeId node,
-                                           final OpenflowVersion ofVersion,
-                                           final BigInteger datapathId) {
+    private void translatePortStats(final List<DataObject> listDataObject,
+                                    final MultipartReplyMessage mpReply,
+                                    final NodeId node,
+                                    final OpenflowVersion ofVersion,
+                                    final BigInteger datapathId) {
         if (!MultipartType.OFPMPPORTSTATS.equals(mpReply.getType())) {
             return;
         }
@@ -240,9 +247,10 @@ public class SinglePurposeMultipartReplyTranslator {
         listDataObject.add(message.build());
     }
 
-    private static void translateGroup(final List<DataObject> listDataObject,
-                                       final MultipartReplyMessage mpReply,
-                                       final NodeId node) {
+    private void translateGroup(final List<DataObject> listDataObject,
+                                final MultipartReplyMessage mpReply,
+                                final NodeId node,
+                                final VersionDatapathIdConvertorData data) {
         if (!MultipartType.OFPMPGROUP.equals(mpReply.getType())) {
             return;
         }
@@ -253,15 +261,18 @@ public class SinglePurposeMultipartReplyTranslator {
         message.setTransactionId(generateTransactionId(mpReply.getXid()));
         MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) mpReply.getMultipartReplyBody();
         MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
-        message.setGroupStats(groupStatsConvertor.toSALGroupStatsList(replyBody.getGroupStats()));
+        final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(
+                replyBody.getGroupStats(), data);
+
+        message.setGroupStats(groupStatsList.orElse(Collections.emptyList()));
 
         listDataObject.add(message.build());
     }
 
-    private static void translateGroupDesc(final List<DataObject> listDataObject,
-                                           final MultipartReplyMessage mpReply,
-                                           final NodeId node,
-                                           final OpenflowVersion ofVersion) {
+    private void translateGroupDesc(final List<DataObject> listDataObject,
+                                    final MultipartReplyMessage mpReply,
+                                    final NodeId node,
+                                    final VersionDatapathIdConvertorData data) {
         if (!MultipartType.OFPMPGROUPDESC.equals(mpReply.getType())) {
             return;
         }
@@ -273,14 +284,17 @@ public class SinglePurposeMultipartReplyTranslator {
         MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase) mpReply.getMultipartReplyBody();
         MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
 
-        message.setGroupDescStats(groupStatsConvertor.toSALGroupDescStatsList(replyBody.getGroupDesc(), ofVersion));
+        final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(
+                replyBody.getGroupDesc(), data);
+
+        message.setGroupDescStats(groupDescStatsList.orElse(Collections.emptyList()));
 
         listDataObject.add(message.build());
     }
 
-    private static void translateGroupFeatures(final List<DataObject> listDataObject,
-                                               final MultipartReplyMessage mpReply,
-                                               final NodeId node) {
+    private void translateGroupFeatures(final List<DataObject> listDataObject,
+                                        final MultipartReplyMessage mpReply,
+                                        final NodeId node) {
         if (!MultipartType.OFPMPGROUPFEATURES.equals(mpReply.getType())) {
             return;
         }
@@ -331,9 +345,10 @@ public class SinglePurposeMultipartReplyTranslator {
         listDataObject.add(message.build());
     }
 
-    private static void translateMeter(final List<DataObject> listDataObject,
-                                       final MultipartReplyMessage mpReply,
-                                       final NodeId node) {
+    private void translateMeter(final List<DataObject> listDataObject,
+                                final MultipartReplyMessage mpReply,
+                                final NodeId node,
+                                final VersionDatapathIdConvertorData data) {
         if (!MultipartType.OFPMPMETER.equals(mpReply.getType())) {
             return;
         }
@@ -345,14 +360,18 @@ public class SinglePurposeMultipartReplyTranslator {
 
         MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
         MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
-        message.setMeterStats(meterStatsConvertor.toSALMeterStatsList(replyBody.getMeterStats()));
+        final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats>> meterStatsList =
+                convertorExecutor.convert(replyBody.getMeterStats(), data);
+
+        message.setMeterStats(meterStatsList.orElse(Collections.emptyList()));
 
         listDataObject.add(message.build());
     }
 
-    private static void translateMeterConfig(final List<DataObject> listDataObject,
-                                             final MultipartReplyMessage mpReply,
-                                             final NodeId node) {
+    private void translateMeterConfig(final List<DataObject> listDataObject,
+                                      final MultipartReplyMessage mpReply,
+                                      final NodeId node,
+                                      final VersionDatapathIdConvertorData data) {
         if (!MultipartType.OFPMPMETERCONFIG.equals(mpReply.getType())) {
             return;
         }
@@ -364,12 +383,14 @@ public class SinglePurposeMultipartReplyTranslator {
 
         MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
         MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
-        message.setMeterConfigStats(meterStatsConvertor.toSALMeterConfigList(replyBody.getMeterConfig()));
+        final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
+
+        message.setMeterConfigStats(meterConfigStatsList.orElse(Collections.emptyList()));
 
         listDataObject.add(message.build());
     }
 
-    private static void translateMeterFeatures(final List<DataObject> listDataObject,
+    private void translateMeterFeatures(final List<DataObject> listDataObject,
                                                final MultipartReplyMessage mpReply,
                                                final NodeId node) {
         if (!MultipartType.OFPMPMETERFEATURES.equals(mpReply.getType())) {
@@ -419,7 +440,7 @@ public class SinglePurposeMultipartReplyTranslator {
         listDataObject.add(message.build());
     }
 
-    private static void translateTable(final List<DataObject> listDataObject,
+    private void translateTable(final List<DataObject> listDataObject,
                                        final MultipartReplyMessage mpReply,
                                        final NodeId node) {
         if (!MultipartType.OFPMPTABLE.equals(mpReply.getType())) {
@@ -450,7 +471,7 @@ public class SinglePurposeMultipartReplyTranslator {
         listDataObject.add(message.build());
     }
 
-    private static void translateQueue(final List<DataObject> listDataObject,
+    private void translateQueue(final List<DataObject> listDataObject,
                                        final MultipartReplyMessage mpReply,
                                        final NodeId node,
                                        final OpenflowVersion ofVersion,
index 8fe6bb4b52edaa197a903d0ae4586addbb745671..b34e9529ed2bec2bbb7c8a8f517a092f969ad9ce 100644 (file)
@@ -40,6 +40,7 @@ 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,6 +57,7 @@ class StatisticsContextImpl implements StatisticsContext {
     private final ListenableFuture<Boolean> emptyFuture;
     private final boolean shuttingDownStatisticsPolling;
     private final Object COLLECTION_STAT_TYPE_LOCK = new Object();
+    private final SinglePurposeMultipartReplyTranslator multipartReplyTranslator;
     @GuardedBy("COLLECTION_STAT_TYPE_LOCK")
     private List<MultipartType> collectingStatType;
 
@@ -66,13 +68,14 @@ class StatisticsContextImpl implements StatisticsContext {
     private volatile boolean schedulingEnabled;
     private volatile CONTEXT_STATE contextState;
 
-    StatisticsContextImpl(@CheckForNull final DeviceInfo deviceInfo, final boolean shuttingDownStatisticsPolling, final LifecycleConductor lifecycleConductor) {
+    StatisticsContextImpl(@CheckForNull final DeviceInfo deviceInfo, final boolean shuttingDownStatisticsPolling, final LifecycleConductor lifecycleConductor, final ConvertorExecutor convertorExecutor) {
         this.deviceContext = Preconditions.checkNotNull(lifecycleConductor.getDeviceContext(deviceInfo));
         this.devState = Preconditions.checkNotNull(deviceContext.getDeviceState());
         this.shuttingDownStatisticsPolling = shuttingDownStatisticsPolling;
+        multipartReplyTranslator = new SinglePurposeMultipartReplyTranslator(convertorExecutor);
         emptyFuture = Futures.immediateFuture(false);
         statisticsGatheringService = new StatisticsGatheringService(this, deviceContext);
-        statisticsGatheringOnTheFlyService = new StatisticsGatheringOnTheFlyService(this, deviceContext);
+        statisticsGatheringOnTheFlyService = new StatisticsGatheringOnTheFlyService(this, deviceContext, convertorExecutor);
         itemLifeCycleListener = new ItemLifecycleListenerImpl(deviceContext);
         statListForCollectingInitialization();
         contextState = CONTEXT_STATE.WORKING;
@@ -289,7 +292,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPFLOW*/ multipartType,
                 deviceContext,
                 deviceContext,
-                initial) : emptyFuture;
+                initial, multipartReplyTranslator) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectTableStatistics(final MultipartType multipartType) {
@@ -299,7 +302,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPTABLE*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false) : emptyFuture;
+                false, multipartReplyTranslator) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectPortStatistics(final MultipartType multipartType) {
@@ -309,7 +312,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPPORTSTATS*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false) : emptyFuture;
+                false, multipartReplyTranslator) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectQueueStatistics(final MultipartType multipartType) {
@@ -319,7 +322,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPQUEUE*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false);
+                false, multipartReplyTranslator);
     }
 
     private ListenableFuture<Boolean> collectGroupDescStatistics(final MultipartType multipartType) {
@@ -329,7 +332,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPGROUPDESC*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false) : emptyFuture;
+                false, multipartReplyTranslator) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectGroupStatistics(final MultipartType multipartType) {
@@ -339,7 +342,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPGROUP*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false) : emptyFuture;
+                false, multipartReplyTranslator) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectMeterConfigStatistics(final MultipartType multipartType) {
@@ -349,7 +352,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPMETERCONFIG*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false) : emptyFuture;
+                false, multipartReplyTranslator) : emptyFuture;
     }
 
     private ListenableFuture<Boolean> collectMeterStatistics(final MultipartType multipartType) {
@@ -359,7 +362,7 @@ class StatisticsContextImpl implements StatisticsContext {
                 /*MultipartType.OFPMPMETER*/ multipartType,
                 deviceContext,
                 deviceContext,
-                false) : emptyFuture;
+                false, multipartReplyTranslator) : emptyFuture;
     }
 
     @VisibleForTesting
index ea0a7c6f4d653e73a710af25073284298ef8674b..b47dfee91359d53c4d2708f326e923585be30420 100644 (file)
@@ -119,7 +119,6 @@ public final class StatisticsGatheringUtils {
     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();
     private static final String QUEUE2_REQCTX = "QUEUE2REQCTX-";
 
     private StatisticsGatheringUtils() {
@@ -132,7 +131,8 @@ public final class StatisticsGatheringUtils {
                                                       final MultipartType type,
                                                       final TxFacade txFacade,
                                                       final DeviceRegistry registry,
-                                                      final Boolean initial) {
+                                                      final Boolean initial,
+                                                      final SinglePurposeMultipartReplyTranslator multipartReplyTranslator) {
         EventIdentifier wholeProcessEventIdentifier = null;
         if (MultipartType.OFPMPFLOW.equals(type)) {
             wholeProcessEventIdentifier = new EventIdentifier(type.toString(), deviceInfo.getNodeId().getValue());
@@ -142,7 +142,7 @@ public final class StatisticsGatheringUtils {
         final ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
                 JdkFutureAdapters.listenInPoolThread(statisticsGatheringService.getStatisticsOfType(
                         ofpQueuToRequestContextEventIdentifier, type));
-        return transformAndStoreStatisticsData(statisticsDataInFuture, deviceInfo, wholeProcessEventIdentifier, type, txFacade, registry, initial);
+        return transformAndStoreStatisticsData(statisticsDataInFuture, deviceInfo, wholeProcessEventIdentifier, type, txFacade, registry, initial, multipartReplyTranslator);
     }
 
     private static ListenableFuture<Boolean> transformAndStoreStatisticsData(final ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture,
@@ -151,7 +151,8 @@ public final class StatisticsGatheringUtils {
                                                                              final MultipartType type,
                                                                              final TxFacade txFacade,
                                                                              final DeviceRegistry registry,
-                                                                             final boolean initial) {
+                                                                             final boolean initial,
+                                                                             final SinglePurposeMultipartReplyTranslator multipartReplyTranslator) {
         return Futures.transform(statisticsDataInFuture, new AsyncFunction<RpcResult<List<MultipartReply>>, Boolean>() {
             @Nullable
             @Override
@@ -169,7 +170,7 @@ public final class StatisticsGatheringUtils {
 
                         try {
                             for (final MultipartReply singleReply : rpcResult.getResult()) {
-                                final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
+                                final List<? extends DataObject> multipartDataList = multipartReplyTranslator.translate(
                                         deviceInfo.getDatapathId(),
                                         deviceInfo.getVersion(), singleReply);
                                 multipartData = multipartDataList.get(0);
index 8aa3c7aa537d248bc8b58a1cb78991f180fc450b..8386755c855c15468c8efa4406a6ba2c2fd2573b 100644 (file)
@@ -40,6 +40,7 @@ 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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;
@@ -56,6 +57,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class);
 
     private static final long DEFAULT_STATS_TIMEOUT_SEC = 50L;
+    private final ConvertorExecutor convertorExecutor;
 
     private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
     private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
@@ -80,7 +82,9 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
 
     public StatisticsManagerImpl(@CheckForNull final RpcProviderRegistry rpcProviderRegistry,
                                  final boolean shuttingDownStatisticsPolling,
-                                 final LifecycleConductor lifecycleConductor) {
+                                 final LifecycleConductor lifecycleConductor,
+                                 final ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
         Preconditions.checkArgument(rpcProviderRegistry != null);
         this.controlServiceRegistration = Preconditions.checkNotNull(rpcProviderRegistry.addRpcImplementation(
                 StatisticsManagerControlService.class, this));
@@ -93,7 +97,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
 
         final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
 
-        final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceInfo, shuttingDownStatisticsPolling, conductor);
+        final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceInfo, shuttingDownStatisticsPolling, conductor, convertorExecutor);
         Verify.verify(contexts.putIfAbsent(deviceInfo, statisticsContext) == null, "StatisticsCtx still not closed for Node {}", deviceInfo.getNodeId());
 
         deviceInitPhaseHandler.onDeviceContextLevelUp(deviceInfo);
index d49c00b6966fe3b60935089b2ae5602f6925da8b..caa24be942bf1815b0351f75e5f3f0900c86b4e7 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
@@ -33,10 +34,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public final class AllFlowsInAllTablesService extends AbstractCompatibleStatService<GetAllFlowsStatisticsFromAllFlowTablesInput,
         GetAllFlowsStatisticsFromAllFlowTablesOutput, FlowsStatisticsUpdate> {
     private final MultipartRequestFlowCase flowCase;
+    private final ConvertorExecutor convertorExecutor;
 
     public AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
-                                      final AtomicLong compatibilityXidSeed) {
+                                      final AtomicLong compatibilityXidSeed, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
 
         final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
         final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
@@ -67,6 +70,6 @@ public final class AllFlowsInAllTablesService extends AbstractCompatibleStatServ
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId, convertorExecutor);
     }
 }
index cdd22569049220317bedb11bf974bbbdf9eea2b3..d7a4af5da35782cbb5dfb4c6c5dcf9b38b5cc39a 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
@@ -34,10 +35,12 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAllFlowStatisticsFromFlowTableInput,
         GetAllFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
 
+    private final ConvertorExecutor convertorExecutor;
     private Function<? super RpcResult<List<MultipartReply>>, FlowsStatisticsUpdate> transformer;
 
-    public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -72,6 +75,6 @@ public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAll
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> mpResult, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceInfo(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceInfo(), getOfVersion(), emulatedTxId, convertorExecutor);
     }
 }
index 5cf5db31ef1f61fb106178fa1185ffdf59181234..4c563dde03196afba06de62ea70049daa8863dfe 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.GroupStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
@@ -45,9 +46,12 @@ final class AllGroupsStatsService extends
         GROUP_CASE = caseBuilder.build();
     }
 
+    private final ConvertorExecutor convertorExecutor;
 
-    public AllGroupsStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+
+    public AllGroupsStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
     }
 
 
@@ -71,6 +75,6 @@ final class AllGroupsStatsService extends
 
     @Override
     public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), emulatedTxId);
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), emulatedTxId, convertorExecutor);
     }
 }
index 1fc57caca09c4873ada8a46c069e2dfc8f819405..19768808addff4e38b2a971e62894b6599adcb73 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -16,7 +17,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
@@ -40,7 +42,6 @@ final class AllMeterConfigStatsService
         extends AbstractCompatibleStatService<GetAllMeterConfigStatisticsInput, GetAllMeterConfigStatisticsOutput, MeterConfigStatsUpdated> {
 
     private static final MultipartRequestMeterConfigCase METER_CONFIG_CASE;
-    private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
 
 
     static {
@@ -54,8 +55,13 @@ final class AllMeterConfigStatsService
         METER_CONFIG_CASE = caseBuilder.build();
     }
 
-    public AllMeterConfigStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    private final ConvertorExecutor convertorExecutor;
+    private final VersionConvertorData data;
+
+    public AllMeterConfigStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
+        data = new VersionConvertorData(getVersion());
     }
 
     @Override
@@ -81,10 +87,14 @@ final class AllMeterConfigStatsService
         for (MultipartReply mpReply : result) {
             MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
             MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
-            message.getMeterConfigStats().addAll(meterStatsConvertor.toSALMeterConfigList(replyBody.getMeterConfig()));
 
+            final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
+
+            if (meterConfigStatsList.isPresent()) {
+                message.getMeterConfigStats().addAll(meterConfigStatsList.get());
+            }
         }
 
         return message.build();
     }
-}
+}
\ No newline at end of file
index aae79faed6afe89965b3c65df720cd0fad6d2af2..2c47f1ec58c6109ef97eb8f6eab2042db9a16c7e 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.MeterStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
@@ -46,8 +47,11 @@ final class AllMeterStatsService
         METER_CASE = caseBuilder.build();
     }
 
-    public AllMeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    private final ConvertorExecutor convertorExecutor;
+
+    public AllMeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -65,6 +69,6 @@ final class AllMeterStatsService
 
     @Override
     public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId, convertorExecutor);
     }
 }
index 70b458daaa3084d42b8e6c87564aaf6a9f2d8ca5..1bf30f6650d1106f00bc9e61c0ce7bc745db437a 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
@@ -32,8 +33,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public final class FlowsInTableService extends AbstractCompatibleStatService<GetFlowStatisticsFromFlowTableInput,
         GetFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
 
-    public FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    private final ConvertorExecutor convertorExecutor;
+
+    public FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -73,8 +77,7 @@ public final class FlowsInTableService extends AbstractCompatibleStatService<Get
 
         // convert and inject match
         final short version = getVersion();
-        MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
-                getDeviceInfo().getDatapathId());
+        MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder, convertorExecutor);
 
         // Set request body to main multipart request
         multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
@@ -92,6 +95,6 @@ public final class FlowsInTableService extends AbstractCompatibleStatService<Get
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId, convertorExecutor);
     }
 }
index bb6c9f7b5318d9bd466e58ffc1180a2ef4ce3fb6..1858309ae3298e7ac7d71694c2c842fed900347b 100644 (file)
@@ -9,13 +9,15 @@ package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
 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.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
@@ -35,11 +37,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 final class GroupDescriptionService
         extends AbstractCompatibleStatService<GetGroupDescriptionInput, GetGroupDescriptionOutput, GroupDescStatsUpdated> {
     private static final MultipartRequestGroupDescCase GROUP_DESC_CASE = new MultipartRequestGroupDescCaseBuilder().build();
-    private final GroupStatsResponseConvertor groupStatsResponseConvertor;
+    private final ConvertorExecutor convertorExecutor;
 
-    public GroupDescriptionService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    public GroupDescriptionService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
-        groupStatsResponseConvertor = new GroupStatsResponseConvertor();
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -63,11 +65,17 @@ final class GroupDescriptionService
         notification.setTransactionId(emulatedTxId);
 
         notification.setGroupDescStats(new ArrayList<GroupDescStats>());
+        final VersionConvertorData data = new VersionConvertorData(getVersion());
+
         for (MultipartReply mpReply : result) {
             MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase) mpReply.getMultipartReplyBody();
             MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
-            notification.getGroupDescStats().addAll(
-                    groupStatsResponseConvertor.toSALGroupDescStatsList(replyBody.getGroupDesc(), getOfVersion()));
+            final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(
+                    replyBody.getGroupDesc(), data);
+
+            if (groupDescStatsList.isPresent()) {
+                notification.getGroupDescStats().addAll(groupDescStatsList.get());
+            }
         }
 
         return notification.build();
index 77ec5014cc1ff689413de02781d333f9eaae81d0..edb78d16ce31c3a2fdf82cdbd0a659adc3e711ec 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.GroupStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
@@ -31,8 +32,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 final class GroupStatsService
         extends AbstractCompatibleStatService<GetGroupStatisticsInput, GetGroupStatisticsOutput, GroupStatisticsUpdated> {
 
-    public GroupStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    private final ConvertorExecutor convertorExecutor;
+
+    public GroupStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -56,6 +60,6 @@ final class GroupStatsService
 
     @Override
     public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), emulatedTxId);
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), emulatedTxId, convertorExecutor);
     }
 }
index 6456c89fad3b0bcc0d6731a984766f1063f9769a..5e013172047008dabc9cb64c02043388ff3f2a9d 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
@@ -25,8 +26,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 
 final class MatchingFlowsInTableService extends AbstractMultipartService<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput> {
 
-    public MatchingFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    private final ConvertorExecutor convertorExecutor;
+
+    public MatchingFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -60,7 +64,7 @@ final class MatchingFlowsInTableService extends AbstractMultipartService<GetAggr
             mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
         }
 
-        MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder, getDatapathId());
+        MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder, convertorExecutor);
 
         FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
 
index 841adf203903edf7c5bceb7df119f0c193bd8544..d7c0ec0209bc29cb66467cb3c5ebf9937826e82a 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.MeterStatisticsToNotificationTransformer;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
@@ -31,8 +32,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 final class MeterStatsService
         extends AbstractCompatibleStatService<GetMeterStatisticsInput, GetMeterStatisticsOutput, MeterStatisticsUpdated> {
 
-    public MeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    private final ConvertorExecutor convertorExecutor;
+
+    public MeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.convertorExecutor = convertorExecutor;
     }
 
     @Override
@@ -57,6 +61,6 @@ final class MeterStatsService
 
     @Override
     public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId);
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceInfo(), getOfVersion(), emulatedTxId, convertorExecutor);
     }
 }
index d028ad976cb9734697e9ca1be0edd8f0eb34d1f6..3ab8c8b21af044805919b78706c1ffe4a54fbefe 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
@@ -86,13 +87,13 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
     private OpendaylightFlowStatisticsService delegate;
 
     public static OpendaylightFlowStatisticsServiceImpl createWithOook(final RequestContextStack requestContextStack,
-                                                              final DeviceContext deviceContext) {
-        return new OpendaylightFlowStatisticsServiceImpl(requestContextStack, deviceContext, deviceContext.oook());
+                                                              final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
+        return new OpendaylightFlowStatisticsServiceImpl(requestContextStack, deviceContext, deviceContext.oook(), convertorExecutor);
     }
 
     public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
-                                                 final TranslatorLibrary translatorLibrary) {
-        matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext);
+                                                 final TranslatorLibrary translatorLibrary, final ConvertorExecutor convertorExecutor) {
+        matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext, convertorExecutor);
         this.translatorLibrary = translatorLibrary;
     }
 
index 28eaa8f0230280206590e1c6ae55688e70a31906..b428aa7182992b1128d1601db6d45bfa2ba7f7fe 100644 (file)
@@ -12,6 +12,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
@@ -35,12 +36,13 @@ public class OpendaylightGroupStatisticsServiceImpl implements OpendaylightGroup
 
     public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
                                                   final AtomicLong compatibilityXidSeed,
-                                                  final NotificationPublishService notificationPublishService) {
+                                                  final NotificationPublishService notificationPublishService,
+                                                  final ConvertorExecutor convertorExecutor) {
         this.notificationPublishService = notificationPublishService;
-        allGroups = new AllGroupsStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
-        groupDesc = new GroupDescriptionService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allGroups = new AllGroupsStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
+        groupDesc = new GroupDescriptionService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
         groupFeat = new GroupFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
-        groupStats = new GroupStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        groupStats = new GroupStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
     }
 
     @Override
index 22f74d27672f5eea4c5bb0a9134a640085e1dc8e..4087e88282ccbb1f57d61c74f54b35862cb98763 100644 (file)
@@ -12,6 +12,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
@@ -33,13 +34,14 @@ public class OpendaylightMeterStatisticsServiceImpl implements OpendaylightMeter
     public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack,
                                                   final DeviceContext deviceContext,
                                                   final AtomicLong compatibilityXidSeed,
-                                                  final NotificationPublishService notificationPublishService) {
+                                                  final NotificationPublishService notificationPublishService,
+                                                  final ConvertorExecutor convertorExecutor) {
         this.notificationPublishService = notificationPublishService;
 
-        allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
-        allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
+        allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
         meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
-        meterStats = new MeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        meterStats = new MeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
     }
 
     @Override
index c3e2a91c828995e311f8c71cf52fc3f4915749b0..3b4605959d78766195a3d083855f5ac4357c3906 100644 (file)
@@ -11,9 +11,11 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 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.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
@@ -27,20 +29,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * pulled out flow stats to notification transformation
  */
 public class FlowStatisticsToNotificationTransformer {
-
-    private static FlowStatsResponseConvertor flowStatsConvertor = new FlowStatsResponseConvertor();
-
     /**
      * @param mpResult      raw multipart response from device
      * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
+     * @param convertorExecutor
      * @return notification containing flow stats
      */
     public static FlowsStatisticsUpdate transformToNotification(final List<MultipartReply> mpResult,
                                                                 final DeviceInfo deviceInfo,
                                                                 final OpenflowVersion ofVersion,
-                                                                final TransactionId emulatedTxId) {
+                                                                final TransactionId emulatedTxId,
+                                                                final ConvertorExecutor convertorExecutor) {
+        final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(ofVersion.getVersion());
+        data.setDatapathId(deviceInfo.getDatapathId());
         final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
         final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
         notification.setId(deviceInfo.getNodeId());
@@ -53,11 +56,13 @@ public class FlowStatisticsToNotificationTransformer {
 
             MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpRawReply.getMultipartReplyBody();
             MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
-            List<FlowAndStatisticsMapList> outStatsItem = flowStatsConvertor.toSALFlowStatsList(
-                    replyBody.getFlowStats(),
-                    deviceInfo.getDatapathId(),
-                    ofVersion);
-            statsList.addAll(outStatsItem);
+            final Optional<List<FlowAndStatisticsMapList>> outStatsItem =
+                    convertorExecutor.convert(replyBody.getFlowStats(), data);
+
+
+            if (outStatsItem.isPresent()) {
+                statsList.addAll(outStatsItem.get());
+            }
         }
 
         return notification.build();
index 5df1440ec25dbc89c66741d593d661ad94735c55..39bbfeb6d40193ec13ee6ddfc4cb47bd73153730 100644 (file)
@@ -10,8 +10,10 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder;
@@ -24,19 +26,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * pulled out group stats to notification transformation
  */
 public class GroupStatisticsToNotificationTransformer {
-
-    private static GroupStatsResponseConvertor groupStatsConvertor = new GroupStatsResponseConvertor();
-
     /**
      * @param mpReplyList   raw multipart response from device
      * @param deviceInfo   device state
      * @param emulatedTxId
+     * @param convertorExecutor
      * @return notification containing flow stats
      */
     public static GroupStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList,
                                                                  final DeviceInfo deviceInfo,
-                                                                 final TransactionId emulatedTxId) {
+                                                                 final TransactionId emulatedTxId,
+                                                                 final ConvertorExecutor convertorExecutor) {
 
+        VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
         GroupStatisticsUpdatedBuilder notification = new GroupStatisticsUpdatedBuilder();
         notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
@@ -47,7 +49,12 @@ public class GroupStatisticsToNotificationTransformer {
         for (MultipartReply mpReply : mpReplyList) {
             MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) mpReply.getMultipartReplyBody();
             MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
-            notification.getGroupStats().addAll(groupStatsConvertor.toSALGroupStatsList(replyBody.getGroupStats()));
+            final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(
+                    replyBody.getGroupStats(), data);
+
+            if (groupStatsList.isPresent()) {
+                notification.getGroupStats().addAll(groupStatsList.get());
+            }
         }
         return notification.build();
     }
index f4f09234fb4b7a08e311145e5cd151a76b18af1d..375fd6687274dbf033365bc1e3423ae3a1d1591a 100644 (file)
@@ -10,9 +10,11 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder;
@@ -26,20 +28,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class MeterStatisticsToNotificationTransformer {
 
-    private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
-
     /**
      * @param mpReplyList   raw multipart response from device
      * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
+     * @param convertorExecutor
      * @return notification containing flow stats
      */
     public static MeterStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList,
                                                                  final DeviceInfo deviceInfo,
                                                                  final OpenflowVersion ofVersion,
-                                                                 final TransactionId emulatedTxId) {
+                                                                 final TransactionId emulatedTxId,
+                                                                 final ConvertorExecutor convertorExecutor) {
 
+        VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
         MeterStatisticsUpdatedBuilder notification = new MeterStatisticsUpdatedBuilder();
         notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
@@ -49,7 +52,11 @@ public class MeterStatisticsToNotificationTransformer {
         for (MultipartReply mpReply : mpReplyList) {
             MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
             MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
-            notification.getMeterStats().addAll(meterStatsConvertor.toSALMeterStatsList(replyBody.getMeterStats()));
+            final Optional<List<MeterStats>> meterStatsList = convertorExecutor.convert(replyBody.getMeterStats(), data);
+
+            if (meterStatsList.isPresent()) {
+                notification.getMeterStats().addAll(meterStatsList.get());
+            }
         }
 
         return notification.build();
index 199afcaccbf4f04ef4a2c6a817ddafbc43b1b9de..afd42d2e0f544f4c6ac4bd05e84ee824a24d79cf 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsIn
 import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInAllTablesService;
 import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInTableService;
 import org.opendaylight.openflowplugin.impl.statistics.services.FlowsInTableService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
@@ -47,12 +48,13 @@ public class OpendaylightFlowStatisticsServiceDelegateImpl implements Opendaylig
     public OpendaylightFlowStatisticsServiceDelegateImpl(final RequestContextStack requestContextStack,
                                                          final DeviceContext deviceContext,
                                                          final NotificationPublishService notificationService,
-                                                         final AtomicLong compatibilityXidSeed) {
+                                                         final AtomicLong compatibilityXidSeed,
+                                                         final ConvertorExecutor convertorExecutor) {
         this.notificationService = notificationService;
         aggregateFlowsInTable = AggregateFlowsInTableService.createWithOook(requestContextStack, deviceContext, compatibilityXidSeed);
-        allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext, compatibilityXidSeed);
-        allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
-        flowsInTable = new FlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
+        allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
+        flowsInTable = new FlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed, convertorExecutor);
     }
 
     /**
index 60f7b03f29dcfcd03314392bcfbeae6534f7e372..1ba77a309bc04dfa0264a4c4df0dfdea41221875 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Stati
 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartOnTheFlyService;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -32,8 +33,8 @@ public class StatisticsGatheringOnTheFlyService extends AbstractMultipartOnTheFl
 
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringOnTheFlyService.class);
 
-    public StatisticsGatheringOnTheFlyService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+    public StatisticsGatheringOnTheFlyService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
+        super(requestContextStack, deviceContext, convertorExecutor);
     }
 
     @Override
index 9c200a990a90e0277ed149f0fad0ce1eba8ad837..156c34a0cdefab96376ef45eca564ceb75084fb0 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.StoreStatsGrouping;
 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;
@@ -67,18 +68,25 @@ public abstract class AbstractDirectStatisticsService<I extends StoreStatsGroupi
             };
 
     private final MultipartType multipartType;
+    private final ConvertorExecutor convertorExecutor;
     private final OpenflowVersion ofVersion = OpenflowVersion.get(getVersion());
-
     /**
      * Instantiates a new Abstract direct statistics service.
      *
      * @param multipartType       the multipart type
      * @param requestContextStack the request context stack
      * @param deviceContext       the device context
+     * @param convertorExecutor
      */
-    protected AbstractDirectStatisticsService(MultipartType multipartType, RequestContextStack requestContextStack, DeviceContext deviceContext) {
+    protected AbstractDirectStatisticsService(MultipartType multipartType, RequestContextStack requestContextStack,
+                                              DeviceContext deviceContext, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext);
         this.multipartType = multipartType;
+        this.convertorExecutor = convertorExecutor;
+    }
+
+    protected ConvertorExecutor getConvertorExecutor() {
+        return convertorExecutor;
     }
 
     /**
index 66c8a93679c9d90334477205c4e5bb16f2fd60ef..81d8b887aa357e0d120f07cd7f3ab8fb35f61ae5 100644 (file)
@@ -10,13 +10,15 @@ package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput;
@@ -47,16 +49,18 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * The Flow direct statistics service.
  */
 public class FlowDirectStatisticsService extends AbstractDirectStatisticsService<GetFlowStatisticsInput, GetFlowStatisticsOutput> {
-    private final FlowStatsResponseConvertor flowStatsConvertor = new FlowStatsResponseConvertor();
+    private final VersionDatapathIdConvertorData data;
 
     /**
      * Instantiates a new Flow direct statistics service.
-     *
-     * @param requestContextStack the request context stack
+     *  @param requestContextStack the request context stack
      * @param deviceContext       the device context
+     * @param convertorExecutor
      */
-    public FlowDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(MultipartType.OFPMPFLOW, requestContextStack, deviceContext);
+    public FlowDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext, ConvertorExecutor convertorExecutor) {
+        super(MultipartType.OFPMPFLOW, requestContextStack, deviceContext, convertorExecutor);
+        data = new VersionDatapathIdConvertorData(getVersion());
+        data.setDatapathId(getDatapathId());
     }
 
     @Override
@@ -93,7 +97,7 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
             mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
         }
 
-        MatchReactor.getInstance().convert(input.getMatch(), getVersion(), mprFlowRequestBuilder, getDatapathId());
+        MatchReactor.getInstance().convert(input.getMatch(), getVersion(), mprFlowRequestBuilder, getConvertorExecutor());
 
         return new MultipartRequestFlowCaseBuilder()
                 .setMultipartRequestFlow(mprFlowRequestBuilder.build())
@@ -108,17 +112,19 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
             for (final MultipartReply mpReply : input) {
                 final MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpReply.getMultipartReplyBody();
                 final MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
-
-                final List<FlowAndStatisticsMapList> statsListPart = flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats(), getDatapathId(), getOfVersion());
-
-                for (final FlowAndStatisticsMapList part : statsListPart) {
-                    final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId flowId =
-                            new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId(generateFlowId(part).getValue());
-
-                    statsList.add(new FlowAndStatisticsMapListBuilder(part)
-                            .setKey(new FlowAndStatisticsMapListKey(flowId))
-                            .setFlowId(flowId)
-                            .build());
+                final Optional<List<FlowAndStatisticsMapList>> statsListPart = getConvertorExecutor().convert(
+                        replyBody.getFlowStats(), data);
+
+                if (statsListPart.isPresent()) {
+                    for (final FlowAndStatisticsMapList part : statsListPart.get()) {
+                        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId flowId =
+                                new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId(generateFlowId(part).getValue());
+
+                        statsList.add(new FlowAndStatisticsMapListBuilder(part)
+                                .setKey(new FlowAndStatisticsMapListKey(flowId))
+                                .setFlowId(flowId)
+                                .build());
+                    }
                 }
             }
         }
index 75579a18c0ac606a678083ad6b5f6df50e3a12cc..9a4925c8a95a42bcd2a3e0ff285130d22543cc9b 100644 (file)
@@ -10,11 +10,13 @@ package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutputBuilder;
@@ -39,16 +41,17 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * The Group direct statistics service.
  */
 public class GroupDirectStatisticsService extends AbstractDirectStatisticsService<GetGroupStatisticsInput, GetGroupStatisticsOutput> {
-    private final GroupStatsResponseConvertor groupStatsConvertor = new GroupStatsResponseConvertor();
+    private final VersionConvertorData data;
 
     /**
      * Instantiates a new Group direct statistics service.
-     *
-     * @param requestContextStack the request context stack
+     *  @param requestContextStack the request context stack
      * @param deviceContext       the device context
+     * @param convertorExecutor
      */
-    public GroupDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(MultipartType.OFPMPGROUP, requestContextStack, deviceContext);
+    public GroupDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext, ConvertorExecutor convertorExecutor) {
+        super(MultipartType.OFPMPGROUP, requestContextStack, deviceContext, convertorExecutor);
+        data = new VersionConvertorData(getVersion());
     }
 
     @Override
@@ -74,7 +77,12 @@ public class GroupDirectStatisticsService extends AbstractDirectStatisticsServic
             for (final MultipartReply mpReply : input) {
                 final MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) mpReply.getMultipartReplyBody();
                 final MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
-                groupStats.addAll(groupStatsConvertor.toSALGroupStatsList(replyBody.getGroupStats()));
+                final Optional<List<GroupStats>> groupStatsList = getConvertorExecutor().convert(
+                        replyBody.getGroupStats(), data);
+
+                if (groupStatsList.isPresent()) {
+                    groupStats.addAll(groupStatsList.get());
+                }
             }
         }
 
index 55e0fab0cc7bddfa8483901168506c97d9693cf2..1e1146d711812a82ce309700502015a97d12242a 100644 (file)
@@ -10,11 +10,13 @@ package org.opendaylight.openflowplugin.impl.statistics.services.direct;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutputBuilder;
@@ -39,16 +41,17 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * The Meter direct statistics service.
  */
 public class MeterDirectStatisticsService extends AbstractDirectStatisticsService<GetMeterStatisticsInput, GetMeterStatisticsOutput> {
-    private final MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
+    private final VersionConvertorData data;
 
     /**
      * Instantiates a new Meter direct statistics service.
-     *
-     * @param requestContextStack the request context stack
+     *  @param requestContextStack the request context stack
      * @param deviceContext       the device context
+     * @param convertorExecutor
      */
-    public MeterDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(MultipartType.OFPMPMETER, requestContextStack, deviceContext);
+    public MeterDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext, ConvertorExecutor convertorExecutor) {
+        super(MultipartType.OFPMPMETER, requestContextStack, deviceContext, convertorExecutor);
+        data = new VersionConvertorData(getVersion());
     }
 
     @Override
@@ -74,7 +77,11 @@ public class MeterDirectStatisticsService extends AbstractDirectStatisticsServic
             for (final MultipartReply mpReply : input) {
                 final MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
                 final MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
-                meterStats.addAll(meterStatsConvertor.toSALMeterStatsList(replyBody.getMeterStats()));
+                final Optional<List<MeterStats>> meterStatsList = getConvertorExecutor().convert(replyBody.getMeterStats(), data);
+
+                if (meterStatsList.isPresent()) {
+                    meterStats.addAll(meterStatsList.get());
+                }
             }
         }
 
index 6f8017100a3ddb02496b6645911ca3053df6d52b..2efa1cf3493e30c410f9c94c763eef68b22ab3fb 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput;
@@ -48,12 +49,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 public class NodeConnectorDirectStatisticsService extends AbstractDirectStatisticsService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput> {
     /**
      * Instantiates a new Node connector direct statistics service.
-     *
-     * @param requestContextStack the request context stack
+     *  @param requestContextStack the request context stack
      * @param deviceContext       the device context
+     * @param convertorExecutor
      */
-    public NodeConnectorDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(MultipartType.OFPMPPORTSTATS, requestContextStack, deviceContext);
+    public NodeConnectorDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext, ConvertorExecutor convertorExecutor) {
+        super(MultipartType.OFPMPPORTSTATS, requestContextStack, deviceContext, convertorExecutor);
     }
 
     @Override
index dd0d136c6504c619cf8870e0b69695b7812d320e..9ebbece5865bceeca47d9aa8c1b5d8ba91aef369 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
@@ -51,12 +52,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 public class QueueDirectStatisticsService extends AbstractDirectStatisticsService<GetQueueStatisticsInput, GetQueueStatisticsOutput> {
     /**
      * Instantiates a new Queue direct statistics service.
-     *
-     * @param requestContextStack the request context stack
+     *  @param requestContextStack the request context stack
      * @param deviceContext       the device context
+     * @param convertorExecutor
      */
-    public QueueDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(MultipartType.OFPMPQUEUE, requestContextStack, deviceContext);
+    public QueueDirectStatisticsService(RequestContextStack requestContextStack, DeviceContext deviceContext, ConvertorExecutor convertorExecutor) {
+        super(MultipartType.OFPMPQUEUE, requestContextStack, deviceContext, convertorExecutor);
     }
 
     @Override
index c5683d2ebc171a071b446bbae668efa65be1a9e5..eb9ff12296554045022cffdf270f6c08fc0be45f 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.openflowplugin.impl.translator;
 
+import java.util.Optional;
 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;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 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;
@@ -21,6 +22,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions)
  */
 public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
+    private final ConvertorExecutor convertorExecutor;
+
+    public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
+
+    protected ConvertorExecutor getConvertorExecutor() {
+        return convertorExecutor;
+    }
 
     @Override
     public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceInfo deviceInfo, Object connectionDistinguisher) {
@@ -35,8 +45,14 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
     }
 
     protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
-        return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
-                deviceInfo.getDatapathId(), OpenflowVersion.OF13);
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
+        datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId());
+
+        final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(
+                flowRemoved.getMatch(),
+                datapathIdConvertorData);
+
+        return matchBuilderOptional.orElse(new MatchBuilder());
     }
 
     /**
index e5904310c5288618b29f0a8529834a91d5391fd0..997321dfac858abe94f6898d68eaf64017e94f6b 100644 (file)
@@ -8,9 +8,10 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
+import java.util.Optional;
 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
 
@@ -19,10 +20,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class FlowRemovedV10Translator extends FlowRemovedTranslator {
 
+    public FlowRemovedV10Translator(ConvertorExecutor convertorExecutor) {
+        super(convertorExecutor);
+    }
+
     @Override
     protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
-        return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
-                deviceInfo.getDatapathId(), OpenflowVersion.OF10);
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
+        datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId());
+
+        final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(
+                flowRemoved.getMatchV10(),
+                datapathIdConvertorData);
+
+        return matchBuilderOptional.orElse(new MatchBuilder());
     }
 
     /**
@@ -33,6 +44,6 @@ public class FlowRemovedV10Translator extends FlowRemovedTranslator {
      */
     @Override
     protected Short translateTableId(FlowRemoved flowRemoved) {
-        return Short.valueOf((short)0);
+        return (short) 0;
     }
 }
index 9b5f76069f1d38d303bf27c4365ad7d6335be526..f37474da379e7a25ec342c6dd0f0f6dcc87d4c6a 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import com.google.common.annotations.VisibleForTesting;
 import java.math.BigInteger;
+import java.util.Optional;
 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;
@@ -17,11 +18,11 @@ import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.impl.util.NodeConnectorRefToPortTranslator;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 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.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;
@@ -32,6 +33,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Table
  * Created by tkubas on 4/1/15.
  */
 public class PacketReceivedTranslator implements MessageTranslator<PacketInMessage, PacketReceived> {
+    private final ConvertorExecutor convertorExecutor;
+
+    public PacketReceivedTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
+
     @Override
     public PacketReceived translate(final PacketInMessage input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
 
@@ -72,18 +79,25 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
     }
 
     @VisibleForTesting
-    static org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
-        Match match = MatchConvertorImpl.fromOFMatchToSALMatch(input.getMatch(),
-                datapathId,
-                OpenflowVersion.get(input.getVersion().shortValue())).build();
-        MatchBuilder matchBuilder = new MatchBuilder(match);
+    org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
+        datapathIdConvertorData.setDatapathId(datapathId);
 
-        AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap =
+        final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
+        final MatchBuilder matchBuilder = matchOptional.isPresent() ?
+                new MatchBuilder(matchOptional.get().build()) :
+                new MatchBuilder();
+
+        final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap =
                 MatchExtensionHelper.processAllExtensions(
-                        input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion().shortValue()), MatchPath.PACKETRECEIVED_MATCH);
+                        input.getMatch().getMatchEntry(),
+                        OpenflowVersion.get(input.getVersion()),
+                        MatchPath.PACKETRECEIVED_MATCH);
+
         if (matchExtensionWrap != null) {
             matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
         }
+
         return matchBuilder.build();
     }
 }
index ec8930f4730d725a3983c57a0ed408af917a6ea9..ab7d8a6ce1f9f46314b484f08cad33c07e3bb056 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.openflowplugin.impl.common.NodeStaticReplyTranslatorUtil
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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.FlowCapableNodeConnector;
@@ -93,9 +94,10 @@ public class DeviceInitializationUtils {
      *
      * @param deviceContext
      * @param switchFeaturesMandatory
+     * @param convertorExecutor
      * @return future - recommended to have blocking call for this future
      */
-    public static ListenableFuture<Void> initializeNodeInformation(final DeviceContext deviceContext, final boolean switchFeaturesMandatory) {
+    public static ListenableFuture<Void> initializeNodeInformation(final DeviceContext deviceContext, final boolean switchFeaturesMandatory, final ConvertorExecutor convertorExecutor) {
         Preconditions.checkArgument(deviceContext != null);
         final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
         final DeviceInfo deviceInfo = deviceContext.getDeviceInfo();
@@ -144,7 +146,7 @@ public class DeviceInitializationUtils {
             final Capabilities capabilities = connectionContext.getFeatures().getCapabilities();
             LOG.debug("Setting capabilities for device {}", deviceInfo.getNodeId());
             DeviceStateUtil.setDeviceStateBasedOnV13Capabilities(deviceState, capabilities);
-            deviceFeaturesFuture = createDeviceFeaturesForOF13(deviceContext, deviceState, switchFeaturesMandatory);
+            deviceFeaturesFuture = createDeviceFeaturesForOF13(deviceContext, switchFeaturesMandatory, convertorExecutor);
         } else {
             deviceFeaturesFuture = Futures.immediateFailedFuture(new ConnectionException("Unsupported version "
                     + version));
@@ -192,7 +194,7 @@ public class DeviceInitializationUtils {
     }
 
     private static ListenableFuture<List<RpcResult<List<MultipartReply>>>> createDeviceFeaturesForOF13(
-            final DeviceContext deviceContext, final DeviceState deviceState, final boolean switchFeaturesMandatory) {
+            final DeviceContext deviceContext, final boolean switchFeaturesMandatory, final ConvertorExecutor convertorExecutor) {
 
         final ListenableFuture<RpcResult<List<MultipartReply>>> replyDesc = getNodeStaticInfo(MultipartType.OFPMPDESC,
                 deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
@@ -205,32 +207,32 @@ public class DeviceInitializationUtils {
                             final RpcResult<List<MultipartReply>> rpcResult) throws Exception {
 
                         translateAndWriteReply(MultipartType.OFPMPDESC, deviceContext,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), rpcResult.getResult());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), rpcResult.getResult(), convertorExecutor);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyMeterFeature = getNodeStaticInfo(
                                 MultipartType.OFPMPMETERFEATURES, deviceContext,
                                 deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
                         createSuccessProcessingCallback(MultipartType.OFPMPMETERFEATURES, deviceContext,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyMeterFeature);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyMeterFeature, convertorExecutor);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyGroupFeatures = getNodeStaticInfo(
                                 MultipartType.OFPMPGROUPFEATURES, deviceContext,
                                 deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPGROUPFEATURES, deviceContext,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyGroupFeatures);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyGroupFeatures, convertorExecutor);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyTableFeatures = getNodeStaticInfo(
                                 MultipartType.OFPMPTABLEFEATURES, deviceContext,
                                 deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPTABLEFEATURES, deviceContext,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyTableFeatures);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyTableFeatures, convertorExecutor);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyPortDescription = getNodeStaticInfo(
                                 MultipartType.OFPMPPORTDESC, deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
                                 deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPPORTDESC, deviceContext,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyPortDescription);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyPortDescription, convertorExecutor);
                         if (switchFeaturesMandatory) {
                             return Futures.allAsList(Arrays.asList(replyMeterFeature, replyGroupFeatures,
                                     replyTableFeatures, replyPortDescription));
@@ -244,7 +246,8 @@ public class DeviceInitializationUtils {
     }
 
     static void translateAndWriteReply(final MultipartType type, final DeviceContext dContext,
-                                       final InstanceIdentifier<Node> nodeII, final Collection<MultipartReply> result) {
+                                       final InstanceIdentifier<Node> nodeII, final Collection<MultipartReply> result,
+                                       final ConvertorExecutor convertorExecutor) {
         try {
             for (final MultipartReply reply : result) {
                 final MultipartReplyBody body = reply.getMultipartReplyBody();
@@ -263,7 +266,7 @@ public class DeviceInitializationUtils {
                         final MultipartReplyTableFeatures tableFeaturesMP = ((MultipartReplyTableFeaturesCase) body)
                                 .getMultipartReplyTableFeatures();
                         final List<TableFeatures> tableFeatures = NodeStaticReplyTranslatorUtil
-                                .nodeTableFeatureTranslator(tableFeaturesMP);
+                                .nodeTableFeatureTranslator(tableFeaturesMP, dContext.getDeviceInfo().getVersion(), convertorExecutor);
                         for (final TableFeatures tableFeature : tableFeatures) {
                             final Short tableId = tableFeature.getTableId();
                             final KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII =
@@ -394,14 +397,15 @@ public class DeviceInitializationUtils {
 
     static void createSuccessProcessingCallback(final MultipartType type, final DeviceContext deviceContext,
                                                 final InstanceIdentifier<Node> nodeII,
-                                                final ListenableFuture<RpcResult<List<MultipartReply>>> requestContextFuture) {
+                                                final ListenableFuture<RpcResult<List<MultipartReply>>> requestContextFuture,
+                                                final ConvertorExecutor convertorExecutor) {
         Futures.addCallback(requestContextFuture, new FutureCallback<RpcResult<List<MultipartReply>>>() {
             @Override
             public void onSuccess(final RpcResult<List<MultipartReply>> rpcResult) {
                 final List<MultipartReply> result = rpcResult.getResult();
                 if (result != null) {
                     LOG.info("Static node {} info: {} collected", deviceContext.getDeviceInfo().getNodeId(), type);
-                    translateAndWriteReply(type, deviceContext, nodeII, result);
+                    translateAndWriteReply(type, deviceContext, nodeII, result, convertorExecutor);
                 } else {
                     final Iterator<RpcError> rpcErrorIterator = rpcResult.getErrors().iterator();
                     while (rpcErrorIterator.hasNext()) {
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/IntegerIpAddress.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/IntegerIpAddress.java
new file mode 100644 (file)
index 0000000..d4ae17c
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * 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.impl.util;
+
+/**
+ * 4B base + 4B mask wrapper
+ */
+public class IntegerIpAddress {
+
+    int ip;
+    int mask;
+
+    public IntegerIpAddress(final int ip, final int mask) {
+        this.ip = ip;
+        this.mask = mask;
+    }
+
+    public int getIp() {
+        return ip;
+    }
+
+    public int getMask() {
+        return mask;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchComparatorFactory.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchComparatorFactory.java
new file mode 100644 (file)
index 0000000..8c3b48e
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.util;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Provides comparator for comparing according to various {@link Match} attributes
+ *
+ */
+public final class MatchComparatorFactory {
+
+    private MatchComparatorFactory() {
+        // NOOP
+    }
+
+    private static final Collection<SimpleComparator<Match>> MATCH_COMPARATORS = new ArrayList<>();
+    static {
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createEthernet());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createIcmpv4());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createInPhyPort());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createInPort());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createIp());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createL3());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createL4());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createProtocolMatchFields());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createMetadata());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createNull());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createTunnel());
+        MATCH_COMPARATORS.add(MatchComparatorFactory.createVlan());
+    }
+
+    public static SimpleComparator<Match> createNull() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by whole object
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                return (statsMatch == null) == (storedMatch == null);
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createVlan() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by VLAN
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getVlanMatch() == null) {
+                    if (statsMatch.getVlanMatch() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getVlanMatch().equals(statsMatch.getVlanMatch())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createTunnel() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by tunnel
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getTunnel() == null) {
+                    if (statsMatch.getTunnel() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getTunnel().equals(statsMatch.getTunnel())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createProtocolMatchFields() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by protocol fields
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getProtocolMatchFields() == null) {
+                    if (statsMatch.getProtocolMatchFields() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getProtocolMatchFields().equals(statsMatch.getProtocolMatchFields())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createMetadata() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by metadata
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getMetadata() == null) {
+                    if (statsMatch.getMetadata() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getMetadata().equals(statsMatch.getMetadata())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createL4() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by layer4
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getLayer4Match() == null) {
+                    if (statsMatch.getLayer4Match() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getLayer4Match().equals(statsMatch.getLayer4Match())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createL3() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by layer3
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getLayer3Match() == null) {
+                    if (statsMatch.getLayer3Match() != null) {
+                        return false;
+                    }
+                } else if (!MatchComparatorHelper.layer3MatchEquals(statsMatch.getLayer3Match(), storedMatch.getLayer3Match())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createIp() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by Ip
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getIpMatch() == null) {
+                    if (statsMatch.getIpMatch() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getIpMatch().equals(statsMatch.getIpMatch())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createInPort() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by InPort
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getInPort() == null) {
+                    if (statsMatch.getInPort() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getInPort().equals(statsMatch.getInPort())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createInPhyPort() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by InPhyPort
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getInPhyPort() == null) {
+                    if (statsMatch.getInPhyPort() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getInPhyPort().equals(statsMatch.getInPhyPort())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createEthernet() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by Ethernet
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getEthernetMatch() == null) {
+                    if (statsMatch.getEthernetMatch() != null) {
+                        return false;
+                    }
+                } else if (!MatchComparatorHelper.ethernetMatchEquals(statsMatch.getEthernetMatch(), storedMatch.getEthernetMatch())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createIcmpv4() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Comparation by Icmpv4
+             */
+            @Override
+            public boolean areObjectsEqual(Match statsMatch, Match storedMatch) {
+                if (storedMatch == null) {
+                    return false;
+                }
+                if (storedMatch.getIcmpv4Match() == null) {
+                    if (statsMatch.getIcmpv4Match() != null) {
+                        return false;
+                    }
+                } else if (!storedMatch.getIcmpv4Match().equals(statsMatch.getIcmpv4Match())) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+    public static SimpleComparator<Match> createMatch() {
+        return new SimpleComparator<Match>() {
+            /**
+             * Compares flows by whole match
+             */
+            @Override
+            public boolean areObjectsEqual(final Match statsFlow, final Match storedFlow) {
+                if (statsFlow == null) {
+                    if (storedFlow != null) {
+                        return false;
+                    }
+                } else if (!compareMatches(statsFlow, storedFlow)) {
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
+
+
+    /**
+     * Explicit equals method to compare the 'match' for flows stored in the data-stores and flow fetched from the switch.
+     * Flow installation process has three steps
+     * 1) Store flow in config data store
+     * 2) and send it to plugin for installation
+     * 3) Flow gets installed in switch
+     *
+     * The flow user wants to install and what finally gets installed in switch can be slightly different.
+     * E.g, If user installs flow with src/dst ip=10.0.0.1/24, when it get installed in the switch
+     * src/dst ip will be changes to 10.0.0.0/24 because of netmask of 24. When statistics manager fetch
+     * stats it gets 10.0.0.0/24 rather then 10.0.0.1/24. Custom match takes care of by using masked ip
+     * while comparing two ip addresses.
+     *
+     * Sometimes when user don't provide few values that is required by flow installation request, like
+     * priority,hard timeout, idle timeout, cookies etc, plugin usages default values before sending
+     * request to the switch. So when statistics manager gets flow statistics, it gets the default value.
+     * But the flow stored in config data store don't have those defaults value. I included those checks
+     * in the customer flow/match equal function.
+     *
+     *
+     * @param statsMatch
+     * @param storedMatch
+     * @return
+     */
+    private static boolean compareMatches(final Match statsMatch, final Match storedMatch) {
+        if (statsMatch == storedMatch) {
+            return true;
+        }
+
+        for (SimpleComparator<Match> matchComp : MATCH_COMPARATORS) {
+            if (!matchComp.areObjectsEqual(statsMatch, storedMatch)) {
+                return false;
+            }
+        }
+        return true;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchComparatorHelper.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchComparatorHelper.java
new file mode 100644 (file)
index 0000000..16684ef
--- /dev/null
@@ -0,0 +1,646 @@
+/**
+ * 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.impl.util;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.net.InetAddresses;
+import com.google.common.primitives.UnsignedBytes;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.MacAddressFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author joe
+ * @author sai.marapareddy@gmail.com
+ *
+ */
+public class MatchComparatorHelper {
+
+    private static final Logger LOG = LoggerFactory.getLogger(MatchComparatorHelper.class);
+    private static final int DEFAULT_SUBNET = 32;
+    private static final int IPV4_MASK_LENGTH = 32;
+    private static final int SHIFT_OCTET_1 = 24;
+    private static final int SHIFT_OCTET_2 = 16;
+    private static final int SHIFT_OCTET_3 = 8;
+    private static final int SHIFT_OCTET_4 = 0;
+    private static final int POSITION_OCTET_1 = 0;
+    private static final int POSITION_OCTET_2 = 1;
+    private static final int POSITION_OCTET_3 = 2;
+    private static final int POSITION_OCTET_4 = 3;
+    private static final String DEFAULT_ARBITRARY_BIT_MASK = "255.255.255.255";
+    private static final String DEFAULT_IPV6_ARBITRARY_BIT_MASK = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff";
+    private static final String PREFIX_SEPARATOR = "/";
+    private static final int IPV4_ADDRESS_LENGTH = 32;
+    private static final int IPV6_ADDRESS_LENGTH = 128;
+    private static final int BYTE_SIZE = 8;
+
+    /*
+     * Custom EthernetMatch is required because mac address string provided by user in EthernetMatch can be in any case
+     * (upper or lower or mix). Ethernet Match which controller receives from switch is always an upper case string.
+     * Default EthernetMatch equals doesn't use equalsIgnoreCase() and hence it fails. E.g User provided mac address
+     * string in flow match is aa:bb:cc:dd:ee:ff and when controller fetch statistic data, openflow driver library
+     * returns AA:BB:CC:DD:EE:FF and default eqauls fails here.
+     */
+    @VisibleForTesting
+    static boolean ethernetMatchEquals(final EthernetMatch statsEthernetMatch, final EthernetMatch storedEthernetMatch) {
+        boolean verdict = true;
+        final Boolean checkNullValues = checkNullValues(statsEthernetMatch, storedEthernetMatch);
+        if (checkNullValues != null) {
+            verdict = checkNullValues;
+        } else {
+            verdict = ethernetMatchFieldsEquals(statsEthernetMatch.getEthernetSource(),
+                    storedEthernetMatch.getEthernetSource());
+            if (verdict) {
+                verdict = ethernetMatchFieldsEquals(statsEthernetMatch.getEthernetDestination(),
+                        storedEthernetMatch.getEthernetDestination());
+            }
+            if (verdict) {
+                if (statsEthernetMatch.getEthernetType() == null) {
+                    if (storedEthernetMatch.getEthernetType() != null) {
+                        verdict = false;
+                    }
+                } else {
+                    verdict = statsEthernetMatch.getEthernetType().equals(storedEthernetMatch.getEthernetType());
+                }
+            }
+        }
+        return verdict;
+    }
+
+    static boolean ethernetMatchFieldsEquals(final MacAddressFilter statsEthernetMatchFields,
+                                             final MacAddressFilter storedEthernetMatchFields) {
+        boolean verdict = true;
+        final Boolean checkNullValues = checkNullValues(statsEthernetMatchFields, storedEthernetMatchFields);
+        if (checkNullValues != null) {
+            verdict = checkNullValues;
+        } else {
+            verdict = macAddressEquals(statsEthernetMatchFields.getAddress(), storedEthernetMatchFields.getAddress());
+            if (verdict) {
+                verdict = macAddressEquals(statsEthernetMatchFields.getMask(), storedEthernetMatchFields.getMask());
+            }
+        }
+        return verdict;
+    }
+
+    static boolean macAddressEquals(final MacAddress statsMacAddress, final MacAddress storedMacAddress) {
+        boolean verdict = true;
+        final Boolean checkNullValues = checkNullValues(statsMacAddress, storedMacAddress);
+        if (checkNullValues != null) {
+            verdict = checkNullValues;
+        } else {
+            verdict = statsMacAddress.getValue().equalsIgnoreCase(storedMacAddress.getValue());
+        }
+        return verdict;
+    }
+
+    @VisibleForTesting
+    static boolean layer3MatchEquals(final Layer3Match statsLayer3Match, final Layer3Match storedLayer3Match) {
+        boolean verdict = true;
+        if (statsLayer3Match instanceof Ipv4Match && storedLayer3Match instanceof Ipv4Match) {
+            final Ipv4Match statsIpv4Match = (Ipv4Match) statsLayer3Match;
+            final Ipv4Match storedIpv4Match = (Ipv4Match) storedLayer3Match;
+            verdict = MatchComparatorHelper.compareIpv4PrefixNullSafe(storedIpv4Match.getIpv4Destination(),
+                    statsIpv4Match.getIpv4Destination());
+            if (verdict) {
+                verdict = MatchComparatorHelper.compareIpv4PrefixNullSafe(statsIpv4Match.getIpv4Source(),
+                        storedIpv4Match.getIpv4Source());
+            }
+        } else if (statsLayer3Match instanceof Ipv6Match && storedLayer3Match instanceof Ipv6Match) {
+            final Ipv6Match statsIpv6Match = (Ipv6Match) statsLayer3Match;
+            final Ipv6Match storedIpv6Match = (Ipv6Match) storedLayer3Match;
+            verdict = MatchComparatorHelper.compareIpv6PrefixNullSafe(storedIpv6Match.getIpv6Destination(),
+                    statsIpv6Match.getIpv6Destination());
+            if (verdict) {
+                verdict = MatchComparatorHelper.compareIpv6PrefixNullSafe(statsIpv6Match.getIpv6Source(),
+                        storedIpv6Match.getIpv6Source());
+            }
+        } else if (statsLayer3Match instanceof  Ipv4MatchArbitraryBitMask && storedLayer3Match instanceof Ipv4MatchArbitraryBitMask) {
+            // At this moment storedIpv4MatchArbitraryBitMask & statsIpv4MatchArbitraryBitMask will always have non null arbitrary masks.
+            // In case of no / null arbitrary mask, statsLayer3Match will be an instance of Ipv4Match.
+            // Eg:- stats -> 1.0.1.0/255.0.255.0  stored -> 1.1.1.0/255.0.255.0
+            final Ipv4MatchArbitraryBitMask statsIpv4MatchArbitraryBitMask= (Ipv4MatchArbitraryBitMask) statsLayer3Match;
+            final Ipv4MatchArbitraryBitMask storedIpv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) storedLayer3Match;
+            if ((storedIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask() != null |
+                    storedIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask() != null)) {
+                if (storedIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask() != null) {
+                    String storedDstIpAddress = normalizeIpv4Address(storedIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask(),
+                            storedIpv4MatchArbitraryBitMask.getIpv4DestinationArbitraryBitmask());
+                    String statsDstIpAddress = normalizeIpv4Address(statsIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask(),
+                            statsIpv4MatchArbitraryBitMask.getIpv4DestinationArbitraryBitmask());
+                    if (MatchComparatorHelper.compareStringNullSafe(storedIpv4MatchArbitraryBitMask.getIpv4DestinationArbitraryBitmask().getValue(),
+                            statsIpv4MatchArbitraryBitMask.getIpv4DestinationArbitraryBitmask().getValue())) {
+                        verdict = MatchComparatorHelper.compareStringNullSafe(storedDstIpAddress,
+                                statsDstIpAddress);
+                    } else {
+                        verdict = false;
+                        return verdict;
+                    }
+                }
+                if (storedIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask() != null) {
+                    String storedSrcIpAddress = normalizeIpv4Address(storedIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask()
+                            ,storedIpv4MatchArbitraryBitMask.getIpv4SourceArbitraryBitmask());
+                    String statsSrcIpAddress = normalizeIpv4Address(statsIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask()
+                            ,statsIpv4MatchArbitraryBitMask.getIpv4SourceArbitraryBitmask());
+                    if (MatchComparatorHelper.compareStringNullSafe(storedIpv4MatchArbitraryBitMask.getIpv4SourceArbitraryBitmask().getValue(),
+                            statsIpv4MatchArbitraryBitMask.getIpv4SourceArbitraryBitmask().getValue())) {
+                        verdict = MatchComparatorHelper.compareStringNullSafe(storedSrcIpAddress,
+                                statsSrcIpAddress);
+                    } else {
+                        verdict = false;
+                    }
+                }
+            } else {
+                final Boolean nullCheckOut = checkNullValues(storedLayer3Match, statsLayer3Match);
+                if (nullCheckOut != null) {
+                    verdict = nullCheckOut;
+                } else {
+                    verdict = storedLayer3Match.equals(statsLayer3Match);
+                }
+            }
+        } else if (statsLayer3Match instanceof Ipv4Match && storedLayer3Match instanceof Ipv4MatchArbitraryBitMask) {
+            // Here stored netmask is an instance of Ipv4MatchArbitraryBitMask, when it is pushed in to switch
+            // it automatically converts it in to cidr format in case of certain subnet masks ( consecutive ones or zeroes)
+            // Eg:- stats src/dest -> 1.1.1.0/24  stored src/dest -> 1.1.1.0/255.255.255.0
+            final Ipv4Match statsIpv4Match = (Ipv4Match) statsLayer3Match;
+            final Ipv4MatchArbitraryBitMask storedIpv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) storedLayer3Match;
+            if (storedIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask() != null) {
+                Ipv4Prefix ipv4PrefixDestination;
+                if (storedIpv4MatchArbitraryBitMask.getIpv4DestinationArbitraryBitmask() != null) {
+                    byte[] destByteMask = convertArbitraryMaskToByteArray(storedIpv4MatchArbitraryBitMask.getIpv4DestinationArbitraryBitmask());
+                    ipv4PrefixDestination = createPrefix(storedIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask(), destByteMask);
+                } else {
+                    ipv4PrefixDestination = createPrefix(storedIpv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask());
+                }
+                verdict = MatchComparatorHelper.compareIpv4PrefixNullSafe(ipv4PrefixDestination, statsIpv4Match.getIpv4Destination());
+                if (verdict == false) {
+                    return verdict;
+                }
+            }
+            if (storedIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask() != null) {
+                Ipv4Prefix ipv4PrefixSource;
+                if (storedIpv4MatchArbitraryBitMask.getIpv4SourceArbitraryBitmask() != null) {
+                    byte[] srcByteMask = convertArbitraryMaskToByteArray(storedIpv4MatchArbitraryBitMask.getIpv4SourceArbitraryBitmask());
+                    ipv4PrefixSource = createPrefix(storedIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask(), srcByteMask);
+                } else {
+                    ipv4PrefixSource = createPrefix(storedIpv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask());
+                }
+                verdict = MatchComparatorHelper.compareIpv4PrefixNullSafe(ipv4PrefixSource, statsIpv4Match.getIpv4Source());
+            }
+        } else if (statsLayer3Match instanceof Ipv6MatchArbitraryBitMask && storedLayer3Match instanceof Ipv6MatchArbitraryBitMask) {
+            // At this moment storedIpv6MatchArbitraryBitMask & statsIpv6MatchArbitraryBitMask will always have non null arbitrary masks.
+            // In case of no / null arbitrary mask, statsLayer3Match will be an instance of Ipv6Match.
+            // Eg:- stats src/dest  -> 2001:2001:2001:2001:2001:2001:2001:2001/FFFF:FFFF:FFFF:FFFF:0000:FFFF:FFFF:FFF0
+            //     stored src/dest  -> 2001:2001:2001:2001:2001:2001:2001:2001/FFFF:FFFF:FFFF:FFFF:0000:FFFF:FFFF:FFF0
+            final Ipv6MatchArbitraryBitMask statsIpv6MatchArbitraryBitMask= (Ipv6MatchArbitraryBitMask) statsLayer3Match;
+            final Ipv6MatchArbitraryBitMask storedIpv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) storedLayer3Match;
+            if ((storedIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask() != null |
+                    storedIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask() != null)) {
+                if (storedIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask() != null) {
+                    String storedDstIpAddress = normalizeIpv6Address(storedIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask(),
+                            storedIpv6MatchArbitraryBitMask.getIpv6DestinationArbitraryBitmask());
+                    String statsDstIpAddress = normalizeIpv6Address(statsIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask(),
+                            statsIpv6MatchArbitraryBitMask.getIpv6DestinationArbitraryBitmask());
+                    String storedDstMask = extractIpv6CanonicalForm(storedIpv6MatchArbitraryBitMask.
+                            getIpv6DestinationArbitraryBitmask().getValue()).getHostAddress();
+                    String statsDstMask = extractIpv6CanonicalForm(statsIpv6MatchArbitraryBitMask.
+                            getIpv6DestinationArbitraryBitmask().getValue()).getHostAddress();
+                    if (MatchComparatorHelper.compareStringNullSafe(storedDstMask,statsDstMask)) {
+                        verdict = MatchComparatorHelper.compareStringNullSafe(storedDstIpAddress,
+                                statsDstIpAddress);
+                    } else {
+                        verdict = false;
+                        return verdict;
+                    }
+                }
+                if (storedIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask() != null) {
+                    String storedSrcIpAddress = normalizeIpv6Address(storedIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask()
+                            ,storedIpv6MatchArbitraryBitMask.getIpv6SourceArbitraryBitmask());
+                    String statsSrcIpAddress = normalizeIpv6Address(statsIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask()
+                            ,statsIpv6MatchArbitraryBitMask.getIpv6SourceArbitraryBitmask());
+                    String storedSrcMask = extractIpv6CanonicalForm(storedIpv6MatchArbitraryBitMask.
+                            getIpv6SourceArbitraryBitmask().getValue()).getHostAddress();
+                    String statsSrcMask = extractIpv6CanonicalForm(statsIpv6MatchArbitraryBitMask.
+                            getIpv6SourceArbitraryBitmask().getValue()).getHostAddress();
+                    if (MatchComparatorHelper.compareStringNullSafe(storedSrcMask, statsSrcMask)) {
+                        verdict = MatchComparatorHelper.compareStringNullSafe(storedSrcIpAddress,
+                                statsSrcIpAddress);
+                    } else {
+                        verdict = false;
+                    }
+                }
+            } else {
+                final Boolean nullCheckOut = checkNullValues(storedLayer3Match, statsLayer3Match);
+                if (nullCheckOut != null) {
+                    verdict = nullCheckOut;
+                } else {
+                    verdict = storedLayer3Match.equals(statsLayer3Match);
+                }
+            }
+        } else if (statsLayer3Match instanceof Ipv6Match && storedLayer3Match instanceof Ipv6MatchArbitraryBitMask) {
+            // Here stored netmask is an instance of Ipv6MatchArbitraryBitMask, when it is pushed in to switch
+            // it automatically converts it in to cidr format in case of certain subnet masks ( consecutive ones or zeroes)
+            // Eg:- stats src/dest -> 2001:2001:2001:2001:2001:2001:2001:2001/124
+            // stored src/dest -> 2001:2001:2001:2001:2001:2001:2001:2001/FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFF0
+            final Ipv6Match statsIpv6Match = (Ipv6Match) statsLayer3Match;
+            final Ipv6MatchArbitraryBitMask storedIpv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) storedLayer3Match;
+            if (storedIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask() != null) {
+                Ipv6Prefix ipv6PrefixDestination;
+                if (storedIpv6MatchArbitraryBitMask.getIpv6DestinationArbitraryBitmask() != null) {
+                    byte[] destByteMask = convertIpv6ArbitraryMaskToByteArray(storedIpv6MatchArbitraryBitMask.getIpv6DestinationArbitraryBitmask());
+                    ipv6PrefixDestination = createPrefix(storedIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask(), destByteMask);
+                } else {
+                    ipv6PrefixDestination = createPrefix(storedIpv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask());
+                }
+                verdict = MatchComparatorHelper.compareIpv6PrefixNullSafe(ipv6PrefixDestination, statsIpv6Match.getIpv6Destination());
+                if (verdict == false) {
+                    return verdict;
+                }
+            }
+            if (storedIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask() != null) {
+                Ipv6Prefix ipv6PrefixSource;
+                if (storedIpv6MatchArbitraryBitMask.getIpv6SourceArbitraryBitmask() != null) {
+                    byte[] srcByteMask = convertIpv6ArbitraryMaskToByteArray(storedIpv6MatchArbitraryBitMask.getIpv6SourceArbitraryBitmask());
+                    ipv6PrefixSource = createPrefix(storedIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask(), srcByteMask);
+                } else {
+                    ipv6PrefixSource = createPrefix(storedIpv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask());
+                }
+                verdict = MatchComparatorHelper.compareIpv6PrefixNullSafe(ipv6PrefixSource, statsIpv6Match.getIpv6Source());
+            }
+        } else if (statsLayer3Match instanceof ArpMatch && storedLayer3Match instanceof ArpMatch) {
+            verdict = arpMatchEquals((ArpMatch)statsLayer3Match, (ArpMatch)storedLayer3Match);
+        } else {
+            final Boolean nullCheckOut = checkNullValues(storedLayer3Match, statsLayer3Match);
+            if (nullCheckOut != null) {
+                verdict = nullCheckOut;
+            } else {
+                verdict = storedLayer3Match.equals(statsLayer3Match);
+            }
+        }
+        return verdict;
+    }
+
+    static boolean arpMatchEquals(final ArpMatch statsArpMatch, final ArpMatch storedArpMatch) {
+
+        Integer statsOp = statsArpMatch.getArpOp();
+        Integer storedOp = storedArpMatch.getArpOp();
+
+        Boolean nullCheck = checkNullValues(statsOp, storedOp);
+        if (nullCheck != null) {
+            if (nullCheck == false) {
+                return false;
+            }
+        } else if (!statsOp.equals(storedOp)) {
+            return false;
+        }
+
+        Ipv4Prefix statsIp = statsArpMatch.getArpSourceTransportAddress();
+        Ipv4Prefix storedIp = storedArpMatch.getArpSourceTransportAddress();
+        if (!compareIpv4PrefixNullSafe(statsIp, storedIp)) {
+            return false;
+        }
+
+        statsIp = statsArpMatch.getArpTargetTransportAddress();
+        storedIp = storedArpMatch.getArpTargetTransportAddress();
+        if (!compareIpv4PrefixNullSafe(statsIp, storedIp)) {
+            return false;
+        }
+
+        MacAddressFilter statsMac = statsArpMatch.getArpSourceHardwareAddress();
+        MacAddressFilter storedMac = storedArpMatch.getArpSourceHardwareAddress();
+        if (!ethernetMatchFieldsEquals(statsMac, storedMac)) {
+            return false;
+        }
+
+        statsMac = statsArpMatch.getArpTargetHardwareAddress();
+        storedMac = storedArpMatch.getArpTargetHardwareAddress();
+        if (!ethernetMatchFieldsEquals(statsMac, storedMac)) {
+            return false;
+        }
+
+        return true;
+    }
+
+
+    /**
+     * TODO: why don't we use the default Ipv4Prefix.equals()?
+     *
+     * @param statsIpAddress
+     * @param storedIpAddress
+     * @return true if IPv4prefixes equals
+     */
+    static boolean IpAddressEquals(final Ipv4Prefix statsIpAddress, final Ipv4Prefix storedIpAddress) {
+        final IntegerIpAddress statsIpAddressInt = MatchComparatorHelper.strIpToIntIp(statsIpAddress.getValue());
+        final IntegerIpAddress storedIpAddressInt = MatchComparatorHelper.strIpToIntIp(storedIpAddress.getValue());
+
+        if (ipAndMaskBasedMatch(statsIpAddressInt, storedIpAddressInt)) {
+            return true;
+        }
+        if (ipBasedMatch(statsIpAddressInt, storedIpAddressInt)) {
+            return true;
+        }
+        return false;
+    }
+
+    static boolean ipAndMaskBasedMatch(final IntegerIpAddress statsIpAddressInt,
+                                       final IntegerIpAddress storedIpAddressInt) {
+        return ((statsIpAddressInt.getIp() & statsIpAddressInt.getMask()) == (storedIpAddressInt.getIp() & storedIpAddressInt
+                .getMask()));
+    }
+
+    static boolean ipBasedMatch(final IntegerIpAddress statsIpAddressInt, final IntegerIpAddress storedIpAddressInt) {
+        return (statsIpAddressInt.getIp() == storedIpAddressInt.getIp());
+    }
+
+
+    private static boolean IpAddressEquals(Ipv6Prefix statsIpv6, Ipv6Prefix storedIpv6) {
+        final String[] statsIpMask = statsIpv6.getValue().split("/");
+        final String[] storedIpMask = storedIpv6.getValue().split("/");
+        if (! (statsIpMask.length > 1 && storedIpMask.length > 1 &&  statsIpMask[1].equals(storedIpMask[1]))){
+            return false;
+        }
+
+        final int prefix = Integer.parseInt(statsIpMask[1]);
+        final int byteIndex = prefix/BYTE_SIZE;
+        final int lastByteBits = BYTE_SIZE - (prefix % BYTE_SIZE);
+        final InetAddress statsIp = InetAddresses.forString(statsIpMask[0]);
+        final InetAddress storedIp = InetAddresses.forString(storedIpMask[0]);
+        byte[] statsIpArr = Arrays.copyOfRange(statsIp.getAddress(),0,byteIndex+1);
+        byte[] storedIpArr = Arrays.copyOfRange(storedIp.getAddress(),0,byteIndex+1);
+        statsIpArr[byteIndex] = (byte) (statsIpArr[byteIndex] & (0XFF << lastByteBits));
+        storedIpArr[byteIndex] = (byte) (storedIpArr[byteIndex] & (0XFF << lastByteBits));
+        if(Arrays.equals(statsIpArr,storedIpArr)) {
+            return true;
+        }
+        return false;
+    }
+
+    static Boolean checkNullValues(final Object v1, final Object v2) {
+        Boolean verdict = null;
+        if (v1 == null && v2 != null) {
+            verdict = Boolean.FALSE;
+        } else if (v1 != null && v2 == null) {
+            verdict = Boolean.FALSE;
+        } else if (v1 == null && v2 == null) {
+            verdict = Boolean.TRUE;
+        }
+        return verdict;
+    }
+
+    static boolean compareIpv4PrefixNullSafe(final Ipv4Prefix statsIpv4, final Ipv4Prefix storedIpv4) {
+        boolean verdict = true;
+        final Boolean checkDestNullValuesOut = checkNullValues(storedIpv4, statsIpv4);
+        if (checkDestNullValuesOut != null) {
+            verdict = checkDestNullValuesOut;
+        } else if (!IpAddressEquals(statsIpv4, storedIpv4)) {
+            verdict = false;
+        }
+        return verdict;
+    }
+
+    static boolean compareStringNullSafe(final String stringA, final String stringB) {
+        boolean verdict = true;
+        final Boolean checkDestNullValuesOut = checkNullValues(stringA,stringB);
+        if (checkDestNullValuesOut != null) {
+            verdict = checkDestNullValuesOut;
+        } else if (!stringA.equals(stringB)) {
+            verdict = false;
+        }
+        return verdict;
+    }
+
+    private static boolean compareIpv6PrefixNullSafe(Ipv6Prefix statsIpv6, Ipv6Prefix storedIpv6) {
+        boolean verdict = true;
+        final Boolean checkDestNullValuesOut = checkNullValues(statsIpv6, storedIpv6);
+        if (checkDestNullValuesOut != null) {
+            verdict = checkDestNullValuesOut;
+        } else if (!IpAddressEquals(statsIpv6, storedIpv6)) {
+            verdict = false;
+        }
+        return verdict;
+    }
+
+    /**
+     * Method return integer version of ip address. Converted int will be mask if mask specified
+     */
+    static IntegerIpAddress strIpToIntIp(final String ipAddresss) {
+
+        final String[] parts = ipAddresss.split("/");
+        final String ip = parts[0];
+        int prefix;
+
+        if (parts.length < 2) {
+            prefix = DEFAULT_SUBNET;
+        } else {
+            prefix = Integer.parseInt(parts[1]);
+            if (prefix < 0 || prefix > IPV4_MASK_LENGTH) {
+                final StringBuilder stringBuilder = new StringBuilder(
+                        "Valid values for mask are from range 0 - 32. Value ");
+                stringBuilder.append(prefix);
+                stringBuilder.append(" is invalid.");
+                throw new IllegalStateException(stringBuilder.toString());
+            }
+        }
+
+        IntegerIpAddress integerIpAddress = null;
+
+        final Inet4Address addr = ((Inet4Address) InetAddresses.forString(ip));
+        final byte[] addrBytes = addr.getAddress();
+        // FIXME: what is meaning of anding with 0xFF? Probably could be removed.
+        final int ipInt = ((addrBytes[POSITION_OCTET_1] & 0xFF) << SHIFT_OCTET_1)
+                | ((addrBytes[POSITION_OCTET_2] & 0xFF) << SHIFT_OCTET_2)
+                | ((addrBytes[POSITION_OCTET_3] & 0xFF) << SHIFT_OCTET_3)
+                | ((addrBytes[POSITION_OCTET_4] & 0xFF) << SHIFT_OCTET_4);
+
+        // FIXME: Is this valid?
+        final int mask = 0xffffffff << DEFAULT_SUBNET - prefix;
+
+        integerIpAddress = new IntegerIpAddress(ipInt, mask);
+
+        return integerIpAddress;
+    }
+
+    static boolean isArbitraryBitMask(byte[] byteMask) {
+        if (byteMask == null) {
+            return false;
+        } else {
+            ArrayList<Integer> integerMaskArrayList = new ArrayList<Integer>();
+            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));
+            }
+            return checkArbitraryBitMask(integerMaskArrayList);
+        }
+    }
+
+    static boolean checkArbitraryBitMask(ArrayList<Integer> arrayList) {
+        if (arrayList.size()>0 && arrayList.size()< IPV4_MASK_LENGTH ) {
+            // checks 0*1* case - Leading zeros in arrayList are truncated
+            return true;
+        } else {
+            //checks 1*0*1 case
+            for(int i=0; i<arrayList.size()-1;i++) {
+                if(arrayList.get(i) ==0 && arrayList.get(i+1) == 1) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    static final byte[] convertArbitraryMaskToByteArray(DottedQuad mask) {
+        String maskValue;
+        if (mask.getValue() != null) {
+            maskValue  = mask.getValue();
+        } else {
+            maskValue = DEFAULT_ARBITRARY_BIT_MASK;
+        }
+        InetAddress maskInIpFormat = null;
+        try {
+            maskInIpFormat = InetAddress.getByName(maskValue);
+        } catch (UnknownHostException e) {
+            LOG.error("Failed to recognize the host while converting mask ", e);
+        }
+        byte[] bytes = maskInIpFormat.getAddress();
+        return bytes;
+    }
+
+    private static final byte[] convertIpv6ArbitraryMaskToByteArray ( final Ipv6ArbitraryMask mask) {
+        String maskValue;
+        if (mask.getValue() != null) {
+            maskValue = mask.getValue();
+        } else {
+            maskValue = DEFAULT_IPV6_ARBITRARY_BIT_MASK;
+        }
+        InetAddress maskInIpv6Format = null;
+        try {
+            maskInIpv6Format = InetAddress.getByName(maskValue);
+        } catch (UnknownHostException e) {
+            LOG.error("Failed to convert string mask value to ipv6 format ", e);
+        }
+        return maskInIpv6Format.getAddress();
+    }
+
+    static String normalizeIpv4Address(Ipv4Address ipAddress, DottedQuad netMask) {
+        String actualIpAddress="";
+        String[] netMaskParts = netMask.getValue().split("\\.");
+        String[] ipAddressParts = ipAddress.getValue().split("\\.");
+
+        for (int i=0; i<ipAddressParts.length;i++) {
+            int integerFormatIpAddress=Integer.parseInt(ipAddressParts[i]);
+            int integerFormatNetMask=Integer.parseInt(netMaskParts[i]);
+            int ipAddressPart=(integerFormatIpAddress) & (integerFormatNetMask);
+            actualIpAddress += ipAddressPart;
+            if (i != ipAddressParts.length -1 ) {
+                actualIpAddress = actualIpAddress+".";
+            }
+        }
+        return actualIpAddress;
+    }
+
+    private static String normalizeIpv6Address(final Ipv6Address ipAddress, final Ipv6ArbitraryMask netMask) {
+        byte[] ipAddressParts = convertIpv6ToBytes(ipAddress.getValue());
+        byte[] netMaskParts  = convertIpv6ToBytes(netMask.getValue());
+        byte[] actualIpv6Bytes = new byte[16];
+
+        for (int i=0; i<ipAddressParts.length;i++) {
+            byte ipAddressPart= (byte) (ipAddressParts[i] & netMaskParts[i]);
+            actualIpv6Bytes[i] = ipAddressPart;
+        }
+        InetAddress ipv6Address = null;
+        try {
+            ipv6Address = InetAddress.getByAddress(actualIpv6Bytes);
+        } catch (UnknownHostException e) {
+            LOG.error("Failed to recognize the host while normalizing IPv6 address from bytes ", e);
+        }
+        return ipv6Address.getHostAddress();
+    }
+
+    private static byte[] convertIpv6ToBytes(final String ipv6Address) {
+        return extractIpv6CanonicalForm(ipv6Address).getAddress();
+    }
+
+    private static InetAddress extractIpv6CanonicalForm(final String ipv6Address) {
+        InetAddress address = null;
+        try {
+            address = InetAddress.getByName(ipv6Address);
+        } catch (UnknownHostException e) {
+            LOG.error("Failed to recognize the host while converting IPv6 to bytes ", e);
+        }
+        return address;
+    }
+
+    static Ipv4Prefix createPrefix(final Ipv4Address ipv4Address, final byte [] bytemask){
+        return createPrefix(ipv4Address, String.valueOf(countBits(bytemask)));
+    }
+
+    private static Ipv6Prefix createPrefix(final Ipv6Address ipv6Address, final byte [] bytemask) {
+        return createPrefix(ipv6Address, String.valueOf(countBits(bytemask)));
+    }
+
+    private static Ipv6Prefix createPrefix(final Ipv6Address ipv6Address, final String mask) {
+        if (mask != null && !mask.isEmpty()) {
+            return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + mask);
+        } else {
+            return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + IPV6_ADDRESS_LENGTH);
+        }
+    }
+
+    private static Ipv6Prefix createPrefix(final Ipv6Address ipv6Address) {
+        return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + IPV6_ADDRESS_LENGTH);
+    }
+
+    static int countBits(final byte[] mask) {
+        int netmask = 0;
+        for (byte b : mask) {
+            netmask += Integer.bitCount(UnsignedBytes.toInt(b));
+        }
+        return netmask;
+    }
+
+    static Ipv4Prefix createPrefix(final Ipv4Address ipv4Address){
+        return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + IPV4_ADDRESS_LENGTH);
+    }
+
+    static Ipv4Prefix createPrefix(final Ipv4Address ipv4Address, final String mask){
+        /*
+         * Ipv4Address has already validated the address part of the prefix,
+         * It is mandated to comply to the same regexp as the address
+         * There is absolutely no point rerunning additional checks vs this
+         * Note - there is no canonical form check here!!!
+         */
+        if (null != mask && !mask.isEmpty()) {
+            return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + mask);
+        } else {
+            return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + IPV4_ADDRESS_LENGTH);
+        }
+    }
+}
index 71d1ddd5e7bfc7c8a0a5d888d468df58a9024195..25860087b9502466f46207623870b570fc4a48b6 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.openflowplugin.impl.util;
 
 import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
 import com.google.common.reflect.TypeToken;
 import java.util.concurrent.atomic.AtomicLong;
 import javax.annotation.CheckForNull;
@@ -45,6 +44,7 @@ import org.opendaylight.openflowplugin.impl.statistics.services.direct.NodeConne
 import org.opendaylight.openflowplugin.impl.statistics.services.direct.OpendaylightDirectStatisticsServiceImpl;
 import org.opendaylight.openflowplugin.impl.statistics.services.direct.OpendaylightDirectStatisticsServiceProvider;
 import org.opendaylight.openflowplugin.impl.statistics.services.direct.QueueDirectStatisticsService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SalEchoService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SalExperimenterMessageService;
@@ -80,21 +80,22 @@ public class MdSalRegistrationUtils {
 
     /**
      * Method registers all OF services for role {@link OfpRole#BECOMEMASTER}
-     *
-     * @param rpcContext    - registration processing is implemented in {@link RpcContext}
-     * @param deviceContext - every service needs {@link DeviceContext} as input parameter
+     *  @param rpcContext    - registration processing is implemented in {@link org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext}
+     * @param deviceContext - every service needs {@link org.opendaylight.openflowplugin.api.openflow.device.DeviceContext} as input parameter
+     * @param convertorExecutor
      */
     public static void registerServices(@CheckForNull final RpcContext rpcContext,
                                         @CheckForNull final DeviceContext deviceContext,
-                                        final ExtensionConverterProvider extensionConverterProvider) {
+                                        final ExtensionConverterProvider extensionConverterProvider,
+                                        final ConvertorExecutor convertorExecutor) {
         Preconditions.checkArgument(rpcContext != null);
         Preconditions.checkArgument(deviceContext != null);
 
         // create service instances
-        final SalFlowServiceImpl salFlowService = new SalFlowServiceImpl(rpcContext, deviceContext);
+        final SalFlowServiceImpl salFlowService = new SalFlowServiceImpl(rpcContext, deviceContext, convertorExecutor);
         final FlowCapableTransactionServiceImpl flowCapableTransactionService = new FlowCapableTransactionServiceImpl(rpcContext, deviceContext);
-        final SalGroupServiceImpl salGroupService = new SalGroupServiceImpl(rpcContext, deviceContext);
-        final SalMeterServiceImpl salMeterService = new SalMeterServiceImpl(rpcContext, deviceContext);
+        final SalGroupServiceImpl salGroupService = new SalGroupServiceImpl(rpcContext, deviceContext, convertorExecutor);
+        final SalMeterServiceImpl salMeterService = new SalMeterServiceImpl(rpcContext, deviceContext, convertorExecutor);
 
         // register routed service instances
         rpcContext.registerRpcServiceImplementation(SalEchoService.class, new SalEchoServiceImpl(rpcContext, deviceContext));
@@ -103,19 +104,19 @@ public class MdSalRegistrationUtils {
         rpcContext.registerRpcServiceImplementation(FlowCapableTransactionService.class, flowCapableTransactionService);
         rpcContext.registerRpcServiceImplementation(SalMeterService.class, salMeterService);
         rpcContext.registerRpcServiceImplementation(SalGroupService.class, salGroupService);
-        rpcContext.registerRpcServiceImplementation(SalTableService.class, new SalTableServiceImpl(rpcContext, deviceContext, deviceContext.getPrimaryConnectionContext().getNodeId()));
-        rpcContext.registerRpcServiceImplementation(SalPortService.class, new SalPortServiceImpl(rpcContext, deviceContext));
-        rpcContext.registerRpcServiceImplementation(PacketProcessingService.class, new PacketProcessingServiceImpl(rpcContext, deviceContext));
+        rpcContext.registerRpcServiceImplementation(SalTableService.class, new SalTableServiceImpl(rpcContext, deviceContext, convertorExecutor));
+        rpcContext.registerRpcServiceImplementation(SalPortService.class, new SalPortServiceImpl(rpcContext, deviceContext, convertorExecutor));
+        rpcContext.registerRpcServiceImplementation(PacketProcessingService.class, new PacketProcessingServiceImpl(rpcContext, deviceContext, convertorExecutor));
         rpcContext.registerRpcServiceImplementation(NodeConfigService.class, new NodeConfigServiceImpl(rpcContext, deviceContext));
-        rpcContext.registerRpcServiceImplementation(OpendaylightFlowStatisticsService.class, OpendaylightFlowStatisticsServiceImpl.createWithOook(rpcContext, deviceContext));
+        rpcContext.registerRpcServiceImplementation(OpendaylightFlowStatisticsService.class, OpendaylightFlowStatisticsServiceImpl.createWithOook(rpcContext, deviceContext, convertorExecutor));
 
         // Direct statistics gathering
         final OpendaylightDirectStatisticsServiceProvider statisticsProvider = new OpendaylightDirectStatisticsServiceProvider();
-        statisticsProvider.register(FlowDirectStatisticsService.class, new FlowDirectStatisticsService(rpcContext, deviceContext));
-        statisticsProvider.register(GroupDirectStatisticsService.class, new GroupDirectStatisticsService(rpcContext, deviceContext));
-        statisticsProvider.register(MeterDirectStatisticsService.class, new MeterDirectStatisticsService(rpcContext, deviceContext));
-        statisticsProvider.register(NodeConnectorDirectStatisticsService.class, new NodeConnectorDirectStatisticsService(rpcContext, deviceContext));
-        statisticsProvider.register(QueueDirectStatisticsService.class, new QueueDirectStatisticsService(rpcContext, deviceContext));
+        statisticsProvider.register(FlowDirectStatisticsService.class, new FlowDirectStatisticsService(rpcContext, deviceContext, convertorExecutor));
+        statisticsProvider.register(GroupDirectStatisticsService.class, new GroupDirectStatisticsService(rpcContext, deviceContext, convertorExecutor));
+        statisticsProvider.register(MeterDirectStatisticsService.class, new MeterDirectStatisticsService(rpcContext, deviceContext, convertorExecutor));
+        statisticsProvider.register(NodeConnectorDirectStatisticsService.class, new NodeConnectorDirectStatisticsService(rpcContext, deviceContext, convertorExecutor));
+        statisticsProvider.register(QueueDirectStatisticsService.class, new QueueDirectStatisticsService(rpcContext, deviceContext, convertorExecutor));
         rpcContext.registerRpcServiceImplementation(OpendaylightDirectStatisticsService.class, new OpendaylightDirectStatisticsServiceImpl(statisticsProvider));
 
         final SalFlatBatchServiceImpl salFlatBatchService = new SalFlatBatchServiceImpl(
@@ -158,13 +159,14 @@ public class MdSalRegistrationUtils {
     /**
      * Support deprecated statistic related services for backward compatibility. The only exception from deprecation is
      * the aggregated flow statistic with match criteria input.
-     *
-     * @param rpcContext
+     *  @param rpcContext
      * @param deviceContext
      * @param notificationPublishService
+     * @param convertorExecutor
      */
     public static void registerStatCompatibilityServices(final RpcContext rpcContext, final DeviceContext deviceContext,
-                                                         final NotificationPublishService notificationPublishService) {
+                                                         final NotificationPublishService notificationPublishService,
+                                                         final ConvertorExecutor convertorExecutor) {
 
         AtomicLong compatibilityXidSeed = new AtomicLong();
         // pickup low statistics service
@@ -173,16 +175,16 @@ public class MdSalRegistrationUtils {
         Preconditions.checkArgument(COMPOSITE_SERVICE_TYPE_TOKEN.isAssignableFrom(flowStatisticsService.getClass()));
         // attach delegate to flow statistics service (to cover all but aggregated stats with match filter input)
         final OpendaylightFlowStatisticsServiceDelegateImpl flowStatisticsDelegate =
-                new OpendaylightFlowStatisticsServiceDelegateImpl(rpcContext, deviceContext, notificationPublishService, new AtomicLong());
+                new OpendaylightFlowStatisticsServiceDelegateImpl(rpcContext, deviceContext, notificationPublishService, new AtomicLong(), convertorExecutor);
         ((Delegator<OpendaylightFlowStatisticsService>) flowStatisticsService).setDelegate(flowStatisticsDelegate);
 
         // register all statistics (deprecated) services
         rpcContext.registerRpcServiceImplementation(OpendaylightFlowTableStatisticsService.class,
                 new OpendaylightFlowTableStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService));
         rpcContext.registerRpcServiceImplementation(OpendaylightGroupStatisticsService.class,
-                new OpendaylightGroupStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService));
+                new OpendaylightGroupStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService, convertorExecutor));
         rpcContext.registerRpcServiceImplementation(OpendaylightMeterStatisticsService.class,
-                new OpendaylightMeterStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService));
+                new OpendaylightMeterStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService, convertorExecutor));
         rpcContext.registerRpcServiceImplementation(OpendaylightQueueStatisticsService.class,
                 new OpendaylightQueueStatisticsServiceImpl(rpcContext, deviceContext, compatibilityXidSeed, notificationPublishService));
         rpcContext.registerRpcServiceImplementation(OpendaylightPortStatisticsService.class,
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/SimpleComparator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/SimpleComparator.java
new file mode 100644 (file)
index 0000000..55583e9
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.util;
+
+public interface SimpleComparator<T> {
+
+    boolean areObjectsEqual(T obj1, T obj2);
+
+}
\ No newline at end of file
index dd02168d266ebced87f051cab04444426c14956d..8ec2c59c909a46c604996ee512c1b685b54459fe 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.openflowplugin.impl.translator.PacketReceivedTranslator;
 import org.opendaylight.openflowplugin.impl.translator.PortUpdateTranslator;
 import org.opendaylight.openflowplugin.impl.translator.TranslatorKeyFactory;
 import org.opendaylight.openflowplugin.impl.translator.TranslatorLibraryBuilder;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
@@ -35,23 +36,20 @@ public final class TranslatorLibraryUtil {
 
     private static final TranslatorKeyFactory of13TranslatorKeyFactory = new TranslatorKeyFactory(OFConstants.OFP_VERSION_1_3);
     private static final TranslatorKeyFactory of10TranslatorKeyFactory = new TranslatorKeyFactory(OFConstants.OFP_VERSION_1_0);
-    private static final TranslatorLibrary basicTranslatorLibrary;
 
-    static {
-        basicTranslatorLibrary = new TranslatorLibraryBuilder().
-                addTranslator(of13TranslatorKeyFactory.createTranslatorKey(PacketIn.class), new PacketReceivedTranslator()).
+    public static void injectBasicTranslatorLibrary(final TranslatorLibrarian librarian, final ConvertorExecutor convertorExecutor) {
+        final TranslatorLibrary basicTranslatorLibrary = new TranslatorLibraryBuilder().
+                addTranslator(of13TranslatorKeyFactory.createTranslatorKey(PacketIn.class), new PacketReceivedTranslator(convertorExecutor)).
                 addTranslator(of13TranslatorKeyFactory.createTranslatorKey(PortGrouping.class), new PortUpdateTranslator()).
                 addTranslator(of13TranslatorKeyFactory.createTranslatorKey(MultipartReplyAggregateCase.class), new AggregatedFlowStatisticsTranslator()).
-                addTranslator(of13TranslatorKeyFactory.createTranslatorKey(FlowRemoved.class), new FlowRemovedTranslator()).
-                addTranslator(of10TranslatorKeyFactory.createTranslatorKey(PacketIn.class), new PacketReceivedTranslator()).
+                addTranslator(of13TranslatorKeyFactory.createTranslatorKey(FlowRemoved.class), new FlowRemovedTranslator(convertorExecutor)).
+                addTranslator(of10TranslatorKeyFactory.createTranslatorKey(PacketIn.class), new PacketReceivedTranslator(convertorExecutor)).
                 addTranslator(of10TranslatorKeyFactory.createTranslatorKey(PortGrouping.class), new PortUpdateTranslator()).
                 addTranslator(of10TranslatorKeyFactory.createTranslatorKey(MultipartReplyAggregateCase.class), new AggregatedFlowStatisticsTranslator()).
-                addTranslator(of10TranslatorKeyFactory.createTranslatorKey(FlowRemoved.class), new FlowRemovedV10Translator()).
+                addTranslator(of10TranslatorKeyFactory.createTranslatorKey(FlowRemoved.class), new FlowRemovedV10Translator(convertorExecutor)).
 
                 build();
-    }
 
-    public static void setBasicTranslatorLibrary(final TranslatorLibrarian librarian) {
         librarian.setTranslatorLibrary(basicTranslatorLibrary);
     }
 }
index c1ba409b27d33a43966bf16ae1a67d2eb21912bc..99a1cf4ce51b11e4c21dd51b206262c63edb85ae 100644 (file)
@@ -38,6 +38,8 @@ 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.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -92,8 +94,9 @@ public class LifecycleConductorImplTest {
     @Before
     public void setUp() {
         nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
 
-        lifecycleConductor = new LifecycleConductorImpl(messageIntelligenceAgency);
+        lifecycleConductor = new LifecycleConductorImpl(messageIntelligenceAgency, convertorManager);
         lifecycleConductor.setSafelyManager(deviceManager);
         lifecycleConductor.setSafelyManager(statisticsManager);
         lifecycleConductor.setSafelyManager(rpcManager);
index 06faed2cb71d99d6ab3987b755c9e2fdb0192595..5294656ae910260724a271d7b306dac1502dbf17 100644 (file)
@@ -57,6 +57,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTermin
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
@@ -148,8 +150,9 @@ public class DeviceManagerImplTest {
 
         when(mockedWriteTransaction.submit()).thenReturn(mockedFuture);
 
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
         final DeviceManagerImpl deviceManager = new DeviceManagerImpl(mockedDataBroker,
-                TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA, false, barrierIntervalNanos, barrierCountLimit, lifecycleConductor, true);
+                TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA, false, barrierIntervalNanos, barrierCountLimit, lifecycleConductor, true, convertorManager);
 
         deviceManager.setDeviceInitializationPhaseHandler(deviceInitPhaseHandler);
         deviceManager.setDeviceTerminationPhaseHandler(deviceTerminationPhaseHandler);
index c86bc598f956a87e1a040ae786a0731a83340727..a085ce1e4cfb591c670a9b60aced993eef958abf 100644 (file)
@@ -44,6 +44,8 @@ import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKe
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntelligenceAgencyImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -128,6 +130,7 @@ public class MultipartRequestOnTheFlyCallbackTest {
         when(mockedDeviceState.deviceSynchronized()).thenReturn(true);
         when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId);
         when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
+        when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
 
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
         when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
@@ -148,9 +151,11 @@ public class MultipartRequestOnTheFlyCallbackTest {
                 //NOOP
             }
         };
+
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
         multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class,
                 mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceInfo,
-                mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext);
+                mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext, convertorManager);
     }
 
 
index 7647e5c3367aadadd079c52a0dbd7777d2a1211b..8438f009669999a14c185f9a37766842379e8e33 100644 (file)
@@ -15,6 +15,8 @@ import static org.mockito.Mockito.verify;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
@@ -45,7 +47,8 @@ public class PacketProcessingServiceImplTest extends ServiceMocking {
 
     @Override
     protected void setup() {
-        packetProcessingService = new PacketProcessingServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        packetProcessingService = new PacketProcessingServiceImpl(mockedRequestContextStack, mockedDeviceContext, convertorManager);
         pathToNodeconnector = KeyedInstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId("ofp-ut:123")))
                 .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("ofp-ut:123:1")));
index 6600c9e8a5ec0ab102e997dad54ed54643cd6335..89cbef6d7e49435b9e08035672bddc5fb532c03b 100644 (file)
@@ -38,6 +38,8 @@ import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -45,12 +47,16 @@ 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.flow.service.rev130819.AddFlowInput;
+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.RemoveFlowInput;
+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.UpdateFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
+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.UpdatedFlow;
+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.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -135,7 +141,8 @@ public class SalFlowServiceImplTest extends TestCase {
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
         when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
 
-        salFlowService = new SalFlowServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        salFlowService = new SalFlowServiceImpl(mockedRequestContextStack, mockedDeviceContext, convertorManager);
     }
 
     @Test
@@ -145,7 +152,11 @@ public class SalFlowServiceImplTest extends TestCase {
 
     @Test
     public void testAddFlowFailCallback() throws Exception {
-        AddFlowInput mockedAddFlowInput = createFlowMock(AddFlowInput.class);
+        AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         Mockito.doReturn(Futures.<RequestContext<Object>>immediateFailedFuture(new Exception("ut-failed-response")))
                 .when(requestContext).getFuture();
 
@@ -160,7 +171,10 @@ public class SalFlowServiceImplTest extends TestCase {
 
     @Test
     public void testRemoveFlowFailCallback() throws Exception {
-        RemoveFlowInput mockedRemoveFlowInput = createFlowMock(RemoveFlowInput.class);
+        RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder()
+                .setMatch(match)
+                .build();
+
         Mockito.doReturn(Futures.<RequestContext<Object>>immediateFailedFuture(new Exception("ut-failed-response")))
                 .when(requestContext).getFuture();
 
@@ -178,7 +192,11 @@ public class SalFlowServiceImplTest extends TestCase {
     }
 
     private void addFlow(final ItemLifecycleListener itemLifecycleListener) throws ExecutionException, InterruptedException {
-        AddFlowInput mockedAddFlowInput = createFlowMock(AddFlowInput.class);
+        AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         salFlowService.setItemLifecycleListener(itemLifecycleListener);
 
         mockingFlowRegistryLookup();
@@ -199,7 +217,10 @@ public class SalFlowServiceImplTest extends TestCase {
     }
 
     private void removeFlow(final ItemLifecycleListener itemLifecycleListener) throws Exception {
-        RemoveFlowInput mockedRemoveFlowInput = createFlowMock(RemoveFlowInput.class);
+        RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
 
         if (itemLifecycleListener != null) {
             salFlowService.setItemLifecycleListener(itemLifecycleListener);
@@ -227,14 +248,22 @@ public class SalFlowServiceImplTest extends TestCase {
     private void updateFlow(final ItemLifecycleListener itemLifecycleListener) throws Exception {
         UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
 
-        UpdatedFlow mockedUpdateFlow = createFlowMock(UpdatedFlow.class);
+        UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow);
 
         FlowRef mockedFlowRef = mock(FlowRef.class);
         Mockito.doReturn(TABLE_II.child(Flow.class, new FlowKey(new FlowId(DUMMY_FLOW_ID)))).when(mockedFlowRef).getValue();
         when(mockedUpdateFlowInput.getFlowRef()).thenReturn(mockedFlowRef);
 
-        OriginalFlow mockedOriginalFlow = createFlowMock(OriginalFlow.class);
+        OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow);
 
         if (itemLifecycleListener != null) {
@@ -266,10 +295,4 @@ public class SalFlowServiceImplTest extends TestCase {
         assertNotNull(addFlowOutputRpcResult);
         assertTrue(addFlowOutputRpcResult.isSuccessful());
     }
-
-    private <T extends org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow> T createFlowMock(Class<T> flowClazz) {
-        T mockedFlow = mock(flowClazz);
-        when(mockedFlow.getMatch()).thenReturn(match);
-        return mockedFlow;
-    }
 }
index fa0d1aae8f3234aea4f60332cf171dc523c7e22a..f0814d8962320ef7bf1e89ecf42033030a9fcebe 100644 (file)
@@ -17,6 +17,8 @@ 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -48,7 +50,8 @@ public class SalGroupServiceImplTest extends ServiceMocking {
     public void initialization() {
         super.initialization();
         when(mockedDeviceContext.getDeviceGroupRegistry()).thenReturn(mockedDeviceGroupRegistry);
-        salGroupService = new SalGroupServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        salGroupService = new SalGroupServiceImpl(mockedRequestContextStack, mockedDeviceContext, convertorManager);
     }
 
     @Test
index 0a04fd52bb50eef89235df4a75f5c196bb8e0484..ea20a88647c778e0c1aeb0cdf39a7ba47a050353 100644 (file)
@@ -17,6 +17,8 @@ import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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.meter.service.rev130918.AddMeterInput;
@@ -48,7 +50,8 @@ public class SalMeterServiceImplTest extends ServiceMocking {
     public void initialization() {
         super.initialization();
         when(mockedDeviceContext.getDeviceMeterRegistry()).thenReturn(mockedDeviceMeterRegistry);
-        salMeterService = new SalMeterServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        salMeterService = new SalMeterServiceImpl(mockedRequestContextStack, mockedDeviceContext, convertorManager);
     }
 
     @Test
index 04bd3e227bd0be3758a424ebd9bf8f0ea43c8715..a8940cb58ff5bc26e6e86e3cd71e4a913d77d9cf 100644 (file)
@@ -15,6 +15,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
@@ -38,7 +40,8 @@ public class SalPortServiceImplTest extends ServiceMocking {
     @Override
     public void initialization() {
         super.initialization();
-        salPortService = new SalPortServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        salPortService = new SalPortServiceImpl(mockedRequestContextStack, mockedDeviceContext, convertorManager);
     }
 
     @Test
index 442e051779a7374673d9d9b0007fca81d6943cb2..3bf020e83e3f22050f70596fc319375d4d37b06f 100644 (file)
@@ -27,6 +27,8 @@ import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
@@ -70,8 +72,9 @@ public class SalTableServiceImplTest extends ServiceMocking {
                 .when(mockedOutboundQueue).commitEntry(
                 Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
 
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
         salTableService = new SalTableServiceImpl(mockedRequestContextStack, mockedDeviceContext,
-                mockedDeviceContext.getPrimaryConnectionContext().getNodeId());
+                convertorManager);
     }
 
     @Test
index ccca8d077c2aa8f2e39b2ec178943d06b76ef027..3c1cabd8972489b47ac673a37ef8139b883a60f4 100644 (file)
@@ -16,10 +16,13 @@ import com.google.common.collect.Lists;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
+import org.junit.Before;
 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.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
@@ -61,7 +64,7 @@ public class SinglePurposeMultipartReplyTranslatorTest {
 
     private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("21");
     private static final Long DUMMY_XID = 1L;
-    private static final SinglePurposeMultipartReplyTranslator singlePurposeMultipartReplyTranslator = new SinglePurposeMultipartReplyTranslator();
+    private SinglePurposeMultipartReplyTranslator singlePurposeMultipartReplyTranslator;
     private static final BigInteger DUMMY_BYTE_COUNT = new BigInteger("31");
     private static final BigInteger DUMMY_PACKET_COUNT = new BigInteger("41");
     private static final Long DUMMY_FLOW_COUNT = 51L;
@@ -86,6 +89,12 @@ public class SinglePurposeMultipartReplyTranslatorTest {
     private static final GroupType DUMMY_GROUP_TYPE = GroupType.OFPGTALL;
     private static final Long GROUP_ACTION_BITMAP = 0b00000000000000000000000000000000000001111111111111001100000000001L;
 
+    @Before
+    public void setUp() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        singlePurposeMultipartReplyTranslator = new SinglePurposeMultipartReplyTranslator(convertorManager);
+    }
+
     @Test
     public void testTranslateFlow() {
         DeviceContext mockedDeviceContext = mock(DeviceContext.class);
index 9f0121779fdc76abee0963cba5abb29a8808ee1e..f89cade140262418ca4ea0faa151d674f0154d94 100644 (file)
@@ -96,6 +96,5 @@ class StatisticsContextImpMockInitiation {
 
         mockConductor.setSafelyManager(mockedDeviceManager);
         when(mockConductor.getDeviceContext(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
-
     }
 }
index 5eeb696049cd0333f98d71fc9ea354291fa64424..445265bb952e6c7680ec9bab3c7f953ba4e96e9a 100644 (file)
@@ -23,6 +23,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -61,8 +63,8 @@ public class StatisticsContextImplParamTest extends StatisticsContextImpMockInit
     @Test
     public void gatherDynamicDataTest() {
 
-
-        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor, convertorManager);
 
         final ListenableFuture<RpcResult<List<MultipartReply>>> rpcResult = immediateFuture(RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build());
         when(mockedStatisticsGatheringService.getStatisticsOfType(any(EventIdentifier.class), any(MultipartType
index 30e51bcccf3acea6aa71821c2b64d266cd794fde..6c7ef1a7000681ef6b2c56b8838c056fe534c88c 100644 (file)
@@ -28,6 +28,8 @@ 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -42,16 +44,18 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
 
     private static final Long TEST_XID = 55L;
     private StatisticsContextImpl statisticsContext;
+    private ConvertorManager convertorManager;
 
     @Before
     public void setUp() throws Exception {
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
         when(mockedDeviceContext.reserveXidForDeviceMessage()).thenReturn(TEST_XID);
         when(mockConductor.getDeviceContext(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
         initStatisticsContext();
     }
 
     private void initStatisticsContext() {
-        statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor);
+        statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor, convertorManager);
         statisticsContext.setStatisticsGatheringService(mockedStatisticsGatheringService);
         statisticsContext.setStatisticsGatheringOnTheFlyService(mockedStatisticsOnFlyGatheringService);
     }
@@ -69,7 +73,7 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
      */
     @Test
     public void testClose() throws Exception {
-        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor);
+        final StatisticsContextImpl statisticsContext = new StatisticsContextImpl(mockedDeviceInfo, false, mockConductor, convertorManager);
         final RequestContext<Object> requestContext = statisticsContext.createRequestContext();
         statisticsContext.close();
         try {
index 3e3085d254df8f7623f037a2dd0af6dcc5ea23f5..57a890ed4cd3ed0d1ef16eda4f3a641d2cd89453 100644 (file)
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -48,6 +47,8 @@ import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRe
 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;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
@@ -164,12 +165,16 @@ public class StatisticsGatheringUtilsTest {
     @Mock
     private TxFacade txFacade;
 
+    private SinglePurposeMultipartReplyTranslator singlePurposeMultipartReplyTranslator;
+
     public StatisticsGatheringUtilsTest() {
         OpenflowPortsUtil.init();
     }
 
     @Before
     public void setUp() throws Exception {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        singlePurposeMultipartReplyTranslator = new SinglePurposeMultipartReplyTranslator(convertorManager);
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
         when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry);
@@ -189,11 +194,6 @@ public class StatisticsGatheringUtilsTest {
         when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID);
     }
 
-    @After
-    public void tearDown() throws Exception {
-
-    }
-
     @Test
     public void testWriteFlowStatistics() throws Exception {
         final ArgumentCaptor<LogicalDatastoreType> dataStoreType = ArgumentCaptor.forClass(LogicalDatastoreType.class);
@@ -496,7 +496,8 @@ public class StatisticsGatheringUtilsTest {
                 type,
                 txFacade,
                 deviceContext,
-                false);
+                false,
+                singlePurposeMultipartReplyTranslator);
         Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS).booleanValue());
         verify(txFacade).submitTransaction();
     }
index c36821897dfb5cef6a87af57e82edaf55be7c3f6..6c4229e10fa6cfd280560c3a654eb24f2adf7acc 100644 (file)
@@ -58,6 +58,8 @@ import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleLi
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -182,7 +184,8 @@ public class StatisticsManagerImplTest {
                 Matchers.eq(StatisticsManagerControlService.class),
                 Matchers.<StatisticsManagerControlService>any())).thenReturn(serviceControlRegistration);
 
-        statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, conductor);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, conductor, convertorManager);
         statisticsManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
         when(conductor.getDeviceContext(deviceInfo)).thenReturn(mockedDeviceContext);
     }
index bd25110f4a528f2efaa7e5cf161251c1b6130ab7..3a8f42c4f91bfdeb58d37ae9373a86f91ce470da 100644 (file)
@@ -104,7 +104,6 @@ public abstract class AbstractStatsServiceTest {
         Mockito.when(getFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
         Mockito.when(getFeaturesOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
 
-
         setUp();
     }
 
index 49a16e38c00cd4a4a89a535d639023453ca40e86..009ff0de2f938de3391f35978fa8e8052dc2af8c 100644 (file)
@@ -14,6 +14,8 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
@@ -36,7 +38,8 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer
     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
 
     public void setUp() {
-        flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
 
         rqContext = new AbstractRequestContext<Object>(42L) {
             @Override
index 8c3d71dbb6debce9ebdcba942fc22549578c7f6b..3f093b0387335fcdb4a59c35baeb2e5393538973 100644 (file)
@@ -26,6 +26,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
@@ -53,7 +55,8 @@ public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsSer
 
 
     public void setUp() {
-        flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
 
         rqContextMp = new AbstractRequestContext<List<MultipartReply>>(42L) {
             @Override
index 329c670886197ef70f61c5d55ae8da33f6a28ad7..b565c379a61438d48cfa4ae1032af2e572dc1d16 100644 (file)
@@ -11,6 +11,8 @@ package org.opendaylight.openflowplugin.impl.statistics.services;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
@@ -33,7 +35,8 @@ public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsSer
     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
 
     public void setUp() {
-        flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
         flowStatisticsService.setDelegate(flowStatisticsDelegate);
     }
 
index 84e5b4e2d37fadafb6cb25d8c9e1043f8de693a1..9357d2cd787e5ad43d1e6cead5f1e5c4688b2c68 100644 (file)
@@ -21,6 +21,8 @@ import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
@@ -65,8 +67,9 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt
     private OpendaylightGroupStatisticsServiceImpl groupStatisticsService;
 
     public void setUp() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
         groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(rqContextStack, deviceContext,
-                new AtomicLong(), notificationPublishService);
+                new AtomicLong(), notificationPublishService, convertorManager);
 
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
                 .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
index 0952a01dc9543ea21de3f59e6d97cc74e41e5f9c..04e5c85a911b22f17db2396c8de75ec3cdba565e 100644 (file)
@@ -21,6 +21,8 @@ import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
@@ -64,8 +66,9 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleSt
     private OpendaylightMeterStatisticsServiceImpl meterStatisticsService;
 
     public void setUp() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
         meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(rqContextStack, deviceContext,
-                new AtomicLong(), notificationPublishService);
+                new AtomicLong(), notificationPublishService, convertorManager);
 
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
                 .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
index 251eb10fb1b25f2790f32c020a8312ac6f3c4dbc..86fcdaa9a195f27ee14f2bc7289894a3667ff33f 100644 (file)
@@ -24,6 +24,8 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
@@ -76,8 +78,9 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS
 
     @Override
     public void setUp() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
         flowStatisticsServiceDelegate = new OpendaylightFlowStatisticsServiceDelegateImpl(
-                rqContextStack, deviceContext, notificationPublishService, new AtomicLong(21));
+                rqContextStack, deviceContext, notificationPublishService, new AtomicLong(21), convertorManager);
 
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
                 .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
index eb17d48ae775499080e9c194199cc91b54c3bacd..dd292d112d65d46665ae90d4d7ad4049c3335234 100644 (file)
@@ -14,6 +14,8 @@ import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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.MultipartRequestInput;
@@ -29,7 +31,8 @@ public class StatisticsGatheringOnTheFlyServiceTest extends ServiceMocking {
 
     @Override
     protected void setup() {
-        statisticsGatheringService = new StatisticsGatheringOnTheFlyService(mockedRequestContextStack, mockedDeviceContext);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        statisticsGatheringService = new StatisticsGatheringOnTheFlyService(mockedRequestContextStack, mockedDeviceContext, convertorManager);
         Mockito.doReturn(NODE_ID).when(mockedPrimConnectionContext).getNodeId();
         Mockito.when(mockedDeviceInfo.getNodeId()).thenReturn(NODE_ID);
         Mockito.when(mockedDeviceContext.getDeviceInfo().getNodeId()).thenReturn(NODE_ID);
index 024d08762f64275293470e516b35ab30b6dcc555..bedc24e4be18badd9bfc8e8b7bd077044537fcfc 100644 (file)
@@ -28,6 +28,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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.NodeConnectorId;
@@ -73,6 +75,7 @@ public abstract class AbstractDirectStatisticsServiceTest {
 
     protected NodeConnectorId nodeConnectorId;
     protected KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
+    protected ConvertorManager convertorManager;
 
     protected static NodeRef createNodeRef(String nodeIdValue) {
         InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
@@ -92,6 +95,8 @@ public abstract class AbstractDirectStatisticsServiceTest {
                 .create(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId(NODE_ID)));
 
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
+
         when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
         when(deviceContext.getMultiMsgCollector(any())).thenReturn(multiMsgCollector);
index b2f39f30e73b560e0a12b65e99401359a21b753c..9dd7d6aaf954745c388a1e2f5a855a6988f8d044 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
 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.flow._case.multipart.reply.flow.FlowStatsBuilder;
 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;
 
@@ -42,7 +43,7 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
 
     @Override
     public void setUp() throws Exception {
-        service = new FlowDirectStatisticsService(requestContextStack, deviceContext);
+        service = new FlowDirectStatisticsService(requestContextStack, deviceContext, convertorManager);
         final DeviceFlowRegistry registry = mock(DeviceFlowRegistry.class);
         when(registry.storeIfNecessary(any())).thenReturn(new FlowId("1"));
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(registry);
@@ -66,22 +67,25 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
         final MultipartReply reply = mock(MultipartReply.class);
         final MultipartReplyFlowCase flowCase = mock(MultipartReplyFlowCase.class);
         final MultipartReplyFlow flow = mock(MultipartReplyFlow.class);
-        final FlowStats flowStat = mock(FlowStats.class);
-        final List<FlowStats> flowStats = Arrays.asList(flowStat);
-        final List<MultipartReply> input = Arrays.asList(reply);
+        final FlowStats flowStat = new FlowStatsBuilder()
+                .setDurationSec(1L)
+                .setDurationNsec(1L)
+                .setTableId(TABLE_NO)
+                .setByteCount(BigInteger.ONE)
+                .setPacketCount(BigInteger.ONE)
+                .setFlags(mock(FlowModFlags.class))
+                .setMatch(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder()
+                        .setMatchEntry(Collections.emptyList())
+                        .build())
+                .build();
+
+        final List<FlowStats> flowStats = Collections.singletonList(flowStat);
+        final List<MultipartReply> input = Collections.singletonList(reply);
 
         when(flow.getFlowStats()).thenReturn(flowStats);
         when(flowCase.getMultipartReplyFlow()).thenReturn(flow);
         when(reply.getMultipartReplyBody()).thenReturn(flowCase);
 
-        when(flowStat.getTableId()).thenReturn(TABLE_NO);
-        when(flowStat.getByteCount()).thenReturn(BigInteger.ONE);
-        when(flowStat.getPacketCount()).thenReturn(BigInteger.ONE);
-        when(flowStat.getFlags()).thenReturn(mock(FlowModFlags.class));
-        when(flowStat.getMatch()).thenReturn(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder()
-                .setMatchEntry(Collections.emptyList())
-                .build());
-
         final GetFlowStatisticsOutput output = service.buildReply(input, true);
         assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
 
index 87811f1b92eeed7e1dd621700040dee457873577..ab8cd6072bbb640423146b801ee2040d4fa3d17d 100644 (file)
@@ -18,6 +18,7 @@ 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.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput;
@@ -27,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
 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.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;
 
@@ -36,7 +38,7 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
 
     @Override
     public void setUp() throws Exception {
-        service = new GroupDirectStatisticsService(requestContextStack, deviceContext);
+        service = new GroupDirectStatisticsService(requestContextStack, deviceContext, convertorManager);
     }
 
     @Override
@@ -57,18 +59,23 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
         final MultipartReply reply = mock(MultipartReply.class);
         final MultipartReplyGroupCase groupCase = mock(MultipartReplyGroupCase.class);
         final MultipartReplyGroup group = mock(MultipartReplyGroup.class);
-        final GroupStats groupStat = mock(GroupStats.class);
-        final List<GroupStats> groupStats = Arrays.asList(groupStat);
-        final List<MultipartReply> input = Arrays.asList(reply);
+        final GroupStats groupStat = new GroupStatsBuilder()
+                .setGroupId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO))
+                .setByteCount(BigInteger.ONE)
+                .setPacketCount(BigInteger.ONE)
+                .setBucketStats(Collections.emptyList())
+                .setDurationSec(1L)
+                .setDurationNsec(1L)
+                .setRefCount(0L)
+                .build();
+
+        final List<GroupStats> groupStats = Collections.singletonList(groupStat);
+        final List<MultipartReply> input = Collections.singletonList(reply);
 
         when(group.getGroupStats()).thenReturn(groupStats);
         when(groupCase.getMultipartReplyGroup()).thenReturn(group);
         when(reply.getMultipartReplyBody()).thenReturn(groupCase);
 
-        when(groupStat.getGroupId()).thenReturn(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO));
-        when(groupStat.getByteCount()).thenReturn(BigInteger.ONE);
-        when(groupStat.getPacketCount()).thenReturn(BigInteger.ONE);
-
         final GetGroupStatisticsOutput output = service.buildReply(input, true);
         assertTrue(output.getGroupStats().size() > 0);
 
index b923cff06871a636161f0e638563b75991896774..ed96db005f649d0d6cf5386f1a27eca59691c761 100644 (file)
@@ -18,6 +18,7 @@ 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.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsInput;
@@ -27,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder;
 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;
 
@@ -36,7 +38,7 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
 
     @Override
     public void setUp() throws Exception {
-        service = new MeterDirectStatisticsService(requestContextStack, deviceContext);
+        service = new MeterDirectStatisticsService(requestContextStack, deviceContext, convertorManager);
     }
 
     @Override
@@ -57,18 +59,23 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
         final MultipartReply reply = mock(MultipartReply.class);
         final MultipartReplyMeterCase MeterCase = mock(MultipartReplyMeterCase.class);
         final MultipartReplyMeter meter = mock(MultipartReplyMeter.class);
-        final MeterStats meterStat = mock(MeterStats.class);
-        final List<MeterStats> meterStats = Arrays.asList(meterStat);
-        final List<MultipartReply> input = Arrays.asList(reply);
+        final MeterStats meterStat = new MeterStatsBuilder()
+                .setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO))
+                .setByteInCount(BigInteger.ONE)
+                .setPacketInCount(BigInteger.ONE)
+                .setDurationSec(1L)
+                .setDurationNsec(1L)
+                .setFlowCount(0L)
+                .setMeterBandStats(Collections.emptyList())
+                .build();
+
+        final List<MeterStats> meterStats = Collections.singletonList(meterStat);
+        final List<MultipartReply> input = Collections.singletonList(reply);
 
         when(meter.getMeterStats()).thenReturn(meterStats);
         when(MeterCase.getMultipartReplyMeter()).thenReturn(meter);
         when(reply.getMultipartReplyBody()).thenReturn(MeterCase);
 
-        when(meterStat.getMeterId()).thenReturn(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO));
-        when(meterStat.getByteInCount()).thenReturn(BigInteger.ONE);
-        when(meterStat.getPacketInCount()).thenReturn(BigInteger.ONE);
-
         final GetMeterStatisticsOutput output = service.buildReply(input, true);
         assertTrue(output.getMeterStats().size() > 0);
 
index d95595e08205e6c4fb109fbb57ae782ab3275dad..aaaeb7548d6e1857bdf42a14bc1d6030082e7e19 100644 (file)
@@ -35,7 +35,7 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat
 
     @Override
     public void setUp() throws Exception {
-        service = new NodeConnectorDirectStatisticsService(requestContextStack, deviceContext);
+        service = new NodeConnectorDirectStatisticsService(requestContextStack, deviceContext, convertorManager);
     }
 
     @Override
index c8ae34a06bab366bdbb20e0e0735975d3f60012e..388f73630353fc6b20248da554fc8081364a5a2a 100644 (file)
@@ -38,7 +38,7 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
 
     @Override
     public void setUp() throws Exception {
-        service = new QueueDirectStatisticsService(requestContextStack, deviceContext);
+        service = new QueueDirectStatisticsService(requestContextStack, deviceContext, convertorManager);
     }
 
     @Override
index d3e95982193122398c65b6cd178982502ff927a1..b12cdb23ca9ee239d1ee79d214b851364d658e16 100644 (file)
@@ -21,6 +21,8 @@ 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -68,8 +70,9 @@ public class FlowRemovedTranslatorTest {
         nodeId = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId("dummyNodeId")));
 
-        translator = new FlowRemovedTranslator();
-        translatorV10 = new FlowRemovedV10Translator();
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        translator = new FlowRemovedTranslator(convertorManager);
+        translatorV10 = new FlowRemovedV10Translator(convertorManager);
 
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
         when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeId);
index 632309ea7cd52ea43b1d6d62cbdaf1df1edc8d47..6a4ef2ebc23f8f8e48a5347aa7d5b832bdc21c51 100644 (file)
@@ -24,6 +24,8 @@ 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.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -76,6 +78,8 @@ public class PacketReceivedTranslatorTest {
     @Mock
     PhyPort phyPort;
 
+    ConvertorManager convertorManager;
+
     static final Long PORT_NO = 5l;
     static final Long PORT_NO_DS = 6l;
     static final String DATA = "Test_Data";
@@ -88,6 +92,7 @@ public class PacketReceivedTranslatorTest {
     @Before
     public void setUp() throws Exception {
         final List<PhyPort> phyPorts = Arrays.asList(phyPort);
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
 
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(connectionContext.getFeatures()).thenReturn(featuresReply);
@@ -105,7 +110,7 @@ public class PacketReceivedTranslatorTest {
         final KeyedInstanceIdentifier<Node, NodeKey> nodePath = KeyedInstanceIdentifier
                 .create(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId("openflow:10")));
-        final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator();
+        final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager);
         final PacketInMessage packetInMessage = createPacketInMessage(DATA.getBytes(), PORT_NO);
         Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
 
@@ -150,7 +155,8 @@ public class PacketReceivedTranslatorTest {
                 .setVersion(OFConstants.OFP_VERSION_1_3);
         BigInteger dpid = BigInteger.TEN;
 
-        final Match packetInMatch = PacketReceivedTranslator.getPacketInMatch(inputBld.build(), dpid);
+        final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager);
+        final Match packetInMatch = packetReceivedTranslator.getPacketInMatch(inputBld.build(), dpid);
 
         Assert.assertNotNull(packetInMatch.getInPort());
         Assert.assertEquals("openflow:10:" + PORT_NUM_VALUE, packetInMatch.getInPort().getValue());
index 71da6bd8c1388382fe4e228959e041d9e50fbd3a..08476e5debb82bed8978a8e94b6f2997fc7c54fc 100644 (file)
@@ -54,6 +54,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitia
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.device.DeviceContextImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 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;
@@ -136,9 +138,12 @@ public class DeviceInitializationUtilsTest {
     @Mock
     private DeviceInfo deviceInfo;
 
+    private ConvertorManager convertorManager;
+
     @Before
     public void setUp() throws Exception {
         OpenflowPortsUtil.init();
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
 
         when(mockConnectionContext.getNodeId()).thenReturn(new NodeId(DUMMY_NODE_ID));
         when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures);
@@ -171,7 +176,7 @@ public class DeviceInitializationUtilsTest {
         final ConnectionContext connectionContext = buildMockConnectionContext(OFConstants.OFP_VERSION_1_0);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
 
-        DeviceInitializationUtils.initializeNodeInformation(mockedDeviceContext, true);
+        DeviceInitializationUtils.initializeNodeInformation(mockedDeviceContext, true, convertorManager);
 
         verify(mockFeatures, atLeastOnce()).getPhyPort();
         verify(tLibrary, atLeastOnce()).lookupTranslator(any(TranslatorKey.class));
@@ -208,13 +213,14 @@ public class DeviceInitializationUtilsTest {
 
         final Collection<MultipartReply> multipartReplyMessages = prepareDataforTypeDesc(mockedDeviceContext);
 
-        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPDESC, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages);
+        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPDESC, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages, convertorManager);
         verify(mockedDeviceContext)
                 .writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), eq(DUMMY_NODE_II.augmentation(FlowCapableNode.class)), any(FlowCapableNode.class));
     }
 
     @Test
     public void translateAndWriteReplyTypeTableFeatures() throws Exception {
+        when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
         tableFeature.setTableId(DUMMY_TABLE_ID);
         final List<TableFeatures> tableFeatures = new ArrayList<>();
@@ -226,7 +232,7 @@ public class DeviceInitializationUtilsTest {
 
         final MultipartReplyMessage multipartReplyMessage = new MultipartReplyMessageBuilder().setMultipartReplyBody(multipartReplyTableFeaturesCaseBuilder.build()).build();
         final Set<MultipartReply> multipartReplyMessages = Collections.<MultipartReply>singleton(multipartReplyMessage);
-        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPTABLEFEATURES, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages);
+        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPTABLEFEATURES, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages, convertorManager);
         verify(mockedDeviceContext)
                 .writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL),
                         eq(DUMMY_NODE_II.augmentation(FlowCapableNode.class).child(Table.class, new TableKey(DUMMY_TABLE_ID))), any(Table.class));
@@ -248,7 +254,7 @@ public class DeviceInitializationUtilsTest {
 
         final MultipartReplyMessage multipartReplyMessage = new MultipartReplyMessageBuilder().setMultipartReplyBody(multipartReplyMeterFeaturesCaseBuilder.build()).build();
         final Set<MultipartReply> multipartReplyMessages = Collections.<MultipartReply>singleton(multipartReplyMessage);
-        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPMETERFEATURES, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages);
+        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPMETERFEATURES, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages, convertorManager);
         verify(mockedDeviceContext)
                 .writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), eq(DUMMY_NODE_II.augmentation(NodeMeterFeatures.class)), any(NodeMeterFeatures.class));
         verify(mockedDeviceState).setMeterAvailable(eq(true));
@@ -270,7 +276,7 @@ public class DeviceInitializationUtilsTest {
         final MultipartReplyMessage multipartReplyMessage = new MultipartReplyMessageBuilder().setMultipartReplyBody(multipartReplyGroupFeaturesCaseBuilder.build()).build();
         final Set<MultipartReply> multipartReplyMessages = Collections.<MultipartReply>singleton(multipartReplyMessage);
 
-        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPGROUPFEATURES, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages);
+        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPGROUPFEATURES, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages, convertorManager);
         verify(mockedDeviceContext)
                 .writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), eq(DUMMY_NODE_II.augmentation(NodeGroupFeatures.class)), any(NodeGroupFeatures.class));
     }
@@ -304,7 +310,7 @@ public class DeviceInitializationUtilsTest {
         final Set<MultipartReply> multipartReplyMessages = Collections.<MultipartReply>singleton(multipartReplyMessage);
 
         OpenflowPortsUtil.init();
-        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPPORTDESC, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages);
+        DeviceInitializationUtils.translateAndWriteReply(MultipartType.OFPMPPORTDESC, mockedDeviceContext, DUMMY_NODE_II, multipartReplyMessages, convertorManager);
         verify(mockedDeviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.<InstanceIdentifier<NodeConnector>> any(), any(NodeConnector.class));
     }
@@ -320,12 +326,12 @@ public class DeviceInitializationUtilsTest {
         final RpcResult<List<MultipartReply>> result = RpcResultBuilder.<List<MultipartReply>>success(multipartReplies).build();
         ListenableFuture<RpcResult<List<MultipartReply>>> mockedRequestContextFuture = Futures.immediateFuture(result);
 
-        DeviceInitializationUtils.createSuccessProcessingCallback(MultipartType.OFPMPDESC, mockedDeviceContext, DUMMY_NODE_II, mockedRequestContextFuture);
+        DeviceInitializationUtils.createSuccessProcessingCallback(MultipartType.OFPMPDESC, mockedDeviceContext, DUMMY_NODE_II, mockedRequestContextFuture, convertorManager);
         verify(mockedDeviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), eq(DUMMY_NODE_II.augmentation(FlowCapableNode.class)), any(FlowCapableNode.class));
 
         final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.PROTOCOL, "dummy error").build();
         mockedRequestContextFuture = Futures.immediateFuture(rpcResult);
-        DeviceInitializationUtils.createSuccessProcessingCallback(MultipartType.OFPMPDESC, mockedDeviceContext, DUMMY_NODE_II, mockedRequestContextFuture);
+        DeviceInitializationUtils.createSuccessProcessingCallback(MultipartType.OFPMPDESC, mockedDeviceContext, DUMMY_NODE_II, mockedRequestContextFuture, convertorManager);
         verify(mockedDeviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), eq(DUMMY_NODE_II.augmentation(FlowCapableNode.class)), any(FlowCapableNode.class));
     }
 
index 4a5d9402276a639e8f5ed6a03d9c50f6febf7b5a..33f544b022d63d34dd63beca6ef00dda0ea8bee3 100644 (file)
@@ -24,8 +24,9 @@ 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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 org.opendaylight.yangtools.yang.binding.RpcService;
 
 public class MdSalRegistrationUtilsTest {
@@ -58,7 +59,8 @@ public class MdSalRegistrationUtilsTest {
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
 
         final ExtensionConverterProvider extensionConverterProvider = mock(ExtensionConverterProvider.class);
-        MdSalRegistrationUtils.registerServices(mockedRpcContext, mockedDeviceContext, extensionConverterProvider);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        MdSalRegistrationUtils.registerServices(mockedRpcContext, mockedDeviceContext, extensionConverterProvider, convertorManager);
         verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(
                 Matchers.<Class<RpcService>> any(), any(RpcService.class));
     }
index 2a4520782b400c231eb72330725cfccaf43d1f0c..862f01a9a43fd8b2bbdcce03e2e3d1feca16a6e5 100644 (file)
@@ -18,6 +18,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
 import org.opendaylight.openflowplugin.impl.translator.TranslatorKeyFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
@@ -48,7 +50,8 @@ public class TranslatorLibratyUtilTest {
 
     @Test
     public void setBasicTranslatorLibraryTest() {
-        TranslatorLibraryUtil.setBasicTranslatorLibrary(translatorLibrarian);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        TranslatorLibraryUtil.injectBasicTranslatorLibrary(translatorLibrarian, convertorManager);
         TranslatorLibrary translatorLibrary = translatorLibrarian.oook();
 
         TranslatorKeyFactory of13TranslatorKeyFactory = new TranslatorKeyFactory(OFP_VERSION_1_3);
index da6901c395735c6a72feaf9ffc96d24ed7ef97a8..d13362ec9b53d00d6ab71798f93f236298dc2a1a 100644 (file)
@@ -37,6 +37,7 @@ 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.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.translator.ErrorTranslator;
 import org.opendaylight.openflowplugin.openflow.md.core.translator.ErrorV10Translator;
@@ -106,6 +107,7 @@ import org.slf4j.LoggerFactory;
 public class MDController implements IMDController, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(MDController.class);
+    private final ConvertorExecutor convertorExecutor;
 
     private Collection<SwitchConnectionProvider> switchConnectionProviders;
 
@@ -120,6 +122,10 @@ public class MDController implements IMDController, AutoCloseable {
 
     private ExtensionConverterProvider extensionConverterProvider;
 
+    public MDController(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
+
     /**
      * @return translator mapping
      */
@@ -140,19 +146,19 @@ public class MDController implements IMDController, AutoCloseable {
         //TODO: move registration to factory
         addMessageTranslator(ErrorMessage.class, OF10, new ErrorV10Translator());
         addMessageTranslator(ErrorMessage.class, OF13, new ErrorTranslator());
-        addMessageTranslator(FlowRemovedMessage.class, OF10, new FlowRemovedTranslator());
-        addMessageTranslator(FlowRemovedMessage.class, OF13, new FlowRemovedTranslator());
+        addMessageTranslator(FlowRemovedMessage.class, OF10, new FlowRemovedTranslator(convertorExecutor));
+        addMessageTranslator(FlowRemovedMessage.class, OF13, new FlowRemovedTranslator(convertorExecutor));
         addMessageTranslator(PacketInMessage.class,OF10, new PacketInV10Translator());
-        addMessageTranslator(PacketInMessage.class,OF13, new PacketInTranslator());
+        addMessageTranslator(PacketInMessage.class,OF13, new PacketInTranslator(convertorExecutor));
         addMessageTranslator(PortStatusMessage.class,OF10, new PortStatusMessageToNodeConnectorUpdatedTranslator());
         addMessageTranslator(PortStatusMessage.class,OF13, new PortStatusMessageToNodeConnectorUpdatedTranslator());
         addMessageTranslator(MultipartReplyMessage.class,OF13,new MultiPartReplyPortToNodeConnectorUpdatedTranslator());
         addMessageTranslator(MultipartReplyMessage.class,OF10, new MultiPartMessageDescToNodeUpdatedTranslator());
         addMessageTranslator(MultipartReplyMessage.class,OF13, new MultiPartMessageDescToNodeUpdatedTranslator());
         addMessageTranslator(ExperimenterMessage.class, OF10, new ExperimenterTranslator());
-        addMessageTranslator(MultipartReplyMessage.class,OF10, new MultipartReplyTranslator());
-        addMessageTranslator(MultipartReplyMessage.class,OF13, new MultipartReplyTranslator());
-        addMessageTranslator(MultipartReplyMessage.class,OF13,new MultipartReplyTableFeaturesToTableUpdatedTranslator());
+        addMessageTranslator(MultipartReplyMessage.class,OF10, new MultipartReplyTranslator(convertorExecutor));
+        addMessageTranslator(MultipartReplyMessage.class,OF13, new MultipartReplyTranslator(convertorExecutor));
+        addMessageTranslator(MultipartReplyMessage.class,OF13,new MultipartReplyTableFeaturesToTableUpdatedTranslator(convertorExecutor));
         addMessageTranslator(GetFeaturesOutput.class,OF10, new FeaturesV10ToNodeConnectorUpdatedTranslator());
         addMessageTranslator(NotificationQueueWrapper.class, OF10, new NotificationPlainTranslator());
         addMessageTranslator(NotificationQueueWrapper.class, OF13, new NotificationPlainTranslator());
index aee9dffc1e2f408bac254a6b4d5a47562c48501b..74f503cb626fbf045e55614969a9d31454136d98 100644 (file)
@@ -8,21 +8,21 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
 import com.google.common.base.Optional;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
-import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
@@ -111,6 +111,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     private final NodeId nodeId;
     private final IMessageDispatchService messageService;
     private short version = 0;
+    private final ConvertorExecutor convertorExecutor;
     private OFRpcTaskContext rpcTaskContext;
 
     // TODO:read timeout from configSubsystem
@@ -118,11 +119,12 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     protected TimeUnit maxTimeoutUnit = TimeUnit.MILLISECONDS;
 
     protected ModelDrivenSwitchImpl(final NodeId nodeId, final InstanceIdentifier<Node> identifier,
-                                    final SessionContext sessionContext) {
+                                    final SessionContext sessionContext, final ConvertorExecutor convertorExecutor) {
         super(identifier, sessionContext);
         this.nodeId = nodeId;
         messageService = sessionContext.getMessageDispatchService();
         version = sessionContext.getPrimaryConductor().getVersion();
+        this.convertorExecutor = convertorExecutor;
         final NotificationProviderService rpcNotificationProviderService = OFSessionUtil.getSessionManager().getNotificationProviderService();
 
         rpcTaskContext = new OFRpcTaskContext();
@@ -143,7 +145,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         SwitchConnectionDistinguisher cookie = null;
 
         OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task =
-                OFRpcTaskFactory.createAddFlowTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createAddFlowTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
 
         return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddFlowOutput());
@@ -158,7 +160,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         SwitchConnectionDistinguisher cookie = null;
 
         OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task =
-                OFRpcTaskFactory.createAddGroupTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createAddGroupTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
 
         return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddGroupOutput());
@@ -172,7 +174,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         SwitchConnectionDistinguisher cookie = null;
 
         OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task =
-                OFRpcTaskFactory.createAddMeterTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createAddMeterTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
 
         return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddMeterOutput());
@@ -185,7 +187,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         // use primary connection
         SwitchConnectionDistinguisher cookie = null;
         OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> task =
-                OFRpcTaskFactory.createRemoveFlowTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createRemoveFlowTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
 
         return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveFlowOutput());
@@ -197,7 +199,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
 
         SwitchConnectionDistinguisher cookie = null;
         OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task =
-                OFRpcTaskFactory.createRemoveGroupTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createRemoveGroupTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
 
         return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveGroupOutput());
@@ -209,7 +211,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
 
         SwitchConnectionDistinguisher cookie = null;
         OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task =
-                OFRpcTaskFactory.createRemoveMeterTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createRemoveMeterTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
 
         return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveMeterOutput());
@@ -219,8 +221,11 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
         LOG.debug("TransmitPacket - {}", input);
         // Convert TransmitPacket to PacketOutInput
-        PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, version, sessionContext.getNextXid(),
-                sessionContext.getFeatures().getDatapathId());
+        final PacketOutConvertorData data = new PacketOutConvertorData(version);
+        data.setDatapathId(sessionContext.getFeatures().getDatapathId());
+        data.setXid(sessionContext.getNextXid());
+
+        final java.util.Optional<PacketOutInput> message = convertorExecutor.convert(input, data);
 
         SwitchConnectionDistinguisher cookie = null;
         ConnectionCookie connectionCookie = input.getConnectionCookie();
@@ -229,7 +234,8 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         }
 
         LOG.debug("Calling the transmitPacket RPC method");
-        return messageService.packetOut(message, cookie);
+        return messageService.packetOut(message
+                .orElse(PacketOutConvertor.defaultResult(version)), cookie);
     }
 
     @Override
@@ -240,7 +246,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         SwitchConnectionDistinguisher cookie = null;
         final ReadWriteTransaction rwTx = OFSessionUtil.getSessionManager().getDataBroker().newReadWriteTransaction();
         OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
-                OFRpcTaskFactory.createUpdateFlowTask(rpcTaskContext, input, cookie, rwTx);
+                OFRpcTaskFactory.createUpdateFlowTask(rpcTaskContext, input, cookie, rwTx, convertorExecutor);
         ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
 
         return result;
@@ -254,7 +260,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         SwitchConnectionDistinguisher cookie = null;
 
         OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
-                OFRpcTaskFactory.createUpdateGroupTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createUpdateGroupTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
 
         return result;
@@ -268,7 +274,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         SwitchConnectionDistinguisher cookie = null;
 
         OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
-                OFRpcTaskFactory.createUpdateMeterTask(rpcTaskContext, input, cookie);
+                OFRpcTaskFactory.createUpdateMeterTask(rpcTaskContext, input, cookie, convertorExecutor);
         ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
 
         return result;
@@ -386,7 +392,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         LOG.debug("Calling the updatePort RPC method on MessageDispatchService");
 
         OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
-                OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, null);
+                OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, null, convertorExecutor);
         return task.submit();
     }
 
@@ -395,7 +401,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         LOG.debug("Calling the updateTable RPC method on MessageDispatchService");
 
         OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
-                OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, null);
+                OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, null, convertorExecutor);
         return task.submit();
     }
 
@@ -425,7 +431,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         LOG.debug("Calling the getFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
 
         OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
-                OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null);
+                OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null, convertorExecutor);
         return task.submit();
     }
 
@@ -445,7 +451,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForGivenMatch RPC method on MessageDispatchService");
 
         OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
-                OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, null);
+                OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, null, convertorExecutor);
         return task.submit();
     }
 
index 60df8aabf3be101c6d405f0502a45a9d540f32ca..3bc86226cd97f3c4f641f559f2d5f0c84827327a 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -27,11 +28,12 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.sal.NotificationComposer;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
@@ -201,16 +203,23 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input flow object input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return UpdateFlow task
      */
     public static OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> createAddFlowTask(
             OFRpcTaskContext taskContext, AddFlowInput input,
-            SwitchConnectionDistinguisher cookie) {
+            SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
 
         class OFRpcTaskImpl extends OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> {
 
-            public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie, AddFlowInput input) {
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionDatapathIdConvertorData data;
+
+            public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie, AddFlowInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
             }
 
             @Override
@@ -218,10 +227,12 @@ public abstract class OFRpcTaskFactory {
                 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
 
                 // Convert the AddFlowInput to FlowModInput
-                List<FlowModInputBuilder> ofFlowModInputs = FlowConvertor.toFlowModInputs(getInput(),
-                        getVersion(), getSession().getFeatures().getDatapathId());
-                LOG.debug("Number of flows to push to switch: {}", ofFlowModInputs.size());
-                result = chainFlowMods(ofFlowModInputs, 0, getTaskContext(), getCookie());
+                final java.util.Optional<List<FlowModInputBuilder>> ofFlowModInputs =
+                        convertorExecutor.convert(getInput(), data);
+
+                final List<FlowModInputBuilder> flowModInputs = ofFlowModInputs.orElse(Collections.emptyList());
+                LOG.debug("Number of flows to push to switch: {}", flowModInputs.size());
+                result = chainFlowMods(flowModInputs, 0, getTaskContext(), getCookie());
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(),
@@ -235,12 +246,12 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
-     * Recursive helper method for {@link OFRpcTaskFactory#createAddFlowTask(OFRpcTaskContext, AddFlowInput, SwitchConnectionDistinguisher)}
-     * and {@link OFRpcTaskFactory#createUpdateFlowTask(OFRpcTaskContext, UpdateFlowInput, SwitchConnectionDistinguisher, ReadWriteTransaction)} to chain results
+     * Recursive helper method for {@link OFRpcTaskFactory#createAddFlowTask(OFRpcTaskContext, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput, org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)}
+     * and {@link OFRpcTaskFactory#createUpdateFlowTask(OFRpcTaskContext, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput, org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher, org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)} to chain results
      * of multiple flowmods.
      * The next flowmod gets executed if the earlier one is successful.
      * All the flowmods should have the same xid, in-order to cross-reference
@@ -312,19 +323,23 @@ public abstract class OFRpcTaskFactory {
      * @param input update flow input
      * @param cookie switch connection distinguisher cookie value
      * @param rwTx  read write transaction
+     * @param convertorExecutor
      * @return UpdateFlow task
      */
     public static OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> createUpdateFlowTask(
             final OFRpcTaskContext taskContext, UpdateFlowInput input,
-            SwitchConnectionDistinguisher cookie, final ReadWriteTransaction rwTx) {
+            SwitchConnectionDistinguisher cookie, final ReadWriteTransaction rwTx, ConvertorExecutor convertorExecutor) {
 
         class OFRpcTaskImpl extends OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> {
             final ReadWriteTransaction rwTx;
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionDatapathIdConvertorData data;
             InstanceIdentifier<Table> iiToTable = null;
             String flowId = null;
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    final UpdateFlowInput in, final ReadWriteTransaction rwTx) {
+                                 final UpdateFlowInput in, final ReadWriteTransaction rwTx, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, in);
+                this.convertorExecutor = convertorExecutor;
                 final FlowRef flowRef = in.getFlowRef();
                 if (flowRef != null) {
                     InstanceIdentifier<Flow> iiToFlow = (InstanceIdentifier<Flow>)(flowRef.getValue());
@@ -336,6 +351,8 @@ public abstract class OFRpcTaskFactory {
                     }
                 }
                 this.rwTx = rwTx;
+                data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
             }
 
             @Override
@@ -345,26 +362,27 @@ public abstract class OFRpcTaskFactory {
                 UpdateFlowInput in = getInput();
                 UpdatedFlow updated = in.getUpdatedFlow();
                 OriginalFlow original = in.getOriginalFlow();
-                Short version = getVersion();
 
                 List<FlowModInputBuilder> allFlowMods = new ArrayList<>();
-                List<FlowModInputBuilder> ofFlowModInputs;
+                java.util.Optional<List<FlowModInputBuilder>> ofFlowModInputs;
 
-                if (!FlowCreatorUtil.canModifyFlow(original, updated, version)) {
+                if (!FlowCreatorUtil.canModifyFlow(original, updated, getVersion())) {
                     // We would need to remove original and add updated.
 
                     //remove flow
                     RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(original);
-                    List<FlowModInputBuilder> ofFlowRemoveInput = FlowConvertor.toFlowModInputs(removeflow.build(),
-                            version, getSession().getFeatures().getDatapathId());
-                    // remove flow should be the first
-                    allFlowMods.addAll(ofFlowRemoveInput);
+                    java.util.Optional<List<FlowModInputBuilder>> ofFlowRemoveInput =
+                            convertorExecutor.convert(removeflow.build(), data);
+
+                    if (ofFlowRemoveInput.isPresent()) {
+                        // remove flow should be the first
+                        allFlowMods.addAll(ofFlowRemoveInput.get());
+                    }
+
                     AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(updated);
-                    ofFlowModInputs = FlowConvertor.toFlowModInputs(addFlowInputBuilder.build(),
-                            version, getSession().getFeatures().getDatapathId());
+                    ofFlowModInputs = convertorExecutor.convert(addFlowInputBuilder.build(), data);
                 } else {
-                    ofFlowModInputs = FlowConvertor.toFlowModInputs(updated,
-                            version, getSession().getFeatures().getDatapathId());
+                    ofFlowModInputs = convertorExecutor.convert(updated, data);
                 }
 
                 //deleting flow hash value from operational DS
@@ -400,7 +418,10 @@ public abstract class OFRpcTaskFactory {
 
                 }
 
-                allFlowMods.addAll(ofFlowModInputs);
+                if (ofFlowModInputs.isPresent()) {
+                    allFlowMods.addAll(ofFlowModInputs.get());
+                }
+
                 LOG.debug("Number of flows to push to switch: {}", allFlowMods.size());
                 result = chainFlowMods(allFlowMods, 0, getTaskContext(), getCookie());
 
@@ -424,7 +445,7 @@ public abstract class OFRpcTaskFactory {
                 return getInput().getUpdatedFlow().isBarrier();
             }
         }
-        return new OFRpcTaskImpl(taskContext, cookie, input, rwTx);
+        return new OFRpcTaskImpl(taskContext, cookie, input, rwTx, convertorExecutor);
     }
 
 
@@ -448,15 +469,22 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext taks context
      * @param input group update input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return update group task
      */
     public static OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> createAddGroupTask(
             final OFRpcTaskContext taskContext, AddGroupInput input,
-            final SwitchConnectionDistinguisher cookie) {
+            final SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> {
 
-            public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie, AddGroupInput input) {
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionDatapathIdConvertorData data;
+
+            public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie, AddGroupInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
             }
 
             @Override
@@ -464,15 +492,14 @@ public abstract class OFRpcTaskFactory {
                 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
 
                 // Convert the AddGroupInput to GroupModInput
-                GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
-                        getVersion(), getSession().getFeatures().getDatapathId());
-                final Long xId = getSession().getNextXid();
-                ofGroupModInput.setXid(xId);
+                final java.util.Optional<GroupModInputBuilder> ofGroupModInput = convertorExecutor.convert(getInput(), data);
+                final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                        .orElse(GroupConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
-                        .groupMod(ofGroupModInput.build(), getCookie());
+                        .groupMod(groupModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createGroupAddedNotification(getInput()));
@@ -486,7 +513,7 @@ public abstract class OFRpcTaskFactory {
             }
         };
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
 
@@ -511,30 +538,37 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input meter add input
      * @param cookie switch connection distinguisher
+     * @param convertorExecutor
      * @return update meter task
      */
     public static OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> createAddMeterTask(
             OFRpcTaskContext taskContext, AddMeterInput input,
-            SwitchConnectionDistinguisher cookie) {
+            SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> {
 
-            public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie, AddMeterInput input) {
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionConvertorData data;
+
+            public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie, AddMeterInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionConvertorData(getVersion());
             }
 
             @Override
             public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
                 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
 
-                // Convert the AddGroupInput to GroupModInput
-                MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
-                final Long xId = getSession().getNextXid();
-                ofMeterModInput.setXid(xId);
+                // Convert the AddMeterInput to UpdateMeterOutput
+                final java.util.Optional<MeterModInputBuilder> ofMeterModInput = convertorExecutor.convert(getInput(), data);
+
+                final MeterModInputBuilder meterModInputBuilder = ofMeterModInput
+                        .orElse(MeterConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
-                        .meterMod(ofMeterModInput.build(), getCookie());
+                        .meterMod(meterModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createMeterAddedNotification(getInput()));
@@ -548,7 +582,7 @@ public abstract class OFRpcTaskFactory {
             }
         };
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -572,16 +606,23 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input update group output
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return UpdateFlow task
      */
     public static OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> createUpdateGroupTask(
             OFRpcTaskContext taskContext, UpdateGroupInput input,
-            SwitchConnectionDistinguisher cookie) {
+            SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionDatapathIdConvertorData data;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    UpdateGroupInput input) {
+                                 UpdateGroupInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
             }
 
             @Override
@@ -589,14 +630,15 @@ public abstract class OFRpcTaskFactory {
                 ListenableFuture<RpcResult<UpdateGroupOutput>> result = null;
 
                 // Convert the UpdateGroupInput to GroupModInput
-                GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(
-                        getInput().getUpdatedGroup(), getVersion(),
-                        getSession().getFeatures().getDatapathId());
-                final Long xId = getSession().getNextXid();
-                ofGroupModInput.setXid(xId);
+                final java.util.Optional<GroupModInputBuilder> ofGroupModInput =
+                        convertorExecutor.convert(getInput().getUpdatedGroup(), data);
+
+                final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                        .orElse(GroupConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib =
-                        getMessageService().groupMod(ofGroupModInput.build(), getCookie());
+                        getMessageService().groupMod(groupModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
 
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
@@ -612,7 +654,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -636,16 +678,22 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input update meter input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return update meter task
      */
     public static OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> createUpdateMeterTask(
             OFRpcTaskContext taskContext, UpdateMeterInput input,
-            SwitchConnectionDistinguisher cookie) {
+            SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionConvertorData data;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    UpdateMeterInput input) {
+                                 UpdateMeterInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionConvertorData(getVersion());
             }
 
             @Override
@@ -653,15 +701,15 @@ public abstract class OFRpcTaskFactory {
                 ListenableFuture<RpcResult<UpdateMeterOutput>> result = null;
 
                 // Convert the UpdateMeterInput to MeterModInput
-                MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(
-                        getInput().getUpdatedMeter(), getVersion());
-                final Long xId = getSession().getNextXid();
-                ofMeterModInput.setXid(xId);
+                final java.util.Optional<MeterModInputBuilder> ofMeterModInput = convertorExecutor.convert(getInput().getUpdatedMeter(), data);
+
+                final MeterModInputBuilder meterModInputBuilder = ofMeterModInput
+                        .orElse(MeterConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib =
-                        getMessageService().meterMod(ofMeterModInput.build(), getCookie());
+                        getMessageService().meterMod(meterModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createMeterUpdatedNotification(getInput()));
@@ -674,7 +722,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -699,16 +747,23 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input update flow input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task remove flow task
      */
     public static OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> createRemoveFlowTask(
             OFRpcTaskContext taskContext, RemoveFlowInput input,
-            SwitchConnectionDistinguisher cookie) {
+            SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> {
 
+            private final VersionDatapathIdConvertorData data;
+            private final ConvertorExecutor convertorExecutor;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    RemoveFlowInput input) {
+                                 RemoveFlowInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
             }
 
             @Override
@@ -716,10 +771,9 @@ public abstract class OFRpcTaskFactory {
                 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
 
                 // Convert the AddFlowInput to FlowModInput
-                List<FlowModInputBuilder> ofFlowModInputs = FlowConvertor.toFlowModInputs(getInput(),
-                        getVersion(), getSession().getFeatures().getDatapathId());
+                final java.util.Optional<List<FlowModInputBuilder>> ofFlowModInputs = convertorExecutor.convert(getInput(), data);
 
-                result = chainFlowMods(ofFlowModInputs, 0, getTaskContext(), getCookie());
+                result = chainFlowMods(ofFlowModInputs.orElse(Collections.emptyList()), 0, getTaskContext(), getCookie());
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
 
                 OFRpcTaskUtil.hookFutureNotification(this, result,
@@ -734,7 +788,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -759,16 +813,23 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input remove group input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task remove group task
      */
     public static OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> createRemoveGroupTask(
             final OFRpcTaskContext taskContext, RemoveGroupInput input,
-            final SwitchConnectionDistinguisher cookie) {
+            final SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionDatapathIdConvertorData data;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    RemoveGroupInput input) {
+                                 RemoveGroupInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
             }
 
             @Override
@@ -776,15 +837,15 @@ public abstract class OFRpcTaskFactory {
                 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
 
                 // Convert the AddGroupInput to GroupModInput
-                GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
-                        getVersion(), getSession().getFeatures().getDatapathId());
-                final Long xId = getSession().getNextXid();
-                ofGroupModInput.setXid(xId);
+                final java.util.Optional<GroupModInputBuilder> ofGroupModInput = convertorExecutor.convert(getInput(), data);
+
+                final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                        .orElse(GroupConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
-                        .groupMod(ofGroupModInput.build(), getCookie());
+                        .groupMod(groupModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createGroupRemovedNotification(getInput()));
@@ -798,7 +859,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -822,32 +883,39 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input meter removed input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task meter remove task
      */
     public static OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> createRemoveMeterTask(
             OFRpcTaskContext taskContext, RemoveMeterInput input,
-            SwitchConnectionDistinguisher cookie) {
+            SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
 
         class OFRpcTaskImpl extends OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionConvertorData data;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    RemoveMeterInput input) {
+                                 RemoveMeterInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionConvertorData(getVersion());
             }
 
             @Override
             public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
                 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
 
-                // Convert the AddGroupInput to GroupModInput
-                MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
-                final Long xId = getSession().getNextXid();
-                ofMeterModInput.setXid(xId);
+                // Convert the RemoveMeterInput to UpdateMeterOutput
+                final java.util.Optional<MeterModInputBuilder> ofMeterModInput = convertorExecutor.convert(getInput(), data);
+
+                final MeterModInputBuilder meterModInputBuilder = ofMeterModInput
+                        .orElse(MeterConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
-                        .meterMod(ofMeterModInput.build(), getCookie());
+                        .meterMod(meterModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createMeterRemovedNotification(getInput()));
@@ -861,7 +929,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
 
     }
 
@@ -1593,18 +1661,22 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input get flow statistics from flow table
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task get flow statistics from flow table task
      */
     public static OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>
     createGetFlowStatisticsFromFlowTableTask(
             final OFRpcTaskContext taskContext,
-            final GetFlowStatisticsFromFlowTableInput input, SwitchConnectionDistinguisher cookie) {
+            final GetFlowStatisticsFromFlowTableInput input, SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
 
         class OFRpcTaskImpl extends OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    GetFlowStatisticsFromFlowTableInput input) {
+                                 GetFlowStatisticsFromFlowTableInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
             }
 
             @Override
@@ -1644,8 +1716,7 @@ public abstract class OFRpcTaskFactory {
 
                 // convert and inject match
                 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
-                                .getPrimaryConductor().getVersion(), mprFlowRequestBuilder,
-                        taskContext.getSession().getFeatures().getDatapathId());
+                                .getPrimaryConductor().getVersion(), mprFlowRequestBuilder, convertorExecutor);
 
                 // Set request body to main multipart request
                 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
@@ -1669,7 +1740,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -1736,17 +1807,21 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input aggregate flow statistics input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task task to fetch the statistics
      */
     public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
     createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(
             final OFRpcTaskContext taskContext,
-            final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input, SwitchConnectionDistinguisher cookie) {
+            final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input, SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
         class OFRpcTaskImpl extends OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+                                 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
             }
 
             @Override
@@ -1772,8 +1847,7 @@ public abstract class OFRpcTaskFactory {
                 }
 
                 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
-                                .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder,
-                        taskContext.getSession().getFeatures().getDatapathId());
+                                .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder, convertorExecutor);
 
                 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
                         .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
@@ -1800,7 +1874,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
@@ -2064,30 +2138,35 @@ public abstract class OFRpcTaskFactory {
      * @param taskContext task context
      * @param input update port input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task task to update port
      */
     public static OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> createUpdatePortTask(
             final OFRpcTaskContext taskContext, final UpdatePortInput input,
-            final SwitchConnectionDistinguisher cookie) {
+            final SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
 
         class OFRpcTaskImpl extends OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionConvertorData data;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    UpdatePortInput input) {
+                                 UpdatePortInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionConvertorData(getVersion());
             }
 
             @Override
             public ListenableFuture<RpcResult<UpdatePortOutput>> call() {
                 ListenableFuture<RpcResult<UpdatePortOutput>> result = SettableFuture.create();
-                final Long xid = taskContext.getSession().getNextXid();
-                Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
+                final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
 
-                PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort,
-                        taskContext.getSession().getPrimaryConductor().getVersion());
+                final java.util.Optional<PortModInput> ofPortModInput = convertorExecutor.convert(inputPort, data);
 
-                PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
-                mdInput.setXid(xid);
+                PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput
+                        .orElse(PortConvertor.defaultResult(getVersion())))
+                        .setXid(taskContext.getSession().getNextXid());
 
                 Future<RpcResult<UpdatePortOutput>> resultFromOFLib = getMessageService()
                         .portMod(mdInput.build(), cookie);
@@ -2097,24 +2176,30 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     /**
      * @param taskContext task context
      * @param input update table input
      * @param cookie switch connection distinguisher cookie value
+     * @param convertorExecutor
      * @return task task to udpate table input
      */
     public static OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> createUpdateTableTask(
             final OFRpcTaskContext taskContext, final UpdateTableInput input,
-            final SwitchConnectionDistinguisher cookie) {
+            final SwitchConnectionDistinguisher cookie, ConvertorExecutor convertorExecutor) {
 
         class OFRpcTaskImpl extends OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> {
 
+            private final ConvertorExecutor convertorExecutor;
+            private final VersionConvertorData data;
+
             public OFRpcTaskImpl(OFRpcTaskContext taskContext, SwitchConnectionDistinguisher cookie,
-                    UpdateTableInput input) {
+                                 UpdateTableInput input, ConvertorExecutor convertorExecutor) {
                 super(taskContext, cookie, input);
+                this.convertorExecutor = convertorExecutor;
+                data = new VersionConvertorData(getVersion());
             }
 
             @Override
@@ -2125,9 +2210,9 @@ public abstract class OFRpcTaskFactory {
 
                 MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
                 MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
-                List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor
-                        .toTableFeaturesRequest(input.getUpdatedTable());
-                requestBuilder.setTableFeatures(ofTableFeatureList);
+
+                final java.util.Optional<List<TableFeatures>> ofTableFeatureList = convertorExecutor.convert(input.getUpdatedTable(), data);
+                requestBuilder.setTableFeatures(ofTableFeatureList.orElse(Collections.emptyList()));
                 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
 
                 // Set request body to main multipart request
@@ -2152,7 +2237,7 @@ public abstract class OFRpcTaskFactory {
             }
         }
 
-        return new OFRpcTaskImpl(taskContext, cookie, input);
+        return new OFRpcTaskImpl(taskContext, cookie, input, convertorExecutor);
     }
 
     public static OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> createSetNodeConfigTask(final OFRpcTaskContext taskContext,
index 58754980b056e55a3ea56f20250fa08864831720..dd88be1c5ea5883b13b4d9316781d2ef7f81e617 100644 (file)
@@ -22,6 +22,8 @@ import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionCon
 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.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFRoleManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.statistics.MessageSpyCounterImpl;
@@ -67,6 +69,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
      * Initialization of services and msgSpy counter
      */
     public void initialization() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+
         messageCountProvider = new MessageSpyCounterImpl();
         extensionConverterManager = new ExtensionConverterManagerImpl();
         roleManager = new OFRoleManager(OFSessionUtil.getSessionManager());
@@ -76,14 +80,14 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         entManager.init();
 
         LOG.debug("dependencies gathered..");
-        registrationManager = new SalRegistrationManager();
+        registrationManager = new SalRegistrationManager(convertorManager);
         registrationManager.setDataService(dataBroker);
         registrationManager.setPublishService(notificationService);
         registrationManager.setRpcProviderRegistry(rpcRegistry);
         registrationManager.setOfEntityManager(entManager);
         registrationManager.init();
 
-        mdController = new MDController();
+        mdController = new MDController(convertorManager);
         mdController.setSwitchConnectionProviders(switchConnectionProviders);
         mdController.setMessageSpyCounter(messageCountProvider);
         mdController.setExtensionConverterProvider(extensionConverterManager);
index ec72db0329f9effd5e26fd371b09747e901016c8..7f3ce58b63135006f9f9eca8aa363476da7a6c34 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionListe
 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.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
@@ -53,6 +54,7 @@ import org.slf4j.LoggerFactory;
 public class SalRegistrationManager implements SessionListener, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(SalRegistrationManager.class);
+    private final ConvertorExecutor convertorExecutor;
 
     private NotificationProviderService publishService;
 
@@ -66,7 +68,8 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
 
     private OfEntityManager entManager;
 
-    public SalRegistrationManager() {
+    public SalRegistrationManager(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
         swFeaturesUtil = SwitchFeaturesUtil.getInstance();
     }
 
@@ -105,7 +108,7 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId);
         NodeRef nodeRef = new NodeRef(identifier);
         NodeId nodeId = nodeIdFromDatapathId(datapathId);
-        ModelDrivenSwitch ofSwitch = new ModelDrivenSwitchImpl(nodeId, identifier,context);
+        ModelDrivenSwitch ofSwitch = new ModelDrivenSwitchImpl(nodeId, identifier, context, convertorExecutor);
 
         NotificationQueueWrapper wrappedNotification = new NotificationQueueWrapper(
                 nodeAdded(ofSwitch, features, nodeRef),
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java
deleted file mode 100644 (file)
index 8d55f55..0000000
+++ /dev/null
@@ -1,1214 +0,0 @@
-/**
- * Copyright (c) 2014 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.openflow.md.core.sal.convertor;
-
-import com.google.common.collect.Ordering;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
-import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
-import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
-import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
-import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
-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.action.PopMplsActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
-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.entries.grouping.MatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;
-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.TcpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author usha@ericsson Action List:This class takes data from SAL layer and
- *         converts into OF Data
- * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
- *         actions
- */
-public final class ActionConvertor {
-    private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
-    private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
-    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
-            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
-
-    private ActionConvertor() {
-        // NOOP
-    }
-
-    /**
-     * Translates SAL actions into OF Library actions
-     *
-     * @param actions    SAL actions
-     * @param version    Openflow protocol version used
-     * @param datapathid datapath id
-     * @param flow       TODO
-     * @return OF Library actions
-     */
-    public static List<Action> getActions(
-            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
-            final short version, final BigInteger datapathid, final Flow flow) {
-        List<Action> actionsList = new ArrayList<>();
-        Action ofAction;
-
-        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions =
-                ACTION_ORDERING.sortedCopy(actions);
-
-        for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) {
-            ofAction = null;
-            ActionBuilder actionBuilder = new ActionBuilder();
-
-            org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = sortedActions.get(
-                    actionItem).getAction();
-
-
-            if (action instanceof OutputActionCase) {
-                ofAction = salToOFAction((OutputActionCase) action, actionBuilder, version);
-            } else if (action instanceof DropActionCase){
-                //noop
-            } else if (action instanceof GroupActionCase) {
-                ofAction = salToOFGroupAction(action, actionBuilder);
-            } else if (action instanceof CopyTtlOutCase) {
-                ofAction = salToOFCopyTTLIOut(actionBuilder);
-            } else if (action instanceof CopyTtlInCase) {
-                ofAction = salToOFCopyTTLIIn(actionBuilder);
-            } else if (action instanceof SetMplsTtlActionCase) {
-                ofAction = salToOFSetMplsTtl(action, actionBuilder);
-            } else if (action instanceof DecMplsTtlCase) {
-                ofAction = salToOFDecMplsTtl(actionBuilder);
-            } else if (action instanceof PushVlanActionCase) {
-                ofAction = salToOFPushVlanAction(action, actionBuilder, version);
-            } else if (action instanceof PopVlanActionCase) {
-                ofAction = (version == OFConstants.OFP_VERSION_1_0) ?
-                        salToOFStripVlan(actionBuilder, version)
-                        : salToOFPopVlan(actionBuilder);
-            } else if (action instanceof PushMplsActionCase) {
-                ofAction = salToOFPushMplsAction(action, actionBuilder);
-            } else if (action instanceof PopMplsActionCase) {
-                ofAction = salToOFPopMpls(action, actionBuilder);
-            } else if (action instanceof SetQueueActionCase) {
-                ofAction = salToOFSetQueue(action, actionBuilder);
-            } else if (action instanceof SetNwTtlActionCase) {
-                ofAction = salToOFSetNwTtl(action, actionBuilder);
-            } else if (action instanceof DecNwTtlCase) {
-                ofAction = salToOFDecNwTtl(actionBuilder);
-            } else if (action instanceof SetFieldCase) {
-                ofAction = salToOFSetField(action, actionBuilder, version, datapathid);
-            } else if (action instanceof PushPbbActionCase) {
-                ofAction = salToOFPushPbbAction(action, actionBuilder);
-            } else if (action instanceof PopPbbActionCase) {
-                ofAction = salToOFPopPBB(actionBuilder);
-
-                // 1.0 Actions
-            } else if (action instanceof SetVlanIdActionCase) {
-                ofAction = salToOFSetVlanId(action, actionBuilder, version);
-            } else if (action instanceof SetVlanPcpActionCase) {
-                ofAction = salToOFSetVlanpcp(action, actionBuilder, version);
-            } else if (action instanceof StripVlanActionCase) {
-                ofAction = salToOFStripVlan(actionBuilder, version);
-            } else if (action instanceof SetDlSrcActionCase) {
-                ofAction = salToOFSetDlSrc(action, actionBuilder, version);
-            } else if (action instanceof SetDlDstActionCase) {
-                ofAction = salToOFSetDlDst(action, actionBuilder, version);
-            } else if (action instanceof SetNwSrcActionCase) {
-                ofAction = salToOFSetNwSrc(action, actionBuilder, version);
-            } else if (action instanceof SetNwDstActionCase) {
-                ofAction = salToOFSetNwDst(action, actionBuilder, version);
-            } else if (action instanceof SetTpSrcActionCase) {
-                ofAction = salToOFSetTpSrc(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch().
-                        getIpMatch().getIpProtocol()));
-            } else if (action instanceof SetTpDstActionCase) {
-                ofAction = salToOFSetTpDst(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch().
-                        getIpMatch().getIpProtocol()));
-            } else if (action instanceof SetNwTosActionCase) {
-                ofAction = salToOFSetNwTos(action, actionBuilder, version);
-            } else if (action instanceof GeneralExtensionGrouping) {
-                /**
-                 * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
-                 * - we might need sessionContext as converter input
-                 *
-                 */
-
-                GeneralExtensionGrouping extensionCaseGrouping = (GeneralExtensionGrouping) action;
-                Extension extAction = extensionCaseGrouping.getExtension();
-                ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionCaseGrouping.getExtensionKey(), version);
-                ConvertorToOFJava<Action> convertor =
-                        OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
-                if (convertor != null) {
-                    ofAction = convertor.convert(extAction);
-                }
-            } else {
-                // try vendor codecs
-                TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
-                        new TypeVersionKey<>(
-                                (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) action.getImplementedInterface(),
-                                version);
-                ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
-                        OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
-                LOG.trace("OFP Extension action, key:{}, converter:{}", key, convertor);
-                if (convertor != null) {
-                    ofAction = convertor.convert(action);
-                }
-            }
-
-            if (ofAction != null) {
-                actionsList.add(ofAction);
-            }
-        }
-        return actionsList;
-    }
-
-    private static Action salToOFSetField(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version, final BigInteger datapathid) {
-
-        SetFieldCase setFieldCase = (SetFieldCase) action;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match =
-                setFieldCase.getSetField();
-
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            // pushvlan +setField can be called to configure 1.0 switches via MDSAL app
-            if (match.getVlanMatch() != null) {
-                SetVlanVidActionBuilder vlanidActionBuilder = new SetVlanVidActionBuilder();
-                SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
-                vlanidActionBuilder.setVlanVid(match.getVlanMatch().getVlanId().getVlanId().getValue());
-                setVlanVidCaseBuilder.setSetVlanVidAction(vlanidActionBuilder.build());
-
-                actionBuilder.setActionChoice(setVlanVidCaseBuilder.build());
-                return actionBuilder.build();
-            } else {
-                return emtpyAction(actionBuilder);
-            }
-
-        } else {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-            MatchReactor.getInstance().convert(match, version, setFieldBuilder, datapathid);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-
-            return actionBuilder.build();
-        }
-    }
-
-    private static Action salToOFDecNwTtl(final ActionBuilder actionBuilder) {
-        actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
-        return emtpyAction(actionBuilder);
-    }
-
-    private static Action salToOFPushMplsAction(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
-        PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
-        PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
-        pushMplsBuilder.setEthertype(new EtherType(pushMplsActionCase.getPushMplsAction().getEthernetType()));
-        pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
-        actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFPushPbbAction(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
-        PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
-        PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
-        pushPbbBuilder.setEthertype(new EtherType(pushPbbActionCase.getPushPbbAction().getEthernetType()));
-        pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
-        actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFPushVlanAction(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            // if client configure openflow 1.0 switch as a openflow 1.3 switch using openflow 1.3 instructions
-            // then we can ignore PUSH_VLAN as set-vlan-id will push a vlan header if not present
-            return null;
-        }
-        PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
-        PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
-
-        PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
-        PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
-        if (null != pushVlanAction.getEthernetType()) {
-            pushVlanBuilder.setEthertype(new EtherType(pushVlanAction.getEthernetType()));
-        }
-        pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
-        actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFSetNwTtl(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
-
-        SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
-        SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
-        nwTtlBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
-        nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
-        actionBuilder.setActionChoice(nwTtlCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFSetQueue(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
-        SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
-
-        SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
-        SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
-        setQueueBuilder.setQueueId(setQueueAction.getQueueId());
-        setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
-        actionBuilder.setActionChoice(setQueueCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFPopMpls(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
-
-        PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
-        PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
-        popMplsBuilder.setEthertype(new EtherType(new EtherType(popMplsActionCase.getPopMplsAction().getEthernetType())));
-        popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
-        actionBuilder.setActionChoice(popMplsCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFPopVlan(final ActionBuilder actionBuilder) {
-        actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
-        return emtpyAction(actionBuilder);
-    }
-
-    private static Action salToOFPopPBB(final ActionBuilder actionBuilder) {
-        actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
-        return emtpyAction(actionBuilder);
-    }
-
-    // set-vlan-id (1.0 feature) can be called on  1.3 switches as well using ADSAL apis
-    private static Action salToOFSetVlanId(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
-        SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
-
-        SetVlanVidActionBuilder vlanidActionBuilder = new SetVlanVidActionBuilder();
-        SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
-
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
-            setVlanVidCaseBuilder.setSetVlanVidAction(vlanidActionBuilder.build());
-            actionBuilder.setActionChoice(setVlanVidCaseBuilder.build());
-            return actionBuilder.build();
-
-        } else {
-            if (version >= OFConstants.OFP_VERSION_1_3) {
-                SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-                SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-                List<MatchEntry> entries = new ArrayList<>();
-                MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
-                matchBuilder.setOxmClass(OpenflowBasicClass.class);
-                matchBuilder.setOxmMatchField(VlanVid.class);
-                matchBuilder.setHasMask(false);
-                VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
-                VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
-                vlanVidBuilder.setCfiBit(true);
-                vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
-                vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
-                matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
-                entries.add(matchBuilder.build());
-                setFieldBuilder.setMatchEntry(entries);
-                setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-                actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-                return actionBuilder.build();
-            } else {
-                LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-                return null;
-            }
-        }
-    }
-
-    private static Action salToOFSetVlanpcp(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
-        SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
-
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
-            SetVlanPcpCaseBuilder setVlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
-            setVlanPcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
-            setVlanPcpCaseBuilder.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
-            actionBuilder.setActionChoice(setVlanPcpCaseBuilder.build());
-            return actionBuilder.build();
-        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
-            List<MatchEntry> matchEntriesList = new ArrayList<>();
-            matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
-            setFieldBuilder.setMatchEntry(matchEntriesList);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-
-            return actionBuilder.build();
-        } else {
-            LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-            return null;
-        }
-    }
-
-    private static Action salToOFStripVlan(final ActionBuilder actionBuilder, final short version) {
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
-            return emtpyAction(actionBuilder);
-        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-            List<MatchEntry> entries = new ArrayList<>();
-            MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
-            matchBuilder.setOxmClass(OpenflowBasicClass.class);
-            matchBuilder.setOxmMatchField(VlanVid.class);
-            matchBuilder.setHasMask(false);
-            VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
-            VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
-            vlanVidBuilder.setCfiBit(true);
-            vlanVidBuilder.setVlanVid(0x0000);
-            vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
-            matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
-            matchBuilder.setHasMask(false);
-            entries.add(matchBuilder.build());
-            setFieldBuilder.setMatchEntry(entries);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-            return actionBuilder.build();
-        } else {
-            LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-            return null;
-        }
-    }
-
-    private static Action salToOFSetDlSrc(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
-        SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
-
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            SetDlSrcCaseBuilder setDlSrcCaseBuilder = new SetDlSrcCaseBuilder();
-            SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
-            setDlSrcActionBuilder.setDlSrcAddress(setdlsrcaction.getAddress());
-            setDlSrcCaseBuilder.setSetDlSrcAction(setDlSrcActionBuilder.build());
-            actionBuilder.setActionChoice(setDlSrcCaseBuilder.build());
-            return actionBuilder.build();
-        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
-            List<MatchEntry> entries = new ArrayList<>();
-            MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
-            matchBuilder.setOxmClass(OpenflowBasicClass.class);
-            matchBuilder.setOxmMatchField(EthSrc.class);
-            EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
-            EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
-            ethSrcBuilder.setMacAddress(setdlsrcaction.getAddress());
-            matchBuilder.setHasMask(false);
-            ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
-            matchBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
-            entries.add(matchBuilder.build());
-            setFieldBuilder.setMatchEntry(entries);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-
-            return actionBuilder.build();
-        } else {
-            LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-            return null;
-        }
-    }
-
-    private static Action salToOFSetDlDst(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
-        SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
-
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            SetDlDstCaseBuilder setDlDstCaseBuilder = new SetDlDstCaseBuilder();
-            SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
-            setDlDstActionBuilder.setDlDstAddress(setdldstaction.getAddress());
-            setDlDstCaseBuilder.setSetDlDstAction(setDlDstActionBuilder.build());
-            actionBuilder.setActionChoice(setDlDstCaseBuilder.build());
-            return actionBuilder.build();
-        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
-            List<MatchEntry> entries = new ArrayList<>();
-
-            MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
-            matchBuilder.setOxmClass(OpenflowBasicClass.class);
-            matchBuilder.setOxmMatchField(EthDst.class);
-            EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
-            EthDstBuilder ethDstBuilder = new EthDstBuilder();
-            ethDstBuilder.setMacAddress(setdldstaction.getAddress());
-            matchBuilder.setHasMask(false);
-            ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
-            matchBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
-            entries.add(matchBuilder.build());
-            setFieldBuilder.setMatchEntry(entries);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-            return actionBuilder.build();
-        } else {
-            LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-            return null;
-        }
-    }
-
-    protected static Action salToOFSetNwSrc(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        try {
-            ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
-        } catch (Exception e) {
-            LOG.error(e.getMessage(), e);
-            return null;
-        }
-
-        return actionBuilder.build();
-    }
-
-    protected static Action salToOFSetNwDst(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        try {
-            ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
-        } catch (Exception e) {
-            LOG.error(e.getMessage(), e);
-            return null;
-        }
-
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFSetNwTos(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version) {
-
-        SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
-        SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
-
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
-            SetNwTosCaseBuilder setNwTosCaseBuilder = new SetNwTosCaseBuilder();
-            setNwTosActionBuilder.setNwTos(setnwtosaction.getTos().shortValue());
-            setNwTosCaseBuilder.setSetNwTosAction(setNwTosActionBuilder.build());
-            actionBuilder.setActionChoice(setNwTosCaseBuilder.build());
-            return actionBuilder.build();
-        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
-            List<MatchEntry> entries = new ArrayList<>();
-            entries.add(MatchConvertorImpl.toOfIpDscp(new Dscp(
-                    ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
-            )));
-            setFieldBuilder.setMatchEntry(entries);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-            return actionBuilder.build();
-        } else {
-            LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-            return null;
-        }
-
-    }
-
-    private static Action salToOFSetTpSrc(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version, final IPProtocols protocol) {
-
-        SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
-        SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            SetTpSrcCaseBuilder setTpSrcCaseBuilder = new SetTpSrcCaseBuilder();
-            SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
-            setTpSrcActionBuilder.setPort(new PortNumber(settpsrcaction.getPort()
-                    .getValue()
-                    .longValue()));
-            setTpSrcCaseBuilder.setSetTpSrcAction(setTpSrcActionBuilder.build());
-            actionBuilder.setActionChoice(setTpSrcCaseBuilder.build());
-            return actionBuilder.build();
-        } else if (version == OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
-            MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
-            matchBuilder.setOxmClass(OpenflowBasicClass.class);
-            matchBuilder.setHasMask(false);
-
-            InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
-            int port = settpsrcaction.getPort().getValue().intValue();
-            int type = 0xff & port;
-
-            switch (protocol) {
-                case ICMP:
-                    matchBuilder.setOxmMatchField(Icmpv4Type.class);
-                    Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
-                    Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
-                    icmpv4TypeBuilder.setIcmpv4Type((short) type);
-                    icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
-                    matchBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
-                    break;
-                case ICMPV6:
-                    matchBuilder.setOxmMatchField(Icmpv6Type.class);
-                    Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
-                    Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
-                    icmpv6TypeBuilder.setIcmpv6Type((short) type);
-                    icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
-                    matchBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
-                    break;
-                case TCP:
-                    matchBuilder.setOxmMatchField(TcpSrc.class);
-                    TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
-                    TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
-                    tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
-                    tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
-                    matchBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
-                    break;
-                case UDP:
-                    matchBuilder.setOxmMatchField(UdpSrc.class);
-                    UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
-                    UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
-                    udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
-                    udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
-                    matchBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
-                    break;
-                default:
-                    LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
-                    break;
-            }
-            List<MatchEntry> entries = new ArrayList<MatchEntry>();
-            entries.add(matchBuilder.build());
-            setFieldBuilder.setMatchEntry(entries);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-            return actionBuilder.build();
-        }
-        LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-        return null;
-    }
-
-    private static Action salToOFSetTpDst(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder, final short version, final IPProtocols protocol) {
-
-        SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
-        SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
-        if (version == OFConstants.OFP_VERSION_1_0) {
-            SetTpDstCaseBuilder setTpDstCaseBuilder = new SetTpDstCaseBuilder();
-            SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
-            setTpDstActionBuilder.setPort(new PortNumber(settpdstaction.getPort().getValue().longValue()));
-            setTpDstCaseBuilder.setSetTpDstAction(setTpDstActionBuilder.build());
-            actionBuilder.setActionChoice(setTpDstCaseBuilder.build());
-            return actionBuilder.build();
-        } else if (version == OFConstants.OFP_VERSION_1_3) {
-            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
-            MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
-            matchBuilder.setOxmClass(OpenflowBasicClass.class);
-            matchBuilder.setHasMask(false);
-            int port = settpdstaction.getPort().getValue().intValue();
-            int code = 0xff & port;
-
-            switch (protocol) {
-                case ICMP:
-                    matchBuilder.setOxmMatchField(Icmpv4Code.class);
-                    Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
-                    Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
-                    icmpv4CodeBuilder.setIcmpv4Code((short) code);
-                    icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
-                    matchBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
-                    break;
-                case ICMPV6:
-                    matchBuilder.setOxmMatchField(Icmpv6Code.class);
-                    Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
-                    Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
-                    icmpv6CodeBuilder.setIcmpv6Code((short) code);
-                    icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
-                    matchBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
-                    break;
-                case TCP:
-                    matchBuilder.setOxmMatchField(TcpDst.class);
-                    TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
-                    TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
-                    tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
-                    tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
-                    matchBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
-                    break;
-                case UDP:
-                    matchBuilder.setOxmMatchField(UdpDst.class);
-                    UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
-                    UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
-                    udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
-                    udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
-                    matchBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
-                    break;
-                default:
-                    LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
-                    break;
-            }
-            List<MatchEntry> entries = new ArrayList<MatchEntry>();
-            entries.add(matchBuilder.build());
-            setFieldBuilder.setMatchEntry(entries);
-            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-            actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-            return actionBuilder.build();
-        }
-        LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
-        return null;
-    }
-
-    private static Action salToOFGroupAction(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        GroupActionCase groupActionCase = (GroupActionCase) action;
-        GroupAction groupAction = groupActionCase.getGroupAction();
-        GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
-        GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
-
-        if (null != groupAction.getGroupId()) {
-            groupActionBuilder.setGroupId(groupAction.getGroupId());
-        } else {
-            groupActionBuilder.setGroupId(Long.parseLong(groupAction.getGroup()));
-        }
-
-        groupCaseBuilder.setGroupAction(groupActionBuilder.build());
-        actionBuilder.setActionChoice(groupCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFDecMplsTtl(final ActionBuilder actionBuilder) {
-        actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build());
-        return emtpyAction(actionBuilder);
-    }
-
-    private static Action salToOFSetMplsTtl(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            final ActionBuilder actionBuilder) {
-        SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
-        SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
-        SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
-        SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder();
-        setMplsTtlBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
-        setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build());
-        actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build());
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFCopyTTLIIn(final ActionBuilder actionBuilder) {
-        actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
-        return emtpyAction(actionBuilder);
-    }
-
-    private static Action salToOFCopyTTLIOut(final ActionBuilder actionBuilder) {
-        actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
-        return emtpyAction(actionBuilder);
-
-    }
-
-    private static Action emtpyAction(final ActionBuilder actionBuilder) {
-        return actionBuilder.build();
-    }
-
-    private static Action salToOFAction(
-            final OutputActionCase outputActionCase,
-            final ActionBuilder actionBuilder, final short version) {
-
-        OutputAction outputAction = outputActionCase.getOutputAction();
-        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
-        OutputActionBuilder outputBuilder = new OutputActionBuilder();
-
-        if (outputAction.getMaxLength() != null) {
-            outputBuilder.setMaxLength(outputAction.getMaxLength());
-        } else {
-            outputBuilder.setMaxLength(0);
-        }
-        Uri uri = outputAction.getOutputNodeConnector();
-        OpenflowVersion ofVersion = OpenflowVersion.get(version);
-        Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
-        if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
-            outputBuilder.setPort(new PortNumber(portNumber));
-        } else {
-            LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, ofVersion);
-        }
-        caseBuilder.setOutputAction(outputBuilder.build());
-        actionBuilder.setActionChoice(caseBuilder.build());
-        return actionBuilder.build();
-
-    }
-
-    /**
-     * Method to convert OF actions associated with bucket to SAL Actions.
-     *
-     * @param actionList action list
-     * @param ofVersion  current ofp version
-     * @param actionPath TODO
-     * @return List of converted SAL Actions.
-     */
-    public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
-            final List<Action> actionList, final OpenflowVersion ofVersion, final ActionPath actionPath) {
-
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
-        if(actionList != null){
-            for (Action action : actionList) {
-                if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) {
-                    bucketActions.add(ofToSALOutputAction(ofVersion, action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase) {
-                    bucketActions.add(ofToSALGroupAction(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase) {
-                    CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
-                    bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase) {
-                    CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
-                    bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
-
-                } else if (action.getActionChoice() instanceof SetMplsTtlCase) {
-                    bucketActions.add(ofToSALSetMplsTtl(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase) {
-                    DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
-                    bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase) {
-                    bucketActions.add(ofToSALPushVlanAction(action));
-                } else if ((action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase)
-                        || (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase)) {
-                    // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
-                    PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
-                    bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase) {
-                    bucketActions.add(ofToSALPushMplsAction(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase) {
-                    bucketActions.add(ofToSALPopMplsAction(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase) {
-                    bucketActions.add(ofToSALSetQueue(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase) {
-                    bucketActions.add(ofToSALSetNwTtl(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase) {
-                    DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
-                    bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder()
-                            .setDecNwTtl(decNwTtl.build()).build());
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) {
-                    bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder()
-                            .setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion)).build());
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase) {
-                    bucketActions.add(ofToSALPushPbbAction(action));
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase) {
-                    PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
-                    bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
-
-                } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase) {
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder setNwDstActionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder();
-                    bucketActions.add(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
-
-                } else {
-                    /**
-                     * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
-                     * - we might also need a way on how to identify exact type of augmentation to be
-                     *   used as match can be bound to multiple models
-                     */
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction =
-                            ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
-                    if (processedAction != null) {
-                        bucketActions.add(processedAction);
-                    }
-                }
-            }
-        }
-        return bucketActions;
-    }
-
-    /**
-     * Method converts OF Output action object to SAL Output action object.
-     *
-     * @param ofVersion openflow version
-     * @param action    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
-     *                  action.rev130731.actions.actions.list.Action
-     * @return OutputAction
-     */
-    public static OutputActionCase ofToSALOutputAction(final OpenflowVersion ofVersion, final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder outputAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder();
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) action.getActionChoice();
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputAction outputActionFromOF = actionCase.getOutputAction();
-        if (outputActionFromOF.getPort() != null) {
-            PortNumberUni protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
-                    ofVersion, outputActionFromOF.getPort().getValue());
-            String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
-            outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
-        } else {
-            LOG.error("Provided action is not OF Output action, no associated port found!");
-        }
-
-        Integer maxLength = outputActionFromOF.getMaxLength();
-        if (maxLength != null) {
-            outputAction.setMaxLength(maxLength);
-        } else {
-            LOG.error("Provided action is not OF Output action, no associated length found!");
-        }
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder outputActionCaseBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder();
-        outputActionCaseBuilder.setOutputAction(outputAction.build());
-        return outputActionCaseBuilder.build();
-    }
-
-    /**
-     * Method converts OF GroupAction object to SAL GroupAction object
-     *
-     * @param action action
-     * @return GroupAction group action
-     */
-    public static GroupActionCase ofToSALGroupAction(final Action action) {
-        GroupCase actionCase = (GroupCase) action.getActionChoice();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupAction groupActionFromOF =
-                actionCase.getGroupAction();
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder groupAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder();
-        groupAction.setGroupId(groupActionFromOF.getGroupId());
-
-        return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
-    }
-
-    /**
-     * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
-     * object.
-     *
-     * @param action action
-     * @return set-mpls ttl action
-     */
-    public static SetMplsTtlActionCase ofToSALSetMplsTtl(final Action action) {
-        SetMplsTtlCase actionCase = (SetMplsTtlCase) action.getActionChoice();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action
-                .choice.set.mpls.ttl._case.SetMplsTtlAction setMplsTtlActionFromOF = actionCase.getSetMplsTtlAction();
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder mplsTtlAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder();
-        mplsTtlAction.setMplsTtl(setMplsTtlActionFromOF.getMplsTtl());
-        return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
-    }
-
-    /**
-     * Method converts OF Pushvlan action to SAL PushVlan action.
-     *
-     * @param action input actioj
-     * @return PushVlanAction
-     */
-    public static PushVlanActionCase ofToSALPushVlanAction(final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase) action.getActionChoice();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanAction pushVlanActionFromOF =
-                actionCase.getPushVlanAction();
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder pushVlanAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder();
-
-        pushVlanAction.setEthernetType(pushVlanActionFromOF.getEthertype().getValue());
-        return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
-    }
-
-    /**
-     * Method converts OF PushMpls action to SAL PushMpls action.
-     *
-     * @param action action
-     * @return PushMplsAction
-     */
-    public static PushMplsActionCase ofToSALPushMplsAction(final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase) action.getActionChoice();
-        PushMplsAction pushMplsActionFromOF = actionCase.getPushMplsAction();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder pushMplsAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder();
-        pushMplsAction.setEthernetType(pushMplsActionFromOF.getEthertype().getValue());
-        return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
-    }
-
-    /**
-     * Method converts OF PopMpls action to SAL PopMpls action.
-     *
-     * @param action action
-     * @return PopMplsActionCase
-     */
-    public static PopMplsActionCase ofToSALPopMplsAction(final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase) action.getActionChoice();
-        PopMplsAction popMplsActionFromOF = actionCase.getPopMplsAction();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder popMplsAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder();
-        popMplsAction.setEthernetType(popMplsActionFromOF.getEthertype().getValue());
-        return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
-    }
-
-    /**
-     * Method converts OF SetQueue action to SAL SetQueue action.
-     *
-     * @param action action
-     * @return SetQueueAction
-     */
-    public static SetQueueActionCase ofToSALSetQueue(final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase) action.getActionChoice();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueAction queueActionFromOF =
-                actionCase.getSetQueueAction();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder setQueueAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder();
-        setQueueAction.setQueueId(queueActionFromOF.getQueueId());
-        return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
-    }
-
-    /**
-     * Method converts OF SetNwTtl action to SAL SetNwTtl action.
-     *
-     * @param action action
-     * @return SetNwTtlAction
-     */
-    public static SetNwTtlActionCase ofToSALSetNwTtl(final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase) action.getActionChoice();
-        SetNwTtlAction setNwTtlActionFromOf = actionCase.getSetNwTtlAction();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder setNwTtl =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder();
-        setNwTtl.setNwTtl(setNwTtlActionFromOf.getNwTtl());
-        return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
-    }
-
-    /**
-     * Method converts OF Pushvlan action to SAL PushVlan action.
-     *
-     * @param action action
-     * @return PushVlanAction
-     */
-    public static PushPbbActionCase ofToSALPushPbbAction(final Action action) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase actionCase =
-                (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase) action.getActionChoice();
-        PushPbbAction pushPbbActionFromOf = actionCase.getPushPbbAction();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder pushPbbAction =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder();
-        pushPbbAction.setEthernetType(pushPbbActionFromOf.getEthertype().getValue());
-        return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
-    }
-
-    //TODO make a model in YANG for protocols
-    /*private enum IPProtocols {
-        ICMP(1),
-        TCP(6),
-        UDP(17),
-        ICMPV6(58);
-
-        private int protocol;
-
-        private static Map<Integer, IPProtocols> valueMap;
-        static {
-            valueMap = new HashMap<>();
-            for(IPProtocols protocols : IPProtocols.values()) {
-                valueMap.put(protocols.protocol, protocols);
-            }
-        }
-
-        private IPProtocols(int value) {
-            this.protocol = value;
-        }
-
-        private byte getValue() {
-            return (byte) this.protocol;
-        }
-
-        private Short getShortValue() {
-            return (short) protocol;
-        }
-
-        private IPProtocols fromProtocolNum(Short protocolNum) {
-            return valueMap.get(protocolNum);
-        }
-    }    */
-
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java
new file mode 100644 (file)
index 0000000..1e28a54
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import java.util.Collection;
+import java.util.Optional;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public interface ConvertorExecutor {
+    /**
+     * Lookup and use convertor by specified type, then converts source and returns converted result
+     *
+     * @param <FROM> the source type
+     * @param <TO>   the result type
+     * @param <DATA> the data type
+     * @param source the source
+     * @param data   convertor data
+     * @return the result (can be empty, if no convertor was found)
+     */
+    <FROM extends DataContainer, TO, DATA extends ConvertorData> Optional<TO> convert(final FROM source, final DATA data);
+
+    /**
+     * Lookup and use convertor by specified type, then converts source collection and returns converted result
+     *
+     * @param <FROM> the source type
+     * @param <TO>   the result type
+     * @param <DATA> the data type
+     * @param source the source collection
+     * @param data   convertor data
+     * @return the result (can be empty, if no convertor was found)
+     */
+    <FROM extends DataContainer, TO, DATA extends ConvertorData> Optional<TO> convert(final Collection<FROM> source, final DATA data);
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java
new file mode 100644 (file)
index 0000000..191b21d
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Stream;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Manages various convertors and allows to use them all in one generic way
+ */
+public class ConvertorManager implements ConvertorExecutor, ConvertorRegistrator {
+    private static final Logger LOG = LoggerFactory.getLogger(ConvertorManager.class);
+
+    // Cache, that holds all registered convertors, but they can have multiple keys,
+    // based on instanceof checks in the convert method
+    private Map<Short, Map<Class<? extends DataContainer>, Convertor<?, ?, ? extends ConvertorData>>> convertors;
+
+    /**
+     * Create new instance of Convertor Manager
+     * @param supportedVersions supported versions
+     */
+    public ConvertorManager(final Short... supportedVersions) {
+        final Stream<Short> stream = Arrays.stream(supportedVersions);
+
+        if (supportedVersions.length == 1) {
+            final Optional<Short> versionOptional = stream.findFirst();
+            versionOptional.ifPresent(version -> convertors = Collections.singletonMap(version, new ConcurrentHashMap<>()));
+        } else {
+            convertors = new ConcurrentHashMap<>();
+            stream.forEach(version -> convertors.putIfAbsent(version, new ConcurrentHashMap<>()));
+        }
+    }
+
+    @Override
+    public ConvertorManager registerConvertor(final short version, final Convertor<?, ?, ? extends ConvertorData> convertor) {
+        final Map<Class<? extends DataContainer>, Convertor<?, ?, ? extends ConvertorData>> convertorsForVersion =
+                convertors.get(version);
+
+        if (Objects.nonNull(convertorsForVersion)) {
+            for (final Class<? extends DataContainer> type : convertor.getTypes()) {
+                final Convertor<?, ?, ? extends ConvertorData> result = convertorsForVersion.get(type);
+
+                if (Objects.isNull(result)) {
+                    convertor.setConvertorExecutor(this);
+                    convertorsForVersion.put(type, convertor);
+                    LOG.debug("{} for version {} is now converted by {}", type, version, convertor);
+                } else {
+                    LOG.warn("{} for version {} have already registered convertor", type, version);
+                }
+            }
+        } else {
+            LOG.warn("{} do not supports version {}", this, version);
+        }
+
+        return this;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <FROM extends DataContainer, TO, DATA extends ConvertorData> Optional<TO> convert(final FROM source, final DATA data) {
+        Optional<TO> result = Optional.empty();
+
+        if (Objects.isNull(source)) {
+            LOG.trace("Cannot extract type from null source");
+            return result;
+        }
+
+        final Class<? extends DataContainer> type = source.getImplementedInterface();
+
+        if (Objects.isNull(type)) {
+            LOG.warn("Cannot extract type from {}, because getImplementedInterface() returns null", source);
+            return result;
+        }
+
+         return findConvertor(data.getVersion(), type)
+                .map(convertor -> (TO)convertor.convert(source, data));
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <FROM extends DataContainer, TO, DATA extends ConvertorData> Optional<TO> convert(final Collection<FROM> source, final DATA data) {
+        Optional<TO> result = Optional.empty();
+
+        if (Objects.isNull(source)) {
+            LOG.trace("Cannot extract type from null source");
+            return result;
+        }
+
+        final Optional<FROM> first = source.stream().findFirst();
+
+        if (!first.isPresent()) {
+            LOG.trace("Cannot extract type from empty collection");
+            return result;
+        }
+
+        final Class<? extends DataContainer> type = first.get().getImplementedInterface();
+
+        if (Objects.isNull(type)) {
+            LOG.warn("Cannot extract type from {}, because getImplementedInterface() returns null", source);
+            return result;
+        }
+
+        return findConvertor(data.getVersion(), type)
+                .map(convertor -> (TO)convertor.convert(source, data));
+    }
+
+    /**
+     * Last resort. If we do not already have convertor registered,
+     * we will perform some costly operations and try to find if we
+     * can convert input using any of already registered convertors
+     * @param type input type
+     * @return found convertor
+     */
+    @VisibleForTesting
+    Optional<Convertor> findConvertor(final short version, final Class<? extends DataContainer> type) {
+        final Map<Class<? extends DataContainer>, Convertor<?, ?, ? extends ConvertorData>> convertorsForVersion =
+                convertors.get(version);
+
+        Optional<Convertor> convertor = Optional.empty();
+
+        if (Objects.nonNull(convertorsForVersion)) {
+            convertor = Optional.ofNullable(convertorsForVersion.get(type));
+
+            if (!convertor.isPresent()) {
+                for (final Class<? extends DataContainer> convertorType : convertorsForVersion.keySet()) {
+                    if (type.isAssignableFrom(convertorType)) {
+                        final Convertor<?, ?, ? extends ConvertorData> foundConvertor = convertorsForVersion.get(convertorType);
+                        convertor = Optional.ofNullable(foundConvertor);
+
+                        if (convertor.isPresent()) {
+                            convertorsForVersion.put(type, foundConvertor);
+                            LOG.warn("{} for version {} is now converted by {} using last resort method", type, version, foundConvertor);
+                            break;
+                        }
+                    }
+                }
+
+                if (!convertor.isPresent()) {
+                    LOG.warn("Convertor for {} for version {} not found", type, version);
+                }
+            }
+        } else {
+            LOG.warn("{} do not supports version {}", this, version);
+        }
+
+        return convertor;
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerFactory.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerFactory.java
new file mode 100644 (file)
index 0000000..5111912
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowInstructionResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor;
+
+/**
+ * Convertor manager factory.
+ */
+public class ConvertorManagerFactory {
+    /**
+     * Create default convertor manager.
+     *
+     * @return the convertor manager
+     */
+    public static ConvertorManager createDefaultManager() {
+        final TableFeaturesConvertor tableFeaturesConvertor = new TableFeaturesConvertor();
+        final TableFeaturesResponseConvertor tableFeaturesResponseConvertor = new TableFeaturesResponseConvertor();
+        final MeterConvertor meterConvertor = new MeterConvertor();
+        final MeterStatsResponseConvertor meterStatsResponseConvertor = new MeterStatsResponseConvertor();
+        final MeterConfigStatsResponseConvertor meterConfigStatsResponseConvertor = new MeterConfigStatsResponseConvertor();
+        final PortConvertor portConvertor = new PortConvertor();
+        final MatchResponseConvertor matchResponseConvertor = new MatchResponseConvertor();
+        final MatchV10ResponseConvertor matchV10ResponseConvertor = new MatchV10ResponseConvertor();
+        final ActionConvertor actionConvertor = new ActionConvertor();
+        final ActionResponseConvertor actionResponseConvertor = new ActionResponseConvertor();
+        final GroupConvertor groupConvertor = new GroupConvertor();
+        final GroupDescStatsResponseConvertor groupDescStatsResponseConvertor = new GroupDescStatsResponseConvertor();
+        final GroupStatsResponseConvertor groupStatsResponseConvertor = new GroupStatsResponseConvertor();
+        final PacketOutConvertor packetOutConvertor = new PacketOutConvertor();
+        final FlowConvertor flowConvertor = new FlowConvertor();
+        final FlowInstructionResponseConvertor flowInstructionResponseConvertor = new FlowInstructionResponseConvertor();
+        final FlowStatsResponseConvertor flowStatsResponseConvertor = new FlowStatsResponseConvertor();
+
+        return new ConvertorManager(OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, tableFeaturesConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, tableFeaturesConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, tableFeaturesResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, tableFeaturesResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, meterConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, meterConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, meterStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, meterStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, meterConfigStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, meterConfigStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, portConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, portConvertor)
+                // TODO: Add MatchConvertorImpl and MatchConvertorV10Impl
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, matchResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, matchV10ResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, actionConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, actionConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, actionResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, actionResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, groupConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, groupConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, groupDescStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, groupDescStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, groupStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, groupStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, packetOutConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, packetOutConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, flowConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, flowConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, flowInstructionResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, flowInstructionResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_0, flowStatsResponseConvertor)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, flowStatsResponseConvertor);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorRegistrator.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorRegistrator.java
new file mode 100644 (file)
index 0000000..f5dbc59
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+
+public interface ConvertorRegistrator {
+    /**
+     * Register convertor.
+     *
+     * @param convertor the convertor
+     */
+    ConvertorManager registerConvertor(final short version, final Convertor<?, ?, ? extends ConvertorData> convertor);
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowStatsResponseConvertor.java
deleted file mode 100644 (file)
index 989444f..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
-import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
-import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
-
-/**
- * Class is an utility class for converting flow related statistics messages coming from openflow
- * switch to MD-SAL messages.
- * @author avishnoi@in.ibm.com
- *
- */
-public class FlowStatsResponseConvertor {
-
-    /**
-     * Method returns the list of MD-SAL format flow statistics, converted flow Openflow
-     * specific flow statistics.
-     * @param allFlowStats all flow stats
-     * @param datapathid  datapath id
-     * @param ofVersion  openflow version
-     * @return list of flow and statistics mapping
-     */
-    public List<FlowAndStatisticsMapList> toSALFlowStatsList(List<FlowStats> allFlowStats, BigInteger datapathid, OpenflowVersion ofVersion){
-
-        List<FlowAndStatisticsMapList> convertedSALFlowStats = new ArrayList<FlowAndStatisticsMapList>();
-
-        for(FlowStats flowStats : allFlowStats){
-            convertedSALFlowStats.add(toSALFlowStats(flowStats, datapathid, ofVersion));
-        }
-
-        return convertedSALFlowStats;
-    }
-
-    /**
-     * Method convert Openflow switch specific flow statistics to the MD-SAL format
-     * flow statistics.
-     * @param flowStats flow statis
-     * @param datapathid  datapath id
-     * @param ofVersion  openflow version
-     * @return flow and statistics map
-     */
-    public FlowAndStatisticsMapList toSALFlowStats(FlowStats flowStats, BigInteger datapathid, OpenflowVersion ofVersion){
-        FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
-        salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
-        if(flowStats.getCookie() != null) {
-            salFlowStatsBuilder.setCookie(new FlowCookie(flowStats.getCookie()));
-        }
-        DurationBuilder time = new DurationBuilder();
-        time.setSecond(new Counter32(flowStats.getDurationSec()));
-        time.setNanosecond(new Counter32(flowStats.getDurationNsec()));
-        salFlowStatsBuilder.setDuration(time.build());
-
-        salFlowStatsBuilder.setHardTimeout(flowStats.getHardTimeout());
-        salFlowStatsBuilder.setIdleTimeout(flowStats.getIdleTimeout());
-        salFlowStatsBuilder.setPacketCount(new Counter64(flowStats.getPacketCount()));
-        salFlowStatsBuilder.setPriority(flowStats.getPriority());
-        salFlowStatsBuilder.setTableId(flowStats.getTableId());
-        if(flowStats.getMatchV10() != null){
-            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowStats.getMatchV10(), datapathid, OpenflowVersion.OF10).build());
-            if(flowStats.getAction() != null && flowStats.getAction().size()!=0){
-                salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.wrapOF10ActionsToInstruction(flowStats.getAction(), ofVersion));
-            }
-        }
-        if(flowStats.getMatch() != null){
-            MatchBuilder matchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(flowStats.getMatch(),datapathid, ofVersion);
-
-            AugmentTuple<Match> matchExtensionWrap =
-                    MatchExtensionHelper.processAllExtensions(
-                            flowStats.getMatch().getMatchEntry(), ofVersion, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
-            if (matchExtensionWrap != null) {
-                matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
-            }
-
-
-            salFlowStatsBuilder.setMatch(matchBuilder.build());
-            salFlowStatsBuilder.setFlags(
-                    new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(),
-                            flowStats.getFlags().isOFPFFRESETCOUNTS(),
-                            flowStats.getFlags().isOFPFFNOPKTCOUNTS(),
-                            flowStats.getFlags().isOFPFFNOBYTCOUNTS(),
-                            flowStats.getFlags().isOFPFFSENDFLOWREM()));
-        }
-        if(flowStats.getInstruction()!= null){
-            salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.toSALInstruction(flowStats.getInstruction(), ofVersion));
-        }
-
-        return salFlowStatsBuilder.build();
-    }
-}
index 2a73c8bbaa0b98e9d8bd890adf02f74404c0e5d5..527da0910d37db00ef8c9f46c18af15ffa8ea647 100644 (file)
@@ -1,22 +1,29 @@
-/**
- * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+/*
+ * 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.openflow.md.core.sal.convertor;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
-
+import java.util.Optional;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
@@ -28,86 +35,53 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
 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.buckets.grouping.BucketsListBuilder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * This Utility class decodes the SAL - Group Mod Message and encodes into a OF
+ * Decodes the SAL - Group Mod Message and encodes into a OF
  * Library for the OFPT_GROUP_MOD Message. Input:SAL Layer Group command data.
- * Output:GroupModInput Message.
- *
  *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * Optional<GroupModInputBuilder> ofGroup = convertorManager.convert(salGroup, data);
+ * }
+ * </pre>
  */
-public final class GroupConvertor {
+public class GroupConvertor extends Convertor<Group, GroupModInputBuilder, VersionDatapathIdConvertorData> {
+    private static final List<Class<? extends DataContainer>> TYPES = Arrays.asList(Group.class, AddGroupInput.class, RemoveGroupInput.class, UpdatedGroup.class);
+    /**
+     * Create default empty group mod input builder
+     * Use this method, if result from convertor is empty.
+     *
+     * @param version Openflow version
+     * @return default empty group mod input builder
+     */
+    public static GroupModInputBuilder defaultResult(short version) {
+        return new GroupModInputBuilder()
+                .setVersion(version);
+    }
 
     private static final Logger LOG = LoggerFactory.getLogger(GroupConvertor.class);
-
     private static final Integer DEFAULT_WEIGHT = 0;
     private static final Long OFPP_ANY = Long.parseLong("ffffffff", 16);
     private static final Long DEFAULT_WATCH_PORT = OFPP_ANY;
     private static final Long OFPG_ANY = Long.parseLong("ffffffff", 16);
     private static final Long DEFAULT_WATCH_GROUP = OFPG_ANY;
-    private static final Comparator<Bucket> comparator = new Comparator<Bucket>(){
-        @Override
-        public int compare(Bucket bucket1,
-                           Bucket bucket2) {
-            if(bucket1.getBucketId() == null || bucket2.getBucketId() == null) return 0;
-            return  bucket1.getBucketId().getValue().compareTo(bucket2.getBucketId().getValue());
-        }
+    private static final Comparator<Bucket> COMPARATOR = (bucket1, bucket2) -> {
+        if (bucket1.getBucketId() == null || bucket2.getBucketId() == null) return 0;
+        return bucket1.getBucketId().getValue().compareTo(bucket2.getBucketId().getValue());
     };
 
-    private GroupConvertor() {
-
-    }
-
-    public static GroupModInputBuilder toGroupModInput(
-
-    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group source, short version,BigInteger datapathid) {
-        List<BucketsList> bucketLists = null;
-        GroupModInputBuilder groupModInputBuilder = new GroupModInputBuilder();
-        if (source instanceof AddGroupInput) {
-            groupModInputBuilder.setCommand(GroupModCommand.OFPGCADD);
-        } else if (source instanceof RemoveGroupInput) {
-            groupModInputBuilder.setCommand(GroupModCommand.OFPGCDELETE);
-        } else if (source instanceof UpdatedGroup) {
-            groupModInputBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
-        }
-
-        if (GroupTypes.GroupAll.equals(source.getGroupType())) {
-            groupModInputBuilder.setType(GroupType.OFPGTALL);
-        }
-
-        if (GroupTypes.GroupSelect.equals(source.getGroupType())) {
-            groupModInputBuilder.setType(GroupType.OFPGTSELECT);
-        }
-
-        if (GroupTypes.GroupIndirect.equals(source.getGroupType())) {
-            groupModInputBuilder.setType(GroupType.OFPGTINDIRECT);
-        }
-
-        if (GroupTypes.GroupFf.equals(source.getGroupType())) {
-            groupModInputBuilder.setType(GroupType.OFPGTFF);
-        }
-
-        groupModInputBuilder.setGroupId(new GroupId(source.getGroupId().getValue()));
-        // Only if the bucket is configured for the group then add it
-        // During group deletion donot push the buckets
-        if(groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
-            if ((source.getBuckets() != null) && (source.getBuckets().getBucket().size() != 0)) {
-
-                Collections.sort(source.getBuckets().getBucket(), comparator);
-
-                bucketLists = salToOFBucketList(source.getBuckets(), version, source.getGroupType().getIntValue(), datapathid);
-                groupModInputBuilder.setBucketsList(bucketLists);
-            }
-        }
-        groupModInputBuilder.setVersion(version);
-        return groupModInputBuilder;
-
-    }
-
-    private static List<BucketsList> salToOFBucketList(Buckets buckets, short version, int groupType,BigInteger datapathid) {
+    private List<BucketsList> salToOFBucketList(Buckets buckets, short version, int groupType, BigInteger datapathid) {
         final List<BucketsList> bucketLists = new ArrayList<>();
+        final ActionConvertorData data = new ActionConvertorData(version);
+        data.setDatapathId(datapathid);
+
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket groupBucket : buckets
                 .getBucket()) {
             BucketsListBuilder bucketBuilder = new BucketsListBuilder();
@@ -116,11 +90,14 @@ public final class GroupConvertor {
             salToOFBucketListWatchGroup(groupBucket, bucketBuilder, groupType);
             salToOFBucketListWatchPort(groupBucket, bucketBuilder, groupType);
 
-            List<Action> bucketActionList = ActionConvertor.getActions(groupBucket.getAction(), version, datapathid, null);
-            bucketBuilder.setAction(bucketActionList);
+            Optional<List<Action>> bucketActionList = getConvertorExecutor().convert(
+                    groupBucket.getAction(), data);
+
+            bucketBuilder.setAction(bucketActionList.orElse(Collections.emptyList()));
             BucketsList bucket = bucketBuilder.build();
             bucketLists.add(bucket);
         }
+
         return bucketLists;
 
     }
@@ -149,7 +126,7 @@ public final class GroupConvertor {
 
     private static void salToOFBucketListWeight(Bucket groupBucket, BucketsListBuilder bucketBuilder, int groupType) {
         if (null != groupBucket.getWeight()) {
-            bucketBuilder.setWeight(groupBucket.getWeight().intValue());
+            bucketBuilder.setWeight(groupBucket.getWeight());
         } else {
             bucketBuilder.setWeight(DEFAULT_WEIGHT);
             if (groupType == GroupType.OFPGTSELECT.getIntValue()) {
@@ -158,4 +135,53 @@ public final class GroupConvertor {
         }
     }
 
-}
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return  TYPES;
+    }
+
+    @Override
+    public GroupModInputBuilder convert(Group source, VersionDatapathIdConvertorData data) {
+        GroupModInputBuilder groupModInputBuilder = new GroupModInputBuilder();
+        if (source instanceof AddGroupInput) {
+            groupModInputBuilder.setCommand(GroupModCommand.OFPGCADD);
+        } else if (source instanceof RemoveGroupInput) {
+            groupModInputBuilder.setCommand(GroupModCommand.OFPGCDELETE);
+        } else if (source instanceof UpdatedGroup) {
+            groupModInputBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
+        }
+
+        if (GroupTypes.GroupAll.equals(source.getGroupType())) {
+            groupModInputBuilder.setType(GroupType.OFPGTALL);
+        }
+
+        if (GroupTypes.GroupSelect.equals(source.getGroupType())) {
+            groupModInputBuilder.setType(GroupType.OFPGTSELECT);
+        }
+
+        if (GroupTypes.GroupIndirect.equals(source.getGroupType())) {
+            groupModInputBuilder.setType(GroupType.OFPGTINDIRECT);
+        }
+
+        if (GroupTypes.GroupFf.equals(source.getGroupType())) {
+            groupModInputBuilder.setType(GroupType.OFPGTFF);
+        }
+
+        groupModInputBuilder.setGroupId(new GroupId(source.getGroupId().getValue()));
+
+        // Only if the bucket is configured for the group then add it
+        // During group deletion do not push the buckets
+        if (groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
+            if ((source.getBuckets() != null) && (source.getBuckets().getBucket().size() != 0)) {
+
+                Collections.sort(source.getBuckets().getBucket(), COMPARATOR);
+
+                List<BucketsList> bucketLists = salToOFBucketList(source.getBuckets(), data.getVersion(), source.getGroupType().getIntValue(), data.getDatapathId());
+                groupModInputBuilder.setBucketsList(bucketLists);
+            }
+        }
+
+        groupModInputBuilder.setVersion(data.getVersion());
+        return groupModInputBuilder;
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java
new file mode 100644 (file)
index 0000000..6b58fa3
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+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.group.types.rev131018.BucketId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.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.desc._case.multipart.reply.group.desc.GroupDesc;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts GroupDesc message from library to MD SAL defined GroupDescStats
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<List<GroupDescStats>> salGroupStats = convertorManager.convert(ofGroupStats, data);
+ * }
+ * </pre>
+ */
+public class GroupDescStatsResponseConvertor extends Convertor<List<GroupDesc>, List<GroupDescStats>, VersionConvertorData> {
+
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(GroupDesc.class);
+
+    private org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets toSALBucketsDesc(List<BucketsList> bucketDescStats, short version) {
+        final ActionResponseConvertorData data = new ActionResponseConvertorData(version);
+        data.setActionPath(ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION);
+
+        org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder salBucketsDesc =
+                new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder();
+        List<Bucket> allBuckets = new ArrayList<>();
+        int bucketKey = 0;
+
+        for (BucketsList bucketDetails : bucketDescStats) {
+            BucketBuilder bucketDesc = new BucketBuilder();
+            final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> convertedSalActions =
+                    getConvertorExecutor().convert(
+                            bucketDetails.getAction(), data);
+
+
+            if (convertedSalActions.isPresent()) {
+                List<Action> actions = new ArrayList<>();
+
+                int actionKey = 0;
+
+                for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : convertedSalActions.get()) {
+                    ActionBuilder wrappedAction = new ActionBuilder();
+                    wrappedAction.setAction(action);
+                    wrappedAction.setKey(new ActionKey(actionKey));
+                    wrappedAction.setOrder(actionKey);
+                    actions.add(wrappedAction.build());
+                    actionKey++;
+                }
+
+                bucketDesc.setAction(actions);
+            } else {
+                bucketDesc.setAction(Collections.emptyList());
+            }
+
+            bucketDesc.setWeight(bucketDetails.getWeight());
+            bucketDesc.setWatchPort(bucketDetails.getWatchPort().getValue());
+            bucketDesc.setWatchGroup(bucketDetails.getWatchGroup());
+            BucketId bucketId = new BucketId((long) bucketKey);
+            bucketDesc.setBucketId(bucketId);
+            bucketDesc.setKey(new BucketKey(bucketId));
+            bucketKey++;
+            allBuckets.add(bucketDesc.build());
+        }
+
+        salBucketsDesc.setBucket(allBuckets);
+        return salBucketsDesc.build();
+    }
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public List<GroupDescStats> convert(List<GroupDesc> source, VersionConvertorData data) {
+        List<GroupDescStats> convertedSALGroupsDesc = new ArrayList<>();
+
+        for (GroupDesc groupDesc : source) {
+            GroupDescStatsBuilder salGroupDescStats = new GroupDescStatsBuilder();
+
+            salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.getBucketsList(), data.getVersion()));
+            salGroupDescStats.setGroupId(new GroupId(groupDesc.getGroupId().getValue()));
+            salGroupDescStats.setGroupType(GroupTypes.forValue(groupDesc.getType().getIntValue()));
+            salGroupDescStats.setKey(new GroupDescStatsKey(salGroupDescStats.getGroupId()));
+
+            convertedSALGroupsDesc.add(salGroupDescStats.build());
+        }
+
+        return convertedSALGroupsDesc;
+    }
+}
\ No newline at end of file
index 99c8cdf619dcc4d2fa82f48a4ab34f65bca33811..aea519d4d9320c268be3d2570dcdda46a8327f67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
+ * 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,
@@ -9,24 +9,16 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
-
-import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import java.util.Set;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
-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.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.Buckets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.BucketsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.DurationBuilder;
@@ -36,141 +28,76 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.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.group.stats.BucketStats;
-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.yangtools.yang.binding.DataContainer;
 
 /**
- * Class is an utility class for converting group related statistics messages coming from switch to MD-SAL
- * messages.
- * @author avishnoi@in.ibm.com
+ * Converts group related statistics messages coming from switch to MD-SAL messages.
  *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<List<GroupStats>> salGroupStats = convertorManager.convert(ofGroupStats, data);
+ * }
+ * </pre>
  */
-public class GroupStatsResponseConvertor {
-
-    public List<GroupStats> toSALGroupStatsList(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
-            .multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats> allGroupStats){
-        List<GroupStats> convertedSALGroups = new ArrayList<>();
-        for(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
-                .multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats group: allGroupStats){
-            convertedSALGroups.add(toSALGroupStats(group));
-        }
-        return convertedSALGroups;
-
-    }
-    /**
-     * Method convert GroupStats message from library to MD SAL defined GroupStats
-     * @param groupStats GroupStats from library
-     * @return GroupStats -- GroupStats defined in MD-SAL
-     */
-    public GroupStats toSALGroupStats(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.
-            multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats groupStats){
+public class GroupStatsResponseConvertor extends Convertor<
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats>,
+        List<GroupStats>,
+        VersionConvertorData> {
 
-        GroupStatsBuilder salGroupStats = new GroupStatsBuilder();
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats.class);
 
-        salGroupStats.setBuckets(toSALBuckets(groupStats.getBucketStats()));
-        salGroupStats.setByteCount(new Counter64(groupStats.getByteCount()));
-
-        DurationBuilder time = new DurationBuilder();
-        time.setSecond(new Counter32(groupStats.getDurationSec()));
-        time.setNanosecond(new Counter32(groupStats.getDurationNsec()));
-
-        salGroupStats.setDuration(time.build());
-        salGroupStats.setGroupId(new GroupId(groupStats.getGroupId().getValue()));
-        salGroupStats.setPacketCount(new Counter64(groupStats.getPacketCount()));
-        salGroupStats.setRefCount(new Counter32(groupStats.getRefCount()));
-        salGroupStats.setKey(new GroupStatsKey(salGroupStats.getGroupId()));
-
-        return salGroupStats.build();
-    }
-
-    public Buckets toSALBuckets(
-            List<BucketStats> bucketStats ){
-
-        BucketsBuilder salBuckets  = new BucketsBuilder();
+    private Buckets toSALBuckets(List<BucketStats> bucketStats) {
+        BucketsBuilder salBuckets = new BucketsBuilder();
 
         List<BucketCounter> allBucketStats = new ArrayList<>();
         int bucketKey = 0;
-        for(BucketStats bucketStat : bucketStats){
+
+        for (BucketStats bucketStat : bucketStats) {
             BucketCounterBuilder bucketCounter = new BucketCounterBuilder();
             bucketCounter.setByteCount(new Counter64(bucketStat.getByteCount()));
             bucketCounter.setPacketCount(new Counter64(bucketStat.getPacketCount()));
-            BucketId bucketId = new BucketId((long)bucketKey);
+            BucketId bucketId = new BucketId((long) bucketKey);
             bucketCounter.setKey(new BucketCounterKey(bucketId));
             bucketCounter.setBucketId(bucketId);
             bucketKey++;
             allBucketStats.add(bucketCounter.build());
         }
+
         salBuckets.setBucketCounter(allBucketStats);
         return salBuckets.build();
     }
 
-
-    public List<GroupDescStats> toSALGroupDescStatsList(
-            List<GroupDesc> allGroupDescStats, OpenflowVersion ofVersion){
-
-        List<GroupDescStats> convertedSALGroupsDesc = new ArrayList<>();
-        for(GroupDesc groupDesc: allGroupDescStats){
-            convertedSALGroupsDesc.add(toSALGroupDescStats(groupDesc, ofVersion));
-        }
-        return convertedSALGroupsDesc;
-
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
     }
-    /**
-     * Method convert GroupStats message from library to MD SAL defined GroupStats
-     * @param groupDesc GroupStats from library
-     * @param ofVersion current ofp version
-     * @return GroupStats -- GroupStats defined in MD-SAL
-     */
-    public GroupDescStats toSALGroupDescStats(GroupDesc groupDesc, OpenflowVersion ofVersion){
 
-        GroupDescStatsBuilder salGroupDescStats = new GroupDescStatsBuilder();
+    @Override
+    public List<GroupStats> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats> source, VersionConvertorData data) {
+        List<GroupStats> convertedSALGroups = new ArrayList<>();
 
-        salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.getBucketsList(), ofVersion));
-        salGroupDescStats.setGroupId(new GroupId(groupDesc.getGroupId().getValue()));
-        salGroupDescStats.setGroupType(GroupTypes.forValue(groupDesc.getType().getIntValue()));
-        salGroupDescStats.setKey(new GroupDescStatsKey(salGroupDescStats.getGroupId()));
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
+                .multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats groupStats : source) {
+            GroupStatsBuilder salGroupStats = new GroupStatsBuilder();
 
-        return salGroupDescStats.build();
-    }
+            salGroupStats.setBuckets(toSALBuckets(groupStats.getBucketStats()));
+            salGroupStats.setByteCount(new Counter64(groupStats.getByteCount()));
 
-    public  org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets toSALBucketsDesc(
-            List<BucketsList> bucketDescStats, OpenflowVersion ofVersion ){
+            DurationBuilder time = new DurationBuilder();
+            time.setSecond(new Counter32(groupStats.getDurationSec()));
+            time.setNanosecond(new Counter32(groupStats.getDurationNsec()));
 
-        org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder salBucketsDesc  =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder();
-        List<Bucket> allBuckets = new ArrayList<>();
-        int bucketKey = 0;
-        for(BucketsList bucketDetails : bucketDescStats){
-            BucketBuilder bucketDesc = new BucketBuilder();
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedSalActions =
-                    ActionConvertor.toMDSalActions (bucketDetails.getAction(), ofVersion,
-                            ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION);
-
-            List<Action> actions = new ArrayList<>();
-            int actionKey = 0;
-            for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : convertedSalActions){
-                ActionBuilder wrappedAction = new ActionBuilder();
-                wrappedAction.setAction(action);
-                wrappedAction.setKey(new ActionKey(actionKey));
-                wrappedAction.setOrder(actionKey);
-                actions.add(wrappedAction.build());
-                actionKey++;
-            }
-            bucketDesc.setAction(actions);
-            bucketDesc.setWeight(bucketDetails.getWeight());
-            bucketDesc.setWatchPort(bucketDetails.getWatchPort().getValue());
-            bucketDesc.setWatchGroup(bucketDetails.getWatchGroup());
-            BucketId bucketId = new BucketId((long)bucketKey);
-            bucketDesc.setBucketId(bucketId);
-            bucketDesc.setKey(new BucketKey(bucketId));
-            bucketKey++;
-            allBuckets.add(bucketDesc.build());
+            salGroupStats.setDuration(time.build());
+            salGroupStats.setGroupId(new GroupId(groupStats.getGroupId().getValue()));
+            salGroupStats.setPacketCount(new Counter64(groupStats.getPacketCount()));
+            salGroupStats.setRefCount(new Counter32(groupStats.getRefCount()));
+            salGroupStats.setKey(new GroupStatsKey(salGroupStats.getGroupId()));
+            convertedSALGroups.add(salGroupStats.build());
         }
-        salBucketsDesc.setBucket(allBuckets);
-        return salBucketsDesc.build();
-    }
 
+        return convertedSALGroups;
+    }
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java
new file mode 100644 (file)
index 0000000..218c545
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts list of OF library config meter stats to MD-SAL config meter stats.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<List<MeterConfigStats>> salMeterConfigStats = convertorManager.convert(ofMeterConfigStats, data);
+ * }
+ * </pre>
+ */
+public class MeterConfigStatsResponseConvertor extends Convertor<List<MeterConfig>, List<MeterConfigStats>, VersionConvertorData> {
+
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(MeterConfig.class);
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public List<MeterConfigStats> convert(List<MeterConfig> source, VersionConvertorData data) {
+        List<MeterConfigStats> listMeterConfigStats = new ArrayList<>();
+
+        for (MeterConfig meterConfig : source) {
+            MeterConfigStatsBuilder meterConfigStatsBuilder = new MeterConfigStatsBuilder();
+            meterConfigStatsBuilder.setMeterId(new MeterId(meterConfig.getMeterId().getValue()));
+            meterConfigStatsBuilder.setKey(new MeterConfigStatsKey(meterConfigStatsBuilder.getMeterId()));
+            MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
+            List<Bands> bands = meterConfig.getBands();
+
+            MeterFlags meterFlags = new MeterFlags(meterConfig.getFlags().isOFPMFBURST(),
+                    meterConfig.getFlags().isOFPMFKBPS(),
+                    meterConfig.getFlags().isOFPMFPKTPS(),
+                    meterConfig.getFlags().isOFPMFSTATS());
+
+            meterConfigStatsBuilder.setFlags(meterFlags);
+            List<MeterBandHeader> listBandHeaders = new ArrayList<>();
+            int bandKey = 0;
+
+            for (Bands band : bands) {
+                MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
+                if (band.getMeterBand() instanceof MeterBandDropCase) {
+                    MeterBandDropCase dropCaseBand = (MeterBandDropCase) band.getMeterBand();
+                    MeterBandDrop dropBand = dropCaseBand.getMeterBandDrop();
+                    DropBuilder dropBuilder = new DropBuilder();
+                    dropBuilder.setDropBurstSize(dropBand.getBurstSize());
+                    dropBuilder.setDropRate(dropBand.getRate());
+                    meterBandHeaderBuilder.setBandType(dropBuilder.build());
+
+                    meterBandHeaderBuilder.setBandBurstSize(dropBand.getBurstSize());
+                    meterBandHeaderBuilder.setBandRate(dropBand.getRate());
+                    BandId bandId = new BandId((long) bandKey);
+                    meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
+                    meterBandHeaderBuilder.setBandId(bandId);
+
+                    MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
+                    meterBandTypesBuilder.setFlags(new MeterBandType(true, false, false));
+                    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
+
+                    listBandHeaders.add(meterBandHeaderBuilder.build());
+                } else if (band.getMeterBand() instanceof MeterBandDscpRemarkCase) {
+                    MeterBandDscpRemarkCase dscpRemarkCaseBand = (MeterBandDscpRemarkCase) band.getMeterBand();
+                    MeterBandDscpRemark dscpRemarkBand = dscpRemarkCaseBand.getMeterBandDscpRemark();
+                    DscpRemarkBuilder dscpRemarkBuilder = new DscpRemarkBuilder();
+                    dscpRemarkBuilder.setDscpRemarkBurstSize(dscpRemarkBand.getBurstSize());
+                    dscpRemarkBuilder.setDscpRemarkRate(dscpRemarkBand.getRate());
+                    dscpRemarkBuilder.setPrecLevel(dscpRemarkBand.getPrecLevel());
+                    meterBandHeaderBuilder.setBandType(dscpRemarkBuilder.build());
+
+                    meterBandHeaderBuilder.setBandBurstSize(dscpRemarkBand.getBurstSize());
+                    meterBandHeaderBuilder.setBandRate(dscpRemarkBand.getRate());
+                    BandId bandId = new BandId((long) bandKey);
+                    meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
+                    meterBandHeaderBuilder.setBandId(bandId);
+
+                    MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
+                    meterBandTypesBuilder.setFlags(new MeterBandType(false, true, false));
+                    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
+                    listBandHeaders.add(meterBandHeaderBuilder.build());
+
+                } else if (band.getMeterBand() instanceof MeterBandExperimenterCase) {
+                    MeterBandExperimenterCase experimenterCaseBand = (MeterBandExperimenterCase) band.getMeterBand();
+                    MeterBandExperimenter experimenterBand = experimenterCaseBand.getMeterBandExperimenter();
+                    ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
+                    experimenterBuilder.setExperimenterBurstSize(experimenterBand.getBurstSize());
+                    experimenterBuilder.setExperimenterRate(experimenterBand.getRate());
+                    meterBandHeaderBuilder.setBandType(experimenterBuilder.build());
+
+                    meterBandHeaderBuilder.setBandBurstSize(experimenterBand.getBurstSize());
+                    meterBandHeaderBuilder.setBandRate(experimenterBand.getRate());
+                    BandId bandId = new BandId((long) bandKey);
+                    meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
+                    meterBandHeaderBuilder.setBandId(bandId);
+
+                    MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
+                    meterBandTypesBuilder.setFlags(new MeterBandType(false, false, true));
+                    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
+
+                    listBandHeaders.add(meterBandHeaderBuilder.build());
+
+                }
+
+                bandKey++;
+            }
+
+            meterBandHeadersBuilder.setMeterBandHeader(listBandHeaders);
+            meterConfigStatsBuilder.setMeterBandHeaders(meterBandHeadersBuilder.build());
+            listMeterConfigStats.add(meterConfigStatsBuilder.build());
+        }
+
+        return listMeterConfigStats;
+    }
+}
\ No newline at end of file
index 41a10aaf29ffaf1af3b79efd0c30f910e3cca911..8a7dc4274553a09f66ebab7dc7a6808df3e61ec2 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -8,17 +8,16 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
-/****
- *
- * This class is used for converting the data from SAL layer to OF Library Layer for Meter Mod Command.
- *
- */
-
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
-
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter;
@@ -41,74 +40,40 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class MeterConvertor {
+/**
+ * Converts a MD-SAL meter mod command into the OF library meter mod command.
+ * <p>
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<MeterModInputBuilder> ofMeter = convertorManager.convert(salMeter, data);
+ * }
+ * </pre>
+ */
+public class MeterConvertor extends Convertor<Meter, MeterModInputBuilder, VersionConvertorData> {
     private static final Logger LOG = LoggerFactory.getLogger(MeterConvertor.class);
+    private static final List<Class<? extends DataContainer>> TYPES = Arrays.asList(Meter.class, AddMeterInput.class, RemoveMeterInput.class, UpdatedMeter.class);
 
-    private MeterConvertor() {
-
-    }
-
-    // Get all the data for the meter from the Yang/SAL-Layer
     /**
-     * @param version of version
-     * @param source Data source
-     * @return MeterModInput required by OF Library
+     * Create default empty meter mot input builder.
+     * Use this method, if result from convertor is empty.
+     *
+     * @param version Openflow version
+     * @return default empty meter mod input builder
      */
-    public static MeterModInputBuilder toMeterModInput(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter source, short version) {
-
-        MeterModInputBuilder meterModInputBuilder = new MeterModInputBuilder();
-        List<Bands> bands = new ArrayList<Bands>();
-
-        if (source instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) {
-            meterModInputBuilder.setCommand(MeterModCommand.OFPMCADD);
-        } else if (source instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) {
-            meterModInputBuilder.setCommand(MeterModCommand.OFPMCDELETE);
-        } else if (source instanceof UpdatedMeter) {
-            meterModInputBuilder.setCommand(MeterModCommand.OFPMCMODIFY);
-        }
-
-        meterModInputBuilder.setMeterId(new MeterId(source.getMeterId().getValue()));
-
-        if (null != source.getFlags()) {
-            meterModInputBuilder.setFlags(new MeterFlags(source.getFlags().isMeterBurst(), source.getFlags()
-                .isMeterKbps(), source.getFlags().isMeterPktps(), source.getFlags().isMeterStats()));
-        } else {
-
-            /*
-             * As per 0F1.3.1,The rate field indicates the rate value above
-             * which the corresponding band may apply to packets (see 5.7.1).
-             * The rate value is in kilobit per seconds, unless the flags eld
-             * includes OFPMF_PKTPS, in which case the rate is in packets per
-             * seconds.
-             */
-
-            meterModInputBuilder.setFlags(new MeterFlags(false, false, true, false));
-        }
-        if (source.getMeterBandHeaders() != null) {
-            getBandsFromSAL(source.getMeterBandHeaders(), bands);
-            meterModInputBuilder.setBands(bands);
-        } else {
-            LOG.error("For this meter Id" + source.getMeterId().getValue() + ",no associated band data found!");
-        }
-
-        meterModInputBuilder.setVersion(version);
-        return meterModInputBuilder;
+    public static MeterModInputBuilder defaultResult(short version) {
+        return new MeterModInputBuilder()
+                .setVersion(version)
+                .setFlags(new MeterFlags(false, false, true, false));
     }
 
     private static void getBandsFromSAL(MeterBandHeaders meterBandHeaders, List<Bands> bands) {
-
-        Iterator<MeterBandHeader> bandHeadersIterator = meterBandHeaders.getMeterBandHeader().iterator();
-        MeterBandHeader meterBandHeader;
-
-        BandsBuilder bandsB = null;
-
-        while (bandHeadersIterator.hasNext()) {
-            meterBandHeader = bandHeadersIterator.next();
-            MeterBand meterBandItem = null;
+        for (MeterBandHeader meterBandHeader : meterBandHeaders.getMeterBandHeader()) {
             // The band types :drop,DSCP_Remark or experimenter.
             if (null != meterBandHeader.getMeterBandTypes() &&
                     null != meterBandHeader.getMeterBandTypes().getFlags()) {
@@ -122,8 +87,8 @@ public final class MeterConvertor {
                         meterBandDropBuilder.setBurstSize(drop.getDropBurstSize());
                         meterBandDropBuilder.setRate(drop.getDropRate());
                         dropCaseBuilder.setMeterBandDrop(meterBandDropBuilder.build());
-                        meterBandItem = dropCaseBuilder.build();
-                        bandsB = new BandsBuilder();
+                        MeterBand meterBandItem = dropCaseBuilder.build();
+                        BandsBuilder bandsB = new BandsBuilder();
                         bandsB.setMeterBand(meterBandItem);
                         // Bands list
                         bands.add(bandsB.build());
@@ -140,8 +105,8 @@ public final class MeterConvertor {
                         meterBandDscpRemarkBuilder.setRate(dscpRemark.getDscpRemarkRate());
                         meterBandDscpRemarkBuilder.setPrecLevel(dscpRemark.getPrecLevel());
                         dscpCaseBuilder.setMeterBandDscpRemark(meterBandDscpRemarkBuilder.build());
-                        meterBandItem = dscpCaseBuilder.build();
-                        bandsB = new BandsBuilder();
+                        MeterBand meterBandItem = dscpCaseBuilder.build();
+                        BandsBuilder bandsB = new BandsBuilder();
                         bandsB.setMeterBand(meterBandItem);
                         // Bands list
                         bands.add(bandsB.build());
@@ -161,8 +126,8 @@ public final class MeterConvertor {
                         meterBandExperimenterBuilder.addAugmentation(ExperimenterIdMeterBand.class, expBuilder.build());
                         // TODO - implement / finish experimenter meter band translation
                         experimenterCaseBuilder.setMeterBandExperimenter(meterBandExperimenterBuilder.build());
-                        meterBandItem = experimenterCaseBuilder.build();
-                        bandsB = new BandsBuilder();
+                        MeterBand meterBandItem = experimenterCaseBuilder.build();
+                        BandsBuilder bandsB = new BandsBuilder();
                         bandsB.setMeterBand(meterBandItem);
                         // Bands list
                         bands.add(bandsB.build());
@@ -170,7 +135,6 @@ public final class MeterConvertor {
                         logBandTypeMissing(MeterBandType.OFPMBTEXPERIMENTER);
                     }
                 }
-
             } else {
                 LOG.error("Invalid meter band data found.");
             }
@@ -182,4 +146,50 @@ public final class MeterConvertor {
         LOG.error("BandType: {} No Band Data found", meterBandType);
     }
 
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return  TYPES;
+    }
+
+    @Override
+    public MeterModInputBuilder convert(Meter source, VersionConvertorData data) {
+        MeterModInputBuilder meterModInputBuilder = new MeterModInputBuilder();
+        List<Bands> bands = new ArrayList<>();
+
+        if (source instanceof AddMeterInput) {
+            meterModInputBuilder.setCommand(MeterModCommand.OFPMCADD);
+        } else if (source instanceof RemoveMeterInput) {
+            meterModInputBuilder.setCommand(MeterModCommand.OFPMCDELETE);
+        } else if (source instanceof UpdatedMeter) {
+            meterModInputBuilder.setCommand(MeterModCommand.OFPMCMODIFY);
+        }
+
+        meterModInputBuilder.setMeterId(new MeterId(source.getMeterId().getValue()));
+
+        if (null != source.getFlags()) {
+            meterModInputBuilder.setFlags(new MeterFlags(source.getFlags().isMeterBurst(), source.getFlags()
+                    .isMeterKbps(), source.getFlags().isMeterPktps(), source.getFlags().isMeterStats()));
+        } else {
+
+            /*
+             * As per 0F1.3.1,The rate field indicates the rate value above
+             * which the corresponding band may apply to packets (see 5.7.1).
+             * The rate value is in kilobit per seconds, unless the flags eld
+             * includes OFPMF_PKTPS, in which case the rate is in packets per
+             * seconds.
+             */
+
+            meterModInputBuilder.setFlags(new MeterFlags(false, false, true, false));
+        }
+
+        if (source.getMeterBandHeaders() != null) {
+            getBandsFromSAL(source.getMeterBandHeaders(), bands);
+            meterModInputBuilder.setBands(bands);
+        } else {
+            LOG.error("For this meter Id" + source.getMeterId().getValue() + ",no associated band data found!");
+        }
+
+        meterModInputBuilder.setVersion(data.getVersion());
+        return meterModInputBuilder;
+    }
 }
index 9964cc31bf1a1506ee7c2da91422293076d20dfd..654e8cde9787e818926c211311fa4a141edfa9bc 100644 (file)
@@ -9,24 +9,16 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat;
@@ -35,177 +27,75 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
- * Class is an utility class for converting group related statistics messages coming from switch to MD-SAL
- * messages.
+ * Converts list of OF library meter stats to MD-SAL meter stats.
  *
- * @author avishnoi@in.ibm.com
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<List<MeterStats>> salMeterStats = convertorManager.convert(ofMeterStats, data);
+ * }
+ * </pre>
  */
-public class MeterStatsResponseConvertor {
+public class MeterStatsResponseConvertor extends Convertor<
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
+                .multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats>,
+        List<MeterStats>,
+        VersionConvertorData> {
 
-    /**
-     * Method converts list of OF Meter Stats to SAL Meter Stats.
-     *
-     * @param allMeterStats all meter stats
-     * @return List of MeterStats
-     */
-    public List<MeterStats> toSALMeterStatsList(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
-                    .multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats> allMeterStats) {
-        List<MeterStats> convertedSALMeters = new ArrayList<MeterStats>();
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.
-                multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats meter : allMeterStats) {
-            convertedSALMeters.add(toSALMeterStats(meter));
-        }
-        return convertedSALMeters;
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats.class);
 
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
     }
 
-    /**
-     * Method convert MeterStats message from library to MD SAL defined MeterStats
-     *
-     * @param meterStats MeterStats from library
-     * @return MeterStats -- MeterStats defined in MD-SAL
-     */
-    public MeterStats toSALMeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
-                                              .multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats meterStats) {
-
-        MeterStatsBuilder salMeterStats = new MeterStatsBuilder();
-        salMeterStats.setByteInCount(new Counter64(meterStats.getByteInCount()));
-
-        DurationBuilder time = new DurationBuilder();
-        time.setSecond(new Counter32(meterStats.getDurationSec()));
-        time.setNanosecond(new Counter32(meterStats.getDurationNsec()));
-        salMeterStats.setDuration(time.build());
-
-        salMeterStats.setFlowCount(new Counter32(meterStats.getFlowCount()));
-        salMeterStats.setMeterId(new MeterId(meterStats.getMeterId().getValue()));
-        salMeterStats.setPacketInCount(new Counter64(meterStats.getPacketInCount()));
-        salMeterStats.setKey(new MeterStatsKey(salMeterStats.getMeterId()));
+    @Override
+    public List<MeterStats> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats> source, VersionConvertorData data) {
+        List<MeterStats> convertedSALMeters = new ArrayList<>();
 
-        List<MeterBandStats> allMeterBandStats = meterStats.getMeterBandStats();
-
-        MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
-        List<BandStat> listAllBandStats = new ArrayList<BandStat>();
-        int bandKey = 0;
-        for (MeterBandStats meterBandStats : allMeterBandStats) {
-            BandStatBuilder bandStatBuilder = new BandStatBuilder();
-            bandStatBuilder.setByteBandCount(new Counter64(meterBandStats.getByteBandCount()));
-            bandStatBuilder.setPacketBandCount(new Counter64(meterBandStats.getPacketBandCount()));
-            BandId bandId = new BandId((long) bandKey);
-            bandStatBuilder.setKey(new BandStatKey(bandId));
-            bandStatBuilder.setBandId(bandId);
-            bandKey++;
-            listAllBandStats.add(bandStatBuilder.build());
-        }
-        meterBandStatsBuilder.setBandStat(listAllBandStats);
-        salMeterStats.setMeterBandStats(meterBandStatsBuilder.build());
-        return salMeterStats.build();
-    }
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.
+                multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats meterStats : source) {
+            // Convert MeterStats message from library to MD SAL defined MeterStats
+            MeterStatsBuilder salMeterStats = new MeterStatsBuilder();
+            salMeterStats.setByteInCount(new Counter64(meterStats.getByteInCount()));
 
-    /**
-     * Method convert list of OF Meter config Stats to SAL Meter Config stats
-     *
-     * @param allMeterConfigs all meter configs
-     * @return list of MeterConfigStats
-     */
-    public List<MeterConfigStats> toSALMeterConfigList(List<MeterConfig> allMeterConfigs) {
+            DurationBuilder time = new DurationBuilder();
+            time.setSecond(new Counter32(meterStats.getDurationSec()));
+            time.setNanosecond(new Counter32(meterStats.getDurationNsec()));
+            salMeterStats.setDuration(time.build());
 
-        List<MeterConfigStats> listMeterConfigStats = new ArrayList<MeterConfigStats>();
-        for (MeterConfig meterConfig : allMeterConfigs) {
-            MeterConfigStatsBuilder meterConfigStatsBuilder = new MeterConfigStatsBuilder();
-            meterConfigStatsBuilder.setMeterId(new MeterId(meterConfig.getMeterId().getValue()));
-            meterConfigStatsBuilder.setKey(new MeterConfigStatsKey(meterConfigStatsBuilder.getMeterId()));
+            salMeterStats.setFlowCount(new Counter32(meterStats.getFlowCount()));
+            salMeterStats.setMeterId(new MeterId(meterStats.getMeterId().getValue()));
+            salMeterStats.setPacketInCount(new Counter64(meterStats.getPacketInCount()));
+            salMeterStats.setKey(new MeterStatsKey(salMeterStats.getMeterId()));
 
-            MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
-            List<Bands> bands = meterConfig.getBands();
+            List<MeterBandStats> allMeterBandStats = meterStats.getMeterBandStats();
 
-            MeterFlags meterFlags = new MeterFlags(meterConfig.getFlags().isOFPMFBURST(),
-                    meterConfig.getFlags().isOFPMFKBPS(),
-                    meterConfig.getFlags().isOFPMFPKTPS(),
-                    meterConfig.getFlags().isOFPMFSTATS());
-            meterConfigStatsBuilder.setFlags(meterFlags);
-            List<MeterBandHeader> listBandHeaders = new ArrayList<MeterBandHeader>();
+            MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
+            List<BandStat> listAllBandStats = new ArrayList<>();
             int bandKey = 0;
-            for (Bands band : bands) {
-                MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
-                if (band.getMeterBand() instanceof MeterBandDropCase) {
-                    MeterBandDropCase dropCaseBand = (MeterBandDropCase) band.getMeterBand();
-                    MeterBandDrop dropBand = dropCaseBand.getMeterBandDrop();
-                    DropBuilder dropBuilder = new DropBuilder();
-                    dropBuilder.setDropBurstSize(dropBand.getBurstSize());
-                    dropBuilder.setDropRate(dropBand.getRate());
-                    meterBandHeaderBuilder.setBandType(dropBuilder.build());
-
-                    meterBandHeaderBuilder.setBandBurstSize(dropBand.getBurstSize());
-                    meterBandHeaderBuilder.setBandRate(dropBand.getRate());
-                    BandId bandId = new BandId((long) bandKey);
-                    meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
-                    meterBandHeaderBuilder.setBandId(bandId);
 
-                    MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
-                    meterBandTypesBuilder.setFlags(new MeterBandType(true, false, false));
-                    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
-
-                    listBandHeaders.add(meterBandHeaderBuilder.build());
-                } else if (band.getMeterBand() instanceof MeterBandDscpRemarkCase) {
-                    MeterBandDscpRemarkCase dscpRemarkCaseBand = (MeterBandDscpRemarkCase) band.getMeterBand();
-                    MeterBandDscpRemark dscpRemarkBand = dscpRemarkCaseBand.getMeterBandDscpRemark();
-                    DscpRemarkBuilder dscpRemarkBuilder = new DscpRemarkBuilder();
-                    dscpRemarkBuilder.setDscpRemarkBurstSize(dscpRemarkBand.getBurstSize());
-                    dscpRemarkBuilder.setDscpRemarkRate(dscpRemarkBand.getRate());
-                    dscpRemarkBuilder.setPrecLevel(dscpRemarkBand.getPrecLevel());
-                    meterBandHeaderBuilder.setBandType(dscpRemarkBuilder.build());
-
-                    meterBandHeaderBuilder.setBandBurstSize(dscpRemarkBand.getBurstSize());
-                    meterBandHeaderBuilder.setBandRate(dscpRemarkBand.getRate());
-                    BandId bandId = new BandId((long) bandKey);
-                    meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
-                    meterBandHeaderBuilder.setBandId(bandId);
-
-                    MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
-                    meterBandTypesBuilder.setFlags(new MeterBandType(false, true, false));
-                    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
-                    listBandHeaders.add(meterBandHeaderBuilder.build());
-
-                } else if (band.getMeterBand() instanceof MeterBandExperimenterCase) {
-                    MeterBandExperimenterCase experimenterCaseBand = (MeterBandExperimenterCase) band.getMeterBand();
-                    MeterBandExperimenter experimenterBand = experimenterCaseBand.getMeterBandExperimenter();
-                    ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
-                    experimenterBuilder.setExperimenterBurstSize(experimenterBand.getBurstSize());
-                    experimenterBuilder.setExperimenterRate(experimenterBand.getRate());
-                    meterBandHeaderBuilder.setBandType(experimenterBuilder.build());
-
-                    meterBandHeaderBuilder.setBandBurstSize(experimenterBand.getBurstSize());
-                    meterBandHeaderBuilder.setBandRate(experimenterBand.getRate());
-                    BandId bandId = new BandId((long) bandKey);
-                    meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
-                    meterBandHeaderBuilder.setBandId(bandId);
-
-                    MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
-                    meterBandTypesBuilder.setFlags(new MeterBandType(false, false, true));
-                    meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
-
-                    listBandHeaders.add(meterBandHeaderBuilder.build());
-
-                }
+            for (MeterBandStats meterBandStats : allMeterBandStats) {
+                BandStatBuilder bandStatBuilder = new BandStatBuilder();
+                bandStatBuilder.setByteBandCount(new Counter64(meterBandStats.getByteBandCount()));
+                bandStatBuilder.setPacketBandCount(new Counter64(meterBandStats.getPacketBandCount()));
+                BandId bandId = new BandId((long) bandKey);
+                bandStatBuilder.setKey(new BandStatKey(bandId));
+                bandStatBuilder.setBandId(bandId);
                 bandKey++;
+                listAllBandStats.add(bandStatBuilder.build());
             }
-            meterBandHeadersBuilder.setMeterBandHeader(listBandHeaders);
-            meterConfigStatsBuilder.setMeterBandHeaders(meterBandHeadersBuilder.build());
-            listMeterConfigStats.add(meterConfigStatsBuilder.build());
+
+            meterBandStatsBuilder.setBandStat(listAllBandStats);
+            salMeterStats.setMeterBandStats(meterBandStatsBuilder.build());
+            convertedSALMeters.add(salMeterStats.build());
         }
 
-        return listMeterConfigStats;
+        return convertedSALMeters;
     }
-}
+}
\ No newline at end of file
@@ -1,20 +1,16 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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.openflow.md.core.sal.convertor;
 
 /**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 13.3.2015.
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 8/2/16.
  */
-public final class ActionUtil {
-
-    private ActionUtil() {
-        throw new IllegalStateException("This class should not be instantiated");
-    }
+public class OFApprovedExperimenterIds {
 
+    public static final long MATCH_TCP_FLAGS_EXP_ID = 1330529792;
 }
index bc002d1409e58e85ce9f4d7d7fdecef3f8dc0a59..bc320215b8e2b9a7e18a7757eeb25eef43db7c85 100644 (file)
@@ -1,21 +1,27 @@
-/**
+/*
  * 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.openflow.md.core.sal.convertor;
 
 import com.google.common.collect.Iterables;
-import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
+import java.util.Set;
 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.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;
 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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
@@ -26,106 +32,125 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class PacketOutConvertor {
+/**
+ * Converts a MD-SAL packet out data into the OF library packet out input.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * PacketOutConvertorData data = new PacketOutConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * data.setXid(xid);
+ * Optional<PacketOutInput> ofPacketInput = convertorManager.convert(salPacket, data);
+ * }
+ * </pre>
+ */
+public class PacketOutConvertor extends Convertor<TransmitPacketInput, PacketOutInput, PacketOutConvertorData> {
     private static final Logger LOG = LoggerFactory.getLogger(PacketOutConvertor.class);
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(TransmitPacketInput.class);
 
-    private PacketOutConvertor() {
-
+    /**
+     * Create default empty meter mot input builder.
+     * Use this method, if result from convertor is empty.
+     *
+     * @param version Openflow version
+     * @return default empty meter mod input builder
+     */
+    public static PacketOutInput defaultResult(short version) {
+        return new PacketOutInputBuilder()
+                .setVersion(version)
+                .build();
     }
 
-    // Get all the data for the PacketOut from the Yang/SAL-Layer
+    private static PortNumber getPortNumber(final PathArgument pathArgument, final Short ofVersion) {
+        // FIXME VD P! find InstanceIdentifier helper
+        InstanceIdentifier.IdentifiableItem<?, ?> item = Arguments.checkInstanceOf(pathArgument,
+                InstanceIdentifier.IdentifiableItem.class);
+        NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
+        Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                OpenflowVersion.get(ofVersion), key.getId());
+        return new PortNumber(port);
+    }
 
-    /**
-     * @param version openflow version
-     * @param inputPacket input packet
-     * @param datapathid  datapath id
-     * @param xid tx id
-     * @return PacketOutInput required by OF Library
-     */
-    public static PacketOutInput toPacketOutInput(final TransmitPacketInput inputPacket, final short version, final Long xid,
-                                                  final BigInteger datapathid) {
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
 
-        LOG.trace("toPacketOutInput for datapathId:{}, xid:{}", datapathid, xid);
+    @Override
+    public PacketOutInput convert(TransmitPacketInput source, PacketOutConvertorData data) {
+        LOG.trace("toPacketOutInput for datapathId:{}, xid:{}", data.getDatapathId(), data.getXid());
         // Build Port ID from TransmitPacketInput.Ingress
-        PortNumber inPortNr = null;
+        PortNumber inPortNr;
         Long bufferId = OFConstants.OFP_NO_BUFFER;
         Iterable<PathArgument> inArgs = null;
         PacketOutInputBuilder builder = new PacketOutInputBuilder();
-        if (inputPacket.getIngress() != null) {
-            inArgs = inputPacket.getIngress().getValue().getPathArguments();
+
+        if (source.getIngress() != null) {
+            inArgs = source.getIngress().getValue().getPathArguments();
         }
+
         if (inArgs != null && Iterables.size(inArgs) >= 3) {
-            inPortNr = getPortNumber(Iterables.get(inArgs, 2), version);
+            inPortNr = getPortNumber(Iterables.get(inArgs, 2), data.getVersion());
         } else {
             // The packetOut originated from the controller
             inPortNr = new PortNumber(0xfffffffdL);
         }
 
         // Build Buffer ID to be NO_OFP_NO_BUFFER
-        if (inputPacket.getBufferId() != null) {
-            bufferId = inputPacket.getBufferId();
+        if (source.getBufferId() != null) {
+            bufferId = source.getBufferId();
         }
 
         PortNumber outPort = null;
-        NodeConnectorRef outRef = inputPacket.getEgress();
+        NodeConnectorRef outRef = source.getEgress();
         Iterable<PathArgument> outArgs = outRef.getValue().getPathArguments();
+
         if (Iterables.size(outArgs) >= 3) {
-            outPort = getPortNumber(Iterables.get(outArgs, 2), version);
+            outPort = getPortNumber(Iterables.get(outArgs, 2), data.getVersion());
         } else {
             // TODO : P4 search for some normal exception
-            new Exception("PORT NR not exist in Egress");
+            // new Exception("PORT NR not exist in Egress");
+            LOG.error("PORT NR not exist in Egress");
         }
 
-        List<Action> actions = null;
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions =
-                inputPacket.getAction();
+        List<Action> actions = new ArrayList<>();
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions = source.getAction();
+
         if (inputActions != null) {
-            actions = ActionConvertor.getActions(inputActions, version, datapathid, null);
+            final ActionConvertorData actionConvertorData = new ActionConvertorData(data.getVersion());
+            actionConvertorData.setDatapathId(data.getDatapathId());
+
+            final Optional<List<Action>> convertedActions = getConvertorExecutor().convert(
+                    inputActions, actionConvertorData);
+
+            actions = convertedActions.orElse(Collections.emptyList());
 
         } else {
-            actions = new ArrayList<>();
             // TODO VD P! wait for way to move Actions (e.g. augmentation)
             ActionBuilder aBuild = new ActionBuilder();
-
-            OutputActionCaseBuilder outputActionCaseBuilder =
-                    new OutputActionCaseBuilder();
-
-            OutputActionBuilder outputActionBuilder =
-                    new OutputActionBuilder();
-
+            OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+            OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
             outputActionBuilder.setPort(outPort);
             outputActionBuilder.setMaxLength(OFConstants.OFPCML_NO_BUFFER);
-
             outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
-
             aBuild.setActionChoice(outputActionCaseBuilder.build());
-
             actions.add(aBuild.build());
         }
 
         builder.setAction(actions);
-        builder.setData(inputPacket.getPayload());
-        builder.setVersion(version);
-        builder.setXid(xid);
+        builder.setData(source.getPayload());
+        builder.setVersion(data.getVersion());
+        builder.setXid(data.getXid());
         builder.setInPort(inPortNr);
         builder.setBufferId(bufferId);
-        // --------------------------------------------------------
 
         return builder.build();
     }
-
-    private static PortNumber getPortNumber(final PathArgument pathArgument, final Short ofVersion) {
-        // FIXME VD P! find InstanceIdentifier helper
-        InstanceIdentifier.IdentifiableItem<?, ?> item = Arguments.checkInstanceOf(pathArgument,
-                InstanceIdentifier.IdentifiableItem.class);
-        NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
-        Long port =  InventoryDataServiceUtil.portNumberfromNodeConnectorId(
-                OpenflowVersion.get(ofVersion), key.getId());
-        return new PortNumber(port);
-    }
-}
+}
\ No newline at end of file
index 2f4e2043fc104e9eb3baefcb01e12804aeb11843..bd27e212641203b046b504817686cb4b2bc33a6e 100644 (file)
@@ -1,15 +1,23 @@
-/**
+/*
  * Copyright (c) 2014 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.openflow.md.core.sal.convertor;
 
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
@@ -20,54 +28,34 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
- * @author esssuuu This convertor class is used for Port Mod,port status and
- *         port description messages,decodes SAL and encodes to OF Data
+ * Converts port mod, port status and port description MD-SAL messages to OF library data
  *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<PortModInput> ofPort = convertorManager.convert(salPort, data);
+ * }
+ * </pre>
  */
-public final class PortConvertor {
-    private static final Logger LOG = LoggerFactory.getLogger(PortConvertor.class);
+public class PortConvertor extends Convertor<Port, PortModInput, VersionConvertorData> {
 
-    private PortConvertor() {
-
-    }
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(Port.class);
 
     /**
-     * This method is used by PORT_MOD_MESSAGE
+     * Create default empty port mod input
+     * Use this method, if result from convertor is empty.
      *
-     * @param source source port
-     * @param version openflow version
-     * @return port mod input
+     * @param version Openflow version
+     * @return default empty port mod input
      */
-
-    public static PortModInput toPortModInput(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port source,
-            short version) {
-
-
-        PortConfig config = maskPortConfigFields(source.getConfiguration());
-        PortConfigV10 configV10 = maskPortConfigV10Fields(source.getConfiguration());
-
-        PortModInputBuilder portModInputBuilder = new PortModInputBuilder();
-        portModInputBuilder.setAdvertise(getPortFeatures(source.getAdvertisedFeatures()));
-        portModInputBuilder.setPortNo(new PortNumber(
-                OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(version), source.getPortNumber())));
-
-        portModInputBuilder.setConfig(config);
-        portModInputBuilder.setMask(config);
-
-        portModInputBuilder.setHwAddress(new MacAddress(source.getHardwareAddress()));
-
-        portModInputBuilder.setVersion(version);
-
-        portModInputBuilder.setConfigV10(configV10);
-        portModInputBuilder.setMaskV10(configV10);
-        portModInputBuilder.setAdvertiseV10(getPortFeaturesV10(source.getAdvertisedFeatures()));
-        return portModInputBuilder.build();
-
+    public static PortModInput defaultResult(short version) {
+        return new PortModInputBuilder()
+                .setVersion(version)
+                .build();
     }
 
     private static PortConfig maskPortConfigFields(
@@ -91,6 +79,7 @@ public final class PortConvertor {
         return new PortConfigV10(false, noFwd, noPacketIn, noRecv, true, true, portDown);
 
     }
+
     private static PortFeatures getPortFeatures(
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures salPortFeatures) {
 
@@ -110,23 +99,19 @@ public final class PortConvertor {
                 salPortFeatures.isPause(), salPortFeatures.isPauseAsym());
     }
 
-
-    /*
+    /**
      * This method is called as a reply to OFPMP_PORT_DESCRIPTION
      * message(OF1.3.1)
-     */
-    /**
-     * @param source FlowCapablePort
+     *
+     * @param source  FlowCapablePort
      * @param version openflow version
      * @return OF:Ports
      */
-    public static Ports toPortDesc(
+    @VisibleForTesting
+    static Ports toPortDesc(
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort source,
             short version) {
 
-        PortConfig config = null;
-        PortState portState = null;
-
         PortsBuilder oFPortDescDataBuilder = new PortsBuilder();
 
         oFPortDescDataBuilder.setPortNo(
@@ -135,11 +120,11 @@ public final class PortConvertor {
         oFPortDescDataBuilder.setHwAddr(source.getHardwareAddress());
         oFPortDescDataBuilder.setName(source.getName());
 
-        config = maskPortConfigFields(source.getConfiguration());
+        PortConfig config = maskPortConfigFields(source.getConfiguration());
 
         oFPortDescDataBuilder.setConfig(config);
 
-        portState = getPortState(source.getState());
+        PortState portState = getPortState(source.getState());
 
         oFPortDescDataBuilder.setState(portState);
         oFPortDescDataBuilder.setCurrentFeatures(getPortFeatures(source.getCurrentFeature()));
@@ -164,6 +149,31 @@ public final class PortConvertor {
 
     }
 
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
 
+    @Override
+    public PortModInput convert(Port source, VersionConvertorData data) {
+        PortConfig config = maskPortConfigFields(source.getConfiguration());
+        PortConfigV10 configV10 = maskPortConfigV10Fields(source.getConfiguration());
 
-}
+        PortModInputBuilder portModInputBuilder = new PortModInputBuilder();
+        portModInputBuilder.setAdvertise(getPortFeatures(source.getAdvertisedFeatures()));
+        portModInputBuilder.setPortNo(new PortNumber(
+                OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(data.getVersion()), source.getPortNumber())));
+
+        portModInputBuilder.setConfig(config);
+        portModInputBuilder.setMask(config);
+
+        portModInputBuilder.setHwAddress(new MacAddress(source.getHardwareAddress()));
+
+        portModInputBuilder.setVersion(data.getVersion());
+
+        portModInputBuilder.setConfigV10(configV10);
+        portModInputBuilder.setMaskV10(configV10);
+        portModInputBuilder.setAdvertiseV10(getPortFeaturesV10(source.getAdvertisedFeatures()));
+        return portModInputBuilder.build();
+    }
+}
\ No newline at end of file
index 652b5fdd35fb7458c0dbb76ff52c596d1c64ec20..38b1935b32e22079253b3eaf096bc5eceb6d2192 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -12,10 +12,14 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import com.google.common.collect.Ordering;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
@@ -39,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
@@ -84,6 +89,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpT
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
@@ -141,47 +147,87 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfield;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMiss;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfield;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Utility class for converting a MD-SAL Table features into the OF library table
- * features.
+ * Converts a MD-SAL table features into the OF library table features.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<List<TableFeatures>> ofFeatures = convertorManager..convert(salTableFeatures, data);
+ * }
+ * </pre>
  */
-public class TableFeaturesConvertor {
+public class TableFeaturesConvertor extends Convertor<
+        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures,
+        List<TableFeatures>,
+        VersionConvertorData> {
+
     private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class);
     private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> TABLE_FEATURE_PROPS_ORDERING =
             Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build());
+    private static final Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES;
+    private static final List<Class<? extends DataContainer>> TYPES = Arrays.asList(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures.class, UpdatedTable.class);
 
-    private TableFeaturesConvertor() {
-        //hiding implicit construcotr
-    }
-
-    public static List<TableFeatures> toTableFeaturesRequest(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures salTableFeaturesList) {
-        List<TableFeatures> ofTableFeaturesList = new ArrayList<>();
-        TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures salTableFeatures : salTableFeaturesList
-                .getTableFeatures()) {
-            ofTableFeatures.setTableId(salTableFeatures.getTableId());
-            ofTableFeatures.setName(salTableFeatures.getName());
-            ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
-            ofTableFeatures.setMetadataWrite(salTableFeatures.getMetadataWrite());
-            ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
-            if (salTableFeatures.getConfig() != null) {
-                ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().isDEPRECATEDMASK()));
-            }
-            ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));
-            ofTableFeaturesList.add(ofTableFeatures.build());
-        }
-        return ofTableFeaturesList;
+    static {
+        Builder<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> builder = ImmutableMap.builder();
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class, UdpSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class, TcpFlags.class);
+        SAL_TO_OF_TABLE_FEATURES = builder.build();
     }
 
     private static List<TableFeatureProperties> toTableProperties(
             final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) {
         if (tableProperties == null) {
-            return Collections.<TableFeatureProperties>emptyList();
+            return Collections.emptyList();
         }
+
         List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
 
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>
@@ -194,7 +240,8 @@ public class TableFeaturesConvertor {
             org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property
                     .getTableFeaturePropType();
 
-            setTableFeatureProperty(propType, propBuilder);
+            setTableFeatureProperty(propType);
+
             if (propType instanceof Instructions) {
                 setTableFeatureProperty((Instructions) propType, propBuilder);
             } else if (propType instanceof InstructionsMiss) {
@@ -224,13 +271,15 @@ public class TableFeaturesConvertor {
             } else if (propType instanceof ApplySetfieldMiss) {
                 setTableFeatureProperty((ApplySetfieldMiss) propType, propBuilder);
             }
-            // Experimenter and Experimeneter miss Table features are unhandled
+
+            // Experimenter and Experimenter miss Table features are unhandled
             ofTablePropertiesList.add(propBuilder.build());
         }
+
         return ofTablePropertiesList;
     }
 
-    private static void setTableFeatureProperty(final TableFeaturePropType propType, final TableFeaturePropertiesBuilder propBuilder) {
+    private static void setTableFeatureProperty(final TableFeaturePropType propType) {
         LOG.debug("Unknown TableFeaturePropType [{}]", propType.getClass());
     }
 
@@ -241,10 +290,11 @@ public class TableFeaturesConvertor {
         if (null != applySetfieldMiss) {
             setFieldMatch = applySetfieldMiss.getSetFieldMatch();
         }
+
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS,
-                ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
+                ((setFieldMatch == null) ? new ArrayList<>()
                         : setFieldMatch));
     }
 
@@ -255,10 +305,11 @@ public class TableFeaturesConvertor {
         if (null != applySetfield) {
             setFieldMatch = applySetfield.getSetFieldMatch();
         }
+
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYSETFIELD,
-                ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
+                ((setFieldMatch == null) ? new ArrayList<>()
                         : setFieldMatch));
     }
 
@@ -269,10 +320,11 @@ public class TableFeaturesConvertor {
         if (null != writeSetfieldMiss) {
             setFieldMatch = writeSetfieldMiss.getSetFieldMatch();
         }
+
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS,
-                ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
+                ((setFieldMatch == null) ? new ArrayList<>()
                         : setFieldMatch));
     }
 
@@ -287,7 +339,7 @@ public class TableFeaturesConvertor {
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITESETFIELD,
-                ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
+                ((setFieldMatch == null) ? new ArrayList<>()
                         : setFieldMatch));
     }
 
@@ -302,7 +354,7 @@ public class TableFeaturesConvertor {
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWILDCARDS,
-                ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
+                ((setFieldMatch == null) ? new ArrayList<>()
                         : setFieldMatch));
     }
 
@@ -317,7 +369,7 @@ public class TableFeaturesConvertor {
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTMATCH,
-                ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
+                ((setFieldMatch == null) ? new ArrayList<>()
                         : setFieldMatch));
     }
 
@@ -327,7 +379,7 @@ public class TableFeaturesConvertor {
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS,
-                ((applyActionsMiss == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
+                ((applyActionsMiss == null) ? new ArrayList<>()
                         : applyActionsMiss.getAction()));
     }
 
@@ -336,7 +388,7 @@ public class TableFeaturesConvertor {
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYACTIONS,
-                ((applyActions == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
+                ((applyActions == null) ? new ArrayList<>()
                         : applyActions.getAction()));
     }
 
@@ -345,7 +397,7 @@ public class TableFeaturesConvertor {
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS,
-                ((writeActionsMiss == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
+                ((writeActionsMiss == null) ? new ArrayList<>()
                         : writeActionsMiss.getAction()));
     }
 
@@ -354,7 +406,7 @@ public class TableFeaturesConvertor {
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITEACTIONS,
-                ((writeActions == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
+                ((writeActions == null) ? new ArrayList<>()
                         : writeActions.getAction()));
     }
 
@@ -362,28 +414,28 @@ public class TableFeaturesConvertor {
         TablesMiss tables = propType
                 .getTablesMiss();
         setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLESMISS,
-                (tables == null) ? new ArrayList<Short>() : tables.getTableIds());
+                (tables == null) ? new ArrayList<>() : tables.getTableIds());
     }
 
     private static void setTableFeatureProperty(final NextTable propType, final TableFeaturePropertiesBuilder propBuilder) {
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.Tables tables = propType
                 .getTables();
         setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLES,
-                (tables == null) ? new ArrayList<Short>() : tables.getTableIds());
+                (tables == null) ? new ArrayList<>() : tables.getTableIds());
     }
 
     private static void setTableFeatureProperty(final InstructionsMiss propType, final TableFeaturePropertiesBuilder propBuilder) {
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMiss instructions = propType
                 .getInstructionsMiss();
         setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS,
-                (instructions == null) ? new ArrayList<Instruction>() : instructions.getInstruction());
+                (instructions == null) ? new ArrayList<>() : instructions.getInstruction());
     }
 
     private static void setTableFeatureProperty(final Instructions propType, final TableFeaturePropertiesBuilder propBuilder) {
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions instructions = propType
                 .getInstructions();
         setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS,
-                (instructions == null) ? new ArrayList<Instruction>() : instructions.getInstruction());
+                (instructions == null) ? new ArrayList<>() : instructions.getInstruction());
     }
 
     private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
@@ -395,6 +447,7 @@ public class TableFeaturesConvertor {
 
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction = currInstruction
                     .getInstruction();
+
             if (instruction instanceof GoToTableCase) {
                 GotoTableCaseBuilder goToTableCaseBuilder = new GotoTableCaseBuilder();
                 instructionType.setInstructionChoice(goToTableCaseBuilder.build());
@@ -414,9 +467,11 @@ public class TableFeaturesConvertor {
                 MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
                 instructionType.setInstructionChoice(meterCaseBuilder.build());
             }
-            // TODO: Experimeneter instructions are unhandled
+
+            // TODO: Experimenter instructions are unhandled
             instructionTypeList.add(instructionType.build());
         }
+
         InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
         propBuilder.setInstruction(instructionTypeList);
         builder.setType(type);
@@ -432,6 +487,7 @@ public class TableFeaturesConvertor {
             nextTableId.setTableId(tableId);
             nextTableIdsList.add(nextTableId.build());
         }
+
         NextTableRelatedTableFeaturePropertyBuilder propBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
         propBuilder.setNextTableIds(nextTableIdsList);
         builder.setType(type);
@@ -448,6 +504,7 @@ public class TableFeaturesConvertor {
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction
                     .getAction();
             ActionBuilder actionBuilder = new ActionBuilder();
+
             if (actionType instanceof OutputActionCase) {
                 OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
                 actionBuilder.setActionChoice(outputActionCaseBuilder.build());
@@ -497,6 +554,7 @@ public class TableFeaturesConvertor {
                 PopPbbCaseBuilder popPbbCaseBuilder = new PopPbbCaseBuilder();
                 actionBuilder.setActionChoice(popPbbCaseBuilder.build());
             }
+
             // Experimenter action is unhandled
             actionList.add(actionBuilder.build());
         }
@@ -507,55 +565,6 @@ public class TableFeaturesConvertor {
         builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
     }
 
-    private static final Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES;
-
-    static {
-        Builder<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> builder = ImmutableMap.builder();
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class, UdpSrc.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class);
-        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class);
-        SAL_TO_OF_TABLE_FEATURES = builder.build();
-    }
-
     private static void setSetFieldTableFeatureProperty(
             final TableFeaturePropertiesBuilder builder,
             final TableFeaturesPropType type,
@@ -566,13 +575,12 @@ public class TableFeaturesConvertor {
             Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> currMatchType = currMatch
                     .getMatchType();
             MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-
             Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField> ofTableFeatureClass
                     = SAL_TO_OF_TABLE_FEATURES.get(currMatchType);
             setMatchEntry(matchEntryBuilder, ofTableFeatureClass, currMatch.isHasMask());
-
             matchEntriesList.add(matchEntryBuilder.build());
         }
+
         OxmRelatedTableFeaturePropertyBuilder propBuilder = new OxmRelatedTableFeaturePropertyBuilder();
         propBuilder.setMatchEntry(matchEntriesList);
         builder.setType(type);
@@ -582,8 +590,41 @@ public class TableFeaturesConvertor {
     private static void setMatchEntry(final MatchEntryBuilder builder,
                                       final Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField> field,
                                       final Boolean hasMask) {
-        builder.setOxmClass(OpenflowBasicClass.class);
+        if(field == TcpFlags.class) {
+            builder.setOxmClass(ExperimenterClass.class);
+        } else {
+            builder.setOxmClass(OpenflowBasicClass.class);
+        }
         builder.setOxmMatchField(field);
         builder.setHasMask(hasMask);
     }
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return  TYPES;
+    }
+
+    @Override
+    public List<TableFeatures> convert(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, VersionConvertorData data) {
+        List<TableFeatures> ofTableFeaturesList = new ArrayList<>();
+        TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
+
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures salTableFeatures : source
+                .getTableFeatures()) {
+            ofTableFeatures.setTableId(salTableFeatures.getTableId());
+            ofTableFeatures.setName(salTableFeatures.getName());
+            ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
+            ofTableFeatures.setMetadataWrite(salTableFeatures.getMetadataWrite());
+            ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
+
+            if (salTableFeatures.getConfig() != null) {
+                ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().isDEPRECATEDMASK()));
+            }
+
+            ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));
+            ofTableFeaturesList.add(ofTableFeatures.build());
+        }
+
+        return ofTableFeaturesList;
+    }
 }
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -12,10 +12,15 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
@@ -65,11 +70,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
@@ -160,247 +165,226 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Utility class for converting a OF library table features to MD-SAL table
- * features.
+ * Converts a OF library table features into the MD-SAL library table features.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<List<TableFeatures>> salFeatures = convertorManager.convert(ofTableFeatures, data);
+ * }
+ * </pre>
  */
-public class TableFeaturesReplyConvertor {
-    private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesReplyConvertor.class);
-
-    private TableFeaturesReplyConvertor() {
-        //hiding implicit constructor
-    }
-
-    private interface ActionExecutor {
-        public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder);
-    }
-
-    public static List<TableFeatures> toTableFeaturesReply(
-            final MultipartReplyTableFeatures ofTableFeaturesList) {
-        if (ofTableFeaturesList == null || ofTableFeaturesList.getTableFeatures() == null) {
-            return Collections.<TableFeatures>emptyList();
-        }
-        List<TableFeatures> salTableFeaturesList = new ArrayList<>();
-        TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.
-                multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures ofTableFeatures : ofTableFeaturesList
-                .getTableFeatures()) {
-            salTableFeatures.setTableId(ofTableFeatures.getTableId());
-            salTableFeatures.setName(ofTableFeatures.getName());
-            if (ofTableFeatures.getMetadataMatch() != null) {
-                salTableFeatures.setMetadataMatch(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataMatch()));
-            }
-            if (ofTableFeatures.getMetadataWrite() != null) {
-                salTableFeatures.setMetadataWrite(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataWrite()));
-            }
-            if (ofTableFeatures.getConfig() != null) {
-                salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
-            }
-            salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
-            salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
-            salTableFeaturesList.add(salTableFeatures.build());
-        }
-        return salTableFeaturesList;
-    }
-
+public class TableFeaturesResponseConvertor extends Convertor<MultipartReplyTableFeatures, List<TableFeatures>, VersionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesResponseConvertor.class);
     private static final Map<TableFeaturesPropType, ActionExecutor> TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION;
+    private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION;
+    private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES;
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(MultipartReplyTableFeatures.class);
 
     static {
         final Builder<TableFeaturesPropType, ActionExecutor> builder = ImmutableMap.builder();
 
-        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder();
-                instructionBuilder
-                        .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
-                                .setInstruction(setInstructionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(instructionBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder();
+            instructionBuilder
+                    .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
+                            .setInstruction(setInstructionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(instructionBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder instructionMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder();
-                instructionMissBuilder
-                        .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
-                                .setInstruction(setInstructionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder instructionMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder();
+            instructionMissBuilder
+                    .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
+                            .setInstruction(setInstructionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder nextTableBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder();
-                nextTableBuilder
-                        .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
-                                .setTableIds(setNextTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(nextTableBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder nextTableBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder();
+            nextTableBuilder
+                    .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
+                            .setTableIds(setNextTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(nextTableBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder nextTableMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder();
-                nextTableMissBuilder
-                        .setTablesMiss(new TablesMissBuilder()
-                                .setTableIds(setNextTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder nextTableMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder();
+            nextTableMissBuilder
+                    .setTablesMiss(new TablesMissBuilder()
+                            .setTableIds(setNextTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder writeActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder();
-                writeActionsBuilder
-                        .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder writeActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder();
+            writeActionsBuilder
+                    .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder writeActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder();
-                writeActionsMissBuilder
-                        .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder writeActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder();
+            writeActionsMissBuilder
+                    .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder applyActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder();
-                applyActionsBuilder
-                        .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder applyActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder();
+            applyActionsBuilder
+                    .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder applyActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder();
-                applyActionsMissBuilder
-                        .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder applyActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder();
+            applyActionsMissBuilder
+                    .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTMATCH, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTMATCH, (property, propBuilder) -> {
+            MatchSetfieldBuilder matchBuilder = new MatchSetfieldBuilder();
 
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                MatchSetfieldBuilder matchBuilder = new MatchSetfieldBuilder();
-
-                matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
-                propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
-            }
+            matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
+            propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWILDCARDS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                WildcardSetfieldBuilder wildcardsBuilder = new WildcardSetfieldBuilder();
-                wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWILDCARDS, (property, propBuilder) -> {
+            WildcardSetfieldBuilder wildcardsBuilder = new WildcardSetfieldBuilder();
+            wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                WriteSetfieldBuilder writeSetfieldBuilder = new WriteSetfieldBuilder();
-                writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, (property, propBuilder) -> {
+            WriteSetfieldBuilder writeSetfieldBuilder = new WriteSetfieldBuilder();
+            writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                WriteSetfieldMissBuilder writeSetfieldMissBuilder = new WriteSetfieldMissBuilder();
-                writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, (property, propBuilder) -> {
+            WriteSetfieldMissBuilder writeSetfieldMissBuilder = new WriteSetfieldMissBuilder();
+            writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                ApplySetfieldBuilder applySetfieldBuilder = new ApplySetfieldBuilder();
-                applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, (property, propBuilder) -> {
+            ApplySetfieldBuilder applySetfieldBuilder = new ApplySetfieldBuilder();
+            applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                ApplySetfieldMissBuilder applySetfieldMissBuilder = new ApplySetfieldMissBuilder();
-                applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder().setApplySetfieldMiss(applySetfieldMissBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, (property, propBuilder) -> {
+            ApplySetfieldMissBuilder applySetfieldMissBuilder = new ApplySetfieldMissBuilder();
+            applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder().setApplySetfieldMiss(applySetfieldMissBuilder.build()).build());
         });
 
-        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, (property, propBuilder) -> LOG.debug("Experimenter Table features is unhandled"));
 
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                LOG.debug("Experimenter Table features is unhandled");
-            }
-        });
+        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, (property, propBuilder) -> LOG.debug("Experimenter miss Table features is unhandled"));
 
-        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, new ActionExecutor() {
+        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = builder.build();
 
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                LOG.debug("Experimenter miss Table features is unhandled");
-            }
-        });
+    }
 
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = builder.build();
+    static {
+        Builder<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> builder = ImmutableMap.builder();
+
+        builder.put(OutputActionCase.class, new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().build()).build());
+        builder.put(GroupCase.class, new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().build()).build());
+        builder.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().setCopyTtlOut(new CopyTtlOutBuilder().build()).build());
+        builder.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().setCopyTtlIn(new CopyTtlInBuilder().build()).build());
+        builder.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(new SetMplsTtlActionBuilder().build()).build());
+        builder.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().setDecMplsTtl(new DecMplsTtlBuilder().build()).build());
+        builder.put(PushVlanCase.class, new PushVlanActionCaseBuilder().setPushVlanAction(new PushVlanActionBuilder().build()).build());
+        builder.put(PopVlanCase.class, new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build());
+        builder.put(PushMplsCase.class, new PushMplsActionCaseBuilder().setPushMplsAction(new PushMplsActionBuilder().build()).build());
+        builder.put(PopMplsCase.class, new PopMplsActionCaseBuilder().setPopMplsAction(new PopMplsActionBuilder().build()).build());
+        builder.put(SetQueueCase.class, new SetQueueActionCaseBuilder().setSetQueueAction(new SetQueueActionBuilder().build()).build());
+        builder.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().setSetNwTtlAction(new SetNwTtlActionBuilder().build()).build());
+        builder.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build());
+        builder.put(SetFieldCase.class, new SetFieldCaseBuilder().setSetField(new SetFieldBuilder().build()).build());
+        builder.put(PushPbbCase.class, new PushPbbActionCaseBuilder().setPushPbbAction(new PushPbbActionBuilder().build()).build());
+        builder.put(PopPbbCase.class, new PopPbbActionCaseBuilder().setPopPbbAction(new PopPbbActionBuilder().build()).build());
+        builder.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().build()).build());
+        builder.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().setSetNwDstAction(new SetNwDstActionBuilder().build()).build());
+
+        OF_TO_SAL_ACTION = builder.build();
+    }
+
+    static {
+        final Builder<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> builder = ImmutableMap.builder();
 
+        builder.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
+        builder.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
+        builder.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
+        builder.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
+        builder.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
+        builder.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
+        builder.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
+        builder.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
+        builder.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
+        builder.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
+        builder.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
+        builder.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
+        builder.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
+        builder.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
+        builder.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
+        builder.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
+        builder.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
+        builder.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
+        builder.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
+        builder.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
+        builder.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
+        builder.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
+        builder.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
+        builder.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
+        builder.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
+        builder.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
+        builder.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
+        builder.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
+        builder.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
+        builder.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
+        builder.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
+        builder.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
+        builder.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
+        builder.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
+        builder.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
+        builder.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
+        builder.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+        builder.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
+        builder.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
+        builder.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+        builder.put(TcpFlags.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class);
+
+        OF_TO_SAL_TABLE_FEATURE_PROPERTIES = builder.build();
     }
 
     private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
         if (ofTablePropertiesList == null) {
             return new TablePropertiesBuilder()
-                    .setTableFeatureProperties(
-                            Collections
-                                    .<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>emptyList())
+                    .setTableFeatureProperties(Collections.emptyList())
                     .build();
         }
+
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
         TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
         int index = 0;
+
         for (TableFeatureProperties property : ofTablePropertiesList) {
             TableFeaturesPropType propType = property.getType();
-
             ActionExecutor actionExecutor = TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.get(propType);
+
             if (actionExecutor != null) {
                 actionExecutor.execute(property, propBuilder);
             } else {
                 LOG.error("Unsupported table feature property : " + propType);
             }
-            propBuilder.setOrder(index);
 
+            propBuilder.setOrder(index);
             salTablePropertiesList.add(propBuilder.build());
             index += 1;
         }
@@ -411,8 +395,8 @@ public class TableFeaturesReplyConvertor {
     private static List<Instruction> setInstructionTableFeatureProperty(final TableFeatureProperties properties) {
         List<Instruction> instructionList = new ArrayList<>();
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
-
         int index = 0;
+
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731
                 .instructions.grouping.Instruction currInstruction : properties
                 .getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstruction()) {
@@ -442,58 +426,28 @@ public class TableFeaturesReplyConvertor {
                 builder.setInstruction((new MeterCaseBuilder()
                         .setMeter(new MeterBuilder().build())
                         .build()));
-            } else if (currInstructionType instanceof ExperimenterIdCase) {
-                // TODO: Experimenter instructions are unhandled
             }
 
+            // TODO: Experimenter instructions are unhandled
             builder.setOrder(index);
             index += 1;
 
             instructionList.add(builder.build());
         }
+
         return instructionList;
     }
 
     private static List<Short> setNextTableFeatureProperty(final TableFeatureProperties properties) {
-        List<Short> nextTableIdsList = new ArrayList<>();
-        for (NextTableIds tableId : properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
-                .getNextTableIds()) {
-            nextTableIdsList.add(tableId.getTableId());
-        }
-        return nextTableIdsList;
-    }
-
-    private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION;
-
-    static {
-        Builder<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> builder = ImmutableMap.builder();
-
-        builder.put(OutputActionCase.class, new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().build()).build());
-        builder.put(GroupCase.class, new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().build()).build());
-        builder.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().setCopyTtlOut(new CopyTtlOutBuilder().build()).build());
-        builder.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().setCopyTtlIn(new CopyTtlInBuilder().build()).build());
-        builder.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(new SetMplsTtlActionBuilder().build()).build());
-        builder.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().setDecMplsTtl(new DecMplsTtlBuilder().build()).build());
-        builder.put(PushVlanCase.class, new PushVlanActionCaseBuilder().setPushVlanAction(new PushVlanActionBuilder().build()).build());
-        builder.put(PopVlanCase.class, new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build());
-        builder.put(PushMplsCase.class, new PushMplsActionCaseBuilder().setPushMplsAction(new PushMplsActionBuilder().build()).build());
-        builder.put(PopMplsCase.class, new PopMplsActionCaseBuilder().setPopMplsAction(new PopMplsActionBuilder().build()).build());
-        builder.put(SetQueueCase.class, new SetQueueActionCaseBuilder().setSetQueueAction(new SetQueueActionBuilder().build()).build());
-        builder.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().setSetNwTtlAction(new SetNwTtlActionBuilder().build()).build());
-        builder.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build());
-        builder.put(SetFieldCase.class, new SetFieldCaseBuilder().setSetField(new SetFieldBuilder().build()).build());
-        builder.put(PushPbbCase.class, new PushPbbActionCaseBuilder().setPushPbbAction(new PushPbbActionBuilder().build()).build());
-        builder.put(PopPbbCase.class, new PopPbbActionCaseBuilder().setPopPbbAction(new PopPbbActionBuilder().build()).build());
-        builder.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().build()).build());
-        builder.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().setSetNwDstAction(new SetNwDstActionBuilder().build()).build());
-
-        OF_TO_SAL_ACTION = builder.build();
+        return properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
+                .getNextTableIds().stream().map(NextTableIds::getTableId).collect(Collectors.toList());
     }
 
     private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
             final TableFeatureProperties properties) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
         int order = 0;
+
         for (Action action : properties
                 .getAugmentation(ActionRelatedTableFeatureProperty.class).getAction()) {
             if (action != null && null != action.getActionChoice()) {
@@ -507,56 +461,8 @@ public class TableFeaturesReplyConvertor {
                 actionList.add(actionBuilder.build());
             }
         }
-        return actionList;
-    }
-
-    private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES;
-
-    static {
-        final Builder<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> builder = ImmutableMap.builder();
-
-        builder.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
-        builder.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
-        builder.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
-        builder.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
-        builder.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
-        builder.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
-        builder.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
-        builder.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
-        builder.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
-        builder.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
-        builder.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
-        builder.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
-        builder.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
-        builder.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
-        builder.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
-        builder.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
-        builder.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
-        builder.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
-        builder.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
-        builder.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
-        builder.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
-        builder.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
-        builder.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
-        builder.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
-        builder.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
-        builder.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
-        builder.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
-        builder.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
-        builder.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
-        builder.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
-        builder.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
-        builder.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
-        builder.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
-        builder.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
-        builder.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
-        builder.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
-        builder.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
-        builder.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
-        builder.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
-        builder.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
 
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES = builder.build();
+        return actionList;
     }
 
     private static List<SetFieldMatch> setSetFieldTableFeatureProperty(final TableFeatureProperties properties,
@@ -564,21 +470,63 @@ public class TableFeaturesReplyConvertor {
         List<SetFieldMatch> setFieldMatchList = new ArrayList<>();
         SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
 
-        Class<? extends MatchField> ofMatchField = null;
-
         // This handles only OpenflowBasicClass oxm class.
         for (MatchEntry currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class)
                 .getMatchEntry()) {
-            ofMatchField = currMatch.getOxmMatchField();
-            Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> salMatchField = null;
-            setFieldMatchBuilder.setMatchType(salMatchField);
+            Class<? extends MatchField> ofMatchField = currMatch.getOxmMatchField();
+
             if (setHasMask) {
                 setFieldMatchBuilder.setHasMask(currMatch.isHasMask());
             }
+
             setFieldMatchBuilder.setMatchType(OF_TO_SAL_TABLE_FEATURE_PROPERTIES.get(ofMatchField));
             setFieldMatchList.add(setFieldMatchBuilder.build());
         }
+
         return setFieldMatchList;
     }
 
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public List<TableFeatures> convert(MultipartReplyTableFeatures source, VersionConvertorData data) {
+        if (source == null || source.getTableFeatures() == null) {
+            return Collections.emptyList();
+        }
+
+        List<TableFeatures> salTableFeaturesList = new ArrayList<>();
+        TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
+
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.
+                multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures ofTableFeatures : source
+                .getTableFeatures()) {
+            salTableFeatures.setTableId(ofTableFeatures.getTableId());
+            salTableFeatures.setName(ofTableFeatures.getName());
+
+            if (ofTableFeatures.getMetadataMatch() != null) {
+                salTableFeatures.setMetadataMatch(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataMatch()));
+            }
+
+            if (ofTableFeatures.getMetadataWrite() != null) {
+                salTableFeatures.setMetadataWrite(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataWrite()));
+            }
+
+            if (ofTableFeatures.getConfig() != null) {
+                salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
+            }
+
+            salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
+            salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
+            salTableFeaturesList.add(salTableFeatures.build());
+        }
+
+        return salTableFeaturesList;
+    }
+
+    private interface ActionExecutor {
+        void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder);
+    }
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java
new file mode 100644 (file)
index 0000000..55582b5
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2014 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.openflow.md.core.sal.convertor.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfCopyTtlInCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfCopyTtlOutCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfDecMplsTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfDecNwTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfDropActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfGeneralExtensionGroupingCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfGroupActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfOutputActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopMplsActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopPbbActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopVlanActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopVlanActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPushMplsActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPushPbbActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPushVlanActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlDstActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlDstActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlSrcActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlSrcActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetFieldCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetFieldV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetMplsTtlActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwDstActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwDstActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwSrcActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwSrcActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwTosActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwTosActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwTtlActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetQueueActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpDstActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpDstActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpSrcActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpSrcActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanIdActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanIdActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanPcpActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanPcpActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfStripVlanActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfStripVlanActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfVendorCodecCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts SAL actions into OF Library actions
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * ActionConvertorData data = new ActionConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * data.setIpProtocol(ipProtocol);
+ * Optional<List<Action>> ofActions = convertorManager.convert(salActions, data);
+ * }
+ * </pre>
+ */
+public final class ActionConvertor extends Convertor<
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>,
+        List<Action>,
+        ActionConvertorData> {
+
+    private static final ConvertorProcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action, ActionConvertorData> PROCESSOR = new ConvertorProcessor<
+            org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action,
+            Action,
+            ActionConvertorData>()
+            // Set default rule, what will be used if no rule match is found
+            .setDefaultCase(new SalToOfVendorCodecCase())
+            // Add rules for each action type
+            .addCase(new SalToOfCopyTtlInCase())
+            .addCase(new SalToOfCopyTtlOutCase())
+            .addCase(new SalToOfDecMplsTtlCase())
+            .addCase(new SalToOfDecNwTtlCase())
+            .addCase(new SalToOfDropActionCase())
+            .addCase(new SalToOfGroupActionCase())
+            .addCase(new SalToOfOutputActionCase())
+            .addCase(new SalToOfPopMplsActionCase())
+            .addCase(new SalToOfPopPbbActionCase())
+            .addCase(new SalToOfPopVlanActionCase())
+            .addCase(new SalToOfPopVlanActionV10Case())
+            .addCase(new SalToOfPushMplsActionCase())
+            .addCase(new SalToOfPushPbbActionCase())
+            .addCase(new SalToOfPushVlanActionCase())
+            .addCase(new SalToOfSetFieldCase())
+            .addCase(new SalToOfSetFieldV10Case())
+            .addCase(new SalToOfSetMplsTtlActionCase())
+            .addCase(new SalToOfSetNwTtlActionCase())
+            .addCase(new SalToOfSetQueueActionCase())
+            // Openflow 1.0 actions, with support for Openflow 1.3
+            .addCase(new SalToOfSetVlanIdActionCase())
+            .addCase(new SalToOfSetVlanIdActionV10Case())
+            .addCase(new SalToOfSetVlanPcpActionCase())
+            .addCase(new SalToOfSetVlanPcpActionV10Case())
+            .addCase(new SalToOfStripVlanActionCase())
+            .addCase(new SalToOfStripVlanActionV10Case())
+            .addCase(new SalToOfSetDlSrcActionCase())
+            .addCase(new SalToOfSetDlSrcActionV10Case())
+            .addCase(new SalToOfSetDlDstActionCase())
+            .addCase(new SalToOfSetDlDstActionV10Case())
+            .addCase(new SalToOfSetNwSrcActionCase())
+            .addCase(new SalToOfSetNwSrcActionV10Case())
+            .addCase(new SalToOfSetNwDstActionCase())
+            .addCase(new SalToOfSetNwDstActionV10Case())
+            .addCase(new SalToOfSetTpSrcActionCase())
+            .addCase(new SalToOfSetTpSrcActionV10Case())
+            .addCase(new SalToOfSetTpDstActionCase())
+            .addCase(new SalToOfSetTpDstActionV10Case())
+            .addCase(new SalToOfSetNwTosActionCase())
+            .addCase(new SalToOfSetNwTosActionV10Case())
+            // Try to convert action grouping using converters from openflowplugin-extension
+            .addCase(new SalToOfGeneralExtensionGroupingCase());
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action.class);
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public List<Action> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> source, ActionConvertorData data) {
+        // Prepare list of converted actions
+        final List<Action> result = new ArrayList<>();
+
+        // Iterate over SAL actions, run them through tokenizer and then add them to list of converted actions
+        if (source != null) {
+            for (final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : source) {
+                final Optional<Action> convertedAction = PROCESSOR.process(action.getAction(), data, getConvertorExecutor());
+
+                if (convertedAction.isPresent()) {
+                    result.add(convertedAction.get());
+                }
+            }
+        }
+
+        return result;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionResponseConvertor.java
new file mode 100644 (file)
index 0000000..c689b0c
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2014 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.openflow.md.core.sal.convertor.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalCopyTtlInCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalCopyTtlOutCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalDecMplsTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalDecNwTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalGroupCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalOutputActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPopMplsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPopPbbCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPopVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushMplsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushPbbCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetFieldCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetMplsTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetQueueCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalStripVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts OF actions associated with bucket to SAL Actions.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * ActionResponseConvertorData data = new ActionResponseConvertorData(version);
+ * data.setActionPath(actionPath);
+ * Optional<List<Action>> salActions = convertorManager.convert(ofActions, data);
+ * }
+ * </pre>
+ */
+public final class ActionResponseConvertor extends Convertor<
+        List<Action>,
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>,
+        ActionResponseConvertorData> {
+
+    private static final ConvertorProcessor<ActionChoice, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, ActionResponseConvertorData> PROCESSOR = new ConvertorProcessor<
+            ActionChoice,
+            org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action,
+            ActionResponseConvertorData>()
+            // Add rules for each action type
+            .addCase(new OfToSalCopyTtlInCase())
+            .addCase(new OfToSalCopyTtlOutCase())
+            .addCase(new OfToSalDecMplsTtlCase())
+            .addCase(new OfToSalDecNwTtlCase())
+            .addCase(new OfToSalGroupCase())
+            .addCase(new OfToSalOutputActionCase())
+            .addCase(new OfToSalPopMplsCase())
+            .addCase(new OfToSalPopPbbCase())
+            .addCase(new OfToSalPopVlanCase())
+            .addCase(new OfToSalPushMplsCase())
+            .addCase(new OfToSalPushPbbCase())
+            .addCase(new OfToSalPushVlanCase())
+            .addCase(new OfToSalSetFieldCase())
+            .addCase(new OfToSalSetMplsTtlCase())
+            .addCase(new OfToSalSetNwDstCase())
+            .addCase(new OfToSalSetNwTtlCase())
+            .addCase(new OfToSalSetQueueCase())
+            .addCase(new OfToSalStripVlanCase());
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(Action.class);
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convert(List<Action> source, ActionResponseConvertorData data) {
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> result = new ArrayList<>();
+        final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
+
+        // Iterate over Openflow actions, run them through tokenizer and then add them to list of converted actions
+        if (source != null) {
+            for (final Action action : source) {
+                final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedAction = PROCESSOR.process(action.getActionChoice(), data, getConvertorExecutor());
+
+                if (convertedAction.isPresent()) {
+                    result.add(convertedAction.get());
+                } else {
+                    /**
+                     * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
+                     * - we might also need a way on how to identify exact type of augmentation to be
+                     *   used as match can be bound to multiple models
+                     */
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction =
+                            ActionExtensionHelper.processAlienAction(action, ofVersion, data.getActionPath());
+
+                    if (processedAction != null) {
+                        result.add(processedAction);
+                    }
+                }
+            }
+        }
+
+        return result;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorImpl.java
deleted file mode 100644 (file)
index 0ea9d72..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the 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.openflow.md.core.sal.convertor.action;
-
-import java.math.BigInteger;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
-
-import com.google.common.base.Splitter;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwDstConvertorImpl implements Convertor<SetNwDstActionCase, Object> {
-    private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
-
-    @Override
-    public Object convert(final SetNwDstActionCase source, final BigInteger datapathid) {
-        Address address = source.getSetNwDstAction().getAddress();
-        if (address instanceof Ipv4) {
-            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
-            return new Ipv4Address(addressParts.iterator().next());
-        } else if (address instanceof Ipv6) {
-            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
-            return new Ipv6Address(addressParts.iterator().next());
-        } else {
-            throw new IllegalArgumentException("Address is not supported: "+address.getClass().getName());
-        }
-    }
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java
deleted file mode 100644 (file)
index 576a995..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the 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.openflow.md.core.sal.convertor.action;
-
-import java.math.BigInteger;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwDstConvertorV10Impl implements Convertor<SetNwDstActionCase, Object> {
-
-    @Override
-    public Object convert(SetNwDstActionCase source, BigInteger datapathid) {
-        Address address = source.getSetNwDstAction().getAddress();
-        if (address instanceof Ipv4) {
-            //FIXME use of substring should be removed and OF models should distinguish where
-            //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
-
-            String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
-            ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
-            return new Ipv4Address(ipAddress);
-        } else {
-            throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
-        }
-    }
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactor.java
deleted file mode 100644 (file)
index 887ed4f..0000000
+++ /dev/null
@@ -1,55 +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.openflow.md.core.sal.convertor.action;
-
-import java.util.Map;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-
-/**
- *
- */
-public class ActionSetNwDstReactor extends ConvertReactor<SetNwDstActionCase> {
-
-    private static ActionSetNwDstReactor INSTANCE = new ActionSetNwDstReactor();
-
-    private ActionSetNwDstReactor() {
-        //NOOP
-    }
-
-    /**
-     * @return singleton
-     */
-    public static ActionSetNwDstReactor getInstance() {
-        return INSTANCE;
-    }
-
-    @Override
-    protected void initMappings(final Map<Short, Convertor<SetNwDstActionCase,?>> conversions,
-            final Map<InjectionKey, ResultInjector<?,?>> injections) {
-        ActionSetNwDstReactorMappingFactory.addSetNwDstConvertors(conversions);
-        ActionSetNwDstReactorMappingFactory.addSetNwDstInjectors(injections);
-    }
-
-    @Override
-    protected InjectionKey buildInjectionKey(final short version,
-            final Object convertedItem, final Object target) {
-        InjectionResultTargetKey key = null;
-        if (convertedItem != null) {
-             key = new InjectionResultTargetKey(version, target.getClass(), convertedItem.getClass());
-        }
-        return key;
-    }
-
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorMappingFactory.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorMappingFactory.java
deleted file mode 100644 (file)
index 7669705..0000000
+++ /dev/null
@@ -1,135 +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.openflow.md.core.sal.convertor.action;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
-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.entries.grouping.MatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
-
-/**
- * add prepared convertors and injectors into given mappings
- *
- * @see ActionSetNwSrcReactor
- */
-public class ActionSetNwDstReactorMappingFactory {
-
-    /**
-     * @param conversionMapping conversion mapping
-     */
-    public static void addSetNwDstConvertors(final Map<Short, Convertor<SetNwDstActionCase, ?>> conversionMapping) {
-        conversionMapping.put(OFConstants.OFP_VERSION_1_0, new ActionSetNwDstConvertorV10Impl());
-        conversionMapping.put(OFConstants.OFP_VERSION_1_3, new ActionSetNwDstConvertorImpl());
-    }
-
-    /**
-     * @param injectionMapping injection mapping
-     */
-    public static void addSetNwDstInjectors(final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping) {
-        // OF-1.0| Ipv4Address -> ActionBuilder; SetNwDst
-        injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_0,
-                        ActionBuilder.class, Ipv4Address.class),
-                new ResultInjector<Ipv4Address, ActionBuilder>() {
-                    @Override
-                    public void inject(final Ipv4Address result, final ActionBuilder target) {
-                        SetNwDstCaseBuilder setNwDstCaseBuilder = new SetNwDstCaseBuilder();
-                        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
-                        setNwDstActionBuilder.setIpAddress(result);
-                        setNwDstCaseBuilder.setSetNwDstAction(setNwDstActionBuilder.build());
-                        target.setActionChoice(setNwDstCaseBuilder.build());
-                    }
-                });
-
-        // OF-1.3| Ipv4Address -> ActionBuilder; SetNwDst
-        injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
-                        ActionBuilder.class, Ipv4Address.class),
-                new ResultInjector<Ipv4Address, ActionBuilder>() {
-                    @Override
-                    public void inject(final Ipv4Address result, final ActionBuilder target) {
-                        List<MatchEntry> matchEntriesList = new ArrayList<>();
-                        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                        matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
-
-                        Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
-                        Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
-                        ipv4DstBuilder.setIpv4Address(result);
-                        Integer prefix = IpConversionUtil.extractPrefix(result);
-                        if (prefix != null) {
-                            ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
-                        }
-                        ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
-
-                        matchEntryBuilder.setHasMask(false);
-                        matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
-                        matchEntriesList.add(matchEntryBuilder.build());
-
-                        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-                        SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
-                        setFieldActionBuilder.setMatchEntry(matchEntriesList);
-                        setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
-                        target.setActionChoice(setFieldCaseBuilder.build());
-                    }
-                });
-
-        // OF-1.3| Ipv6Address -> ActionBuilder; SetNwDst
-        injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
-                        ActionBuilder.class, Ipv6Address.class),
-                new ResultInjector<Ipv6Address, ActionBuilder>() {
-                    @Override
-                    public void inject(final Ipv6Address result, final ActionBuilder target) {
-                        List<MatchEntry> matchEntriesList = new ArrayList<>();
-                        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                        matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
-
-                        Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
-                        Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
-                        ipv6DstBuilder.setIpv6Address(result);
-                        Integer prefix = IpConversionUtil.extractPrefix(result);
-                        if (prefix != null) {
-                            ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
-                        }
-                        ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
-
-                        matchEntryBuilder.setHasMask(false);
-                        matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
-                        matchEntriesList.add(matchEntryBuilder.build());
-
-                        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-                        SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
-                        setFieldActionBuilder.setMatchEntry(matchEntriesList);
-                        setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
-                        target.setActionChoice(setFieldCaseBuilder.build());
-                    }
-                });
-    }
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorImpl.java
deleted file mode 100644 (file)
index 6702c05..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the 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.openflow.md.core.sal.convertor.action;
-
-import java.math.BigInteger;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
-
-import com.google.common.base.Splitter;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwSrcConvertorImpl implements Convertor<SetNwSrcActionCase, Object> {
-
-    private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
-
-    @Override
-    public Object convert(final SetNwSrcActionCase source, final BigInteger datapathid) {
-        Address address = source.getSetNwSrcAction().getAddress();
-        if (address instanceof Ipv4) {
-            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
-            return new Ipv4Address(addressParts.iterator().next());
-        } else if (address instanceof Ipv6) {
-            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
-            return new Ipv6Address(addressParts.iterator().next());
-        } else {
-            throw new IllegalArgumentException("Address is not supported: "+address.getClass().getName());
-        }
-    }
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorV10Impl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorV10Impl.java
deleted file mode 100644 (file)
index d7e8e8c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the 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.openflow.md.core.sal.convertor.action;
-
-import java.math.BigInteger;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwSrcConvertorV10Impl implements Convertor<SetNwSrcActionCase, Object> {
-
-    @Override
-    public Object convert(SetNwSrcActionCase source, BigInteger datapathid) {
-        Address address = source.getSetNwSrcAction().getAddress();
-        if (address instanceof Ipv4) {
-            //FIXME use of substring should be removed and OF models should distinguish where
-            //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
-
-            String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
-            ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
-            return new Ipv4Address(ipAddress);
-        } else {
-            throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
-        }
-    }
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactor.java
deleted file mode 100644 (file)
index a704458..0000000
+++ /dev/null
@@ -1,55 +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.openflow.md.core.sal.convertor.action;
-
-import java.util.Map;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-
-/**
- *
- */
-public class ActionSetNwSrcReactor extends ConvertReactor<SetNwSrcActionCase> {
-
-    private static ActionSetNwSrcReactor INSTANCE = new ActionSetNwSrcReactor();
-
-    private ActionSetNwSrcReactor() {
-        //NOOP
-    }
-
-    /**
-     * @return singleton
-     */
-    public static ActionSetNwSrcReactor getInstance() {
-        return INSTANCE;
-    }
-
-    @Override
-    protected void initMappings(final Map<Short, Convertor<SetNwSrcActionCase,?>> conversions,
-            final Map<InjectionKey, ResultInjector<?,?>> injections) {
-        ActionSetNwSrcReactorMappingFactory.addSetNwSrcConvertors(conversions);
-        ActionSetNwSrcReactorMappingFactory.addSetNwSrcInjectors(injections);
-    }
-
-    @Override
-    protected InjectionKey buildInjectionKey(final short version,
-            final Object convertedItem, final Object target) {
-        InjectionResultTargetKey key = null;
-        if (convertedItem != null) {
-             key = new InjectionResultTargetKey(version, target.getClass(), convertedItem.getClass());
-        }
-        return key;
-    }
-
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorMappingFactory.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorMappingFactory.java
deleted file mode 100644 (file)
index 675a913..0000000
+++ /dev/null
@@ -1,155 +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.openflow.md.core.sal.convertor.action;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
-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.entries.grouping.MatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
-
-/**
- * add prepared convertors and injectors into given mappings
- *
- * @see ActionSetNwSrcReactor
- */
-public class ActionSetNwSrcReactorMappingFactory {
-
-    /**
-     * @param conversionMapping conversion mapping
-     */
-    public static void addSetNwSrcConvertors(final Map<Short, Convertor<SetNwSrcActionCase, ?>> conversionMapping) {
-        conversionMapping.put(OFConstants.OFP_VERSION_1_0, new ActionSetNwSrcConvertorV10Impl());
-        conversionMapping.put(OFConstants.OFP_VERSION_1_3, new ActionSetNwSrcConvertorImpl());
-    }
-
-    /**
-     * @param injectionMapping injection mapping
-     */
-    public static void addSetNwSrcInjectors(final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping) {
-        // OF-1.0| Ipv4Address -> ActionBuilder; SetNwSrc
-        injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_0,
-                        ActionBuilder.class, Ipv4Address.class),
-                new ResultInjector<Ipv4Address, ActionBuilder>() {
-                    @Override
-                    public void inject(final Ipv4Address result, final ActionBuilder target) {
-                        SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
-                        SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
-                        nwSrcBuilder.setIpAddress(new Ipv4Address(result));
-                        nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
-                        target.setActionChoice(nwSrcCaseBuilder.build());
-                    }
-                });
-
-        // OF-1.3| Ipv4Address -> ActionBuilder; SetNwSrc
-        injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
-                        ActionBuilder.class, Ipv4Address.class),
-                new ResultInjector<Ipv4Address, ActionBuilder>() {
-                    @Override
-                    public void inject(final Ipv4Address result, final ActionBuilder target) {
-                        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-                        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-                        List<MatchEntry> entries = new ArrayList<>();
-                        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                        matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
-
-                        Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
-                        Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
-                        ipv4SrcBuilder.setIpv4Address(result);
-                        Integer prefix = IpConversionUtil.extractPrefix(result);
-                        if (prefix != null) {
-                            ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
-                        }
-                        ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
-
-                        matchEntryBuilder.setHasMask(false);
-                        matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
-                        entries.add(matchEntryBuilder.build());
-                        setFieldBuilder.setMatchEntry(entries);
-                        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
-                        target.setActionChoice(setFieldCaseBuilder.build());
-                    }
-                });
-
-        // OF-1.3| Ipv6Address -> ActionBuilder; SetNwSrc
-        injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
-                        ActionBuilder.class, Ipv6Address.class),
-                new ResultInjector<Ipv6Address, ActionBuilder>() {
-                    @Override
-                    public void inject(final Ipv6Address result, final ActionBuilder target) {
-                        List<MatchEntry> matchEntriesList = new ArrayList<>();
-                        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                        matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
-
-                        Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
-                        Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
-                        ipv6SrcBuilder.setIpv6Address(result);
-                        Integer prefix = IpConversionUtil.extractPrefix(result);
-                        if (prefix != null) {
-                            ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
-                        }
-                        ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
-
-                        matchEntryBuilder.setHasMask(false);
-                        matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
-                        matchEntriesList.add(matchEntryBuilder.build());
-
-                        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
-                        SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
-                        setFieldActionBuilder.setMatchEntry(matchEntriesList);
-                        setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
-                        target.setActionChoice(setFieldCaseBuilder.build());
-
-                    }
-                });
-    }
-
-    private static byte[] extractIpv4Mask(boolean hasMask, final Iterator<String> addressParts) {
-        final int prefix;
-        if (addressParts.hasNext()) {
-            int potentionalPrefix = Integer.parseInt(addressParts.next());
-            prefix = potentionalPrefix < 32 ? potentionalPrefix : 0;
-        } else {
-            prefix = 0;
-        }
-
-        if (prefix != 0) {
-            int mask = 0xffffffff << (32 - prefix);
-            byte[] maskBytes = new byte[]{(byte) (mask >>> 24), (byte) (mask >>> 16), (byte) (mask >>> 8),
-                    (byte) mask};
-            hasMask = true;
-            return maskBytes;
-        }
-        return null;
-    }
-}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalCopyTtlInCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalCopyTtlInCase.java
new file mode 100644 (file)
index 0000000..28e95b9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
+
+public class OfToSalCopyTtlInCase extends ConvertorCase<CopyTtlInCase, Action, ActionResponseConvertorData> {
+    public OfToSalCopyTtlInCase() {
+        super(CopyTtlInCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final CopyTtlInCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
+        return Optional.of(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalCopyTtlOutCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalCopyTtlOutCase.java
new file mode 100644 (file)
index 0000000..53a7511
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
+
+public class OfToSalCopyTtlOutCase extends ConvertorCase<CopyTtlOutCase, Action, ActionResponseConvertorData> {
+    public OfToSalCopyTtlOutCase() {
+        super(CopyTtlOutCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final CopyTtlOutCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
+        return Optional.of(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalDecMplsTtlCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalDecMplsTtlCase.java
new file mode 100644 (file)
index 0000000..f3ff8f3
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
+
+public class OfToSalDecMplsTtlCase extends ConvertorCase<DecMplsTtlCase, Action, ActionResponseConvertorData> {
+    public OfToSalDecMplsTtlCase() {
+        super(DecMplsTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final DecMplsTtlCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
+        return Optional.of(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalDecNwTtlCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalDecNwTtlCase.java
new file mode 100644 (file)
index 0000000..7a74be0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase;
+
+public class OfToSalDecNwTtlCase extends ConvertorCase<DecNwTtlCase, Action, ActionResponseConvertorData> {
+    public OfToSalDecNwTtlCase() {
+        super(DecNwTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final DecNwTtlCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
+        return Optional.of(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalGroupCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalGroupCase.java
new file mode 100644 (file)
index 0000000..ae5067e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupAction;
+
+public class OfToSalGroupCase extends ConvertorCase<GroupCase, Action, ActionResponseConvertorData> {
+    public OfToSalGroupCase() {
+        super(GroupCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final GroupCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        GroupAction groupActionFromOF = source.getGroupAction();
+        GroupActionBuilder groupAction = new GroupActionBuilder();
+        groupAction.setGroupId(groupActionFromOF.getGroupId());
+
+        return Optional.of(new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalOutputActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalOutputActionCase.java
new file mode 100644 (file)
index 0000000..f24ff5f
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+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.flow.types.port.rev130925.PortNumberUni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OfToSalOutputActionCase extends ConvertorCase<OutputActionCase, Action, ActionResponseConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(OfToSalOutputActionCase.class);
+
+    public OfToSalOutputActionCase() {
+        super(OutputActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
+
+        OutputActionBuilder outputAction = new OutputActionBuilder();
+        OutputAction outputActionFromOF = source.getOutputAction();
+
+        if (outputActionFromOF.getPort() != null) {
+            PortNumberUni protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(ofVersion, outputActionFromOF.getPort().getValue());
+            String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
+            outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
+        } else {
+            LOG.error("Provided action is not OF Output action, no associated port found!");
+        }
+
+        Integer maxLength = outputActionFromOF.getMaxLength();
+
+        if (maxLength != null) {
+            outputAction.setMaxLength(maxLength);
+        } else {
+            LOG.error("Provided action is not OF Output action, no associated length found!");
+        }
+
+        OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+        outputActionCaseBuilder.setOutputAction(outputAction.build());
+
+        return Optional.of(outputActionCaseBuilder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopMplsCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopMplsCase.java
new file mode 100644 (file)
index 0000000..613dcc7
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsAction;
+
+public class OfToSalPopMplsCase extends ConvertorCase<PopMplsCase, Action, ActionResponseConvertorData> {
+    public OfToSalPopMplsCase() {
+        super(PopMplsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final PopMplsCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PopMplsAction popMplsActionFromOF = source.getPopMplsAction();
+        PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
+        popMplsAction.setEthernetType(popMplsActionFromOF.getEthertype().getValue());
+        return Optional.of(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopPbbCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopPbbCase.java
new file mode 100644 (file)
index 0000000..0867b77
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase;
+
+public class OfToSalPopPbbCase extends ConvertorCase<PopPbbCase, Action, ActionResponseConvertorData> {
+    public OfToSalPopPbbCase() {
+        super(PopPbbCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final PopPbbCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
+        return Optional.of(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopVlanCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopVlanCase.java
new file mode 100644 (file)
index 0000000..b7b5f64
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
+
+public class OfToSalPopVlanCase extends ConvertorCase<PopVlanCase, Action, ActionResponseConvertorData> {
+    public OfToSalPopVlanCase() {
+        super(PopVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final PopVlanCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
+        return Optional.of(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushMplsCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushMplsCase.java
new file mode 100644 (file)
index 0000000..37217fb
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsAction;
+
+public class OfToSalPushMplsCase extends ConvertorCase<PushMplsCase, Action, ActionResponseConvertorData> {
+    public OfToSalPushMplsCase() {
+        super(PushMplsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final PushMplsCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PushMplsAction pushMplsActionFromOF = source.getPushMplsAction();
+        PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
+        pushMplsAction.setEthernetType(pushMplsActionFromOF.getEthertype().getValue());
+        return Optional.of(new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushPbbCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushPbbCase.java
new file mode 100644 (file)
index 0000000..2b09fdb
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbAction;
+
+public class OfToSalPushPbbCase extends ConvertorCase<PushPbbCase, Action, ActionResponseConvertorData> {
+    public OfToSalPushPbbCase() {
+        super(PushPbbCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final PushPbbCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PushPbbAction pushPbbActionFromOf = source.getPushPbbAction();
+        PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
+        pushPbbAction.setEthernetType(pushPbbActionFromOf.getEthertype().getValue());
+        return Optional.of(new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushVlanCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPushVlanCase.java
new file mode 100644 (file)
index 0000000..c4864e1
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanAction;
+
+public class OfToSalPushVlanCase extends ConvertorCase<PushVlanCase, Action, ActionResponseConvertorData> {
+    public OfToSalPushVlanCase() {
+        super(PushVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final PushVlanCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PushVlanAction pushVlanActionFromOF = source.getPushVlanAction();
+        PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
+        pushVlanAction.setEthernetType(pushVlanActionFromOF.getEthertype().getValue());
+        return Optional.of(new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetFieldCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetFieldCase.java
new file mode 100644 (file)
index 0000000..3672d3f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldAction;
+
+public class OfToSalSetFieldCase extends ConvertorCase<SetFieldCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetFieldCase() {
+        super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(data.getVersion());
+        final SetFieldAction setFieldAction = source.getSetFieldAction();
+        final SetFieldBuilder setField = new SetFieldBuilder();
+        final Optional<MatchBuilder> matchOptional = convertorExecutor.convert(setFieldAction, datapathIdConvertorData);
+        setField.fieldsFrom(matchOptional.orElse(new MatchBuilder()).build());
+
+        return Optional.of(new SetFieldCaseBuilder().setSetField(setField.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetMplsTtlCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetMplsTtlCase.java
new file mode 100644 (file)
index 0000000..ac79d81
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlAction;
+
+public class OfToSalSetMplsTtlCase extends ConvertorCase<SetMplsTtlCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetMplsTtlCase() {
+        super(SetMplsTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetMplsTtlCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetMplsTtlAction setMplsTtlActionFromOF = source.getSetMplsTtlAction();
+
+        SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
+        mplsTtlAction.setMplsTtl(setMplsTtlActionFromOF.getMplsTtl());
+        return Optional.of(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwDstCase.java
new file mode 100644 (file)
index 0000000..2f7d171
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase;
+
+public class OfToSalSetNwDstCase extends ConvertorCase<SetNwDstCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetNwDstCase() {
+        super(SetNwDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+        return Optional.of(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwTtlCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwTtlCase.java
new file mode 100644 (file)
index 0000000..07cb4b9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlAction;
+
+public class OfToSalSetNwTtlCase extends ConvertorCase<SetNwTtlCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetNwTtlCase() {
+        super(SetNwTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwTtlCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetNwTtlAction setNwTtlActionFromOf = source.getSetNwTtlAction();
+        SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
+        setNwTtl.setNwTtl(setNwTtlActionFromOf.getNwTtl());
+        return Optional.of(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetQueueCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetQueueCase.java
new file mode 100644 (file)
index 0000000..49c9a3e
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueAction;
+
+public class OfToSalSetQueueCase extends ConvertorCase<SetQueueCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetQueueCase() {
+        super(SetQueueCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetQueueCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetQueueAction queueActionFromOF = source.getSetQueueAction();
+        SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
+        setQueueAction.setQueueId(queueActionFromOF.getQueueId());
+        return Optional.of(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalStripVlanCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalStripVlanCase.java
new file mode 100644 (file)
index 0000000..c000a98
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase;
+
+public class OfToSalStripVlanCase extends ConvertorCase<StripVlanCase, Action, ActionResponseConvertorData> {
+    public OfToSalStripVlanCase() {
+        super(StripVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final StripVlanCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
+        return Optional.of(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfCopyTtlInCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfCopyTtlInCase.java
new file mode 100644 (file)
index 0000000..6b51ad7
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfCopyTtlInCase extends ConvertorCase<CopyTtlInCase, Action, ActionConvertorData> {
+    public SalToOfCopyTtlInCase() {
+        super(CopyTtlInCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final CopyTtlInCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new CopyTtlInCaseBuilder().build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfCopyTtlOutCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfCopyTtlOutCase.java
new file mode 100644 (file)
index 0000000..76b3937
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfCopyTtlOutCase extends ConvertorCase<CopyTtlOutCase, Action, ActionConvertorData> {
+    public SalToOfCopyTtlOutCase() {
+        super(CopyTtlOutCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final CopyTtlOutCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new CopyTtlOutCaseBuilder().build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDecMplsTtlCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDecMplsTtlCase.java
new file mode 100644 (file)
index 0000000..8b48009
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfDecMplsTtlCase extends ConvertorCase<DecMplsTtlCase, Action, ActionConvertorData> {
+    public SalToOfDecMplsTtlCase() {
+        super(DecMplsTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final DecMplsTtlCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new DecMplsTtlCaseBuilder().build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDecNwTtlCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDecNwTtlCase.java
new file mode 100644 (file)
index 0000000..5b2e722
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfDecNwTtlCase extends ConvertorCase<DecNwTtlCase, Action, ActionConvertorData> {
+    public SalToOfDecNwTtlCase() {
+        super(DecNwTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final DecNwTtlCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new DecNwTtlCaseBuilder().build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDropActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfDropActionCase.java
new file mode 100644 (file)
index 0000000..104ea4e
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+
+public class SalToOfDropActionCase extends ConvertorCase<DropActionCase, Action, ActionConvertorData> {
+    public SalToOfDropActionCase() {
+        super(DropActionCase.class, false, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final DropActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.empty();
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfGeneralExtensionGroupingCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfGeneralExtensionGroupingCase.java
new file mode 100644 (file)
index 0000000..a364434
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfGeneralExtensionGroupingCase extends ConvertorCase<GeneralExtensionGrouping, Action, ActionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(SalToOfGeneralExtensionGroupingCase.class);
+
+    public SalToOfGeneralExtensionGroupingCase() {
+        super(GeneralExtensionGrouping.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final GeneralExtensionGrouping source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final short version = data.getVersion();
+        /**
+         * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
+         * - we might need sessionContext as converter input
+         *
+         */
+
+        Extension extAction = source.getExtension();
+        ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(source.getExtensionKey(), version);
+        ConvertorToOFJava<Action> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+        return convertor != null ? Optional.of(convertor.convert(extAction)) : Optional.empty();
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfGroupActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfGroupActionCase.java
new file mode 100644 (file)
index 0000000..6aed0cc
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfGroupActionCase extends ConvertorCase<GroupActionCase, Action, ActionConvertorData> {
+    public SalToOfGroupActionCase() {
+        super(GroupActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final GroupActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        GroupAction groupAction = source.getGroupAction();
+        GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
+
+        if (null != groupAction.getGroupId()) {
+            groupActionBuilder.setGroupId(groupAction.getGroupId());
+        } else {
+            groupActionBuilder.setGroupId(Long.parseLong(groupAction.getGroup()));
+        }
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new GroupCaseBuilder()
+                        .setGroupAction(groupActionBuilder.build())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfOutputActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfOutputActionCase.java
new file mode 100644 (file)
index 0000000..469e822
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+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.action.output.action._case.OutputAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfOutputActionCase extends ConvertorCase<OutputActionCase, Action, ActionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(SalToOfOutputActionCase.class);
+
+    public SalToOfOutputActionCase() {
+        super(OutputActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final OutputAction outputAction = source.getOutputAction();
+        final OutputActionBuilder outputBuilder = new OutputActionBuilder();
+
+        if (outputAction.getMaxLength() != null) {
+            outputBuilder.setMaxLength(outputAction.getMaxLength());
+        } else {
+            outputBuilder.setMaxLength(0);
+        }
+
+        final OpenflowVersion version = OpenflowVersion.get(data.getVersion());
+        final String nodeConnectorId = outputAction.getOutputNodeConnector().getValue();
+        final Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(version, nodeConnectorId);
+
+        if (OpenflowPortsUtil.checkPortValidity(version, portNumber)) {
+            outputBuilder.setPort(new PortNumber(portNumber));
+        } else {
+            LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, version);
+        }
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new OutputActionCaseBuilder()
+                        .setOutputAction(outputBuilder.build())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopMplsActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopMplsActionCase.java
new file mode 100644 (file)
index 0000000..9c11a41
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPopMplsActionCase extends ConvertorCase<PopMplsActionCase, Action, ActionConvertorData> {
+    public SalToOfPopMplsActionCase() {
+        super(PopMplsActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PopMplsActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
+        PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
+        popMplsBuilder.setEthertype(new EtherType(new EtherType(source.getPopMplsAction().getEthernetType())));
+        popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(popMplsCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopPbbActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopPbbActionCase.java
new file mode 100644 (file)
index 0000000..8c3fc74
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfPopPbbActionCase extends ConvertorCase<PopPbbActionCase, Action, ActionConvertorData> {
+    public SalToOfPopPbbActionCase() {
+        super(PopPbbActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PopPbbActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new PopPbbCaseBuilder().build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopVlanActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopVlanActionCase.java
new file mode 100644 (file)
index 0000000..ba6c4ba
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfPopVlanActionCase extends ConvertorCase<PopVlanActionCase, Action, ActionConvertorData> {
+    public SalToOfPopVlanActionCase() {
+        super(PopVlanActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PopVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new PopVlanCaseBuilder().build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopVlanActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPopVlanActionV10Case.java
new file mode 100644 (file)
index 0000000..6b0fe7a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfPopVlanActionV10Case extends ConvertorCase<PopVlanActionCase, Action, ActionConvertorData> {
+    public SalToOfPopVlanActionV10Case() {
+        super(PopVlanActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PopVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new StripVlanCaseBuilder().build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushMplsActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushMplsActionCase.java
new file mode 100644 (file)
index 0000000..d336ed0
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPushMplsActionCase extends ConvertorCase<PushMplsActionCase, Action, ActionConvertorData> {
+    public SalToOfPushMplsActionCase() {
+        super(PushMplsActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PushMplsActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
+        PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
+        pushMplsBuilder.setEthertype(new EtherType(source.getPushMplsAction().getEthernetType()));
+        pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(pushMplsCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushPbbActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushPbbActionCase.java
new file mode 100644 (file)
index 0000000..a9044da
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPushPbbActionCase extends ConvertorCase<PushPbbActionCase, Action, ActionConvertorData> {
+    public SalToOfPushPbbActionCase() {
+        super(PushPbbActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PushPbbActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
+        PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
+        pushPbbBuilder.setEthertype(new EtherType(source.getPushPbbAction().getEthernetType()));
+        pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(pushPbbCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushVlanActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfPushVlanActionCase.java
new file mode 100644 (file)
index 0000000..c564165
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPushVlanActionCase extends ConvertorCase<PushVlanActionCase, Action, ActionConvertorData> {
+    public SalToOfPushVlanActionCase() {
+        super(PushVlanActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final PushVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        PushVlanAction pushVlanAction = source.getPushVlanAction();
+
+        PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
+        PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
+
+        if (pushVlanAction.getEthernetType() != null) {
+            pushVlanBuilder.setEthertype(new EtherType(pushVlanAction.getEthernetType()));
+        }
+
+        pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(pushVlanCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlDstActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlDstActionCase.java
new file mode 100644 (file)
index 0000000..ada4508
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;
+
+public class SalToOfSetDlDstActionCase extends ConvertorCase<SetDlDstActionCase, Action, ActionConvertorData> {
+    public SalToOfSetDlDstActionCase() {
+        super(SetDlDstActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetDlDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetDlDstAction setdldstaction = source.getSetDlDstAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        List<MatchEntry> entries = new ArrayList<>();
+
+        MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+        matchBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchBuilder.setOxmMatchField(EthDst.class);
+        EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
+        EthDstBuilder ethDstBuilder = new EthDstBuilder();
+        ethDstBuilder.setMacAddress(setdldstaction.getAddress());
+        matchBuilder.setHasMask(false);
+        ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
+        matchBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
+        entries.add(matchBuilder.build());
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlDstActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlDstActionV10Case.java
new file mode 100644 (file)
index 0000000..31e70c6
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetDlDstActionV10Case extends ConvertorCase<SetDlDstActionCase, Action, ActionConvertorData> {
+    public SalToOfSetDlDstActionV10Case() {
+        super(SetDlDstActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetDlDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetDlDstAction setdldstaction = source.getSetDlDstAction();
+        SetDlDstCaseBuilder setDlDstCaseBuilder = new SetDlDstCaseBuilder();
+        SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
+        setDlDstActionBuilder.setDlDstAddress(setdldstaction.getAddress());
+        setDlDstCaseBuilder.setSetDlDstAction(setDlDstActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setDlDstCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlSrcActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlSrcActionCase.java
new file mode 100644 (file)
index 0000000..736c4b0
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;
+
+public class SalToOfSetDlSrcActionCase extends ConvertorCase<SetDlSrcActionCase, Action, ActionConvertorData> {
+    public SalToOfSetDlSrcActionCase() {
+        super(SetDlSrcActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetDlSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetDlSrcAction setdlsrcaction = source.getSetDlSrcAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+        matchBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchBuilder.setOxmMatchField(EthSrc.class);
+        EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
+        EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
+        ethSrcBuilder.setMacAddress(setdlsrcaction.getAddress());
+        matchBuilder.setHasMask(false);
+        ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
+        matchBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
+        entries.add(matchBuilder.build());
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlSrcActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetDlSrcActionV10Case.java
new file mode 100644 (file)
index 0000000..f6da183
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetDlSrcActionV10Case extends ConvertorCase<SetDlSrcActionCase, Action, ActionConvertorData> {
+    public SalToOfSetDlSrcActionV10Case() {
+        super(SetDlSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetDlSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetDlSrcAction setdlsrcaction = source.getSetDlSrcAction();
+        SetDlSrcCaseBuilder setDlSrcCaseBuilder = new SetDlSrcCaseBuilder();
+        SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
+        setDlSrcActionBuilder.setDlSrcAddress(setdlsrcaction.getAddress());
+        setDlSrcCaseBuilder.setSetDlSrcAction(setDlSrcActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setDlSrcCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetFieldCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetFieldCase.java
new file mode 100644 (file)
index 0000000..a54ecc2
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetFieldCase extends ConvertorCase<SetFieldCase, Action, ActionConvertorData> {
+    public SalToOfSetFieldCase() {
+        super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final short version = data.getVersion();
+        final SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        MatchReactor.getInstance().convert(source.getSetField(), version, setFieldBuilder, convertorExecutor);
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new SetFieldCaseBuilder()
+                        .setSetFieldAction(setFieldBuilder.build())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetFieldV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetFieldV10Case.java
new file mode 100644 (file)
index 0000000..863e301
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetFieldV10Case extends ConvertorCase<SetFieldCase, Action, ActionConvertorData> {
+    public SalToOfSetFieldV10Case() {
+        super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
+
+        if (source.getSetField().getVlanMatch() != null) {
+            setVlanVidCaseBuilder.setSetVlanVidAction(new SetVlanVidActionBuilder()
+                    .setVlanVid(source.getSetField().getVlanMatch().getVlanId().getVlanId().getValue())
+                    .build());
+        }
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setVlanVidCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetMplsTtlActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetMplsTtlActionCase.java
new file mode 100644 (file)
index 0000000..957bf38
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetMplsTtlActionCase extends ConvertorCase<SetMplsTtlActionCase, Action, ActionConvertorData> {
+    public SalToOfSetMplsTtlActionCase() {
+        super(SetMplsTtlActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetMplsTtlActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder()
+                .setMplsTtl(source.getSetMplsTtlAction().getMplsTtl());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new SetMplsTtlCaseBuilder()
+                        .setSetMplsTtlAction(setMplsTtlBuilder.build())
+                        .build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwDstActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwDstActionCase.java
new file mode 100644 (file)
index 0000000..d9d5818
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import com.google.common.base.Splitter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
+
+public class SalToOfSetNwDstActionCase extends ConvertorCase<SetNwDstActionCase, Action, ActionConvertorData> {
+    private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
+
+    public SalToOfSetNwDstActionCase() {
+        super(SetNwDstActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final ActionBuilder builder = new ActionBuilder();
+        final Address address = source.getSetNwDstAction().getAddress();
+
+        if (address instanceof Ipv4) {
+            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
+            Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
+            List<MatchEntry> matchEntriesList = new ArrayList<>();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
+
+            Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+            Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
+            ipv4DstBuilder.setIpv4Address(result);
+            Integer prefix = IpConversionUtil.extractPrefix(result);
+            ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+            ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
+
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+            matchEntriesList.add(matchEntryBuilder.build());
+
+            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+            SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+            setFieldActionBuilder.setMatchEntry(matchEntriesList);
+            setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+            builder.setActionChoice(setFieldCaseBuilder.build());
+        } else if (address instanceof Ipv6) {
+            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
+            Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
+            List<MatchEntry> matchEntriesList = new ArrayList<>();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
+
+            Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+            Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
+            ipv6DstBuilder.setIpv6Address(result);
+            Integer prefix = IpConversionUtil.extractPrefix(result);
+            ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+            ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+            matchEntriesList.add(matchEntryBuilder.build());
+
+            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+            SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+            setFieldActionBuilder.setMatchEntry(matchEntriesList);
+            setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+            builder.setActionChoice(setFieldCaseBuilder.build());
+        } else {
+            throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
+        }
+
+        return Optional.of(builder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwDstActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwDstActionV10Case.java
new file mode 100644 (file)
index 0000000..d55fd78
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwDstActionV10Case extends ConvertorCase<SetNwDstActionCase, Action, ActionConvertorData> {
+    public SalToOfSetNwDstActionV10Case() {
+        super(SetNwDstActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final ActionBuilder builder = new ActionBuilder();
+        final Address address = source.getSetNwDstAction().getAddress();
+
+        if (address instanceof Ipv4) {
+            //FIXME use of substring should be removed and OF models should distinguish where
+            //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
+
+            String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
+            ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
+            Ipv4Address result = new Ipv4Address(ipAddress);
+            SetNwDstCaseBuilder setNwDstCaseBuilder = new SetNwDstCaseBuilder();
+            SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+            setNwDstActionBuilder.setIpAddress(result);
+            setNwDstCaseBuilder.setSetNwDstAction(setNwDstActionBuilder.build());
+            builder.setActionChoice(setNwDstCaseBuilder.build());
+        } else {
+            throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
+        }
+
+        return Optional.of(builder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwSrcActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwSrcActionCase.java
new file mode 100644 (file)
index 0000000..2fb9f94
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import com.google.common.base.Splitter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
+
+public class SalToOfSetNwSrcActionCase extends ConvertorCase<SetNwSrcActionCase, Action, ActionConvertorData> {
+    private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
+
+    public SalToOfSetNwSrcActionCase() {
+        super(SetNwSrcActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final ActionBuilder builder = new ActionBuilder();
+        final Address address = source.getSetNwSrcAction().getAddress();
+
+        if (address instanceof Ipv4) {
+            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
+            Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
+
+            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+            SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+            List<MatchEntry> entries = new ArrayList<>();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
+
+            Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+            Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+            ipv4SrcBuilder.setIpv4Address(result);
+            Integer prefix = IpConversionUtil.extractPrefix(result);
+            ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+            ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+            entries.add(matchEntryBuilder.build());
+            setFieldBuilder.setMatchEntry(entries);
+            setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+            builder.setActionChoice(setFieldCaseBuilder.build());
+        } else if (address instanceof Ipv6) {
+            Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
+            Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
+
+            List<MatchEntry> matchEntriesList = new ArrayList<>();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
+
+            Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+            Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+            ipv6SrcBuilder.setIpv6Address(result);
+            Integer prefix = IpConversionUtil.extractPrefix(result);
+            ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+            ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+            matchEntriesList.add(matchEntryBuilder.build());
+
+            SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+            SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+            setFieldActionBuilder.setMatchEntry(matchEntriesList);
+            setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+            builder.setActionChoice(setFieldCaseBuilder.build());
+        } else {
+            throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
+        }
+
+        return Optional.of(builder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwSrcActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwSrcActionV10Case.java
new file mode 100644 (file)
index 0000000..006a5cd
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwSrcActionV10Case extends ConvertorCase<SetNwSrcActionCase, Action, ActionConvertorData> {
+    public SalToOfSetNwSrcActionV10Case() {
+        super(SetNwSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final ActionBuilder builder = new ActionBuilder();
+        final Address address = source.getSetNwSrcAction().getAddress();
+
+        if (address instanceof Ipv4) {
+            //FIXME use of substring should be removed and OF models should distinguish where
+            //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
+
+            String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
+            ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
+            Ipv4Address result = new Ipv4Address(ipAddress);
+            SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
+            SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
+            nwSrcBuilder.setIpAddress(new Ipv4Address(result));
+            nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
+            builder.setActionChoice(nwSrcCaseBuilder.build());
+        } else {
+            throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
+        }
+
+        return Optional.of(builder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTosActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTosActionCase.java
new file mode 100644 (file)
index 0000000..3ffdd00
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+
+public class SalToOfSetNwTosActionCase extends ConvertorCase<SetNwTosActionCase, Action, ActionConvertorData> {
+    public SalToOfSetNwTosActionCase() {
+        super(SetNwTosActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetNwTosAction setnwtosaction = source.getSetNwTosAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        List<MatchEntry> entries = new ArrayList<>();
+        entries.add(MatchConvertorUtil.toOfIpDscp(new Dscp(
+                ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
+        )));
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTosActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTosActionV10Case.java
new file mode 100644 (file)
index 0000000..80e67fc
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwTosActionV10Case extends ConvertorCase<SetNwTosActionCase, Action, ActionConvertorData> {
+    public SalToOfSetNwTosActionV10Case() {
+        super(SetNwTosActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetNwTosAction setnwtosaction = source.getSetNwTosAction();
+        SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+        SetNwTosCaseBuilder setNwTosCaseBuilder = new SetNwTosCaseBuilder();
+        setNwTosActionBuilder.setNwTos(setnwtosaction.getTos().shortValue());
+        setNwTosCaseBuilder.setSetNwTosAction(setNwTosActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setNwTosCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTtlActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetNwTtlActionCase.java
new file mode 100644 (file)
index 0000000..1d5d561
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwTtlActionCase extends ConvertorCase<SetNwTtlActionCase, Action, ActionConvertorData> {
+    public SalToOfSetNwTtlActionCase() {
+        super(SetNwTtlActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwTtlActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
+        SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
+        nwTtlBuilder.setNwTtl(source.getSetNwTtlAction().getNwTtl());
+        nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(nwTtlCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetQueueActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetQueueActionCase.java
new file mode 100644 (file)
index 0000000..b433bc8
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetQueueActionCase extends ConvertorCase<SetQueueActionCase, Action, ActionConvertorData> {
+    public SalToOfSetQueueActionCase() {
+        super(SetQueueActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetQueueActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetQueueAction setQueueAction = source.getSetQueueAction();
+        SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
+        SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
+        setQueueBuilder.setQueueId(setQueueAction.getQueueId());
+        setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setQueueCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpDstActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpDstActionCase.java
new file mode 100644 (file)
index 0000000..81027bf
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfSetTpDstActionCase extends ConvertorCase<SetTpDstActionCase, Action, ActionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpDstActionCase.class);
+
+    public SalToOfSetTpDstActionCase() {
+        super(SetTpDstActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        IPProtocols protocol = null;
+
+        if (data.getIpProtocol() != null) {
+            protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
+        }
+
+        SetTpDstAction settpdstaction = source.getSetTpDstAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+        matchBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchBuilder.setHasMask(false);
+        int port = settpdstaction.getPort().getValue();
+        int code = 0xff & port;
+
+        if (protocol != null) {
+            switch (protocol) {
+                case ICMP:
+                    matchBuilder.setOxmMatchField(Icmpv4Code.class);
+                    Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
+                    Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
+                    icmpv4CodeBuilder.setIcmpv4Code((short) code);
+                    icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
+                    matchBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
+                    break;
+                case ICMPV6:
+                    matchBuilder.setOxmMatchField(Icmpv6Code.class);
+                    Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
+                    Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
+                    icmpv6CodeBuilder.setIcmpv6Code((short) code);
+                    icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
+                    matchBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
+                    break;
+                case TCP:
+                    matchBuilder.setOxmMatchField(TcpDst.class);
+                    TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
+                    TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
+                    tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
+                    tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
+                    matchBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
+                    break;
+                case UDP:
+                    matchBuilder.setOxmMatchField(UdpDst.class);
+                    UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
+                    UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
+                    udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
+                    udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
+                    matchBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
+                    break;
+                default:
+                    LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+                    break;
+            }
+        } else {
+            LOG.warn("Missing protocol with combination of SetSourcePort");
+        }
+
+        List<MatchEntry> entries = new ArrayList<>();
+        entries.add(matchBuilder.build());
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpDstActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpDstActionV10Case.java
new file mode 100644 (file)
index 0000000..d870f1e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+
+public class SalToOfSetTpDstActionV10Case extends ConvertorCase<SetTpDstActionCase, Action, ActionConvertorData> {
+    public SalToOfSetTpDstActionV10Case() {
+        super(SetTpDstActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetTpDstAction settpdstaction = source.getSetTpDstAction();
+        SetTpDstCaseBuilder setTpDstCaseBuilder = new SetTpDstCaseBuilder();
+        SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+        setTpDstActionBuilder.setPort(new PortNumber(settpdstaction.getPort().getValue().longValue()));
+        setTpDstCaseBuilder.setSetTpDstAction(setTpDstActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setTpDstCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpSrcActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpSrcActionCase.java
new file mode 100644 (file)
index 0000000..3844dd0
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfSetTpSrcActionCase extends ConvertorCase<SetTpSrcActionCase, Action, ActionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpSrcActionCase.class);
+
+    public SalToOfSetTpSrcActionCase() {
+        super(SetTpSrcActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        IPProtocols protocol = null;
+
+        if (data.getIpProtocol() != null) {
+            protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
+        }
+
+        SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+        matchBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchBuilder.setHasMask(false);
+
+        int port = settpsrcaction.getPort().getValue();
+        int type = 0xff & port;
+
+        if (protocol != null) {
+            switch (protocol) {
+                case ICMP:
+                    matchBuilder.setOxmMatchField(Icmpv4Type.class);
+                    Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
+                    Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
+                    icmpv4TypeBuilder.setIcmpv4Type((short) type);
+                    icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
+                    matchBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
+                    break;
+                case ICMPV6:
+                    matchBuilder.setOxmMatchField(Icmpv6Type.class);
+                    Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
+                    Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
+                    icmpv6TypeBuilder.setIcmpv6Type((short) type);
+                    icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
+                    matchBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
+                    break;
+                case TCP:
+                    matchBuilder.setOxmMatchField(TcpSrc.class);
+                    TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
+                    TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
+                    tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
+                    tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
+                    matchBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
+                    break;
+                case UDP:
+                    matchBuilder.setOxmMatchField(UdpSrc.class);
+                    UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
+                    UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
+                    udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
+                    udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
+                    matchBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
+                    break;
+                default:
+                    LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+                    break;
+            }
+        } else {
+            LOG.warn("Null protocol with combination of SetSourcePort");
+        }
+
+        List<MatchEntry> entries = new ArrayList<>();
+        entries.add(matchBuilder.build());
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpSrcActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetTpSrcActionV10Case.java
new file mode 100644 (file)
index 0000000..c60cfcc
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfSetTpSrcActionV10Case extends ConvertorCase<SetTpSrcActionCase, Action, ActionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpSrcActionV10Case.class);
+
+    public SalToOfSetTpSrcActionV10Case() {
+        super(SetTpSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
+        SetTpSrcCaseBuilder setTpSrcCaseBuilder = new SetTpSrcCaseBuilder();
+        SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+        setTpSrcActionBuilder.setPort(new PortNumber(settpsrcaction.getPort()
+                .getValue()
+                .longValue()));
+        setTpSrcCaseBuilder.setSetTpSrcAction(setTpSrcActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setTpSrcCaseBuilder.build())
+                .build());
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanIdActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanIdActionCase.java
new file mode 100644 (file)
index 0000000..9bd386c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
+
+public class SalToOfSetVlanIdActionCase extends ConvertorCase<SetVlanIdActionCase, Action, ActionConvertorData> {
+    public SalToOfSetVlanIdActionCase() {
+        super(SetVlanIdActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetVlanIdActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetVlanIdAction setvlanidaction = source.getSetVlanIdAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+        matchBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchBuilder.setOxmMatchField(VlanVid.class);
+        matchBuilder.setHasMask(false);
+        VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+        VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+        vlanVidBuilder.setCfiBit(true);
+        vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
+        vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+        matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+        entries.add(matchBuilder.build());
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanIdActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanIdActionV10Case.java
new file mode 100644 (file)
index 0000000..2ace316
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetVlanIdActionV10Case extends ConvertorCase<SetVlanIdActionCase, Action, ActionConvertorData> {
+    public SalToOfSetVlanIdActionV10Case() {
+        super(SetVlanIdActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetVlanIdActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetVlanIdAction setvlanidaction = source.getSetVlanIdAction();
+        SetVlanVidActionBuilder vlanidActionBuilder = new SetVlanVidActionBuilder();
+        SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
+        vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
+        setVlanVidCaseBuilder.setSetVlanVidAction(vlanidActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setVlanVidCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanPcpActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanPcpActionCase.java
new file mode 100644 (file)
index 0000000..7ef7221
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+
+public class SalToOfSetVlanPcpActionCase extends ConvertorCase<SetVlanPcpActionCase, Action, ActionConvertorData> {
+    public SalToOfSetVlanPcpActionCase() {
+        super(SetVlanPcpActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetVlanPcpActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetVlanPcpAction setvlanpcpaction = source.getSetVlanPcpAction();
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+        List<MatchEntry> matchEntriesList = new ArrayList<>();
+        matchEntriesList.add(MatchConvertorUtil.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
+        setFieldBuilder.setMatchEntry(matchEntriesList);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanPcpActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfSetVlanPcpActionV10Case.java
new file mode 100644 (file)
index 0000000..f6f436c
--- /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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetVlanPcpActionV10Case extends ConvertorCase<SetVlanPcpActionCase, Action, ActionConvertorData> {
+    public SalToOfSetVlanPcpActionV10Case() {
+        super(SetVlanPcpActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final SetVlanPcpActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetVlanPcpAction setvlanpcpaction = source.getSetVlanPcpAction();
+        SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
+        SetVlanPcpCaseBuilder setVlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
+        setVlanPcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
+        setVlanPcpCaseBuilder.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setVlanPcpCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfStripVlanActionCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfStripVlanActionCase.java
new file mode 100644 (file)
index 0000000..8b595ad
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
+
+public class SalToOfStripVlanActionCase extends ConvertorCase<StripVlanActionCase, Action, ActionConvertorData> {
+    public SalToOfStripVlanActionCase() {
+        super(StripVlanActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final StripVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+        matchBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchBuilder.setOxmMatchField(VlanVid.class);
+        matchBuilder.setHasMask(false);
+        VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+        VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+        vlanVidBuilder.setCfiBit(true);
+        vlanVidBuilder.setVlanVid(0x0000);
+        vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+        matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+        matchBuilder.setHasMask(false);
+        entries.add(matchBuilder.build());
+        setFieldBuilder.setMatchEntry(entries);
+        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(setFieldCaseBuilder.build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfStripVlanActionV10Case.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfStripVlanActionV10Case.java
new file mode 100644 (file)
index 0000000..aff535a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfStripVlanActionV10Case extends ConvertorCase<StripVlanActionCase, Action, ActionConvertorData> {
+    public SalToOfStripVlanActionV10Case() {
+        super(StripVlanActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final StripVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new ActionBuilder()
+                .setActionChoice(new StripVlanCaseBuilder().build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfVendorCodecCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/SalToOfVendorCodecCase.java
new file mode 100644 (file)
index 0000000..25e450e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
+import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfVendorCodecCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action, ActionConvertorData> {
+    private static final Logger LOG = LoggerFactory.getLogger(SalToOfVendorCodecCase.class);
+
+    public SalToOfVendorCodecCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Nonnull
+    @Override
+    public Optional<Action> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        final short version = data.getVersion();
+        final TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
+                new TypeVersionKey<>(
+                        (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) source.getImplementedInterface(),
+                        version);
+
+        ExtensionConverterProvider extensionConverterProvider = OFSessionUtil.getExtensionConvertorProvider();
+
+        if (extensionConverterProvider == null) {
+            return Optional.empty();
+        }
+
+        final ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
+                extensionConverterProvider.getConverter(key);
+
+        LOG.trace("OFP Extension action, key:{}, converter:{}", key, convertor);
+        return convertor != null ? Optional.of(convertor.convert(source)) : Optional.empty();
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionConvertorData.java
new file mode 100644 (file)
index 0000000..493bd2c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.data;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+
+/**
+ * Convertor data used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor}
+ * containing Openflow version, datapath ID and IP protocol from flow
+ */
+public class ActionConvertorData extends VersionDatapathIdConvertorData {
+    private Short ipProtocol;
+
+    /**
+     * Instantiates a new Action convertor data.
+     *
+     * @param version the version
+     */
+    public ActionConvertorData(short version) {
+        super(version);
+    }
+
+    /**
+     * Gets ip protocol.
+     *
+     * @return the ip protocol
+     */
+    public Short getIpProtocol() {
+        return ipProtocol;
+    }
+
+    /**
+     * Sets ip protocol.
+     *
+     * @param ipProtocol the ip protocol
+     */
+    public void setIpProtocol(Short ipProtocol) {
+        this.ipProtocol = ipProtocol;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionResponseConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionResponseConvertorData.java
new file mode 100644 (file)
index 0000000..0b0d5b8
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.openflow.md.core.sal.convertor.action.data;
+
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+
+/**
+ * Convertor data used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor}
+ * containing Openflow version and {@link org.opendaylight.openflowplugin.extension.api.path.ActionPath}
+ */
+public class ActionResponseConvertorData extends ConvertorData {
+    private ActionPath actionPath;
+
+    /**
+     * Instantiates a new Action response convertor data.
+     *
+     * @param version the version
+     */
+    public ActionResponseConvertorData(short version) {
+        super(version);
+    }
+
+    /**
+     * Gets action path.
+     *
+     * @return the action path
+     */
+    public ActionPath getActionPath() {
+        return actionPath;
+    }
+
+    /**
+     * Sets action path.
+     *
+     * @param actionPath the action path
+     */
+    public void setActionPath(ActionPath actionPath) {
+        this.actionPath = actionPath;
+    }
+}
index d6e60b2a420a13b6aad60881a3a071f91f3c19d8..ede61108a35f3c9357360ded213e6a6afc9c0695 100644 (file)
@@ -8,23 +8,22 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
-import java.math.BigInteger;
+import com.google.common.collect.ImmutableMap;
 import java.util.HashMap;
 import java.util.Map;
-
-import com.google.common.collect.ImmutableMap;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 
 /**
  * @param <FROM> source type for conversion
  *
  */
 public abstract class ConvertReactor<FROM> {
-    private final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping;
-    private final Map<Short, Convertor<FROM, ?>> conversionMapping;
+    private final Map<ConvertorKey, ResultInjector<?, ?>> injectionMapping;
+    private final Map<Short, ConvertReactorConvertor<FROM, ?>> conversionMapping;
 
     protected ConvertReactor() {
-        final Map<Short, Convertor<FROM, ?>> conversions = new HashMap<>();
-        final Map<InjectionKey, ResultInjector<?, ?>> injections = new HashMap<>();
+        final Map<Short, ConvertReactorConvertor<FROM, ?>> conversions = new HashMap<>();
+        final Map<ConvertorKey, ResultInjector<?, ?>> injections = new HashMap<>();
         initMappings(conversions, injections);
 
         // Create optimized view of mappings
@@ -37,29 +36,29 @@ public abstract class ConvertReactor<FROM> {
      * @param conversions convert from
      * @param injections injection
      */
-    protected abstract void initMappings(Map<Short, Convertor<FROM, ?>> conversions,
-            Map<InjectionKey, ResultInjector<?, ?>> injections);
+    protected abstract void initMappings(Map<Short, ConvertReactorConvertor<FROM, ?>> conversions,
+            Map<ConvertorKey, ResultInjector<?, ?>> injections);
 
     /**
+     * @param <RESULT> result
+     * @param <TARGET> target
      * @param source convert from
      * @param version openflow version
      * @param target convert to
-     * @param datapathid datapath id
-     * @param <RESULT> result
-     * @param <TARGET> target
+     * @param convertorExecutor
      */
     @SuppressWarnings("unchecked")
-    public <RESULT, TARGET> void convert(final FROM source, final short version, final TARGET target, final BigInteger datapathid) {
+    public <RESULT, TARGET> void convert(final FROM source, final short version, final TARGET target, final ConvertorExecutor convertorExecutor) {
 
         //lookup converter
-        Convertor<FROM, RESULT> convertor = (Convertor<FROM, RESULT>) conversionMapping.get(version);
+        ConvertReactorConvertor<FROM, RESULT> convertor = (ConvertReactorConvertor<FROM, RESULT>) conversionMapping.get(version);
         if (convertor == null) {
             throw new IllegalArgumentException("convertor for given version ["+version+"] not found");
         }
-        RESULT convertedItem = convertor.convert(source,datapathid);
+        RESULT convertedItem = convertor.convert(source, convertorExecutor);
 
         //lookup injection
-        InjectionKey key = buildInjectionKey(version, convertedItem, target);
+        ConvertorKey key = buildInjectionKey(version, convertedItem, target);
         ResultInjector<RESULT, TARGET> injection = (ResultInjector<RESULT, TARGET>) injectionMapping.get(key);
         if (injection == null) {
             throw new IllegalArgumentException("injector for given version and target ["+key+"] not found");
@@ -73,8 +72,8 @@ public abstract class ConvertReactor<FROM> {
      * @param target object
      * @return injection key
      */
-    protected InjectionKey buildInjectionKey(final short version, final Object convertedItem, final Object target) {
-        return new InjectionKey(version, target.getClass());
+    protected ConvertorKey buildInjectionKey(final short version, final Object convertedItem, final Object target) {
+        return new ConvertorKey(version, target.getClass());
     }
 
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertReactorConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertReactorConvertor.java
new file mode 100644 (file)
index 0000000..938f975
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.openflow.md.core.sal.convertor.common;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+
+/**
+ * Converts OpenflowJava to MDSal model and vice versa
+ *
+ * @param <FROM> type of source
+ * @param <TO>   type of result
+ */
+public interface ConvertReactorConvertor<FROM, TO> {
+    /**
+     * Converts source to result
+     *
+     * @param source source
+     * @param convertorExecutor
+     * @return converted source
+     */
+    TO convert(FROM source, ConvertorExecutor convertorExecutor);
+}
index 4583a15587c2ee7d45dcfd5e0a636ea8b7068ef8..91f91d2aac3c19c559aac2a4b6044594cc7c8562 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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,
@@ -8,20 +8,52 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
-import java.math.BigInteger;
-
+import java.util.Collection;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
- * converting from MD-SAL model into appropriate OF-API model
- * @param <FROM>  type of source
- * @param <TO>  type of result
+ * Converts OpenflowJava to MDSal model and vice versa
+ *
+ * @param <FROM> type of source
+ * @param <TO>   type of result
+ * @param <DATA> the type parameter
  */
-public interface Convertor<FROM, TO> {
-    
+public abstract class Convertor<FROM, TO, DATA extends ConvertorData> {
+    private ConvertorExecutor convertorExecutor;
+
+    /**
+     * Gets convertor manager.
+     *
+     * @return the convertor manager
+     */
+    protected ConvertorExecutor getConvertorExecutor() {
+        return convertorExecutor;
+    }
+
+    /**
+     * Sets convertor manager.
+     *
+     * @param convertorExecutor the convertor manager
+     */
+    public void setConvertorExecutor(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
+
+    /**
+     * Gets type of convertor, used in
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}.
+     *
+     * @return the type of convertor
+     */
+    public abstract Collection<Class<? extends DataContainer>> getTypes();
+
     /**
-     * @param source source type
-     * @param datapathid  datapath id
-     * @return converted match (into OF-API model)
+     * Converts source to result
+     *
+     * @param source source
+     * @param data   convertor data
+     * @return converted source
      */
-    TO convert(FROM source,BigInteger datapathid);
+    public abstract TO convert(FROM source, DATA data);
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorCase.java
new file mode 100644 (file)
index 0000000..c1639d0
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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.openflow.md.core.sal.convertor.common;
+
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+
+/**
+ * The Convertor case used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor}.
+ *
+ * @param <FROM> the source type
+ * @param <TO>   the result type
+ * @param <DATA> the data type
+ */
+public abstract class ConvertorCase<FROM, TO, DATA extends ConvertorData> {
+    private final List<Short> supportedVersions;
+    private final Class<FROM> type;
+    private final boolean errorOnEmpty;
+
+    /**
+     * Instantiates a new Convertor case.
+     *
+     * @param type              the type
+     * @param errorOnEmpty      the error on empty
+     * @param supportedVersions the supported versions
+     */
+    protected ConvertorCase(Class<FROM> type, boolean errorOnEmpty, Short... supportedVersions) {
+        this.type = type;
+        this.errorOnEmpty = errorOnEmpty;
+        this.supportedVersions = Arrays.asList(Preconditions.checkNotNull(supportedVersions));
+    }
+
+    /**
+     * Process source and return result, what can be empty
+     *
+     *
+     * @param source the source
+     * @param data   the data
+     * @param convertorExecutor convertor executor
+     * @return the optional
+     */
+    public abstract Optional<TO> process(@Nonnull final FROM source, final DATA data, final ConvertorExecutor convertorExecutor);
+
+    /**
+     * Should {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor}
+     * throw error when result of process method is empty?
+     *
+     * @return the boolean
+     */
+    boolean isErrorOnEmpty() {
+        return errorOnEmpty;
+    }
+
+    /**
+     * Cast untyped source to type of this case and sends it to actual process method.
+     *
+     *
+     * @param source the source
+     * @param data   the data
+     * @param convertorExecutor convertor executor
+     * @return the optional
+     */
+    Optional<TO> processRaw(@Nonnull final Object source, final DATA data, final ConvertorExecutor convertorExecutor) {
+        return process(getType().cast(source), data, convertorExecutor);
+    }
+
+    /**
+     * Gets type of this convertor case.
+     *
+     * @return the type
+     */
+    Class<FROM> getType() {
+        return type;
+    }
+
+    /**
+     * Gets supported Openflow versions.
+     *
+     * @return the supported versions
+     */
+    List<Short> getSupportedVersions() {
+        return supportedVersions;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorData.java
new file mode 100644 (file)
index 0000000..43f8701
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.openflow.md.core.sal.convertor.common;
+
+/**
+ * The base class for all convertor data.
+ */
+public abstract class ConvertorData {
+    private short version;
+
+    /**
+     * Instantiates a new Convertor data.
+     *
+     * @param version the version
+     */
+    public ConvertorData(final short version) {
+        this.version = version;
+    }
+
+    /**
+     * Gets Openflow version.
+     *
+     * @return the version
+     */
+    public short getVersion() {
+        return version;
+    }
+}
@@ -16,7 +16,7 @@ import com.google.common.base.Preconditions;
 /**
  * injection lookup key based on version and target object
  */
-public class InjectionKey {
+public class ConvertorKey {
 
     private final int version;
     private final Class<?> targetClazz;
@@ -25,7 +25,7 @@ public class InjectionKey {
      * @param version openflow version
      * @param targetClazz target class
      */
-    public InjectionKey(final int version, final Class<?> targetClazz) {
+    public ConvertorKey(final int version, final Class<?> targetClazz) {
         this.version = version;
         this.targetClazz = Preconditions.checkNotNull(targetClazz);
     }
@@ -46,11 +46,8 @@ public class InjectionKey {
         if (getClass() != obj.getClass()) {
             return false;
         }
-        final InjectionKey other = (InjectionKey) obj;
-        if (version != other.version) {
-            return false;
-        }
-        return targetClazz.equals(other.targetClazz);
+        final ConvertorKey other = (ConvertorKey) obj;
+        return version == other.version && targetClazz.equals(other.targetClazz);
     }
 
     @Override
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorProcessor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorProcessor.java
new file mode 100644 (file)
index 0000000..c06629a
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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.openflow.md.core.sal.convertor.common;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Processes source and return result based on convertor cases added to this processor.
+ *
+ * @param <FROM> the source type
+ * @param <TO>   the result type
+ * @param <DATA> the type of convertor data
+ */
+public class ConvertorProcessor<FROM extends DataContainer, TO, DATA extends ConvertorData> {
+    private static final short OFP_VERSION_ALL = 0x00;
+    private static final Logger LOG = LoggerFactory.getLogger(ConvertorProcessor.class);
+
+    private final Map<Short, Map<Class<?>, ConvertorCase<?, TO, DATA>>> conversions = new ConcurrentHashMap<>();
+    private ConvertorCase<?, TO, DATA> defaultCase;
+
+    /**
+     * Add convertor processor case.
+     *
+     * @param processorCase the processor case
+     * @return the convertor processor
+     */
+    public ConvertorProcessor<FROM, TO, DATA> addCase(final ConvertorCase<?, TO, DATA> processorCase) {
+        if (processorCase.getSupportedVersions().isEmpty()) {
+            getCasesForVersion(OFP_VERSION_ALL).putIfAbsent(processorCase.getType(), processorCase);
+        } else {
+            for (short supportedVersion : processorCase.getSupportedVersions()) {
+                getCasesForVersion(supportedVersion).putIfAbsent(processorCase.getType(), processorCase);
+            }
+        }
+
+        return this;
+    }
+
+    /**
+     * Process source and return result based on convertor cases, or empty if no match is found.
+     *
+     * @param source the source
+     * @param convertorExecutor convertor executor
+     * @return the optional
+     */
+    public Optional<TO> process(final FROM source, final ConvertorExecutor convertorExecutor) {
+        return process(source, null, convertorExecutor);
+    }
+
+    /**
+     * Process source and return result based on convertor cases, or empty if no match is found.
+     *
+     * @param source the source
+     * @param data   the data
+     * @param convertorExecutor convertor executor
+     * @return the optional
+     */
+    public Optional<TO> process(final FROM source, final DATA data, final ConvertorExecutor convertorExecutor) {
+        Optional<TO> result = Optional.empty();
+        final short version = data != null ? data.getVersion() : OFP_VERSION_ALL;
+
+        if (Objects.isNull(source)) {
+            LOG.trace("Failed to convert null for version {}", version);
+            return result;
+        }
+
+        final Class<?> clazz = source.getImplementedInterface();
+        final Optional<ConvertorCase<?, TO, DATA>> caseOptional = Optional
+                .ofNullable(getCasesForVersion(version).get(clazz));
+
+        final ConvertorCase<?, TO, DATA> processorCase = caseOptional.orElse(defaultCase);
+
+        if (Objects.nonNull(processorCase)) {
+            result = processorCase.processRaw(source, data, convertorExecutor);
+
+            if (processorCase.isErrorOnEmpty() && !result.isPresent()) {
+                LOG.warn("Failed to process {} for version {}", clazz, version);
+            }
+        } else {
+            LOG.trace("Failed to process {} for version {}", clazz, version);
+        }
+
+        return result;
+    }
+
+    /**
+     * Sets default case, what will be used when we do not find any matching convertor case for source.
+     *
+     * @param defaultCase the default case
+     * @return the default case
+     */
+    public ConvertorProcessor<FROM, TO, DATA> setDefaultCase(final ConvertorCase<?, TO, DATA> defaultCase) {
+        this.defaultCase = defaultCase;
+        return this;
+    }
+
+    private Map<Class<?>, ConvertorCase<?, TO, DATA>> getCasesForVersion(final short version) {
+        final Map<Class<?>, ConvertorCase<?, TO, DATA>> casesForVersion =
+                conversions.getOrDefault(version, new ConcurrentHashMap<>());
+
+        conversions.putIfAbsent(version, casesForVersion);
+
+        return casesForVersion;
+    }
+}
similarity index 93%
rename from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java
rename to openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IPProtocols.java
index 2e6a386204ac377cd50f7bd471235f418ecf12b6..caec87b676742533c44f1394c143abda29c58b68 100644 (file)
@@ -1,11 +1,12 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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.openflow.md.core.sal.convertor;
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/InjectionResultTargetKey.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/InjectionResultTargetKey.java
deleted file mode 100644 (file)
index 7d1e8ad..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
-
-/**
- *
- */
-public class InjectionResultTargetKey extends InjectionKey {
-
-    private final Class<?> resultClazz;
-
-    /**
-     * @param version openflow version
-     * @param targetClazz target class
-     * @param resultClazz result class
-     */
-    public InjectionResultTargetKey(final int version, final Class<?> targetClazz, final Class<?> resultClazz) {
-        super(version, targetClazz);
-        this.resultClazz = Preconditions.checkNotNull(resultClazz);
-    }
-
-    @Override
-    public int hashCode() {
-        return super.hashCode() ^ resultClazz.hashCode();
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        final InjectionResultTargetKey other = (InjectionResultTargetKey) obj;
-        return resultClazz.equals(other.resultClazz);
-    }
-
-    @Override
-    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return super.addToStringAttributes(toStringHelper).add("resultClazz", resultClazz);
-    }
-}
@@ -1,12 +1,12 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc., Brocade, Communications Systems, Inc. and others.  All rights reserved.
+ * 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.openflow.md.core.sal.convertor;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/PacketOutConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/PacketOutConvertorData.java
new file mode 100644 (file)
index 0000000..1ae204a
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.openflow.md.core.sal.convertor.data;
+
+/**
+ * Convertor data used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor}
+ * containing Openflow version and XID
+ */
+public class PacketOutConvertorData extends VersionDatapathIdConvertorData {
+    private Long xid;
+
+    /**
+     * Instantiates a new Packet out convertor data.
+     *
+     * @param version the version
+     */
+    public PacketOutConvertorData(short version) {
+        super(version);
+    }
+
+    /**
+     * Gets xid.
+     *
+     * @return the xid
+     */
+    public Long getXid() {
+        return xid;
+    }
+
+    /**
+     * Sets xid.
+     *
+     * @param xid the xid
+     */
+    public void setXid(Long xid) {
+        this.xid = xid;
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/VersionConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/VersionConvertorData.java
new file mode 100644 (file)
index 0000000..af5f39b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.openflow.md.core.sal.convertor.data;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+
+/**
+ * Convertor data implementation containing only Openflow version
+ */
+public class VersionConvertorData extends ConvertorData {
+    /**
+     * Instantiates a new Version convertor data.
+     *
+     * @param version the version
+     */
+    public VersionConvertorData(short version) {
+        super(version);
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/VersionDatapathIdConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/VersionDatapathIdConvertorData.java
new file mode 100644 (file)
index 0000000..d445451
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.openflow.md.core.sal.convertor.data;
+
+import java.math.BigInteger;
+
+/**
+ * Convertor data implementation containing Openflow version and datapath ID
+ */
+public class VersionDatapathIdConvertorData extends VersionConvertorData {
+    private BigInteger datapathId;
+
+    /**
+     * Instantiates a new version datapath id convertor data.
+     *
+     * @param version the version
+     */
+    public VersionDatapathIdConvertorData(short version) {
+        super(version);
+    }
+
+    /**
+     * Gets datapath id.
+     *
+     * @return the datapath id
+     */
+    public BigInteger getDatapathId() {
+        return datapathId;
+    }
+
+    /**
+     * Sets datapath id.
+     *
+     * @param datapathId the datapath id
+     */
+    public void setDatapathId(BigInteger datapathId) {
+        this.datapathId = datapathId;
+    }
+}
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013, 2015 Ericsson. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,17 +6,32 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow;
 
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Ordering;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag.FlowFlagReactor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.ApplyActionsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.ClearActionsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.GoToTableCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.MeterCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.WriteActionsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.WriteMetadataCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag.FlowFlagReactor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
-import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
@@ -34,35 +49,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.I
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MatchTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
@@ -70,21 +65,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Ordering;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 /**
- * Utility class for converting a MD-SAL Flow into the OF flow mod
+ * Converts the SAL Flow to OF Flow. It checks if there is a set-vlan-id (1.0) action made on OF1.3.
+ * If yes its handled separately.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * Optional<List<FlowModInputBuilder>> ofFlow = convertorManager.convert(salFlow, data);
+ * }
+ * </pre>
  */
-public class FlowConvertor {
-    private static final Logger LOG = LoggerFactory.getLogger(FlowConvertor.class);
-
-    // Default values for when things are null
-    private static final TableId DEFAULT_TABLE_ID = new TableId(0L);
+public class FlowConvertor extends Convertor<Flow, List<FlowModInputBuilder>, VersionDatapathIdConvertorData> {
     /**
      * Default idle timeout
      */
@@ -97,11 +93,6 @@ public class FlowConvertor {
      * Default priority
      */
     public static final Integer DEFAULT_PRIORITY = Integer.parseInt("8000", 16);
-    private static final Long DEFAULT_BUFFER_ID = OFConstants.OFP_NO_BUFFER;
-    private static final Long OFPP_ANY = Long.parseLong("ffffffff", 16);
-    private static final Long DEFAULT_OUT_PORT = OFPP_ANY;
-    private static final Long OFPG_ANY = Long.parseLong("ffffffff", 16);
-    private static final Long DEFAULT_OUT_GROUP = OFPG_ANY;
     /**
      * flow flag: remove
      */
@@ -133,14 +124,27 @@ public class FlowConvertor {
     /**
      * default match entries - empty
      */
-    public static final List<MatchEntry> DEFAULT_MATCH_ENTRIES = new ArrayList<MatchEntry>();
-    private static final Integer PUSH_VLAN = 0x8100;
-
-    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> INSTRUCTION_ORDERING =
-            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build());
+    public static final List<MatchEntry> DEFAULT_MATCH_ENTRIES = new ArrayList<>();
 
+    // Default values for when things are null
+    private static final TableId DEFAULT_TABLE_ID = new TableId(0L);
+    private static final Long DEFAULT_BUFFER_ID = OFConstants.OFP_NO_BUFFER;
+    private static final Long OFPP_ANY = Long.parseLong("ffffffff", 16);
+    private static final Long DEFAULT_OUT_PORT = OFPP_ANY;
+    private static final Long OFPG_ANY = Long.parseLong("ffffffff", 16);
+    private static final Long DEFAULT_OUT_GROUP = OFPG_ANY;
+    private static final Integer PUSH_VLAN = 0x8100;
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> INSTRUCTION_ORDERING = Ordering.from(OrderComparator.build());
     private static final VlanMatch VLAN_MATCH_FALSE;
     private static final VlanMatch VLAN_MATCH_TRUE;
+    private static final ConvertorProcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction, Instruction, ActionConvertorData> PROCESSOR = new ConvertorProcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction, Instruction, ActionConvertorData>()
+            .addCase(new ApplyActionsCase())
+            .addCase(new ClearActionsCase())
+            .addCase(new GoToTableCase())
+            .addCase(new MeterCase())
+            .addCase(new WriteActionsCase())
+            .addCase(new WriteMetadataCase());
+    private static final List<Class<? extends DataContainer>> TYPES = Arrays.asList(Flow.class, AddFlowInput.class, RemoveFlowInput.class, UpdatedFlow.class);
 
     static {
         final VlanId zeroVlan = new VlanId(0);
@@ -161,29 +165,7 @@ public class FlowConvertor {
         VLAN_MATCH_TRUE = vlanMatchBuilder2.build();
     }
 
-    private FlowConvertor() {
-        //hiding implicit constructor
-    }
-
-    /**
-     * This method converts the SAL Flow to OF Flow.
-     * It checks if there is a set-vlan-id (1.0) action made on OF1.3.
-     * If yes its handled separately
-     *
-     * @param srcFlow source flow
-     * @param version openflow version
-     * @param datapathId datapath id
-     * @return list of flow mod build
-     */
-    public static List<FlowModInputBuilder> toFlowModInputs(Flow srcFlow, short version, BigInteger datapathId) {
-        if (version >= OFConstants.OFP_VERSION_1_3 && isSetVlanIdActionCasePresent(srcFlow)) {
-            return handleSetVlanIdForOF13(srcFlow, version, datapathId);
-        } else {
-            return Collections.singletonList(toFlowModInput(srcFlow, version, datapathId));
-        }
-    }
-
-    private static FlowModInputBuilder toFlowModInput(Flow flow, short version, BigInteger datapathid) {
+    private FlowModInputBuilder toFlowModInput(Flow flow, short version, BigInteger datapathid) {
 
         FlowModInputBuilder flowMod = new FlowModInputBuilder();
         salToOFFlowCookie(flow, flowMod);
@@ -198,15 +180,16 @@ public class FlowConvertor {
         salToOFFlowOutGroup(flow, flowMod);
 
         // convert and inject flowFlags
-        FlowFlagReactor.getInstance().convert(flow.getFlags(), version, flowMod, datapathid);
+        FlowFlagReactor.getInstance().convert(flow.getFlags(), version, flowMod, getConvertorExecutor());
 
         // convert and inject match
-        MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod, datapathid);
+        MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod, getConvertorExecutor());
 
         if (flow.getInstructions() != null) {
             flowMod.setInstruction(toInstructions(flow, version, datapathid));
             flowMod.setAction(getActions(version, datapathid, flow));
         }
+
         flowMod.setVersion(version);
 
         return flowMod;
@@ -296,81 +279,31 @@ public class FlowConvertor {
         }
     }
 
-    private static List<Instruction> toInstructions(
-            Flow flow,
-            short version, BigInteger datapathid) {
-        List<Instruction> instructionsList = new ArrayList<>();
+    private List<Instruction> toInstructions(Flow flow, short version, BigInteger datapathid) {
+        final List<Instruction> instructionsList = new ArrayList<>();
+        final ActionConvertorData data = new ActionConvertorData(version);
+        data.setDatapathId(datapathid);
+        data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
+
+        Instructions instructions = flow.getInstructions();
 
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions();
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions
                 .getInstruction()) {
-            InstructionBuilder instructionBuilder = new InstructionBuilder();
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
                     .getInstruction();
-            if (curInstruction instanceof GoToTableCase) {
-                GoToTableCase goToTablecase = (GoToTableCase) curInstruction;
-                GoToTable goToTable = goToTablecase.getGoToTable();
-                GotoTableCaseBuilder gotoTableCaseBuilder = new GotoTableCaseBuilder();
-                GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
-                gotoTableBuilder.setTableId(goToTable.getTableId());
-                gotoTableCaseBuilder.setGotoTable(gotoTableBuilder.build());
-                instructionBuilder.setInstructionChoice(gotoTableCaseBuilder.build());
-                instructionsList.add(instructionBuilder.build());
-            } else if (curInstruction instanceof WriteMetadataCase) {
-                WriteMetadataCase writeMetadatacase = (WriteMetadataCase) curInstruction;
-                WriteMetadata writeMetadata = writeMetadatacase.getWriteMetadata();
-
-                WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
-                WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
-                writeMetadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadata(),
-                                                                             OFConstants.SIZE_OF_LONG_IN_BYTES));
-                writeMetadataBuilder.setMetadataMask(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadataMask(),
-                                                                                     OFConstants.SIZE_OF_LONG_IN_BYTES));
-                writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
-                instructionBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());
-                instructionsList.add(instructionBuilder.build());
-            } else if (curInstruction instanceof WriteActionsCase) {
-                WriteActionsCase writeActionscase = (WriteActionsCase) curInstruction;
-                WriteActions writeActions = writeActionscase.getWriteActions();
-                WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
-                WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
-                writeActionsBuilder.setAction(ActionConvertor.getActions(writeActions.getAction(),version, datapathid, flow));
-                writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
-                instructionBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
-                instructionsList.add(instructionBuilder.build());
-            } else if (curInstruction instanceof ApplyActionsCase) {
-                ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
-                ApplyActions applyActions = applyActionscase.getApplyActions();
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder applyActionsCaseBuilder =
-                        new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder();
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder applyActionsBuilder =
-                        new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder();
-                applyActionsBuilder.setAction(ActionConvertor.getActions(applyActions.getAction(), version, datapathid, flow));
-                applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
-                instructionBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
-                instructionsList.add(instructionBuilder.build());
-            } else if (curInstruction instanceof ClearActionsCase) {
-                ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
-                instructionBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
-                instructionsList.add(instructionBuilder.build());
-            } else if (curInstruction instanceof MeterCase) {
-                MeterCase metercase = (MeterCase) curInstruction;
-                Meter meter = metercase.getMeter();
-                MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
-                MeterBuilder meterBuilder = new MeterBuilder();
-                Long meterId = meter.getMeterId().getValue();
-                meterBuilder.setMeterId(meterId);
-                meterCaseBuilder.setMeter(meterBuilder.build());
-                instructionBuilder.setInstructionChoice(meterCaseBuilder.build());
-                instructionsList.add(instructionBuilder.build());
+
+            Optional<Instruction> result = PROCESSOR.process(curInstruction, data, getConvertorExecutor());
+
+            if (result.isPresent()) {
+                instructionsList.add(result.get());
             }
         }
+
         return instructionsList;
     }
 
-    private static List<Action> getActions(short version, BigInteger datapathid, Flow flow) {
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions();
+    private List<Action> getActions(short version, BigInteger datapathid, Flow flow) {
+        Instructions instructions = flow.getInstructions();
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> sortedInstructions =
                 INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction());
 
@@ -378,12 +311,18 @@ public class FlowConvertor {
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
                     .getInstruction();
 
-            if (curInstruction instanceof ApplyActionsCase) {
-                ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
+            if (curInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
+                org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
                 ApplyActions applyActions = applyActionscase.getApplyActions();
-                return ActionConvertor.getActions(applyActions.getAction(), version, datapathid, flow);
+
+                final ActionConvertorData data = new ActionConvertorData(version);
+                data.setDatapathId(datapathid);
+                data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
+                Optional<List<Action>> result = getConvertorExecutor().convert(applyActions.getAction(), data);
+                return result.orElse(Collections.emptyList());
             }
         }
+
         return null;
     }
 
@@ -391,14 +330,14 @@ public class FlowConvertor {
     private static boolean isSetVlanIdActionCasePresent(Flow flow) {
         // we are trying to find if there is a set-vlan-id action (OF1.0) action present in the flow.
         // If yes,then we would need to two flows
-        if (flow.getInstructions() != null) {
+        if (flow.getInstructions() != null && flow.getInstructions().getInstruction() != null) {
             for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction :
                     flow.getInstructions().getInstruction()) {
                 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction =
                         instruction.getInstruction();
 
-                if (curInstruction instanceof ApplyActionsCase) {
-                    ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
+                if (curInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
                     ApplyActions applyActions = applyActionscase.getApplyActions();
                     for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action :
                             applyActions.getAction()) {
@@ -422,7 +361,7 @@ public class FlowConvertor {
      * Â  Â  1) Match on (OFPVID_NONE ) without mask + action [push vlan tag + set_field]
      * Â  Â  2) Match on (OFPVID_PRESENT) with mask (OFPVID_PRESENT ) + action [ set_field]
      */
-    private static List<FlowModInputBuilder> handleSetVlanIdForOF13(Flow srcFlow, short version, BigInteger datapathId) {
+    private List<FlowModInputBuilder> handleSetVlanIdForOF13(Flow srcFlow, short version, BigInteger datapathId) {
         List<FlowModInputBuilder> list = new ArrayList<>(2);
 
         final Match srcMatch = Preconditions.checkNotNull(srcFlow.getMatch());
@@ -466,13 +405,13 @@ public class FlowConvertor {
 
     private static Optional<? extends Flow> injectMatchToFlow(Flow sourceFlow, Match match) {
         if (sourceFlow instanceof AddFlowInput) {
-            return Optional.<AddFlowInput>of(new AddFlowInputBuilder(sourceFlow).setMatch(match).build());
+            return Optional.of(new AddFlowInputBuilder(sourceFlow).setMatch(match).build());
         } else if (sourceFlow instanceof RemoveFlowInput) {
-            return Optional.<RemoveFlowInput>of(new RemoveFlowInputBuilder(sourceFlow).setMatch(match).build());
+            return Optional.of(new RemoveFlowInputBuilder(sourceFlow).setMatch(match).build());
         } else if (sourceFlow instanceof UpdatedFlow) {
-            return Optional.<UpdatedFlow>of(new UpdatedFlowBuilder(sourceFlow).setMatch(match).build());
+            return Optional.of(new UpdatedFlowBuilder(sourceFlow).setMatch(match).build());
         } else {
-            return Optional.<Flow>absent();
+            return Optional.empty();
         }
     }
 
@@ -483,16 +422,16 @@ public class FlowConvertor {
                 .build();
 
         if (sourceFlow instanceof AddFlowInput) {
-            return Optional.<AddFlowInput>of(new AddFlowInputBuilder(sourceFlow)
+            return Optional.of(new AddFlowInputBuilder(sourceFlow)
                     .setMatch(match).setInstructions(instructions).build());
         } else if (sourceFlow instanceof RemoveFlowInput) {
-            return Optional.<RemoveFlowInput>of(new RemoveFlowInputBuilder(sourceFlow)
+            return Optional.of(new RemoveFlowInputBuilder(sourceFlow)
                     .setMatch(match).setInstructions(instructions).build());
         } else if (sourceFlow instanceof UpdatedFlow) {
-            return Optional.<UpdatedFlow>of(new UpdatedFlowBuilder(sourceFlow)
+            return Optional.of(new UpdatedFlowBuilder(sourceFlow)
                     .setMatch(match).setInstructions(instructions).build());
         } else {
-            return Optional.<Flow>absent();
+            return Optional.empty();
         }
     }
 
@@ -508,22 +447,19 @@ public class FlowConvertor {
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder instructionBuilder =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
 
-        for (int i = 0; i < srcInstructionList.size(); i++) {
-            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction srcInstruction =
-                    srcInstructionList.get(i);
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction srcInstruction : srcInstructionList) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curSrcInstruction =
                     srcInstruction.getInstruction();
 
-            if (curSrcInstruction instanceof ApplyActionsCase) {
-                ApplyActionsCase applyActionscase = (ApplyActionsCase) curSrcInstruction;
+            if (curSrcInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
+                org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curSrcInstruction;
                 ApplyActions applyActions = applyActionscase.getApplyActions();
                 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> srcActionList = applyActions.getAction();
 
                 int offset = 0;
-                for (int j = 0; j < srcActionList.size(); j++) {
+                for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action actionItem : srcActionList) {
                     // check if its a set-vlan-action. If yes, then add the injected-action
 
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action actionItem = srcActionList.get(j);
                     if (actionItem.getAction() instanceof SetVlanIdActionCase) {
                         SetVlanIdActionCase setVlanIdActionCase = (SetVlanIdActionCase) actionItem.getAction();
 
@@ -537,7 +473,7 @@ public class FlowConvertor {
                         pushVlanActionCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build());
                         PushVlanActionCase injectedAction = pushVlanActionCaseBuilder.build();
 
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder = new ActionBuilder();
+                        ActionBuilder actionBuilder = new ActionBuilder();
                         actionBuilder.setAction(injectedAction)
                                 .setKey(actionItem.getKey())
                                 .setOrder(actionItem.getOrder() + offset);
@@ -548,8 +484,8 @@ public class FlowConvertor {
 
                     if (offset > 0) {
                         // we need to increment the order for all the actions added after injection
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder =
-                                new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder(actionItem);
+                        ActionBuilder actionBuilder =
+                                new ActionBuilder(actionItem);
                         actionBuilder.setOrder(actionItem.getOrder() + offset);
                         actionItem = actionBuilder.build();
                     }
@@ -577,4 +513,17 @@ public class FlowConvertor {
         return targetInstructionList;
     }
 
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return  TYPES;
+    }
+
+    @Override
+    public List<FlowModInputBuilder> convert(Flow source, VersionDatapathIdConvertorData data) {
+        if (data.getVersion() >= OFConstants.OFP_VERSION_1_3 && isSetVlanIdActionCasePresent(source)) {
+            return handleSetVlanIdForOF13(source, data.getVersion(), data.getDatapathId());
+        } else {
+            return Collections.singletonList(toFlowModInput(source, data.getVersion(), data.getDatapathId()));
+        }
+    }
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorUtil.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorUtil.java
new file mode 100644 (file)
index 0000000..ac765e1
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow;
+
+import java.util.ArrayList;
+import java.util.List;
+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.types.rev131026.Flow;
+
+/**
+ * Flow related utils
+ */
+public abstract class FlowConvertorUtil {
+
+    /**
+     * Method wrapping all the actions org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
+     * in org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action, to set appropriate keys
+     * for actions.
+     *
+     * @param actionList the action list
+     * @return the list
+     */
+    public static List<Action> wrapActionList(List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> actionList) {
+        List<Action> actions = new ArrayList<>();
+
+        int actionKey = 0;
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : actionList) {
+            ActionBuilder wrappedAction = new ActionBuilder();
+            wrappedAction.setAction(action);
+            wrappedAction.setKey(new ActionKey(actionKey));
+            wrappedAction.setOrder(actionKey);
+            actions.add(wrappedAction.build());
+            actionKey++;
+        }
+
+        return actions;
+    }
+
+    /**
+     * Safely gets ip protocol from flow.
+     *
+     * @param flow the flow
+     * @return the ip protocol from flow
+     */
+    public static Short getIpProtocolFromFlow(Flow flow) {
+        Short ipProtocol = null;
+
+        if (flow.getMatch() != null && flow.getMatch().getIpMatch() != null) {
+            ipProtocol = flow.getMatch().getIpMatch().getIpProtocol();
+        }
+
+        return ipProtocol;
+    }
+}
@@ -6,17 +6,21 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
+import java.util.Set;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-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.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
@@ -38,49 +42,59 @@ 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.GotoTableCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 
-public final class OFToMDSalFlowConvertor {
+/**
+ * Converts Openflow 1.3+ specific instructions to MD-SAL format flow instruction
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionConvertorData data = new VersionConvertorData(version);
+ * Optional<Instructions> salFlowInstruction = convertorManager.convert(ofFlowInstructions, data);
+ * }
+ * </pre>
+ */
+public final class FlowInstructionResponseConvertor extends Convertor<
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction>,
+        Instructions,
+        VersionConvertorData> {
 
-    private OFToMDSalFlowConvertor() {
-        // hiding implicite constructor
-    }
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction.class);
 
-    /**
-     * Method convert Openflow 1.3+ specific instructions to MD-SAL format
-     * flow instruction
-     *
-     * @param instructions instructions
-     * @param ofVersion    current ofp version
-     * @return instruction converted to SAL instruction
-     */
-    public static Instructions toSALInstruction(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> instructions, OpenflowVersion ofVersion) {
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
 
+    @Override
+    public Instructions convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> source, VersionConvertorData data) {
         InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
 
-        List<Instruction> salInstructionList = new ArrayList<Instruction>();
+        List<Instruction> salInstructionList = new ArrayList<>();
         int instructionTreeNodekey = 0;
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction salInstruction;
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction switchInst : instructions) {
-            if (switchInst.getInstructionChoice() instanceof ApplyActionsCase) {
 
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.
+                Instruction switchInst : source) {
+            if (switchInst.getInstructionChoice() instanceof ApplyActionsCase) {
                 ApplyActionsCase actionsInstruction = ((ApplyActionsCase) switchInst.getInstructionChoice());
                 ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
                 ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
 
+                final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
+                actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);
 
-                applyActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsInstruction.getApplyActions().getAction(), ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION)));
+                final Optional<List<Action>> actions = getConvertorExecutor().convert(
+                        actionsInstruction.getApplyActions().getAction(), actionResponseConvertorData);
 
+                applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
                 applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
                 salInstruction = applyActionsCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
-
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase clearActionsCase =
-                        ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) switchInst.getInstructionChoice());
                 ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
                 salInstruction = clearActionsCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof GotoTableCase) {
-
                 GotoTableCase gotoTableCase = ((GotoTableCase) switchInst.getInstructionChoice());
 
                 GoToTableCaseBuilder goToTableCaseBuilder = new GoToTableCaseBuilder();
@@ -90,10 +104,8 @@ public final class OFToMDSalFlowConvertor {
 
                 salInstruction = goToTableCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof MeterCase) {
-
                 MeterCase meterIdInstruction = ((MeterCase) switchInst.getInstructionChoice());
 
-
                 MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
                 MeterBuilder meterBuilder = new MeterBuilder();
                 meterBuilder.setMeterId(new MeterId(meterIdInstruction.getMeter().getMeterId()));
@@ -101,17 +113,20 @@ public final class OFToMDSalFlowConvertor {
 
                 salInstruction = meterCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof WriteActionsCase) {
-
                 WriteActionsCase writeActionsCase = ((WriteActionsCase) switchInst.getInstructionChoice());
-
                 WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
                 WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
-                writeActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(writeActionsCase.getWriteActions().getAction(), ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION)));
-                writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
 
+                final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
+                actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+
+                final Optional<List<Action>> actions = getConvertorExecutor().convert(
+                        writeActionsCase.getWriteActions().getAction(), actionResponseConvertorData);
+
+                writeActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
+                writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
                 salInstruction = writeActionsCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) {
-
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase writeMetadataCase =
                         ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) switchInst.getInstructionChoice());
                 WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
@@ -132,60 +147,8 @@ public final class OFToMDSalFlowConvertor {
             salInstructionList.add(instBuilder.build());
 
         }
-        instructionsBuilder.setInstruction(salInstructionList);
-        return instructionsBuilder.build();
-    }
-
-    /*
-     * Method wrapping all the actions org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
-     * in org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action, to set appropriate keys
-     * for actions.
-     */
-    private static List<Action> wrapActionList(List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> actionList) {
-        List<Action> actions = new ArrayList<>();
-
-        int actionKey = 0;
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : actionList) {
-            ActionBuilder wrappedAction = new ActionBuilder();
-            wrappedAction.setAction(action);
-            wrappedAction.setKey(new ActionKey(actionKey));
-            wrappedAction.setOrder(actionKey);
-            actions.add(wrappedAction.build());
-            actionKey++;
-        }
-
-        return actions;
-    }
-
-    /**
-     * Method wraps openflow 1.0 actions list to Apply Action Instructions
-     *
-     * @param ofVersion current ofp version
-     * @param actionsList list of action
-     * @return OF10 actions as an instructions
-     */
-
-    public static Instructions wrapOF10ActionsToInstruction(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList, OpenflowVersion ofVersion) {
-        InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
-
-        List<Instruction> salInstructionList = new ArrayList<Instruction>();
-
-        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
-        ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
-
-        applyActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsList, ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION)));
-
-        applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
-
-        InstructionBuilder instBuilder = new InstructionBuilder();
-        instBuilder.setInstruction(applyActionsCaseBuilder.build());
-        instBuilder.setKey(new InstructionKey(0));
-        instBuilder.setOrder(0);
-        salInstructionList.add(instBuilder.build());
 
         instructionsBuilder.setInstruction(salInstructionList);
         return instructionsBuilder.build();
     }
-
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java
new file mode 100644 (file)
index 0000000..84c8b69
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+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.model.statistics.types.rev130925.duration.DurationBuilder;
+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.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts flow related statistics messages coming from openflow switch to MD-SAL messages.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * Optional<List<FlowAndStatisticsMapList>> salFlowStats = convertorManager.convert(ofFlowStats, data);
+ * }
+ * </pre>
+ */
+public class FlowStatsResponseConvertor extends Convertor<List<FlowStats>, List<FlowAndStatisticsMapList>, VersionDatapathIdConvertorData> {
+
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(FlowStats.class);
+
+    /**
+     * Method wraps openflow 1.0 actions list to Apply Action Instructions
+     *
+     * @param actionsList list of action
+     * @return OF10 actions as an instructions
+     */
+    private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList, final short version) {
+        ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(version);
+        actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+
+        InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
+        List<Instruction> salInstructionList = new ArrayList<>();
+
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
+
+        final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> actions = getConvertorExecutor().convert(
+                actionsList, actionResponseConvertorData);
+
+        applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
+        applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+
+        InstructionBuilder instBuilder = new InstructionBuilder();
+        instBuilder.setInstruction(applyActionsCaseBuilder.build());
+        instBuilder.setKey(new InstructionKey(0));
+        instBuilder.setOrder(0);
+        salInstructionList.add(instBuilder.build());
+
+        instructionsBuilder.setInstruction(salInstructionList);
+        return instructionsBuilder.build();
+    }
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public List<FlowAndStatisticsMapList> convert(List<FlowStats> source, VersionDatapathIdConvertorData data) {
+        final List<FlowAndStatisticsMapList> result = new ArrayList<>();
+
+        for (FlowStats flowStats : source) {
+            // Convert Openflow switch specific flow statistics to the MD-SAL format flow statistics
+            FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
+            salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
+
+            if (flowStats.getCookie() != null) {
+                salFlowStatsBuilder.setCookie(new FlowCookie(flowStats.getCookie()));
+            }
+
+            DurationBuilder time = new DurationBuilder();
+            time.setSecond(new Counter32(flowStats.getDurationSec()));
+            time.setNanosecond(new Counter32(flowStats.getDurationNsec()));
+            salFlowStatsBuilder.setDuration(time.build());
+
+            salFlowStatsBuilder.setHardTimeout(flowStats.getHardTimeout());
+            salFlowStatsBuilder.setIdleTimeout(flowStats.getIdleTimeout());
+            salFlowStatsBuilder.setPacketCount(new Counter64(flowStats.getPacketCount()));
+            salFlowStatsBuilder.setPriority(flowStats.getPriority());
+            salFlowStatsBuilder.setTableId(flowStats.getTableId());
+
+            if (flowStats.getMatchV10() != null) {
+                final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatchV10(), data);
+
+                if (matchBuilderOptional.isPresent()) {
+                    salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build());
+                }
+
+                if (flowStats.getAction() != null && flowStats.getAction().size() != 0) {
+                    salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion()));
+                }
+            }
+
+            if (flowStats.getMatch() != null) {
+                final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatch(), data);
+
+                if (matchBuilderOptional.isPresent()) {
+                    final MatchBuilder matchBuilder = matchBuilderOptional.get();
+
+                    final AugmentTuple<Match> matchExtensionWrap =
+                            MatchExtensionHelper.processAllExtensions(
+                                    flowStats.getMatch().getMatchEntry(),
+                                    OpenflowVersion.get(data.getVersion()),
+                                    MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+
+                    if (matchExtensionWrap != null) {
+                        matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
+                    }
+
+                    salFlowStatsBuilder.setMatch(matchBuilder.build());
+                }
+
+
+                salFlowStatsBuilder.setFlags(
+                        new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(),
+                                flowStats.getFlags().isOFPFFRESETCOUNTS(),
+                                flowStats.getFlags().isOFPFFNOPKTCOUNTS(),
+                                flowStats.getFlags().isOFPFFNOBYTCOUNTS(),
+                                flowStats.getFlags().isOFPFFSENDFLOWREM()));
+            }
+
+            if (flowStats.getInstruction() != null) {
+                final VersionConvertorData simpleConvertorData = new VersionConvertorData(data.getVersion());
+                final Optional<Instructions> instructions = getConvertorExecutor().convert(
+                        flowStats.getInstruction(), simpleConvertorData);
+
+                salFlowStatsBuilder.setInstructions(instructions.orElse(new InstructionsBuilder()
+                        .setInstruction(Collections.emptyList()).build()));
+            }
+
+            result.add(salFlowStatsBuilder.build());
+        }
+
+        return result;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/ApplyActionsCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/ApplyActionsCase.java
new file mode 100644 (file)
index 0000000..139cd8c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow.cases;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+
+public class ApplyActionsCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase, Instruction, ActionConvertorData> {
+    public ApplyActionsCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Instruction> process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        ApplyActions applyActions = source.getApplyActions();
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
+
+        final Optional<List<Action>> actionList = convertorExecutor.convert(applyActions.getAction(), data);
+
+        applyActionsBuilder.setAction(actionList.orElse(Collections.emptyList()));
+        applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+        instructionBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
+        return Optional.of(instructionBuilder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/ClearActionsCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/ClearActionsCase.java
new file mode 100644 (file)
index 0000000..c167cef
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+
+public class ClearActionsCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase, Instruction, ActionConvertorData> {
+    public ClearActionsCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Instruction> process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+        instructionBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
+        return Optional.of(instructionBuilder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/GoToTableCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/GoToTableCase.java
new file mode 100644 (file)
index 0000000..997f6b6
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+
+public class GoToTableCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase, Instruction, ActionConvertorData> {
+    public GoToTableCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Instruction> process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        GoToTable goToTable = source.getGoToTable();
+        GotoTableCaseBuilder gotoTableCaseBuilder = new GotoTableCaseBuilder();
+        GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
+        gotoTableBuilder.setTableId(goToTable.getTableId());
+        gotoTableCaseBuilder.setGotoTable(gotoTableBuilder.build());
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+        instructionBuilder.setInstructionChoice(gotoTableCaseBuilder.build());
+        return Optional.of(instructionBuilder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/MeterCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/MeterCase.java
new file mode 100644 (file)
index 0000000..293fd39
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+
+public class MeterCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase, Instruction, ActionConvertorData> {
+    public MeterCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Instruction> process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        Meter meter = source.getMeter();
+        MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+        MeterBuilder meterBuilder = new MeterBuilder();
+        Long meterId = meter.getMeterId().getValue();
+        meterBuilder.setMeterId(meterId);
+        meterCaseBuilder.setMeter(meterBuilder.build());
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+        instructionBuilder.setInstructionChoice(meterCaseBuilder.build());
+        return Optional.of(instructionBuilder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/WriteActionsCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/WriteActionsCase.java
new file mode 100644 (file)
index 0000000..198bbd1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow.cases;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+
+public class WriteActionsCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase, Instruction, ActionConvertorData> {
+    public WriteActionsCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Instruction> process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        WriteActions writeActions = source.getWriteActions();
+        WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
+        WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
+
+        final Optional<List<Action>> actions = convertorExecutor.convert(writeActions.getAction(), data);
+
+        writeActionsBuilder.setAction(actions.orElse(Collections.emptyList()));
+        writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+        instructionBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
+        return Optional.of(instructionBuilder.build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/WriteMetadataCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/cases/WriteMetadataCase.java
new file mode 100644 (file)
index 0000000..20938e8
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.flow.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+
+public class WriteMetadataCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase, Instruction, ActionConvertorData> {
+    public WriteMetadataCase() {
+        super(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<Instruction> process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
+        WriteMetadata writeMetadata = source.getWriteMetadata();
+        WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
+        WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
+        writeMetadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadata(), OFConstants.SIZE_OF_LONG_IN_BYTES));
+        writeMetadataBuilder.setMetadataMask(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadataMask(), OFConstants.SIZE_OF_LONG_IN_BYTES));
+        writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
+        InstructionBuilder instructionBuilder = new InstructionBuilder();
+        instructionBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());
+        return Optional.of(instructionBuilder.build());
+    }
+}
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,24 +6,22 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
-
-import java.math.BigInteger;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag;
 
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 
 /**
  * converting from MD-SAL match model into appropriate OF-API match model
- * @param <E>  type of converted match
+ *
+ * @param <E> type of converted match
  */
-public interface FlowFlagConvertor<E> extends Convertor<FlowModFlags, E> {
-    
+public interface FlowFlagConvertor<E> extends ConvertReactorConvertor<FlowModFlags, E> {
     /**
      * @param source flow mode flags
-     * @param datapathid  datapath id
+     * @param convertorExecutor
      * @return converted match (into OF-API model)
      */
-    @Override
-    E convert(FlowModFlags source,BigInteger datapathid);
+    E convert(FlowModFlags source, ConvertorExecutor convertorExecutor);
 }
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,13 +6,12 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag;
 
 import java.util.Map;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorKey;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 
@@ -35,8 +34,8 @@ public class FlowFlagReactor extends ConvertReactor<FlowModFlags> {
     }
 
     @Override
-    protected void initMappings(final Map<Short, Convertor<FlowModFlags, ?>> conversions,
-            final Map<InjectionKey, ResultInjector<?,?>> injections) {
+    protected void initMappings(final Map<Short, ConvertReactorConvertor<FlowModFlags, ?>> conversions,
+                                final Map<ConvertorKey, ResultInjector<?, ?>> injections) {
         FlowFlagReactorMappingFactory.addFlowFlagsConvertors(conversions);
         FlowFlagReactorMappingFactory.addFlowFlagsIjectors(injections);
     }
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,13 +6,12 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag;
 
 import java.util.Map;
-
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorKey;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
@@ -20,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 
 /**
  * add prepared convertors and injectors into given mappings
+ *
  * @see FlowFlagReactor
  */
 public class FlowFlagReactorMappingFactory {
@@ -27,7 +27,7 @@ public class FlowFlagReactorMappingFactory {
     /**
      * @param conversionMapping conversion mapping
      */
-    public static void addFlowFlagsConvertors(final Map<Short, Convertor<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags, ?>> conversionMapping) {
+    public static void addFlowFlagsConvertors(final Map<Short, ConvertReactorConvertor<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags, ?>> conversionMapping) {
         conversionMapping.put(OFConstants.OFP_VERSION_1_3, new FlowFlagsConvertorImpl());
         conversionMapping.put(OFConstants.OFP_VERSION_1_0, new FlowFlagsConvertorV10Impl());
     }
@@ -35,26 +35,26 @@ public class FlowFlagReactorMappingFactory {
     /**
      * @param injectionMapping injection mapping
      */
-    public static void addFlowFlagsIjectors(final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping) {
+    public static void addFlowFlagsIjectors(final Map<ConvertorKey, ResultInjector<?, ?>> injectionMapping) {
         // OF-1.3|FlowModFlags --> FlowModInputBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_3, FlowModInputBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_3, FlowModInputBuilder.class),
                 new ResultInjector<FlowModFlags, FlowModInputBuilder>() {
-            @Override
-            public void inject(final FlowModFlags value,
-                    final FlowModInputBuilder target) {
-                target.setFlags(value);
-            }
-        });
+                    @Override
+                    public void inject(final FlowModFlags value,
+                                       final FlowModInputBuilder target) {
+                        target.setFlags(value);
+                    }
+                });
 
         // OF-1.3|FlowModFlagsV10 --> FlowModInputBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_0, FlowModInputBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_0, FlowModInputBuilder.class),
                 new ResultInjector<FlowModFlagsV10, FlowModInputBuilder>() {
-            @Override
-            public void inject(final FlowModFlagsV10 value,
-                    final FlowModInputBuilder target) {
-                target.setFlagsV10(value);
-            }
-        });
+                    @Override
+                    public void inject(final FlowModFlagsV10 value,
+                                       final FlowModInputBuilder target) {
+                        target.setFlagsV10(value);
+                    }
+                });
 
     }
 
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,36 +6,35 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
-
-import java.math.BigInteger;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag;
 
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
 
 /**
- * 
+ *
  */
 public class FlowFlagsConvertorImpl implements FlowFlagConvertor<FlowModFlags> {
 
     @Override
     public FlowModFlags convert(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source, BigInteger datapathid) {
-    
-        FlowModFlags ofFlowModFlags = null;
+            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source, ConvertorExecutor convertorExecutor) {
+
+        FlowModFlags ofFlowModFlags;
         if (source != null) {
             ofFlowModFlags = new FlowModFlags(
                     source.isCHECKOVERLAP(), source.isNOBYTCOUNTS(), source.isNOPKTCOUNTS(),
                     source.isRESETCOUNTS(), source.isSENDFLOWREM());
         } else {
             ofFlowModFlags = new FlowModFlags(
-                    FlowConvertor.DEFAULT_OFPFF_CHECK_OVERLAP, 
-                    FlowConvertor.DEFAULT_OFPFF_NO_BYT_COUNTS, 
+                    FlowConvertor.DEFAULT_OFPFF_CHECK_OVERLAP,
+                    FlowConvertor.DEFAULT_OFPFF_NO_BYT_COUNTS,
                     FlowConvertor.DEFAULT_OFPFF_NO_PKT_COUNTS,
-                    FlowConvertor.DEFAULT_OFPFF_RESET_COUNTS, 
+                    FlowConvertor.DEFAULT_OFPFF_RESET_COUNTS,
                     FlowConvertor.DEFAULT_OFPFF_FLOW_REM);
         }
-        
+
         return ofFlowModFlags;
     }
 }
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -6,33 +6,33 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
-
-import java.math.BigInteger;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag;
 
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
 
 /**
- * 
+ *
  */
 public class FlowFlagsConvertorV10Impl implements FlowFlagConvertor<FlowModFlagsV10> {
 
     @Override
     public FlowModFlagsV10 convert(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source, BigInteger datapathid) {
-    
-        FlowModFlagsV10 ofFlowModFlags = null;
+            FlowModFlags source, ConvertorExecutor convertorExecutor) {
+
+        FlowModFlagsV10 ofFlowModFlags;
         if (source != null) {
             ofFlowModFlags = new FlowModFlagsV10(
                     source.isCHECKOVERLAP(), FlowConvertor.DEFAULT_OFPFF_EMERGENCY, source.isSENDFLOWREM());
         } else {
             ofFlowModFlags = new FlowModFlagsV10(
-                    FlowConvertor.DEFAULT_OFPFF_CHECK_OVERLAP, 
-                    FlowConvertor.DEFAULT_OFPFF_EMERGENCY, 
+                    FlowConvertor.DEFAULT_OFPFF_CHECK_OVERLAP,
+                    FlowConvertor.DEFAULT_OFPFF_EMERGENCY,
                     FlowConvertor.DEFAULT_OFPFF_FLOW_REM);
         }
-        
+
         return ofFlowModFlags;
     }
 }
index c51761c9e3454be3c0f2098e1bc118988fb39880..b4a027329e98b96527fb0957f8a554350ecb553d 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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,
@@ -8,22 +8,20 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
-import java.math.BigInteger;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 
 /**
  * converting from MD-SAL match model into appropriate OF-API match model
- * @param <E>  type of converted match
+ *
+ * @param <E> type of converted match
  */
-public interface MatchConvertor<E> extends Convertor<Match, E> {
-    
+public interface MatchConvertor<E> extends ConvertReactorConvertor<Match, E> {
     /**
      * @param source match input
-     * @param datapathid datapath id
+     * @param convertorExecutor
      * @return converted match (into OF-API model)
      */
-    @Override
-    E convert(Match source,BigInteger datapathid);
+    E convert(Match source, ConvertorExecutor convertorExecutor);
 }
index 4de3dbf84e38d3a3cfb957695a2768f5f3615e4b..9f273ed729971749c0fb07bf7242a9d10622abcd 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013, 2015 Ericsson. and others.  All rights reserved.
+/*
+ * 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,
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
-import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
 
 import com.google.common.base.Optional;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import javax.annotation.Nonnull;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionResolvers;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.OFApprovedExperimenterIds;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfArpMatchCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfIpv4MatchArbitraryBitMaskCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfIpv4MatchCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfIpv6MatchArbitraryBitMaskCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfIpv6MatchCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfSctpMatchCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfTcpMatchCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfTunnelIpv4MatchCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfUdpMatchCase;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6Label;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
 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.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
 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.entries.grouping.MatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
-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.InPortCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder;
@@ -237,1601 +108,340 @@ 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.icmpv6.type._case.Icmpv6TypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;
 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.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProtoBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabelBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTcBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsidBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Utility class for converting a MD-SAL Flow into the OF flow mod
  */
 public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
-    private static final Logger logger = LoggerFactory.getLogger(MatchConvertorImpl.class);
+    private static final ConvertorProcessor<Layer3Match, List<MatchEntry>, VersionConvertorData> LAYER3_PROCESSOR = new ConvertorProcessor<Layer3Match, List<MatchEntry>, VersionConvertorData>()
+            .addCase(new SalToOfIpv4MatchArbitraryBitMaskCase())
+            .addCase(new SalToOfIpv4MatchCase())
+            .addCase(new SalToOfTunnelIpv4MatchCase())
+            .addCase(new SalToOfArpMatchCase())
+            .addCase(new SalToOfIpv6MatchArbitraryBitMaskCase())
+            .addCase(new SalToOfIpv6MatchCase());
+
+    private static final ConvertorProcessor<Layer4Match, List<MatchEntry>, VersionConvertorData> LAYER4_PROCESSOR = new ConvertorProcessor<Layer4Match, List<MatchEntry>, VersionConvertorData>()
+            .addCase(new SalToOfTcpMatchCase())
+            .addCase(new SalToOfUdpMatchCase())
+            .addCase(new SalToOfSctpMatchCase());
+
     private static final byte[] VLAN_VID_MASK = new byte[]{16, 0};
-    private static final short PROTO_TCP = 6;
-    private static final short PROTO_UDP = 17;
-    private static final short PROTO_ICMPV4 = 1;
-    private static final String NO_IP = "0.0.0.0/0";
-
-    // Pre-calculated masks for the 33 possible values. Do not give them out, but clone() them as they may
-    // end up being leaked and vulnerable.
-    private static final byte[][] IPV4_MASKS;
-    static {
-        final byte[][] tmp = new byte[33][];
-        for (int i = 0; i <= 32; ++i) {
-            final int mask = 0xffffffff << (32 - i);
-            tmp[i] =  new byte[]{(byte) (mask >>> 24), (byte) (mask >>> 16), (byte) (mask >>> 8), (byte) mask};
-        }
 
-        IPV4_MASKS = tmp;
-    }
+    private static void layer3Match(final List<MatchEntry> matchEntryList, final Layer3Match layer3Match, ConvertorExecutor convertorExecutor) {
+        java.util.Optional<List<MatchEntry>> result = LAYER3_PROCESSOR.process(layer3Match, convertorExecutor);
 
-    @Override
-    public List<MatchEntry> convert(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match, final BigInteger datapathid) {
-        List<MatchEntry> matchEntryList = new ArrayList<>();
-        if (match == null) {
-            return matchEntryList;
-        }
-        if (match.getInPort() != null) {
-            //TODO: currently this matchconverter is mapped to OF1.3 in MatchReactorMappingFactory. Will need to revisit during 1.4+
-            matchEntryList.add(toOfPort(InPort.class,
-                    InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, match.getInPort())));
+        if (result.isPresent()) {
+            matchEntryList.addAll(result.get());
         }
+    }
 
-        if (match.getInPhyPort() != null) {
-            //TODO: currently this matchconverter is mapped to OF1.3 in MatchReactorMappingFactory. Will need to revisit during 1.4+
-            matchEntryList.add(toOfPhyPort(InPhyPort.class,
-                    InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, match.getInPhyPort())));
-        }
+    private static void layer4Match(final List<MatchEntry> matchEntryList, final Layer4Match layer4Match, ConvertorExecutor convertorExecutor) {
+        java.util.Optional<List<MatchEntry>> result = LAYER4_PROCESSOR.process(layer4Match, convertorExecutor);
 
-        org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata metadata = match
-                .getMetadata();
-        if (metadata != null) {
-            matchEntryList.add(toOfMetadata(Metadata.class, metadata.getMetadata(), metadata.getMetadataMask()));
+        if (result.isPresent()) {
+            matchEntryList.addAll(result.get());
         }
+    }
 
-        ethernetMatch(matchEntryList, match.getEthernetMatch());
-        vlanMatch(matchEntryList, match.getVlanMatch());
-        ipMatch(matchEntryList, match.getIpMatch());
-        layer4Match(matchEntryList, match.getLayer4Match());
-        icmpv4Match(matchEntryList, match.getIcmpv4Match());
-        icmpv6Match(matchEntryList, match.getIcmpv6Match());
-        layer3Match(matchEntryList, match.getLayer3Match());
-        protocolMatchFields(matchEntryList, match.getProtocolMatchFields());
-
-        org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel tunnel = match
-                .getTunnel();
-        if (tunnel != null) {
-            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-            TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
-            TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
-            boolean hasMask = false;
-            if (null != tunnel.getTunnelMask()) {
-                hasMask = true;
-                tunnelIdBuilder.setMask(ByteUtil.convertBigIntegerToNBytes(tunnel.getTunnelMask(), OFConstants.SIZE_OF_LONG_IN_BYTES));
-            }
-            tunnelIdBuilder.setTunnelId(ByteUtil.convertBigIntegerToNBytes(tunnel.getTunnelId(), OFConstants.SIZE_OF_LONG_IN_BYTES));
-            tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
-            matchEntryBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
-            matchEntryBuilder.setHasMask(hasMask);
-            matchEntryBuilder.setOxmMatchField(TunnelId.class);
-            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-            matchEntryList.add(matchEntryBuilder.build());
+    private static void inPortMatch(final List<MatchEntry> matchEntryList, NodeConnectorId inPort) {
+        if (inPort == null) {
+            return;
         }
 
+        //TODO: currently this matchconverter is mapped to OF1.3 in MatchReactorMappingFactory. Will need to revisit during 1.4+
+        final long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPort);
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchEntryBuilder.setHasMask(false);
+        matchEntryBuilder.setOxmMatchField(InPort.class);
+        InPortCaseBuilder caseBuilder = new InPortCaseBuilder();
+        InPortBuilder portBuilder = new InPortBuilder();
+        portBuilder.setPortNumber(new PortNumber(portNumber));
+        caseBuilder.setInPort(portBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        matchEntryList.add(matchEntryBuilder.build());
+    }
 
-        /**
-         * TODO: EXTENSION PROPOSAL (match, MD-SAL to OFJava)
-         * - we might need version for conversion and for key
-         * - sanitize NPE
-         */
-        Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(match);
-        if (extensionListOpt.isPresent()) {
-            for (ExtensionList extensionItem : extensionListOpt.get().getExtensionList()) {
-                // TODO: get real version
-                ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
-                ConvertorToOFJava<MatchEntry> convertor =
-                        OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
-                MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
-                matchEntryList.add(ofMatch);
-            }
+    private static void inPhyPortMatch(final List<MatchEntry> matchEntryList, NodeConnectorId inPhyPort) {
+        if (inPhyPort == null) {
+            return;
         }
 
-        return matchEntryList;
+        //TODO: currently this matchconverter is mapped to OF1.3 in MatchReactorMappingFactory. Will need to revisit during 1.4+
+        final long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPhyPort);
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchEntryBuilder.setHasMask(false);
+        matchEntryBuilder.setOxmMatchField(InPhyPort.class);
+        InPhyPortCaseBuilder caseBuilder = new InPhyPortCaseBuilder();
+        InPhyPortBuilder portBuilder = new InPhyPortBuilder();
+        portBuilder.setPortNumber(new PortNumber(portNumber));
+        caseBuilder.setInPhyPort(portBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        matchEntryList.add(matchEntryBuilder.build());
     }
 
-
-    private static void protocolMatchFields(final List<MatchEntry> matchEntryList,
-            final ProtocolMatchFields protocolMatchFields) {
-        if (protocolMatchFields != null) {
-            if (protocolMatchFields.getMplsLabel() != null) {
-                matchEntryList.add(toOfMplsLabel(protocolMatchFields.getMplsLabel()));
-            }
-
-            if (protocolMatchFields.getMplsBos() != null) {
-                matchEntryList.add(toOfMplsBos(protocolMatchFields.getMplsBos()));
-            }
-
-            if (protocolMatchFields.getMplsTc() != null) {
-                matchEntryList.add(toOfMplsTc(protocolMatchFields.getMplsTc()));
-            }
-
-            if (protocolMatchFields.getPbb() != null) {
-                matchEntryList.add(toOfMplsPbb(protocolMatchFields.getPbb()));
-            }
+    private static void metadataMatch(final List<MatchEntry> matchEntryList,
+                                      final org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata metadata) {
+        if (metadata == null) {
+            return;
         }
-    }
 
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        boolean hasmask = metadata.getMetadataMask() != null;
+        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchEntryBuilder.setOxmMatchField(Metadata.class);
+        MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();
+        metadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(metadata.getMetadata(), OFConstants.SIZE_OF_LONG_IN_BYTES));
 
-    private static void layer3Match(final List<MatchEntry> matchEntryList, final Layer3Match layer3Match) {
-        if (layer3Match != null) {
-            if(layer3Match instanceof Ipv6MatchArbitraryBitMask){
-                Ipv6MatchArbitraryBitMask Ipv6ArbitraryMaskMatchFields = (Ipv6MatchArbitraryBitMask) layer3Match;
-                if (Ipv6ArbitraryMaskMatchFields.getIpv6SourceAddressNoMask() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
-
-                    Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
-                    Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
-                    ipv6SrcBuilder.setIpv6Address(Ipv6ArbitraryMaskMatchFields.getIpv6SourceAddressNoMask());
-                    Ipv6ArbitraryMask sourceArbitrarySubNetMask = Ipv6ArbitraryMaskMatchFields.getIpv6SourceArbitraryBitmask();
-                    boolean hasMask = false;
-                    if (sourceArbitrarySubNetMask != null) {
-                        byte[] maskByteArray = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
-                        if (maskByteArray != null) {
-                            ipv6SrcBuilder.setMask(maskByteArray);
-                            hasMask = true;
-                        }
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-                if (Ipv6ArbitraryMaskMatchFields.getIpv6DestinationAddressNoMask() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
-
-                    Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
-                    Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
-
-                    ipv6DstBuilder.setIpv6Address(Ipv6ArbitraryMaskMatchFields.getIpv6DestinationAddressNoMask());
-                    Ipv6ArbitraryMask destinationArbitrarySubNetMask = Ipv6ArbitraryMaskMatchFields.getIpv6DestinationArbitraryBitmask();
-
-                    boolean hasMask = false;
-                    if (destinationArbitrarySubNetMask != null) {
-                        byte[] maskByteArray = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(destinationArbitrarySubNetMask);
-                        if (maskByteArray != null) {
-                            ipv6DstBuilder.setMask(maskByteArray);
-                            hasMask = true;
-                        }
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            }
-            if(layer3Match instanceof Ipv4MatchArbitraryBitMask) {
-                Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMaskFields = (Ipv4MatchArbitraryBitMask) layer3Match;
-                if (ipv4MatchArbitraryBitMaskFields.getIpv4SourceAddressNoMask() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
-
-                    Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
-                    Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
-
-                    ipv4SrcBuilder.setIpv4Address(ipv4MatchArbitraryBitMaskFields.getIpv4SourceAddressNoMask());
-                    DottedQuad sourceArbitrarySubNetMask = ipv4MatchArbitraryBitMaskFields.getIpv4SourceArbitraryBitmask();
-
-                    boolean hasMask = false;
-                    if (sourceArbitrarySubNetMask != null) {
-                        byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
-                        if (maskByteArray != null) {
-                            ipv4SrcBuilder.setMask(maskByteArray);
-                            hasMask = true;
-                        }
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-                if (ipv4MatchArbitraryBitMaskFields.getIpv4DestinationAddressNoMask() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
-
-                    Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
-                    Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
-
-                    ipv4DstBuilder.setIpv4Address(ipv4MatchArbitraryBitMaskFields.getIpv4DestinationAddressNoMask());
-                    DottedQuad destArbitrarySubNetMask = ipv4MatchArbitraryBitMaskFields.getIpv4DestinationArbitraryBitmask();
-
-                    boolean hasMask = false;
-                    if (destArbitrarySubNetMask != null) {
-                        byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(destArbitrarySubNetMask);
-                        if (maskByteArray != null) {
-                            ipv4DstBuilder.setMask(maskByteArray);
-                            hasMask = true;
-                        }
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            }
-            if(layer3Match instanceof Ipv4Match){
-                Ipv4Match ipv4Match = (Ipv4Match) layer3Match;
-                if (ipv4Match.getIpv4Source() != null) {
-                    Ipv4Prefix ipv4Prefix = ipv4Match.getIpv4Source();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
-
-                    Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
-                    Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
-
-                    Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
-                    Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
-                    ipv4SrcBuilder.setIpv4Address(ipv4Address);
-                    boolean hasMask = false;
-                    byte[] mask = extractIpv4Mask(addressParts);
-                    if (null != mask) {
-                        ipv4SrcBuilder.setMask(mask);
-                        hasMask = true;
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-                if (ipv4Match.getIpv4Destination() != null) {
-                    Ipv4Prefix ipv4Prefix = ipv4Match.getIpv4Destination();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
-
-                    Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
-                    Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
-
-                    Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
-                    Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
-                    ipv4DstBuilder.setIpv4Address(ipv4Address);
-                    boolean hasMask = false;
-                    byte[] mask = extractIpv4Mask(addressParts);
-                    if (null != mask) {
-                        ipv4DstBuilder.setMask(mask);
-                        hasMask = true;
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            }
-            if (layer3Match instanceof TunnelIpv4Match) {
-                TunnelIpv4Match tunnelIpv4Src = (TunnelIpv4Match) layer3Match;
-                if (tunnelIpv4Src.getTunnelIpv4Source() != null) {
-                    Ipv4Prefix ipv4Prefix = tunnelIpv4Src.getTunnelIpv4Source();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
-
-                    Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
-                    Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
-
-                    Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
-                    Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
-                    ipv4SrcBuilder.setIpv4Address(ipv4Address);
-                    boolean hasMask = false;
-                    byte[] mask = extractIpv4Mask(addressParts);
-                    if (null != mask) {
-                        ipv4SrcBuilder.setMask(mask);
-                        hasMask = true;
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-                if (tunnelIpv4Src.getTunnelIpv4Destination() != null) {
-                    Ipv4Prefix ipv4Prefix = tunnelIpv4Src.getTunnelIpv4Destination();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
-
-                    Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
-                    Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
-
-                    Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
-                    Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
-                    ipv4DstBuilder.setIpv4Address(ipv4Address);
-                    boolean hasMask = false;
-                    byte[] mask = extractIpv4Mask(addressParts);
-                    if (null != mask) {
-                        ipv4DstBuilder.setMask(mask);
-                        hasMask = true;
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            } else if (layer3Match instanceof ArpMatch) {
-                ArpMatch arpMatch = (ArpMatch) layer3Match;
-                if (arpMatch.getArpOp() != null) {
-                    matchEntryList.add(toOfArpOpCode(arpMatch.getArpOp()));
-                }
-
-                if (arpMatch.getArpSourceTransportAddress() != null) {
-                    Ipv4Prefix ipv4Prefix = arpMatch.getArpSourceTransportAddress();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(ArpSpa.class);
-
-                    ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
-                    ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
-
-                    Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
-                    Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
-                    arpSpaBuilder.setIpv4Address(ipv4Address);
-                    boolean hasMask = false;
-                    byte[] mask = extractIpv4Mask(addressParts);
-                    if (null != mask) {
-                        arpSpaBuilder.setMask(mask);
-                        hasMask = true;
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-
-                if (arpMatch.getArpTargetTransportAddress() != null) {
-                    Ipv4Prefix ipv4Prefix = arpMatch.getArpTargetTransportAddress();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(ArpTpa.class);
-
-                    ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
-                    ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
-
-                    Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
-                    Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
-                    arpTpaBuilder.setIpv4Address(ipv4Address);
-                    boolean hasMask = false;
-                    byte[] mask = extractIpv4Mask(addressParts);
-                    if (null != mask) {
-                        arpTpaBuilder.setMask(mask);
-                        hasMask = true;
-                    }
-                    matchEntryBuilder.setHasMask(hasMask);
-                    arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
+        if (hasmask) {
+            metadataBuilder.setMask(ByteUtil.convertBigIntegerToNBytes(metadata.getMetadataMask(), OFConstants.SIZE_OF_LONG_IN_BYTES));
+        }
 
-                ArpSourceHardwareAddress arpSourceHardwareAddress = arpMatch.getArpSourceHardwareAddress();
-                if (arpSourceHardwareAddress != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(ArpSha.class);
-
-                    ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
-                    ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
-                    arpShaBuilder.setMacAddress(arpSourceHardwareAddress.getAddress());
-                    boolean hasMask = false;
-                    if (null != arpSourceHardwareAddress.getMask()) {
-                        arpShaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpSourceHardwareAddress.getMask().getValue()));
-                        hasMask = true;
-                    }
-                    arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(hasMask);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
+        metadataCaseBuilder.setMetadata(metadataBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(metadataCaseBuilder.build());
+        matchEntryBuilder.setHasMask(hasmask);
+        matchEntryList.add(matchEntryBuilder.build());
+    }
 
-                ArpTargetHardwareAddress arpTargetHardwareAddress = arpMatch.getArpTargetHardwareAddress();
-                if (arpTargetHardwareAddress != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(ArpTha.class);
-
-                    ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
-                    ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
-                    arpThaBuilder.setMacAddress(arpTargetHardwareAddress.getAddress());
-                    boolean hasMask = false;
-                    if (null != arpTargetHardwareAddress.getMask()) {
-                        arpThaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpTargetHardwareAddress.getMask().getValue()));
-                        hasMask = true;
-                    }
-                    arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(hasMask);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            } else if (layer3Match instanceof Ipv6Match) {
-                Ipv6Match ipv6Match = (Ipv6Match) layer3Match;
-                if (ipv6Match.getIpv6Source() != null) {
-                    Ipv6Prefix ipv6Prefix = ipv6Match.getIpv6Source();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
-
-                    Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
-                    Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
-                    final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
-                    boolean hasMask = false;
-                    if (null != prefix) {
-                        ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
-                        hasMask = true;
-                    }
-                    ipv6SrcBuilder.setIpv6Address(IpConversionUtil.extractIpv6Address(ipv6Prefix));
-                    ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
-                    matchEntryBuilder.setHasMask(hasMask);
-                    matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
+    private static void tunnelMatch(final List<MatchEntry> matchEntryList,
+                                    final org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel tunnel) {
+        if (tunnel == null) {
+            return;
+        }
 
-                if (ipv6Match.getIpv6Destination() != null) {
-                    Ipv6Prefix ipv6Prefix = ipv6Match.getIpv6Destination();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
-
-                    Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
-                    Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
-                    final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
-                    boolean hasMask = false;
-                    if (null != prefix) {
-                        ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
-                        hasMask = true;
-                    }
-                    ipv6DstBuilder.setIpv6Address(IpConversionUtil.extractIpv6Address(ipv6Prefix));
-                    ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
-                    matchEntryBuilder.setHasMask(hasMask);
-                    matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
+        TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
+        boolean hasMask = tunnel.getTunnelMask() != null;
 
-                if (ipv6Match.getIpv6Label() != null) {
-                    matchEntryList.add(toOfIpv6FlowLabel(ipv6Match.getIpv6Label()));
-                }
+        if (hasMask) {
+            tunnelIdBuilder.setMask(ByteUtil.convertBigIntegerToNBytes(tunnel.getTunnelMask(), OFConstants.SIZE_OF_LONG_IN_BYTES));
+        }
 
-                if (ipv6Match.getIpv6NdTarget() != null) {
-                    matchEntryList.add(toOfIpv6NdTargetAddress(ipv6Match.getIpv6NdTarget()));
-                }
+        tunnelIdBuilder.setTunnelId(ByteUtil.convertBigIntegerToNBytes(tunnel.getTunnelId(), OFConstants.SIZE_OF_LONG_IN_BYTES));
+        tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
+        matchEntryBuilder.setHasMask(hasMask);
+        matchEntryBuilder.setOxmMatchField(TunnelId.class);
+        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchEntryList.add(matchEntryBuilder.build());
+    }
 
-                if (ipv6Match.getIpv6NdSll() != null) {
-                    MacAddress ipv6NdSll = ipv6Match.getIpv6NdSll();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv6NdSll.class);
-
-                    Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();
-                    Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();
-                    ipv6NdSllBuilder.setMacAddress(ipv6NdSll);
-                    ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
+    private static void protocolMatchFields(final List<MatchEntry> matchEntryList,
+                                            final ProtocolMatchFields protocolMatchFields) {
+        if (protocolMatchFields == null) {
+            return;
+        }
 
-                if (ipv6Match.getIpv6NdTll() != null) {
-                    MacAddress ipv6NdSll = ipv6Match.getIpv6NdTll();
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(Ipv6NdTll.class);
+        if (protocolMatchFields.getMplsLabel() != null) {
+            matchEntryList.add(toOfMplsLabel(protocolMatchFields.getMplsLabel()));
+        }
 
-                    Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();
-                    Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();
-                    ipv6NdTllBuilder.setMacAddress(ipv6NdSll);
-                    ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
+        if (protocolMatchFields.getMplsBos() != null) {
+            matchEntryList.add(toOfMplsBos(protocolMatchFields.getMplsBos()));
+        }
 
-                }
+        if (protocolMatchFields.getMplsTc() != null) {
+            matchEntryList.add(toOfMplsTc(protocolMatchFields.getMplsTc()));
+        }
 
-                if (ipv6Match.getIpv6ExtHeader() != null) {
-                    matchEntryList.add(toOfIpv6ExtHeader(ipv6Match.getIpv6ExtHeader()));
-                }
-            }
+        if (protocolMatchFields.getPbb() != null) {
+            matchEntryList.add(toOfMplsPbb(protocolMatchFields.getPbb()));
         }
     }
 
-
     private static void icmpv6Match(final List<MatchEntry> matchEntryList, final Icmpv6Match icmpv6Match) {
-        if (icmpv6Match != null) {
-            if (icmpv6Match.getIcmpv6Type() != null) {
-                matchEntryList.add(toOfIcmpv6Type(icmpv6Match.getIcmpv6Type()));
-            }
-
-            if (icmpv6Match.getIcmpv6Code() != null) {
-                matchEntryList.add(toOfIcmpv6Code(icmpv6Match.getIcmpv6Code()));
-            }
+        if (icmpv6Match == null) {
+            return;
         }
-    }
-
 
-    private static void icmpv4Match(final List<MatchEntry> matchEntryList, final Icmpv4Match icmpv4Match) {
-        if (icmpv4Match != null) {
-            if (icmpv4Match.getIcmpv4Type() != null) {
-                matchEntryList.add(toOfIcmpv4Type(icmpv4Match.getIcmpv4Type()));
-            }
+        if (icmpv6Match.getIcmpv6Type() != null) {
+            matchEntryList.add(toOfIcmpv6Type(icmpv6Match.getIcmpv6Type()));
+        }
 
-            if (icmpv4Match.getIcmpv4Code() != null) {
-                matchEntryList.add(toOfIcmpv4Code(icmpv4Match.getIcmpv4Code()));
-            }
+        if (icmpv6Match.getIcmpv6Code() != null) {
+            matchEntryList.add(toOfIcmpv6Code(icmpv6Match.getIcmpv6Code()));
         }
     }
 
+    private static void icmpv4Match(final List<MatchEntry> matchEntryList, final Icmpv4Match icmpv4Match) {
+        if (icmpv4Match == null) {
+            return;
+        }
 
-    private static void layer4Match(final List<MatchEntry> matchEntryList, final Layer4Match layer4Match) {
-        if (layer4Match != null) {
-            if (layer4Match instanceof TcpMatch) {
-                TcpMatch tcpMatch = (TcpMatch) layer4Match;
-
-                if (tcpMatch.getTcpSourcePort() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(TcpSrc.class);
-
-                    TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
-                    TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
-                    tcpSrcBuilder.setPort(tcpMatch.getTcpSourcePort());
-                    tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
-
-                    matchEntryBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-                if (tcpMatch.getTcpDestinationPort() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(TcpDst.class);
-
-                    TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
-                    TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
-                    tcpDstBuilder.setPort(tcpMatch.getTcpDestinationPort());
-                    tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            } else if (layer4Match instanceof UdpMatch) {
-                UdpMatch udpMatch = (UdpMatch) layer4Match;
-                if (udpMatch.getUdpSourcePort() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(UdpSrc.class);
-
-                    UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
-                    UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
-                    boolean hasMask = false;
-                    udpSrcBuilder.setPort(udpMatch.getUdpSourcePort());
-                    udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(hasMask);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-
-                if (udpMatch.getUdpDestinationPort() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(UdpDst.class);
-
-                    UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
-                    UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
-                    udpDstBuilder.setPort(udpMatch.getUdpDestinationPort());
-                    udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            } else if (layer4Match instanceof SctpMatch) {
-                SctpMatch sctpMatch = (SctpMatch) layer4Match;
-                if (sctpMatch.getSctpSourcePort() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(SctpSrc.class);
-
-                    SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();
-                    SctpSrcBuilder sctpSrcBuilder = new SctpSrcBuilder();
-                    sctpSrcBuilder.setPort(sctpMatch.getSctpSourcePort());
-                    sctpSrcCaseBuilder.setSctpSrc(sctpSrcBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
+        if (icmpv4Match.getIcmpv4Type() != null) {
+            matchEntryList.add(toOfIcmpv4Type(icmpv4Match.getIcmpv4Type()));
+        }
 
-                if (sctpMatch.getSctpDestinationPort() != null) {
-                    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                    matchEntryBuilder.setOxmMatchField(SctpDst.class);
-
-                    SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();
-                    SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();
-                    sctpDstBuilder.setPort(sctpMatch.getSctpDestinationPort());
-                    sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());
-                    matchEntryBuilder.setMatchEntryValue(sctpDstCaseBuilder.build());
-                    matchEntryBuilder.setHasMask(false);
-                    matchEntryList.add(matchEntryBuilder.build());
-                }
-            }
+        if (icmpv4Match.getIcmpv4Code() != null) {
+            matchEntryList.add(toOfIcmpv4Code(icmpv4Match.getIcmpv4Code()));
         }
     }
 
-
     private static void ipMatch(final List<MatchEntry> matchEntryList, final IpMatch ipMatch) {
-        if (ipMatch != null) {
-            if (ipMatch.getIpDscp() != null) {
-                matchEntryList.add(toOfIpDscp(ipMatch.getIpDscp()));
-            }
+        if (ipMatch == null) {
+            return;
+        }
 
-            if (ipMatch.getIpEcn() != null) {
-                matchEntryList.add(toOfIpEcn(ipMatch.getIpEcn()));
-            }
+        if (ipMatch.getIpDscp() != null) {
+            matchEntryList.add(MatchConvertorUtil.toOfIpDscp(ipMatch.getIpDscp()));
+        }
 
-            if (ipMatch.getIpProtocol() != null) {
-                matchEntryList.add(toOfIpProto(ipMatch.getIpProtocol()));
-            }
+        if (ipMatch.getIpEcn() != null) {
+            matchEntryList.add(toOfIpEcn(ipMatch.getIpEcn()));
         }
-    }
 
+        if (ipMatch.getIpProtocol() != null) {
+            matchEntryList.add(toOfIpProto(ipMatch.getIpProtocol()));
+        }
+    }
 
     private static void vlanMatch(final List<MatchEntry> matchEntryList, final VlanMatch vlanMatch) {
-        if (vlanMatch != null) {
-            if (vlanMatch.getVlanId() != null) {
-                VlanId vlanId = vlanMatch.getVlanId();
-                MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                matchEntryBuilder.setOxmMatchField(VlanVid.class);
-
-                VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
-                VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
-                boolean setCfiBit = false;
-                Integer vidEntryValue = 0;
-                boolean hasmask = false;
-                if (Boolean.TRUE.equals(vlanId.isVlanIdPresent())) {
-                    setCfiBit = true;
-                    if (vlanId.getVlanId() != null) {
-                        vidEntryValue = vlanId.getVlanId().getValue();
-                    }
-                    hasmask = (vidEntryValue == 0);
-                    if (hasmask) {
-                        vlanVidBuilder.setMask(VLAN_VID_MASK);
-                    }
-                }
-
-                vlanVidBuilder.setCfiBit(setCfiBit);
-                vlanVidBuilder.setVlanVid(vidEntryValue);
-                vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
-                matchEntryBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
-                matchEntryBuilder.setHasMask(hasmask);
-                matchEntryList.add(matchEntryBuilder.build());
-            }
-
-            if (vlanMatch.getVlanPcp() != null) {
-                matchEntryList.add(toOfVlanPcp(vlanMatch.getVlanPcp()));
-            }
+        if (vlanMatch == null) {
+            return;
         }
-    }
 
+        if (vlanMatch.getVlanId() != null) {
+            VlanId vlanId = vlanMatch.getVlanId();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(VlanVid.class);
+            VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+            VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+            boolean setCfiBit = false;
+            Integer vidEntryValue = 0;
+            boolean hasmask = false;
 
-    private static void ethernetMatch(final List<MatchEntry> matchEntryList, final EthernetMatch ethernetMatch) {
-        if (ethernetMatch != null) {
-            EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
-            if (ethernetDestination != null) {
-                MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                matchEntryBuilder.setOxmMatchField(EthDst.class);
-                EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
-                EthDstBuilder ethDstBuilder = new EthDstBuilder();
-                ethDstBuilder.setMacAddress(ethernetDestination.getAddress());
-                boolean hasMask = false;
-                if (null != ethernetDestination.getMask()) {
-                    ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetDestination.getMask().getValue()));
-                    hasMask = true;
+            if (Boolean.TRUE.equals(vlanId.isVlanIdPresent())) {
+                setCfiBit = true;
+                if (vlanId.getVlanId() != null) {
+                    vidEntryValue = vlanId.getVlanId().getValue();
                 }
-                ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
-                matchEntryBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
-                matchEntryBuilder.setHasMask(hasMask);
-                matchEntryList.add(matchEntryBuilder.build());
-            }
 
-            EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
-            if (ethernetSource != null) {
-                MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-                matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-                matchEntryBuilder.setOxmMatchField(EthSrc.class);
-
-                EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
-                EthSrcBuilder ethDstBuilder = new EthSrcBuilder();
-                ethDstBuilder.setMacAddress(ethernetSource.getAddress());
-                boolean hasMask = false;
-                if (null != ethernetSource.getMask()) {
-                    ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetSource.getMask().getValue()));
-                    hasMask = true;
+                hasmask = (vidEntryValue == 0);
+                if (hasmask) {
+                    vlanVidBuilder.setMask(VLAN_VID_MASK);
                 }
-                ethSrcCaseBuilder.setEthSrc(ethDstBuilder.build());
-                matchEntryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
-                matchEntryBuilder.setHasMask(hasMask);
-                matchEntryList.add(matchEntryBuilder.build());
-            }
-
-            if (ethernetMatch.getEthernetType() != null) {
-                matchEntryList.add(toOfEthernetType(ethernetMatch.getEthernetType()));
             }
-        }
-    }
 
-
-    private static byte[] extractIpv4Mask(final Iterator<String> addressParts) {
-        final int prefix;
-        if (addressParts.hasNext()) {
-            int potentionalPrefix = Integer.parseInt(addressParts.next());
-            prefix = potentionalPrefix < 32 ? potentionalPrefix : 0;
-        } else {
-            prefix = 0;
+            vlanVidBuilder.setCfiBit(setCfiBit);
+            vlanVidBuilder.setVlanVid(vidEntryValue);
+            vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasmask);
+            matchEntryList.add(matchEntryBuilder.build());
         }
 
-        if (prefix != 0) {
-            // clone() is necessary to protect our constants
-            return IPV4_MASKS[prefix].clone();
+        if (vlanMatch.getVlanPcp() != null) {
+            matchEntryList.add(MatchConvertorUtil.toOfVlanPcp(vlanMatch.getVlanPcp()));
         }
-        return null;
     }
 
-    /**
-     * Method convert Openflow 1.0 specific flow match to MD-SAL format flow
-     * match
-     * @param swMatch source match
-     * @param datapathid datapath id
-     * @param ofVersion openflow version
-     * @return match builder
-     */
-    public static MatchBuilder fromOFMatchV10ToSALMatch(@Nonnull final MatchV10 swMatch, @Nonnull final BigInteger datapathid, @Nonnull final OpenflowVersion ofVersion) {
-        MatchBuilder matchBuilder = new MatchBuilder();
-        EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
-        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
-        Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
-        IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
-        if (!swMatch.getWildcards().isINPORT().booleanValue() && swMatch.getInPort() != null) {
-            matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid,
-                    (long) swMatch.getInPort(), ofVersion));
+    private static void ethernetMatch(final List<MatchEntry> matchEntryList, final EthernetMatch ethernetMatch) {
+        if (ethernetMatch == null) {
+            return;
         }
 
-        if (!swMatch.getWildcards().isDLSRC().booleanValue() && swMatch.getDlSrc() != null) {
-            EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
-            ethSrcBuilder.setAddress(swMatch.getDlSrc());
-            ethMatchBuilder.setEthernetSource(ethSrcBuilder.build());
-            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-        }
-        if (!swMatch.getWildcards().isDLDST().booleanValue() && swMatch.getDlDst() != null) {
-            EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
-            ethDstBuilder.setAddress(swMatch.getDlDst());
-            ethMatchBuilder.setEthernetDestination(ethDstBuilder.build());
-            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-        }
-        if (!swMatch.getWildcards().isDLTYPE().booleanValue() && swMatch.getDlType() != null) {
-            EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-            ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType(
-                    (long) swMatch.getDlType()));
-            ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
-            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-        }
-        if (!swMatch.getWildcards().isDLVLAN().booleanValue() && swMatch.getDlVlan() != null) {
-            VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-            int vlanId = (swMatch.getDlVlan() == (0xffff)) ? 0 : swMatch.getDlVlan();
-            vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanId));
-            vlanIdBuilder.setVlanIdPresent(vlanId == 0 ? false : true);
-            vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
-            matchBuilder.setVlanMatch(vlanMatchBuilder.build());
-        }
-        if (!swMatch.getWildcards().isDLVLANPCP().booleanValue() && swMatch.getDlVlanPcp() != null) {
-            vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(
-                    swMatch.getDlVlanPcp()));
-            matchBuilder.setVlanMatch(vlanMatchBuilder.build());
-        }
-        if (!swMatch.getWildcards().isDLTYPE().booleanValue() && swMatch.getNwSrc() != null) {
-            final Ipv4Prefix prefix;
-            if (swMatch.getNwSrcMask() != null) {
-                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(swMatch.getNwSrc(), swMatch.getNwSrcMask());
-            } else {
-                //Openflow Spec : 1.3.2
-                //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
-                // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
-                // statistics response.
-                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(swMatch.getNwSrc());
-            }
-            if (!NO_IP.equals(prefix.getValue())) {
-                ipv4MatchBuilder.setIpv4Source(prefix);
-                matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
-            }
-        }
-        if (!swMatch.getWildcards().isDLTYPE().booleanValue() && swMatch.getNwDst() != null) {
-            final Ipv4Prefix prefix;
-            if (swMatch.getNwDstMask() != null) {
-                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(swMatch.getNwDst(), swMatch.getNwDstMask());
-            } else {
-                //Openflow Spec : 1.3.2
-                //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
-                // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
-                // statistics response.
-                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(swMatch.getNwDst());
-            }
-            if (!NO_IP.equals(prefix.getValue())) {
-                ipv4MatchBuilder.setIpv4Destination(prefix);
-                matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+        EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
+        if (ethernetDestination != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(EthDst.class);
+            EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
+            EthDstBuilder ethDstBuilder = new EthDstBuilder();
+            ethDstBuilder.setMacAddress(ethernetDestination.getAddress());
+            boolean hasMask = ethernetDestination.getMask() != null;
+
+            if (hasMask) {
+                ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetDestination.getMask().getValue()));
             }
-        }
-        if (!swMatch.getWildcards().isNWPROTO().booleanValue() && swMatch.getNwProto() != null) {
-            Short nwProto = swMatch.getNwProto();
-            ipMatchBuilder.setIpProtocol(nwProto);
-            matchBuilder.setIpMatch(ipMatchBuilder.build());
-
-            int proto = nwProto.intValue();
-            if (proto == PROTO_TCP) {
-                TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
-                boolean hasTcp = false;
-                if (!swMatch.getWildcards().isTPSRC().booleanValue() && swMatch.getTpSrc() != null) {
-                    tcpMatchBuilder
-                            .setTcpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
-                                    swMatch.getTpSrc()));
-                    hasTcp = true;
-                }
-                if (!swMatch.getWildcards().isTPDST().booleanValue() && swMatch.getTpDst() != null) {
-                    tcpMatchBuilder
-                            .setTcpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
-                                    swMatch.getTpDst()));
-                    hasTcp = true;
-                }
-
-                if (hasTcp) {
-                    matchBuilder.setLayer4Match(tcpMatchBuilder.build());
-                }
-            } else if (proto == PROTO_UDP) {
-                UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
-                boolean hasUdp = false;
-                if (!swMatch.getWildcards().isTPSRC().booleanValue() && swMatch.getTpSrc() != null) {
-                    udpMatchBuilder
-                            .setUdpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
-                                    swMatch.getTpSrc()));
-                    hasUdp = true;
-                }
-                if (!swMatch.getWildcards().isTPDST().booleanValue() && swMatch.getTpDst() != null) {
-                    udpMatchBuilder
-                            .setUdpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
-                                    swMatch.getTpDst()));
-                    hasUdp = true;
-                }
 
-                if (hasUdp) {
-                    matchBuilder.setLayer4Match(udpMatchBuilder.build());
-                }
-            } else if (proto == PROTO_ICMPV4) {
-                Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
-                boolean hasIcmpv4 = false;
-                if (!swMatch.getWildcards().isTPSRC().booleanValue()) {
-                    Integer type = swMatch.getTpSrc();
-                    if (type != null) {
-                        icmpv4MatchBuilder.setIcmpv4Type(type.shortValue());
-                        hasIcmpv4 = true;
-                    }
-                }
-                if (!swMatch.getWildcards().isTPDST().booleanValue()) {
-                    Integer code = swMatch.getTpDst();
-                    if (code != null) {
-                        icmpv4MatchBuilder.setIcmpv4Code(code.shortValue());
-                        hasIcmpv4 = true;
-                    }
-                }
-
-                if (hasIcmpv4) {
-                    matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
-                }
-            }
-        }
-        if (!swMatch.getWildcards().isNWTOS().booleanValue() && swMatch.getNwTos() != null) {
-            Short dscp = ActionUtil.tosToDscp(swMatch.getNwTos().shortValue());
-            ipMatchBuilder.setIpDscp(new Dscp(dscp));
-            matchBuilder.setIpMatch(ipMatchBuilder.build());
+            ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasMask);
+            matchEntryList.add(matchEntryBuilder.build());
         }
 
-        return matchBuilder;
-    }
-
-    /**
-     * Method converts Openflow 1.3+ specific flow match to MD-SAL format flow
-     * match
-     *
-     * @param swMatch source match
-     * @param datapathid datapath id
-     * @param ofVersion openflow version
-     * @return md-sal match instance
-     * @author avishnoi@in.ibm.com
-     */
-    public static MatchBuilder fromOFMatchToSALMatch(
-            @Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match swMatch,
-            @Nonnull final BigInteger datapathid, @Nonnull final OpenflowVersion ofVersion) {
-        return OfMatchToSALMatchConvertor(swMatch.getMatchEntry(), datapathid, ofVersion);
-    }
-
-    private static MatchBuilder OfMatchToSALMatchConvertor(final List<MatchEntry> swMatchList, final BigInteger datapathid,
-                                                           final OpenflowVersion ofVersion) {
-
-        MatchBuilder matchBuilder = new MatchBuilder();
-        EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
-        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
-        IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
-        TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
-        UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
-        SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
-        Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
-        Icmpv6MatchBuilder icmpv6MatchBuilder = new Icmpv6MatchBuilder();
-        Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
-        Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = new Ipv4MatchArbitraryBitMaskBuilder();
-        ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
-        Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
-        Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = new Ipv6MatchArbitraryBitMaskBuilder();
-        ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
-        TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
-
-        for (MatchEntry ofMatch : swMatchList) {
-
-            if (ofMatch.getOxmMatchField().equals(InPort.class)) {
-                PortNumber portNumber = ((InPortCase) ofMatch.getMatchEntryValue()).getInPort().getPortNumber();
-                if (portNumber != null) {
-                    matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid, portNumber.getValue(), ofVersion));
-                }
-            } else if (ofMatch.getOxmMatchField().equals(InPhyPort.class)) {
-                PortNumber portNumber = ((InPhyPortCase) ofMatch.getMatchEntryValue()).getInPhyPort().getPortNumber();
-                matchBuilder.setInPhyPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid,
-                        portNumber.getValue(), ofVersion));
-            } else if (ofMatch.getOxmMatchField().equals(Metadata.class)) {
-                MetadataBuilder metadataBuilder = new MetadataBuilder();
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata metadata = ((MetadataCase) ofMatch.getMatchEntryValue()).getMetadata();
-                if (metadata != null) {
-                    metadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, metadata.getMetadata()));
-                    byte[] metadataMask = metadata.getMask();
-                    if (metadataMask != null) {
-                        metadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, metadataMask));
-                    }
-                    matchBuilder.setMetadata(metadataBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(EthSrc.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrc ethSrcCase = ((EthSrcCase) ofMatch.getMatchEntryValue()).getEthSrc();
-                if (ethSrcCase != null) {
-                    EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
-                    ethSourceBuilder.setAddress(ethSrcCase.getMacAddress());
-                    byte[] mask = ethSrcCase.getMask();
-                    if (mask != null) {
-                        ethSourceBuilder.setMask(new MacAddress(macAddressToString(mask)));
-                    }
-                    ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
-                    matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(EthDst.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDst ethDstCase = ((EthDstCase) ofMatch.getMatchEntryValue()).getEthDst();
-                if (ethDstCase != null) {
-                    EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
-                    ethDestinationBuilder.setAddress(ethDstCase.getMacAddress());
-                    byte[] destinationMask = ethDstCase.getMask();
-                    if (destinationMask != null) {
-                        ethDestinationBuilder.setMask(new MacAddress(macAddressToString(destinationMask)));
-                    }
-                    ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
-                    matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(EthType.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthType ethTypeCase = ((EthTypeCase) ofMatch.getMatchEntryValue()).getEthType();
-                if (ethTypeCase != null) {
-                    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-                    ethTypeBuilder
-                            .setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType(
-                                    (long) ethTypeCase.getEthType().getValue()));
-                    ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
-                    matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(VlanVid.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVid vlanVid = ((VlanVidCase) ofMatch.getMatchEntryValue()).getVlanVid();
-                if (vlanVid != null) {
-                    VlanIdBuilder vlanBuilder = new VlanIdBuilder();
-                    vlanBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(
-                            vlanVid.getVlanVid()))
-                            .setVlanIdPresent(vlanVid.isCfiBit());
-                    vlanBuilder.setVlanIdPresent(vlanVid.isCfiBit());
-                    vlanMatchBuilder.setVlanId(vlanBuilder.build());
-
-                    matchBuilder.setVlanMatch(vlanMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(VlanPcp.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcp vlanPcp = ((VlanPcpCase) ofMatch.getMatchEntryValue()).getVlanPcp();
-                if (vlanPcp != null) {
-                    vlanMatchBuilder
-                            .setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(
-                                    vlanPcp.getVlanPcp()));
-                    matchBuilder.setVlanMatch(vlanMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(IpDscp.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscp ipDscp = ((IpDscpCase) ofMatch.getMatchEntryValue()).getIpDscp();
-                if (ipDscp != null) {
-                    ipMatchBuilder.setIpDscp(new Dscp(ipDscp.getDscp().getValue()));
-                    matchBuilder.setIpMatch(ipMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(IpEcn.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcn ipEcn = ((IpEcnCase) ofMatch.getMatchEntryValue()).getIpEcn();
-                if (ipEcn != null) {
-                    ipMatchBuilder.setIpEcn(ipEcn.getEcn());
-                    matchBuilder.setIpMatch(ipMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(IpProto.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProto ipProto = ((IpProtoCase) ofMatch.getMatchEntryValue()).getIpProto();
-                Short protocolNumber = ipProto.getProtocolNumber();
-                if (protocolNumber != null) {
-                    ipMatchBuilder.setIpProtocol(protocolNumber);
-                    matchBuilder.setIpMatch(ipMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(TcpSrc.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrc tcpSrc = ((TcpSrcCase) ofMatch.getMatchEntryValue()).getTcpSrc();
-                if (tcpSrc != null) {
-                    tcpMatchBuilder.setTcpSourcePort(tcpSrc.getPort());
-                    matchBuilder.setLayer4Match(tcpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(TcpDst.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDst tcpDst = ((TcpDstCase) ofMatch.getMatchEntryValue()).getTcpDst();
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber portNumber = tcpDst.getPort();
-                if (portNumber != null) {
-                    tcpMatchBuilder.setTcpDestinationPort(portNumber);
-                    matchBuilder.setLayer4Match(tcpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(UdpSrc.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrc udpSrc = ((UdpSrcCase) ofMatch.getMatchEntryValue()).getUdpSrc();
-                if (udpSrc != null) {
-                    udpMatchBuilder.setUdpSourcePort(udpSrc.getPort());
-                    matchBuilder.setLayer4Match(udpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(UdpDst.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDst udpDst = ((UdpDstCase) ofMatch.getMatchEntryValue()).getUdpDst();
-                if (udpDst != null) {
-                    udpMatchBuilder.setUdpDestinationPort(udpDst.getPort());
-                    matchBuilder.setLayer4Match(udpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(SctpSrc.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrc sctpSrc = ((SctpSrcCase) ofMatch.getMatchEntryValue()).getSctpSrc();
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber portNumber = sctpSrc.getPort();
-                if (portNumber != null) {
-                    sctpMatchBuilder.setSctpSourcePort(portNumber);
-                    matchBuilder.setLayer4Match(sctpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(SctpDst.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDst sctpDst = ((SctpDstCase) ofMatch.getMatchEntryValue()).getSctpDst();
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber portNumber = sctpDst.getPort();
-                if (portNumber != null) {
-                    sctpMatchBuilder.setSctpDestinationPort(portNumber);
-                    matchBuilder.setLayer4Match(sctpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Icmpv4Type.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4Type icmpv4Type = ((Icmpv4TypeCase) ofMatch.getMatchEntryValue()).getIcmpv4Type();
-                Short type = icmpv4Type.getIcmpv4Type();
-                if (type != null) {
-                    icmpv4MatchBuilder.setIcmpv4Type(type);
-                    matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Icmpv4Code.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4Code icmpv4Code = ((Icmpv4CodeCase) ofMatch.getMatchEntryValue()).getIcmpv4Code();
-                Short v4code = icmpv4Code.getIcmpv4Code();
-                if (v4code != null) {
-                    icmpv4MatchBuilder.setIcmpv4Code(v4code);
-                    matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Icmpv6Type.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6Type icmpv6Type = ((Icmpv6TypeCase) ofMatch.getMatchEntryValue()).getIcmpv6Type();
-                Short v6type = icmpv6Type.getIcmpv6Type();
-                if (v6type != null) {
-                    icmpv6MatchBuilder.setIcmpv6Type(v6type);
-                    matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Icmpv6Code.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6Code icmpv6Code = ((Icmpv6CodeCase) ofMatch.getMatchEntryValue()).getIcmpv6Code();
-                Short v6code = icmpv6Code.getIcmpv6Code();
-                if (v6code != null) {
-                    icmpv6MatchBuilder.setIcmpv6Code(v6code);
-                    matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv4Src.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4Src ipv4Address = ((Ipv4SrcCase) ofMatch.getMatchEntryValue()).getIpv4Src();
-                if (ipv4Address != null) {
-                    byte[] mask = ipv4Address.getMask();
-                    if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
-                        // case where ipv4dst is of type ipv4MatchBuilder and ipv4src is of type ipv4MatchArbitrary.
-                        // Needs to convert ipv4dst to ipv4MatchArbitrary.
-                        if (ipv4MatchBuilder.getIpv4Destination() != null) {
-                            Ipv4Prefix ipv4PrefixDestinationAddress = ipv4MatchBuilder.getIpv4Destination();
-                            Ipv4Address ipv4DstAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixDestinationAddress);
-                            DottedQuad dstDottedQuadMask = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixDestinationAddress);
-                            setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, ofMatch,
-                                    dstDottedQuadMask, ipv4DstAddress.getValue());
-                        }
-                        DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
-                        String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
-                        setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, ofMatch,
-                                srcDottedQuadMask, stringIpv4SrcAddress);
-                        matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
-                    } else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4DestinationAddressNoMask() != null) {
-                         /*
-                        Case where destination is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
-                        source which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
-                        We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
-                        expected output example:-
-                        <ipv4-destination>36.36.36.0/24</ipv4-destination>
-                        <ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
-                        <ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
-                        after conversion output example:-
-                        <ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
-                        <ipv4-destination-arbitrary-bitmask>255.255.255.0</ipv4-destination-arbitrary-bitmask>
-                        <ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
-                        <ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
-                        */
-                        DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
-                        String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
-                        setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, ofMatch,
-                                srcDottedQuadMask, stringIpv4SrcAddress);
-                        matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
-                    } else {
-                        String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
-                        setIpv4MatchBuilderFields(ipv4MatchBuilder, ofMatch, mask, stringIpv4SrcAddress);
-                        matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
-                    }
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv4Dst.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4Dst ipv4Address = ((Ipv4DstCase) ofMatch.getMatchEntryValue()).getIpv4Dst();
-                if (ipv4Address != null) {
-                    byte[] mask = ipv4Address.getMask();
-                    if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
-                        // case where ipv4src is of type ipv4MatchBuilder and ipv4dst is of type ipv4MatchArbitrary.
-                        // Needs to convert ipv4src to ipv4MatchArbitrary.
-                        if (ipv4MatchBuilder.getIpv4Source() != null) {
-                            Ipv4Prefix ipv4PrefixSourceAddress = ipv4MatchBuilder.getIpv4Source();
-                            Ipv4Address ipv4SourceAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixSourceAddress);
-                            DottedQuad srcDottedQuad = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixSourceAddress);
-                            setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder,ofMatch,
-                                    srcDottedQuad, ipv4SourceAddress.getValue());
-                        }
-                        DottedQuad dstDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
-                        String stringIpv4DstAddress = ipv4Address.getIpv4Address().getValue();
-                        setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, ofMatch,
-                                dstDottedQuadMask, stringIpv4DstAddress);
-                        matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
-                    } else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4SourceAddressNoMask() != null) {
-                        /*
-                        Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
-                        destination which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
-                        We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
-                        expected output example:-
-                        <ipv4-source>36.36.36.0/24</ipv4-source>
-                        <ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
-                        <ipv4-destination-arbitrary-bitmask>255.0.255.0</ipv4-destination-arbitrary-bitmask>
-                        after conversion output example:-
-                        <ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
-                        <ipv4-source-arbitrary-bitmask>255.255.255.0</ipv4-source-arbitrary-bitmask>
-                        <ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
-                        <ipv4-destination-arbitrary-bitmask>255.0.255.0</ipv4-destination-arbitrary-bitmask>
-                        */
-                        DottedQuad dstDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
-                        String stringIpv4DstAddress = ipv4Address.getIpv4Address().getValue();
-                        setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, ofMatch,
-                                dstDottedQuadMask, stringIpv4DstAddress);
-                        matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
-                    }
-                    else {
-                        String ipv4PrefixStr = ipv4Address.getIpv4Address().getValue();
-                        setIpv4MatchBuilderFields(ipv4MatchBuilder, ofMatch, mask, ipv4PrefixStr);
-                        matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
-                    }
-                }
-            } else if (ofMatch.getOxmMatchField().equals(TunnelIpv4Dst.class)
-                    || ofMatch.getOxmMatchField().equals(TunnelIpv4Src.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4Dst tunnelIpv4Dst = ((Ipv4DstCase) ofMatch.getMatchEntryValue()).getIpv4Dst();
-                if (tunnelIpv4Dst != null) {
-                    String ipv4PrefixStr = tunnelIpv4Dst.getIpv4Address().getValue();
-                    byte[] mask = tunnelIpv4Dst.getMask();
-                    ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + ByteBuffer.wrap(tunnelIpv4Dst.getMask()).getInt();
-                    setIpv4MatchBuilderFields(ipv4MatchBuilder, ofMatch, mask, ipv4PrefixStr);
-                    matchBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(TunnelIpv4Src.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4Src tunnelIpv4Dst = ((Ipv4SrcCase) ofMatch.getMatchEntryValue()).getIpv4Src();
-                if (tunnelIpv4Dst != null) {
-                    String ipv4PrefixStr = tunnelIpv4Dst.getIpv4Address().getValue();
-                    byte[] mask = tunnelIpv4Dst.getMask();
-                    ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + ByteBuffer.wrap(tunnelIpv4Dst.getMask()).getInt();
-                    setIpv4MatchBuilderFields(ipv4MatchBuilder, ofMatch, mask, ipv4PrefixStr);
-                    matchBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(ArpOp.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOp arpOp = ((ArpOpCase) ofMatch.getMatchEntryValue()).getArpOp();
-                if (arpOp != null) {
-                    arpMatchBuilder.setArpOp(arpOp.getOpCode());
-
-                    matchBuilder.setLayer3Match(arpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(ArpSpa.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpa arpSpa = ((ArpSpaCase) ofMatch.getMatchEntryValue()).getArpSpa();
-                if (arpSpa != null) {
-                    int mask = 32;
-                    if (null != arpSpa.getMask()){
-                        mask = IpConversionUtil.countBits(arpSpa.getMask());
-                    }
-                    Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpSpa.getIpv4Address(), mask);
-                    arpMatchBuilder.setArpSourceTransportAddress(ipv4Prefix);
-                    matchBuilder.setLayer3Match(arpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(ArpTpa.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpa arpTpa = ((ArpTpaCase) ofMatch.getMatchEntryValue()).getArpTpa();
-                if (arpTpa != null) {
-                    int mask = 32;
-                    if (null != arpTpa.getMask()){
-                        mask = IpConversionUtil.countBits(arpTpa.getMask());
-                    }
-                    Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpTpa.getIpv4Address(), mask);
-
-                    arpMatchBuilder.setArpTargetTransportAddress(ipv4Prefix);
-                    matchBuilder.setLayer3Match(arpMatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(ArpSha.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpSha arpSha = ((ArpShaCase) ofMatch.getMatchEntryValue()).getArpSha();
-                MacAddress macAddress = arpSha.getMacAddress();
-                if (macAddress != null) {
-                    if (ofMatch.getOxmMatchField().equals(ArpSha.class)) {
-                        ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
-                        arpSourceHardwareAddressBuilder.setAddress(macAddress);
-                        byte[] mask = arpSha.getMask();
-                        if (mask != null) {
-                            arpSourceHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils
-                                    .macAddressToString(mask)));
-                        }
-                        arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
-                        matchBuilder.setLayer3Match(arpMatchBuilder.build());
-                    }
-                }
-            } else if (ofMatch.getOxmMatchField().equals(ArpTha.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpTha arpTha = ((ArpThaCase) ofMatch.getMatchEntryValue()).getArpTha();
-                MacAddress macAddress = arpTha.getMacAddress();
-                if (macAddress != null) {
-                    if (ofMatch.getOxmMatchField().equals(ArpTha.class)) {
-                        ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
-                        arpTargetHardwareAddressBuilder.setAddress(macAddress);
-                        byte[] mask = arpTha.getMask();
-                        if (mask != null) {
-                            arpTargetHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils
-                                    .macAddressToString(mask)));
-                        }
-                        arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
-                        matchBuilder.setLayer3Match(arpMatchBuilder.build());
-                    }
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6Src.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6Src ipv6Address = ((Ipv6SrcCase) ofMatch.getMatchEntryValue()).getIpv6Src();
-                if (ipv6Address != null) {
-                    byte[] mask = ipv6Address.getMask();
-                    if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
-                        // case where ipv6dst is of type ipv6MatchBuilder and ipv6src is of type ipv6MatchArbitrary.
-                        // Need to convert ipv6dst to ipv6MatchArbitrary.
-
-                        if (ipv6MatchBuilder.getIpv6Destination() != null) {
-                            Ipv6Prefix ipv6PrefixDestinationAddress = ipv6MatchBuilder.getIpv6Destination();
-                            Ipv6Address ipv6DstAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixDestinationAddress);
-                            Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
-                                    IpConversionUtil.extractIpv6AddressMask(ipv6PrefixDestinationAddress));
-                            setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, ofMatch,
-                                    dstIpv6ArbitraryMask, IpConversionUtil.compressedIpv6Format(ipv6DstAddress.getValue()));
-                        }
-                        Ipv6ArbitraryMask srcIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
-                                IpConversionUtil.createIpv6ArbitraryBitMask(mask));
-                        String stringIpv6SrcAddress = IpConversionUtil.compressedIpv6Format(ipv6Address.getIpv6Address().getValue());
-                        setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, ofMatch,
-                                srcIpv6ArbitraryMask, stringIpv6SrcAddress);
-                        matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
-                    } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6DestinationAddressNoMask() != null) {
-                         /*
-                         TODO Change comments
-                        Case where destination is of type ipv6MatchArbitraryBitMask already exists in Layer3Match,
-                        source which of type ipv6Match needs to be converted to ipv4MatchArbitraryBitMask.
-                        We convert 1::/32 to 1::/FFFF:FFFF::
-                        example:-
-                        <ipv6-source>1::/32</ipv4-source>
-                        <ipv6-destination-address-no-mask>1::1</ipv6-destination-address-no-mask>
-                        <ipv6-destination-arbitrary-bitmask>FFFF::0001</ipv6-destination-arbitrary-bitmask>
-                        after conversion output example:-
-                        <ipv6-source-address-no-mask>1::</ipv6-source-address-no-mask>
-                        <ipv6-source-arbitrary-bitmask>FFFF:FFFF::</ipv6-source-arbitrary-bitmask>
-                        <ipv6-destination-address-no-mask>1::1</ipv6-destination-address-no-mask>
-                        <ipv6-destination-arbitrary-bitmask>FFFF::0001</ipv6-destination-arbitrary-bitmask>
-                        */
-                        Ipv6ArbitraryMask srcIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
-                                IpConversionUtil.createIpv6ArbitraryBitMask(mask));
-                        String stringIpv6SrcAddress = IpConversionUtil.compressedIpv6Format(ipv6Address.getIpv6Address().getValue());
-                        setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, ofMatch,
-                                srcIpv6ArbitraryMask, stringIpv6SrcAddress);
-                        matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
-                    } else {
-                        String stringIpv6SrcAddress = IpConversionUtil.compressedIpv6Format(ipv6Address.getIpv6Address().getValue());
-                        setIpv6MatchBuilderFields(ipv6MatchBuilder, ofMatch, mask, stringIpv6SrcAddress);
-                        matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                    }
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6Dst.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6Dst ipv6Address = ((Ipv6DstCase) ofMatch.getMatchEntryValue()).getIpv6Dst();
-                if (ipv6Address != null) {
-                    byte[] mask = ipv6Address.getMask();
-                    if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
-                        // case where ipv6src is of type ipv6MatchBuilder and ipv6dst is of type ipv6MatchArbitrary.
-                        // Need to convert ipv6src to ipv6MatchArbitrary.
-
-                        if (ipv6MatchBuilder.getIpv6Source() != null) {
-                            Ipv6Prefix ipv6PrefixSourceAddress = ipv6MatchBuilder.getIpv6Source();
-                            Ipv6Address ipv6SrcAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixSourceAddress);
-                            Ipv6ArbitraryMask srcIpv6Arbitrary = IpConversionUtil.compressedIpv6MaskFormat(
-                                    IpConversionUtil.extractIpv6AddressMask(ipv6PrefixSourceAddress));
-                            setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, ofMatch,
-                                    srcIpv6Arbitrary, IpConversionUtil.compressedIpv6Format(ipv6SrcAddress.getValue()));
-                        }
-                        Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
-                                IpConversionUtil.createIpv6ArbitraryBitMask(mask));
-                        String stringIpv6DstAddress = IpConversionUtil.compressedIpv6Format(ipv6Address.getIpv6Address().getValue());
-                        setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, ofMatch,
-                                dstIpv6ArbitraryMask, stringIpv6DstAddress);
-                        matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
-                    } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6SourceAddressNoMask() != null) {
-                         /*
-                         TODO Change comments
-                        Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
-                        source which of type ipv6Match needs to be converted to ipv6MatchArbitraryBitMask.
-                        We convert 1::/32 to 1::/FFFF:FFFF::
-                        example:-
-                        <ipv6-destination>1::/32</ipv6-destination>
-                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
-                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
-                        after conversion output example:-
-                        <ipv6-destination-address-no-mask>1::</ipv6-destination-address-no-mask>
-                        <ipv6-destination-arbitrary-bitmask>FFFF:FFFF::</ipv6-destination-arbitrary-bitmask>
-                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
-                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
-                        */
-                        Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
-                                IpConversionUtil.createIpv6ArbitraryBitMask(mask));
-                        String stringIpv6DstAddress = IpConversionUtil.compressedIpv6Format(ipv6Address.getIpv6Address().getValue());
-                        setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, ofMatch,
-                                dstIpv6ArbitraryMask, stringIpv6DstAddress);
-                        matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
-                    } else {
-                        String stringIpv6DstAddress = IpConversionUtil.compressedIpv6Format(ipv6Address.getIpv6Address().getValue());
-                        setIpv6MatchBuilderFields(ipv6MatchBuilder, ofMatch, mask, stringIpv6DstAddress);
-                        matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                    }
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6Flabel.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel ipv6Flabel = ((Ipv6FlabelCase) ofMatch.getMatchEntryValue()).getIpv6Flabel();
-                if (ipv6Flabel != null) {
-                    Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
-                    ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(ipv6Flabel.getIpv6Flabel()));
-                    byte[] mask = ipv6Flabel.getMask();
-                    if (mask != null) {
-                        ipv6LabelBuilder.setFlabelMask(new Ipv6FlowLabel(Long.valueOf(ByteUtil
-                                .bytesToUnsignedInt(mask))));
-                    }
-                    ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
-                    matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6NdTarget.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTarget ipv6NdTarget = ((Ipv6NdTargetCase) ofMatch.getMatchEntryValue()).getIpv6NdTarget();
-                if (ipv6NdTarget != null) {
-                    ipv6MatchBuilder.setIpv6NdTarget(ipv6NdTarget.getIpv6Address());
-                    matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6NdSll.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSll ipv6NdSll = ((Ipv6NdSllCase) ofMatch.getMatchEntryValue()).getIpv6NdSll();
-                if (ipv6NdSll != null) {
-                    ipv6MatchBuilder.setIpv6NdSll(ipv6NdSll.getMacAddress());
-                    matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6NdTll.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTll ipv6NdTll = ((Ipv6NdTllCase) ofMatch.getMatchEntryValue()).getIpv6NdTll();
-                if (ipv6NdTll != null) {
-                    ipv6MatchBuilder.setIpv6NdTll(ipv6NdTll.getMacAddress());
-                    matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(Ipv6Exthdr.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6Exthdr ipv6Exthdr = ((Ipv6ExthdrCase) ofMatch.getMatchEntryValue()).getIpv6Exthdr();
-                if (ipv6Exthdr != null) {
-                    Ipv6ExtHeaderBuilder ipv6ExtHeaderBuilder = new Ipv6ExtHeaderBuilder();
-
-                    Ipv6ExthdrFlags pField = ipv6Exthdr.getPseudoField();
-                    Integer bitmap = MatchConvertorUtil.ipv6ExthdrFlagsToInt(pField);
-
-                    ipv6ExtHeaderBuilder.setIpv6Exthdr(bitmap);
-                    byte[] mask = ipv6Exthdr.getMask();
-                    if (mask != null) {
-                        ipv6ExtHeaderBuilder.setIpv6ExthdrMask(ByteUtil.bytesToUnsignedShort(mask));
-                    }
-                    ipv6MatchBuilder.setIpv6ExtHeader(ipv6ExtHeaderBuilder.build());
-                    matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(MplsLabel.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabel mplsLabel = ((MplsLabelCase) ofMatch.getMatchEntryValue()).getMplsLabel();
-                if (mplsLabel != null) {
-                    protocolMatchFieldsBuilder.setMplsLabel(mplsLabel.getMplsLabel());
-                    matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(MplsBos.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos mplsBos = ((MplsBosCase) ofMatch.getMatchEntryValue()).getMplsBos();
-                if (mplsBos != null) {
-                    protocolMatchFieldsBuilder.setMplsBos(mplsBos.isBos() ? (short) 1 : (short) 0);
-                    matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(MplsTc.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTc mplsTc = ((MplsTcCase) ofMatch.getMatchEntryValue()).getMplsTc();
-                if (mplsTc != null) {
-                    protocolMatchFieldsBuilder.setMplsTc(mplsTc.getTc());
-                    matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(PbbIsid.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsid pbbIsid = ((PbbIsidCase) ofMatch.getMatchEntryValue()).getPbbIsid();
-                if (pbbIsid != null) {
-                    PbbBuilder pbbBuilder = new PbbBuilder();
-                    pbbBuilder.setPbbIsid(pbbIsid.getIsid());
-                    byte[] mask = pbbIsid.getMask();
-                    if (mask != null) {
-                        pbbBuilder.setPbbMask(ByteUtil.bytesToUnsignedMedium(mask));
-                    }
-                    protocolMatchFieldsBuilder.setPbb(pbbBuilder.build());
-                    matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
-                }
-            } else if (ofMatch.getOxmMatchField().equals(TunnelId.class)) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelId tunnelId = ((TunnelIdCase) ofMatch.getMatchEntryValue()).getTunnelId();
-                TunnelBuilder tunnelBuilder = new TunnelBuilder();
-                if (tunnelId.getTunnelId()!= null) {
-                    tunnelBuilder.setTunnelId(new BigInteger(OFConstants.SIGNUM_UNSIGNED, tunnelId.getTunnelId()));
-                    byte[] mask = tunnelId.getMask();
-                    if (null != mask) {
-                        tunnelBuilder.setTunnelMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, mask));
-                    }
-                    matchBuilder.setTunnel(tunnelBuilder.build());
-                }
+        EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
+        if (ethernetSource != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(EthSrc.class);
+            EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
+            EthSrcBuilder ethDstBuilder = new EthSrcBuilder();
+            ethDstBuilder.setMacAddress(ethernetSource.getAddress());
+            boolean hasMask = ethernetSource.getMask() != null;
+
+            if (hasMask) {
+                ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetSource.getMask().getValue()));
             }
-        }
-        return matchBuilder;
-    }
 
-    private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder ipv6MatchBuilder, final MatchEntry ofMatch, final byte[] mask, final String ipv6PrefixStr) {
-        Ipv6Prefix ipv6Prefix;
-
-        if (mask != null) {
-            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr), mask);
-        } else {
-            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr));
+            ethSrcCaseBuilder.setEthSrc(ethDstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasMask);
+            matchEntryList.add(matchEntryBuilder.build());
         }
 
-        if (ofMatch.getOxmMatchField().equals(Ipv6Src.class)) {
-            ipv6MatchBuilder.setIpv6Source(ipv6Prefix);
-        }
-        if (ofMatch.getOxmMatchField().equals(Ipv6Dst.class)) {
-            ipv6MatchBuilder.setIpv6Destination(ipv6Prefix);
+        if (ethernetMatch.getEthernetType() != null) {
+            matchEntryList.add(toOfEthernetType(ethernetMatch.getEthernetType()));
         }
     }
 
-    private static void setIpv4MatchBuilderFields(final Ipv4MatchBuilder ipv4MatchBuilder, final MatchEntry ofMatch, final byte[] mask, final String ipv4PrefixStr) {
-        final Ipv4Prefix ipv4Prefix;
-        if (mask != null) {
-            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
-        } else {
-            //Openflow Spec : 1.3.2
-            //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
-            // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
-            // statistics response.
-            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
-        }
-        if (ofMatch.getOxmMatchField().equals(Ipv4Src.class)) {
-            ipv4MatchBuilder.setIpv4Source(ipv4Prefix);
-        }
-        if (ofMatch.getOxmMatchField().equals(Ipv4Dst.class)) {
-            ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
-        }
-    }
-
-    private static void setSrcIpv4MatchArbitraryBitMaskBuilderFields(
-            final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder,
-            final MatchEntry ofMatch, final DottedQuad mask, final String ipv4AddressStr) {
-        Ipv4Address ipv4Address;
-        if (mask != null) {
-            ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceArbitraryBitmask(mask);
-        }
-        ipv4Address = new Ipv4Address(ipv4AddressStr);
-        ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(ipv4Address);
-    }
+    private static void tcpFlagsMatch(List<MatchEntry> matchEntryList, TcpFlagsMatch tcpFlagsMatch) {
+        ExperimenterIdCaseBuilder expIdCaseBuilder = new ExperimenterIdCaseBuilder();
+        if (tcpFlagsMatch != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(ExperimenterClass.class);
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setOxmMatchField(TcpFlags.class);
+
+            TcpFlagsContainerBuilder tcpFlagsContainerBuilder = new TcpFlagsContainerBuilder();
+            TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder();
+            tcpFlagsBuilder.setFlags(tcpFlagsMatch.getTcpFlags());
+            if(tcpFlagsMatch.getTcpFlagsMask() != null) {
+                matchEntryBuilder.setHasMask(true);
+                tcpFlagsBuilder.setMask(ByteUtil.unsignedShortToBytes(tcpFlagsMatch.getTcpFlagsMask()));
+            }
+            tcpFlagsContainerBuilder.setTcpFlags(tcpFlagsBuilder.build());
 
-    private static void setDstIpv4MatchArbitraryBitMaskBuilderFields(
-            final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder,
-            final MatchEntry ofMatch, final DottedQuad mask, final String ipv4AddressStr) {
-        Ipv4Address ipv4Address;
-        if (mask != null) {
-            ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(mask);
-        }
-        ipv4Address = new Ipv4Address(ipv4AddressStr);
-        ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(ipv4Address);
-    }
+            //Set experimenter ID.
+            ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
+            experimenterBuilder.setExperimenter(new ExperimenterId(OFApprovedExperimenterIds.MATCH_TCP_FLAGS_EXP_ID));
+            expIdCaseBuilder.setExperimenter(experimenterBuilder.build());
 
-    private static void setSrcIpv6MatchArbitraryBitMaskBuilderFields(
-            final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder,
-            final MatchEntry ofMatch, final Ipv6ArbitraryMask mask, final String ipv6AddressStr) {
-        Ipv6Address ipv6Address;
-        if (mask != null) {
-            ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceArbitraryBitmask(mask);
-        }
-        ipv6Address = new Ipv6Address(ipv6AddressStr);
-        ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceAddressNoMask(ipv6Address);
-    }
-
-    private static void setDstIpv6MatchArbitraryBitMaskBuilderFields(
-            final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder,
-            final MatchEntry ofMatch, final Ipv6ArbitraryMask mask, final String ipv6AddressStr) {
-        Ipv6Address ipv6Address;
-        if (mask != null) {
-            ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationArbitraryBitmask(mask);
+            expIdCaseBuilder.addAugmentation(TcpFlagsContainer.class, tcpFlagsContainerBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(expIdCaseBuilder.build());
+            matchEntryList.add(matchEntryBuilder.build());
         }
-        ipv6Address = new Ipv6Address(ipv6AddressStr);
-        ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationAddressNoMask(ipv6Address);
     }
 
     private static MatchEntry toOfMplsPbb(final Pbb pbb) {
         MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        boolean hasmask = false;
+        boolean hasmask = pbb.getPbbMask() != null;
         matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntryBuilder.setOxmMatchField(PbbIsid.class);
         PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
         PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
         pbbIsidBuilder.setIsid(pbb.getPbbIsid());
-        if (pbb.getPbbMask() != null) {
-            hasmask = true;
+
+        if (hasmask) {
             pbbIsidBuilder.setMask(ByteUtil.unsignedMediumToBytes(pbb.getPbbMask()));
         }
+
         pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
         matchEntryBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
         matchEntryBuilder.setHasMask(hasmask);
@@ -1858,13 +468,8 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
         matchEntryBuilder.setOxmMatchField(MplsBos.class);
         MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();
         MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();
-        boolean isBos = false;
-        if (mplsBos.shortValue() != 0) {
-            isBos = true;
-        }
-        mplsBosBuilder.setBos(isBos);
+        mplsBosBuilder.setBos(mplsBos != 0);
         mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());
-
         matchEntryBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());
         return matchEntryBuilder.build();
     }
@@ -1874,7 +479,6 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
         matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntryBuilder.setHasMask(false);
         matchEntryBuilder.setOxmMatchField(MplsLabel.class);
-
         MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();
         MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();
         mplsLabelBuilder.setMplsLabel(mplsLabel);
@@ -1883,102 +487,6 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
         return matchEntryBuilder.build();
     }
 
-    private static MatchEntry toOfIpv6ExtHeader(final Ipv6ExtHeader ipv6ExtHeader) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        boolean hasmask = false;
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setOxmMatchField(Ipv6Exthdr.class);
-        Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
-        Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
-
-        Integer bitmap = ipv6ExtHeader.getIpv6Exthdr();
-        final Boolean NONEXT = ((bitmap) & (1 << 0)) != 0;
-        final Boolean ESP = ((bitmap) & (1 << 1)) != 0;
-        final Boolean AUTH = ((bitmap) & (1 << 2)) != 0;
-        final Boolean DEST = ((bitmap) & (1 << 3)) != 0;
-        final Boolean FRAG = ((bitmap) & (1 << 4)) != 0;
-        final Boolean ROUTER = ((bitmap) & (1 << 5)) != 0;
-        final Boolean HOP = ((bitmap) & (1 << 6)) != 0;
-        final Boolean UNREP = ((bitmap) & (1 << 7)) != 0;
-        final Boolean UNSEQ = ((bitmap) & (1 << 8)) != 0;
-
-        ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));
-        //TODO ipv6ExthdrBuilder.setMask()
-        if (ipv6ExtHeader.getIpv6ExthdrMask() != null) {
-            hasmask = true;
-            ipv6ExthdrBuilder.setMask(ByteUtil.unsignedShortToBytes(ipv6ExtHeader.getIpv6ExthdrMask()));
-        }
-        ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
-        matchEntryBuilder.setHasMask(hasmask);
-        return matchEntryBuilder.build();
-    }
-
-    private static MatchEntry toOfIpv6FlowLabel(final Ipv6Label ipv6Label) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        boolean hasmask = false;
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setOxmMatchField(Ipv6Flabel.class);
-        Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
-        Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
-        ipv6FlabelBuilder.setIpv6Flabel(ipv6Label.getIpv6Flabel());
-        if (ipv6Label.getFlabelMask() != null) {
-            hasmask = true;
-            ipv6FlabelBuilder.setMask(ByteUtil.unsignedIntToBytes(ipv6Label.getFlabelMask().getValue()));
-        }
-        ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
-        matchEntryBuilder.setHasMask(hasmask);
-        return matchEntryBuilder.build();
-    }
-
-    private static MatchEntry toOfPort(final Class<? extends MatchField> field, final Long portNumber) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setHasMask(false);
-        matchEntryBuilder.setOxmMatchField(field);
-        InPortCaseBuilder caseBuilder = new InPortCaseBuilder();
-        InPortBuilder portBuilder = new InPortBuilder();
-        portBuilder.setPortNumber(new PortNumber(portNumber));
-        caseBuilder.setInPort(portBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-
-        return matchEntryBuilder.build();
-    }
-
-    private static MatchEntry toOfPhyPort(final Class<? extends MatchField> field, final Long portNumber) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setHasMask(false);
-        matchEntryBuilder.setOxmMatchField(field);
-        InPhyPortCaseBuilder caseBuilder = new InPhyPortCaseBuilder();
-        InPhyPortBuilder portBuilder = new InPhyPortBuilder();
-        portBuilder.setPortNumber(new PortNumber(portNumber));
-        caseBuilder.setInPhyPort(portBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
-
-        return matchEntryBuilder.build();
-    }
-
-    private static MatchEntry toOfMetadata(final Class<? extends MatchField> field, final BigInteger metadata,
-                                           final BigInteger metadataMask) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        boolean hasmask = false;
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setOxmMatchField(field);
-        MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();
-        metadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(metadata, OFConstants.SIZE_OF_LONG_IN_BYTES));
-        if (metadataMask != null) {
-            hasmask = true;
-            metadataBuilder.setMask(ByteUtil.convertBigIntegerToNBytes(metadataMask, OFConstants.SIZE_OF_LONG_IN_BYTES));
-        }
-        metadataCaseBuilder.setMetadata(metadataBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(metadataCaseBuilder.build());
-        matchEntryBuilder.setHasMask(hasmask);
-        return matchEntryBuilder.build();
-    }
-
     private static MatchEntry toOfEthernetType(final EthernetType ethernetType) {
         MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
         matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -2045,35 +553,6 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
         return matchEntryBuilder.build();
     }
 
-    public static MatchEntry toOfIpDscp(final Dscp ipDscp) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setHasMask(false);
-        matchEntryBuilder.setOxmMatchField(IpDscp.class);
-
-        IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();
-        IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();
-        ipDscpBuilder.setDscp(ipDscp);
-        ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-    public static MatchEntry toOfVlanPcp(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp vlanPcp) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setHasMask(false);
-        matchEntryBuilder.setOxmMatchField(VlanPcp.class);
-        VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();
-        VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();
-        vlanPcpBuilder.setVlanPcp(vlanPcp.getValue());
-        vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-
     private static MatchEntry toOfIpProto(final Short ipProtocol) {
         MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
         matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -2100,53 +579,44 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
         return matchEntryBuilder.build();
     }
 
-    private static MatchEntry toOfArpOpCode(final Integer arpOp) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setHasMask(false);
-        matchEntryBuilder.setOxmMatchField(ArpOp.class);
-        ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
-        ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
-        arpOpBuilder.setOpCode(arpOp);
-        arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-    private static MatchEntry toOfIpv6NdTargetAddress(final Ipv6Address address) {
-        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
-        matchEntryBuilder.setHasMask(false);
-        matchEntryBuilder.setOxmMatchField(Ipv6NdTarget.class);
-
-        Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
-        Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
-        ipv6NdTargetBuilder.setIpv6Address(address);
-        ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
-        matchEntryBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
-        return matchEntryBuilder.build();
-    }
-
-
+    @Override
+    public List<MatchEntry> convert(final Match match, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
 
+        if (match == null) {
+            return result;
+        }
+
+        inPortMatch(result, match.getInPort());
+        inPhyPortMatch(result, match.getInPhyPort());
+        metadataMatch(result, match.getMetadata());
+        ethernetMatch(result, match.getEthernetMatch());
+        vlanMatch(result, match.getVlanMatch());
+        ipMatch(result, match.getIpMatch());
+        layer4Match(result, match.getLayer4Match(), convertorExecutor);
+        icmpv4Match(result, match.getIcmpv4Match());
+        icmpv6Match(result, match.getIcmpv6Match());
+        layer3Match(result, match.getLayer3Match(), convertorExecutor);
+        protocolMatchFields(result, match.getProtocolMatchFields());
+        tunnelMatch(result, match.getTunnel());
+        tcpFlagsMatch(result, match.getTcpFlagsMatch());
 
-    /**
-     * Method converts OF SetField action to SAL SetFiled action.
-     *
-     * @param action input action
-     * @param ofVersion current ofp version
-     * @return set field builder
-     */
-    public static SetField fromOFSetFieldToSALSetFieldAction(
-            final Action action, final OpenflowVersion ofVersion) {
-        logger.debug("Converting OF SetField action to SAL SetField action");
-        SetFieldCase setFieldCase = (SetFieldCase) action.getActionChoice();
-        SetFieldAction setFieldAction = setFieldCase.getSetFieldAction();
+        /**
+         * TODO: EXTENSION PROPOSAL (match, MD-SAL to OFJava)
+         * - we might need version for conversion and for key
+         * - sanitize NPE
+         */
+        Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(match);
+        if (extensionListOpt.isPresent()) {
+            for (ExtensionList extensionItem : extensionListOpt.get().getExtensionList()) {
+                // TODO: get real version
+                ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
+                ConvertorToOFJava<MatchEntry> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+                MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
+                result.add(ofMatch);
+            }
+        }
 
-        SetFieldBuilder setField = new SetFieldBuilder();
-        MatchBuilder match = OfMatchToSALMatchConvertor(setFieldAction.getMatchEntry(), null, ofVersion);
-        setField.fieldsFrom(match.build());
-        return setField.build();
+        return result;
     }
-
 }
index cc95a7bc2595df7cf7020387209fcec452023d16..df2ff96270ae4dbabb22899db9a08e5d65a13d6a 100644 (file)
@@ -1,28 +1,53 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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.openflow.md.core.sal.convertor.match;
 
+import java.util.Iterator;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder;
 
 /**
  * match related tools
  */
 public abstract class MatchConvertorUtil {
+    // Pre-calculated masks for the 33 possible values. Do not give them out, but clone() them as they may
+    // end up being leaked and vulnerable.
+    private static final byte[][] IPV4_MASKS;
 
-    private static final String PREFIX_SEPARATOR = "/";
+    static {
+        final byte[][] tmp = new byte[33][];
+        for (int i = 0; i <= 32; ++i) {
+            final int mask = 0xffffffff << (32 - i);
+            tmp[i] = new byte[]{(byte) (mask >>> 24), (byte) (mask >>> 16), (byte) (mask >>> 8), (byte) mask};
+        }
+
+        IPV4_MASKS = tmp;
+    }
 
     /**
+     * Ipv 6 exthdr flags to int integer.
+     *
      * @param pField ipv6 external header flag
      * @return integer containing lower 9 bits filled with corresponding flags
      */
     public static Integer ipv6ExthdrFlagsToInt(final Ipv6ExthdrFlags pField) {
         Integer bitmap = 0;
-        bitmap |= pField.isNonext() ? (1 << 0) : 0;
+        bitmap |= pField.isNonext() ? 1 : 0;
         bitmap |= pField.isEsp() ? (1 << 1) : 0;
         bitmap |= pField.isAuth() ? (1 << 2) : 0;
         bitmap |= pField.isDest() ? (1 << 3) : 0;
@@ -34,4 +59,66 @@ public abstract class MatchConvertorUtil {
         return bitmap;
     }
 
+    /**
+     * Extract ipv 4 mask byte [ ].
+     *
+     * @param addressParts the address parts
+     * @return the byte [ ]
+     */
+    public static byte[] extractIpv4Mask(final Iterator<String> addressParts) {
+        final int prefix;
+        if (addressParts.hasNext()) {
+            int potentionalPrefix = Integer.parseInt(addressParts.next());
+            prefix = potentionalPrefix < 32 ? potentionalPrefix : 0;
+        } else {
+            prefix = 0;
+        }
+
+        if (prefix != 0) {
+            // clone() is necessary to protect our constants
+            return IPV4_MASKS[prefix].clone();
+        }
+
+        return null;
+    }
+
+    /**
+     * To of ip dscp match entry.
+     *
+     * @param ipDscp the ip dscp
+     * @return the match entry
+     */
+    public static MatchEntry toOfIpDscp(final Dscp ipDscp) {
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchEntryBuilder.setHasMask(false);
+        matchEntryBuilder.setOxmMatchField(IpDscp.class);
+
+        IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();
+        IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();
+        ipDscpBuilder.setDscp(ipDscp);
+        ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());
+        return matchEntryBuilder.build();
+    }
+
+    /**
+     * To of vlan pcp match entry.
+     *
+     * @param vlanPcp the vlan pcp
+     * @return the match entry
+     */
+    public static MatchEntry toOfVlanPcp(
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp vlanPcp) {
+        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+        matchEntryBuilder.setHasMask(false);
+        matchEntryBuilder.setOxmMatchField(VlanPcp.class);
+        VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();
+        VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();
+        vlanPcpBuilder.setVlanPcp(vlanPcp.getValue());
+        vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());
+        return matchEntryBuilder.build();
+    }
 }
index 43a46c4121ae661de341f7979376169cee88fae9..2046508949793127fd7b0dd826a60ec28bffaa1b 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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,
@@ -8,13 +8,12 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
-import java.math.BigInteger;
 import java.util.Iterator;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
@@ -33,14 +32,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
 
 /**
- *
+ * The type Match convertor v 10.
  */
 public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
 
-    /** default MAC */
-    public static final MacAddress zeroMac = new MacAddress("00:00:00:00:00:00");
-    /** default IPv4 */
-    public static final Ipv4Address zeroIPv4 = new Ipv4Address("0.0.0.0");
+    /**
+     * default MAC
+     */
+    private static final MacAddress zeroMac = new MacAddress("00:00:00:00:00:00");
+    /**
+     * default IPv4
+     */
+    private static final Ipv4Address zeroIPv4 = new Ipv4Address("0.0.0.0");
 
     /*
      * The value 0xffff (OFP_VLAN_NONE) is used to indicate
@@ -48,113 +51,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
      */
     private static final Integer OFP_VLAN_NONE = 0xffff;
 
-    /**
-     * Method builds openflow 1.0 specific match (MatchV10) from MD-SAL match.
-     * @param match MD-SAL match
-     * @return OF-API match
-     * @author avishnoi@in.ibm.com
-     */
-    @Override
-    public MatchV10 convert(final Match match,final BigInteger datapathid) {
-        MatchV10Builder matchBuilder = new MatchV10Builder();
-        boolean _dLDST = true;
-        boolean _dLSRC = true;
-        boolean _dLTYPE = true;
-        boolean _dLVLAN = true;
-        boolean _dLVLANPCP = true;
-        boolean _iNPORT = true;
-        boolean _nWPROTO = true;
-        boolean _nWTOS = true;
-        boolean _tPDST = true;
-        boolean _tPSRC = true;
-
-        matchBuilder.setInPort(0);
-        matchBuilder.setDlDst(zeroMac);
-        matchBuilder.setDlSrc(zeroMac);
-        matchBuilder.setDlType(0);
-        matchBuilder.setDlVlan(OFP_VLAN_NONE);
-        matchBuilder.setDlVlanPcp((short) 0);
-        matchBuilder.setNwDst(zeroIPv4);
-        matchBuilder.setNwDstMask((short) 0);
-        matchBuilder.setNwSrc(zeroIPv4);
-        matchBuilder.setNwSrcMask((short) 0);
-        matchBuilder.setNwProto((short) 0);
-        matchBuilder.setNwTos((short) 0);
-        matchBuilder.setTpSrc(0);
-        matchBuilder.setTpDst(0);
-
-        if (match != null) {
-            EthernetMatch ethernetMatch = match.getEthernetMatch();
-            if(ethernetMatch!= null){
-                _dLDST = convertEthernetDlDst(matchBuilder, ethernetMatch);
-                _dLSRC = convertEthernetDlSrc(matchBuilder, ethernetMatch);
-                _dLTYPE = convertEthernetDlType(matchBuilder, ethernetMatch);
-            }
-            VlanMatch vlanMatch = match.getVlanMatch();
-            if(vlanMatch!= null){
-                _dLVLAN = convertDlVlan(matchBuilder, vlanMatch);
-                _dLVLANPCP = convertDlVlanPcp(matchBuilder, vlanMatch);
-            }
-            NodeConnectorId inPort = match.getInPort();
-            if(inPort!=null){
-                _iNPORT = convertInPortMatch(matchBuilder, inPort);
-            }
-            Layer3Match l3Match = match.getLayer3Match();
-            if(l3Match != null){
-                if(l3Match instanceof Ipv4Match){
-                    Ipv4Match ipv4 = (Ipv4Match)l3Match;
-                    convertL3Ipv4SrcMatch(matchBuilder, ipv4);
-                    convertL3Ipv4DstMatch(matchBuilder, ipv4);
-                }
-            }
-            IpMatch ipMatch = match.getIpMatch();
-            if(ipMatch!=null){
-                _nWPROTO = convertNwProto(matchBuilder, ipMatch);
-                _nWTOS = convertNwTos(matchBuilder, ipMatch);
-            }
-            Layer4Match layer4Match = match.getLayer4Match();
-            if (layer4Match != null) {
-                if (layer4Match instanceof TcpMatch) {
-                    TcpMatch tcpMatch = (TcpMatch) layer4Match;
-                    _tPSRC = convertL4TpSrcMatch(matchBuilder, tcpMatch);
-                    _tPDST = convertL4TpDstMatch(matchBuilder, tcpMatch);
-                } else if (layer4Match instanceof UdpMatch) {
-                    UdpMatch udpMatch = (UdpMatch) layer4Match;
-                    _tPSRC = convertL4UdpSrcMatch(matchBuilder, udpMatch);
-                    _tPDST = convertL4UdpDstMatch(matchBuilder, udpMatch);
-                }
-            } else {
-                Icmpv4Match icmpv4Match = match.getIcmpv4Match();
-                if (icmpv4Match != null) {
-                    Short type = icmpv4Match.getIcmpv4Type();
-                    if (type != null) {
-                        matchBuilder.setTpSrc(type.intValue());
-                        _tPSRC = false;
-                    }
-                    Short code = icmpv4Match.getIcmpv4Code();
-                    if (code != null) {
-                        matchBuilder.setTpDst(code.intValue());
-                        _tPDST = false;
-                    }
-                }
-            }
-        }
-
-        FlowWildcardsV10 wildCards = new FlowWildcardsV10(
-                _dLDST, _dLSRC, _dLTYPE, _dLVLAN,
-                _dLVLANPCP, _iNPORT, _nWPROTO, _nWTOS, _tPDST, _tPSRC);
-        matchBuilder.setWildcards(wildCards);
-
-        return matchBuilder.build();
-    }
-
-    /**
-     * @param matchBuilder
-     * @param udpMatch
-     * @return is wildCard
-     */
     private static boolean convertL4UdpDstMatch(final MatchV10Builder matchBuilder,
-            final UdpMatch udpMatch) {
+                                                final UdpMatch udpMatch) {
         if (udpMatch.getUdpDestinationPort() != null) {
             matchBuilder.setTpDst(udpMatch.getUdpDestinationPort().getValue());
             return false;
@@ -162,13 +60,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param udpMatch
-     * @return is wildCard
-     */
     private static boolean convertL4UdpSrcMatch(final MatchV10Builder matchBuilder,
-            final UdpMatch udpMatch) {
+                                                final UdpMatch udpMatch) {
         if (udpMatch.getUdpSourcePort() != null) {
             matchBuilder.setTpSrc(udpMatch.getUdpSourcePort().getValue());
             return false;
@@ -176,13 +69,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param tcpMatch
-     * @return is wildCard
-     */
     private static boolean convertL4TpDstMatch(final MatchV10Builder matchBuilder,
-            final TcpMatch tcpMatch) {
+                                               final TcpMatch tcpMatch) {
         if (tcpMatch.getTcpDestinationPort() != null) {
             matchBuilder.setTpDst(tcpMatch.getTcpDestinationPort().getValue());
             return false;
@@ -190,13 +78,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param tcpMatch
-     * @return is wildCard
-     */
     private static boolean convertL4TpSrcMatch(final MatchV10Builder matchBuilder,
-            final TcpMatch tcpMatch) {
+                                               final TcpMatch tcpMatch) {
         if (tcpMatch.getTcpSourcePort() != null) {
             matchBuilder.setTpSrc(tcpMatch.getTcpSourcePort().getValue());
             return false;
@@ -204,13 +87,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param ipMatch
-     * @return is wildCard
-     */
     private static boolean convertNwTos(final MatchV10Builder matchBuilder,
-            final IpMatch ipMatch) {
+                                        final IpMatch ipMatch) {
         if (ipMatch.getIpDscp() != null) {
             matchBuilder.setNwTos(ActionUtil.dscpToTos(ipMatch.getIpDscp().getValue()));
             return false;
@@ -218,11 +96,6 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param ipMatch
-     * @return is wildCard
-     */
     private static boolean convertNwProto(final MatchV10Builder matchBuilder, final IpMatch ipMatch) {
         if (ipMatch.getIpProtocol() != null) {
             matchBuilder.setNwProto(ipMatch.getIpProtocol());
@@ -234,12 +107,13 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
     /**
      * Method splits the IP address and its mask and set their respective values in MatchV10Builder instance.
      * Wildcard value of the IP mask will be determined by Openflow java encoding library.
-     * @param matchBuilder
-     * @param ipv4
+     *
+     * @param matchBuilder match builder
+     * @param ipv4         ip v4 match
      */
     private static void convertL3Ipv4DstMatch(final MatchV10Builder matchBuilder,
-            final Ipv4Match ipv4) {
-        if(ipv4.getIpv4Destination()!=null){
+                                              final Ipv4Match ipv4) {
+        if (ipv4.getIpv4Destination() != null) {
             Iterator<String> addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Destination().getValue()).iterator();
             Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
             Integer prefix = buildPrefix(addressParts);
@@ -251,12 +125,13 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
     /**
      * Method splits the IP address and its mask and set their respective values in MatchV10Builder instance.
      * Wildcard value of the IP mask will be determined by Openflow java encoding library.
-     * @param matchBuilder
-     * @param ipv4
+     *
+     * @param matchBuilder match builder
+     * @param ipv4         ip v4 match
      */
     private static void convertL3Ipv4SrcMatch(final MatchV10Builder matchBuilder,
-            final Ipv4Match ipv4) {
-        if(ipv4.getIpv4Source()!=null){
+                                              final Ipv4Match ipv4) {
+        if (ipv4.getIpv4Source() != null) {
             Iterator<String> addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Source().getValue()).iterator();
             Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
             int prefix = buildPrefix(addressParts);
@@ -266,10 +141,6 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         }
     }
 
-    /**
-     * @param addressParts
-     * @return
-     */
     private static int buildPrefix(final Iterator<String> addressParts) {
         int prefix = 32;
         if (addressParts.hasNext()) {
@@ -278,13 +149,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return prefix;
     }
 
-    /**
-     * @param matchBuilder
-     * @param vlanMatch
-     * @return
-     */
     private static boolean convertDlVlanPcp(final MatchV10Builder matchBuilder,
-            final VlanMatch vlanMatch) {
+                                            final VlanMatch vlanMatch) {
         if (vlanMatch.getVlanPcp() != null) {
             matchBuilder.setDlVlanPcp(vlanMatch.getVlanPcp().getValue());
             return false;
@@ -292,11 +158,6 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param vlanMatch
-     * @return
-     */
     private static boolean convertDlVlan(final MatchV10Builder matchBuilder, final VlanMatch vlanMatch) {
         if (vlanMatch.getVlanId() != null) {
             int vlanId = vlanMatch.getVlanId().getVlanId().getValue();
@@ -306,13 +167,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param ethernetMatch
-     * @return is wildCard
-     */
     private static boolean convertEthernetDlType(final MatchV10Builder matchBuilder,
-            final EthernetMatch ethernetMatch) {
+                                                 final EthernetMatch ethernetMatch) {
         if (ethernetMatch.getEthernetType() != null) {
             matchBuilder.setDlType(ethernetMatch.getEthernetType().getType().getValue().intValue());
             return false;
@@ -320,13 +176,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param ethernetMatch
-     * @return is wildCard
-     */
     private static boolean convertEthernetDlSrc(final MatchV10Builder matchBuilder,
-            final EthernetMatch ethernetMatch) {
+                                                final EthernetMatch ethernetMatch) {
         if (ethernetMatch.getEthernetSource() != null) {
             matchBuilder.setDlSrc(ethernetMatch.getEthernetSource().getAddress());
             return false;
@@ -334,13 +185,8 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param ethernetMatch
-     * @return is wildCard
-     */
     private static boolean convertEthernetDlDst(final MatchV10Builder matchBuilder,
-            final EthernetMatch ethernetMatch) {
+                                                final EthernetMatch ethernetMatch) {
         if (ethernetMatch.getEthernetDestination() != null) {
             matchBuilder.setDlDst(ethernetMatch.getEthernetDestination().getAddress());
             return false;
@@ -348,10 +194,6 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
-    /**
-     * @param matchBuilder
-     * @param inPort
-     */
     private static boolean convertInPortMatch(final MatchV10Builder matchBuilder, final NodeConnectorId inPort) {
         if (inPort != null) {
             matchBuilder.setInPort(InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF10, inPort).intValue());
@@ -360,4 +202,104 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
         return true;
     }
 
+    /**
+     * Method builds openflow 1.0 specific match (MatchV10) from MD-SAL match.
+     *
+     * @param match MD-SAL match
+     * @param convertorExecutor
+     * @return OF-API match
+     */
+    @Override
+    public MatchV10 convert(final Match match, ConvertorExecutor convertorExecutor) {
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        boolean _dLDST = true;
+        boolean _dLSRC = true;
+        boolean _dLTYPE = true;
+        boolean _dLVLAN = true;
+        boolean _dLVLANPCP = true;
+        boolean _iNPORT = true;
+        boolean _nWPROTO = true;
+        boolean _nWTOS = true;
+        boolean _tPDST = true;
+        boolean _tPSRC = true;
+
+        matchBuilder.setInPort(0);
+        matchBuilder.setDlDst(zeroMac);
+        matchBuilder.setDlSrc(zeroMac);
+        matchBuilder.setDlType(0);
+        matchBuilder.setDlVlan(OFP_VLAN_NONE);
+        matchBuilder.setDlVlanPcp((short) 0);
+        matchBuilder.setNwDst(zeroIPv4);
+        matchBuilder.setNwDstMask((short) 0);
+        matchBuilder.setNwSrc(zeroIPv4);
+        matchBuilder.setNwSrcMask((short) 0);
+        matchBuilder.setNwProto((short) 0);
+        matchBuilder.setNwTos((short) 0);
+        matchBuilder.setTpSrc(0);
+        matchBuilder.setTpDst(0);
+
+        if (match != null) {
+            EthernetMatch ethernetMatch = match.getEthernetMatch();
+            if (ethernetMatch != null) {
+                _dLDST = convertEthernetDlDst(matchBuilder, ethernetMatch);
+                _dLSRC = convertEthernetDlSrc(matchBuilder, ethernetMatch);
+                _dLTYPE = convertEthernetDlType(matchBuilder, ethernetMatch);
+            }
+            VlanMatch vlanMatch = match.getVlanMatch();
+            if (vlanMatch != null) {
+                _dLVLAN = convertDlVlan(matchBuilder, vlanMatch);
+                _dLVLANPCP = convertDlVlanPcp(matchBuilder, vlanMatch);
+            }
+            NodeConnectorId inPort = match.getInPort();
+            if (inPort != null) {
+                _iNPORT = convertInPortMatch(matchBuilder, inPort);
+            }
+            Layer3Match l3Match = match.getLayer3Match();
+            if (l3Match != null) {
+                if (l3Match instanceof Ipv4Match) {
+                    Ipv4Match ipv4 = (Ipv4Match) l3Match;
+                    convertL3Ipv4SrcMatch(matchBuilder, ipv4);
+                    convertL3Ipv4DstMatch(matchBuilder, ipv4);
+                }
+            }
+            IpMatch ipMatch = match.getIpMatch();
+            if (ipMatch != null) {
+                _nWPROTO = convertNwProto(matchBuilder, ipMatch);
+                _nWTOS = convertNwTos(matchBuilder, ipMatch);
+            }
+            Layer4Match layer4Match = match.getLayer4Match();
+            if (layer4Match != null) {
+                if (layer4Match instanceof TcpMatch) {
+                    TcpMatch tcpMatch = (TcpMatch) layer4Match;
+                    _tPSRC = convertL4TpSrcMatch(matchBuilder, tcpMatch);
+                    _tPDST = convertL4TpDstMatch(matchBuilder, tcpMatch);
+                } else if (layer4Match instanceof UdpMatch) {
+                    UdpMatch udpMatch = (UdpMatch) layer4Match;
+                    _tPSRC = convertL4UdpSrcMatch(matchBuilder, udpMatch);
+                    _tPDST = convertL4UdpDstMatch(matchBuilder, udpMatch);
+                }
+            } else {
+                Icmpv4Match icmpv4Match = match.getIcmpv4Match();
+                if (icmpv4Match != null) {
+                    Short type = icmpv4Match.getIcmpv4Type();
+                    if (type != null) {
+                        matchBuilder.setTpSrc(type.intValue());
+                        _tPSRC = false;
+                    }
+                    Short code = icmpv4Match.getIcmpv4Code();
+                    if (code != null) {
+                        matchBuilder.setTpDst(code.intValue());
+                        _tPDST = false;
+                    }
+                }
+            }
+        }
+
+        FlowWildcardsV10 wildCards = new FlowWildcardsV10(
+                _dLDST, _dLSRC, _dLTYPE, _dLVLAN,
+                _dLVLANPCP, _iNPORT, _nWPROTO, _nWTOS, _tPDST, _tPSRC);
+        matchBuilder.setWildcards(wildCards);
+
+        return matchBuilder.build();
+    }
 }
index 9775d01afaab0279c020bfa1cbe5af5614efa397..3c31f4d1011fad9a985d7b7772891fe7828f92d6 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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,
@@ -9,10 +9,9 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
 import java.util.Map;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorKey;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 
@@ -35,8 +34,8 @@ public class MatchReactor extends ConvertReactor<Match> {
     }
 
     @Override
-    protected void initMappings(final Map<Short, Convertor<Match,?>> conversions,
-            final Map<InjectionKey, ResultInjector<?,?>> injections) {
+    protected void initMappings(final Map<Short, ConvertReactorConvertor<Match, ?>> conversions,
+                                final Map<ConvertorKey, ResultInjector<?, ?>> injections) {
         MatchReactorMappingFactory.addMatchConvertors(conversions);
         MatchReactorMappingFactory.addMatchIjectors(injections);
     }
index bc4ca0c4e6654887b5fa9692ddd6bd17f7ad34a3..f10fce499655253c105abaaa05086f3605b7ee4e 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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,
@@ -8,11 +8,13 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
+import java.util.List;
+import java.util.Map;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorKey;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
@@ -21,8 +23,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
-import java.util.List;
-import java.util.Map;
 
 /**
  * add prepared convertors and injectors into given mappings
@@ -34,7 +34,7 @@ public class MatchReactorMappingFactory {
     /**
      * @param conversionMapping conversion mapping
      */
-    public static void addMatchConvertors(final Map<Short, Convertor<Match, ?>> conversionMapping) {
+    public static void addMatchConvertors(final Map<Short, ConvertReactorConvertor<Match, ?>> conversionMapping) {
         conversionMapping.put(OFConstants.OFP_VERSION_1_3, new MatchConvertorImpl());
         conversionMapping.put(OFConstants.OFP_VERSION_1_0, new MatchConvertorV10Impl());
     }
@@ -42,9 +42,9 @@ public class MatchReactorMappingFactory {
     /**
      * @param injectionMapping injection mapping
      */
-    public static void addMatchIjectors(final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping) {
+    public static void addMatchIjectors(final Map<ConvertorKey, ResultInjector<?, ?>> injectionMapping) {
         // OF-1.3|List<MatchEntries> --> FlowModInputBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_3, FlowModInputBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_3, FlowModInputBuilder.class),
                 new ResultInjector<List<MatchEntry>, FlowModInputBuilder>() {
                     @Override
                     public void inject(final List<MatchEntry> value,
@@ -54,7 +54,7 @@ public class MatchReactorMappingFactory {
                 });
 
         // OF-1.3|List<MatchEntries> --> OxmFieldsActionBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_3, SetFieldActionBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_3, SetFieldActionBuilder.class),
                 new ResultInjector<List<MatchEntry>, SetFieldActionBuilder>() {
                     @Override
                     public void inject(final List<MatchEntry> value,
@@ -64,7 +64,7 @@ public class MatchReactorMappingFactory {
                 });
 
         // OF-1.0|MatchV10Builder --> FlowModInputBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_0, FlowModInputBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_0, FlowModInputBuilder.class),
                 new ResultInjector<MatchV10, FlowModInputBuilder>() {
                     @Override
                     public void inject(final MatchV10 value,
@@ -74,7 +74,7 @@ public class MatchReactorMappingFactory {
                 });
 
         // OF-1.3|List<MatchEntries> --> MultipartRequestFlowBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_3, MultipartRequestFlowBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_3, MultipartRequestFlowBuilder.class),
                 new ResultInjector<List<MatchEntry>, MultipartRequestFlowBuilder>() {
                     @Override
                     public void inject(final List<MatchEntry> value,
@@ -84,7 +84,7 @@ public class MatchReactorMappingFactory {
                 });
 
         // OF-1.0|List<MatchEntries> --> MultipartRequestFlowBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_0, MultipartRequestFlowBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_0, MultipartRequestFlowBuilder.class),
                 new ResultInjector<MatchV10, MultipartRequestFlowBuilder>() {
                     @Override
                     public void inject(final MatchV10 value,
@@ -94,7 +94,7 @@ public class MatchReactorMappingFactory {
                 });
 
         // OF-1.3|List<MatchEntries> --> MultipartRequestAggregateBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_3, MultipartRequestAggregateBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_3, MultipartRequestAggregateBuilder.class),
                 new ResultInjector<List<MatchEntry>, MultipartRequestAggregateBuilder>() {
                     @Override
                     public void inject(final List<MatchEntry> value,
@@ -104,7 +104,7 @@ public class MatchReactorMappingFactory {
                 });
 
         // OF-1.0|List<MatchEntries> --> MultipartRequestAggregateBuilder
-        injectionMapping.put(new InjectionKey(OFConstants.OFP_VERSION_1_0, MultipartRequestAggregateBuilder.class),
+        injectionMapping.put(new ConvertorKey(OFConstants.OFP_VERSION_1_0, MultipartRequestAggregateBuilder.class),
                 new ResultInjector<MatchV10, MultipartRequestAggregateBuilder>() {
                     @Override
                     public void inject(final MatchV10 value,
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java
new file mode 100644 (file)
index 0000000..2529f37
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match;
+
+import java.util.Arrays;
+import java.util.Collection;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalArpOpCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalArpShaCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalArpSpaCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalArpThaCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalArpTpaCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalEthDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalEthSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalEthTypeCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIcmpv4CodeCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIcmpv4TypeCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIcmpv6CodeCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIcmpv6TypeCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalInPhyPortCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalInPortCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpDscpCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpEcnCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpProtoCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv4DstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv4SrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6DstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6ExthdrCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6FlabelCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6NdSllCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6NdTargetCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6NdTllCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalIpv6SrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalMetadataCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalMplsBosCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalMplsLabelCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalMplsTcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalPbbIsidCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalSctpDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalSctpSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalTcpDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalExperimenterIdCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalTcpSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalTunnelIdCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalTunnelIpv4DstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalTunnelIpv4SrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalUdpDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalUdpSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalVlanPcpCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.OfToSalVlanVidCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping;
+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.MatchEntryValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts Openflow 1.3+ specific flow match to MD-SAL format flow
+ * match
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * Optional<MatchBuilder> salMatch = convertorManager.convert(ofMatch, data);
+ * }
+ * </pre>
+ */
+public class MatchResponseConvertor extends Convertor<MatchEntriesGrouping, MatchBuilder, VersionDatapathIdConvertorData> {
+    private static final ConvertorProcessor<MatchEntryValue, MatchBuilder, MatchResponseConvertorData> OF_TO_SAL_PROCESSOR = new ConvertorProcessor<MatchEntryValue, MatchBuilder, MatchResponseConvertorData>()
+            .addCase(new OfToSalInPortCase())
+            .addCase(new OfToSalInPhyPortCase())
+            .addCase(new OfToSalMetadataCase())
+            .addCase(new OfToSalEthSrcCase())
+            .addCase(new OfToSalEthDstCase())
+            .addCase(new OfToSalEthTypeCase())
+            .addCase(new OfToSalVlanVidCase())
+            .addCase(new OfToSalVlanPcpCase())
+            .addCase(new OfToSalIpDscpCase())
+            .addCase(new OfToSalIpEcnCase())
+            .addCase(new OfToSalIpProtoCase())
+            .addCase(new OfToSalTcpSrcCase())
+            .addCase(new OfToSalTcpDstCase())
+            .addCase(new OfToSalUdpSrcCase())
+            .addCase(new OfToSalUdpDstCase())
+            .addCase(new OfToSalSctpSrcCase())
+            .addCase(new OfToSalSctpDstCase())
+            .addCase(new OfToSalIcmpv4TypeCase())
+            .addCase(new OfToSalIcmpv4CodeCase())
+            .addCase(new OfToSalIcmpv6TypeCase())
+            .addCase(new OfToSalIcmpv6CodeCase())
+            .addCase(new OfToSalIpv4SrcCase())
+            .addCase(new OfToSalIpv4DstCase())
+            .addCase(new OfToSalArpOpCase())
+            .addCase(new OfToSalArpSpaCase())
+            .addCase(new OfToSalArpTpaCase())
+            .addCase(new OfToSalArpShaCase())
+            .addCase(new OfToSalArpThaCase())
+            .addCase(new OfToSalIpv6SrcCase())
+            .addCase(new OfToSalIpv6DstCase())
+            .addCase(new OfToSalIpv6FlabelCase())
+            .addCase(new OfToSalIpv6NdTargetCase())
+            .addCase(new OfToSalIpv6NdSllCase())
+            .addCase(new OfToSalIpv6NdTllCase())
+            .addCase(new OfToSalIpv6ExthdrCase())
+            .addCase(new OfToSalMplsLabelCase())
+            .addCase(new OfToSalMplsBosCase())
+            .addCase(new OfToSalMplsTcCase())
+            .addCase(new OfToSalPbbIsidCase())
+            .addCase(new OfToSalTunnelIdCase())
+            .addCase(new OfToSalExperimenterIdCase());
+
+    private static final ConvertorProcessor<MatchEntryValue, MatchBuilder, MatchResponseConvertorData> OF_TO_SAL_TUNNEL_PROCESSOR = new ConvertorProcessor<MatchEntryValue, MatchBuilder, MatchResponseConvertorData>()
+            .addCase(new OfToSalTunnelIpv4SrcCase())
+            .addCase(new OfToSalTunnelIpv4DstCase());
+    private static final java.util.List<Class<? extends DataContainer>> TYPES = Arrays.asList(Match.class, SetFieldAction.class);
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return  TYPES;
+    }
+
+    @Override
+    public MatchBuilder convert(MatchEntriesGrouping source, VersionDatapathIdConvertorData datapathIdConvertorData) {
+        final MatchBuilder matchBuilder = new MatchBuilder();
+
+        final MatchResponseConvertorData data = new MatchResponseConvertorData(datapathIdConvertorData.getVersion());
+        data.setDatapathId(datapathIdConvertorData.getDatapathId());
+        data.setMatchBuilder(matchBuilder);
+        data.setEthernetMatchBuilder(new EthernetMatchBuilder());
+        data.setVlanMatchBuilder(new VlanMatchBuilder());
+        data.setIpMatchBuilder(new IpMatchBuilder());
+        data.setTcpMatchBuilder(new TcpMatchBuilder());
+        data.setUdpMatchBuilder(new UdpMatchBuilder());
+        data.setSctpMatchBuilder(new SctpMatchBuilder());
+        data.setIcmpv4MatchBuilder(new Icmpv4MatchBuilder());
+        data.setIcmpv6MatchBuilder(new Icmpv6MatchBuilder());
+        data.setIpv4MatchBuilder(new Ipv4MatchBuilder());
+        data.setIpv4MatchArbitraryBitMaskBuilder(new Ipv4MatchArbitraryBitMaskBuilder());
+        data.setIpv6MatchArbitraryBitMaskBuilder(new Ipv6MatchArbitraryBitMaskBuilder());
+        data.setArpMatchBuilder(new ArpMatchBuilder());
+        data.setIpv6MatchBuilder(new Ipv6MatchBuilder());
+        data.setProtocolMatchFieldsBuilder(new ProtocolMatchFieldsBuilder());
+        data.setTunnelIpv4MatchBuilder(new TunnelIpv4MatchBuilder());
+        data.setTcpFlagsMatchBuilder(new TcpFlagsMatchBuilder());
+
+        for (MatchEntry ofMatch : source.getMatchEntry()) {
+            if (TunnelIpv4Dst.class.isAssignableFrom(ofMatch.getOxmMatchField()) ||
+                    TunnelIpv4Src.class.isAssignableFrom(ofMatch.getOxmMatchField())) {
+                /**
+                 * TODO: Fix TunnelIpv4Src and Ipv4Dst, because current implementation do not work
+                 * TunnelIpv4Src and TunnelIpv4Dst are not compatible with
+                 * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField
+                 * and so you cannot even set them to OxmMatchField.
+                 * Creation of TunnelIpv4SrcCase and TunnelIpv4DstCase in
+                 * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value
+                 * and proper use of it can fix this bug.
+                 */
+                OF_TO_SAL_TUNNEL_PROCESSOR.process(ofMatch.getMatchEntryValue(), data, getConvertorExecutor());
+            } else {
+                data.setOxmMatchField(ofMatch.getOxmMatchField());
+                OF_TO_SAL_PROCESSOR.process(ofMatch.getMatchEntryValue(), data, getConvertorExecutor());
+            }
+        }
+
+        return matchBuilder;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertor.java
new file mode 100644 (file)
index 0000000..742ddc0
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match;
+
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Converts Openflow 1.0 specific flow match to MD-SAL format flow
+ * match
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * Optional<MatchBuilder> salMatch = convertorManager.convert(ofMatchV10, data);
+ * }
+ * </pre>
+ */
+public class MatchV10ResponseConvertor extends Convertor<MatchV10, MatchBuilder, VersionDatapathIdConvertorData> {
+    private static final short PROTO_TCP = 6;
+    private static final short PROTO_UDP = 17;
+    private static final short PROTO_ICMPV4 = 1;
+    private static final String NO_IP = "0.0.0.0/0";
+    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(MatchV10.class);
+
+    @Override
+    public Collection<Class<? extends DataContainer>> getTypes() {
+        return TYPES;
+    }
+
+    @Override
+    public MatchBuilder convert(MatchV10 source, VersionDatapathIdConvertorData datapathIdConvertorData) {
+        MatchBuilder matchBuilder = new MatchBuilder();
+        EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
+        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+        Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+        IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
+        OpenflowVersion ofVersion = OpenflowVersion.get(datapathIdConvertorData.getVersion());
+        BigInteger datapathid = datapathIdConvertorData.getDatapathId();
+
+        if (!source.getWildcards().isINPORT() && source.getInPort() != null) {
+            matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid,
+                    (long) source.getInPort(), ofVersion));
+        }
+
+        if (!source.getWildcards().isDLSRC() && source.getDlSrc() != null) {
+            EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
+            ethSrcBuilder.setAddress(source.getDlSrc());
+            ethMatchBuilder.setEthernetSource(ethSrcBuilder.build());
+            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+        }
+        if (!source.getWildcards().isDLDST() && source.getDlDst() != null) {
+            EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
+            ethDstBuilder.setAddress(source.getDlDst());
+            ethMatchBuilder.setEthernetDestination(ethDstBuilder.build());
+            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+        }
+        if (!source.getWildcards().isDLTYPE() && source.getDlType() != null) {
+            EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+            ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType(
+                    (long) source.getDlType()));
+            ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
+            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+        }
+        if (!source.getWildcards().isDLVLAN() && source.getDlVlan() != null) {
+            VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+            int vlanId = (source.getDlVlan() == (0xffff)) ? 0 : source.getDlVlan();
+            vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanId));
+            vlanIdBuilder.setVlanIdPresent(vlanId != 0);
+            vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
+            matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+        }
+        if (!source.getWildcards().isDLVLANPCP() && source.getDlVlanPcp() != null) {
+            vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(
+                    source.getDlVlanPcp()));
+            matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+        }
+        if (!source.getWildcards().isDLTYPE() && source.getNwSrc() != null) {
+            final Ipv4Prefix prefix;
+            if (source.getNwSrcMask() != null) {
+                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwSrc(), source.getNwSrcMask());
+            } else {
+                //Openflow Spec : 1.3.2
+                //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
+                // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
+                // statistics response.
+                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwSrc());
+            }
+            if (!NO_IP.equals(prefix.getValue())) {
+                ipv4MatchBuilder.setIpv4Source(prefix);
+                matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+            }
+        }
+        if (!source.getWildcards().isDLTYPE() && source.getNwDst() != null) {
+            final Ipv4Prefix prefix;
+            if (source.getNwDstMask() != null) {
+                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwDst(), source.getNwDstMask());
+            } else {
+                //Openflow Spec : 1.3.2
+                //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
+                // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
+                // statistics response.
+                prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwDst());
+            }
+            if (!NO_IP.equals(prefix.getValue())) {
+                ipv4MatchBuilder.setIpv4Destination(prefix);
+                matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+            }
+        }
+        if (!source.getWildcards().isNWPROTO() && source.getNwProto() != null) {
+            Short nwProto = source.getNwProto();
+            ipMatchBuilder.setIpProtocol(nwProto);
+            matchBuilder.setIpMatch(ipMatchBuilder.build());
+
+            int proto = nwProto.intValue();
+            if (proto == PROTO_TCP) {
+                TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
+                boolean hasTcp = false;
+                if (!source.getWildcards().isTPSRC() && source.getTpSrc() != null) {
+                    tcpMatchBuilder
+                            .setTcpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
+                                    source.getTpSrc()));
+                    hasTcp = true;
+                }
+                if (!source.getWildcards().isTPDST() && source.getTpDst() != null) {
+                    tcpMatchBuilder
+                            .setTcpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
+                                    source.getTpDst()));
+                    hasTcp = true;
+                }
+
+                if (hasTcp) {
+                    matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+                }
+            } else if (proto == PROTO_UDP) {
+                UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
+                boolean hasUdp = false;
+                if (!source.getWildcards().isTPSRC() && source.getTpSrc() != null) {
+                    udpMatchBuilder
+                            .setUdpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
+                                    source.getTpSrc()));
+                    hasUdp = true;
+                }
+                if (!source.getWildcards().isTPDST() && source.getTpDst() != null) {
+                    udpMatchBuilder
+                            .setUdpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(
+                                    source.getTpDst()));
+                    hasUdp = true;
+                }
+
+                if (hasUdp) {
+                    matchBuilder.setLayer4Match(udpMatchBuilder.build());
+                }
+            } else if (proto == PROTO_ICMPV4) {
+                Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
+                boolean hasIcmpv4 = false;
+                if (!source.getWildcards().isTPSRC()) {
+                    Integer type = source.getTpSrc();
+                    if (type != null) {
+                        icmpv4MatchBuilder.setIcmpv4Type(type.shortValue());
+                        hasIcmpv4 = true;
+                    }
+                }
+                if (!source.getWildcards().isTPDST()) {
+                    Integer code = source.getTpDst();
+                    if (code != null) {
+                        icmpv4MatchBuilder.setIcmpv4Code(code.shortValue());
+                        hasIcmpv4 = true;
+                    }
+                }
+
+                if (hasIcmpv4) {
+                    matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
+                }
+            }
+        }
+        if (!source.getWildcards().isNWTOS() && source.getNwTos() != null) {
+            Short dscp = ActionUtil.tosToDscp(source.getNwTos());
+            ipMatchBuilder.setIpDscp(new Dscp(dscp));
+            matchBuilder.setIpMatch(ipMatchBuilder.build());
+        }
+
+        return matchBuilder;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpOpCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpOpCase.java
new file mode 100644 (file)
index 0000000..e777edf
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOp;
+
+public class OfToSalArpOpCase extends ConvertorCase<ArpOpCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalArpOpCase() {
+        super(ArpOpCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull ArpOpCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
+
+        ArpOp arpOp = source.getArpOp();
+
+        if (arpOp != null) {
+            arpMatchBuilder.setArpOp(arpOp.getOpCode());
+            matchBuilder.setLayer3Match(arpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpShaCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpShaCase.java
new file mode 100644 (file)
index 0000000..ca42239
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpSha;
+
+public class OfToSalArpShaCase extends ConvertorCase<ArpShaCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalArpShaCase() {
+        super(ArpShaCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull ArpShaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
+
+        ArpSha arpSha = source.getArpSha();
+        MacAddress macAddress = arpSha.getMacAddress();
+
+        if (macAddress != null) {
+            ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
+            arpSourceHardwareAddressBuilder.setAddress(macAddress);
+            byte[] mask = arpSha.getMask();
+
+            if (mask != null) {
+                arpSourceHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils
+                        .macAddressToString(mask)));
+            }
+
+            arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
+            matchBuilder.setLayer3Match(arpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpSpaCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpSpaCase.java
new file mode 100644 (file)
index 0000000..04eda9d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpa;
+
+public class OfToSalArpSpaCase extends ConvertorCase<ArpSpaCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalArpSpaCase() {
+        super(ArpSpaCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull ArpSpaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
+
+        ArpSpa arpSpa = source.getArpSpa();
+
+        if (arpSpa != null) {
+            int mask = 32;
+
+            if (null != arpSpa.getMask()) {
+                mask = IpConversionUtil.countBits(arpSpa.getMask());
+            }
+
+            Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpSpa.getIpv4Address(), mask);
+            arpMatchBuilder.setArpSourceTransportAddress(ipv4Prefix);
+            matchBuilder.setLayer3Match(arpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpThaCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpThaCase.java
new file mode 100644 (file)
index 0000000..67c06a4
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpTha;
+
+public class OfToSalArpThaCase extends ConvertorCase<ArpThaCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalArpThaCase() {
+        super(ArpThaCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull ArpThaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
+
+        ArpTha arpTha = source.getArpTha();
+        MacAddress macAddress = arpTha.getMacAddress();
+
+        if (macAddress != null) {
+            ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder();
+            arpTargetHardwareAddressBuilder.setAddress(macAddress);
+            byte[] mask = arpTha.getMask();
+
+            if (mask != null) {
+                arpTargetHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils
+                        .macAddressToString(mask)));
+            }
+
+            arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
+            matchBuilder.setLayer3Match(arpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpTpaCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalArpTpaCase.java
new file mode 100644 (file)
index 0000000..e79eb3e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpa;
+
+public class OfToSalArpTpaCase extends ConvertorCase<ArpTpaCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalArpTpaCase() {
+        super(ArpTpaCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull ArpTpaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
+
+        ArpTpa arpTpa = source.getArpTpa();
+
+        if (arpTpa != null) {
+            int mask = 32;
+
+            if (null != arpTpa.getMask()) {
+                mask = IpConversionUtil.countBits(arpTpa.getMask());
+            }
+
+            Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpTpa.getIpv4Address(), mask);
+            arpMatchBuilder.setArpTargetTransportAddress(ipv4Prefix);
+            matchBuilder.setLayer3Match(arpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthDstCase.java
new file mode 100644 (file)
index 0000000..2653eac
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDst;
+
+public class OfToSalEthDstCase extends ConvertorCase<EthDstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalEthDstCase() {
+        super(EthDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull EthDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final EthernetMatchBuilder ethMatchBuilder = data.getEthernetMatchBuilder();
+
+        final EthDst ethDstCase = source.getEthDst();
+
+        if (ethDstCase != null) {
+            EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
+            ethDestinationBuilder.setAddress(ethDstCase.getMacAddress());
+            byte[] destinationMask = ethDstCase.getMask();
+
+            if (destinationMask != null) {
+                ethDestinationBuilder.setMask(new MacAddress(macAddressToString(destinationMask)));
+            }
+
+            ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
+            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthSrcCase.java
new file mode 100644 (file)
index 0000000..f4c12d9
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrc;
+
+public class OfToSalEthSrcCase extends ConvertorCase<EthSrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalEthSrcCase() {
+        super(EthSrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull EthSrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final EthernetMatchBuilder ethMatchBuilder = data.getEthernetMatchBuilder();
+
+        final EthSrc ethSrcCase = source.getEthSrc();
+
+        if (ethSrcCase != null) {
+            EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+            ethSourceBuilder.setAddress(ethSrcCase.getMacAddress());
+            byte[] mask = ethSrcCase.getMask();
+
+            if (mask != null) {
+                ethSourceBuilder.setMask(new MacAddress(macAddressToString(mask)));
+            }
+
+            ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
+            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthTypeCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalEthTypeCase.java
new file mode 100644 (file)
index 0000000..7a6e532
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthType;
+
+public class OfToSalEthTypeCase extends ConvertorCase<EthTypeCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalEthTypeCase() {
+        super(EthTypeCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull EthTypeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final EthernetMatchBuilder ethMatchBuilder = data.getEthernetMatchBuilder();
+
+        final EthType ethTypeCase = source.getEthType();
+
+        if (ethTypeCase != null) {
+            EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+            ethTypeBuilder.setType(new EtherType((long) ethTypeCase.getEthType().getValue()));
+            ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
+            matchBuilder.setEthernetMatch(ethMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalExperimenterIdCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalExperimenterIdCase.java
new file mode 100644 (file)
index 0000000..22bc6f0
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
+
+public class OfToSalExperimenterIdCase extends ConvertorCase<ExperimenterIdCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalExperimenterIdCase() {
+        super(ExperimenterIdCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull ExperimenterIdCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+
+        if (data.getOxmMatchField().equals(TcpFlags.class)) {
+            final TcpFlagsMatchBuilder tcpFlagsMatchBuilder = data.getTcpFlagsMatchBuilder();
+            final TcpFlagsContainer tcpFlagsContainer = source.getAugmentation(TcpFlagsContainer.class);
+
+            if (tcpFlagsContainer != null) {
+                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.
+                        approved.extensions.rev160802.oxm.container.match.entry.
+                        value.experimenter.id._case.TcpFlags tcpFlags = tcpFlagsContainer.getTcpFlags();
+
+                tcpFlagsMatchBuilder.setTcpFlags(tcpFlags.getFlags());
+                byte[] mask = tcpFlags.getMask();
+                if (mask != null) {
+                    tcpFlagsMatchBuilder.setTcpFlagsMask(ByteUtil.bytesToUnsignedShort(mask));
+                }
+
+                matchBuilder.setTcpFlagsMatch(tcpFlagsMatchBuilder.build());
+            }
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv4CodeCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv4CodeCase.java
new file mode 100644 (file)
index 0000000..d5fa2c7
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4Code;
+
+public class OfToSalIcmpv4CodeCase extends ConvertorCase<Icmpv4CodeCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIcmpv4CodeCase() {
+        super(Icmpv4CodeCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Icmpv4CodeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder();
+
+        Icmpv4Code icmpv4Code = source.getIcmpv4Code();
+        Short v4code = icmpv4Code.getIcmpv4Code();
+
+        if (v4code != null) {
+            icmpv4MatchBuilder.setIcmpv4Code(v4code);
+            matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv4TypeCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv4TypeCase.java
new file mode 100644 (file)
index 0000000..749bde8
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4Type;
+
+public class OfToSalIcmpv4TypeCase extends ConvertorCase<Icmpv4TypeCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIcmpv4TypeCase() {
+        super(Icmpv4TypeCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Icmpv4TypeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder();
+
+        Icmpv4Type icmpv4Type = source.getIcmpv4Type();
+        Short type = icmpv4Type.getIcmpv4Type();
+
+        if (type != null) {
+            icmpv4MatchBuilder.setIcmpv4Type(type);
+            matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv6CodeCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv6CodeCase.java
new file mode 100644 (file)
index 0000000..268e825
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6Code;
+
+public class OfToSalIcmpv6CodeCase extends ConvertorCase<Icmpv6CodeCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIcmpv6CodeCase() {
+        super(Icmpv6CodeCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Icmpv6CodeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Icmpv6MatchBuilder icmpv6MatchBuilder = data.getIcmpv6MatchBuilder();
+
+        Icmpv6Code icmpv6Code = source.getIcmpv6Code();
+        Short v6code = icmpv6Code.getIcmpv6Code();
+
+        if (v6code != null) {
+            icmpv6MatchBuilder.setIcmpv6Code(v6code);
+            matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv6TypeCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIcmpv6TypeCase.java
new file mode 100644 (file)
index 0000000..384e0e4
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6Type;
+
+public class OfToSalIcmpv6TypeCase extends ConvertorCase<Icmpv6TypeCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIcmpv6TypeCase() {
+        super(Icmpv6TypeCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Icmpv6TypeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Icmpv6MatchBuilder icmpv6MatchBuilder = data.getIcmpv6MatchBuilder();
+
+        Icmpv6Type icmpv6Type = source.getIcmpv6Type();
+        Short v6type = icmpv6Type.getIcmpv6Type();
+
+        if (v6type != null) {
+            icmpv6MatchBuilder.setIcmpv6Type(v6type);
+            matchBuilder.setIcmpv6Match(icmpv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalInPhyPortCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalInPhyPortCase.java
new file mode 100644 (file)
index 0000000..106682b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.math.BigInteger;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase;
+
+public class OfToSalInPhyPortCase extends ConvertorCase<InPhyPortCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalInPhyPortCase() {
+        super(InPhyPortCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull InPhyPortCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
+        final BigInteger datapathId = data.getDatapathId();
+
+        final PortNumber portNumber = source.getInPhyPort().getPortNumber();
+
+        if (portNumber != null) {
+            matchBuilder.setInPhyPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portNumber.getValue(), ofVersion));
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalInPortCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalInPortCase.java
new file mode 100644 (file)
index 0000000..9df2b5f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.math.BigInteger;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
+
+public class OfToSalInPortCase extends ConvertorCase<InPortCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalInPortCase() {
+        super(InPortCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull InPortCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
+        final BigInteger datapathId = data.getDatapathId();
+
+        final PortNumber portNumber = source.getInPort().getPortNumber();
+
+        if (portNumber != null) {
+            matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portNumber.getValue(), ofVersion));
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpDscpCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpDscpCase.java
new file mode 100644 (file)
index 0000000..4111e27
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscp;
+
+public class OfToSalIpDscpCase extends ConvertorCase<IpDscpCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpDscpCase() {
+        super(IpDscpCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull IpDscpCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final IpMatchBuilder ipMatchBuilder = data.getIpMatchBuilder();
+
+        IpDscp ipDscp = source.getIpDscp();
+
+        if (ipDscp != null) {
+            ipMatchBuilder.setIpDscp(new Dscp(ipDscp.getDscp().getValue()));
+            matchBuilder.setIpMatch(ipMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpEcnCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpEcnCase.java
new file mode 100644 (file)
index 0000000..c87e623
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcn;
+
+public class OfToSalIpEcnCase extends ConvertorCase<IpEcnCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpEcnCase() {
+        super(IpEcnCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull IpEcnCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final IpMatchBuilder ipMatchBuilder = data.getIpMatchBuilder();
+
+        IpEcn ipEcn = source.getIpEcn();
+
+        if (ipEcn != null) {
+            ipMatchBuilder.setIpEcn(ipEcn.getEcn());
+            matchBuilder.setIpMatch(ipMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpProtoCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpProtoCase.java
new file mode 100644 (file)
index 0000000..6a9cd6b
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProto;
+
+public class OfToSalIpProtoCase extends ConvertorCase<IpProtoCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpProtoCase() {
+        super(IpProtoCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull IpProtoCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final IpMatchBuilder ipMatchBuilder = data.getIpMatchBuilder();
+
+        IpProto ipProto = source.getIpProto();
+        Short protocolNumber = ipProto.getProtocolNumber();
+
+        if (protocolNumber != null) {
+            ipMatchBuilder.setIpProtocol(protocolNumber);
+            matchBuilder.setIpMatch(ipMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv4DstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv4DstCase.java
new file mode 100644 (file)
index 0000000..ba55abe
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4Dst;
+
+public class OfToSalIpv4DstCase extends ConvertorCase<Ipv4DstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv4DstCase() {
+        super(Ipv4DstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    private static void setIpv4MatchBuilderFields(final Ipv4MatchBuilder ipv4MatchBuilder, final byte[] mask, final String ipv4PrefixStr) {
+        final Ipv4Prefix ipv4Prefix;
+        if (mask != null) {
+            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
+        } else {
+            //Openflow Spec : 1.3.2
+            //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
+            // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
+            // statistics response.
+            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
+        }
+
+        ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
+    }
+
+    private static void setSrcIpv4MatchArbitraryBitMaskBuilderFields(
+            final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder,
+            final DottedQuad mask, final String ipv4AddressStr) {
+        if (mask != null) {
+            ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceArbitraryBitmask(mask);
+        }
+
+        ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address(ipv4AddressStr));
+    }
+
+    private static void setDstIpv4MatchArbitraryBitMaskBuilderFields(
+            final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder,
+            final DottedQuad mask, final String ipv4AddressStr) {
+        if (mask != null) {
+            ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(mask);
+        }
+
+        ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address(ipv4AddressStr));
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv4DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
+        final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = data.getIpv4MatchArbitraryBitMaskBuilder();
+
+        Ipv4Dst ipv4Address = source.getIpv4Dst();
+
+        if (ipv4Address != null) {
+            byte[] mask = ipv4Address.getMask();
+
+            if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
+                // case where ipv4src is of type ipv4MatchBuilder and ipv4dst is of type ipv4MatchArbitrary.
+                // Needs to convert ipv4src to ipv4MatchArbitrary.
+                if (ipv4MatchBuilder.getIpv4Source() != null) {
+                    Ipv4Prefix ipv4PrefixSourceAddress = ipv4MatchBuilder.getIpv4Source();
+                    Ipv4Address ipv4SourceAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixSourceAddress);
+                    DottedQuad srcDottedQuad = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixSourceAddress);
+                    setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder,
+                            srcDottedQuad, ipv4SourceAddress.getValue());
+                }
+
+                DottedQuad dstDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
+                String stringIpv4DstAddress = ipv4Address.getIpv4Address().getValue();
+                setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder,
+                        dstDottedQuadMask, stringIpv4DstAddress);
+                matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
+            } else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4SourceAddressNoMask() != null) {
+                        /*
+                        Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
+                        destination which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
+                        We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
+                        expected output example:-
+                        <ipv4-source>36.36.36.0/24</ipv4-source>
+                        <ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
+                        <ipv4-destination-arbitrary-bitmask>255.0.255.0</ipv4-destination-arbitrary-bitmask>
+                        after conversion output example:-
+                        <ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
+                        <ipv4-source-arbitrary-bitmask>255.255.255.0</ipv4-source-arbitrary-bitmask>
+                        <ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
+                        <ipv4-destination-arbitrary-bitmask>255.0.255.0</ipv4-destination-arbitrary-bitmask>
+                        */
+                DottedQuad dstDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
+                String stringIpv4DstAddress = ipv4Address.getIpv4Address().getValue();
+                setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder,
+                        dstDottedQuadMask, stringIpv4DstAddress);
+                matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
+            } else {
+                String ipv4PrefixStr = ipv4Address.getIpv4Address().getValue();
+                setIpv4MatchBuilderFields(ipv4MatchBuilder, mask, ipv4PrefixStr);
+                matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+            }
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv4SrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv4SrcCase.java
new file mode 100644 (file)
index 0000000..3fc8de6
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4Src;
+
+public class OfToSalIpv4SrcCase extends ConvertorCase<Ipv4SrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv4SrcCase() {
+        super(Ipv4SrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    private static void setIpv4MatchBuilderFields(final Ipv4MatchBuilder ipv4MatchBuilder, final byte[] mask, final String ipv4PrefixStr) {
+        final Ipv4Prefix ipv4Prefix;
+        if (mask != null) {
+            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
+        } else {
+            //Openflow Spec : 1.3.2
+            //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
+            // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
+            // statistics response.
+            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
+        }
+
+        ipv4MatchBuilder.setIpv4Source(ipv4Prefix);
+    }
+
+    private static void setSrcIpv4MatchArbitraryBitMaskBuilderFields(
+            final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder,
+            final DottedQuad mask, final String ipv4AddressStr) {
+        if (mask != null) {
+            ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceArbitraryBitmask(mask);
+        }
+
+        ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address(ipv4AddressStr));
+    }
+
+    private static void setDstIpv4MatchArbitraryBitMaskBuilderFields(
+            final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder,
+            final DottedQuad mask, final String ipv4AddressStr) {
+        if (mask != null) {
+            ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(mask);
+        }
+
+        ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address(ipv4AddressStr));
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv4SrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
+        final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = data.getIpv4MatchArbitraryBitMaskBuilder();
+
+        Ipv4Src ipv4Address = source.getIpv4Src();
+
+        if (ipv4Address != null) {
+            byte[] mask = ipv4Address.getMask();
+
+            if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
+                // case where ipv4dst is of type ipv4MatchBuilder and ipv4src is of type ipv4MatchArbitrary.
+                // Needs to convert ipv4dst to ipv4MatchArbitrary.
+                if (ipv4MatchBuilder.getIpv4Destination() != null) {
+                    Ipv4Prefix ipv4PrefixDestinationAddress = ipv4MatchBuilder.getIpv4Destination();
+                    Ipv4Address ipv4DstAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixDestinationAddress);
+                    DottedQuad dstDottedQuadMask = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixDestinationAddress);
+
+                    setDstIpv4MatchArbitraryBitMaskBuilderFields(
+                            ipv4MatchArbitraryBitMaskBuilder,
+                            dstDottedQuadMask, ipv4DstAddress.getValue());
+                }
+
+                DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
+                String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
+                setSrcIpv4MatchArbitraryBitMaskBuilderFields(
+                        ipv4MatchArbitraryBitMaskBuilder,
+                        srcDottedQuadMask, stringIpv4SrcAddress);
+                matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
+            } else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4DestinationAddressNoMask() != null) {
+                 /*
+                Case where destination is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
+                source which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
+                We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
+                expected output example:-
+                <ipv4-destination>36.36.36.0/24</ipv4-destination>
+                <ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
+                <ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
+                after conversion output example:-
+                <ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
+                <ipv4-destination-arbitrary-bitmask>255.255.255.0</ipv4-destination-arbitrary-bitmask>
+                <ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
+                <ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
+                */
+                DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
+                String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
+                setSrcIpv4MatchArbitraryBitMaskBuilderFields(
+                        ipv4MatchArbitraryBitMaskBuilder,
+                        srcDottedQuadMask, stringIpv4SrcAddress);
+                matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
+            } else {
+                String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
+                setIpv4MatchBuilderFields(ipv4MatchBuilder, mask, stringIpv4SrcAddress);
+                matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
+            }
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6DstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6DstCase.java
new file mode 100644 (file)
index 0000000..da1272e
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6Dst;
+
+public class OfToSalIpv6DstCase extends ConvertorCase<Ipv6DstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6DstCase() {
+        super(Ipv6DstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+        final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = data.getIpv6MatchArbitraryBitMaskBuilder();
+
+        Ipv6Dst ipv6Dst = source.getIpv6Dst();
+
+        if (ipv6Dst != null) {
+            byte[] mask = ipv6Dst.getMask();
+            if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
+                // case where ipv6src is of type ipv6MatchBuilder and ipv6dst is of type ipv6MatchArbitrary.
+                // Need to convert ipv6src to ipv6MatchArbitrary.
+
+                if (ipv6MatchBuilder.getIpv6Source() != null) {
+                    Ipv6Prefix ipv6PrefixSourceAddress = ipv6MatchBuilder.getIpv6Source();
+                    Ipv6Address ipv6SrcAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixSourceAddress);
+                    Ipv6ArbitraryMask srcIpv6Arbitrary = IpConversionUtil.compressedIpv6MaskFormat(
+                            IpConversionUtil.extractIpv6AddressMask(ipv6PrefixSourceAddress));
+                    setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder,
+                            srcIpv6Arbitrary, IpConversionUtil.compressedIpv6Format(ipv6SrcAddress.getValue()));
+                }
+                Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
+                        IpConversionUtil.createIpv6ArbitraryBitMask(mask));
+                String stringIpv6DstAddress = IpConversionUtil.compressedIpv6Format(ipv6Dst.getIpv6Address().getValue());
+                setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder,
+                        dstIpv6ArbitraryMask, stringIpv6DstAddress);
+                matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
+            } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6SourceAddressNoMask() != null) {
+                         /*
+                         TODO Change comments
+                        Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
+                        source which of type ipv6Match needs to be converted to ipv6MatchArbitraryBitMask.
+                        We convert 1::/32 to 1::/FFFF:FFFF::
+                        example:-
+                        <ipv6-destination>1::/32</ipv6-destination>
+                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
+                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
+                        after conversion output example:-
+                        <ipv6-destination-address-no-mask>1::</ipv6-destination-address-no-mask>
+                        <ipv6-destination-arbitrary-bitmask>FFFF:FFFF::</ipv6-destination-arbitrary-bitmask>
+                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
+                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
+                        */
+                Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
+                        IpConversionUtil.createIpv6ArbitraryBitMask(mask));
+                String stringIpv6DstAddress = IpConversionUtil.compressedIpv6Format(ipv6Dst.getIpv6Address().getValue());
+                setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder,
+                        dstIpv6ArbitraryMask, stringIpv6DstAddress);
+                matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
+            } else {
+                String stringIpv6DstAddress = IpConversionUtil.compressedIpv6Format(ipv6Dst.getIpv6Address().getValue());
+                setIpv6MatchBuilderFields(ipv6MatchBuilder, mask, stringIpv6DstAddress);
+                matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+            }
+        }
+
+        return Optional.of(matchBuilder);
+    }
+
+    private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder ipv6MatchBuilder, final byte[] mask, final String ipv6PrefixStr) {
+        Ipv6Prefix ipv6Prefix;
+
+        if (mask != null) {
+            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr), mask);
+        } else {
+            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr));
+        }
+
+        ipv6MatchBuilder.setIpv6Destination(ipv6Prefix);
+    }
+
+    private static void setSrcIpv6MatchArbitraryBitMaskBuilderFields(
+            final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder,
+            final Ipv6ArbitraryMask mask, final String ipv6AddressStr) {
+        Ipv6Address ipv6Address;
+        if (mask != null) {
+            ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceArbitraryBitmask(mask);
+        }
+        ipv6Address = new Ipv6Address(ipv6AddressStr);
+        ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceAddressNoMask(ipv6Address);
+    }
+
+    private static void setDstIpv6MatchArbitraryBitMaskBuilderFields(
+            final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder,
+            final Ipv6ArbitraryMask mask, final String ipv6AddressStr) {
+        Ipv6Address ipv6Address;
+        if (mask != null) {
+            ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationArbitraryBitmask(mask);
+        }
+        ipv6Address = new Ipv6Address(ipv6AddressStr);
+        ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationAddressNoMask(ipv6Address);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6ExthdrCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6ExthdrCase.java
new file mode 100644 (file)
index 0000000..ee65a38
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6Exthdr;
+
+public class OfToSalIpv6ExthdrCase extends ConvertorCase<Ipv6ExthdrCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6ExthdrCase() {
+        super(Ipv6ExthdrCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6ExthdrCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+
+        Ipv6Exthdr ipv6Exthdr = source.getIpv6Exthdr();
+
+        if (ipv6Exthdr != null) {
+            Ipv6ExtHeaderBuilder ipv6ExtHeaderBuilder = new Ipv6ExtHeaderBuilder();
+            Ipv6ExthdrFlags pField = ipv6Exthdr.getPseudoField();
+            Integer bitmap = MatchConvertorUtil.ipv6ExthdrFlagsToInt(pField);
+            ipv6ExtHeaderBuilder.setIpv6Exthdr(bitmap);
+            byte[] mask = ipv6Exthdr.getMask();
+
+            if (mask != null) {
+                ipv6ExtHeaderBuilder.setIpv6ExthdrMask(ByteUtil.bytesToUnsignedShort(mask));
+            }
+
+            ipv6MatchBuilder.setIpv6ExtHeader(ipv6ExtHeaderBuilder.build());
+            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6FlabelCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6FlabelCase.java
new file mode 100644 (file)
index 0000000..9767932
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel;
+
+public class OfToSalIpv6FlabelCase extends ConvertorCase<Ipv6FlabelCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6FlabelCase() {
+        super(Ipv6FlabelCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6FlabelCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+
+        Ipv6Flabel ipv6Flabel = source.getIpv6Flabel();
+
+        if (ipv6Flabel != null) {
+            Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
+            ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(ipv6Flabel.getIpv6Flabel()));
+            byte[] mask = ipv6Flabel.getMask();
+
+            if (mask != null) {
+                ipv6LabelBuilder.setFlabelMask(new Ipv6FlowLabel(ByteUtil.bytesToUnsignedInt(mask)));
+            }
+
+            ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
+            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdSllCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdSllCase.java
new file mode 100644 (file)
index 0000000..15d83ce
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSll;
+
+public class OfToSalIpv6NdSllCase extends ConvertorCase<Ipv6NdSllCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6NdSllCase() {
+        super(Ipv6NdSllCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6NdSllCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+
+        Ipv6NdSll ipv6NdSll = source.getIpv6NdSll();
+
+        if (ipv6NdSll != null) {
+            ipv6MatchBuilder.setIpv6NdSll(ipv6NdSll.getMacAddress());
+            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdTargetCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdTargetCase.java
new file mode 100644 (file)
index 0000000..667a5e6
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTarget;
+
+public class OfToSalIpv6NdTargetCase extends ConvertorCase<Ipv6NdTargetCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6NdTargetCase() {
+        super(Ipv6NdTargetCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6NdTargetCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+
+        Ipv6NdTarget ipv6NdTarget = source.getIpv6NdTarget();
+
+        if (ipv6NdTarget != null) {
+            ipv6MatchBuilder.setIpv6NdTarget(ipv6NdTarget.getIpv6Address());
+            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdTllCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6NdTllCase.java
new file mode 100644 (file)
index 0000000..7f84187
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTll;
+
+public class OfToSalIpv6NdTllCase extends ConvertorCase<Ipv6NdTllCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6NdTllCase() {
+        super(Ipv6NdTllCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6NdTllCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+
+        Ipv6NdTll ipv6NdTll = source.getIpv6NdTll();
+
+        if (ipv6NdTll != null) {
+            ipv6MatchBuilder.setIpv6NdTll(ipv6NdTll.getMacAddress());
+            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6SrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalIpv6SrcCase.java
new file mode 100644 (file)
index 0000000..2cb8803
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6Src;
+
+public class OfToSalIpv6SrcCase extends ConvertorCase<Ipv6SrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalIpv6SrcCase() {
+        super(Ipv6SrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv6SrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
+        final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = data.getIpv6MatchArbitraryBitMaskBuilder();
+
+        Ipv6Src ipv6Src = source.getIpv6Src();
+
+        if (ipv6Src != null) {
+            byte[] mask = ipv6Src.getMask();
+            if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
+                // case where ipv6dst is of type ipv6MatchBuilder and ipv6src is of type ipv6MatchArbitrary.
+                // Need to convert ipv6dst to ipv6MatchArbitrary.
+
+                if (ipv6MatchBuilder.getIpv6Destination() != null) {
+                    Ipv6Prefix ipv6PrefixDestinationAddress = ipv6MatchBuilder.getIpv6Destination();
+                    Ipv6Address ipv6DstAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixDestinationAddress);
+                    Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
+                            IpConversionUtil.extractIpv6AddressMask(ipv6PrefixDestinationAddress));
+                    setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder,
+                            dstIpv6ArbitraryMask, IpConversionUtil.compressedIpv6Format(ipv6DstAddress.getValue()));
+                }
+                Ipv6ArbitraryMask srcIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
+                        IpConversionUtil.createIpv6ArbitraryBitMask(mask));
+                String stringIpv6SrcAddress = IpConversionUtil.compressedIpv6Format(ipv6Src.getIpv6Address().getValue());
+                setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder,
+                        srcIpv6ArbitraryMask, stringIpv6SrcAddress);
+                matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
+            } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6DestinationAddressNoMask() != null) {
+                         /*
+                         TODO Change comments
+                        Case where destination is of type ipv6MatchArbitraryBitMask already exists in Layer3Match,
+                        source which of type ipv6Match needs to be converted to ipv4MatchArbitraryBitMask.
+                        We convert 1::/32 to 1::/FFFF:FFFF::
+                        example:-
+                        <ipv6-source>1::/32</ipv4-source>
+                        <ipv6-destination-address-no-mask>1::1</ipv6-destination-address-no-mask>
+                        <ipv6-destination-arbitrary-bitmask>FFFF::0001</ipv6-destination-arbitrary-bitmask>
+                        after conversion output example:-
+                        <ipv6-source-address-no-mask>1::</ipv6-source-address-no-mask>
+                        <ipv6-source-arbitrary-bitmask>FFFF:FFFF::</ipv6-source-arbitrary-bitmask>
+                        <ipv6-destination-address-no-mask>1::1</ipv6-destination-address-no-mask>
+                        <ipv6-destination-arbitrary-bitmask>FFFF::0001</ipv6-destination-arbitrary-bitmask>
+                        */
+                Ipv6ArbitraryMask srcIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(
+                        IpConversionUtil.createIpv6ArbitraryBitMask(mask));
+                String stringIpv6SrcAddress = IpConversionUtil.compressedIpv6Format(ipv6Src.getIpv6Address().getValue());
+                setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder,
+                        srcIpv6ArbitraryMask, stringIpv6SrcAddress);
+                matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
+            } else {
+                String stringIpv6SrcAddress = IpConversionUtil.compressedIpv6Format(ipv6Src.getIpv6Address().getValue());
+                setIpv6MatchBuilderFields(ipv6MatchBuilder, mask, stringIpv6SrcAddress);
+                matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
+            }
+        }
+
+        return Optional.of(matchBuilder);
+    }
+
+    private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder ipv6MatchBuilder, final byte[] mask, final String ipv6PrefixStr) {
+        Ipv6Prefix ipv6Prefix;
+
+        if (mask != null) {
+            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr), mask);
+        } else {
+            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr));
+        }
+
+        ipv6MatchBuilder.setIpv6Source(ipv6Prefix);
+    }
+
+    private static void setSrcIpv6MatchArbitraryBitMaskBuilderFields(
+            final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder,
+            final Ipv6ArbitraryMask mask, final String ipv6AddressStr) {
+        Ipv6Address ipv6Address;
+        if (mask != null) {
+            ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceArbitraryBitmask(mask);
+        }
+        ipv6Address = new Ipv6Address(ipv6AddressStr);
+        ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceAddressNoMask(ipv6Address);
+    }
+
+    private static void setDstIpv6MatchArbitraryBitMaskBuilderFields(
+            final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder,
+            final Ipv6ArbitraryMask mask, final String ipv6AddressStr) {
+        Ipv6Address ipv6Address;
+        if (mask != null) {
+            ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationArbitraryBitmask(mask);
+        }
+        ipv6Address = new Ipv6Address(ipv6AddressStr);
+        ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationAddressNoMask(ipv6Address);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMetadataCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMetadataCase.java
new file mode 100644 (file)
index 0000000..9f92494
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.math.BigInteger;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata;
+
+public class OfToSalMetadataCase extends ConvertorCase<MetadataCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalMetadataCase() {
+        super(MetadataCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull MetadataCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final MetadataBuilder metadataBuilder = new MetadataBuilder();
+        final Metadata metadata = source.getMetadata();
+
+        if (metadata != null) {
+            metadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, metadata.getMetadata()));
+            byte[] metadataMask = metadata.getMask();
+
+            if (metadataMask != null) {
+                metadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, metadataMask));
+            }
+
+            matchBuilder.setMetadata(metadataBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsBosCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsBosCase.java
new file mode 100644 (file)
index 0000000..38ae6c2
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos;
+
+public class OfToSalMplsBosCase extends ConvertorCase<MplsBosCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalMplsBosCase() {
+        super(MplsBosCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull MplsBosCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder();
+
+        MplsBos mplsBos = source.getMplsBos();
+
+        if (mplsBos != null) {
+            protocolMatchFieldsBuilder.setMplsBos(mplsBos.isBos() ? (short) 1 : (short) 0);
+            matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsLabelCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsLabelCase.java
new file mode 100644 (file)
index 0000000..cf53c8b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabel;
+
+public class OfToSalMplsLabelCase extends ConvertorCase<MplsLabelCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalMplsLabelCase() {
+        super(MplsLabelCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull MplsLabelCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder();
+
+        MplsLabel mplsLabel = source.getMplsLabel();
+
+        if (mplsLabel != null) {
+            protocolMatchFieldsBuilder.setMplsLabel(mplsLabel.getMplsLabel());
+            matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsTcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalMplsTcCase.java
new file mode 100644 (file)
index 0000000..6fcc8d7
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTc;
+
+public class OfToSalMplsTcCase extends ConvertorCase<MplsTcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalMplsTcCase() {
+        super(MplsTcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull MplsTcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder();
+
+        MplsTc mplsTc = source.getMplsTc();
+
+        if (mplsTc != null) {
+            protocolMatchFieldsBuilder.setMplsTc(mplsTc.getTc());
+            matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPbbIsidCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPbbIsidCase.java
new file mode 100644 (file)
index 0000000..57b876c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsid;
+
+public class OfToSalPbbIsidCase extends ConvertorCase<PbbIsidCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalPbbIsidCase() {
+        super(PbbIsidCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull PbbIsidCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder();
+
+        PbbIsid pbbIsid = source.getPbbIsid();
+
+        if (pbbIsid != null) {
+            PbbBuilder pbbBuilder = new PbbBuilder();
+            pbbBuilder.setPbbIsid(pbbIsid.getIsid());
+            byte[] mask = pbbIsid.getMask();
+
+            if (mask != null) {
+                pbbBuilder.setPbbMask(ByteUtil.bytesToUnsignedMedium(mask));
+            }
+
+            protocolMatchFieldsBuilder.setPbb(pbbBuilder.build());
+            matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalSctpDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalSctpDstCase.java
new file mode 100644 (file)
index 0000000..7046a9b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDst;
+
+public class OfToSalSctpDstCase extends ConvertorCase<SctpDstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalSctpDstCase() {
+        super(SctpDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull SctpDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final SctpMatchBuilder sctpMatchBuilder = data.getSctpMatchBuilder();
+
+        SctpDst sctpDst = source.getSctpDst();
+        PortNumber portNumber = sctpDst.getPort();
+
+        if (portNumber != null) {
+            sctpMatchBuilder.setSctpDestinationPort(portNumber);
+            matchBuilder.setLayer4Match(sctpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalSctpSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalSctpSrcCase.java
new file mode 100644 (file)
index 0000000..d9549a8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrc;
+
+public class OfToSalSctpSrcCase extends ConvertorCase<SctpSrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalSctpSrcCase() {
+        super(SctpSrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull SctpSrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final SctpMatchBuilder sctpMatchBuilder = data.getSctpMatchBuilder();
+
+        SctpSrc sctpSrc = source.getSctpSrc();
+        PortNumber portNumber = sctpSrc.getPort();
+
+        if (portNumber != null) {
+            sctpMatchBuilder.setSctpSourcePort(portNumber);
+            matchBuilder.setLayer4Match(sctpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTcpDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTcpDstCase.java
new file mode 100644 (file)
index 0000000..6dcee21
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDst;
+
+public class OfToSalTcpDstCase extends ConvertorCase<TcpDstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalTcpDstCase() {
+        super(TcpDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull TcpDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final TcpMatchBuilder tcpMatchBuilder = data.getTcpMatchBuilder();
+
+        TcpDst tcpDst = source.getTcpDst();
+        PortNumber portNumber = tcpDst.getPort();
+
+        if (portNumber != null) {
+            tcpMatchBuilder.setTcpDestinationPort(portNumber);
+            matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTcpSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTcpSrcCase.java
new file mode 100644 (file)
index 0000000..503cabe
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrc;
+
+public class OfToSalTcpSrcCase extends ConvertorCase<TcpSrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalTcpSrcCase() {
+        super(TcpSrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull TcpSrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final TcpMatchBuilder tcpMatchBuilder = data.getTcpMatchBuilder();
+
+        TcpSrc tcpSrc = source.getTcpSrc();
+
+        if (tcpSrc != null) {
+            tcpMatchBuilder.setTcpSourcePort(tcpSrc.getPort());
+            matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIdCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIdCase.java
new file mode 100644 (file)
index 0000000..dab5b3c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.math.BigInteger;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelId;
+
+public class OfToSalTunnelIdCase extends ConvertorCase<TunnelIdCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalTunnelIdCase() {
+        super(TunnelIdCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull TunnelIdCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+
+        TunnelId tunnelId = source.getTunnelId();
+        TunnelBuilder tunnelBuilder = new TunnelBuilder();
+
+        if (tunnelId.getTunnelId() != null) {
+            tunnelBuilder.setTunnelId(new BigInteger(OFConstants.SIGNUM_UNSIGNED, tunnelId.getTunnelId()));
+            byte[] mask = tunnelId.getMask();
+
+            if (null != mask) {
+                tunnelBuilder.setTunnelMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, mask));
+            }
+
+            matchBuilder.setTunnel(tunnelBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIpv4DstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIpv4DstCase.java
new file mode 100644 (file)
index 0000000..e5e5bab
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.nio.ByteBuffer;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4Dst;
+
+public class OfToSalTunnelIpv4DstCase extends ConvertorCase<Ipv4DstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalTunnelIpv4DstCase() {
+        super(Ipv4DstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv4DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
+        final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = data.getTunnelIpv4MatchBuilder();
+
+        Ipv4Dst tunnelIpv4Dst = source.getIpv4Dst();
+        if (tunnelIpv4Dst != null) {
+            String ipv4PrefixStr = tunnelIpv4Dst.getIpv4Address().getValue();
+            byte[] mask = tunnelIpv4Dst.getMask();
+            ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + ByteBuffer.wrap(tunnelIpv4Dst.getMask()).getInt();
+            final Ipv4Prefix ipv4Prefix;
+
+            if (mask != null) {
+                ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
+            } else {
+                //Openflow Spec : 1.3.2
+                //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
+                // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
+                // statistics response.
+                ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
+            }
+
+            ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
+            matchBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIpv4SrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalTunnelIpv4SrcCase.java
new file mode 100644 (file)
index 0000000..c84d942
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.nio.ByteBuffer;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4Src;
+
+public class OfToSalTunnelIpv4SrcCase extends ConvertorCase<Ipv4SrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalTunnelIpv4SrcCase() {
+        super(Ipv4SrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull Ipv4SrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
+        final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = data.getTunnelIpv4MatchBuilder();
+
+        Ipv4Src tunnelIpv4Dst = source.getIpv4Src();
+
+        if (tunnelIpv4Dst != null) {
+            String ipv4PrefixStr = tunnelIpv4Dst.getIpv4Address().getValue();
+            byte[] mask = tunnelIpv4Dst.getMask();
+            ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + ByteBuffer.wrap(tunnelIpv4Dst.getMask()).getInt();
+
+            final Ipv4Prefix ipv4Prefix;
+            if (mask != null) {
+                ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
+            } else {
+                //Openflow Spec : 1.3.2
+                //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
+                // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
+                // statistics response.
+                ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
+            }
+
+            ipv4MatchBuilder.setIpv4Source(ipv4Prefix);
+            matchBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalUdpDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalUdpDstCase.java
new file mode 100644 (file)
index 0000000..c3cacff
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDst;
+
+public class OfToSalUdpDstCase extends ConvertorCase<UdpDstCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalUdpDstCase() {
+        super(UdpDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull UdpDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final UdpMatchBuilder udpMatchBuilder = data.getUdpMatchBuilder();
+
+        UdpDst udpDst = source.getUdpDst();
+
+        if (udpDst != null) {
+            udpMatchBuilder.setUdpDestinationPort(udpDst.getPort());
+            matchBuilder.setLayer4Match(udpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalUdpSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalUdpSrcCase.java
new file mode 100644 (file)
index 0000000..0dcf7f2
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrc;
+
+public class OfToSalUdpSrcCase extends ConvertorCase<UdpSrcCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalUdpSrcCase() {
+        super(UdpSrcCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull UdpSrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final UdpMatchBuilder udpMatchBuilder = data.getUdpMatchBuilder();
+
+        UdpSrc udpSrc = source.getUdpSrc();
+
+        if (udpSrc != null) {
+            udpMatchBuilder.setUdpSourcePort(udpSrc.getPort());
+            matchBuilder.setLayer4Match(udpMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalVlanPcpCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalVlanPcpCase.java
new file mode 100644 (file)
index 0000000..b862a46
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcp;
+
+public class OfToSalVlanPcpCase extends ConvertorCase<VlanPcpCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalVlanPcpCase() {
+        super(VlanPcpCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull VlanPcpCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final VlanMatchBuilder vlanMatchBuilder = data.getVlanMatchBuilder();
+
+        final VlanPcp vlanPcp = source.getVlanPcp();
+
+        if (vlanPcp != null) {
+            vlanMatchBuilder
+                    .setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(
+                            vlanPcp.getVlanPcp()));
+            matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalVlanVidCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalVlanVidCase.java
new file mode 100644 (file)
index 0000000..edff8c6
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVid;
+
+public class OfToSalVlanVidCase extends ConvertorCase<VlanVidCase, MatchBuilder, MatchResponseConvertorData> {
+    public OfToSalVlanVidCase() {
+        super(VlanVidCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+    }
+
+    @Override
+    public Optional<MatchBuilder> process(@Nonnull VlanVidCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        final MatchBuilder matchBuilder = data.getMatchBuilder();
+        final VlanMatchBuilder vlanMatchBuilder = data.getVlanMatchBuilder();
+
+        final VlanVid vlanVid = source.getVlanVid();
+
+        if (vlanVid != null) {
+            VlanIdBuilder vlanBuilder = new VlanIdBuilder();
+            vlanBuilder.setVlanId(new VlanId(vlanVid.getVlanVid()));
+            vlanBuilder.setVlanIdPresent(vlanVid.isCfiBit());
+            vlanMatchBuilder.setVlanId(vlanBuilder.build());
+            matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+        }
+
+        return Optional.of(matchBuilder);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfArpMatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfArpMatchCase.java
new file mode 100644 (file)
index 0000000..6ba10bd
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder;
+
+public class SalToOfArpMatchCase extends ConvertorCase<ArpMatch, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfArpMatchCase() {
+        super(ArpMatch.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull ArpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getArpOp() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setOxmMatchField(ArpOp.class);
+            ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
+            ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
+            arpOpBuilder.setOpCode(source.getArpOp());
+            arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getArpSourceTransportAddress() != null) {
+            Ipv4Prefix ipv4Prefix = source.getArpSourceTransportAddress();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(ArpSpa.class);
+
+            ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
+            ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
+
+            Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
+            Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+            arpSpaBuilder.setIpv4Address(ipv4Address);
+            boolean hasMask = false;
+            byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
+            if (null != mask) {
+                arpSpaBuilder.setMask(mask);
+                hasMask = true;
+            }
+            matchEntryBuilder.setHasMask(hasMask);
+            arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getArpTargetTransportAddress() != null) {
+            Ipv4Prefix ipv4Prefix = source.getArpTargetTransportAddress();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(ArpTpa.class);
+
+            ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
+            ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
+
+            Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
+            Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+            arpTpaBuilder.setIpv4Address(ipv4Address);
+            boolean hasMask = false;
+            byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
+            if (null != mask) {
+                arpTpaBuilder.setMask(mask);
+                hasMask = true;
+            }
+            matchEntryBuilder.setHasMask(hasMask);
+            arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        ArpSourceHardwareAddress arpSourceHardwareAddress = source.getArpSourceHardwareAddress();
+        if (arpSourceHardwareAddress != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(ArpSha.class);
+
+            ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
+            ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
+            arpShaBuilder.setMacAddress(arpSourceHardwareAddress.getAddress());
+            boolean hasMask = false;
+            if (null != arpSourceHardwareAddress.getMask()) {
+                arpShaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpSourceHardwareAddress.getMask().getValue()));
+                hasMask = true;
+            }
+            arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasMask);
+            result.add(matchEntryBuilder.build());
+        }
+
+        ArpTargetHardwareAddress arpTargetHardwareAddress = source.getArpTargetHardwareAddress();
+        if (arpTargetHardwareAddress != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(ArpTha.class);
+
+            ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
+            ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
+            arpThaBuilder.setMacAddress(arpTargetHardwareAddress.getAddress());
+            boolean hasMask = false;
+            if (null != arpTargetHardwareAddress.getMask()) {
+                arpThaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpTargetHardwareAddress.getMask().getValue()));
+                hasMask = true;
+            }
+            arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasMask);
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv4MatchArbitraryBitMaskCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv4MatchArbitraryBitMaskCase.java
new file mode 100644 (file)
index 0000000..b8cca51
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+
+public class SalToOfIpv4MatchArbitraryBitMaskCase extends ConvertorCase<Ipv4MatchArbitraryBitMask, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfIpv4MatchArbitraryBitMaskCase() {
+        super(Ipv4MatchArbitraryBitMask.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull Ipv4MatchArbitraryBitMask source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getIpv4SourceAddressNoMask() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
+
+            Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+            Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+
+            ipv4SrcBuilder.setIpv4Address(source.getIpv4SourceAddressNoMask());
+            DottedQuad sourceArbitrarySubNetMask = source.getIpv4SourceArbitraryBitmask();
+
+            boolean hasMask = false;
+            if (sourceArbitrarySubNetMask != null) {
+                byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
+                if (maskByteArray != null) {
+                    ipv4SrcBuilder.setMask(maskByteArray);
+                    hasMask = true;
+                }
+            }
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv4DestinationAddressNoMask() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
+
+            Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+            Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
+
+            ipv4DstBuilder.setIpv4Address(source.getIpv4DestinationAddressNoMask());
+            DottedQuad destArbitrarySubNetMask = source.getIpv4DestinationArbitraryBitmask();
+
+            boolean hasMask = false;
+            if (destArbitrarySubNetMask != null) {
+                byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(destArbitrarySubNetMask);
+                if (maskByteArray != null) {
+                    ipv4DstBuilder.setMask(maskByteArray);
+                    hasMask = true;
+                }
+            }
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv4MatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv4MatchCase.java
new file mode 100644 (file)
index 0000000..490575c
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+
+public class SalToOfIpv4MatchCase extends ConvertorCase<Ipv4Match, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfIpv4MatchCase() {
+        super(Ipv4Match.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull Ipv4Match source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getIpv4Source() != null) {
+            Ipv4Prefix ipv4Prefix = source.getIpv4Source();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
+
+            Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+            Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+
+            Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
+            Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+            ipv4SrcBuilder.setIpv4Address(ipv4Address);
+            boolean hasMask = false;
+            byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
+
+            if (null != mask) {
+                ipv4SrcBuilder.setMask(mask);
+                hasMask = true;
+            }
+
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv4Destination() != null) {
+            Ipv4Prefix ipv4Prefix = source.getIpv4Destination();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
+
+            Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+            Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
+
+            Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
+            Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+            ipv4DstBuilder.setIpv4Address(ipv4Address);
+            boolean hasMask = false;
+            byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
+
+            if (null != mask) {
+                ipv4DstBuilder.setMask(mask);
+                hasMask = true;
+            }
+
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchArbitraryBitMaskCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchArbitraryBitMaskCase.java
new file mode 100644 (file)
index 0000000..0f1056c
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
+
+public class SalToOfIpv6MatchArbitraryBitMaskCase extends ConvertorCase<Ipv6MatchArbitraryBitMask, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfIpv6MatchArbitraryBitMaskCase() {
+        super(Ipv6MatchArbitraryBitMask.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull Ipv6MatchArbitraryBitMask source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getIpv6SourceAddressNoMask() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
+
+            Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+            Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+            ipv6SrcBuilder.setIpv6Address(source.getIpv6SourceAddressNoMask());
+            Ipv6ArbitraryMask sourceArbitrarySubNetMask = source.getIpv6SourceArbitraryBitmask();
+            boolean hasMask = false;
+            if (sourceArbitrarySubNetMask != null) {
+                byte[] maskByteArray = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
+                if (maskByteArray != null) {
+                    ipv6SrcBuilder.setMask(maskByteArray);
+                    hasMask = true;
+                }
+            }
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv6DestinationAddressNoMask() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
+
+            Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+            Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
+
+            ipv6DstBuilder.setIpv6Address(source.getIpv6DestinationAddressNoMask());
+            Ipv6ArbitraryMask destinationArbitrarySubNetMask = source.getIpv6DestinationArbitraryBitmask();
+
+            boolean hasMask = false;
+            if (destinationArbitrarySubNetMask != null) {
+                byte[] maskByteArray = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(destinationArbitrarySubNetMask);
+                if (maskByteArray != null) {
+                    ipv6DstBuilder.setMask(maskByteArray);
+                    hasMask = true;
+                }
+            }
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfIpv6MatchCase.java
new file mode 100644 (file)
index 0000000..ed9f8eb
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
+
+public class SalToOfIpv6MatchCase extends ConvertorCase<Ipv6Match, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfIpv6MatchCase() {
+        super(Ipv6Match.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull Ipv6Match source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getIpv6Source() != null) {
+            Ipv6Prefix ipv6Prefix = source.getIpv6Source();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
+
+            Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+            Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+            final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
+            boolean hasMask = false;
+            if (null != prefix) {
+                ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+                hasMask = true;
+            }
+            ipv6SrcBuilder.setIpv6Address(IpConversionUtil.extractIpv6Address(ipv6Prefix));
+            ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+            matchEntryBuilder.setHasMask(hasMask);
+            matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv6Destination() != null) {
+            Ipv6Prefix ipv6Prefix = source.getIpv6Destination();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
+
+            Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+            Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
+            final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
+            boolean hasMask = false;
+            if (null != prefix) {
+                ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+                hasMask = true;
+            }
+            ipv6DstBuilder.setIpv6Address(IpConversionUtil.extractIpv6Address(ipv6Prefix));
+            ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+            matchEntryBuilder.setHasMask(hasMask);
+            matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv6Label() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            boolean hasmask = false;
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Flabel.class);
+            Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
+            Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
+            ipv6FlabelBuilder.setIpv6Flabel(source.getIpv6Label().getIpv6Flabel());
+
+            if (source.getIpv6Label().getFlabelMask() != null) {
+                hasmask = true;
+                ipv6FlabelBuilder.setMask(ByteUtil.unsignedIntToBytes(source.getIpv6Label().getFlabelMask().getValue()));
+            }
+
+            ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasmask);
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv6NdTarget() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setHasMask(false);
+            matchEntryBuilder.setOxmMatchField(Ipv6NdTarget.class);
+
+            Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
+            Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
+            ipv6NdTargetBuilder.setIpv6Address(source.getIpv6NdTarget());
+            ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv6NdSll() != null) {
+            MacAddress ipv6NdSll = source.getIpv6NdSll();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6NdSll.class);
+
+            Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();
+            Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();
+            ipv6NdSllBuilder.setMacAddress(ipv6NdSll);
+            ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getIpv6NdTll() != null) {
+            MacAddress ipv6NdSll = source.getIpv6NdTll();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6NdTll.class);
+
+            Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();
+            Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();
+            ipv6NdTllBuilder.setMacAddress(ipv6NdSll);
+            ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+
+        }
+
+        if (source.getIpv6ExtHeader() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            boolean hasmask = false;
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv6Exthdr.class);
+            Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
+            Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
+
+            Integer bitmap = source.getIpv6ExtHeader().getIpv6Exthdr();
+            final Boolean NONEXT = ((bitmap) & (1)) != 0;
+            final Boolean ESP = ((bitmap) & (1 << 1)) != 0;
+            final Boolean AUTH = ((bitmap) & (1 << 2)) != 0;
+            final Boolean DEST = ((bitmap) & (1 << 3)) != 0;
+            final Boolean FRAG = ((bitmap) & (1 << 4)) != 0;
+            final Boolean ROUTER = ((bitmap) & (1 << 5)) != 0;
+            final Boolean HOP = ((bitmap) & (1 << 6)) != 0;
+            final Boolean UNREP = ((bitmap) & (1 << 7)) != 0;
+            final Boolean UNSEQ = ((bitmap) & (1 << 8)) != 0;
+
+            ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));
+
+            if (source.getIpv6ExtHeader().getIpv6ExthdrMask() != null) {
+                hasmask = true;
+                ipv6ExthdrBuilder.setMask(ByteUtil.unsignedShortToBytes(source.getIpv6ExtHeader().getIpv6ExthdrMask()));
+            }
+
+            ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
+            matchEntryBuilder.setHasMask(hasmask);
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfSctpMatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfSctpMatchCase.java
new file mode 100644 (file)
index 0000000..e819731
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder;
+
+public class SalToOfSctpMatchCase extends ConvertorCase<SctpMatch, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfSctpMatchCase() {
+        super(SctpMatch.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull SctpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getSctpSourcePort() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(SctpSrc.class);
+
+            SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();
+            SctpSrcBuilder sctpSrcBuilder = new SctpSrcBuilder();
+            sctpSrcBuilder.setPort(source.getSctpSourcePort());
+            sctpSrcCaseBuilder.setSctpSrc(sctpSrcBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getSctpDestinationPort() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(SctpDst.class);
+
+            SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();
+            SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();
+            sctpDstBuilder.setPort(source.getSctpDestinationPort());
+            sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(sctpDstCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfTcpMatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfTcpMatchCase.java
new file mode 100644 (file)
index 0000000..61c5800
--- /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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;
+
+public class SalToOfTcpMatchCase extends ConvertorCase<TcpMatch, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfTcpMatchCase() {
+        super(TcpMatch.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull TcpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getTcpSourcePort() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(TcpSrc.class);
+
+            TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
+            TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
+            tcpSrcBuilder.setPort(source.getTcpSourcePort());
+            tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
+
+            matchEntryBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getTcpDestinationPort() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(TcpDst.class);
+
+            TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
+            TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
+            tcpDstBuilder.setPort(source.getTcpDestinationPort());
+            tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfTunnelIpv4MatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfTunnelIpv4MatchCase.java
new file mode 100644 (file)
index 0000000..6b85e17
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+
+public class SalToOfTunnelIpv4MatchCase extends ConvertorCase<TunnelIpv4Match, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfTunnelIpv4MatchCase() {
+        super(TunnelIpv4Match.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull TunnelIpv4Match source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getTunnelIpv4Source() != null) {
+            Ipv4Prefix ipv4Prefix = source.getTunnelIpv4Source();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
+
+            Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+            Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+
+            Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
+            Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+            ipv4SrcBuilder.setIpv4Address(ipv4Address);
+            boolean hasMask = false;
+            byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
+
+            if (null != mask) {
+                ipv4SrcBuilder.setMask(mask);
+                hasMask = true;
+            }
+
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getTunnelIpv4Destination() != null) {
+            Ipv4Prefix ipv4Prefix = source.getTunnelIpv4Destination();
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
+
+            Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+            Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
+
+            Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
+            Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+            ipv4DstBuilder.setIpv4Address(ipv4Address);
+            boolean hasMask = false;
+            byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
+
+            if (null != mask) {
+                ipv4DstBuilder.setMask(mask);
+                hasMask = true;
+            }
+
+            matchEntryBuilder.setHasMask(hasMask);
+            ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfUdpMatchCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/SalToOfUdpMatchCase.java
new file mode 100644 (file)
index 0000000..3979863
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
+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.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;
+
+public class SalToOfUdpMatchCase extends ConvertorCase<UdpMatch, List<MatchEntry>, VersionConvertorData> {
+    public SalToOfUdpMatchCase() {
+        super(UdpMatch.class, true);
+    }
+
+    @Override
+    public Optional<List<MatchEntry>> process(@Nonnull UdpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
+        List<MatchEntry> result = new ArrayList<>();
+
+        if (source.getUdpSourcePort() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(UdpSrc.class);
+
+            UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
+            UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
+            udpSrcBuilder.setPort(source.getUdpSourcePort());
+            udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        if (source.getUdpDestinationPort() != null) {
+            MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+            matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntryBuilder.setOxmMatchField(UdpDst.class);
+
+            UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
+            UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
+            udpDstBuilder.setPort(source.getUdpDestinationPort());
+            udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
+            matchEntryBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
+            matchEntryBuilder.setHasMask(false);
+            result.add(matchEntryBuilder.build());
+        }
+
+        return Optional.of(result);
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/data/MatchResponseConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/data/MatchResponseConvertorData.java
new file mode 100644 (file)
index 0000000..2cf350e
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * 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.openflow.md.core.sal.convertor.match.data;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+
+/**
+ * Convertor data used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor}
+ * containing Openflow version, datapath ID and various builders, because match response convertor cases depends
+ * on each other and requires shared builders
+ */
+public class MatchResponseConvertorData extends VersionDatapathIdConvertorData {
+    private MatchBuilder matchBuilder;
+    private EthernetMatchBuilder ethernetMatchBuilder;
+    private VlanMatchBuilder vlanMatchBuilder;
+    private IpMatchBuilder ipMatchBuilder;
+    private TcpMatchBuilder tcpMatchBuilder;
+    private UdpMatchBuilder udpMatchBuilder;
+    private SctpMatchBuilder sctpMatchBuilder;
+    private Icmpv4MatchBuilder icmpv4MatchBuilder;
+    private Icmpv6MatchBuilder icmpv6MatchBuilder;
+    private Ipv4MatchBuilder ipv4MatchBuilder;
+    private Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder;
+    private Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder;
+    private ArpMatchBuilder arpMatchBuilder;
+    private Ipv6MatchBuilder ipv6MatchBuilder;
+    private ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder;
+    private TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder;
+    private TcpFlagsMatchBuilder tcpFlagsMatchBuilder;
+    private Class<? extends MatchField> oxmMatchField;
+
+    /**
+     * Instantiates a new Match convertor data.
+     *
+     * @param version the version
+     */
+    public MatchResponseConvertorData(short version) {
+        super(version);
+    }
+
+    /**
+     * Gets match builder.
+     *
+     * @return the match builder
+     */
+    public MatchBuilder getMatchBuilder() {
+        return matchBuilder;
+    }
+
+    /**
+     * Sets match builder.
+     *
+     * @param matchBuilder the match builder
+     */
+    public void setMatchBuilder(MatchBuilder matchBuilder) {
+        this.matchBuilder = matchBuilder;
+    }
+
+    /**
+     * Gets ethernet match builder.
+     *
+     * @return the ethernet match builder
+     */
+    public EthernetMatchBuilder getEthernetMatchBuilder() {
+        return ethernetMatchBuilder;
+    }
+
+    /**
+     * Sets ethernet match builder.
+     *
+     * @param ethernetMatchBuilder the ethernet match builder
+     */
+    public void setEthernetMatchBuilder(EthernetMatchBuilder ethernetMatchBuilder) {
+        this.ethernetMatchBuilder = ethernetMatchBuilder;
+    }
+
+    /**
+     * Gets vlan match builder.
+     *
+     * @return the vlan match builder
+     */
+    public VlanMatchBuilder getVlanMatchBuilder() {
+        return vlanMatchBuilder;
+    }
+
+    /**
+     * Sets vlan match builder.
+     *
+     * @param vlanMatchBuilder the vlan match builder
+     */
+    public void setVlanMatchBuilder(VlanMatchBuilder vlanMatchBuilder) {
+        this.vlanMatchBuilder = vlanMatchBuilder;
+    }
+
+    /**
+     * Gets ip match builder.
+     *
+     * @return the ip match builder
+     */
+    public IpMatchBuilder getIpMatchBuilder() {
+        return ipMatchBuilder;
+    }
+
+    /**
+     * Sets ip match builder.
+     *
+     * @param ipMatchBuilder the ip match builder
+     */
+    public void setIpMatchBuilder(IpMatchBuilder ipMatchBuilder) {
+        this.ipMatchBuilder = ipMatchBuilder;
+    }
+
+    /**
+     * Gets tcp match builder.
+     *
+     * @return the tcp match builder
+     */
+    public TcpMatchBuilder getTcpMatchBuilder() {
+        return tcpMatchBuilder;
+    }
+
+    /**
+     * Sets tcp match builder.
+     *
+     * @param tcpMatchBuilder the tcp match builder
+     */
+    public void setTcpMatchBuilder(TcpMatchBuilder tcpMatchBuilder) {
+        this.tcpMatchBuilder = tcpMatchBuilder;
+    }
+
+    /**
+     * Gets udp match builder.
+     *
+     * @return the udp match builder
+     */
+    public UdpMatchBuilder getUdpMatchBuilder() {
+        return udpMatchBuilder;
+    }
+
+    /**
+     * Sets udp match builder.
+     *
+     * @param udpMatchBuilder the udp match builder
+     */
+    public void setUdpMatchBuilder(UdpMatchBuilder udpMatchBuilder) {
+        this.udpMatchBuilder = udpMatchBuilder;
+    }
+
+    /**
+     * Gets sctp match builder.
+     *
+     * @return the sctp match builder
+     */
+    public SctpMatchBuilder getSctpMatchBuilder() {
+        return sctpMatchBuilder;
+    }
+
+    /**
+     * Sets sctp match builder.
+     *
+     * @param sctpMatchBuilder the sctp match builder
+     */
+    public void setSctpMatchBuilder(SctpMatchBuilder sctpMatchBuilder) {
+        this.sctpMatchBuilder = sctpMatchBuilder;
+    }
+
+    /**
+     * Gets icmpv 4 match builder.
+     *
+     * @return the icmpv 4 match builder
+     */
+    public Icmpv4MatchBuilder getIcmpv4MatchBuilder() {
+        return icmpv4MatchBuilder;
+    }
+
+    /**
+     * Sets icmpv 4 match builder.
+     *
+     * @param icmpv4MatchBuilder the icmpv 4 match builder
+     */
+    public void setIcmpv4MatchBuilder(Icmpv4MatchBuilder icmpv4MatchBuilder) {
+        this.icmpv4MatchBuilder = icmpv4MatchBuilder;
+    }
+
+    /**
+     * Gets icmpv 6 match builder.
+     *
+     * @return the icmpv 6 match builder
+     */
+    public Icmpv6MatchBuilder getIcmpv6MatchBuilder() {
+        return icmpv6MatchBuilder;
+    }
+
+    /**
+     * Sets icmpv 6 match builder.
+     *
+     * @param icmpv6MatchBuilder the icmpv 6 match builder
+     */
+    public void setIcmpv6MatchBuilder(Icmpv6MatchBuilder icmpv6MatchBuilder) {
+        this.icmpv6MatchBuilder = icmpv6MatchBuilder;
+    }
+
+    /**
+     * Gets ipv 4 match builder.
+     *
+     * @return the ipv 4 match builder
+     */
+    public Ipv4MatchBuilder getIpv4MatchBuilder() {
+        return ipv4MatchBuilder;
+    }
+
+    /**
+     * Sets ipv 4 match builder.
+     *
+     * @param ipv4MatchBuilder the ipv 4 match builder
+     */
+    public void setIpv4MatchBuilder(Ipv4MatchBuilder ipv4MatchBuilder) {
+        this.ipv4MatchBuilder = ipv4MatchBuilder;
+    }
+
+    /**
+     * Gets ipv 4 match arbitrary bit mask builder.
+     *
+     * @return the ipv 4 match arbitrary bit mask builder
+     */
+    public Ipv4MatchArbitraryBitMaskBuilder getIpv4MatchArbitraryBitMaskBuilder() {
+        return ipv4MatchArbitraryBitMaskBuilder;
+    }
+
+    /**
+     * Sets ipv 4 match arbitrary bit mask builder.
+     *
+     * @param ipv4MatchArbitraryBitMaskBuilder the ipv 4 match arbitrary bit mask builder
+     */
+    public void setIpv4MatchArbitraryBitMaskBuilder(Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder) {
+        this.ipv4MatchArbitraryBitMaskBuilder = ipv4MatchArbitraryBitMaskBuilder;
+    }
+
+    /**
+     * Gets ipv 6 match arbitrary bit mask builder.
+     *
+     * @return the ipv 6 match arbitrary bit mask builder
+     */
+    public Ipv6MatchArbitraryBitMaskBuilder getIpv6MatchArbitraryBitMaskBuilder() {
+        return ipv6MatchArbitraryBitMaskBuilder;
+    }
+
+    /**
+     * Sets ipv 6 match arbitrary bit mask builder.
+     *
+     * @param ipv6MatchArbitraryBitMaskBuilder the ipv 6 match arbitrary bit mask builder
+     */
+    public void setIpv6MatchArbitraryBitMaskBuilder(Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder) {
+        this.ipv6MatchArbitraryBitMaskBuilder = ipv6MatchArbitraryBitMaskBuilder;
+    }
+
+    /**
+     * Gets arp match builder.
+     *
+     * @return the arp match builder
+     */
+    public ArpMatchBuilder getArpMatchBuilder() {
+        return arpMatchBuilder;
+    }
+
+    /**
+     * Sets arp match builder.
+     *
+     * @param arpMatchBuilder the arp match builder
+     */
+    public void setArpMatchBuilder(ArpMatchBuilder arpMatchBuilder) {
+        this.arpMatchBuilder = arpMatchBuilder;
+    }
+
+    /**
+     * Gets ipv 6 match builder.
+     *
+     * @return the ipv 6 match builder
+     */
+    public Ipv6MatchBuilder getIpv6MatchBuilder() {
+        return ipv6MatchBuilder;
+    }
+
+    /**
+     * Sets ipv 6 match builder.
+     *
+     * @param ipv6MatchBuilder the ipv 6 match builder
+     */
+    public void setIpv6MatchBuilder(Ipv6MatchBuilder ipv6MatchBuilder) {
+        this.ipv6MatchBuilder = ipv6MatchBuilder;
+    }
+
+    /**
+     * Gets protocol match fields builder.
+     *
+     * @return the protocol match fields builder
+     */
+    public ProtocolMatchFieldsBuilder getProtocolMatchFieldsBuilder() {
+        return protocolMatchFieldsBuilder;
+    }
+
+    /**
+     * Sets protocol match fields builder.
+     *
+     * @param protocolMatchFieldsBuilder the protocol match fields builder
+     */
+    public void setProtocolMatchFieldsBuilder(ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder) {
+        this.protocolMatchFieldsBuilder = protocolMatchFieldsBuilder;
+    }
+
+    /**
+     * Gets tunnel ipv 4 match builder.
+     *
+     * @return the tunnel ipv 4 match builder
+     */
+    public TunnelIpv4MatchBuilder getTunnelIpv4MatchBuilder() {
+        return tunnelIpv4MatchBuilder;
+    }
+
+    /**
+     * Sets tunnel ipv 4 match builder.
+     *
+     * @param tunnelIpv4MatchBuilder the tunnel ipv 4 match builder
+     */
+    public void setTunnelIpv4MatchBuilder(TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder) {
+        this.tunnelIpv4MatchBuilder = tunnelIpv4MatchBuilder;
+    }
+
+    /**
+     * Sets tcp flags match builder.
+     *
+     * @param tcpFlagsMatchBuilder the tcp flags match builder
+     */
+    public void setTcpFlagsMatchBuilder(TcpFlagsMatchBuilder tcpFlagsMatchBuilder) {
+        this.tcpFlagsMatchBuilder = tcpFlagsMatchBuilder;
+    }
+
+    /**
+     * Gets tcp flags match builder.
+     *
+     * @return the tcp flags match builder
+     */
+    public TcpFlagsMatchBuilder getTcpFlagsMatchBuilder() {
+        return tcpFlagsMatchBuilder;
+    }
+
+    /**
+     * Sets oxm match field.
+     *
+     * @param oxmMatchField the oxm match field
+     */
+    public void setOxmMatchField(Class<? extends MatchField> oxmMatchField) {
+        this.oxmMatchField = oxmMatchField;
+    }
+
+    /**
+     * Gets oxm match field.
+     *
+     * @return the oxm match field
+     */
+    public Class<? extends MatchField> getOxmMatchField() {
+        return oxmMatchField;
+    }
+}
index d104f030f0f77a350a41245ae8676afb3ce3e1c8..493771c3a1e497dd279e7a4c2a7ec2fe60b51089 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowplugin.api.OFConstants;
@@ -23,8 +24,9 @@ import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
@@ -157,6 +159,11 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
 
     private static final Logger LOG = LoggerFactory.getLogger(FlowRemovedTranslator.class);
     private static final String PREFIX_SEPARATOR = "/";
+    private final ConvertorExecutor convertorExecutor;
+
+    public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
 
     @Override
     public List<DataObject> translate(final SwitchConnectionDistinguisher cookie, final SessionContext sc, final OfHeader msg) {
@@ -198,8 +205,11 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
             if (ofMatch != null) {
                 salFlowRemoved.setMatch(fromMatch(ofMatch, sc.getFeatures().getDatapathId(), ofVersion));
             } else if (ofFlow.getMatchV10() != null) {
-                MatchBuilder matchBuilder = new MatchBuilder(MatchConvertorImpl.fromOFMatchV10ToSALMatch(ofFlow.getMatchV10(), sc.getFeatures().getDatapathId(), ofVersion).build());
-                salFlowRemoved.setMatch(matchBuilder.build());
+                final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(sc.getPrimaryConductor().getVersion());
+                data.setDatapathId(sc.getFeatures().getDatapathId());
+
+                final Optional<MatchBuilder> matchBuilderOptional = convertorExecutor.convert(ofFlow.getMatchV10(), data);
+                salFlowRemoved.setMatch(matchBuilderOptional.orElse(new MatchBuilder()).build());
             }
             salFlowRemoved.setNode(new NodeRef(InventoryDataServiceUtil.identifierFromDatapathId(sc.getFeatures()
                     .getDatapathId())));
index 820cc73efc487ffbc11ec1df01f49eb34cbc6492..e2f755ca3759af12b550689d0686185ad6912d97 100644 (file)
@@ -11,11 +11,13 @@ package org.opendaylight.openflowplugin.openflow.md.core.translator;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
@@ -26,35 +28,41 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.TableUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MultipartReplyTableFeaturesToTableUpdatedTranslator implements
-               IMDMessageTranslator<OfHeader, List<DataObject>> {
+        IMDMessageTranslator<OfHeader, List<DataObject>> {
 
     private static final Logger LOG = LoggerFactory
             .getLogger(MultipartReplyTableFeaturesToTableUpdatedTranslator.class);
+    private final ConvertorExecutor convertorExecutor;
 
-       @Override
-       public List<DataObject> translate(SwitchConnectionDistinguisher cookie,
-                       SessionContext sc, OfHeader msg) {
-
+    public MultipartReplyTableFeaturesToTableUpdatedTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
 
+    @Override
+    public List<DataObject> translate(SwitchConnectionDistinguisher cookie, SessionContext sc, OfHeader msg) {
         if (msg instanceof MultipartReply && ((MultipartReply) msg).getType() == MultipartType.OFPMPTABLEFEATURES) {
             LOG.debug("MultipartReply Being translated to TableUpdated ");
             MultipartReplyMessage mpReply = (MultipartReplyMessage) msg;
 
-            List<DataObject> listDataObject = new CopyOnWriteArrayList<DataObject>();
+            List<DataObject> listDataObject = new CopyOnWriteArrayList<>();
 
-            TableUpdatedBuilder message = new TableUpdatedBuilder() ;
+            TableUpdatedBuilder message = new TableUpdatedBuilder();
             message.setNode((new NodeRef(InventoryDataServiceUtil.identifierFromDatapathId(sc.getFeatures()
                     .getDatapathId()))));
             message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
             message.setTransactionId(new TransactionId(BigInteger.valueOf(mpReply.getXid())));
             MultipartReplyTableFeaturesCase caseBody = (MultipartReplyTableFeaturesCase) mpReply.getMultipartReplyBody();
             MultipartReplyTableFeatures body = caseBody.getMultipartReplyTableFeatures();
-            message.setTableFeatures(TableFeaturesReplyConvertor.toTableFeaturesReply(body)) ;
+
+            final VersionConvertorData data = new VersionConvertorData(sc.getPrimaryConductor().getVersion());
+            final Optional<List<TableFeatures>> tableFeaturesList = convertorExecutor.convert(body, data);
+            message.setTableFeatures(tableFeaturesList.orElse(Collections.emptyList()));
             listDataObject.add( message.build()) ;
 
             return listDataObject ;
@@ -64,5 +72,4 @@ public class MultipartReplyTableFeaturesToTableUpdatedTranslator implements
 
     }
 
-}
-
+}
\ No newline at end of file
index 6cbe4d415c9cf860fce622b2b1cd73d4c24dbb12..2e31766fa8572e73271110e3456279e5d24e85d9 100644 (file)
@@ -10,20 +10,22 @@ package org.opendaylight.openflowplugin.openflow.md.core.translator;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 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;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
@@ -42,6 +44,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectLiveness;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectWeight;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder;
@@ -54,6 +58,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
 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;
@@ -107,10 +112,11 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
 
     protected static final Logger logger = LoggerFactory
             .getLogger(MultipartReplyTranslator.class);
+    private final ConvertorExecutor convertorExecutor;
 
-    private static FlowStatsResponseConvertor flowStatsConvertor = new FlowStatsResponseConvertor();
-    private static GroupStatsResponseConvertor groupStatsConvertor = new GroupStatsResponseConvertor();
-    private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
+    public MultipartReplyTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
 
 
     @Override
@@ -119,6 +125,8 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
         List<DataObject> listDataObject = new CopyOnWriteArrayList<DataObject>();
 
         OpenflowVersion ofVersion = OpenflowVersion.get(sc.getPrimaryConductor().getVersion());
+        final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(sc.getPrimaryConductor().getVersion());
+        data.setDatapathId(sc.getFeatures().getDatapathId());
 
         if(msg instanceof MultipartReplyMessage){
             MultipartReplyMessage mpReply = (MultipartReplyMessage)msg;
@@ -132,8 +140,10 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
                 message.setTransactionId(generateTransactionId(mpReply.getXid()));
                 MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase)mpReply.getMultipartReplyBody();
                 MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
-                message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats(),sc.getFeatures().getDatapathId(), ofVersion));
 
+                final Optional<List<FlowAndStatisticsMapList>> flowAndStatisticsMapLists = convertorExecutor.convert(replyBody.getFlowStats(), data);
+
+                message.setFlowAndStatisticsMapList(flowAndStatisticsMapLists.orElse(Collections.emptyList()));
                 logger.debug("Converted flow statistics : {}",message.build().toString());
                 listDataObject.add(message.build());
                 return listDataObject;
@@ -222,8 +232,8 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
                 message.setTransactionId(generateTransactionId(mpReply.getXid()));
                 MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase)mpReply.getMultipartReplyBody();
                 MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
-                message.setGroupStats(groupStatsConvertor.toSALGroupStatsList(replyBody.getGroupStats()));
-
+                final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(replyBody.getGroupStats(), data);
+                message.setGroupStats(groupStatsList.orElse(Collections.emptyList()));
                 logger.debug("Converted group statistics : {}",message.toString());
                 listDataObject.add(message.build());
                 return listDataObject;
@@ -238,8 +248,8 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
                 MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase)mpReply.getMultipartReplyBody();
                 MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
 
-                message.setGroupDescStats(groupStatsConvertor.toSALGroupDescStatsList(replyBody.getGroupDesc(), ofVersion));
-
+                final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(replyBody.getGroupDesc(), data);
+                message.setGroupDescStats(groupDescStatsList.orElse(Collections.emptyList()));
                 logger.debug("Converted group statistics : {}",message.toString());
                 listDataObject.add(message.build());
                 return listDataObject;
@@ -302,8 +312,11 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
 
                 MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase)mpReply.getMultipartReplyBody();
                 MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
-                message.setMeterStats(meterStatsConvertor.toSALMeterStatsList(replyBody.getMeterStats()));
 
+                final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats>> meterStatsList =
+                        convertorExecutor.convert(replyBody.getMeterStats(), data);
+
+                message.setMeterStats(meterStatsList.orElse(Collections.emptyList()));
                 listDataObject.add(message.build());
                 return listDataObject;
             }
@@ -317,8 +330,10 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
 
                 MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase)mpReply.getMultipartReplyBody();
                 MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
-                message.setMeterConfigStats(meterStatsConvertor.toSALMeterConfigList(replyBody.getMeterConfig()));
 
+                final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
+
+                message.setMeterConfigStats(meterConfigStatsList.orElse(Collections.emptyList()));
                 listDataObject.add(message.build());
                 return listDataObject;
             }
index b5ff55f4f38ddc52d07d91a737e97259afbca047..a2d4b946a97d7482845a4b0d7de081dbb4c23176 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.translator;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
@@ -17,11 +18,11 @@ import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 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.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.GetFeaturesOutput;
@@ -42,6 +43,11 @@ public class PacketInTranslator implements IMDMessageTranslator<OfHeader, List<D
 
     private static final Logger LOG = LoggerFactory
             .getLogger(PacketInTranslator.class);
+    private final ConvertorExecutor convertorExecutor;
+
+    public PacketInTranslator(ConvertorExecutor convertorExecutor) {
+        this.convertorExecutor = convertorExecutor;
+    }
 
     @Override
     public List<DataObject> translate(final SwitchConnectionDistinguisher cookie,
@@ -96,10 +102,12 @@ public class PacketInTranslator implements IMDMessageTranslator<OfHeader, List<D
                     LOG.warn("Received packet_in, but couldn't find an input port");
                 } else {
                     LOG.trace("Received packet_in from {} on port {}", dpid, port);
+                    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(sc.getPrimaryConductor().getVersion());
+                    datapathIdConvertorData.setDatapathId(dpid);
 
-                    OpenflowVersion ofVersion = OpenflowVersion.get(sc.getPrimaryConductor().getVersion());
-                    Match match = MatchConvertorImpl.fromOFMatchToSALMatch(message.getMatch(), dpid, ofVersion).build();
-                    MatchBuilder matchBuilder = new MatchBuilder(match);
+                    final OpenflowVersion ofVersion = OpenflowVersion.get(sc.getPrimaryConductor().getVersion());
+                    final Optional<MatchBuilder> matchOptional = convertorExecutor.convert(message.getMatch(), datapathIdConvertorData);
+                    final MatchBuilder matchBuilder = new MatchBuilder(matchOptional.orElse(new MatchBuilder()).build());
 
                     AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap =
                             MatchExtensionHelper.processAllExtensions(
@@ -110,6 +118,7 @@ public class PacketInTranslator implements IMDMessageTranslator<OfHeader, List<D
 
                     org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match packetInMatch = matchBuilder.build();
                     pktInBuilder.setMatch(packetInMatch);
+
                     pktInBuilder.setPacketInReason(PacketInUtil.getMdSalPacketInReason(message.getReason()));
                     pktInBuilder.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId(message.getTableId().getValue().shortValue()));
                     pktInBuilder.setIngress(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dpid, port, ofVersion));
index d4d3bc9e397356292ad4809c944b7a11f942fd31..639bf1e4f0dbed29754d5899b06dc00fef8b8043 100644 (file)
@@ -11,9 +11,9 @@ package org.opendaylight.openflowplugin.openflow.md.util;
 import java.math.BigInteger;
 import java.util.Objects;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
index ea3254406a90713d444dc35657d8e7ffb551263f..8eb350f358900cfd1cc51805db5fde840b0b2160 100644 (file)
@@ -42,6 +42,8 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.core.plan.ConnectionAdapterStackImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.plan.EventFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.plan.SwitchTestEvent;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.queue.QueueProcessorLightImpl;
 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.PortFeatures;
@@ -154,7 +156,8 @@ public class ConnectionConductorImplTest {
 
         popListener = new PopListenerCountingImpl<>();
 
-        controller = new MDController();
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        controller = new MDController(convertorManager);
         controller.init();
         controller.getMessageTranslators().putAll(assembleTranslatorMapping());
 
index 7acdb6de9ea44a46f814cafcb205f7216ed0d845..d871ec0fccf8ffb0990733fdb487e4b268d42b11 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.openflowplugin.openflow.md.core;
 
 import java.util.List;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -16,6 +15,8 @@ import org.junit.Test;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
@@ -35,7 +36,8 @@ public class MDControllerTest {
      */
     @Before
     public void setUp() throws Exception {
-        controller = new MDController();
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        controller = new MDController(convertorManager);
         controller.init();
     }
 
@@ -47,12 +49,6 @@ public class MDControllerTest {
         controller = null;
     }
 
-
-    /**
-     * Test method for
-     * {@link org.opendaylight.openflowplugin.openflow.md.core.MDController#addMessageListeners}
-     * .
-     */
     @Test
     public void testAddMessageListeners() {
         //clean translators
index 351c566e1515eaf5888b82113b241d669bfd83f5..ae87f009ef71ca520deb5d1cf27e0ca62252774d 100644 (file)
@@ -43,6 +43,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessionKeyOF;
 import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
@@ -60,7 +62,7 @@ public class ConcurrentSalRegistrationManagerTest {
 
     /** registration related action must end within this amount of seconds */
     private static final int REGISTRATION_ACTION_TIMEOUT = 5;
-    protected static final SalRegistrationManager registrationManager = new SalRegistrationManager();
+    protected SalRegistrationManager registrationManager;
     protected static final Logger LOG = LoggerFactory.getLogger(ConcurrentSalRegistrationManagerTest.class);
     protected static final SwitchSessionKeyOF SWITCH_SESSION_KEY_OF = new SwitchSessionKeyOF();
 
@@ -94,6 +96,8 @@ public class ConcurrentSalRegistrationManagerTest {
      */
     @Before
     public void setUp() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        registrationManager = new SalRegistrationManager(convertorManager);
         SWITCH_SESSION_KEY_OF.setDatapathId(BigInteger.ONE);
         Mockito.when(context.getNotificationEnqueuer()).thenReturn(notificationEnqueuer);
 
index 34a6fe4411d2d7502c5749a4c63af0306e8464ff..1d551876e736d50a9330c9c81d9303a20bcc637c 100644 (file)
@@ -35,6 +35,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDist
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
@@ -207,8 +209,9 @@ public class ModelDrivenSwitchImplTest {
 
         OpenflowPortsUtil.init();
 
-        mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context);
-        mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context, convertorManager);
+        mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context, convertorManager);
     }
 
     /**
index 93324e4a6b685d2dcbf14adf3629bf7efbc42a97..ed51e4e73b66cf4d8e7bd087b14a5d5cd99f318c 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.when;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.util.Collection;
@@ -26,6 +27,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDist
 import org.opendaylight.openflowplugin.api.openflow.md.core.sal.NotificationComposer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
@@ -53,24 +56,24 @@ public class OFRpcTaskUtilTest {
     @Mock
     private ListenableFuture<RpcResult<UpdateFlowOutput>> updateFlowRpcResultListenableFuture;
     @Mock
-    private OFRpcTaskContext ofRpcTaskContext;
-    @Mock
     private NotificationProviderService notificationProviderService;
     @Mock
     private NotificationComposer<?> notificationComposer;
     @Mock
     ListeningExecutorService executorService;
+    private ConvertorManager convertorManager;
 
 
     @Before
-    public void setup() {
+    public void setUp() {
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
         when(taskContext.getSession()).thenReturn(sessionContext);
         when(taskContext.getMessageService()).thenReturn(messageDispatchService);
         when(sessionContext.getNextXid()).thenReturn(new Long(10));
         when(sessionContext.getFeatures()).thenReturn(featuresOutput);
         when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         when(messageDispatchService.barrier(Mockito.any(BarrierInput.class), Mockito.any(SwitchConnectionDistinguisher.class))).thenReturn(resultListenableFuture);
-        when(ofRpcTaskContext.getRpcPool()).thenReturn(executorService);
+        when(taskContext.getRpcPool()).thenReturn(executorService);
         when(executorService.submit(Mockito.<Callable<RpcResult<UpdateFlowOutput>>> any())).thenReturn(updateFlowRpcResultListenableFuture);
     }
 
@@ -84,7 +87,7 @@ public class OFRpcTaskUtilTest {
     @Test
     public void testHookFutureNotification() throws Exception {
         final AddFlowInputBuilder flowInputBuilder = new AddFlowInputBuilder();
-        final OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> addFlowInputRpcResultOFRpcTask = OFRpcTaskFactory.createAddFlowTask(ofRpcTaskContext, flowInputBuilder.build(), connectionDistinguisher);
+        final OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> addFlowInputRpcResultOFRpcTask = OFRpcTaskFactory.createAddFlowTask(taskContext, flowInputBuilder.build(), connectionDistinguisher, convertorManager);
         OFRpcTaskUtil.hookFutureNotification(addFlowInputRpcResultOFRpcTask, updateFlowRpcResultListenableFuture, notificationProviderService, notificationComposer);
     }
 
@@ -92,7 +95,7 @@ public class OFRpcTaskUtilTest {
     public void testChainFutureBarrier() throws Exception {
         final AddFlowInputBuilder flowInputBuilder = new AddFlowInputBuilder();
         flowInputBuilder.setBarrier(true);
-        final OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> addFlowInputRpcResultOFRpcTask = OFRpcTaskFactory.createAddFlowTask(ofRpcTaskContext, flowInputBuilder.build(), connectionDistinguisher);
+        final OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> addFlowInputRpcResultOFRpcTask = OFRpcTaskFactory.createAddFlowTask(taskContext, flowInputBuilder.build(), connectionDistinguisher, convertorManager);
         OFRpcTaskUtil.chainFutureBarrier(addFlowInputRpcResultOFRpcTask, updateFlowRpcResultListenableFuture);
     }
 }
\ No newline at end of file
index 120107b547a497acf1392c50d58219ff9b039cf5..a1df985628363f5e6fae9c932b9f849d619e50da 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.math.BigInteger;
@@ -36,6 +37,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDist
 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.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 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;
@@ -101,9 +104,10 @@ public class SalRegistrationManagerTest {
         Mockito.when(features.getVersion()).thenReturn((short) 1);
         context.setFeatures(features);
         context.setNotificationEnqueuer(notificationEnqueuer);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
 
-       OfEntityManager entManager = new OfEntityManager(entityOwnershipService,getConfig());
-        mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
+        OfEntityManager entManager = new OfEntityManager(entityOwnershipService,getConfig());
+        mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context, convertorManager);
         registration = new AbstractModelDrivenSwitchRegistration(mdSwitchOF13) {
             @Override
             protected void removeRegistration() {
@@ -119,7 +123,7 @@ public class SalRegistrationManagerTest {
                 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
                         Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
 
-        salRegistrationManager = new SalRegistrationManager();
+        salRegistrationManager = new SalRegistrationManager(convertorManager);
         salRegistrationManager.setPublishService(notificationProviderService);
         salRegistrationManager.setDataService(dataBroker);
         salRegistrationManager.setRpcProviderRegistry(rpcProviderRegistry);
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java
deleted file mode 100644 (file)
index a6da6df..0000000
+++ /dev/null
@@ -1,625 +0,0 @@
-/**
- * Copyright (c) 2014 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.openflow.md.core.sal.convertor;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
-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.PopMplsActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
-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.action.pop.mpls.action._case.PopMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
-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.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
-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.Ipv4DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase;
-
-/**
- * test for {@link ActionConvertor}
- */
-public class ActionConvertorTest {
-
-    List<Action> actions = new ArrayList<>();
-    static Integer actionItem = 0;
-
-    /**
-     * prepare OpenflowPortsUtil util class
-     */
-    @Before
-    public void setUp() {
-        OpenflowPortsUtil.init();
-    }
-
-    @Test
-    public void testActionConvertorwithallParameters() {
-        OutputActionData();
-        CopyTtlData();
-        MplsTtlActionData();
-        vlanActionData();
-        mplsActionData();
-        setQueueActionData();
-        setGroupAction();
-        NwTtlAction();
-        pbbActionData();
-        setFieldData();
-        setExperimenterData();
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> OFActionsList = ActionConvertor.getActions(actions, (short) 0X4, BigInteger.ONE, null);
-
-        outputActions(OFActionsList);
-
-    }
-
-    private void setExperimenterData() {
-
-        // TODO:SAL API Missing
-
-    }
-
-    private void setFieldData() {
-
-        SetFieldBuilder setFA = new SetFieldBuilder();
-
-        SetFieldBuilder matchBuilder = setFA;
-
-        matchBuilder.setInPort(new NodeConnectorId("openflow:1:2125"));
-
-        SetFieldBuilder setFB = new SetFieldBuilder();
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new SetFieldCaseBuilder().setSetField(setFB.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-    }
-
-    private void pbbActionData() {
-        PushPbbActionBuilder pushpbb = new PushPbbActionBuilder();
-        pushpbb.setEthernetType(10);
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pushpbb.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-        PopPbbActionBuilder popPBB = new PopPbbActionBuilder();
-
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPBB.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-
-    }
-
-    private void NwTtlAction() {
-        SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
-
-        setNwTtlActionBuilder.setNwTtl((short) 1);
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-        DecNwTtlBuilder necNwTtlBuilder = new DecNwTtlBuilder();
-
-
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new DecNwTtlCaseBuilder().setDecNwTtl(necNwTtlBuilder.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-
-    }
-
-    private void setGroupAction() {
-
-        GroupActionBuilder grpIdAB = new GroupActionBuilder();
-        grpIdAB.setGroup("98");
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new GroupActionCaseBuilder().setGroupAction(grpIdAB.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-    }
-
-    // TODO - check if this method is needed (private and never used locally) - see line 94
-
-    private static void outputActions(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> oFActionsList) {
-
-        for (int item = 0; item < oFActionsList.size(); item++) {
-
-            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = oFActionsList
-                    .get(item);
-
-            if (action.getActionChoice() instanceof OutputActionCase) {
-                OutputActionCase outputActionCase = (OutputActionCase) action.getActionChoice();
-                Assert.assertEquals((Integer) 10, (outputActionCase.getOutputAction().getMaxLength()));
-                long port = 4294967293L;
-                Assert.assertEquals(port, (long) (outputActionCase.getOutputAction().getPort().getValue()));
-
-
-            }
-            if (action.getActionChoice() instanceof CopyTtlInCase) {
-                CopyTtlInCase copyTtlInCase = (CopyTtlInCase) action.getActionChoice();
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlInCase.class.getName());
-
-            }
-            if (action.getActionChoice() instanceof CopyTtlOutCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlOutCase.class.getName());
-            }
-
-            if (action.getActionChoice() instanceof
-                    // TODO:getMplsTtl is missing.
-                    SetMplsTtlCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetMplsTtlCase.class.getName());
-
-            }
-            if (action.getActionChoice() instanceof DecMplsTtlCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
-                        DecMplsTtlCase.class.getName());
-            }
-
-            if (action.getActionChoice() instanceof PushMplsCase) {
-                PushMplsCase pushMplsCase = (PushMplsCase) action.getActionChoice();
-                EtherType etherType = pushMplsCase.getPushMplsAction().getEthertype();
-
-                if (etherType != null) {
-                    Assert.assertEquals((Integer) 10, etherType.getValue());
-                }
-            }
-
-            if (action.getActionChoice() instanceof PopMplsCase) {
-                PopMplsCase popMplsCase = (PopMplsCase) action.getActionChoice();
-                Assert.assertEquals((Integer) 10, (popMplsCase.getPopMplsAction().getEthertype().getValue()));
-            }
-
-            if (action.getActionChoice() instanceof
-
-                    // TODO:SetQueue,I dont have getQueueId
-                    SetQueueCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetQueueCase.class.getName());
-            }
-
-            if (action.getActionChoice() instanceof GroupCase) {
-                GroupCase groupCase = (GroupCase) action.getActionChoice();
-                Assert.assertEquals(98, (long) (groupCase.getGroupAction().getGroupId()));
-            }
-
-            if (action.getActionChoice() instanceof PushVlanCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PushVlanCase.class.getName());
-            }
-
-            if (action.getActionChoice() instanceof PopVlanCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopVlanCase.class.getName());
-            }
-
-            if (action.getActionChoice() instanceof SetNwTtlCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetNwTtlCase.class.getName());
-            }
-            if (action.getActionChoice() instanceof DecNwTtlCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), DecNwTtlCase.class.getName());
-            }
-            if (action.getActionChoice() instanceof PushPbbCase) {
-                PushPbbCase pushPbbCase = (PushPbbCase) action.getActionChoice();
-                if (pushPbbCase.getPushPbbAction().getEthertype() != null) {
-                    Assert.assertEquals((Integer) 10, pushPbbCase.getPushPbbAction().getEthertype().getValue());
-                }
-            }
-
-            if (action.getActionChoice() instanceof PopMplsCase) {
-                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopMplsCase.class.getName());
-            }
-            if (action.getActionChoice() instanceof SetFieldCase) {
-                SetFieldCase setFieldCase = (SetFieldCase) action.getActionChoice();
-                Assert.assertNotNull(setFieldCase.getSetFieldAction());
-
-/*
-                Assert.assertEquals(OpenflowBasicClass.class, sf.getMatchEntry().get(0).getOxmClass());
-
-                if (sf.getMatchEntry().get(0).getOxmMatchField().equals(InPort.class)) {
-                    InPortCase inPortCase = ((InPortCase) sf.getMatchEntry().get(0).getMatchEntryValue());
-                    Assert.assertEquals(2125, inPortCase.getInPort().getPortNumber().getValue().intValue());
-
-                }
-*/
-
-            }
-
-
-        }
-
-    }
-
-    private void OutputActionData() {
-        OutputActionBuilder outputB = new OutputActionBuilder();
-        outputB.setMaxLength(10);
-        Uri uri = new Uri(OutputPortValues.CONTROLLER.toString());
-        outputB.setOutputNodeConnector(uri);
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new OutputActionCaseBuilder().setOutputAction(outputB.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-    }
-
-    private void CopyTtlData() {
-        CopyTtlOutBuilder copyB = new CopyTtlOutBuilder();
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyB.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-        CopyTtlInBuilder copyTtlInBuilder = new CopyTtlInBuilder();
-
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInBuilder.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-
-    }
-
-    private void MplsTtlActionData() {
-
-        SetMplsTtlActionBuilder setMplsTtlActionB = new SetMplsTtlActionBuilder();
-
-        setMplsTtlActionB.setMplsTtl((short) 10);
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionB.build()).build());
-
-
-        actions.add(actionItem++, AB1.build());
-
-        DecMplsTtlBuilder decMplsTtlB = new DecMplsTtlBuilder();
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtlB.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-    }
-
-    private void vlanActionData() {
-        PushVlanActionBuilder pvB = new PushVlanActionBuilder();
-
-        pvB.setVlanId(new VlanId(10));
-
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new PushVlanActionCaseBuilder().setPushVlanAction(pvB.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-
-        PopVlanActionBuilder popVAB = new PopVlanActionBuilder();
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVAB.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-    }
-
-    private void mplsActionData() {
-
-        PushMplsActionBuilder pushMB = new PushMplsActionBuilder();
-        pushMB.setEthernetType(10);
-
-        ActionBuilder AB = new ActionBuilder();
-        AB.setOrder(actionItem).setAction(new PushMplsActionCaseBuilder().setPushMplsAction(pushMB.build()).build());
-
-        actions.add(actionItem++, AB.build());
-
-        PopMplsActionBuilder popMB = new PopMplsActionBuilder();
-        popMB.setEthernetType(10);
-
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMB.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-    }
-
-    /**
-     * testing {@link ActionConvertor#ofToSALPushMplsAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)}
-     * with OF-1.3, IPv6
-     */
-    @Test
-    public void testOFtoSALPushMplsAction() {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder
-                = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder pushMplsBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder();
-        pushMplsBuilder.setEthertype(new EtherType(new Integer(34888)));
-        pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
-        actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actionBuilder.build();
-        Assert.assertEquals(34888, ActionConvertor.ofToSALPushMplsAction(action).getPushMplsAction().getEthernetType().intValue());
-    }
-
-    private void setQueueActionData() {
-
-        SetQueueActionBuilder setQB = new SetQueueActionBuilder();
-        setQB.setQueue("99");
-
-        ActionBuilder AB1 = new ActionBuilder();
-        AB1.setOrder(actionItem).setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQB.build()).build());
-
-        actions.add(actionItem++, AB1.build());
-
-    }
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.0, IPv4
-     */
-    @Test
-    public void testSalToOFSetNwDst10v4() {
-        short version = 1;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
-        SetNwDstActionCase action = provisionNwDstActionBuilder(address);
-        ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
-        Assert.assertEquals(SetNwDstCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
-        SetNwDstCase setNwDstCase = (SetNwDstCase) actionBuilder.getActionChoice();
-        Assert.assertEquals("10.0.0.1", setNwDstCase.getSetNwDstAction().getIpAddress().getValue());
-    }
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.0, IPv6
-     */
-    @Test
-    public void testSalToOFSetNwDst10v6() {
-        short version = 1;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        /* Use canonical form - no leading zeroes!!! */
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
-        SetNwDstActionCase action = provisionNwDstActionBuilder(address);
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
-        Assert.assertNull(ofAction);
-    }
-
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.3, IPv4
-     */
-    @Test
-    public void testSalToOFSetNwDst13v4() {
-        short version = 4;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
-        SetNwDstActionCase action = provisionNwDstActionBuilder(address);
-        ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
-        Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
-        SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
-        MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
-        Assert.assertEquals(Ipv4Dst.class.getName(), matchEntry.getOxmMatchField().getName());
-        Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) matchEntry.getMatchEntryValue());
-        Assert.assertEquals("10.0.0.1", ipv4DstCase.getIpv4Dst().getIpv4Address().getValue());
-    }
-
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.3, IPv6
-     */
-    @Test
-    public void testSalToOFSetNwDst13v6() {
-        short version = 4;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
-        SetNwDstActionCase action = provisionNwDstActionBuilder(address);
-        ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
-        Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
-        SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
-        MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
-        Assert.assertEquals(Ipv6Dst.class.getName(), matchEntry.getOxmMatchField().getName());
-        Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) matchEntry.getMatchEntryValue());
-        /* We check the IP only, the netmask should have gone into the wildcard field */
-        Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6DstCase.getIpv6Dst().getIpv6Address().getValue());
-    }
-
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.0, IPv4
-     */
-    @Test
-    public void testSalToOFSetNwSrc10v4() {
-        short version = 1;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
-        SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
-        ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
-        Assert.assertEquals(SetNwSrcCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
-        SetNwSrcCase setNwSrcCase = (SetNwSrcCase) actionBuilder.getActionChoice();
-        Assert.assertEquals("10.0.0.1", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());
-    }
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.0, IPv6
-     */
-    @Test
-    public void testSalToOFSetNwSrc10v6() {
-        short version = 1;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
-        SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
-        Assert.assertNull(ofAction);
-    }
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.3, IPv4
-     */
-    @Test
-    public void testSalToOFSetNwSrc13v4() {
-        short version = 4;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
-        SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
-        ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
-        Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
-        SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
-        MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
-        Assert.assertEquals(Ipv4Src.class, matchEntry.getOxmMatchField());
-        Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) matchEntry.getMatchEntryValue());
-        Assert.assertEquals("10.0.0.1", ipv4SrcCase.getIpv4Src().getIpv4Address().getValue());
-    }
-
-    /**
-     * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
-     * with OF-1.3, IPv6
-     */
-    @Test
-    public void testSalToOFSetNwSrc13v6() {
-        short version = 4;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        Address address;
-        /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
-        SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
-        ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
-        Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
-        SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
-        MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
-        Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) matchEntry.getMatchEntryValue());
-        Assert.assertEquals(Ipv6Src.class.getName(), matchEntry.getOxmMatchField().getName());
-        /* We check the IP only, the netmask should have gone into the wildcard field */
-        Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6SrcCase.getIpv6Src().getIpv6Address().getValue());
-    }
-
-    /**
-     * testing {@link ActionConvertor#ofToSALPopMplsAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)}
-     * with OF-1.3, IPv6
-     */
-    @Test
-    public void testOFtoSALPopMplsAction() {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-        PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder popMplsBuilder =
-                new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder();
-        popMplsBuilder.setEthertype(new EtherType(new EtherType(34888)));
-        popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
-        actionBuilder.setActionChoice(popMplsCaseBuilder.build());
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actionBuilder.build();
-        Assert.assertEquals(34888, ActionConvertor.ofToSALPopMplsAction(action).getPopMplsAction().getEthernetType().intValue());
-    }
-
-    private static SetNwDstActionCase provisionNwDstActionBuilder(final Address address) {
-        SetNwDstAction nwDstAction = new SetNwDstActionBuilder().setAddress(address).build();
-        SetNwDstActionCase action = new SetNwDstActionCaseBuilder()
-                .setSetNwDstAction(nwDstAction)
-                .build();
-        return action;
-    }
-
-    private static SetNwSrcActionCase provisionNwSrcActionBuilder(final Address address) {
-        SetNwSrcAction nwSrcAction = new SetNwSrcActionBuilder().setAddress(address).build();
-        SetNwSrcActionCase action = new SetNwSrcActionCaseBuilder()
-                .setSetNwSrcAction(nwSrcAction)
-                .build();
-        return action;
-    }
-
-}
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerTest.java
new file mode 100644 (file)
index 0000000..7675e54
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+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.yangtools.yang.binding.DataContainer;
+
+/**
+ * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ConvertorManagerTest {
+    /**
+     * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager#registerConvertor(short, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor)}
+     * @throws Exception
+     */
+    @Test
+    public void testRegisterConvertor() throws Exception {
+        final ConvertorManager convertorManager = new ConvertorManager(OFConstants.OFP_VERSION_1_3)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, new Convertor<Action, String, VersionConvertorData>() {
+                    @Override
+                    public Collection<Class<? extends DataContainer>> getTypes() {
+                        return Collections.singleton(Action.class);
+                    }
+
+                    @Override
+                    public String convert(Action source, VersionConvertorData data) {
+                        return null;
+                    }
+                });
+
+        final Optional<Convertor> convertor = convertorManager.findConvertor(OFConstants.OFP_VERSION_1_3, Action.class);
+        assertTrue("Failed to find convertor for action", convertor.isPresent());
+    }
+
+    /**
+     * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager#convert(org.opendaylight.yangtools.yang.binding.DataContainer, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData)}
+     * @throws Exception
+     */
+    @Test
+    public void testConvert() throws Exception {
+        final ConvertorManager convertorManager = new ConvertorManager(OFConstants.OFP_VERSION_1_3)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, new Convertor<Action, String, VersionConvertorData>() {
+                    @Override
+                    public Collection<Class<? extends DataContainer>> getTypes() {
+                        return Collections.singleton(Action.class);
+                    }
+
+                    @Override
+                    public String convert(Action source, VersionConvertorData data) {
+                        return String.valueOf(source) + String.valueOf(data);
+                    }
+                });
+
+        final Action source = new ActionBuilder().build();
+        final VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+        final String expectedResult = String.valueOf(source) + String.valueOf(data);
+        final Optional<String> result = convertorManager.convert(source, data);
+
+        assertTrue("Failed to convert action to string", result.isPresent());
+        assertEquals("Result and expected result do not match", result.get(), expectedResult);
+    }
+
+    /**
+     * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager#convert(java.util.Collection, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData)}
+     * @throws Exception
+     */
+    @Test
+    public void testConvert1() throws Exception {
+        final ConvertorManager convertorManager = new ConvertorManager(OFConstants.OFP_VERSION_1_3)
+                .registerConvertor(OFConstants.OFP_VERSION_1_3, new Convertor<List<Action>, String, VersionConvertorData>() {
+                    @Override
+                    public Collection<Class<? extends DataContainer>> getTypes() {
+                        return Collections.singleton(Action.class);
+                    }
+
+                    @Override
+                    public String convert(List<Action> source, VersionConvertorData data) {
+                        return String.valueOf(source) + String.valueOf(data);
+                    }
+                });
+
+        final List<Action> source = Collections.singletonList(new ActionBuilder().build());
+        final VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+        final String expectedResult = String.valueOf(source) + String.valueOf(data);
+        final Optional<String> result = convertorManager.convert(source, data);
+
+        assertTrue("Failed to convert action to string", result.isPresent());
+        assertEquals("Result and expected result do not match", result.get(), expectedResult);
+    }
+}
\ No newline at end of file
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConverterTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConverterTest.java
deleted file mode 100644 (file)
index b45e3e5..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Copyright (c) 2014 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.openflow.md.core.sal.convertor;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
-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.flow.service.rev130819.AddFlowInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-/**
- * test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor}
- */
-public class FlowConverterTest {
-
-
-    @Test
-    public void testCloneAndAugmentFlowWithSetVlanId() {
-        MockFlow mockFlow = new MockFlow();
-        Action action1 = createAction(
-            new SetVlanIdActionCaseBuilder().setSetVlanIdAction(
-                new SetVlanIdActionBuilder().setVlanId(new VlanId(10)).build())
-                .build(),
-            0);
-
-        mockFlow.setMatch(new MatchBuilder().setEthernetMatch(createEthernetMatch()).build());
-        mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1)));
-
-        List<FlowModInputBuilder> flowModInputBuilders =
-            FlowConvertor.toFlowModInputs(mockFlow, OFConstants.OFP_VERSION_1_3, BigInteger.ONE);
-        Assert.assertEquals(2, flowModInputBuilders.size());
-
-    }
-
-    private static Action createAction(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionCase,
-        final int order) {
-        Action action = new ActionBuilder().setOrder(order).setAction(actionCase).build();
-        return action;
-    }
-
-    private static EthernetMatch createEthernetMatch() {
-        EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
-        ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(33024L)).build());
-        return ethernetMatchBuilder.build();
-    }
-
-    private static Instructions toApplyInstruction(
-        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
-        return new InstructionsBuilder()
-            .setInstruction(
-                Collections.singletonList(
-                    new InstructionBuilder()
-                        .setOrder(0)
-                        .setInstruction(
-                            new ApplyActionsCaseBuilder()
-                                .setApplyActions((new ApplyActionsBuilder()).setAction(actions).build())
-                                .build()
-                        ).build())
-            ).build();
-    }
-
-    private static Flow createFlowWithActions(final Action...actions) {
-        MockFlow mockFlow = new MockFlow();
-        mockFlow.setInstructions(toApplyInstruction(Arrays.asList(actions)));
-        return mockFlow;
-    }
-
-    private static class MockFlow implements AddFlowInput {
-        private Instructions instructions;
-        private Match match;
-
-        public void setInstructions(final Instructions instructions) {
-            this.instructions = instructions;
-        }
-
-        public void setMatch(final Match match) {
-            this.match = match;
-        }
-
-
-        @Override
-        public FlowRef getFlowRef() {
-            return null;
-        }
-
-        @Override
-        public <E extends Augmentation<AddFlowInput>> E getAugmentation(final Class<E> augmentationType) {
-            return null;
-        }
-
-        @Override
-        public FlowTableRef getFlowTable() {
-            return null;
-        }
-
-        @Override
-        public Match getMatch() {
-            return match;
-        }
-
-        @Override
-        public Instructions getInstructions() {
-            return instructions;
-        }
-
-        @Override
-        public String getContainerName() {
-            return null;
-        }
-
-        @Override
-        public FlowCookie getCookieMask() {
-            return null;
-        }
-
-        @Override
-        public Long getBufferId() {
-            return null;
-        }
-
-        @Override
-        public BigInteger getOutPort() {
-            return null;
-        }
-
-        @Override
-        public Long getOutGroup() {
-            return null;
-        }
-
-        @Override
-        public FlowModFlags getFlags() {
-            return null;
-        }
-
-        @Override
-        public String getFlowName() {
-            return null;
-        }
-
-        @Override
-        public Boolean isInstallHw() {
-            return null;
-        }
-
-        @Override
-        public Boolean isBarrier() {
-            return null;
-        }
-
-        @Override
-        public Boolean isStrict() {
-            return null;
-        }
-
-        @Override
-        public Integer getPriority() {
-            return null;
-        }
-
-        @Override
-        public Integer getIdleTimeout() {
-            return null;
-        }
-
-        @Override
-        public Integer getHardTimeout() {
-            return null;
-        }
-
-        @Override
-        public FlowCookie getCookie() {
-            return null;
-        }
-
-        @Override
-        public Short getTableId() {
-            return null;
-        }
-
-        @Override
-        public NodeRef getNode() {
-            return null;
-        }
-
-        @Override
-        public Uri getTransactionUri() {
-            return null;
-        }
-
-        @Override
-        public Class<? extends DataContainer> getImplementedInterface() {
-            return null;
-        }
-    }
-
-}
index f0358c4dfbf706a2183684e6fe4e1cfa9a14e44f..92acc97320cbba66dcf4f66b28928d1c012668c7 100644 (file)
@@ -11,8 +11,11 @@ import com.google.common.collect.ImmutableList;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
@@ -31,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 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.types.rev131018.BucketId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
@@ -44,9 +48,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
 
 public class GroupConvertorTest {
+    private ConvertorManager convertorManager;
+
+    @Before
+    public void setUp() {
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
+    }
 
     /**
-     * test of {@link GroupConvertor#toGroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, short, java.math.BigInteger)}
+     * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
      */
     @Test
     public void testGroupModConvertorwithallParameters() {
@@ -126,7 +136,10 @@ public class GroupConvertorTest {
 
         addGroupBuilder.setBuckets(buckets);
 
-        final GroupModInputBuilder outAddGroupInput = GroupConvertor.toGroupModInput(addGroupBuilder.build(), (short) 0X4, BigInteger.valueOf(1));
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
+        data.setDatapathId(BigInteger.valueOf(1));
+
+        final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
 
         Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
         Assert.assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
@@ -166,7 +179,7 @@ public class GroupConvertorTest {
     }
 
     /**
-     * test of {@link GroupConvertor#toGroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, short, java.math.BigInteger)}
+     * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
      */
     @Test
     public void testGroupModConvertorNoBucket() {
@@ -176,14 +189,16 @@ public class GroupConvertorTest {
 
         addGroupBuilder.setGroupType(GroupTypes.GroupAll);
 
-        final GroupModInputBuilder outAddGroupInput = GroupConvertor.toGroupModInput(addGroupBuilder.build(), (short) 0X4, BigInteger.valueOf(1));
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
+        data.setDatapathId(BigInteger.valueOf(1));
 
+        final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
         Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
         Assert.assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
     }
 
     /**
-     * test of {@link GroupConvertor#toGroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, short, java.math.BigInteger)}
+     * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
      */
     @Test
     public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
@@ -233,7 +248,10 @@ public class GroupConvertorTest {
 
         addGroupBuilder.setBuckets(buckets);
 
-        final GroupModInputBuilder outAddGroupInput = GroupConvertor.toGroupModInput(addGroupBuilder.build(), (short) 0X4, BigInteger.valueOf(1));
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
+        data.setDatapathId(BigInteger.valueOf(1));
+
+        final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
 
         Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
         Assert.assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
@@ -260,7 +278,7 @@ public class GroupConvertorTest {
     }
 
     /**
-     * test of {@link GroupConvertor#toGroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, short, java.math.BigInteger)}
+     * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
      */
     @Test
     public void testGroupModConvertSortedBuckets() {
@@ -270,88 +288,91 @@ public class GroupConvertorTest {
         final ArrayList<Bucket> bucket = new ArrayList<Bucket>();
 
         bucket.add(new BucketBuilder()
-                        .setBucketId(new BucketId((long) 4))
-                        .setWatchPort((long)2)
-                        .setWatchGroup((long) 1)
-                        .setAction(ImmutableList.of(new ActionBuilder()
+                .setBucketId(new BucketId((long) 4))
+                .setWatchPort((long)2)
+                .setWatchGroup((long) 1)
+                .setAction(ImmutableList.of(new ActionBuilder()
                         .setOrder(0)
                         .setAction(new OutputActionCaseBuilder()
-                                        .setOutputAction(new OutputActionBuilder()
-                                                                .setOutputNodeConnector(new Uri("openflow:1:2"))
-                                                                .build())
+                                .setOutputAction(new OutputActionBuilder()
+                                        .setOutputNodeConnector(new Uri("openflow:1:2"))
                                         .build())
+                                .build())
                         .build()))
-        .build());
+                .build());
 
         bucket.add(new BucketBuilder()
-                        .setBucketId(new BucketId((long) 3))
-                        .setWatchPort((long)6)
-                        .setWatchGroup((long) 1)
-                        .setAction(ImmutableList.of(new ActionBuilder()
+                .setBucketId(new BucketId((long) 3))
+                .setWatchPort((long)6)
+                .setWatchGroup((long) 1)
+                .setAction(ImmutableList.of(new ActionBuilder()
                         .setOrder(0)
                         .setAction(new OutputActionCaseBuilder()
-                                        .setOutputAction(new OutputActionBuilder()
-                                                                .setOutputNodeConnector(new Uri("openflow:1:6"))
-                                                                .build())
+                                .setOutputAction(new OutputActionBuilder()
+                                        .setOutputNodeConnector(new Uri("openflow:1:6"))
                                         .build())
+                                .build())
                         .build()))
                 .build());
 
         bucket.add(new BucketBuilder()
-                        .setBucketId(new BucketId((long) 2))
-                        .setWatchPort((long)5)
-                        .setWatchGroup((long) 1)
-                        .setAction(ImmutableList.of(new ActionBuilder()
+                .setBucketId(new BucketId((long) 2))
+                .setWatchPort((long)5)
+                .setWatchGroup((long) 1)
+                .setAction(ImmutableList.of(new ActionBuilder()
                         .setOrder(0)
                         .setAction(new OutputActionCaseBuilder()
-                                        .setOutputAction(new OutputActionBuilder()
-                                                                .setOutputNodeConnector(new Uri("openflow:1:5"))
-                                                                .build())
+                                .setOutputAction(new OutputActionBuilder()
+                                        .setOutputNodeConnector(new Uri("openflow:1:5"))
                                         .build())
+                                .build())
                         .build()))
                 .build());
 
         bucket.add(new BucketBuilder()
-                    .setBucketId(new BucketId((long) 1))
-                    .setWatchPort((long)4)
-                    .setWatchGroup((long) 1)
-                    .setAction(ImmutableList.of(new ActionBuilder()
-                    .setOrder(0)
-                    .setAction(new OutputActionCaseBuilder()
-                                    .setOutputAction(new OutputActionBuilder()
-                                                            .setOutputNodeConnector(new Uri("openflow:1:4"))
-                                                            .build())
-                                    .build())
-                    .build()))
-            .build());
+                .setBucketId(new BucketId((long) 1))
+                .setWatchPort((long)4)
+                .setWatchGroup((long) 1)
+                .setAction(ImmutableList.of(new ActionBuilder()
+                        .setOrder(0)
+                        .setAction(new OutputActionCaseBuilder()
+                                .setOutputAction(new OutputActionBuilder()
+                                        .setOutputNodeConnector(new Uri("openflow:1:4"))
+                                        .build())
+                                .build())
+                        .build()))
+                .build());
 
         bucket.add(new BucketBuilder()
-                    .setBucketId(new BucketId((long) 0))
-                    .setWatchPort((long)3)
-                    .setWatchGroup((long) 1)
-                    .setAction(ImmutableList.of(new ActionBuilder()
-                    .setOrder(0)
-                    .setAction(new OutputActionCaseBuilder()
-                                    .setOutputAction(new OutputActionBuilder()
-                                                            .setOutputNodeConnector(new Uri("openflow:1:3"))
-                                                            .build())
-                                    .build())
-                    .build()))
-                    .build());
+                .setBucketId(new BucketId((long) 0))
+                .setWatchPort((long)3)
+                .setWatchGroup((long) 1)
+                .setAction(ImmutableList.of(new ActionBuilder()
+                        .setOrder(0)
+                        .setAction(new OutputActionCaseBuilder()
+                                .setOutputAction(new OutputActionBuilder()
+                                        .setOutputNodeConnector(new Uri("openflow:1:3"))
+                                        .build())
+                                .build())
+                        .build()))
+                .build());
 
 
         final AddGroupInput input = new AddGroupInputBuilder()
-                                    .setGroupId(new GroupId((long) 1))
-                                    .setGroupName("Foo")
-                                    .setGroupType(GroupTypes.GroupFf)
-                                    .setBuckets(new BucketsBuilder()
-                                                       .setBucket(bucket)
-                                                       .build())
-                                    .build();
+                .setGroupId(new GroupId((long) 1))
+                .setGroupName("Foo")
+                .setGroupType(GroupTypes.GroupFf)
+                .setBuckets(new BucketsBuilder()
+                        .setBucket(bucket)
+                        .build())
+                .build();
 
         OpenflowPortsUtil.init();
 
-        final GroupModInputBuilder outAddGroupInput = GroupConvertor.toGroupModInput(input, (short) 0X4, BigInteger.valueOf(1));
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
+        data.setDatapathId(BigInteger.valueOf(1));
+
+        final GroupModInputBuilder outAddGroupInput = convert(input, data);
 
         final List<BucketsList> bucketList = outAddGroupInput.getBucketsList();
         Assert.assertEquals( Long.valueOf(1), bucketList.get(0).getWatchGroup());
@@ -412,7 +433,7 @@ public class GroupConvertorTest {
     }
 
     /**
-     * test of {@link GroupConvertor#toGroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, short, java.math.BigInteger)} )}
+     * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
      */
     @Test
     public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeAll() {
@@ -460,7 +481,10 @@ public class GroupConvertorTest {
 
         addGroupBuilder.setBuckets(buckets);
 
-        final GroupModInputBuilder outAddGroupInput = GroupConvertor.toGroupModInput(addGroupBuilder.build(), (short) 0X4, BigInteger.valueOf(1));
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
+        data.setDatapathId(BigInteger.valueOf(1));
+
+        final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
 
         Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
         Assert.assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
@@ -491,4 +515,10 @@ public class GroupConvertorTest {
         }
 
     }
+
+    private GroupModInputBuilder convert(Group group, VersionDatapathIdConvertorData data) {
+        final Optional<GroupModInputBuilder> outAddGroupInputOptional = convertorManager.convert(group, data);
+        Assert.assertTrue("Group convertor not found", outAddGroupInputOptional.isPresent());
+        return outAddGroupInputOptional.get();
+    }
 }
@@ -9,14 +9,21 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
-\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
@@ -31,9 +38,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab\r
  *\r
  */\r
-public class GroupStatsResponseConvertorTest2 {\r
+public class GroupDescStatsResponseConvertorTest {\r
+    private ConvertorManager convertorManager;\r
 \r
-    GroupStatsResponseConvertor convertor =  new GroupStatsResponseConvertor();\r
+    @Before\r
+    public void setUp() {\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+    }\r
 \r
     /**\r
      * Test empty GroupDescStats conversion\r
@@ -42,8 +53,8 @@ public class GroupStatsResponseConvertorTest2 {
     public void test() {\r
         List<GroupDesc> groupDescStats = new ArrayList<>();\r
 \r
-        List<GroupDescStats> statsList = convertor.toSALGroupDescStatsList(groupDescStats, OpenflowVersion.OF13);\r
-\r
+        VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        List<GroupDescStats> statsList = convert(groupDescStats, data);\r
         Assert.assertEquals("Wrong groupDesc stats size", 0, statsList.size());\r
     }\r
 \r
@@ -56,10 +67,11 @@ public class GroupStatsResponseConvertorTest2 {
         GroupDescBuilder builder = new GroupDescBuilder();\r
         builder.setType(GroupType.OFPGTALL);\r
         builder.setGroupId(new GroupId(42L));\r
-        builder.setBucketsList(new ArrayList<BucketsList>());\r
+        builder.setBucketsList(new ArrayList<>());\r
         groupDescStats.add(builder.build());\r
 \r
-        List<GroupDescStats> statsList = convertor.toSALGroupDescStatsList(groupDescStats, OpenflowVersion.OF13);\r
+        VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        List<GroupDescStats> statsList = convert(groupDescStats, data);\r
 \r
         Assert.assertEquals("Wrong groupDesc stats size", 1, statsList.size());\r
         GroupDescStats stat = statsList.get(0);\r
@@ -75,56 +87,100 @@ public class GroupStatsResponseConvertorTest2 {
     @Test\r
     public void testGroupDescStats() {\r
         List<GroupDesc> groupDescStats = new ArrayList<>();\r
+\r
+        // **********************************************\r
+        // First group desc\r
+        // **********************************************\r
         GroupDescBuilder builder = new GroupDescBuilder();\r
         builder.setType(GroupType.OFPGTFF);\r
         builder.setGroupId(new GroupId(42L));\r
+\r
+        // Buckets for first group desc\r
         List<BucketsList> bucketsList = new ArrayList<>();\r
         BucketsListBuilder bucketsBuilder = new BucketsListBuilder();\r
         bucketsBuilder.setWeight(16);\r
         bucketsBuilder.setWatchPort(new PortNumber(84L));\r
         bucketsBuilder.setWatchGroup(168L);\r
+\r
+        // Actions for buckets for first group desc\r
         List<Action> actions = new ArrayList<>();\r
         ActionBuilder actionBuilder = new ActionBuilder();\r
+        actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
+\r
+        // Build bucket with actions\r
         bucketsBuilder.setAction(actions);\r
         bucketsList.add(bucketsBuilder.build());\r
+\r
+        // Build first group desc\r
         builder.setBucketsList(bucketsList);\r
         groupDescStats.add(builder.build());\r
+\r
+        // **********************************************\r
+        // Second group desc\r
+        // **********************************************\r
         builder = new GroupDescBuilder();\r
         builder.setType(GroupType.OFPGTINDIRECT);\r
         builder.setGroupId(new GroupId(50L));\r
+\r
+        // First buckets for second group desc\r
         bucketsList = new ArrayList<>();\r
         bucketsBuilder = new BucketsListBuilder();\r
         bucketsBuilder.setWeight(100);\r
         bucketsBuilder.setWatchPort(new PortNumber(200L));\r
         bucketsBuilder.setWatchGroup(400L);\r
+\r
+        // Actions for first buckets for second group desc\r
         actions = new ArrayList<>();\r
+\r
         actionBuilder = new ActionBuilder();\r
+        actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
+        actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
+        actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
+\r
+        // Build first bucket with actions\r
         bucketsBuilder.setAction(actions);\r
         bucketsList.add(bucketsBuilder.build());\r
+\r
+        // Second buckets for second group desc\r
         bucketsBuilder = new BucketsListBuilder();\r
         bucketsBuilder.setWeight(5);\r
         bucketsBuilder.setWatchPort(new PortNumber(10L));\r
         bucketsBuilder.setWatchGroup(15L);\r
+\r
+        // Actions for second buckets for second group desc\r
         actions = new ArrayList<>();\r
+\r
+        // Build second bucket with actions\r
         bucketsBuilder.setAction(actions);\r
         bucketsList.add(bucketsBuilder.build());\r
+\r
+        // Build second group desc\r
         builder.setBucketsList(bucketsList);\r
         groupDescStats.add(builder.build());\r
 \r
-        List<GroupDescStats> statsList = convertor.toSALGroupDescStatsList(groupDescStats, OpenflowVersion.OF13);\r
 \r
+        VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        List<GroupDescStats> statsList = convert(groupDescStats, data);\r
         Assert.assertEquals("Wrong groupDesc stats size", 2, statsList.size());\r
+\r
+        // **********************************************\r
+        // Test first group desc\r
+        // **********************************************\r
         GroupDescStats stat = statsList.get(0);\r
         Assert.assertEquals("Wrong type", GroupTypes.GroupFf, stat.getGroupType());\r
         Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().getBucket().size());\r
+\r
+        // Test first bucket for first group desc\r
         Bucket bucket = stat.getBuckets().getBucket().get(0);\r
         Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());\r
         Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());\r
@@ -132,17 +188,24 @@ public class GroupStatsResponseConvertorTest2 {
         Assert.assertEquals("Wrong type", 168, bucket.getWatchGroup().intValue());\r
         Assert.assertEquals("Wrong type", 84, bucket.getWatchPort().intValue());\r
         Assert.assertEquals("Wrong type", 1, bucket.getAction().size());\r
+\r
+        // Test first action for first bucket for first group desc\r
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list\r
-        .Action action = bucket.getAction().get(0);\r
+                .Action action = bucket.getAction().get(0);\r
         Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());\r
         Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
                 + ".action.action.CopyTtlInCase", action.getAction().getImplementedInterface().getName());\r
 \r
+        // **********************************************\r
+        // Test second group desc\r
+        // **********************************************\r
         stat = statsList.get(1);\r
         Assert.assertEquals("Wrong type", GroupTypes.GroupIndirect, stat.getGroupType());\r
         Assert.assertEquals("Wrong group-id", 50, stat.getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong key", 50, stat.getKey().getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().getBucket().size());\r
+\r
+        // Test first bucket for second group desc\r
         bucket = stat.getBuckets().getBucket().get(0);\r
         Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());\r
         Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());\r
@@ -150,18 +213,26 @@ public class GroupStatsResponseConvertorTest2 {
         Assert.assertEquals("Wrong type", 400, bucket.getWatchGroup().intValue());\r
         Assert.assertEquals("Wrong type", 200, bucket.getWatchPort().intValue());\r
         Assert.assertEquals("Wrong type", 3, bucket.getAction().size());\r
+\r
+        // Test first action for first bucket of second group desc\r
         action = bucket.getAction().get(0);\r
         Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());\r
         Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
                 + ".action.action.CopyTtlOutCase", action.getAction().getImplementedInterface().getName());\r
+\r
+        // Test second action for first bucket of second group desc\r
         action = bucket.getAction().get(1);\r
         Assert.assertEquals("Wrong type", 1, action.getOrder().intValue());\r
         Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
                 + ".action.action.DecNwTtlCase", action.getAction().getImplementedInterface().getName());\r
+\r
+        // Test third action for first bucket of second group desc\r
         action = bucket.getAction().get(2);\r
         Assert.assertEquals("Wrong type", 2, action.getOrder().intValue());\r
         Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
                 + ".action.action.PopPbbActionCase", action.getAction().getImplementedInterface().getName());\r
+\r
+        // Test second bucket for second group desc\r
         bucket = stat.getBuckets().getBucket().get(1);\r
         Assert.assertEquals("Wrong type", 1, bucket.getKey().getBucketId().getValue().intValue());\r
         Assert.assertEquals("Wrong type", 1, bucket.getBucketId().getValue().intValue());\r
@@ -170,4 +241,9 @@ public class GroupStatsResponseConvertorTest2 {
         Assert.assertEquals("Wrong type", 10, bucket.getWatchPort().intValue());\r
         Assert.assertEquals("Wrong type", 0, bucket.getAction().size());\r
     }\r
-}
\ No newline at end of file
+\r
+    private List<GroupDescStats> convert(List<GroupDesc> groupDescStats,VersionConvertorData data) {\r
+        Optional<List<GroupDescStats>> statsListOptional = convertorManager.convert(groupDescStats, data);\r
+        return  statsListOptional.orElse(Collections.emptyList());\r
+    }\r
+}\r
index df7a13546010cb0bec85c1e351fa7eebfdb7417e..c0d570058577f6403a69476879ef03bad3eb9384 100644 (file)
@@ -12,8 +12,12 @@ import java.math.BigInteger;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
+import java.util.Optional;\r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;\r
@@ -26,8 +30,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  *\r
  */\r
 public class GroupStatsResponseConvertorTest {\r
+    private ConvertorManager convertorManager;\r
 \r
-    GroupStatsResponseConvertor convertor =  new GroupStatsResponseConvertor();\r
+    @Before\r
+    public void setUp() {\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+    }\r
 \r
     /**\r
      * Test empty GroupStats conversion\r
@@ -36,10 +44,10 @@ public class GroupStatsResponseConvertorTest {
     public void testEmptyGroupStats() {\r
         List<GroupStats> groupStats = new ArrayList<>();\r
 \r
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats> salGroupStats = convertor.toSALGroupStatsList(groupStats);\r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
+                .GroupStats>> salGroupStats = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
 \r
-        Assert.assertEquals("Wrong group stats size", 0, salGroupStats.size());\r
+        Assert.assertFalse("Group stats response should be not present", salGroupStats.isPresent());\r
     }\r
 \r
     /**\r
@@ -58,12 +66,15 @@ public class GroupStatsResponseConvertorTest {
         statsBuilder.setBucketStats(new ArrayList<BucketStats>());\r
         groupStats.add(statsBuilder.build());\r
 \r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
+                .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
+        Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());\r
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats> salGroupStats = convertor.toSALGroupStatsList(groupStats);\r
+                .GroupStats> salGroupStats = salGroupStatsOptional.get();\r
 \r
         Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());\r
         org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats stat = salGroupStats.get(0);\r
+                .GroupStats stat = salGroupStats.get(0);\r
         Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());\r
         Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());\r
@@ -98,12 +109,15 @@ public class GroupStatsResponseConvertorTest {
         statsBuilder.setBucketStats(new ArrayList<BucketStats>());\r
         groupStats.add(statsBuilder.build());\r
 \r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
+                .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
+        Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());\r
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats> salGroupStats = convertor.toSALGroupStatsList(groupStats);\r
+                .GroupStats> salGroupStats = salGroupStatsOptional.get();\r
 \r
         Assert.assertEquals("Wrong group stats size", 2, salGroupStats.size());\r
         org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats stat = salGroupStats.get(0);\r
+                .GroupStats stat = salGroupStats.get(0);\r
         Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());\r
@@ -148,12 +162,15 @@ public class GroupStatsResponseConvertorTest {
         statsBuilder.setBucketStats(bucketStats);\r
         groupStats.add(statsBuilder.build());\r
 \r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
+                .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
+        Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());\r
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats> salGroupStats = convertor.toSALGroupStatsList(groupStats);\r
+                .GroupStats> salGroupStats = salGroupStatsOptional.get();\r
 \r
         Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());\r
         org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
-        .GroupStats stat = salGroupStats.get(0);\r
+                .GroupStats stat = salGroupStats.get(0);\r
         Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
         Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());\r
         Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());\r
@@ -169,4 +186,4 @@ public class GroupStatsResponseConvertorTest {
         Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());\r
         Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());\r
     }\r
-}
\ No newline at end of file
+}\r
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertorTest.java
new file mode 100644 (file)
index 0000000..9360829
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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.openflow.md.core.sal.convertor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class MeterConfigStatsResponseConvertorTest {
+    private static final int PRESET_COUNT = 7;
+
+    private List<MeterConfig> createMeterConfigList(){
+        List<MeterConfig> meterConfigs = new ArrayList<>();
+        MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
+        for (int i = 0; i < PRESET_COUNT; i++) {
+            meterConfigBuilder.setMeterId(new MeterId((long) i));
+            List<Bands> bandses = new ArrayList<>();
+
+            BandsBuilder bandsBuilder = new BandsBuilder();
+            bandsBuilder.setMeterBand(new MeterBandDropCaseBuilder()
+                    .setMeterBandDrop(new MeterBandDropBuilder().build()).build());
+            bandses.add(bandsBuilder.build());
+
+            bandsBuilder = new BandsBuilder();
+            bandsBuilder.setMeterBand(new MeterBandDscpRemarkCaseBuilder()
+                    .setMeterBandDscpRemark(new MeterBandDscpRemarkBuilder().build()).build());
+            bandses.add(bandsBuilder.build());
+
+            bandsBuilder = new BandsBuilder();
+            bandsBuilder.setMeterBand(new MockMeterBandBuilder());
+            bandses.add(bandsBuilder.build());
+
+            bandsBuilder = new BandsBuilder();
+            bandsBuilder.setMeterBand(new MeterBandExperimenterCaseBuilder()
+                    .setMeterBandExperimenter(new MeterBandExperimenterBuilder().build()).build());
+            bandses.add(bandsBuilder.build());
+
+            meterConfigBuilder.setBands(bandses);
+            meterConfigBuilder.setFlags(new MeterFlags(true, false, true, false));
+            meterConfigs.add(meterConfigBuilder.build());
+        }
+
+        return meterConfigs;
+    }
+
+    @Test
+    /**
+     * Test of basic mapping functionality of {@link MeterConfigStatsResponseConvertor#convert(java.util.List)} }
+     */
+    public void testToSALMeterConfigList() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        Optional<List<MeterConfigStats>> meterConfigsOptional = convertorManager.convert(createMeterConfigList(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+        List<MeterConfigStats> meterConfigs = meterConfigsOptional.orElse(Collections.emptyList());
+
+        assertEquals(PRESET_COUNT, meterConfigs.size());
+        int cnt = 0;
+        for (MeterConfigStats meterConfigStats: meterConfigs){
+            assertEquals(new Long(cnt), meterConfigStats.getMeterId().getValue());
+            assertTrue(meterConfigStats.getFlags().isMeterBurst());
+            assertFalse(meterConfigStats.getFlags().isMeterKbps());
+            assertTrue(meterConfigStats.getFlags().isMeterPktps());
+            assertFalse(meterConfigStats.getFlags().isMeterStats());
+
+            cnt++;
+        }
+    }
+
+
+    private final class MockMeterBandBuilder implements org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand {
+
+        @Override
+        public Class<? extends DataContainer> getImplementedInterface() {
+            return MockMeterBandBuilder.class;
+        }
+    }
+
+}
\ No newline at end of file
index 6edaf42c04ef8a73db67ce6031763c751cf7620c..dd4add67d1d588c2f03e89fb35d192e6520ec992 100644 (file)
@@ -13,10 +13,13 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Optional;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 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.types.rev130918.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop;
@@ -40,12 +43,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;
 
 public class MeterConvertorTest {
+    private ConvertorManager convertorManager;
 
-
+    @Before
+    public void setUp() {
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
+    }
 
     @Test
     public void testMeterModCommandConvertorwithAllParameters() {
-
         long BURST_SIZE = 10L;
         long DROP_RATE = 20L;
         // / DROP Band
@@ -116,8 +122,8 @@ public class MeterConvertorTest {
         AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
 
         addMeterFromSAL.setMeterBandHeaders(meterBandHeaders); // MeterBands
-                                                               // added to the
-                                                               // meter command.
+        // added to the
+        // meter command.
         Long temp = 10L;
 
         // NodeKey key = new NodeKey(new NodeId("24"));
@@ -131,7 +137,7 @@ public class MeterConvertorTest {
         addMeterFromSAL.setFlags(flagV);
 
         AddMeterInput meterInputCommand = addMeterFromSAL.build();
-        MeterModInputBuilder outMeterModInput = MeterConvertor.toMeterModInput(meterInputCommand, (short) 0X4);
+        MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
 
         assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
         assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
@@ -174,9 +180,9 @@ public class MeterConvertorTest {
         }
 
     }
+
     @Test
     public void testMeterModCommandConvertorwithNoFlags() {
-
         long BURST_SIZE = 10L;
         long DROP_RATE = 20L;
         // / DROP Band
@@ -249,8 +255,8 @@ public class MeterConvertorTest {
         AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
 
         addMeterFromSAL.setMeterBandHeaders(meterBandHeaders); // MeterBands
-                                                               // added to the
-                                                               // meter command.
+        // added to the
+        // meter command.
         Long temp = 10L;
 
         // NodeKey key = new NodeKey(new NodeId("24"));
@@ -263,7 +269,7 @@ public class MeterConvertorTest {
 
 
         AddMeterInput meterInputCommand = addMeterFromSAL.build();
-        MeterModInputBuilder outMeterModInput = MeterConvertor.toMeterModInput(meterInputCommand, (short) 0X4);
+        MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
 
         assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
         assertFalse(outMeterModInput.getFlags().isOFPMFBURST());
@@ -307,10 +313,9 @@ public class MeterConvertorTest {
         }
 
     }
+
     @Test
     public void testMeterModCommandConvertorBandDataisNULL() {
-
-
         AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
 
         Long temp = 10L;
@@ -326,12 +331,12 @@ public class MeterConvertorTest {
         addMeterFromSAL.setFlags(flagV);
 
         AddMeterInput meterInputCommand = addMeterFromSAL.build();
-        MeterModInputBuilder outMeterModInput = MeterConvertor.toMeterModInput(meterInputCommand, (short) 0X4);
+        MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
 
         assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
         assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
         assertEquals(temp, outMeterModInput.getMeterId().getValue());
-       }
+    }
 
     @Test
     public void testMeterModCommandConvertorNoValidBandData() {
@@ -392,8 +397,8 @@ public class MeterConvertorTest {
         AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
 
         addMeterFromSAL.setMeterBandHeaders(meterBandHeaders); // MeterBands
-                                                               // added to the
-                                                               // meter command.
+        // added to the
+        // meter command.
         Long temp = 10L;
 
         // NodeKey key = new NodeKey(new NodeId("24"));
@@ -407,7 +412,7 @@ public class MeterConvertorTest {
         addMeterFromSAL.setFlags(flagV);
 
         AddMeterInput meterInputCommand = addMeterFromSAL.build();
-        MeterModInputBuilder outMeterModInput = MeterConvertor.toMeterModInput(meterInputCommand, (short) 0X4);
+        MeterModInputBuilder outMeterModInput = convert(meterInputCommand, new VersionConvertorData((short) 0X4));
 
         assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
         assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
@@ -451,4 +456,8 @@ public class MeterConvertorTest {
 
     }
 
-}
+    private MeterModInputBuilder convert(Meter source, VersionConvertorData data) {
+        Optional<MeterModInputBuilder> outMeterModInputOptional = convertorManager.convert(source, data);
+        return outMeterModInputOptional.orElse(MeterConvertor.defaultResult(data.getVersion()));
+    }
+}
\ No newline at end of file
index 8bc4c258942900991fc7ec119a512a159ea0dd95..33db1c193729947b92233d726833e99b0e34dcd8 100644 (file)
@@ -9,33 +9,24 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
 
-/**
- * Created by Martin Bobak mbobak@cisco.com on 9/18/14.
- */
 public class MeterStatsResponseConvertorTest {
-
-    private static final MeterStatsResponseConvertor METER_STATS_RESPONSE_CONVERTOR = new MeterStatsResponseConvertor();
     private static final int PRESET_COUNT = 7;
 
 
@@ -67,30 +58,14 @@ public class MeterStatsResponseConvertorTest {
         return allMeterStats;
     }
 
-    private final List<MeterConfig> createMeterConfigList(){
-        List<MeterConfig> meterConfigs = new ArrayList<>();
-        MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
-        for (int i = 0; i < PRESET_COUNT; i++) {
-            meterConfigBuilder.setMeterId(new MeterId((long) i));
-            List<Bands> bandses = new ArrayList<>();
-            for (int j = 0; j < PRESET_COUNT; j++){
-                BandsBuilder bandsBuilder = new BandsBuilder();
-                bandsBuilder.setMeterBand(new MockMeterBandBuilder());
-                bandses.add(bandsBuilder.build());
-            }
-            meterConfigBuilder.setBands(bandses);
-            meterConfigBuilder.setFlags(new MeterFlags(true, false, true, false));
-            meterConfigs.add(meterConfigBuilder.build());
-        }
-        return meterConfigs;
-    }
     @Test
     /**
-     * Test of basic mapping functionality of {@link MeterStatsResponseConvertor#toSALMeterStatsList(java.util.List)}
+     * Test of basic mapping functionality of {@link MeterStatsResponseConvertor#convert(java.util.List)}
      */
     public void testToSALMeterStatsList() {
-
-        List<MeterStats> meterStatsList = METER_STATS_RESPONSE_CONVERTOR.toSALMeterStatsList(createMeterStatsLit());
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        Optional<List<MeterStats>> meterStatsListOptional = convertorManager.convert(createMeterStatsLit(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+        List<MeterStats> meterStatsList = meterStatsListOptional.orElse(Collections.emptyList());
         assertEquals(PRESET_COUNT, meterStatsList.size());
 
         int cnt = 0;
@@ -115,33 +90,4 @@ public class MeterStatsResponseConvertorTest {
             cnt++;
         }
     }
-
-    @Test
-    /**
-     * Test of basic mapping functionality of {@link MeterStatsResponseConvertor#toSALMeterStatsList(java.util.List)}
-     */
-    public void testToSALMeterConfigList() {
-        List<MeterConfigStats> meterConfigs = METER_STATS_RESPONSE_CONVERTOR.toSALMeterConfigList(createMeterConfigList());
-        assertEquals(PRESET_COUNT, meterConfigs.size());
-        int cnt = 0;
-        for (MeterConfigStats meterConfigStats: meterConfigs){
-            assertEquals(new Long(cnt), meterConfigStats.getMeterId().getValue());
-            assertTrue(meterConfigStats.getFlags().isMeterBurst());
-            assertFalse(meterConfigStats.getFlags().isMeterKbps());
-            assertTrue(meterConfigStats.getFlags().isMeterPktps());
-            assertFalse(meterConfigStats.getFlags().isMeterStats());
-
-            cnt++;
-        }
-    }
-
-
-    private final class MockMeterBandBuilder implements org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand {
-
-        @Override
-        public Class<? extends DataContainer> getImplementedInterface() {
-            return MockMeterBandBuilder.class;
-        }
-    }
-
-}
+}
\ No newline at end of file
index e9cccd8f7f88b0279127d34f568edaeb3543e9c2..ca5909d6935bb6eb6a74c8a965bd0190a23f7a1c 100644 (file)
@@ -10,13 +10,17 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 \r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 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.core.sal.convertor.action.data.ActionConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;\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.rev130715.Uri;\r
@@ -48,9 +52,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 \r
 public class PacketOutConvertorTest {\r
 \r
+    private ConvertorManager convertorManager;\r
+\r
     @Before\r
-    public void init() {\r
+    public void setUp() {\r
         OpenflowPortsUtil.init();\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
     }\r
 \r
     /**\r
@@ -83,13 +90,12 @@ public class PacketOutConvertorTest {
 \r
         Short version = (short) 0x04;\r
         Long xid = null;\r
-        PacketOutInput message = PacketOutConvertor.toPacketOutInput(\r
-                transmitPacketInput, version, null, null);\r
+        PacketOutConvertorData data = new PacketOutConvertorData(version);\r
+        PacketOutInput message = convert(transmitPacketInput, data);\r
 \r
         //FIXME : this has to be fixed along with actions changed in openflowjava\r
 \r
-        Assert.assertEquals(PacketOutConvertorTest.buildActionForNullTransmitPacketInputAction(nodeConnKey,\r
-                version), message.getAction());\r
+        Assert.assertEquals(buildActionForNullTransmitPacketInputAction(nodeConnKey, version), message.getAction());\r
 \r
         Assert.assertEquals(OFConstants.OFP_NO_BUFFER, message.getBufferId());\r
         Assert.assertEquals(new PortNumber(0xfffffffdL), message.getInPort());\r
@@ -163,8 +169,10 @@ public class PacketOutConvertorTest {
 \r
         OpenflowPortsUtil.init();\r
 \r
-        PacketOutInput message = PacketOutConvertor.toPacketOutInput(\r
-                transmitPacketInput, version, xid, datapathId);\r
+        PacketOutConvertorData data = new PacketOutConvertorData(version);\r
+        data.setXid(xid);\r
+        data.setDatapathId(datapathId);\r
+        PacketOutInput message = convert(transmitPacketInput, data);\r
 \r
         Assert.assertEquals(transmitPacketInput.getBufferId(),\r
                 message.getBufferId());\r
@@ -173,9 +181,15 @@ public class PacketOutConvertorTest {
         Assert.assertEquals((Object) version,\r
                 Short.valueOf(message.getVersion()));\r
         Assert.assertEquals(xid, message.getXid());\r
-        Assert.assertEquals(\r
-                ActionConvertor.getActions(actionList, version, datapathId, null),\r
-                message.getAction());\r
+\r
+        ActionConvertorData actionConvertorData = new ActionConvertorData(version);\r
+        actionConvertorData.setDatapathId(datapathId);\r
+\r
+        Optional<List<Action>> actionsOptional = convertorManager.convert(\r
+                actionList, actionConvertorData);\r
+\r
+        List<Action> actions = actionsOptional.orElse(Collections.emptyList());\r
+        Assert.assertEquals(actions, message.getAction());\r
         Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());\r
     }\r
 \r
@@ -269,4 +283,9 @@ public class PacketOutConvertorTest {
                 .<Node, NodeKey>child(Node.class, key).build();\r
         return new NodeRef(path);\r
     }\r
+\r
+    private PacketOutInput convert(TransmitPacketInput transmitPacketInput, PacketOutConvertorData data) {\r
+        Optional<PacketOutInput> messageOptional = convertorManager.convert(transmitPacketInput, data);\r
+        return messageOptional.orElse(PacketOutConvertor.defaultResult(data.getVersion()));\r
+    }\r
 }\r
index d5a2cc0486f5c84a31b37a9bb44b2e355dc501f1..98a3adaf94611769c269e9a8ea80618993569424 100644 (file)
@@ -7,10 +7,13 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
@@ -45,7 +48,7 @@ public class PortConvertorTest {
                     false, false, false, false);
 
     /**
-     * test of {@link PortConvertor#toPortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port, short)}
+     * test of {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)} }
      */
     @Test
     public void testtoPortModInputwithAllParameters()
@@ -57,7 +60,10 @@ public class PortConvertorTest {
         portBld.setPortNumber(new PortNumberUni(42L));
         portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
 
-        PortModInput portOut = PortConvertor.toPortModInput(portBld.build(), EncodeConstants.OF13_VERSION_ID);
+        VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        Optional<PortModInput> portOutOptional = convertorManager.convert(portBld.build(), data);
+        PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
 
         PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false);
 
index 9d8e611dba1f3b3652d59e84e70150fc382bc541..720f98d163b20c3c6512c27516b63353a162b5cf 100644 (file)
@@ -8,19 +8,21 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import junit.framework.TestCase;
+import java.util.Optional;
 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.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
@@ -46,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
@@ -72,6 +75,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
@@ -82,11 +86,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
 
-@RunWith(MockitoJUnitRunner.class)
-public class TableFeaturesConvertorTest extends TestCase {
-
-    @Mock
-    private TableFeatures tableFeatures;
+public class TableFeaturesConvertorTest {
     private static final TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
     private static final Map<Class<? extends TableFeaturePropType>, TableFeaturePropType> augmentationsMap = new HashMap<>();
     private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction> instructionsList = new ArrayList<>();
@@ -185,7 +185,7 @@ public class TableFeaturesConvertorTest extends TestCase {
         fieldTableFeatures.add(setFieldMatchBuilder.build());
         setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
         fieldTableFeatures.add(setFieldMatchBuilder.build());
-        setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlag.class);
+        setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class);
         fieldTableFeatures.add(setFieldMatchBuilder.build());
         setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class);
         fieldTableFeatures.add(setFieldMatchBuilder.build());
@@ -277,10 +277,10 @@ public class TableFeaturesConvertorTest extends TestCase {
         augmentationsMap.put(NextTableMiss.class, nextTableMissBuilder.build());
 
         WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
-        augmentationsMap.put(NextTableMiss.class, writeActionsBuilder.build());
+        augmentationsMap.put(WriteActions.class, writeActionsBuilder.build());
 
         WriteActionsMissBuilder writeActionsMissBuilder = new WriteActionsMissBuilder();
-        augmentationsMap.put(WriteActions.class, writeActionsMissBuilder.build());
+        augmentationsMap.put(WriteActionsMiss.class, writeActionsMissBuilder.build());
 
         ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
         augmentationsMap.put(ApplyActions.class, applyActionsBuilder.build());
@@ -315,7 +315,7 @@ public class TableFeaturesConvertorTest extends TestCase {
 
     @Test
     /**
-     * Basic functionality test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor#toTableFeaturesRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures)}
+     * Basic functionality test method for {@link TableFeaturesConvertor#toTableFeaturesRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures)}
      */
     public void testToTableFeaturesRequest() throws Exception {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> tableFeaturesList = new ArrayList<>();
@@ -330,8 +330,19 @@ public class TableFeaturesConvertorTest extends TestCase {
             tableFeaturesBuilder.setTableProperties(getTableProperties());
             tableFeaturesList.add(tableFeaturesBuilder.build());
         }
-        when(tableFeatures.getTableFeatures()).thenReturn(tableFeaturesList);
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures> tableFeatureses = TableFeaturesConvertor.toTableFeaturesRequest(tableFeatures);
+
+        TableFeatures tableFeatures = new UpdatedTableBuilder()
+                .setTableFeatures(tableFeaturesList)
+                .build();
+
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures>> tableFeaturesesOptional =
+                convertorManager.convert(tableFeatures, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures> tableFeatureses =
+                tableFeaturesesOptional.orElse(Collections.emptyList());
+
         assertNotNull(tableFeatures);
         assertEquals(10, tableFeatures.getTableFeatures().size());
         List<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties();
@@ -364,4 +375,4 @@ public class TableFeaturesConvertorTest extends TestCase {
         tablePropertiesBuilder.setTableFeatureProperties(tableFeaturePropertieses);
         return tablePropertiesBuilder.build();
     }
-}
\ No newline at end of file
+}
@@ -10,10 +10,15 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 \r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;\r
@@ -83,6 +88,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Vlan
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;\r
@@ -103,14 +109,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 /**\r
  * @author michal.polkorab\r
  */\r
-public class TableFeaturesReplyConvertorTest {\r
+public class TableFeaturesResponseConvertorTest {\r
+    private ConvertorManager convertorManager;\r
+\r
+    @Before\r
+    public void setUp() {\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+    }\r
 \r
     /**\r
      * Incorrect / empty input test\r
      */\r
     @Test\r
     public void test() {\r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(null);\r
+        List<TableFeatures> list = convert(null);\r
         Assert.assertEquals("Returned list is not empty", 0, list.size());\r
     }\r
 \r
@@ -120,7 +132,7 @@ public class TableFeaturesReplyConvertorTest {
     @Test\r
     public void test2() {\r
         MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();\r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(builder.build());\r
+        List<TableFeatures> list = convert(builder.build());\r
         Assert.assertEquals("Returned list is not empty", 0, list.size());\r
     }\r
 \r
@@ -144,7 +156,7 @@ public class TableFeaturesReplyConvertorTest {
         featuresBuilder.setMaxEntries(42L);\r
         features.add(featuresBuilder.build());\r
         builder.setTableFeatures(features);\r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(builder.build());\r
+        List<TableFeatures> list = convert(builder.build());\r
         Assert.assertEquals("Returned empty list", 1, list.size());\r
         TableFeatures feature = list.get(0);\r
         Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());\r
@@ -500,11 +512,30 @@ public class TableFeaturesReplyConvertorTest {
 \r
         propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());\r
         properties.add(propBuilder.build());\r
+\r
+        /* -------------------------------------------------- */\r
+\r
+        propBuilder = new TableFeaturePropertiesBuilder();\r
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);\r
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
+        properties.add(propBuilder.build());\r
+\r
+        /* -------------------------------------------------- */\r
+\r
+        propBuilder = new TableFeaturePropertiesBuilder();\r
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);\r
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
+        properties.add(propBuilder.build());\r
+\r
+        /* -------------------------------------------------- */\r
+\r
         featuresBuilder.setTableFeatureProperties(properties);\r
         features.add(featuresBuilder.build());\r
         builder.setTableFeatures(features);\r
 \r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(builder.build());\r
+        List<TableFeatures> list = convert(builder.build());\r
 \r
         Assert.assertEquals("Returned empty list", 2, list.size());\r
         TableFeatures feature = list.get(0);\r
@@ -567,7 +598,7 @@ public class TableFeaturesReplyConvertorTest {
         Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite());\r
         Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());\r
         Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());\r
-        Assert.assertEquals("Wrong properties", 10, feature.getTableProperties().getTableFeatureProperties().size());\r
+        Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());\r
         property = feature.getTableProperties().getTableFeatureProperties().get(0);\r
         Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match",\r
                 property.getTableFeaturePropType().getImplementedInterface().getName());\r
@@ -763,4 +794,9 @@ public class TableFeaturesReplyConvertorTest {
         return setFieldCaseBuilder.build();\r
     }\r
 \r
-}
+\r
+    private List<TableFeatures> convert(MultipartReplyTableFeatures features) {\r
+        Optional<List<TableFeatures>> listOptional = convertorManager.convert(features, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
+        return listOptional.orElse(Collections.emptyList());\r
+    }\r
+}
\ No newline at end of file
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertorTest.java
new file mode 100644 (file)
index 0000000..99a8474
--- /dev/null
@@ -0,0 +1,401 @@
+/**
+ * Copyright (c) 2014 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.openflow.md.core.sal.convertor.action;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+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.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+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.action.pop.mpls.action._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
+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.flow.types.rev131026.OutputPortValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+/**
+ * test for {@link ActionConvertor}
+ */
+public class ActionConvertorTest {
+
+    List<Action> actions = new ArrayList<>();
+    static Integer actionItem = 0;
+
+    /**
+     * prepare OpenflowPortsUtil util class
+     */
+    @Before
+    public void setUp() {
+        OpenflowPortsUtil.init();
+    }
+
+    @Test
+    public void testActionConvertorwithallParameters() {
+        OutputActionData();
+        CopyTtlData();
+        MplsTtlActionData();
+        vlanActionData();
+        mplsActionData();
+        setQueueActionData();
+        setGroupAction();
+        NwTtlAction();
+        pbbActionData();
+        setFieldData();
+        setExperimenterData();
+        dropActionData();
+
+        ActionConvertorData data = new ActionConvertorData((short) 0X4);
+        data.setDatapathId(BigInteger.ONE);
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> OFActionsList =
+                convertorManager.convert(actions, data);
+
+        outputActions(OFActionsList.orElse(Collections.emptyList()));
+
+    }
+
+    private void setExperimenterData() {
+
+        // TODO:SAL API Missing
+
+    }
+
+    private void dropActionData() {
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new DropActionCaseBuilder().build());
+
+        actions.add(actionItem++, AB.build());
+
+    }
+
+    private void setFieldData() {
+
+        SetFieldBuilder matchBuilder = new SetFieldBuilder();
+
+        matchBuilder.setInPort(new NodeConnectorId("openflow:1:2125"));
+
+        SetFieldBuilder setFB = new SetFieldBuilder();
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new SetFieldCaseBuilder().setSetField(setFB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+    }
+
+    private void pbbActionData() {
+        PushPbbActionBuilder pushpbb = new PushPbbActionBuilder();
+        pushpbb.setEthernetType(10);
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pushpbb.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+        PopPbbActionBuilder popPBB = new PopPbbActionBuilder();
+
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPBB.build()).build());
+
+        actions.add(actionItem++, AB1.build());
+
+    }
+
+    private void NwTtlAction() {
+        SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
+
+        setNwTtlActionBuilder.setNwTtl((short) 1);
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+        DecNwTtlBuilder necNwTtlBuilder = new DecNwTtlBuilder();
+
+
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new DecNwTtlCaseBuilder().setDecNwTtl(necNwTtlBuilder.build()).build());
+
+        actions.add(actionItem++, AB1.build());
+
+    }
+
+    private void setGroupAction() {
+
+        GroupActionBuilder grpIdAB = new GroupActionBuilder();
+        grpIdAB.setGroup("98");
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new GroupActionCaseBuilder().setGroupAction(grpIdAB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+    }
+
+    // TODO - check if this method is needed (private and never used locally) - see line 94
+
+    private static void outputActions(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> oFActionsList) {
+
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action : oFActionsList) {
+
+            if (action.getActionChoice() instanceof OutputActionCase) {
+                OutputActionCase outputActionCase = (OutputActionCase) action.getActionChoice();
+                Assert.assertEquals((Integer) 10, (outputActionCase.getOutputAction().getMaxLength()));
+                long port = 4294967293L;
+                Assert.assertEquals(port, (long) (outputActionCase.getOutputAction().getPort().getValue()));
+
+
+            }
+            if (action.getActionChoice() instanceof CopyTtlInCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlInCase.class.getName());
+
+            }
+            if (action.getActionChoice() instanceof CopyTtlOutCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlOutCase.class.getName());
+            }
+
+            if (action.getActionChoice() instanceof
+                    // TODO:getMplsTtl is missing.
+                    SetMplsTtlCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetMplsTtlCase.class.getName());
+
+            }
+            if (action.getActionChoice() instanceof DecMplsTtlCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+                        DecMplsTtlCase.class.getName());
+            }
+
+            if (action.getActionChoice() instanceof PushMplsCase) {
+                PushMplsCase pushMplsCase = (PushMplsCase) action.getActionChoice();
+                EtherType etherType = pushMplsCase.getPushMplsAction().getEthertype();
+
+                if (etherType != null) {
+                    Assert.assertEquals((Integer) 10, etherType.getValue());
+                }
+            }
+
+            if (action.getActionChoice() instanceof PopMplsCase) {
+                PopMplsCase popMplsCase = (PopMplsCase) action.getActionChoice();
+                Assert.assertEquals((Integer) 10, (popMplsCase.getPopMplsAction().getEthertype().getValue()));
+            }
+
+            if (action.getActionChoice() instanceof
+
+                    // TODO:SetQueue,I dont have getQueueId
+                    SetQueueCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetQueueCase.class.getName());
+            }
+
+            if (action.getActionChoice() instanceof GroupCase) {
+                GroupCase groupCase = (GroupCase) action.getActionChoice();
+                Assert.assertEquals(98, (long) (groupCase.getGroupAction().getGroupId()));
+            }
+
+            if (action.getActionChoice() instanceof PushVlanCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PushVlanCase.class.getName());
+            }
+
+            if (action.getActionChoice() instanceof PopVlanCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopVlanCase.class.getName());
+            }
+
+            if (action.getActionChoice() instanceof SetNwTtlCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetNwTtlCase.class.getName());
+            }
+            if (action.getActionChoice() instanceof DecNwTtlCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), DecNwTtlCase.class.getName());
+            }
+            if (action.getActionChoice() instanceof PushPbbCase) {
+                PushPbbCase pushPbbCase = (PushPbbCase) action.getActionChoice();
+                if (pushPbbCase.getPushPbbAction().getEthertype() != null) {
+                    Assert.assertEquals((Integer) 10, pushPbbCase.getPushPbbAction().getEthertype().getValue());
+                }
+            }
+
+            if (action.getActionChoice() instanceof PopMplsCase) {
+                Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopMplsCase.class.getName());
+            }
+            if (action.getActionChoice() instanceof SetFieldCase) {
+                SetFieldCase setFieldCase = (SetFieldCase) action.getActionChoice();
+                Assert.assertNotNull(setFieldCase.getSetFieldAction());
+
+/*
+                Assert.assertEquals(OpenflowBasicClass.class, sf.getMatchEntry().get(0).getOxmClass());
+
+                if (sf.getMatchEntry().get(0).getOxmMatchField().equals(InPort.class)) {
+                    InPortCase inPortCase = ((InPortCase) sf.getMatchEntry().get(0).getMatchEntryValue());
+                    Assert.assertEquals(2125, inPortCase.getInPort().getPortNumber().getValue().intValue());
+
+                }
+*/
+
+            }
+
+
+        }
+
+    }
+
+    private void OutputActionData() {
+        OutputActionBuilder outputB = new OutputActionBuilder();
+        outputB.setMaxLength(10);
+        Uri uri = new Uri(OutputPortValues.CONTROLLER.toString());
+        outputB.setOutputNodeConnector(uri);
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new OutputActionCaseBuilder().setOutputAction(outputB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+    }
+
+    private void CopyTtlData() {
+        CopyTtlOutBuilder copyB = new CopyTtlOutBuilder();
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+        CopyTtlInBuilder copyTtlInBuilder = new CopyTtlInBuilder();
+
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInBuilder.build()).build());
+
+        actions.add(actionItem++, AB1.build());
+
+    }
+
+    private void MplsTtlActionData() {
+
+        SetMplsTtlActionBuilder setMplsTtlActionB = new SetMplsTtlActionBuilder();
+
+        setMplsTtlActionB.setMplsTtl((short) 10);
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionB.build()).build());
+
+
+        actions.add(actionItem++, AB1.build());
+
+        DecMplsTtlBuilder decMplsTtlB = new DecMplsTtlBuilder();
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtlB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+    }
+
+    private void vlanActionData() {
+        PushVlanActionBuilder pvB = new PushVlanActionBuilder();
+
+        pvB.setVlanId(new VlanId(10));
+
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new PushVlanActionCaseBuilder().setPushVlanAction(pvB.build()).build());
+
+        actions.add(actionItem++, AB1.build());
+
+        PopVlanActionBuilder popVAB = new PopVlanActionBuilder();
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVAB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+    }
+
+    private void mplsActionData() {
+
+        PushMplsActionBuilder pushMB = new PushMplsActionBuilder();
+        pushMB.setEthernetType(10);
+
+        ActionBuilder AB = new ActionBuilder();
+        AB.setOrder(actionItem).setAction(new PushMplsActionCaseBuilder().setPushMplsAction(pushMB.build()).build());
+
+        actions.add(actionItem++, AB.build());
+
+        PopMplsActionBuilder popMB = new PopMplsActionBuilder();
+        popMB.setEthernetType(10);
+
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMB.build()).build());
+
+        actions.add(actionItem++, AB1.build());
+    }
+
+    private void setQueueActionData() {
+
+        SetQueueActionBuilder setQB = new SetQueueActionBuilder();
+        setQB.setQueue("99");
+
+        ActionBuilder AB1 = new ActionBuilder();
+        AB1.setOrder(actionItem).setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQB.build()).build());
+
+        actions.add(actionItem++, AB1.build());
+
+    }
+
+}
@@ -6,25 +6,33 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
  */\r
 \r
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;\r
 \r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
-\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertorUtil;\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.rev130715.IpVersion;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;\r
@@ -35,6 +43,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.StripVlanActionCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;\r
@@ -46,11 +55,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;\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.inventory.rev130819.tables.table.FlowBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase;\r
@@ -68,9 +80,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
  *\r
  */\r
 public class ActionConvertorV10Test {\r
+    private ConvertorManager convertorManager;\r
+\r
+    @Before\r
+    public void setUp() {\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+    }\r
 \r
     /**\r
-     * Test {@link ActionConvertor#getActions(List, short, BigInteger)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)}}\r
      */\r
     @Test\r
     public void testGetActions() {\r
@@ -83,6 +101,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(vlanPcpCaseBuilder.build());\r
         actionBuilder.setOrder(0);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         StripVlanActionCaseBuilder stripCaseBuilder = new StripVlanActionCaseBuilder();\r
         StripVlanActionBuilder stripBuilder = new StripVlanActionBuilder();\r
@@ -90,6 +109,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(stripCaseBuilder.build());\r
         actionBuilder.setOrder(1);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         SetDlDstActionCaseBuilder dlDstCaseBuilder = new SetDlDstActionCaseBuilder();\r
         SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();\r
@@ -98,6 +118,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(dlDstCaseBuilder.build());\r
         actionBuilder.setOrder(2);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         SetDlSrcActionCaseBuilder dlSrcCaseBuilder = new SetDlSrcActionCaseBuilder();\r
         SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();\r
@@ -129,6 +150,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(nwDstCaseBuilder.build());\r
         actionBuilder.setOrder(5);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         SetTpSrcActionCaseBuilder tpSrcCaseBuilder = new SetTpSrcActionCaseBuilder();\r
         SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();\r
@@ -137,6 +159,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(tpSrcCaseBuilder.build());\r
         actionBuilder.setOrder(6);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         SetTpDstActionCaseBuilder tpDstCaseBuilder = new SetTpDstActionCaseBuilder();\r
         SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();\r
@@ -145,6 +168,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(tpDstCaseBuilder.build());\r
         actionBuilder.setOrder(7);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         SetNwTosActionCaseBuilder tosCaseBuilder = new SetNwTosActionCaseBuilder();\r
         SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();\r
@@ -153,6 +177,7 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(tosCaseBuilder.build());\r
         actionBuilder.setOrder(8);\r
         salActions.add(actionBuilder.build());\r
+\r
         actionBuilder = new ActionBuilder();\r
         SetVlanIdActionCaseBuilder vlanIdCaseBuilder = new SetVlanIdActionCaseBuilder();\r
         SetVlanIdActionBuilder vlanIdBuilder = new SetVlanIdActionBuilder();\r
@@ -161,13 +186,39 @@ public class ActionConvertorV10Test {
         actionBuilder.setAction(vlanIdCaseBuilder.build());\r
         actionBuilder.setOrder(9);\r
         salActions.add(actionBuilder.build());\r
+\r
+        actionBuilder = new ActionBuilder();\r
+        PopVlanActionCaseBuilder popVlanActionCaseBuilder = new PopVlanActionCaseBuilder();\r
+        actionBuilder.setAction(popVlanActionCaseBuilder.build());\r
+        actionBuilder.setOrder(10);\r
+        salActions.add(actionBuilder.build());\r
+\r
+        actionBuilder = new ActionBuilder();\r
+        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();\r
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();\r
+        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();\r
+        vlanMatchBuilder.setVlanId(new VlanIdBuilder().setVlanId(new VlanId(22)).build());\r
+        setFieldBuilder.setVlanMatch(vlanMatchBuilder.build());\r
+        setFieldCaseBuilder.setSetField(setFieldBuilder.build());\r
+        actionBuilder.setAction(setFieldCaseBuilder.build());\r
+        actionBuilder.setOrder(11);\r
+        salActions.add(actionBuilder.build());\r
         \r
         IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProto(IpVersion.Ipv4);\r
         MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());\r
         FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());\r
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = ActionConvertor.getActions(salActions, EncodeConstants.OF10_VERSION_ID, new BigInteger("42"), flowBld.build());\r
+        Flow flow = flowBld.build();\r
+\r
+        ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        data.setDatapathId(new BigInteger("42"));\r
+        data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));\r
+\r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> actionsOptional =\r
+                convertorManager.convert(salActions, data);\r
+\r
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = actionsOptional.orElse(Collections.emptyList());\r
         \r
-        Assert.assertEquals("Wrong number of actions", 10, actions.size());\r
+        Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
         \r
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actions.get(0);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
@@ -226,10 +277,20 @@ public class ActionConvertorV10Test {
                 + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());\r
         SetVlanVidCase setVlanVidCase = (SetVlanVidCase) action.getActionChoice();\r
         Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());\r
+\r
+        action = actions.get(10);\r
+        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
+                + ".action.rev150203.action.grouping.action.choice.StripVlanCase", action.getActionChoice().getImplementedInterface().getName());\r
+\r
+        action = actions.get(11);\r
+        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
+                + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());\r
+        setVlanVidCase = (SetVlanVidCase) action.getActionChoice();\r
+        Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());\r
     }\r
 \r
     /**\r
-     * Test {@link ActionConvertor#toMDSalActions(List, OpenflowVersion, ActionPath)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)}}\r
      */\r
     @Test\r
     public void testToMDSalActions() {\r
@@ -245,19 +306,18 @@ public class ActionConvertorV10Test {
         outputBuilder.setMaxLength(555);\r
         caseBuilder.setOutputAction(outputBuilder.build());\r
         actionbuilder.setActionChoice(caseBuilder.build());\r
-        \r
-//        actionbuilder.setType(Output.class);\r
-//        PortActionBuilder portBuilder = new PortActionBuilder();\r
-//        portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(14L));\r
-//        actionbuilder.addAugmentation(PortAction.class, portBuilder.build());\r
-//        MaxLengthActionBuilder lengthBuilder = new MaxLengthActionBuilder();\r
-//        lengthBuilder.setMaxLength(555);\r
-//        actionbuilder.addAugmentation(MaxLengthAction.class, lengthBuilder.build());\r
         actions.add(actionbuilder.build());\r
 \r
+        ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        data.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+\r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
+        .Action>> mdSalActionsOptional =\r
+                convertorManager.convert(\r
+                        actions, data);\r
+\r
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
-        .Action> mdSalActions = ActionConvertor.toMDSalActions(actions, OpenflowVersion.OF10,\r
-                ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+                .Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());\r
 \r
         Assert.assertEquals("Wrong number of output actions", 1, mdSalActions.size());\r
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);\r
@@ -6,17 +6,23 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
  */\r
 \r
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;\r
 \r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
-\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertorUtil;\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.rev130715.Ipv4Prefix;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;\r
@@ -53,6 +59,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.strip.vlan.action._case.StripVlanActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;\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.inventory.rev130819.tables.table.FlowBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;\r
@@ -72,8 +79,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder;\r
@@ -111,21 +120,30 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
  * @author michal.polkorab\r
  */\r
 public class ActionConvertorV13Test {\r
+    private ConvertorManager convertorManager;\r
+\r
+    @Before\r
+    public void setUp() {\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+    }\r
+\r
     /**\r
-     * Test {@link ActionConvertor#toMDSalActions(List, OpenflowVersion, ActionPath)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)}}\r
      */\r
     @Test\r
     public void testToMDSalActions() {\r
         List<Action> actions = new ArrayList<>();\r
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
-                .Action> mdSalActions = ActionConvertor.toMDSalActions(actions, OpenflowVersion.OF13,\r
-                ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+        ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        data.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
 \r
-        Assert.assertEquals("Wrong number of output actions", 0, mdSalActions.size());\r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
+                .Action>> mdSalActions = convertorManager.convert(actions, data);\r
+\r
+        Assert.assertEquals("Wrong number of output actions", 0, mdSalActions.orElse(Collections.emptyList()).size());\r
     }\r
 \r
     /**\r
-     * Test {@link ActionConvertor#toMDSalActions(List, OpenflowVersion, ActionPath)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)}}\r
      */\r
     @Test\r
     public void testToMDSalActions2() {\r
@@ -248,11 +266,24 @@ public class ActionConvertorV13Test {
         actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
 \r
+        actionBuilder = new ActionBuilder();\r
+        actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());\r
+        actions.add(actionBuilder.build());\r
+\r
+        actionBuilder = new ActionBuilder();\r
+        actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());\r
+        actions.add(actionBuilder.build());\r
+\r
+        ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        data.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+\r
+        Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
+                .Action>> mdSalActionsOptional = convertorManager.convert(actions, data);\r
+\r
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
-                .Action> mdSalActions = ActionConvertor.toMDSalActions(actions, OpenflowVersion.OF13,\r
-                ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+                .Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());\r
 \r
-        Assert.assertEquals("Wrong number of output actions", 16, mdSalActions.size());\r
+        Assert.assertEquals("Wrong number of output actions", 18, mdSalActions.size());\r
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
                 + ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());\r
@@ -322,10 +353,16 @@ public class ActionConvertorV13Test {
         action = mdSalActions.get(15);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
                 + ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());\r
+        action = mdSalActions.get(16);\r
+        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+                + ".rev131112.action.action.SetNwDstActionCase", action.getImplementedInterface().getName());\r
+        action = mdSalActions.get(17);\r
+        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+                + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());\r
     }\r
 \r
     /**\r
-     * Test {@link ActionConvertor#getActions(java.util.List, short, java.math.BigInteger, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)} }\r
      */\r
     @Test\r
     public void testGetActions() {\r
@@ -468,8 +505,14 @@ public class ActionConvertorV13Test {
         IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProtocol((short) 6);\r
         MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());\r
         FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());\r
+        Flow flow = flowBld.build();\r
+\r
+        ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        data.setDatapathId(new BigInteger("42"));\r
+        data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));\r
 \r
-        List<Action> actions = ActionConvertor.getActions(salActions, EncodeConstants.OF13_VERSION_ID, new BigInteger("42"), flowBld.build());\r
+        Optional<List<Action>> actionsOptional = convertorManager.convert(salActions, data);\r
+        List<Action> actions = actionsOptional.orElse(Collections.emptyList());\r
 \r
         Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
         Action action = actions.get(0);\r
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorTest.java
deleted file mode 100644 (file)
index 5ec41c5..0000000
+++ /dev/null
@@ -1,106 +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.openflow.md.core.sal.convertor.action;
-
-import java.math.BigInteger;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-
-/**
- * match conversion and injection test
- */
-public class ActionSetNwDstReactorTest {
-
-    private Address[] addresses;
-
-    /**
-     * prepare input match
-     */
-    @Before
-    public void setUp() {
-        addresses = new Address[]{
-                new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
-                new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
-                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
-                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
-        };
-    }
-
-    /**
-     * convert for OF-1.3, inject into {@link ActionBuilder}
-     */
-    @Test
-    public void testMatchConvertorV13_flow() {
-        final ActionBuilder target = new ActionBuilder();
-        for (final Address address : addresses) {
-            final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
-            ActionSetNwDstReactor.getInstance().convert(action,
-                    OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
-            final Object mEntry = target.getActionChoice();
-/*
-            Assert.assertNotNull(mEntry);
-            if (address instanceof Ipv4) {
-                Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) mEntry.getMatchEntryValue());
-                Assert.assertNotNull(ipv4DstCase.getIpv4Dst());
-            } else if (address instanceof Ipv6) {
-                Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) mEntry.getMatchEntryValue());
-                Assert.assertNotNull(ipv6DstCase.getIpv6Dst());
-            } else {
-                Assert.fail("not tested yet: " + address.getClass().getName());
-            }
-*/
-        }
-    }
-
-    /**
-     * @param address
-     * @return
-     */
-    private static SetNwDstActionCase prepareSetNwDstActionCase(final Address address) {
-        return new SetNwDstActionCaseBuilder().setSetNwDstAction(
-                new SetNwDstActionBuilder().setAddress(address).build()).build();
-    }
-
-    /**
-     * convert for OF-1.0, inject into {@link ActionBuilder}
-     */
-    @Test
-    public void testMatchConvertorV10_flow() {
-        final ActionBuilder target = new ActionBuilder();
-        for (final Address address : addresses) {
-            final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
-
-            if (address instanceof Ipv4) {
-                ActionSetNwDstReactor.getInstance().convert(action,
-                        OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
-//                Assert.assertNotNull(target.getAugmentation(IpAddressAction.class).getIpAddress());
-            } else {
-                try {
-                    ActionSetNwDstReactor.getInstance().convert(action,
-                            OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
-                    Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
-                } catch (final Exception e) {
-                    //expected
-                    Assert.assertEquals(IllegalArgumentException.class, e.getClass());
-                }
-            }
-        }
-    }
-}
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorTest.java
deleted file mode 100644 (file)
index b326b0f..0000000
+++ /dev/null
@@ -1,106 +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.openflow.md.core.sal.convertor.action;
-
-import java.math.BigInteger;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-
-/**
- * match conversion and injection test
- */
-public class ActionSetNwSrcReactorTest {
-
-    private Address[] addresses;
-
-    /**
-     * prepare input match
-     */
-    @Before
-    public void setUp() {
-        addresses = new Address[]{
-                new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
-                new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
-                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
-                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
-        };
-    }
-
-    /**
-     * convert for OF-1.3, inject into {@link ActionBuilder}
-     */
-
-    @Test
-    public void testMatchConvertorV13_flow() {
-        final ActionBuilder target = new ActionBuilder();
-        for (final Address address : addresses) {
-            final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
-            ActionSetNwSrcReactor.getInstance().convert(action,
-                    OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
-/*
-            MatchEntry mEntry = target.getActionChoice() getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0);
-            Assert.assertNotNull(mEntry);
-            if (address instanceof Ipv4) {
-                Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) mEntry.getMatchEntryValue());
-                Assert.assertNotNull(ipv4SrcCase.getIpv4Src());
-            } else if (address instanceof Ipv6) {
-                Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) mEntry.getMatchEntryValue());
-                Assert.assertNotNull(ipv6SrcCase.getIpv6Src().getIpv6Address());
-            } else {
-                Assert.fail("not tested yet: " + address.getClass().getName());
-            }
-*/
-        }
-    }
-
-    /**
-     * @param address
-     * @return
-     */
-    private static SetNwSrcActionCase prepareSetNwSrcActionCase(final Address address) {
-        return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(
-                new SetNwSrcActionBuilder().setAddress(address).build()).build();
-    }
-
-    /**
-     * convert for OF-1.0, inject into {@link ActionBuilder}
-     */
-    @Test
-    public void testMatchConvertorV10_flow() {
-        final ActionBuilder target = new ActionBuilder();
-        for (final Address address : addresses) {
-            final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
-
-            if (address instanceof Ipv4) {
-                ActionSetNwSrcReactor.getInstance().convert(action,
-                        OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
-            } else {
-                try {
-                    ActionSetNwSrcReactor.getInstance().convert(action,
-                            OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
-                    Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
-                } catch (final Exception e) {
-                    //expected
-                    Assert.assertEquals(IllegalArgumentException.class, e.getClass());
-                }
-            }
-        }
-    }
-}
@@ -12,6 +12,7 @@ import java.util.Arrays;
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.util.ByteBufUtils;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;\r
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
@@ -6,24 +6,39 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
  */\r
 \r
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow;\r
 \r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;\r
@@ -38,7 +53,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;\r
@@ -47,15 +68,23 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
 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.FlowModInputBuilder;\r
+import org.opendaylight.yangtools.yang.binding.Augmentation;\r
+import org.opendaylight.yangtools.yang.binding.DataContainer;\r
 \r
 /**\r
  * @author michal.polkorab\r
  *\r
  */\r
 public class FlowConvertorTest {\r
+    private ConvertorManager convertorManager;\r
+\r
+    @Before\r
+    public void setUp() {\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+    }\r
 \r
     /**\r
-     * Tests {@link FlowConvertor#toFlowModInputs(Flow, short, BigInteger)}\r
+     * Tests {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }\r
      */\r
     @Test\r
     public void test() {\r
@@ -75,8 +104,10 @@ public class FlowConvertorTest {
         flowBuilder.setMatch(null);\r
         RemoveFlowInput flow = flowBuilder.build();\r
 \r
-        List<FlowModInputBuilder> flowMod = FlowConvertor\r
-                .toFlowModInputs(flow, EncodeConstants.OF13_VERSION_ID, new BigInteger("42"));\r
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        data.setDatapathId(new BigInteger("42"));\r
+\r
+        List<FlowModInputBuilder> flowMod = convert(flow, data);\r
 \r
         Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());\r
         Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());\r
@@ -96,7 +127,7 @@ public class FlowConvertorTest {
     }\r
 \r
     /**\r
-     * Tests {@link FlowConvertor#toFlowModInputs(Flow, short, BigInteger)}\r
+     * Tests {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }\r
      */\r
     @Test\r
     public void testOnlyModifyStrictCommand() {\r
@@ -104,15 +135,17 @@ public class FlowConvertorTest {
         flowBuilder.setStrict(true);\r
         UpdatedFlow flow = flowBuilder.build();\r
 \r
-        List<FlowModInputBuilder> flowMod = FlowConvertor\r
-                .toFlowModInputs(flow, EncodeConstants.OF10_VERSION_ID, new BigInteger("42"));\r
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        data.setDatapathId(new BigInteger("42"));\r
+\r
+        List<FlowModInputBuilder> flowMod = convert(flow, data);\r
 \r
         Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());\r
         Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());\r
     }\r
 \r
     /**\r
-     * Tests {@link FlowConvertor#toFlowModInputs(Flow, short, BigInteger)}\r
+     * Tests {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }\r
      */\r
     @Test\r
     public void testInstructionsTranslation() {\r
@@ -175,8 +208,9 @@ public class FlowConvertorTest {
         flowBuilder.setInstructions(instructionsBuilder.build());\r
         AddFlowInput flow = flowBuilder.build();\r
 \r
-        List<FlowModInputBuilder> flowMod = FlowConvertor\r
-                .toFlowModInputs(flow, EncodeConstants.OF10_VERSION_ID, new BigInteger("42"));\r
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        data.setDatapathId(new BigInteger("42"));\r
+        List<FlowModInputBuilder> flowMod = convert(flow, data);\r
 \r
         Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());\r
         Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());\r
@@ -215,4 +249,187 @@ public class FlowConvertorTest {
         MeterCase meterCase = (MeterCase) instruction.getInstructionChoice();\r
         Assert.assertEquals("Wrong meter id", 5, meterCase.getMeter().getMeterId().intValue());\r
     }\r
+\r
+    @Test\r
+    public void testCloneAndAugmentFlowWithSetVlanId() {\r
+        MockFlow mockFlow = new MockFlow();\r
+        Action action1 = createAction(\r
+                new SetVlanIdActionCaseBuilder().setSetVlanIdAction(\r
+                        new SetVlanIdActionBuilder().setVlanId(new VlanId(10)).build())\r
+                        .build(),\r
+                0);\r
+\r
+        mockFlow.setMatch(new MatchBuilder().setEthernetMatch(createEthernetMatch()).build());\r
+        mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1)));\r
+\r
+        VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        data.setDatapathId(BigInteger.ONE);\r
+\r
+        List<FlowModInputBuilder> flowModInputBuilders = convert(mockFlow, data);\r
+\r
+        Assert.assertEquals(2, flowModInputBuilders.size());\r
+\r
+    }\r
+\r
+    private List<FlowModInputBuilder> convert(Flow flow, VersionDatapathIdConvertorData data) {\r
+        Optional<List<FlowModInputBuilder>> flowModOptional = convertorManager.convert(flow, data);\r
+        Assert.assertTrue("Flow convertor not found", flowModOptional.isPresent());\r
+        return flowModOptional.get();\r
+    }\r
+\r
+    private static Action createAction(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionCase,\r
+                                       final int order) {\r
+        Action action = new ActionBuilder().setOrder(order).setAction(actionCase).build();\r
+        return action;\r
+    }\r
+\r
+    private static EthernetMatch createEthernetMatch() {\r
+        EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();\r
+        ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(33024L)).build());\r
+        return ethernetMatchBuilder.build();\r
+    }\r
+\r
+    private static Instructions toApplyInstruction(\r
+            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {\r
+        return new InstructionsBuilder()\r
+                .setInstruction(\r
+                        Collections.singletonList(\r
+                                new InstructionBuilder()\r
+                                        .setOrder(0)\r
+                                        .setInstruction(\r
+                                                new ApplyActionsCaseBuilder()\r
+                                                        .setApplyActions((new ApplyActionsBuilder()).setAction(actions).build())\r
+                                                        .build()\r
+                                        ).build())\r
+                ).build();\r
+    }\r
+\r
+    private static class MockFlow implements AddFlowInput {\r
+        private Instructions instructions;\r
+        private Match match;\r
+\r
+        public void setInstructions(final Instructions instructions) {\r
+            this.instructions = instructions;\r
+        }\r
+\r
+        public void setMatch(final Match match) {\r
+            this.match = match;\r
+        }\r
+\r
+\r
+        @Override\r
+        public FlowRef getFlowRef() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public <E extends Augmentation<AddFlowInput>> E getAugmentation(final Class<E> augmentationType) {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public FlowTableRef getFlowTable() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Match getMatch() {\r
+            return match;\r
+        }\r
+\r
+        @Override\r
+        public Instructions getInstructions() {\r
+            return instructions;\r
+        }\r
+\r
+        @Override\r
+        public String getContainerName() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public FlowCookie getCookieMask() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Long getBufferId() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public BigInteger getOutPort() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Long getOutGroup() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags getFlags() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public String getFlowName() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Boolean isInstallHw() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Boolean isBarrier() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Boolean isStrict() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Integer getPriority() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Integer getIdleTimeout() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Integer getHardTimeout() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public FlowCookie getCookie() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Short getTableId() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public NodeRef getNode() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Uri getTransactionUri() {\r
+            return null;\r
+        }\r
+\r
+        @Override\r
+        public Class<? extends DataContainer> getImplementedInterface() {\r
+            return Flow.class;\r
+        }\r
+    }\r
 }
\ No newline at end of file
@@ -6,17 +6,22 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Optional;
+import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
@@ -38,26 +43,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 /**
  * Created by Martin Bobak mbobak@cisco.com on 9/18/14.
  */
-public class OFToMDSalFlowConvertorTest {
-
-    private static final int PRESET_COUNT = 7;
+public class FlowStatsResponseConvertorTest {
+    private ConvertorManager convertorManager;
 
-    /**
-     * Test method for {@link OFToMDSalFlowConvertor#wrapOF10ActionsToInstruction(java.util.List, org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}
-     */
-    @Test
-    public void testWrapOF10ActionsToInstruction() {
-        ActionBuilder actionBuilder = new ActionBuilder();
-        List<Action> actions = new ArrayList<>();
-        for (int j = 0; j < PRESET_COUNT; j++) {
-            actions.add(actionBuilder.build());
-        }
-        Instructions instructions = OFToMDSalFlowConvertor.wrapOF10ActionsToInstruction(actions, OpenflowVersion.OF13);
-        assertNotNull(instructions);
+    @Before
+    public void setUp() {
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
     }
 
+    private static final int PRESET_COUNT = 7;
+
     /**
-     * Test method for {@link OFToMDSalFlowConvertor#toSALInstruction(java.util.List, org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}
+     * Test method for {@link FlowInstructionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)} }
      */
     @Test
     public void testToSALInstruction() {
@@ -77,7 +74,10 @@ public class OFToMDSalFlowConvertorTest {
             instructionsList.add(instructionBuilder.build());
         }
 
-        Instructions instructions = OFToMDSalFlowConvertor.toSALInstruction(instructionsList, OpenflowVersion.OF13);
+        Instructions instructions;
+        VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+
+        instructions = convert(instructionsList, data);
         assertNotNull(instructions);
         assertEquals(PRESET_COUNT, instructions.getInstruction().size());
 
@@ -91,7 +91,7 @@ public class OFToMDSalFlowConvertorTest {
             instructionsList.add(instructionBuilder.build());
         }
 
-        instructions = OFToMDSalFlowConvertor.toSALInstruction(instructionsList, OpenflowVersion.OF13);
+        instructions = convert(instructionsList, data);
         assertNotNull(instructions);
         assertEquals(PRESET_COUNT, instructions.getInstruction().size());
 
@@ -99,13 +99,13 @@ public class OFToMDSalFlowConvertorTest {
         for (int i = 0; i < PRESET_COUNT; i++) {
             MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
             MeterBuilder meterBuilder = new MeterBuilder();
-            meterBuilder.setMeterId(Long.valueOf(i));
+            meterBuilder.setMeterId((long) i);
             meterCaseBuilder.setMeter(meterBuilder.build());
             instructionBuilder.setInstructionChoice(meterCaseBuilder.build());
             instructionsList.add(instructionBuilder.build());
         }
 
-        instructions = OFToMDSalFlowConvertor.toSALInstruction(instructionsList, OpenflowVersion.OF13);
+        instructions = convert(instructionsList, data);
         assertNotNull(instructions);
         assertEquals(PRESET_COUNT, instructions.getInstruction().size());
 
@@ -125,7 +125,7 @@ public class OFToMDSalFlowConvertorTest {
             instructionsList.add(instructionBuilder.build());
         }
 
-        instructions = OFToMDSalFlowConvertor.toSALInstruction(instructionsList, OpenflowVersion.OF13);
+        instructions = convert(instructionsList, data);
         assertNotNull(instructions);
         assertEquals(PRESET_COUNT, instructions.getInstruction().size());
 
@@ -136,7 +136,7 @@ public class OFToMDSalFlowConvertorTest {
             instructionsList.add(instructionBuilder.build());
         }
 
-        instructions = OFToMDSalFlowConvertor.toSALInstruction(instructionsList, OpenflowVersion.OF13);
+        instructions = convert(instructionsList, data);
         assertNotNull(instructions);
         int instructionSize = instructions.getInstruction().size();
         assertEquals(PRESET_COUNT, instructionSize);
@@ -153,11 +153,17 @@ public class OFToMDSalFlowConvertorTest {
             instructionsList.add(instructionBuilder.build());
         }
 
-        instructions = OFToMDSalFlowConvertor.toSALInstruction(instructionsList, OpenflowVersion.OF13);
+        instructions = convert(instructionsList, data);
         assertNotNull(instructions);
         assertEquals(PRESET_COUNT, instructions.getInstruction().size());
     }
 
+    private Instructions convert(List<Instruction> instructionsList, VersionConvertorData data) {
+        Optional<Instructions> instructionsOptional = convertorManager.convert(instructionsList, data);
+        assertTrue("Flow instruction response convertor not found", instructionsOptional.isPresent());
+        return instructionsOptional.get();
+    }
+
     private static final class MockActionBase extends ActionBase {
         // for testing purposes
     }
@@ -5,13 +5,14 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.flowflag;
 
-import java.math.BigInteger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 
@@ -21,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class FlowFlagReactorTest {
 
     private FlowModFlags[] flowFlags;
+    private ConvertorManager convertorManager;
 
     /**
      * prepare input match
@@ -32,6 +34,7 @@ public class FlowFlagReactorTest {
                 new FlowModFlags(false, false, false, false, false),
                 new FlowModFlags(true, false, true, false, true)
         };
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
     }
 
     /**
@@ -43,7 +46,7 @@ public class FlowFlagReactorTest {
         for (FlowModFlags fFlag : flowFlags) {
             target.setFlags(null);
             FlowFlagReactor.getInstance().convert(fFlag,
-                    OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
+                    OFConstants.OFP_VERSION_1_3, target, convertorManager);
             Assert.assertNotNull(target.getFlags());
         }
     }
@@ -57,7 +60,7 @@ public class FlowFlagReactorTest {
         for (FlowModFlags fFlag : flowFlags) {
             target.setFlagsV10(null);
             FlowFlagReactor.getInstance().convert(fFlag,
-                    OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
+                    OFConstants.OFP_VERSION_1_0, target, convertorManager);
             Assert.assertNotNull(target.getFlagsV10());
         }
     }
index f6e9ba27e59ab946bd8ed1bfb39172f0b5f89506..184012c13c3fb8101630afc0b069cf1a85248d2f 100644 (file)
@@ -13,10 +13,18 @@ import java.util.List;
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\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.rev130715.*;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;\r
@@ -43,6 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;\r
@@ -132,8 +141,6 @@ 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.UdpSrcCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;\r
-import java.math.BigInteger;\r
-import java.util.List;\r
 \r
 /**\r
  * @author michal.polkorab\r
@@ -141,6 +148,7 @@ import java.util.List;
 public class MatchConvertorImpl2Test {\r
 \r
     private static final MatchConvertorImpl convertor = new MatchConvertorImpl();\r
+    private ConvertorManager convertorManager;\r
 \r
     /**\r
      * Initializes OpenflowPortsUtil\r
@@ -148,26 +156,21 @@ public class MatchConvertorImpl2Test {
     @Before\r
     public void startUp() {\r
         OpenflowPortsUtil.init();\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testEmptyAndNullInput() {\r
         MatchBuilder builder = new MatchBuilder();\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(null, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(null, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 0, entries.size());\r
 \r
-        entries = convertor.convert(match, new BigInteger("42"));\r
+        entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 0, entries.size());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -228,7 +231,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 24, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, InPort.class, false);\r
@@ -337,9 +340,6 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("Wrong hasMask", hasMask, entry.isHasMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testIpv4MatchArbitraryBitMaskwithNoMask(){\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -349,7 +349,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
@@ -360,9 +360,6 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("wrong Ipv4Address destination", "10.1.1.1",((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, BigInteger)}\r
-     */\r
     @Test\r
     public void testIpv4MatchArbitraryBitMaskwithMask(){\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -374,7 +371,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
@@ -385,9 +382,6 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("wrong Ipv4Adress destination", "10.1.1.1",((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testUdpMatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -397,7 +391,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer4Match(udpMatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, UdpSrc.class, false);\r
@@ -409,9 +403,27 @@ public class MatchConvertorImpl2Test {
                 .getUdpDst().getPort().getValue().intValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
+    @Test\r
+    public void testTunnelIpv4MatchConversion() {\r
+        MatchBuilder builder = new MatchBuilder();\r
+        TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();\r
+        tunnelIpv4MatchBuilder.setTunnelIpv4Source(new Ipv4Prefix("10.0.0.1/32"));\r
+        tunnelIpv4MatchBuilder.setTunnelIpv4Destination(new Ipv4Prefix("10.0.0.2/32"));\r
+        builder.setLayer3Match(tunnelIpv4MatchBuilder.build());\r
+        Match match = builder.build();\r
+\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
+        Assert.assertEquals("Wrong entries size", 2, entries.size());\r
+        MatchEntry entry = entries.get(0);\r
+        checkEntryHeader(entry, Ipv4Src.class, false);\r
+        Assert.assertEquals("Wrong ipv4 tunnel src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src()\r
+                .getIpv4Address().getValue());\r
+        entry = entries.get(1);\r
+        checkEntryHeader(entry, Ipv4Dst.class, false);\r
+        Assert.assertEquals("Wrong ipv4 tunnel dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst()\r
+                .getIpv4Address().getValue());\r
+    }\r
+\r
     @Test\r
     public void testSctpMatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -421,7 +433,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer4Match(sctpMatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, SctpSrc.class, false);\r
@@ -433,9 +445,6 @@ public class MatchConvertorImpl2Test {
                 .getSctpDst().getPort().getValue().intValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testArpMatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -452,7 +461,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(arpBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 5, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, ArpOp.class, false);\r
@@ -476,9 +485,6 @@ public class MatchConvertorImpl2Test {
                 .getArpTha().getMacAddress().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testArpMatchConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -497,7 +503,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(arpBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 4, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         entry = entries.get(0);\r
@@ -526,9 +532,6 @@ public class MatchConvertorImpl2Test {
                 ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testIpv6MatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -547,7 +550,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 7, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         /* Due to conversion ambiguities, we always get "has mask" because \r
@@ -582,9 +585,6 @@ public class MatchConvertorImpl2Test {
                 true, false, true, false), ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testIpv6MatchConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -594,7 +594,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Src.class, true);\r
@@ -611,9 +611,6 @@ public class MatchConvertorImpl2Test {
                 ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testIpv6ExtHeaderConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -625,7 +622,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 1, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Exthdr.class, true);\r
@@ -635,9 +632,6 @@ public class MatchConvertorImpl2Test {
                 ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -677,7 +671,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 8, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Metadata.class, true);\r
@@ -731,9 +725,6 @@ public class MatchConvertorImpl2Test {
                 ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
-     */\r
     @Test\r
     public void testIpv6MatchArbitraryBitMask(){\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -745,7 +736,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
index 223988bb038b8c19d7cbf5b09c32783a086f89bb..639d6f31c11c51fb725b95da7307f3f483e13339 100644 (file)
@@ -9,9 +9,12 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
 import static org.junit.Assert.assertEquals;
+
 import java.math.BigInteger;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpVersion;
@@ -57,10 +60,12 @@ public class MatchConvertorV10ImplTest {
     private static final VlanId DEFAULT_VLAN_ID = new VlanId(42);
     private static final Ipv4Address DEFAULT_IPV4_ADDRESS = new Ipv4Address("10.0.0.1");
     private static final short DEFAULT_MASK = 24;
+    private ConvertorManager convertorManager;
 
     @Before
     public void setup() {
         OpenflowPortsUtil.init();
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
     }
 
     @Test
@@ -68,7 +73,7 @@ public class MatchConvertorV10ImplTest {
      * Test method for {@link MatchConvertorV10Impl#convert(Match,BigInteger)}
      */
     public void testConvert() {
-        MatchV10 matchV10 = matchConvertorV10.convert(createL4UdpMatch().build(), dataPathId);
+        MatchV10 matchV10 = matchConvertorV10.convert(createL4UdpMatch().build(), null);
 
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
@@ -83,24 +88,24 @@ public class MatchConvertorV10ImplTest {
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
 
-        matchV10 = matchConvertorV10.convert(createL4TcpMatch().build(), dataPathId);
+        matchV10 = matchConvertorV10.convert(createL4TcpMatch().build(), null);
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
 
-        matchV10 = matchConvertorV10.convert(createVlanTcpMatch().build(), dataPathId);
+        matchV10 = matchConvertorV10.convert(createVlanTcpMatch().build(), null);
         assertEquals(DEFAULT_VLAN_ID.getValue().intValue(), matchV10.getDlVlan().intValue());
 
     }
 
     /**
      * ICMPv4 match test for
-     * {@link MatchConvertorV10Impl#convert(Match,BigInteger)}.
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactorConvertor#convert(Object, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)}.
      */
     @Test
     public void testConvertIcmpv4() {
         MatchBuilder matchBuilder = createMatchBuilderWithDefaults();
         Match match = matchBuilder.build();
-        MatchV10 matchV10 = matchConvertorV10.convert(match, dataPathId);
+        MatchV10 matchV10 = matchConvertorV10.convert(match, convertorManager);
         Integer zero = 0;
         boolean wcTpSrc = true;
         boolean wcTpDst = true;
@@ -131,7 +136,7 @@ public class MatchConvertorV10ImplTest {
             wcTpDst, wcTpSrc);
         match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
             build();
-        matchV10 = matchConvertorV10.convert(match, dataPathId);
+        matchV10 = matchConvertorV10.convert(match, convertorManager);
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
         assertEquals(0, matchV10.getDlType().intValue());
@@ -157,7 +162,7 @@ public class MatchConvertorV10ImplTest {
             wcTpDst, wcTpSrc);
         match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
             build();
-        matchV10 = matchConvertorV10.convert(match, dataPathId);
+        matchV10 = matchConvertorV10.convert(match, convertorManager);
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
         assertEquals(0, matchV10.getDlType().intValue());
@@ -185,7 +190,7 @@ public class MatchConvertorV10ImplTest {
             wcTpDst, wcTpSrc);
         match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
             build();
-        matchV10 = matchConvertorV10.convert(match, dataPathId);
+        matchV10 = matchConvertorV10.convert(match, convertorManager);
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
         assertEquals(0, matchV10.getDlType().intValue());
index e32dfe53b06963f815f14e8344d0f20f3d25ff0e..eba0299e43cda8093386424b212995f376d6e2ee 100644 (file)
@@ -11,6 +11,8 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
@@ -18,14 +20,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
-import java.math.BigInteger;
 
 /**
  * match conversion and injection test
  */
 public class MatchReactorTest {
-
     private MatchBuilder matchBuilder;
+    private ConvertorManager convertorManager;
 
     /**
      * prepare input match
@@ -38,6 +39,7 @@ public class MatchReactorTest {
         ethernetTypeBuilder.setType(new EtherType(42L));
         ethernetMatchBuilder.setEthernetType(ethernetTypeBuilder.build());
         matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
     }
 
     /**
@@ -47,7 +49,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_flow() {
         FlowModInputBuilder target = new FlowModInputBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target, convertorManager);
         Assert.assertNotNull(target.getMatch());
     }
 
@@ -58,7 +60,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_flow() {
         FlowModInputBuilder target = new FlowModInputBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target, convertorManager);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -70,7 +72,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_mpRequestFlow() {
         MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target, convertorManager);
         Assert.assertNotNull(target.getMatch());
     }
 
@@ -81,7 +83,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_mpRequestFlow() {
         MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target, convertorManager);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -89,7 +91,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_null() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(null,
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target, convertorManager);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -100,7 +102,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_mpRequestAggregate() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target, convertorManager);
         Assert.assertNotNull(target.getMatch());
     }
 
@@ -108,7 +110,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_null() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(null,
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target, convertorManager);
         Assert.assertNotNull(target.getMatch());
         Assert.assertEquals(0, target.getMatch().getMatchEntry().size());
     }
@@ -120,7 +122,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_mpRequestAggregate() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target, convertorManager);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -11,10 +11,14 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;\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.rev130715.Dscp;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
@@ -156,7 +160,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 /**\r
  * @author michal.polkorab\r
  */\r
-public class MatchConvertorImplV13Test {\r
+public class MatchResponseConvertor2Test {\r
+\r
+    private ConvertorManager convertorManager;\r
 \r
     /**\r
      * Initializes OpenflowPortsUtil\r
@@ -164,24 +170,21 @@ public class MatchConvertorImplV13Test {
     @Before\r
     public void startUp() {\r
         OpenflowPortsUtil.init();\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test(expected = NullPointerException.class)\r
     public void testEmptyMatch() {\r
-        final MatchBuilder builder = new MatchBuilder();\r
-\r
-        MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF10);\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+        convert(new MatchBuilder().build(), datapathIdConvertorData);\r
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testEmptyMatchEntry() {\r
@@ -192,8 +195,12 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         Assert.assertEquals("Wrong match entries", null, builtMatch.getEthernetMatch());\r
@@ -212,9 +219,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryNoMasks() {\r
@@ -499,8 +504,11 @@ public class MatchConvertorImplV13Test {
 \r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());\r
@@ -537,9 +545,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithMasks() {\r
@@ -648,8 +654,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}), builtMatch.getMetadata().getMetadata());\r
@@ -670,9 +679,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithArbitraryMasks() {\r
@@ -711,8 +718,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
@@ -723,9 +733,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask() {\r
@@ -764,8 +772,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
@@ -776,9 +787,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask() {\r
@@ -817,8 +826,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
@@ -830,9 +842,7 @@ public class MatchConvertorImplV13Test {
 \r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithDstArbitraryBitMaskAndSrcCidrMask() {\r
@@ -871,8 +881,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
@@ -883,9 +896,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithDstCidrMaskAndSrcArbitraryBitMask() {\r
@@ -924,8 +935,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
@@ -936,9 +950,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testLayer4MatchUdp() {\r
@@ -972,8 +984,11 @@ public class MatchConvertorImplV13Test {
 \r
         builder.setMatchEntry(entries);\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder builtMatch = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder builtMatch = convert(builder.build(), datapathIdConvertorData);\r
 \r
         final UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();\r
         Assert.assertEquals("Wrong udp src port", 11, udpMatch.getUdpSourcePort().getValue().intValue());\r
@@ -981,9 +996,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testLayer4MatchSctp() {\r
@@ -1016,8 +1029,11 @@ public class MatchConvertorImplV13Test {
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();\r
@@ -1026,9 +1042,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testLayer3MatchIpv6() {\r
@@ -1113,8 +1127,11 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         entries.add(entriesBuilder.build());\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
@@ -1131,9 +1148,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testLayer3MatchIpv6ExtHeader2() {\r
@@ -1153,8 +1168,11 @@ public class MatchConvertorImplV13Test {
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
@@ -1163,9 +1181,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testLayer3MatchArp() {\r
@@ -1228,8 +1244,11 @@ public class MatchConvertorImplV13Test {
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
@@ -1241,9 +1260,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testLayer3MatchArpWithMasks() {\r
@@ -1300,8 +1317,11 @@ public class MatchConvertorImplV13Test {
 \r
         builder.setMatchEntry(entries);\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
+                .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
@@ -1314,9 +1334,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithIpv6ArbitraryMasks() {\r
@@ -1355,9 +1373,12 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+                .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
@@ -1367,9 +1388,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithIpv6SrcCidrlMaskAndDstArbitraryBitMask() {\r
@@ -1408,9 +1427,12 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+                .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
@@ -1420,9 +1442,7 @@ public class MatchConvertorImplV13Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWithMatchEntryWithIpv6SrcArbitraryBitMaskAndDstCidrMask() {\r
@@ -1461,9 +1481,12 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+                .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
@@ -1474,11 +1497,8 @@ public class MatchConvertorImplV13Test {
 \r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
-\r
     @Test\r
     public void testWithMatchEntryWithIpv6DstArbitraryBitMaskAndSrcCidrMask() {\r
         final MatchBuilder builder = new MatchBuilder();\r
@@ -1516,9 +1536,12 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+                .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
@@ -1529,11 +1552,8 @@ public class MatchConvertorImplV13Test {
 \r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchToSALMatch(\r
-     * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger,\r
-     * org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
-\r
     @Test\r
     public void testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask() {\r
         final MatchBuilder builder = new MatchBuilder();\r
@@ -1571,9 +1591,12 @@ public class MatchConvertorImplV13Test {
         builder.setMatchEntry(entries);\r
         final Match match = builder.build();\r
 \r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
-                .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF13);\r
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+                .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
         final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
@@ -1582,5 +1605,12 @@ public class MatchConvertorImplV13Test {
                 ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());\r
     }\r
 \r
+    private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+            .MatchBuilder convert(Match match, VersionDatapathIdConvertorData data) {\r
+        final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+                .MatchBuilder> salMatchOptional = convertorManager.convert(match, data);\r
 \r
+        return salMatchOptional\r
+                .orElse(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder());\r
+    }\r
 }\r
@@ -9,13 +9,18 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.BeforeClass;
+import java.util.Optional;
+import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
@@ -55,9 +60,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 /**
  * Unit test for {@link MatchConvertorImpl}.
  */
-public class MatchConvertorImplTest {
+public class MatchResponseConvertorTest {
     private static final BigInteger DPID = BigInteger.TEN;
-    private static final Long IN_PORT = Long.valueOf(6);
+    private static final Long IN_PORT = 6L;
     private static final String URI_IN_PORT =
             "openflow:" + DPID + ":" + IN_PORT;
     private static final MacAddress MAC_SRC =
@@ -72,16 +77,17 @@ public class MatchConvertorImplTest {
             Ipv4Address.getDefaultInstance("10.1.2.3");
 
     private static final int DL_VLAN_NONE = 0xffff;
+    private ConvertorManager convertorManager;
 
-    @BeforeClass
-    public static void setUp() {
+    @Before
+    public void setUp() {
         OpenflowPortsUtil.init();
+        convertorManager = ConvertorManagerFactory.createDefaultManager();
     }
 
     /**
-     * Test method for {@link MatchConvertorImpl#fromOFMatchToSALMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match, java.math.BigInteger, org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)}.
+     * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }.
      */
-
     @Test
     public void testFromOFMatchToSALMatch() {
         List<MatchEntry> entries = createDefaultMatchEntry();
@@ -104,12 +110,13 @@ public class MatchConvertorImplTest {
             org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match ofMatch =
                     createOFMatch(MatchEntry);
 
-            MatchBuilder builder = MatchConvertorImpl.
-                    fromOFMatchToSALMatch(ofMatch, DPID, OpenflowVersion.OF13);
+            final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+            data.setDatapathId(DPID);
+            final MatchBuilder builder = convert(ofMatch, data);
             checkDefault(builder);
             VlanMatch vlanMatch = builder.getVlanMatch();
             int expectedVid = (vid < 0) ? 0 : vid;
-            Boolean expectedCfi = Boolean.valueOf(vid != 0);
+            Boolean expectedCfi = vid != 0;
             assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().
                     getValue().intValue());
             assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
@@ -118,9 +125,8 @@ public class MatchConvertorImplTest {
     }
 
     /**
-     * Test method for {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}.
+     * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }.
      */
-
     @Test
     public void testFromOFMatchV10ToSALMatch() {
         int[] vids = {
@@ -151,8 +157,9 @@ public class MatchConvertorImplTest {
 
                 FlowWildcardsV10 wc = wcBuilder.build();
                 MatchV10 ofMatch = builder.setWildcards(wc).build();
-                Match match = MatchConvertorImpl.fromOFMatchV10ToSALMatch(
-                        ofMatch, DPID, OpenflowVersion.OF10).build();
+                final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+                data.setDatapathId(DPID);
+                Match match = convert(ofMatch, data).build();
                 checkDefaultV10(match, wc, vid);
 
                 IpMatch ipMatch = match.getIpMatch();
@@ -163,8 +170,7 @@ public class MatchConvertorImplTest {
                 // Set all wildcard bits.
                 wc = wcBuilder.setAll(true).build();
                 ofMatch = builder.setWildcards(wc).build();
-                match = MatchConvertorImpl.fromOFMatchV10ToSALMatch(
-                        ofMatch, DPID, OpenflowVersion.OF10).build();
+                match = convert(ofMatch, data).build();
                 checkDefaultV10(match, wc, vid);
                 assertEquals(null, match.getIpMatch());
             }
@@ -249,7 +255,7 @@ public class MatchConvertorImplTest {
     private static MatchEntry toOfVlanVid(final int vid) {
         MatchEntryBuilder builder = new MatchEntryBuilder();
         boolean cfi = true;
-        Integer vidValue = Integer.valueOf(vid);
+        Integer vidValue = vid;
         byte[] mask = null;
         builder.setOxmClass(OpenflowBasicClass.class);
         builder.setOxmMatchField(VlanVid.class);
@@ -260,7 +266,7 @@ public class MatchConvertorImplTest {
         } else if (vid < 0) {
             // Match packet with VLAN tag regardless of its value.
             mask = new byte[]{0x10, 0x00};
-            vidValue = Integer.valueOf(0);
+            vidValue = 0;
         }
 
         VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
@@ -278,7 +284,7 @@ public class MatchConvertorImplTest {
 
     private static void checkDefaultV10(final Match match, final FlowWildcardsV10 wc, final int vid) {
         EthernetMatch ethMatch = match.getEthernetMatch();
-        if (wc.isDLSRC().booleanValue()) {
+        if (wc.isDLSRC()) {
             if (ethMatch != null) {
                 assertEquals(null, ethMatch.getEthernetSource());
             }
@@ -286,21 +292,23 @@ public class MatchConvertorImplTest {
             assertEquals(MAC_SRC, ethMatch.getEthernetSource().getAddress());
         }
 
-        if (wc.isDLDST().booleanValue()) {
-            if (ethMatch != null) {
+        if (ethMatch != null) {
+            if (wc.isDLDST()) {
                 assertEquals(null, ethMatch.getEthernetDestination());
+            } else {
+                assertNotEquals(null, ethMatch.getEthernetDestination());
+                assertEquals(MAC_DST,
+                        ethMatch.getEthernetDestination().getAddress());
             }
-        } else {
-            assertEquals(MAC_DST,
-                    ethMatch.getEthernetDestination().getAddress());
         }
 
-        if (wc.isDLTYPE().booleanValue()) {
+        if (wc.isDLTYPE()) {
             if (ethMatch != null) {
                 assertEquals(null, ethMatch.getEthernetType());
             }
             assertEquals(null, match.getLayer3Match());
         } else {
+            assert ethMatch != null;
             assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().
                     getValue().intValue());
 
@@ -312,7 +320,7 @@ public class MatchConvertorImplTest {
         }
 
         VlanMatch vlanMatch = match.getVlanMatch();
-        if (wc.isDLVLAN().booleanValue()) {
+        if (wc.isDLVLAN()) {
             assertEquals(null, vlanMatch);
         } else {
             int expectedVid;
@@ -328,7 +336,7 @@ public class MatchConvertorImplTest {
                     getValue().intValue());
             assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
 
-            if (wc.isDLVLANPCP().booleanValue()) {
+            if (wc.isDLVLANPCP()) {
                 assertEquals(null, vlanMatch.getVlanPcp());
             } else {
                 assertEquals(VLAN_PCP,
@@ -336,4 +344,16 @@ public class MatchConvertorImplTest {
             }
         }
     }
+
+    private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) {
+        final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);
+
+        return salMatchOptional.orElse(new MatchBuilder());
+    }
+
+    private MatchBuilder convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match match, VersionDatapathIdConvertorData data) {
+        final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);
+
+        return salMatchOptional.orElse(new MatchBuilder());
+    }
 }
@@ -9,14 +9,19 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;\r
 \r
 import java.math.BigInteger;\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;\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.rev130715.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;\r
@@ -31,7 +36,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
  * @author michal.polkorab\r
  *\r
  */\r
-public class MatchConvertorImplV10Test {\r
+public class MatchV10ResponseConvertorTest {\r
+\r
+    private ConvertorManager convertorManager;\r
 \r
     /**\r
      * Initializes OpenflowPortsUtil\r
@@ -39,10 +46,11 @@ public class MatchConvertorImplV10Test {
     @Before\r
     public void startUp() {\r
         OpenflowPortsUtil.init();\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void test() {\r
@@ -65,7 +73,10 @@ public class MatchConvertorImplV10Test {
         builder.setTpDst(4096);\r
         MatchV10 match = builder.build();\r
 \r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
+        final Match salMatch = convert(match, datapathIdConvertorData).build();\r
 \r
         Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());\r
         Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch()\r
@@ -89,7 +100,7 @@ public class MatchConvertorImplV10Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWildcardedMatch() {\r
@@ -112,7 +123,10 @@ public class MatchConvertorImplV10Test {
         builder.setTpDst(4096);\r
         MatchV10 match = builder.build();\r
 \r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
+        final Match salMatch = convert(match, datapathIdConvertorData).build();\r
 \r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());\r
@@ -124,7 +138,7 @@ public class MatchConvertorImplV10Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testWildcardedMatchWithNoValuesSet() {\r
@@ -133,7 +147,10 @@ public class MatchConvertorImplV10Test {
                 true, true, true, true, true, true));\r
         MatchV10 match = builder.build();\r
 \r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
+        final Match salMatch = convert(match, datapathIdConvertorData).build();\r
 \r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());\r
@@ -145,7 +162,7 @@ public class MatchConvertorImplV10Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testMatchWithValuesUnset() {\r
@@ -157,7 +174,10 @@ public class MatchConvertorImplV10Test {
         builder.setTpDst(4096);\r
         MatchV10 match = builder.build();\r
 \r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
+        final Match salMatch = convert(match, datapathIdConvertorData).build();\r
 \r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());\r
@@ -170,19 +190,21 @@ public class MatchConvertorImplV10Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}\r
+     * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test(expected=NullPointerException.class)\r
     public void testEmptyMatch() {\r
         MatchV10Builder builder = new MatchV10Builder();\r
         MatchV10 match = builder.build();\r
 \r
-        MatchConvertorImpl.fromOFMatchV10ToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
+\r
+        final Match salMatch = convert(match, datapathIdConvertorData).build();\r
     }\r
 \r
     /**\r
-     * ICMPv4 match test for\r
-     * {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}.\r
+     * ICMPv4 match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testIcmpv4Match() {\r
@@ -196,8 +218,11 @@ public class MatchConvertorImplV10Test {
         MatchV10 match = builder.build();\r
 \r
         BigInteger dpid = BigInteger.valueOf(12345L);\r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(dpid);\r
+\r
+        Match salMatch = convert(match, datapathIdConvertorData).build();\r
+\r
         EthernetMatch etherMatch = salMatch.getEthernetMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl src",\r
@@ -217,8 +242,8 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, true, true);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl src",\r
@@ -237,8 +262,7 @@ public class MatchConvertorImplV10Test {
         // Specify ICMPv4 protocol.\r
         Short ipProto = 1;\r
         match = builder.setNwProto(ipProto).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         IpMatch ipMatch = salMatch.getIpMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
@@ -263,8 +287,7 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, true, false);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
@@ -288,8 +311,7 @@ public class MatchConvertorImplV10Test {
         // Specify ICMPv4 type.\r
         Short icmpType = 10;\r
         match = builder.setTpSrc(icmpType.intValue()).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         Icmpv4Match icmpv4Match = salMatch.getIcmpv4Match();\r
@@ -317,8 +339,7 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, false, false);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         icmpv4Match = salMatch.getIcmpv4Match();\r
@@ -345,8 +366,7 @@ public class MatchConvertorImplV10Test {
         // Specify ICMPv4 code only.\r
         Short icmpCode = 33;\r
         match = builder.setTpSrc(null).setTpDst(icmpCode.intValue()).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         icmpv4Match = salMatch.getIcmpv4Match();\r
@@ -375,8 +395,7 @@ public class MatchConvertorImplV10Test {
         icmpCode = 8;\r
         match = builder.setTpSrc(icmpType.intValue()).\r
             setTpDst(icmpCode.intValue()).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         icmpv4Match = salMatch.getIcmpv4Match();\r
@@ -402,8 +421,7 @@ public class MatchConvertorImplV10Test {
     }\r
 \r
     /**\r
-     * TCP match test for\r
-     * {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}.\r
+     * TCP match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testTcpMatch() {\r
@@ -418,8 +436,10 @@ public class MatchConvertorImplV10Test {
         MatchV10 match = builder.build();\r
 \r
         BigInteger dpid = BigInteger.valueOf(12345L);\r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(dpid);\r
+\r
+        Match salMatch = convert(match, datapathIdConvertorData).build();\r
         EthernetMatch etherMatch = salMatch.getEthernetMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl src",\r
@@ -438,8 +458,7 @@ public class MatchConvertorImplV10Test {
         // Specify TCP protocol.\r
         Short ipProto = 6;\r
         match = builder.setNwProto(ipProto).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         IpMatch ipMatch = salMatch.getIpMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
@@ -464,8 +483,7 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, true, false);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
@@ -489,8 +507,7 @@ public class MatchConvertorImplV10Test {
         // Specify TCP source port.\r
         Integer srcPort = 60000;\r
         match = builder.setTpSrc(srcPort).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         TcpMatch tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
@@ -519,8 +536,7 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, false, false);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
@@ -548,8 +564,7 @@ public class MatchConvertorImplV10Test {
         // Specify TCP destination port only.\r
         Integer dstPort = 6653;\r
         match = builder.setTpSrc(null).setTpDst(dstPort).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
@@ -578,8 +593,7 @@ public class MatchConvertorImplV10Test {
         srcPort = 32767;\r
         dstPort = 9999;\r
         match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
@@ -606,8 +620,7 @@ public class MatchConvertorImplV10Test {
     }\r
 \r
     /**\r
-     * UDP match test for\r
-     * {@link MatchConvertorImpl#fromOFMatchV10ToSALMatch(MatchV10, BigInteger, OpenflowVersion)}.\r
+     * UDP match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
      */\r
     @Test\r
     public void testUdpMatch() {\r
@@ -622,8 +635,10 @@ public class MatchConvertorImplV10Test {
         MatchV10 match = builder.build();\r
 \r
         BigInteger dpid = BigInteger.valueOf(12345L);\r
-        Match salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
+        datapathIdConvertorData.setDatapathId(dpid);\r
+\r
+        Match salMatch = convert(match, datapathIdConvertorData).build();\r
         EthernetMatch etherMatch = salMatch.getEthernetMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
         Assert.assertEquals("Wrong dl src",\r
@@ -642,8 +657,7 @@ public class MatchConvertorImplV10Test {
         // Specify UDP protocol.\r
         Short ipProto = 17;\r
         match = builder.setNwProto(ipProto).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         IpMatch ipMatch = salMatch.getIpMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
@@ -668,8 +682,7 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, true, false);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
@@ -693,8 +706,7 @@ public class MatchConvertorImplV10Test {
         // Specify UDP source port.\r
         Integer srcPort = 60000;\r
         match = builder.setTpSrc(srcPort).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         UdpMatch udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
@@ -723,8 +735,7 @@ public class MatchConvertorImplV10Test {
         wc = new FlowWildcardsV10(\r
             true, true, false, true, true, true, false, true, false, false);\r
         match = builder.setWildcards(wc).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
@@ -752,8 +763,7 @@ public class MatchConvertorImplV10Test {
         // Specify UDP destination port only.\r
         Integer dstPort = 6653;\r
         match = builder.setTpSrc(null).setTpDst(dstPort).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
@@ -782,8 +792,7 @@ public class MatchConvertorImplV10Test {
         srcPort = 32767;\r
         dstPort = 9999;\r
         match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();\r
-        salMatch = MatchConvertorImpl.fromOFMatchV10ToSALMatch(\r
-                match, dpid, OpenflowVersion.OF10).build();\r
+        salMatch = convert(match, datapathIdConvertorData).build();\r
         etherMatch = salMatch.getEthernetMatch();\r
         ipMatch = salMatch.getIpMatch();\r
         udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
@@ -808,4 +817,10 @@ public class MatchConvertorImplV10Test {
         Assert.assertEquals("Wrong ICMPv4 match",\r
                             null, salMatch.getIcmpv4Match());\r
     }\r
+\r
+    private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) {\r
+        final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);\r
+\r
+        return salMatchOptional.orElse(new MatchBuilder());\r
+    }\r
 }\r
index 4deaf1281279a7fb70bc5fbf42767eace2ab5590..9a94c3a6cef523ca3d116bf946cd3a46a44353fb 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.openflowplugin.openflow.md.core.session;
 
 import static org.mockito.Matchers.any;
+
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.math.BigInteger;
 import java.net.InetSocketAddress;
@@ -34,6 +35,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessio
 import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.SalRegistrationManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
@@ -91,7 +94,8 @@ public class SessionManagerOFImplTest {
         });
 
         // session listener - prepare registration and notification mockery
-        final SalRegistrationManager sessionListener = new SalRegistrationManager();
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        final SalRegistrationManager sessionListener = new SalRegistrationManager(convertorManager);
         sessionListener.setPublishService(notificationProviderService);
         sessionListener.setRpcProviderRegistry(rpcProviderRegistry);
         sessionListener.setDataService(dataService);
index a226c157960ff6155825359d198c3b8903139c25..629433734987280424e678f31e7d0c10ce8c1844 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.translator;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.when;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
@@ -24,6 +25,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDist
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionManagerOFImpl;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
@@ -161,11 +164,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
-
 @RunWith(MockitoJUnitRunner.class)
-public class FlowRemovedTranslatorTest extends FlowRemovedTranslator {
+public class FlowRemovedTranslatorTest {
 
-    private static final FlowRemovedTranslator flowRemovedTranslator = new FlowRemovedTranslator();
+    private FlowRemovedTranslator flowRemovedTranslator;
     private static final BigInteger DATA_PATH_ID = BigInteger.valueOf(42);
     public static final Ipv6Address IPV_6_ADDRESS = new Ipv6Address("2001:0DB8:AC10:FE01:0000:0000:0000:0000");
     private static final byte[] IPV_6_ADDRESS_MASK = ByteUtil.unsignedIntToBytes(new Long(64));
@@ -538,6 +540,8 @@ public class FlowRemovedTranslatorTest extends FlowRemovedTranslator {
 
     @Before
     public void setup() {
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
+        flowRemovedTranslator = new FlowRemovedTranslator(convertorManager);
         when(sessionContext.getPrimaryConductor()).thenReturn(connectionConductor);
         when(connectionConductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         when(sessionContext.getFeatures()).thenReturn(featuresOutput);
index 56799b28cf2dfc2904a0df876b1e99ccf586bc09..bb046425dabde216ac22079e74ec8863d7b3c191 100644 (file)
@@ -13,15 +13,19 @@ import static org.mockito.Mockito.when;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
 import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
+import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;\r
@@ -50,21 +54,26 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * @author michal.polkorab\r
  *\r
  */\r
+@RunWith(MockitoJUnitRunner.class)\r
 public class MultipartReplyTableFeaturesToTableUpdatedTranslatorTest {\r
 \r
     @Mock SwitchConnectionDistinguisher cookie;\r
     @Mock SessionContext sc;\r
     @Mock GetFeaturesOutput features;\r
+    @Mock ConnectionConductor conductor;\r
 \r
-    MultipartReplyTableFeaturesToTableUpdatedTranslator translator = new MultipartReplyTableFeaturesToTableUpdatedTranslator();\r
+    MultipartReplyTableFeaturesToTableUpdatedTranslator translator;\r
 \r
     /**\r
      * Initializes mocks\r
      */\r
     @Before\r
     public void startUp() {\r
-        MockitoAnnotations.initMocks(this);\r
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+        translator = new MultipartReplyTableFeaturesToTableUpdatedTranslator(convertorManager);\r
+        when(sc.getPrimaryConductor()).thenReturn(conductor);\r
         when(sc.getFeatures()).thenReturn(features);\r
+        when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);\r
         when(features.getDatapathId()).thenReturn(new BigInteger("42"));\r
     }\r
 \r
index d625aa38e1a902b54c5ce22159caa041c992d366..6413795b4f859f886c011031bbd977edabea7fb4 100644 (file)
@@ -16,12 +16,16 @@ import java.util.List;
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
 import org.mockito.Mock;\r
 import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;\r
@@ -56,6 +60,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 /**\r
  * @author michal.polkorab\r
  */\r
+@RunWith(MockitoJUnitRunner.class)\r
 public class MultipartReplyTranslatorFifthTest {\r
 \r
     @Mock\r
@@ -67,13 +72,15 @@ public class MultipartReplyTranslatorFifthTest {
     @Mock\r
     GetFeaturesOutput features;\r
 \r
-    MultipartReplyTranslator translator = new MultipartReplyTranslator();\r
+    MultipartReplyTranslator translator;\r
 \r
     /**\r
      * Initializes mocks\r
      */\r
     @Before\r
     public void startUp() {\r
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+        translator = new MultipartReplyTranslator(convertorManager);\r
         MockitoAnnotations.initMocks(this);\r
         when(sc.getPrimaryConductor()).thenReturn(conductor);\r
         when(conductor.getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID);\r
index 5abafe5ce3d34c61e4eacb3b9fdf8a01c8649593..f4051a80c80571355850600aec7ecd305c62edf6 100644 (file)
@@ -13,16 +13,18 @@ import static org.mockito.Mockito.when;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
 import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;\r
+import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
@@ -48,6 +50,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * @author michal.polkorab\r
  *\r
  */\r
+@RunWith(MockitoJUnitRunner.class)\r
 public class MultipartReplyTranslatorFirstTest {\r
 \r
     @Mock SwitchConnectionDistinguisher cookie;\r
@@ -55,14 +58,15 @@ public class MultipartReplyTranslatorFirstTest {
     @Mock ConnectionConductor conductor;\r
     @Mock GetFeaturesOutput features;\r
 \r
-    MultipartReplyTranslator translator = new MultipartReplyTranslator();\r
+    MultipartReplyTranslator translator;\r
 \r
     /**\r
      * Initializes mocks\r
      */\r
     @Before\r
     public void startUp() {\r
-        MockitoAnnotations.initMocks(this);\r
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+        translator = new MultipartReplyTranslator(convertorManager);\r
         when(sc.getPrimaryConductor()).thenReturn(conductor);\r
         when(conductor.getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID);\r
         when(sc.getFeatures()).thenReturn(features);\r
index af8fa893c8f3117e714af6b4e4c20a65557bf89c..412b67cbcb8d17347b740b4228a557be1b584fd2 100644 (file)
@@ -9,18 +9,22 @@
 package org.opendaylight.openflowplugin.openflow.md.core.translator;\r
 \r
 import static org.mockito.Mockito.when;\r
+\r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
 import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;\r
@@ -57,6 +61,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * @author michal.polkorab\r
  *\r
  */\r
+@RunWith(MockitoJUnitRunner.class)\r
 public class MultipartReplyTranslatorFourthTest {\r
 \r
     @Mock SwitchConnectionDistinguisher cookie;\r
@@ -64,14 +69,15 @@ public class MultipartReplyTranslatorFourthTest {
     @Mock ConnectionConductor conductor;\r
     @Mock GetFeaturesOutput features;\r
 \r
-    MultipartReplyTranslator translator = new MultipartReplyTranslator();\r
+    MultipartReplyTranslator translator;\r
 \r
     /**\r
      * Initializes mocks\r
      */\r
     @Before\r
     public void startUp() {\r
-        MockitoAnnotations.initMocks(this);\r
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+        translator = new MultipartReplyTranslator(convertorManager);\r
         when(sc.getPrimaryConductor()).thenReturn(conductor);\r
         when(conductor.getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID);\r
         when(sc.getFeatures()).thenReturn(features);\r
index b1ea6ff4526c882b1c748cddc79fb26f4a02f74d..737d2ebbeaf43af32fecef9c092e63a5e0f682a3 100644 (file)
@@ -13,16 +13,18 @@ import static org.mockito.Mockito.when;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
 import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;\r
+import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated;\r
@@ -49,6 +51,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * @author michal.polkorab\r
  *\r
  */\r
+@RunWith(MockitoJUnitRunner.class)\r
 public class MultipartReplyTranslatorSecondTest {\r
 \r
     @Mock SwitchConnectionDistinguisher cookie;\r
@@ -56,14 +59,15 @@ public class MultipartReplyTranslatorSecondTest {
     @Mock ConnectionConductor conductor;\r
     @Mock GetFeaturesOutput features;\r
 \r
-    MultipartReplyTranslator translator = new MultipartReplyTranslator();\r
+    MultipartReplyTranslator translator;\r
 \r
     /**\r
      * Initializes mocks\r
      */\r
     @Before\r
     public void startUp() {\r
-        MockitoAnnotations.initMocks(this);\r
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+        translator = new MultipartReplyTranslator(convertorManager);\r
         when(sc.getPrimaryConductor()).thenReturn(conductor);\r
         when(conductor.getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID);\r
         when(sc.getFeatures()).thenReturn(features);\r
index 24aa3849d075027047903ae899b2f656a7ba2d36..eec1af26c7379f50bfe76db201c147e2e223fbdd 100644 (file)
@@ -13,17 +13,19 @@ import static org.mockito.Mockito.when;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
 import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;\r
+import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;\r
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;\r
@@ -56,6 +58,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  * @author michal.polkorab\r
  *\r
  */\r
+@RunWith(MockitoJUnitRunner.class)\r
 public class MultipartReplyTranslatorThirdTest {\r
 \r
     @Mock SwitchConnectionDistinguisher cookie;\r
@@ -63,14 +66,15 @@ public class MultipartReplyTranslatorThirdTest {
     @Mock ConnectionConductor conductor;\r
     @Mock GetFeaturesOutput features;\r
 \r
-    MultipartReplyTranslator translator = new MultipartReplyTranslator();\r
+    MultipartReplyTranslator translator;\r
 \r
     /**\r
      * Initializes mocks\r
      */\r
     @Before\r
     public void startUp() {\r
-        MockitoAnnotations.initMocks(this);\r
+        final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();\r
+        translator = new MultipartReplyTranslator(convertorManager);\r
         when(sc.getPrimaryConductor()).thenReturn(conductor);\r
         when(conductor.getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID);\r
         when(sc.getFeatures()).thenReturn(features);\r
index 148b7517afc78a4d3d494a1b6fb5d1a974580dea..29fd07aa95837d5b00a30cadfe3256ec89ec1d9c 100644 (file)
@@ -161,7 +161,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
@@ -3218,9 +3218,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
          * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
          * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS  0x100
          */
-        final TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
-        tcpFlagMatch.setTcpFlag(0x002);
-        match.setTcpFlagMatch(tcpFlagMatch.build());
+        final TcpFlagsMatchBuilder tcpFlagsMatch = new TcpFlagsMatchBuilder();
+        tcpFlagsMatch.setTcpFlags(0x002);
+        match.setTcpFlagsMatch(tcpFlagsMatch.build());
 
         return match;
     }