From 13e1d5e6c0237b9378d60526dd8c1d79db6d2b49 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 6 Sep 2019 09:04:45 +0200 Subject: [PATCH] Bump mdsal to 5.0.2 This bumps mdsal to 5.0.2 as part of Magnesium MRI. The change in uint{8,16,32,64} mapping necessitates quite a few changes to protocol coding on both protocol-api and plugin-api side, which are done in minimalistic fashion. A follow-up patch will need to clean up unneeded conversions, especially those from BigInteger. Change-Id: Id9ab45edf28477dca8acf8f7538cfd26f237f6f4 Signed-off-by: Robert Varga --- .../ArbitratorReconciliationManagerImpl.java | 29 +-- .../frm/impl/BundleFlowForwarder.java | 8 +- .../frm/impl/BundleGroupForwarder.java | 17 +- .../frm/impl/DevicesGroupRegistry.java | 9 +- .../applications/frm/impl/FlowForwarder.java | 15 +- .../frm/impl/FlowNodeReconciliationImpl.java | 10 +- .../frm/impl/ForwardingRulesManagerImpl.java | 2 +- .../applications/frm/impl/GroupForwarder.java | 13 +- .../applications/frm/util/FrmUtil.java | 10 +- .../impl/SyncReactorGuardDecorator.java | 3 + .../frsync/impl/SyncReactorImpl.java | 10 +- .../SyncPlanPushStrategyFlatBatchImpl.java | 18 +- .../frsync/util/FlowCapableNodeLookups.java | 10 +- .../frsync/util/FlowDescriptor.java | 3 +- .../frsync/util/ReconcileUtil.java | 16 +- ...SyncPlanPushStrategyFlatBatchImplTest.java | 5 +- .../frsync/util/ReconcileUtilTest.java | 46 ++-- .../applications/lldpspeaker/LLDPSpeaker.java | 3 +- .../applications/lldpspeaker/LLDPUtil.java | 7 +- .../lldpspeaker/LLDPSpeakerTest.java | 3 +- .../applications/lldpspeaker/TestUtils.java | 3 +- .../FlowNotificationSupplierImplTest.java | 5 +- .../GroupNotificationSupplierImplTest.java | 5 +- .../MeterNotificationSupplierImplTest.java | 5 +- .../config/DefaultConfigPusherTest.java | 3 +- .../ReconciliationServiceImpl.java | 13 +- .../southboundcli/cli/Reconciliation.java | 12 +- .../topology/lldp/LLDPLinkAger.java | 6 +- .../codec/match/Icmpv6NDOptionsTypeCodec.java | 5 +- .../openflowjava/nx/api/NiciraConstants.java | 6 +- .../nx/codec/action/AbstractActionCodec.java | 3 +- .../nx/codec/action/ActionDeserializer.java | 6 +- .../nx/codec/action/ConntrackCodec.java | 4 +- .../nx/codec/action/DecapCodec.java | 3 +- .../nx/codec/action/EncapCodec.java | 4 +- .../nx/codec/action/LearnCodecUtil.java | 10 +- .../nx/codec/action/RegLoad2Codec.java | 3 +- .../nx/codec/action/RegLoadCodec.java | 3 +- .../nx/codec/action/RegMoveCodec.java | 9 +- .../match/AbstractExperimenterMatchCodec.java | 10 +- .../nx/codec/match/AbstractNshcCodec.java | 5 +- .../nx/codec/match/ArpOpCodec.java | 2 +- .../nx/codec/match/CtTpDstCodec.java | 2 +- .../nx/codec/match/CtTpSrcCodec.java | 2 +- .../nx/codec/match/CtZoneCodec.java | 2 +- .../nx/codec/match/EthTypeCodec.java | 2 +- .../nx/codec/match/IcmpTypeCodec.java | 2 +- .../nx/codec/match/InPortCodec.java | 2 +- .../nx/codec/match/NshFlagsCodec.java | 7 +- .../nx/codec/match/NshMdtypeCodec.java | 5 +- .../nx/codec/match/NshNpCodec.java | 6 +- .../nx/codec/match/NshTtlCodec.java | 8 +- .../openflowjava/nx/codec/match/NsiCodec.java | 12 +- .../openflowjava/nx/codec/match/NspCodec.java | 4 +- .../nx/codec/match/NxmHeader.java | 23 +- .../nx/codec/match/TcpDstCodec.java | 10 +- .../nx/codec/match/TcpSrcCodec.java | 6 +- .../nx/codec/match/TunIdCodec.java | 3 +- .../nx/codec/match/UdpDstCodec.java | 6 +- .../nx/codec/match/UdpSrcCodec.java | 6 +- .../codec/action/ActionDeserializerTest.java | 7 +- .../nx/codec/action/OutputReg2CodecTest.java | 12 +- .../nx/codec/action/RegMoveCodecTest.java | 11 +- .../AbstractExperimenterMatchCodecTest.java | 15 +- .../nx/codec/match/AbstractNshcCodecTest.java | 11 +- .../nx/codec/match/NshFlagsCodecTest.java | 7 +- .../nx/codec/match/NshMdtypeCodecTest.java | 3 +- .../nx/codec/match/NshNpCodecTest.java | 3 +- .../nx/codec/match/NshTtlCodecTest.java | 11 +- .../nx/codec/match/NsiCodecTest.java | 7 +- .../nx/codec/match/NspCodecTest.java | 11 +- .../nx/codec/match/NxmHeaderTest.java | 20 +- .../extension/api/ExtensionConvertorData.java | 17 +- .../match/Icmpv6NDOptionsTypeConvertor.java | 3 +- .../match/Icmpv6NDReservedConvertor.java | 3 +- .../nicira/NiciraExtensionProvider.java | 4 +- .../vendor/nicira/convertor/IpConverter.java | 18 +- .../convertor/action/DecapConvertor.java | 5 +- .../convertor/action/EncapConvertor.java | 5 +- .../convertor/action/FieldChoiceResolver.java | 31 ++- .../convertor/action/MultipathConvertor.java | 18 +- .../convertor/action/RegLoad2Convertor.java | 96 ++++---- .../convertor/action/RegLoadConvertor.java | 18 +- .../convertor/action/RegMoveConvertor.java | 6 +- .../convertor/match/ArpOpConvertor.java | 3 +- .../convertor/match/ArpSpaConvertor.java | 10 +- .../convertor/match/EthTypeConvertor.java | 3 +- .../nicira/convertor/match/MatchUtil.java | 11 +- .../convertor/match/NshFlagsConvertor.java | 7 +- .../convertor/match/NshMdtypeConvertor.java | 5 +- .../convertor/match/NshNpConvertor.java | 5 +- .../convertor/match/NshTtlConvertor.java | 6 +- .../convertor/match/Nshc1Convertor.java | 15 +- .../convertor/match/Nshc2Convertor.java | 7 +- .../convertor/match/Nshc3Convertor.java | 7 +- .../convertor/match/Nshc4Convertor.java | 7 +- .../nicira/convertor/match/NsiConvertor.java | 5 +- .../nicira/convertor/match/NspConvertor.java | 5 +- .../convertor/match/NxmInPortConvertor.java | 3 +- .../convertor/match/TunIdConvertor.java | 4 +- .../nicira/convertor/MatchUtilTest.java | 2 +- .../convertor/action/DecapConvertorTest.java | 3 +- .../convertor/action/EncapConvertorTest.java | 3 +- .../action/FieldChoiceResolverTest.java | 12 +- .../action/FinTimeoutConvertorTest.java | 9 +- .../action/MultipathConvertorTest.java | 64 +++--- .../action/OutputReg2ConvertorTest.java | 37 +-- .../action/OutputRegConvertorTest.java | 41 ++-- .../action/RegLoad2ConvertorTest.java | 50 +++-- .../action/RegLoadConvertorTest.java | 57 ++--- .../action/RegMoveConvertorTest.java | 45 ++-- .../action/ResubmitConvertorTest.java | 10 +- .../match/NshFlagsConvertorTest.java | 5 +- .../match/NshMdtypeConvertorTest.java | 3 +- .../convertor/match/NshNpConvertorTest.java | 3 +- .../convertor/match/NshTtlConvertorTest.java | 3 +- .../convertor/match/Nshc1ConvertorTest.java | 5 +- .../convertor/match/Nshc2ConvertorTest.java | 5 +- .../convertor/match/Nshc3ConvertorTest.java | 5 +- .../convertor/match/Nshc4ConvertorTest.java | 5 +- .../convertor/match/NsiConvertorTest.java | 3 +- .../convertor/match/NspConvertorTest.java | 3 +- .../convertor/match/TunIdConvertorTest.java | 18 +- .../convertor/match/UdpDstConvertorTest.java | 11 +- .../convertor/match/UdpSrcConvertorTest.java | 11 +- .../extension/onf/ByteBufUtils.java | 10 +- .../BundleAddMessageConverterTest.java | 14 +- .../OnfExperimenterErrorFactoryTest.java | 2 +- .../odl-openflowplugin-nsf-model/pom.xml | 2 +- .../port/rev130925/PortNumberUniBuilder.java | 8 +- .../odl-openflowjava-protocol/pom.xml | 2 +- .../api/keys/ActionSerializerKey.java | 21 +- .../keys/ExperimenterActionSerializerKey.java | 21 +- .../api/keys/MatchEntryDeserializerKey.java | 11 +- .../api/keys/MatchEntrySerializerKey.java | 12 +- .../protocol/api/util/EncodeConstants.java | 4 +- .../api/keys/ActionSerializerKeyTest.java | 9 +- .../keys/MatchEntryDeserializerKeyTest.java | 13 +- .../api/keys/MatchEntrySerializerKeyTest.java | 7 +- .../ExperimenterActionSerializerKeyTest.java | 3 +- .../impl/core/OFDatagramPacketEncoder.java | 2 +- .../protocol/impl/core/OFEncoder.java | 2 +- .../SwitchConnectionProviderFactoryImpl.java | 10 +- .../connection/AbstractConnectionAdapter.java | 2 +- .../connection/ConnectionAdapterImpl.java | 2 +- .../impl/core/connection/StackedSegment.java | 2 +- .../OF13SetFieldActionDeserializer.java | 7 +- .../MultipartReplyMessageFactory.java | 5 +- .../action/OF10OutputActionSerializer.java | 2 +- .../action/OF10SetNwTosActionSerializer.java | 2 +- .../OF10SetVlanPcpActionSerializer.java | 2 +- .../OF10SetVlanVidActionSerializer.java | 2 +- .../action/OF13OutputActionSerializer.java | 2 +- .../action/OF13PopMplsActionSerializer.java | 2 +- .../action/OF13PushMplsActionSerializer.java | 2 +- .../action/OF13PushPbbActionSerializer.java | 2 +- .../action/OF13PushVlanActionSerializer.java | 2 +- .../action/OF13SetFieldActionSerializer.java | 6 +- .../OF13SetMplsTtlActionSerializer.java | 2 +- .../action/OF13SetNwTtlActionSerializer.java | 2 +- .../factories/ErrorMessageFactory.java | 4 +- .../ExperimenterInputMessageFactory.java | 2 +- .../factories/FlowModInputMessageFactory.java | 10 +- .../factories/FlowRemovedMessageFactory.java | 8 +- .../GetConfigReplyMessageFactory.java | 2 +- .../MeterModInputMessageFactory.java | 4 +- .../MultipartReplyMessageFactory.java | 31 +-- .../MultipartRequestInputFactory.java | 7 +- .../OF10FlowModInputMessageFactory.java | 4 +- .../OF10FlowRemovedMessageFactory.java | 6 +- .../factories/OF10PacketInMessageFactory.java | 2 +- .../OF10StatsReplyMessageFactory.java | 10 +- .../factories/PacketInMessageFactory.java | 2 +- .../QueueGetConfigReplyMessageFactory.java | 2 +- .../factories/SetConfigMessageFactory.java | 2 +- .../factories/VendorInputMessageFactory.java | 2 +- .../GoToTableInstructionSerializer.java | 2 +- .../match/OxmArpOpSerializer.java | 2 +- .../match/OxmIcmpv4CodeSerializer.java | 2 +- .../match/OxmIcmpv4TypeSerializer.java | 2 +- .../match/OxmIcmpv6CodeSerializer.java | 2 +- .../match/OxmIcmpv6TypeSerializer.java | 2 +- .../match/OxmIpDscpSerializer.java | 2 +- .../match/OxmIpEcnSerializer.java | 2 +- .../match/OxmIpProtoSerializer.java | 2 +- .../match/OxmMplsTcSerializer.java | 2 +- .../match/OxmVlanPcpSerializer.java | 2 +- .../match/OxmVlanVidSerializer.java | 2 +- ...ctOxmExperimenterMatchEntrySerializer.java | 15 +- .../match/ext/OnfOxmTcpFlagsSerializer.java | 7 +- .../util/ActionSerializerRegistryHelper.java | 11 +- .../impl/util/CodeKeyMakerFactory.java | 15 +- .../MatchEntryDeserializerRegistryHelper.java | 9 +- .../MatchEntrySerializerRegistryHelper.java | 9 +- .../impl/util/OF10MatchSerializer.java | 19 +- .../impl/util/OF13MatchSerializer.java | 8 +- .../impl/util/TypeKeyMakerFactory.java | 23 +- .../impl/core/OFEncoderStatisticsTest.java | 7 +- .../protocol/impl/core/OFEncoderTest.java | 7 +- .../ChannelOutboundQueue02Test.java | 12 + .../ConnectionAdapterImp02lTest.java | 19 ++ .../ConnectionAdapterImpl02Test.java | 19 ++ .../ConnectionAdapterImplStatisticsTest.java | 20 ++ .../FlowModInputMessageFactoryTest.java | 9 +- .../FlowRemovedMessageFactoryTest.java | 2 +- .../MultipartReplyMessageFactoryTest.java | 174 +++++--------- .../OF10FlowModInputMessageFactoryTest.java | 5 +- .../OF10StatsReplyMessageFactoryTest.java | 71 ++---- .../RoleRequestInputMessageFactoryTest.java | 12 +- .../multipart/MultipartReplyFlowTest.java | 21 +- .../OF13SetFieldActionSerializerTest.java | 3 +- .../FlowModInputMessageFactoryTest.java | 8 +- .../MultipartReplyMessageFactoryTest.java | 11 +- .../factories/PacketInMessageFactoryTest.java | 3 +- .../RoleReplyMessageFactoryTest.java | 3 +- .../RoleRequestInputMessageFactoryTest.java | 3 +- .../protocol/impl/util/BufferHelper.java | 35 +-- .../impl/util/CodeKeyMakerFactoryTest.java | 3 +- .../util/DefaultDeserializerFactoryTest.java | 6 +- .../impl/util/TypeKeyMakerFactoryTest.java | 6 +- .../protocol/it/integration/MockPlugin.java | 6 +- .../openflowjava/util/ByteBufUtils.java | 2 +- .../openflowplugin/api/OFConstants.java | 33 +-- .../api/openflow/device/DeviceInfo.java | 5 +- .../api/openflow/device/Xid.java | 13 +- .../api/openflow/md/util/OpenflowVersion.java | 12 + .../registry/flow/FlowRegistryKey.java | 5 +- .../impl/OpenFlowPluginProviderImpl.java | 6 +- .../common/DeviceConnectionRateLimiter.java | 4 +- .../common/MultipartReplyTranslatorUtil.java | 6 +- .../OpenFlowProviderConfigImpl.java | 20 +- .../connection/ConnectionContextImpl.java | 39 ++-- .../connection/ConnectionManagerImpl.java | 2 +- .../impl/connection/HandshakeManagerImpl.java | 56 ++--- .../listener/HandshakeListenerImpl.java | 2 +- .../SystemNotificationsListenerImpl.java | 7 +- .../multipart/PortDescMultipartWriter.java | 3 +- .../multipart/PortStatsMultipartWriter.java | 10 +- .../multipart/QueueStatsMultipartWriter.java | 4 +- .../impl/device/DeviceManagerImpl.java | 10 +- .../impl/device/SwitchFeaturesUtil.java | 8 +- .../initialization/OF10DeviceInitializer.java | 2 +- .../initialization/OF13DeviceInitializer.java | 16 +- .../lifecycle/ContextChainHolderImpl.java | 24 +- .../impl/lifecycle/ContextChainImpl.java | 10 +- .../MatchDeserializerInjector.java | 7 +- .../match/MatchDeserializer.java | 16 +- .../messages/PortMessageDeserializer.java | 49 ++-- ...ltipartReplyGroupFeaturesDeserializer.java | 28 +-- .../MultipartReplyPortDescDeserializer.java | 53 ++--- ...ltipartReplyTableFeaturesDeserializer.java | 22 +- .../TableFeaturesMatchFieldDeserializer.java | 14 +- .../actions/OutputActionSerializer.java | 9 +- .../actions/PopMplsActionSerializer.java | 4 +- .../actions/PushMplsActionSerializer.java | 4 +- .../actions/PushPbbActionSerializer.java | 4 +- .../actions/PushVlanActionSerializer.java | 4 +- .../actions/SetMplsTtlActionSerializer.java | 4 +- .../actions/SetNwTtlActionSerializer.java | 4 +- .../actions/SetTpDstActionSerializer.java | 6 +- .../actions/SetTpSrcActionSerializer.java | 6 +- .../GoToTableInstructionSerializer.java | 4 +- .../WriteMetadataInstructionSerializer.java | 11 +- .../match/ArpOpEntrySerializer.java | 8 +- .../match/Icmpv4CodeEntrySerializer.java | 8 +- .../match/Icmpv4TypeEntrySerializer.java | 8 +- .../match/Icmpv6CodeEntrySerializer.java | 8 +- .../match/Icmpv6TypeEntrySerializer.java | 8 +- .../match/InPortEntrySerializer.java | 9 +- .../match/IpDscpEntrySerializer.java | 8 +- .../match/IpEcnEntrySerializer.java | 8 +- .../match/IpProtoEntrySerializer.java | 8 +- .../match/Ipv6ExtHeaderEntrySerializer.java | 8 +- .../match/MetadataEntrySerializer.java | 16 +- .../match/MplsBosEntrySerializer.java | 8 +- .../match/MplsTcEntrySerializer.java | 8 +- .../SctpDestinationPortEntrySerializer.java | 8 +- .../match/SctpSourcePortEntrySerializer.java | 8 +- .../TcpDestinationPortEntrySerializer.java | 8 +- .../match/TcpFlagsEntrySerializer.java | 10 +- .../match/TcpSourcePortEntrySerializer.java | 8 +- .../match/TunnelIdEntrySerializer.java | 15 +- .../UdpDestinationPortEntrySerializer.java | 8 +- .../match/UdpSourcePortEntrySerializer.java | 8 +- .../match/VlanPcpEntrySerializer.java | 8 +- .../match/VlanVidEntrySerializer.java | 10 +- .../messages/FlowMessageSerializer.java | 55 ++--- .../messages/GroupMessageSerializer.java | 10 +- .../messages/MeterMessageSerializer.java | 6 +- ...ultipartRequestExperimenterSerializer.java | 2 +- .../NextTableMissTablePropertySerializer.java | 2 +- .../NextTableTablePropertySerializer.java | 2 +- .../registry/flow/DeviceFlowRegistryImpl.java | 14 +- .../registry/flow/FlowDescriptorFactory.java | 13 +- .../registry/flow/FlowRegistryKeyFactory.java | 18 +- .../impl/role/RoleContextImpl.java | 4 +- .../impl/rpc/AbstractRequestContext.java | 8 +- .../impl/rpc/RpcContextImpl.java | 18 +- .../impl/rpc/RpcManagerImpl.java | 4 +- .../AbstractMultipartCollectorService.java | 9 +- .../impl/services/AbstractService.java | 14 +- .../impl/services/RoleService.java | 9 +- .../services/batch/FlatBatchFlowAdapters.java | 21 +- .../batch/FlatBatchGroupAdapters.java | 2 +- .../batch/FlatBatchMeterAdapters.java | 21 +- ...ltiLayerAggregateFlowMultipartService.java | 6 +- .../MultiLayerTableMultipartService.java | 17 +- .../impl/services/sal/SalRoleServiceImpl.java | 12 +- .../SingleLayerTableMultipartService.java | 14 +- .../impl/services/util/RequestInputUtils.java | 8 +- .../statistics/StatisticsContextImpl.java | 10 +- .../AggregateFlowsInTableService.java | 17 +- .../StatisticsGatheringOnTheFlyService.java | 2 +- .../dedicated/StatisticsGatheringService.java | 2 +- .../FlowDirectStatisticsService.java | 3 +- .../translator/FlowRemovedTranslator.java | 13 +- .../translator/FlowRemovedV10Translator.java | 10 +- .../translator/PacketReceivedTranslator.java | 12 +- .../impl/translator/PortUpdateTranslator.java | 3 +- .../impl/util/AddressNormalizationUtil.java | 3 +- .../impl/util/FlowCreatorUtil.java | 26 +-- .../openflowplugin/impl/util/FlowUtil.java | 5 +- .../openflowplugin/impl/util/GroupUtil.java | 11 +- .../NodeConnectorRefToPortTranslator.java | 21 +- .../impl/util/PortTranslatorUtil.java | 11 +- .../impl/OpenFlowPluginProviderImplTest.java | 8 +- .../ConfigurationServiceFactoryImplTest.java | 10 +- .../OpenFlowProviderConfigImplTest.java | 38 ++-- .../OutboundQueueProviderImplTest.java | 7 +- .../listener/HandshakeListenerImplTest.java | 4 +- .../SystemNotificationsListenerImplTest.java | 10 +- .../impl/device/DeviceContextImplTest.java | 28 +-- .../OF10DeviceInitializerTest.java | 3 +- .../OF13DeviceInitializerTest.java | 3 +- .../listener/MultiMsgCollectorImplTest.java | 21 +- .../lifecycle/ContextChainHolderImplTest.java | 6 +- ...teMetadataInstructionDeserializerTest.java | 14 +- .../EthernetTypeEntryDeserializerTest.java | 4 +- .../match/MetadataEntryDeserializerTest.java | 12 +- .../PacketTypeEntryDeserializerTest.java | 3 +- .../match/TcpFlagsEntryDeserializerTest.java | 4 +- .../match/TunnelIdEntryDeserializerTest.java | 6 +- ...artReplyGroupFeaturesDeserializerTest.java | 11 +- .../actions/SetTpDstActionSerializerTest.java | 3 +- .../actions/SetTpSrcActionSerializerTest.java | 3 +- .../match/TcpFlagsEntrySerializerTest.java | 2 +- ...artRequestTableFeaturesSerializerTest.java | 5 +- ...tTableMissTablePropertySerializerTest.java | 4 +- .../NextTableTablePropertySerializerTest.java | 3 +- .../flow/DeviceFlowRegistryImplTest.java | 10 +- .../registry/flow/FlowDescriptorDtoTest.java | 8 +- .../flow/FlowRegistryKeyFactoryTest.java | 10 +- .../impl/rpc/AbstractRequestContextTest.java | 4 +- .../services/AbstractRequestCallbackTest.java | 7 +- .../impl/services/EchoServiceTest.java | 3 +- .../MultipartRequestOnTheFlyCallbackTest.java | 8 +- .../impl/services/ServiceMocking.java | 16 +- ...FlowCapableTransactionServiceImplTest.java | 4 +- .../sal/NodeConfigServiceImplTest.java | 6 +- .../sal/PacketProcessingServiceImplTest.java | 3 +- .../sal/SalAsyncConfigServiceImplTest.java | 2 +- ...SalExperimenterMessageServiceImplTest.java | 3 +- .../services/sal/SalFlowServiceImplTest.java | 28 +-- .../services/sal/SalPortServiceImplTest.java | 5 +- .../services/sal/SalRoleServiceImplTest.java | 24 +- ...ayerAggregateFlowMultipartServiceTest.java | 4 +- .../SingleLayerPortServiceTest.java | 9 +- .../services/util/RequestInputUtilsTest.java | 7 +- .../MultipartReplyTranslatorTest.java | 52 ++--- .../StatisticsContextImpMockInitiation.java | 4 +- .../statistics/StatisticsContextImplTest.java | 3 +- .../StatisticsGatheringUtilsTest.java | 8 +- .../AbstractSingleStatsServiceTest.java | 3 +- .../services/AbstractStatsServiceTest.java | 15 +- ...aylightFlowStatisticsServiceImpl1Test.java | 5 +- ...aylightFlowStatisticsServiceImpl2Test.java | 4 +- ...ghtFlowTableStatisticsServiceImplTest.java | 6 +- ...aylightGroupStatisticsServiceImplTest.java | 4 +- .../services/PortStatsServiceTest.java | 4 +- .../AbstractCompatibleStatServiceTest.java | 6 +- ...tatisticsGatheringOnTheFlyServiceTest.java | 8 +- .../StatisticsGatheringServiceTest.java | 3 +- .../AbstractDirectStatisticsServiceTest.java | 14 +- .../FlowDirectStatisticsServiceTest.java | 6 +- .../GroupDirectStatisticsServiceTest.java | 5 +- .../MeterDirectStatisticsServiceTest.java | 5 +- ...eConnectorDirectStatisticsServiceTest.java | 27 +-- .../QueueDirectStatisticsServiceTest.java | 15 +- .../FlowDirectStatisticsServiceTest.java | 6 +- .../GroupDirectStatisticsServiceTest.java | 5 +- .../MeterDirectStatisticsServiceTest.java | 5 +- ...eConnectorDirectStatisticsServiceTest.java | 3 +- .../QueueDirectStatisticsServiceTest.java | 5 +- .../translator/FlowRemovedTranslatorTest.java | 4 +- .../PacketReceivedTranslatorTest.java | 12 +- .../util/DeviceInitializationUtilTest.java | 7 +- .../impl/util/FlowUtilTest.java | 3 +- .../impl/util/GroupUtilTest.java | 8 +- .../impl/util/MdSalRegistrationUtilsTest.java | 6 +- .../NodeConnectorRefToPortTranslatorTest.java | 14 +- .../impl/util/PortTranslatorUtilTest.java | 13 +- .../core/extension/ActionExtensionHelper.java | 3 +- .../core/extension/MatchExtensionHelper.java | 10 +- .../md/core/sal/convertor/GroupConvertor.java | 20 +- .../sal/convertor/PacketOutConvertor.java | 13 +- .../sal/convertor/TableFeaturesConvertor.java | 14 +- .../TableFeaturesResponseConvertor.java | 5 +- .../action/cases/OfToSalOutputActionCase.java | 7 +- .../action/cases/OfToSalSetNwTosCase.java | 5 +- .../action/cases/SalToOfOutputActionCase.java | 5 +- .../cases/SalToOfSetTpDstActionCase.java | 10 +- .../cases/SalToOfSetTpSrcActionCase.java | 10 +- .../action/data/ActionConvertorData.java | 9 +- .../data/ActionResponseConvertorData.java | 11 +- .../sal/convertor/common/IPProtocols.java | 32 ++- .../data/VersionDatapathIdConvertorData.java | 10 +- .../sal/convertor/data/XidConvertorData.java | 10 +- .../sal/convertor/flow/FlowConvertor.java | 71 +++--- .../sal/convertor/flow/FlowConvertorUtil.java | 20 +- .../flow/FlowStatsResponseConvertor.java | 20 +- .../sal/convertor/flow/cases/MeterCase.java | 16 +- .../flow/cases/WriteMetadataCase.java | 9 +- .../sal/convertor/match/MatchConvertor.java | 212 ++++++++---------- .../convertor/match/MatchV10Convertor.java | 54 ++--- .../match/MatchV10ResponseConvertor.java | 28 +-- .../match/cases/OfToSalEthTypeCase.java | 19 +- .../match/cases/OfToSalIcmpv4CodeCase.java | 8 +- .../match/cases/OfToSalIcmpv4TypeCase.java | 8 +- .../match/cases/OfToSalIcmpv6CodeCase.java | 8 +- .../match/cases/OfToSalIcmpv6TypeCase.java | 8 +- .../match/cases/OfToSalInPhyPortCase.java | 9 +- .../match/cases/OfToSalInPortCase.java | 9 +- .../match/cases/OfToSalIpProtoCase.java | 8 +- .../match/cases/OfToSalPacketTypeCase.java | 14 +- .../match/cases/SalToOfIpv6MatchCase.java | 8 +- .../openflow/md/util/ActionUtil.java | 10 +- .../openflow/md/util/ByteUtil.java | 76 +++++++ .../md/util/InventoryDataServiceUtil.java | 39 ++-- .../openflow/md/util/OpenflowPortsUtil.java | 96 ++++++-- .../sal/convertor/GroupConvertorTest.java | 47 ++-- ...MeterConfigStatsResponseConvertorTest.java | 3 +- .../sal/convertor/MeterConvertorTest.java | 84 +++---- .../MeterStatsResponseConvertorTest.java | 24 +- .../sal/convertor/PacketOutConvertorTest.java | 17 +- .../core/sal/convertor/PortConvertorTest.java | 13 +- .../TableFeaturesResponseConvertorTest.java | 31 ++- .../convertor/action/ActionConvertorTest.java | 22 +- .../action/ActionConvertorV10Test.java | 4 +- .../action/ActionConvertorV13Test.java | 7 +- .../sal/convertor/flow/FlowConvertorTest.java | 31 +-- .../match/MatchConvertorV10Test.java | 22 +- .../match/MatchResponseConvertor2Test.java | 54 ++--- .../match/MatchResponseConvertorTest.java | 11 +- .../match/MatchV10ResponseConvertorTest.java | 67 +++--- .../openflow/md/util/ByteUtilTest.java | 8 + .../md/util/InventoryDataServiceUtilTest.java | 12 +- .../md/util/OpenflowPortsUtilTest.java | 32 ++- parent/pom.xml | 2 +- .../learningswitch/FlowUtils.java | 10 +- .../InstanceIdentifierUtils.java | 3 +- .../LearningSwitchHandlerSimpleImpl.java | 3 +- .../learningswitch/WakeupOnNode.java | 3 +- .../test/NodeErrorListenerLoggingImpl.java | 5 +- ...luginTableFeaturesTestCommandProvider.java | 6 +- 464 files changed, 2963 insertions(+), 2563 deletions(-) diff --git a/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java b/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java index c0ef4db5fb..ce99ea2f89 100644 --- a/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java +++ b/applications/arbitratorreconciliation/impl/src/main/java/org/opendaylight/openflowplugin/applications/arbitratorreconciliation/impl/ArbitratorReconciliationManagerImpl.java @@ -15,7 +15,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import java.math.BigInteger; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -82,6 +82,7 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,7 +105,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS private final UpgradeState upgradeState; private NotificationRegistration registration; private final ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE); - private final Map bundleIdMap = new ConcurrentHashMap<>(); + private final Map bundleIdMap = new ConcurrentHashMap<>(); @Inject public ArbitratorReconciliationManagerImpl(@Reference RpcProviderRegistry rpcRegistry, @@ -138,7 +139,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS @Override public ListenableFuture> commitActiveBundle( CommitActiveBundleInput input) { - BigInteger nodeId = input.getNodeId(); + Uint64 nodeId = input.getNodeId(); if (bundleIdMap.containsKey(nodeId)) { BundleId bundleId = bundleIdMap.get(nodeId).getBundleId(); if (bundleId != null) { @@ -165,7 +166,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS @Override public ListenableFuture> getActiveBundle(GetActiveBundleInput input) { - BigInteger nodeId = input.getNodeId(); + Uint64 nodeId = input.getNodeId(); BundleDetails bundleDetails = bundleIdMap.get(nodeId); if (bundleDetails != null) { try { @@ -197,7 +198,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS @Override public ListenableFuture endReconciliation(DeviceInfo node) { - BigInteger datapathId = node.getDatapathId(); + Uint64 datapathId = node.getDatapathId(); LOG.trace("Stopping arbitrator reconciliation for node {}", datapathId); bundleIdMap.remove(datapathId); deregisterRpc(node); @@ -225,6 +226,8 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS return JdkFutureAdapters.listenInPoolThread(executor.submit(upgradeReconTask)); } + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") private Messages createMessages(final NodeRef nodeRef) { final List messages = new ArrayList<>(); messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage( @@ -296,7 +299,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS } return Futures.immediateFuture(null); }, MoreExecutors.directExecutor()); - BigInteger nodeId = getDpnIdFromNodeName(node); + Uint64 nodeId = getDpnIdFromNodeName(node); try { if (addBundleMessagesFuture.get().isSuccessful()) { bundleIdMap.put(nodeId, new BundleDetails(bundleIdValue, @@ -316,9 +319,9 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS } public final class CommitActiveBundleCallback implements FutureCallback> { - private final BigInteger nodeId; + private final Uint64 nodeId; - private CommitActiveBundleCallback(final BigInteger nodeId) { + private CommitActiveBundleCallback(final Uint64 nodeId) { this.nodeId = nodeId; } @@ -330,8 +333,7 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS @Override public void onFailure(Throwable throwable) { - LOG.error("Error while performing arbitrator reconciliation for device {}", - nodeId, throwable); + LOG.error("Error while performing arbitrator reconciliation for device {}", nodeId, throwable); } } @@ -387,9 +389,10 @@ public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileS } } - private BigInteger getDpnIdFromNodeName(String nodeName) { + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") + private Uint64 getDpnIdFromNodeName(String nodeName) { String dpnId = nodeName.substring(nodeName.lastIndexOf(SEPARATOR) + 1); - return new BigInteger(dpnId); + return Uint64.valueOf(dpnId); } - } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java index 51797f58f1..46d866d73d 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java @@ -61,6 +61,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,6 +80,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { "NodeConfigurator can not be null!"); } + @Override public void remove(final InstanceIdentifier identifier, final Flow flow, final InstanceIdentifier nodeIdent, final BundleId bundleId) { final List messages = new ArrayList<>(1); @@ -97,6 +100,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { LoggingFutures.addErrorLogging(resultFuture, LOG, "removeBundleFlow"); } + @Override public void update(final InstanceIdentifier identifier, final Flow originalFlow, final Flow updatedFlow, final InstanceIdentifier nodeIdent, final BundleId bundleId) { remove(identifier, originalFlow, nodeIdent, bundleId); @@ -128,7 +132,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { //TODO This read to the DS might have a performance impact. //if the dependent group is not installed than we should just cache the parent group, //till we receive the dependent group DTCN and then push it. - Long groupId = isFlowDependentOnGroup(updatedFlow); + Uint32 groupId = isFlowDependentOnGroup(updatedFlow); ListenableFuture> resultFuture; if (groupId != null) { LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present", @@ -196,7 +200,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter { private final Message messages; private final NodeId nodeId; private final String flowId; - private final short tableId; + private final Uint8 tableId; private final SettableFuture> resultFuture; BundleFlowCallBack(InstanceIdentifier nodeIdent, BundleId bundleId, Message messages, diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleGroupForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleGroupForwarder.java index 1c32fa0662..a82b3b2836 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleGroupForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleGroupForwarder.java @@ -45,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,6 +63,7 @@ public class BundleGroupForwarder implements BundleMessagesCommiter { "NodeConfigurator can not be null!"); } + @Override public void remove(final InstanceIdentifier identifier, final Group group, final InstanceIdentifier nodeIdent, final BundleId bundleId) { final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent); @@ -87,6 +89,7 @@ public class BundleGroupForwarder implements BundleMessagesCommiter { } + @Override public void update(final InstanceIdentifier identifier, final Group originalGroup, final Group updatedGroup, final InstanceIdentifier nodeIdent, final BundleId bundleId) { final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent); @@ -115,7 +118,7 @@ public class BundleGroupForwarder implements BundleMessagesCommiter { public ListenableFuture> add(final InstanceIdentifier identifier, final Group group, final InstanceIdentifier nodeIdent, final BundleId bundleId) { final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent); - final Long groupId = group.getGroupId().getValue(); + final Uint32 groupId = group.getGroupId().getValue(); return nodeConfigurator.enqueueJob(nodeId.getValue(), () -> { if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) { LOG.debug("Group {} already exists in the device. Ignoring the add DTCN", groupId); @@ -141,10 +144,10 @@ public class BundleGroupForwarder implements BundleMessagesCommiter { } private final class BundleAddGroupCallBack implements FutureCallback> { - private final Long groupId; + private final Uint32 groupId; private final NodeId nodeId; - private BundleAddGroupCallBack(final Long groupId, final NodeId nodeId) { + private BundleAddGroupCallBack(final Uint32 groupId, final NodeId nodeId) { this.groupId = groupId; this.nodeId = nodeId; } @@ -167,10 +170,10 @@ public class BundleGroupForwarder implements BundleMessagesCommiter { } private final class BundleUpdateGroupCallBack implements FutureCallback> { - private final Long groupId; + private final Uint32 groupId; private final NodeId nodeId; - private BundleUpdateGroupCallBack(final Long groupId, final NodeId nodeId) { + private BundleUpdateGroupCallBack(final Uint32 groupId, final NodeId nodeId) { this.groupId = groupId; this.nodeId = nodeId; } @@ -193,10 +196,10 @@ public class BundleGroupForwarder implements BundleMessagesCommiter { } private final class BundleRemoveGroupCallBack implements FutureCallback> { - private final Long groupId; + private final Uint32 groupId; private final NodeId nodeId; - private BundleRemoveGroupCallBack(final Long groupId, final NodeId nodeId) { + private BundleRemoveGroupCallBack(final Uint32 groupId, final NodeId nodeId) { this.groupId = groupId; this.nodeId = nodeId; } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java index 93d4231d1d..c464e3c503 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java @@ -13,19 +13,20 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; +import org.opendaylight.yangtools.yang.common.Uint32; public class DevicesGroupRegistry { - private final Map> deviceGroupMapping = new ConcurrentHashMap<>(); + private final Map> deviceGroupMapping = new ConcurrentHashMap<>(); - public boolean isGroupPresent(NodeId nodeId, Long groupId) { + public boolean isGroupPresent(NodeId nodeId, Uint32 groupId) { return deviceGroupMapping.get(nodeId) != null ? deviceGroupMapping.get(nodeId).contains(groupId) : false; } - public void storeGroup(NodeId nodeId, Long groupId) { + public void storeGroup(NodeId nodeId, Uint32 groupId) { deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId); } - public void removeGroup(NodeId nodeId, Long groupId) { + public void removeGroup(NodeId nodeId, Uint32 groupId) { deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java index 07744ffc45..689ffe48c0 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java @@ -67,6 +67,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -192,7 +193,7 @@ public class FlowForwarder extends AbstractListeningCommiter { builder.setUpdatedFlow(new UpdatedFlowBuilder(update).setStrict(Boolean.TRUE).build()); builder.setOriginalFlow(new OriginalFlowBuilder(original).setStrict(Boolean.TRUE).build()); - Long groupId = isFlowDependentOnGroup(update); + Uint32 groupId = isFlowDependentOnGroup(update); if (groupId != null) { LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present", getFlowId(new FlowRef(identifier)), groupId); @@ -238,7 +239,7 @@ public class FlowForwarder extends AbstractListeningCommiter { builder.setFlowRef(new FlowRef(identifier)); builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey))); builder.setTransactionUri(new Uri(provider.getNewTransactionId())); - Long groupId = isFlowDependentOnGroup(addDataObj); + Uint32 groupId = isFlowDependentOnGroup(addDataObj); if (groupId != null) { LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present", getFlowId(new FlowRef(identifier)), groupId); @@ -330,7 +331,7 @@ public class FlowForwarder extends AbstractListeningCommiter { } private ListenableFuture> pushDependentGroup( - final InstanceIdentifier nodeIdent, final Long groupId) { + final InstanceIdentifier nodeIdent, final Uint32 groupId) { //TODO This read to the DS might have a performance impact. //if the dependent group is not installed than we should just cache the parent group, @@ -365,10 +366,10 @@ public class FlowForwarder extends AbstractListeningCommiter { private final class AddFlowCallBack implements FutureCallback> { private final AddFlowInput addFlowInput; private final NodeId nodeId; - private final Long groupId; + private final Uint32 groupId; private final SettableFuture> resultFuture; - private AddFlowCallBack(final AddFlowInput addFlowInput, final NodeId nodeId, Long groupId, + private AddFlowCallBack(final AddFlowInput addFlowInput, final NodeId nodeId, Uint32 groupId, SettableFuture> resultFuture) { this.addFlowInput = addFlowInput; this.nodeId = nodeId; @@ -415,11 +416,11 @@ public class FlowForwarder extends AbstractListeningCommiter { private final class UpdateFlowCallBack implements FutureCallback> { private final UpdateFlowInput updateFlowInput; private final NodeId nodeId; - private final Long groupId; + private final Uint32 groupId; private final SettableFuture> resultFuture; private UpdateFlowCallBack(final UpdateFlowInput updateFlowInput, final NodeId nodeId, - SettableFuture> resultFuture, Long groupId) { + SettableFuture> resultFuture, Uint32 groupId) { this.updateFlowInput = updateFlowInput; this.nodeId = nodeId; this.groupId = groupId; diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java index 80899062a2..b3ef2f2f0b 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java @@ -93,6 +93,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -355,7 +356,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { // new list for suspected groups pointing to ports .. when the ports come up // late List suspectedGroups = new ArrayList<>(); - Map> groupFutures = new HashMap<>(); + Map> groupFutures = new HashMap<>(); while ((!toBeInstalledGroups.isEmpty() || !suspectedGroups.isEmpty()) && counter <= provider.getReconciliationRetryCount()) { // also check if the counter has not @@ -412,7 +413,8 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { .equals("org.opendaylight.yang.gen.v1.urn.opendaylight" + ".action.types.rev131112.action.action.GroupActionCase")) { // chained groups - Long groupId = ((GroupActionCase) action.getAction()).getGroupAction().getGroupId(); + Uint32 groupId = ((GroupActionCase) action.getAction()).getGroupAction() + .getGroupId(); ListenableFuture future = groupFutures.get(groupId); if (future == null) { okToInstall = false; @@ -490,9 +492,9 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { * @param group * The group to add. */ - private void addGroup(Map> map, Group group) { + private void addGroup(Map> map, Group group) { KeyedInstanceIdentifier groupIdent = nodeIdentity.child(Group.class, group.key()); - final Long groupId = group.getGroupId().getValue(); + final Uint32 groupId = group.getGroupId().getValue(); ListenableFuture future = JdkFutureAdapters .listenInPoolThread(provider.getGroupCommiter().add(groupIdent, group, nodeIdentity)); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java index 3aa4f0b04d..0803b8ef59 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java @@ -119,7 +119,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { @Reference final ServiceRecoveryRegistry serviceRecoveryRegistry) { disableReconciliation = config.isDisableReconciliation(); staleMarkingEnabled = config.isStaleMarkingEnabled(); - reconciliationRetryCount = config.getReconciliationRetryCount(); + reconciliationRetryCount = config.getReconciliationRetryCount().toJava(); isBundleBasedReconciliationEnabled = config.isBundleBasedReconciliationEnabled(); this.configurationServiceRegistration = configurationService.registerListener(this); this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!"); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java index ae54153081..3dd51cad18 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java @@ -48,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -240,10 +241,10 @@ public class GroupForwarder extends AbstractListeningCommiter { } private final class AddGroupCallBack implements FutureCallback> { - private final Long groupId; + private final Uint32 groupId; private final NodeId nodeId; - private AddGroupCallBack(final Long groupId, final NodeId nodeId) { + private AddGroupCallBack(final Uint32 groupId, final NodeId nodeId) { this.groupId = groupId; this.nodeId = nodeId; } @@ -266,10 +267,10 @@ public class GroupForwarder extends AbstractListeningCommiter { } private final class UpdateGroupCallBack implements FutureCallback> { - private final Long groupId; + private final Uint32 groupId; private final NodeId nodeId; - private UpdateGroupCallBack(final Long groupId, final NodeId nodeId) { + private UpdateGroupCallBack(final Uint32 groupId, final NodeId nodeId) { this.groupId = groupId; this.nodeId = nodeId; } @@ -293,10 +294,10 @@ public class GroupForwarder extends AbstractListeningCommiter { } private final class RemoveGroupCallBack implements FutureCallback> { - private final Long groupId; + private final Uint32 groupId; private final NodeId nodeId; - private RemoveGroupCallBack(final Long groupId, final NodeId nodeId) { + private RemoveGroupCallBack(final Uint32 groupId, final NodeId nodeId) { this.groupId = groupId; this.nodeId = nodeId; } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java index 4ef0316175..9bb5be1b5f 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java @@ -38,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.arbitrator.reconcile.service.rev180227.GetActiveBundleOutput; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +60,7 @@ public final class FrmUtil { return flowRef.getValue().firstKeyOf(Flow.class).getId().getValue(); } - public static short getTableId(final FlowTableRef flowTableRef) { + public static Uint8 getTableId(final FlowTableRef flowTableRef) { return flowTableRef.getValue().firstKeyOf(Table.class).getId(); } @@ -68,7 +70,7 @@ public final class FrmUtil { return new BigInteger(dpId); } - public static Long isFlowDependentOnGroup(final Flow flow) { + public static Uint32 isFlowDependentOnGroup(final Flow flow) { LOG.debug("Check if flow {} is dependent on group", flow); if (flow.getInstructions() != null) { List instructions = flow.getInstructions().getInstruction(); @@ -92,7 +94,7 @@ public final class FrmUtil { } public static InstanceIdentifier buildGroupInstanceIdentifier( - final InstanceIdentifier nodeIdent, final Long groupId) { + final InstanceIdentifier nodeIdent, final Uint32 groupId) { NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent); InstanceIdentifier groupInstanceId = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class) @@ -120,7 +122,7 @@ public final class FrmUtil { } public static boolean isGroupExistsOnDevice(final InstanceIdentifier nodeIdent, - final Long groupId, final ForwardingRulesManager provider) { + final Uint32 groupId, final ForwardingRulesManager provider) { NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent); return provider.getDevicesGroupRegistry().isGroupPresent(nodeId, groupId); } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java index 91bf600760..2db109b294 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java @@ -11,6 +11,7 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper; @@ -85,6 +86,8 @@ public class SyncReactorGuardDecorator implements SyncReactor { }; } + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") private static String formatNanos(final long nanos) { return "'" + TimeUnit.NANOSECONDS.toMillis(nanos) + " ms'"; } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java index 3537904575..6b9c9523b7 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java @@ -38,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -117,7 +119,7 @@ public class SyncReactorImpl implements SyncReactor { final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { final List groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured); final List groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational); - final Map groupOperationalMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsOperational); + final Map groupOperationalMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsOperational); final List pendingGroups = new ArrayList<>(); pendingGroups.addAll(groupsConfigured); @@ -145,7 +147,7 @@ public class SyncReactorImpl implements SyncReactor { } final List tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational); - final Map tableOperationalMap = FlowCapableNodeLookups.wrapTablesToMap(tablesOperational); + final Map tableOperationalMap = FlowCapableNodeLookups.wrapTablesToMap(tablesOperational); return ReconcileUtil.resolveFlowDiffsInAllTables(nodeId, tableOperationalMap, tablesConfigured, true); } @@ -159,7 +161,7 @@ public class SyncReactorImpl implements SyncReactor { } final List
tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured); - final Map tableConfiguredMap = FlowCapableNodeLookups.wrapTablesToMap(tablesConfigured); + final Map tableConfiguredMap = FlowCapableNodeLookups.wrapTablesToMap(tablesConfigured); return ReconcileUtil.resolveFlowDiffsInAllTables(nodeId, tableConfiguredMap, tablesOperational, false); } @@ -181,7 +183,7 @@ public class SyncReactorImpl implements SyncReactor { final FlowCapableNode flowCapableNodeOperational) { final List groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured); final List groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational); - final Map groupConfiguredMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsConfigured); + final Map groupConfiguredMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsConfigured); final List pendingGroups = new ArrayList<>(); pendingGroups.addAll(groupsOperational); diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java index 54fcf60b8a..3c85a7d7ed 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java @@ -15,6 +15,7 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -80,6 +81,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,7 +162,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { public void onSuccess(final RpcResult result) { if (!result.isSuccessful() && result.getResult() != null && !result.getResult().getBatchFailure().isEmpty()) { - Map, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit); + Map, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit); decrementBatchFailuresCounters(result.getResult().getBatchFailure(), batchMap, counters); } } @@ -172,11 +174,13 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { }; } + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") private static void decrementBatchFailuresCounters(final List batchFailures, - final Map, Batch> batchMap, + final Map, Batch> batchMap, final SyncCrudCounters counters) { for (BatchFailure batchFailure : batchFailures) { - for (Map.Entry, Batch> rangeBatchEntry : batchMap.entrySet()) { + for (Map.Entry, Batch> rangeBatchEntry : batchMap.entrySet()) { if (rangeBatchEntry.getKey().contains(batchFailure.getBatchOrder())) { // get type and decrease final BatchChoice batchChoice = rangeBatchEntry.getValue().getBatchChoice(); @@ -209,15 +213,15 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } } - static Map, Batch> mapBatchesToRanges(final List inputBatchBag, final int failureIndexLimit) { - final Map, Batch> batchMap = new LinkedHashMap<>(); + static Map, Batch> mapBatchesToRanges(final List inputBatchBag, final int failureIndexLimit) { + final Map, Batch> batchMap = new LinkedHashMap<>(); final PeekingIterator batchPeekingIterator = Iterators.peekingIterator(inputBatchBag.iterator()); while (batchPeekingIterator.hasNext()) { final Batch batch = batchPeekingIterator.next(); final int nextBatchOrder = batchPeekingIterator.hasNext() - ? batchPeekingIterator.peek().getBatchOrder() + ? batchPeekingIterator.peek().getBatchOrder().toJava() : failureIndexLimit; - batchMap.put(Range.closed(batch.getBatchOrder(), nextBatchOrder - 1), batch); + batchMap.put(Range.closed(batch.getBatchOrder(), Uint16.valueOf(nextBatchOrder - 1)), batch); } return batchMap; } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java index e582c4a868..f36be7d814 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java @@ -19,6 +19,8 @@ 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.group.types.rev131018.groups.Group; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,8 +36,8 @@ public final class FlowCapableNodeLookups { } @Nonnull - public static Map wrapTablesToMap(@Nullable final List
tables) { - final Map tableMap; + public static Map wrapTablesToMap(@Nullable final List
tables) { + final Map tableMap; if (tables == null) { tableMap = Collections.emptyMap(); @@ -89,8 +91,8 @@ public final class FlowCapableNodeLookups { } @Nonnull - public static Map wrapGroupsToMap(@Nullable final List groups) { - final Map groupMap; + public static Map wrapGroupsToMap(@Nullable final List groups) { + final Map groupMap; if (groups == null) { groupMap = Collections.emptyMap(); diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowDescriptor.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowDescriptor.java index f7a7db5bff..4a1c0c9d93 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowDescriptor.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowDescriptor.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.applications.frsync.util; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Identifier of {@link Flow} in datastore using combination of flow-id and table-id from datastore datapath. @@ -16,7 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta public class FlowDescriptor { private final FlowId flowId; - private final Short tableId; + private final Uint8 tableId; public FlowDescriptor(Flow flow) { this.flowId = flow.getId(); diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java index c923dd7345..6e7f110bfc 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java @@ -45,6 +45,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -153,7 +155,7 @@ public final class ReconcileUtil { * @return list of safe synchronization steps with updates */ public static List> resolveAndDivideGroupDiffs(final NodeId nodeId, - final Map installedGroupsArg, + final Map installedGroupsArg, final Collection pendingGroups) { return resolveAndDivideGroupDiffs(nodeId, installedGroupsArg, pendingGroups, true); } @@ -168,16 +170,16 @@ public final class ReconcileUtil { * @return list of safe synchronization steps */ public static List> resolveAndDivideGroupDiffs(final NodeId nodeId, - final Map installedGroupsArg, + final Map installedGroupsArg, final Collection pendingGroups, final boolean gatherUpdates) { - final Map installedGroups = new HashMap<>(installedGroupsArg); + final Map installedGroups = new HashMap<>(installedGroupsArg); final List> plan = new ArrayList<>(); while (!Iterables.isEmpty(pendingGroups)) { final ItemSyncBox stepPlan = new ItemSyncBox<>(); final Iterator iterator = pendingGroups.iterator(); - final Map installIncrement = new HashMap<>(); + final Map installIncrement = new HashMap<>(); while (iterator.hasNext()) { final Group group = iterator.next(); @@ -221,14 +223,14 @@ public final class ReconcileUtil { return plan; } - public static boolean checkGroupPrecondition(final Set installedGroupIds, final Group pendingGroup) { + public static boolean checkGroupPrecondition(final Set installedGroupIds, final Group pendingGroup) { boolean okToInstall = true; // check each bucket in the pending group for (Bucket bucket : pendingGroup.getBuckets().getBucket()) { for (Action action : bucket.getAction()) { // if the output action is a group if (GroupActionCase.class.equals(action.getAction().implementedInterface())) { - Long groupId = ((GroupActionCase) action.getAction()).getGroupAction().getGroupId(); + Uint32 groupId = ((GroupActionCase) action.getAction()).getGroupAction().getGroupId(); // see if that output group is installed if (!installedGroupIds.contains(groupId)) { // if not installed, we have missing dependencies and cannot install this pending group @@ -327,7 +329,7 @@ public final class ReconcileUtil { * @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps */ public static Map> resolveFlowDiffsInAllTables(final NodeId nodeId, - final Map tableOperationalMap, final List
tablesConfigured, + final Map tableOperationalMap, final List
tablesConfigured, final boolean gatherUpdates) { LOG.trace("resolving flows in tables for {}", nodeId.getValue()); final Map> tableFlowSyncBoxes = new HashMap<>(); diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java index 56334b69bd..c6f6a826a0 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java @@ -61,6 +61,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Test for {@link SyncPlanPushStrategyFlatBatchImpl}. @@ -289,14 +290,14 @@ public class SyncPlanPushStrategyFlatBatchImplTest { new BatchBuilder().setBatchOrder(9).build(), new BatchBuilder().setBatchOrder(15).build() ); - final Map, Batch> rangeBatchMap = + final Map, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBatchesToRanges(inputBatchBag, 42); Assert.assertEquals(4, rangeBatchMap.size()); int idx = 0; final int[] lower = new int[]{0, 5, 9, 15}; final int[] upper = new int[]{4, 8, 14, 41}; - for (Map.Entry, Batch> rangeBatchEntry : rangeBatchMap.entrySet()) { + for (Map.Entry, Batch> rangeBatchEntry : rangeBatchMap.entrySet()) { Assert.assertEquals(lower[idx], rangeBatchEntry.getKey().lowerEndpoint().intValue()); Assert.assertEquals(upper[idx], rangeBatchEntry.getKey().upperEndpoint().intValue()); Assert.assertSame(inputBatchBag.get(idx), rangeBatchEntry.getValue()); diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java index e3f48bc6e9..c029b7a99f 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowplugin.applications.frsync.util; import com.google.common.base.Splitter; +import com.google.common.collect.Maps; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; @@ -54,6 +55,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link ReconcileUtil}. @@ -96,10 +98,7 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs1() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); - installedGroups.put(2L, createGroup(2L)); - installedGroups.put(3L, createGroup(3L)); + final Map installedGroups = createGroups(1, 2, 3); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroup(2L)); @@ -122,8 +121,7 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs2() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); + final Map installedGroups = createGroups(1); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroup(2L)); @@ -156,9 +154,9 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs3() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); - installedGroups.put(2L, createGroupWithPreconditions(2L, 1L)); + final Map installedGroups = new HashMap<>(); + installedGroups.put(Uint32.ONE, createGroup(1L)); + installedGroups.put(Uint32.valueOf(2), createGroupWithPreconditions(2L, 1L)); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroup(1L)); @@ -175,9 +173,7 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs4() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); - installedGroups.put(2L, createGroup(2L)); + final Map installedGroups = createGroups(1, 2); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroupWithPreconditions(1L, 2L)); @@ -200,9 +196,7 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs5() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); - installedGroups.put(2L, createGroup(2L)); + final Map installedGroups = createGroups(1, 2); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroupWithPreconditions(1L, 2L)); @@ -219,9 +213,7 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs_negative1() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); - installedGroups.put(2L, createGroup(2L)); + final Map installedGroups = createGroups(1, 2); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroupWithPreconditions(3L, 4L)); @@ -236,9 +228,7 @@ public class ReconcileUtilTest { */ @Test public void testResolveAndDivideGroupDiffs_negative2() { - final Map installedGroups = new HashMap<>(); - installedGroups.put(1L, createGroup(1L)); - installedGroups.put(2L, createGroup(2L)); + final Map installedGroups = createGroups(1, 2); final List pendingGroups = new ArrayList<>(); pendingGroups.add(createGroupWithPreconditions(1L, 3L)); @@ -250,7 +240,7 @@ public class ReconcileUtilTest { @Test public void testCheckGroupPrecondition() { - final Set installedGroups = new HashSet<>(Arrays.asList(new Long[]{1L, 2L})); + final Set installedGroups = new HashSet<>(Arrays.asList(Uint32.ONE, Uint32.valueOf(2))); final Group pendingGroup1 = createGroupWithPreconditions(3L, 2L, 4L); Assert.assertFalse(ReconcileUtil.checkGroupPrecondition(installedGroups, pendingGroup1)); @@ -262,7 +252,7 @@ public class ReconcileUtilTest { Assert.assertTrue(ReconcileUtil.checkGroupPrecondition(installedGroups, pendingGroup3)); } - private Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) { + private static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) { final List actionBag = new ArrayList<>(); for (long groupIdPrecondition : requiredId) { final GroupAction groupAction = new GroupActionBuilder() @@ -290,7 +280,15 @@ public class ReconcileUtilTest { .build(); } - private Group createGroup(final long groupIdValue) { + private static Map createGroups(long... groupIds) { + final Map ret = Maps.newHashMapWithExpectedSize(groupIds.length); + for (long groupId : groupIds) { + ret.put(Uint32.valueOf(groupId), createGroup(groupId)); + } + return ret; + } + + private static Group createGroup(final long groupIdValue) { final Buckets buckets = new BucketsBuilder() .setBucket(Collections.emptyList()) .build(); diff --git a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeaker.java b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeaker.java index 446c9b984c..cb8d107898 100644 --- a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeaker.java +++ b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeaker.java @@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Tr import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.config.rev160512.LldpSpeakerConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.OperStatus; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -162,7 +163,7 @@ public class LLDPSpeaker implements NodeConnectorEventsObserver, Runnable, AutoC return; } MacAddress srcMacAddress = flowConnector.getHardwareAddress(); - Long outputPortNo = flowConnector.getPortNumber().getUint32(); + Uint32 outputPortNo = flowConnector.getPortNumber().getUint32(); // No need to send LLDP frames on local ports if (outputPortNo == null) { diff --git a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java index 6ca6b55fe6..91c8743639 100644 --- a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java +++ b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java @@ -21,6 +21,7 @@ import org.opendaylight.openflowplugin.libraries.liblldp.PacketException; 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; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +38,7 @@ public final class LLDPUtil { @Nonnull static byte[] buildLldpFrame(final NodeId nodeId, final NodeConnectorId nodeConnectorId, final MacAddress src, - final Long outPortNo, final MacAddress destinationAddress) + final Uint32 outPortNo, final MacAddress destinationAddress) throws PacketException { // Create discovery pkt LLDP discoveryPkt = new LLDP(); @@ -52,7 +53,7 @@ public final class LLDPUtil { discoveryPkt.setChassisId(chassisIdTlv); // Create LLDP PortID TL - String hexString = Long.toHexString(outPortNo); + String hexString = Long.toHexString(outPortNo.toJava()); byte[] pidValue = LLDPTLV.createPortIDTLVValue(hexString); LLDPTLV portIdTlv = new LLDPTLV(); portIdTlv.setType(LLDPTLV.TLVType.PortID.getValue()).setLength((short) pidValue.length).setValue(pidValue); @@ -103,7 +104,7 @@ public final class LLDPUtil { @Nonnull static byte[] buildLldpFrame(final NodeId nodeId, final NodeConnectorId nodeConnectorId, - final MacAddress srcMacAddress, final Long outputPortNo) throws PacketException { + final MacAddress srcMacAddress, final Uint32 outputPortNo) throws PacketException { return buildLldpFrame(nodeId, nodeConnectorId, srcMacAddress, outputPortNo, null); } diff --git a/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeakerTest.java b/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeakerTest.java index 0b1c0fc199..86c8776188 100644 --- a/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeakerTest.java +++ b/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeakerTest.java @@ -44,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.OperStatus; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Tests for {@link LLDPSpeaker}. @@ -71,7 +72,7 @@ public class LLDPSpeakerTest { @Before public void setUp() throws NoSuchAlgorithmException, PacketException { byte[] lldpFrame = LLDPUtil.buildLldpFrame(new NodeId("openflow:1"), - new NodeConnectorId("openflow:1:1"), MAC_ADDRESS, 1L); + new NodeConnectorId("openflow:1:1"), MAC_ADDRESS, Uint32.ONE); packetInput = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(ID)) .setNode(new NodeRef(ID.firstIdentifierOf(Node.class))).setPayload(lldpFrame).build(); diff --git a/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/TestUtils.java b/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/TestUtils.java index a36bdb5010..bf6e18e06c 100644 --- a/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/TestUtils.java +++ b/applications/lldp-speaker/src/test/java/org/opendaylight/openflowplugin/applications/lldpspeaker/TestUtils.java @@ -21,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Helper methods that are used by multiple tests. @@ -52,7 +53,7 @@ public final class TestUtils { MacAddress mac, long port) { return new FlowCapableNodeConnectorBuilder() .setHardwareAddress(mac) - .setPortNumber(new PortNumberUni(port)) + .setPortNumber(new PortNumberUni(Uint32.valueOf(port))) .setState(new StateBuilder().setLinkDown(linkDown).build()) .setConfiguration(new PortConfig(false, false, false, adminDown)); } diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java index accd5362c3..76eb10afc3 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for @@ -48,8 +49,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class FlowNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; - private static final Short FLOW_TABLE_ID = 111; - private static final Short UPDATED_FLOW_TABLE_ID = 100; + private static final Uint8 FLOW_TABLE_ID = Uint8.valueOf(111); + private static final Uint8 UPDATED_FLOW_TABLE_ID = Uint8.valueOf(100); private static final String FLOW_ID = "test-flow-111"; private static final String UPDATED_FLOW_ID = "test-flow-100"; private FlowNotificationSupplierImpl notifSupplierImpl; diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java index 154c1302b2..e0d5c500b0 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link GroupNotificationSupplierImpl}. @@ -45,8 +46,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class GroupNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; - private static final Long GROUP_ID = 111L; - private static final Long UPDATED_GROUP_ID = 100L; + private static final Uint32 GROUP_ID = Uint32.valueOf(111); + private static final Uint32 UPDATED_GROUP_ID = Uint32.valueOf(100); private GroupNotificationSupplierImpl notifSupplierImpl; private NotificationPublishService notifProviderService; diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java index e786f99eb9..981cb1284c 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Met import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for @@ -46,8 +47,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class MeterNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openfow:111"; - private static final Long METER_ID = 111L; - private static final Long UPDATED_METER_ID = 100L; + private static final Uint32 METER_ID = Uint32.valueOf(111); + private static final Uint32 UPDATED_METER_ID = Uint32.valueOf(100); private MeterNotificationSupplierImpl notifSupplierImpl; private NotificationPublishService notifProviderService; diff --git a/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java b/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java index 18baa99d4f..e0059b1b40 100644 --- a/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java +++ b/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.Set import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Test for {@link DefaultConfigPusher}. @@ -77,7 +78,7 @@ public class DefaultConfigPusherTest { Mockito.verify(nodeConfigService).setConfig(setConfigInputCaptor.capture()); final SetConfigInput captured = setConfigInputCaptor.getValue(); Assert.assertEquals(SwitchConfigFlag.FRAGNORMAL.toString(), captured.getFlag()); - Assert.assertEquals(OFConstants.OFPCML_NO_BUFFER, captured.getMissSearchLength()); + Assert.assertEquals(Uint16.valueOf(OFConstants.OFPCML_NO_BUFFER), captured.getMissSearchLength()); Assert.assertEquals(NODE_IID, captured.getNode().getValue()); } diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java index ad2d12166b..31daf4235f 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java @@ -59,6 +59,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,7 +91,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo @Override public ListenableFuture> reconcile(ReconcileInput input) { boolean reconcileAllNodes = input.isReconcileAllNodes(); - List inputNodes = input.getNodes(); + List inputNodes = input.getNodes(); if (inputNodes == null) { inputNodes = new ArrayList<>(); } @@ -104,7 +105,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo SettableFuture> result = SettableFuture.create(); List nodeList = getAllNodes(); List nodesToReconcile = reconcileAllNodes ? nodeList : - inputNodes.stream().distinct().map(BigInteger::longValue).collect(Collectors.toList()); + inputNodes.stream().distinct().map(Uint64::longValue).collect(Collectors.toList()); if (nodesToReconcile.size() > 0) { List unresolvedNodes = nodesToReconcile.stream().filter(node -> !nodeList.contains(node)).collect(Collectors.toList()); @@ -112,11 +113,11 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo return buildErrorResponse("Error executing command reconcile. " + "Node(s) not found: " + String.join(", ", unresolvedNodes.toString())); } - List inprogressNodes = new ArrayList<>(); + List inprogressNodes = new ArrayList<>(); nodesToReconcile.parallelStream().forEach(nodeId -> { Optional state = getReconciliationState(nodeId); if (state.isPresent() && state.get().getState().equals(INPROGRESS)) { - inprogressNodes.add(new BigInteger(String.valueOf(nodeId))); + inprogressNodes.add(Uint64.valueOf(nodeId)); } else { alarmAgent.raiseNodeReconciliationAlarm(nodeId); LOG.info("Executing reconciliation for node {}", nodeId); @@ -215,7 +216,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo if (isSuccess) { if (count.isPresent()) { - Long successCount = count.get().getSuccessCount(); + long successCount = count.get().getSuccessCount().toJava(); counterBuilder.setSuccessCount(++successCount); LOG.debug("Reconcile success count {} for the node: {} ", successCount, nodeId); } else { @@ -223,7 +224,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo } } else { if (count.isPresent()) { - Long failureCount = count.get().getFailureCount(); + long failureCount = count.get().getFailureCount().toJava(); counterBuilder.setFailureCount(++failureCount); LOG.debug("Reconcile failure count {} for the node: {} ", failureCount, nodeId); } else { diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java index 8d12e992ab..2268029001 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/Reconciliation.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.applications.southboundcli.cli; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Formatter; import java.util.List; @@ -24,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.ReconcileOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.ReconciliationService; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,9 +45,9 @@ public class Reconciliation extends OsgiCommandSupport { @Override protected Object doExecute() throws Exception { - List nodes = (nodeIds == null) + List nodes = nodeIds == null ? new ArrayList<>() - : nodeIds.stream().distinct().map(BigInteger::valueOf).collect(Collectors.toList()); + : nodeIds.stream().distinct().map(Uint64::valueOf).collect(Collectors.toList()); LOG.debug("Triggering reconciliation for nodes {}", nodes); ReconcileInput rpcInput = new ReconcileInputBuilder().setNodes(nodes) .setReconcileAllNodes(reconcileAllNodes).build(); @@ -67,14 +67,14 @@ public class Reconciliation extends OsgiCommandSupport { } private void printInProgressNodes(ReconcileOutput reconcileOutput) { - List inprogressNodes = reconcileOutput.getInprogressNodes(); + List inprogressNodes = reconcileOutput.getInprogressNodes(); if (inprogressNodes.size() > 0) { StringBuilder stringBuilder = new StringBuilder(); final Formatter formatter = new Formatter(stringBuilder); session.getConsole().println(getReconcileHeaderOutput()); session.getConsole().println("----------------------------------------------------"); - for (BigInteger node : inprogressNodes) { - session.getConsole().println(formatter.format("%-15s %n",node).toString()); + for (Uint64 node : inprogressNodes) { + session.getConsole().println(formatter.format("%-15s %n", node).toString()); stringBuilder.setLength(0); } } diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java index a2f62446a1..5d4bdbfe26 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.applications.topology.lldp; import com.google.common.annotations.VisibleForTesting; - import java.util.Collection; import java.util.Date; import java.util.Map; @@ -75,7 +74,7 @@ public class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeCha @Reference final ConfigurationService configurationService, @Reference final EntityOwnershipService entityOwnershipService, @Reference final DataBroker dataBroker) { - this.linkExpirationTime = topologyLldpDiscoveryConfig.getTopologyLldpExpirationInterval().getValue(); + this.linkExpirationTime = topologyLldpDiscoveryConfig.getTopologyLldpExpirationInterval().getValue().toJava(); this.notificationService = notificationService; this.configurationServiceRegistration = configurationService.registerListener(this); this.eos = entityOwnershipService; @@ -89,7 +88,8 @@ public class LLDPLinkAger implements ConfigurationListener, ClusteredDataTreeCha LOG.error("DataTreeChangeListeners registration failed:", e); throw new IllegalStateException("LLDPLinkAger startup failed!", e); } - timer.schedule(new LLDPAgingTask(), 0, topologyLldpDiscoveryConfig.getTopologyLldpInterval().getValue()); + timer.schedule(new LLDPAgingTask(), 0, + topologyLldpDiscoveryConfig.getTopologyLldpInterval().getValue().toJava()); } public void put(LinkDiscovered link) { diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java index 0490ea01a2..ade88aa5b5 100644 --- a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java +++ b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.eric.codec.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.eric.api.EricConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -36,8 +35,8 @@ public class Icmpv6NDOptionsTypeCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - Icmpv6NdOptionsTypeCaseValue caseValue = ((Icmpv6NdOptionsTypeCaseValue) input.getMatchEntryValue()); - outBuffer.writeByte(caseValue.getIcmpv6NdOptionsTypeValues().getIcmpv6NdOptionsType()); + Icmpv6NdOptionsTypeCaseValue caseValue = (Icmpv6NdOptionsTypeCaseValue) input.getMatchEntryValue(); + outBuffer.writeByte(caseValue.getIcmpv6NdOptionsTypeValues().getIcmpv6NdOptionsType().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira-api/src/main/java/org/opendaylight/openflowjava/nx/api/NiciraConstants.java b/extension/openflowjava-extension-nicira-api/src/main/java/org/opendaylight/openflowjava/nx/api/NiciraConstants.java index 5ed241446a..61c4eb14c9 100644 --- a/extension/openflowjava-extension-nicira-api/src/main/java/org/opendaylight/openflowjava/nx/api/NiciraConstants.java +++ b/extension/openflowjava-extension-nicira-api/src/main/java/org/opendaylight/openflowjava/nx/api/NiciraConstants.java @@ -7,11 +7,13 @@ */ package org.opendaylight.openflowjava.nx.api; +import org.opendaylight.yangtools.yang.common.Uint32; + public final class NiciraConstants { - public static final Long NX_VENDOR_ID = 0x00002320L; + public static final Uint32 NX_VENDOR_ID = Uint32.valueOf(0x00002320L).intern(); - public static final Long NX_NSH_VENDOR_ID = 0x005AD650L; + public static final Uint32 NX_NSH_VENDOR_ID = Uint32.valueOf(0x005AD650L).intern(); private NiciraConstants() { diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionCodec.java index 2506653490..df2a588e40 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionCodec.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; 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.ExperimenterId; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Base class for an action codec. @@ -71,7 +72,7 @@ public abstract class AbstractActionCodec implements OFSerializer, OFDes outBuffer.setShort(startIndex + EncodeConstants.SIZE_OF_SHORT_IN_BYTES, outBuffer.writerIndex() - startIndex); } - protected static void writeNxmHeader(final BigInteger value, final ByteBuf outBuffer) { + protected static void writeNxmHeader(final Uint64 value, final ByteBuf outBuffer) { if (NxmHeader.isExperimenter(value)) { outBuffer.writeLong(value.longValue()); } else { diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java index ad9e7427cd..5aa922d409 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java @@ -26,9 +26,9 @@ public class ActionDeserializer implements OFDeserializer, DeserializerR private static final Logger LOG = LoggerFactory.getLogger(ActionDeserializer.class); public static final ExperimenterActionDeserializerKey OF13_DESERIALIZER_KEY = new ExperimenterActionDeserializerKey( - EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); + EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID.toJava()); public static final ExperimenterActionDeserializerKey OF10_DESERIALIZER_KEY = new ExperimenterActionDeserializerKey( - EncodeConstants.OF10_VERSION_ID, NiciraConstants.NX_VENDOR_ID); + EncodeConstants.OF10_VERSION_ID, NiciraConstants.NX_VENDOR_ID.toJava()); private final short version; private DeserializerRegistry deserializerRegistry; @@ -50,7 +50,7 @@ public class ActionDeserializer implements OFDeserializer, DeserializerR // size of length message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); long experimenterId = message.readUnsignedInt(); - if (NiciraConstants.NX_VENDOR_ID != experimenterId) { + if (NiciraConstants.NX_VENDOR_ID.toJava() != experimenterId) { throw new IllegalStateException("Experimenter ID is not Nicira vendor id but is " + experimenterId); } int subtype = message.readUnsignedShort(); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java index 39d7dfa1a4..fb817af1fb 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java @@ -143,10 +143,10 @@ public class ConntrackCodec extends AbstractActionCodec { } } if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMIN.getIntValue())) { - outBuffer.writeShort(natAction.getPortMin()); + outBuffer.writeShort(natAction.getPortMin().toJava()); } if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMAX.getIntValue())) { - outBuffer.writeShort(natAction.getPortMax()); + outBuffer.writeShort(natAction.getPortMax().toJava()); } outBuffer.writeZero(pad); } else if (ctActions.getOfpactActions() instanceof NxActionCtMarkCase) { diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java index aa4f07afbd..f02835afb6 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java @@ -48,7 +48,6 @@ public class DecapCodec extends AbstractActionCodec { // add padding outBuffer.writeZero(PADDING); ActionDecap actionDecap = (ActionDecap) input.getActionChoice(); - Long packetType = actionDecap.getNxActionDecap().getPacketType(); - outBuffer.writeInt(packetType.intValue()); + outBuffer.writeInt(actionDecap.getNxActionDecap().getPacketType().intValue()); } } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java index b2580b1d18..68f87e0e89 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; import io.netty.buffer.ByteBuf; @@ -47,7 +46,6 @@ public class EncapCodec extends AbstractActionCodec { serializeHeader(LENGTH, NXAST_ENCAP_SUBTYPE, outBuffer); outBuffer.writeShort(HEADER_SIZE_NOT_SPECIFIED); ActionEncap actionEncap = (ActionEncap) input.getActionChoice(); - Long packetType = actionEncap.getNxActionEncap().getPacketType(); - outBuffer.writeInt(packetType.intValue()); + outBuffer.writeInt(actionEncap.getNxActionEncap().getPacketType().intValue()); } } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java index 03cb99afe4..d2a7b0d111 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java @@ -133,23 +133,23 @@ public final class LearnCodecUtil { } private static void toFlowModSpecHeader(FlowModOutputToPort flowModSpec, ByteBuf outBuffer) { - serializeFlowModSpecHeader(0,2,(short)(int)flowModSpec.getFlowModNumBits(), outBuffer); + serializeFlowModSpecHeader(0,2,(short)flowModSpec.getFlowModNumBits().toJava(), outBuffer); } private static void toFlowModSpecHeader(FlowModCopyValueIntoField flowModSpec, ByteBuf outBuffer) { - serializeFlowModSpecHeader(1,1,(short)(int)flowModSpec.getFlowModNumBits(), outBuffer); + serializeFlowModSpecHeader(1,1,(short)flowModSpec.getFlowModNumBits().toJava(), outBuffer); } private static void toFlowModSpecHeader(FlowModCopyFieldIntoField flowModSpec, ByteBuf outBuffer) { - serializeFlowModSpecHeader(0,1,(short)(int)flowModSpec.getFlowModNumBits(), outBuffer); + serializeFlowModSpecHeader(0,1,(short)flowModSpec.getFlowModNumBits().toJava(), outBuffer); } private static void toFlowModSpecHeader(FlowModAddMatchFromValue flowModSpec, ByteBuf outBuffer) { - serializeFlowModSpecHeader(1,0,(short)(int)flowModSpec.getFlowModNumBits(), outBuffer); + serializeFlowModSpecHeader(1,0,(short)flowModSpec.getFlowModNumBits().toJava(), outBuffer); } private static void toFlowModSpecHeader(FlowModAddMatchFromField flowModSpec, ByteBuf outBuffer) { - serializeFlowModSpecHeader(0,0,(short)(int)flowModSpec.getFlowModNumBits(), outBuffer); + serializeFlowModSpecHeader(0,0,(short)flowModSpec.getFlowModNumBits().toJava(), outBuffer); } private static void serializeFlowModSpecHeader(int src, int dst, short bitNum, ByteBuf outBuffer) { diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoad2Codec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoad2Codec.java index 882e3e7916..3cb7956b36 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoad2Codec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoad2Codec.java @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad2Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.load2.grouping.NxActionRegLoad2; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.load2.grouping.NxActionRegLoad2Builder; +import org.opendaylight.yangtools.yang.common.Uint32; public class RegLoad2Codec extends AbstractActionCodec @@ -63,7 +64,7 @@ public class RegLoad2Codec long expId = message.getUnsignedInt(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + EncodeConstants.SIZE_OF_BYTE_IN_BYTES * 2); - key.setExperimenterId(expId); + key.setExperimenterId(Uint32.valueOf(expId)); } OFDeserializer matchDeserializer = deserializerRegistry.getDeserializer(key); MatchEntry matchEntry = matchDeserializer.deserialize(message); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java index fc4d2f25c9..7f6fce66c5 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; import io.netty.buffer.ByteBuf; @@ -32,7 +31,7 @@ public class RegLoadCodec extends AbstractActionCodec { public void serialize(final Action input, final ByteBuf outBuffer) { ActionRegLoad actionRegLoad = (ActionRegLoad) input.getActionChoice(); serializeHeader(LENGTH, SUBTYPE, outBuffer); - outBuffer.writeShort(actionRegLoad.getNxActionRegLoad().getOfsNbits()); + outBuffer.writeShort(actionRegLoad.getNxActionRegLoad().getOfsNbits().toJava()); outBuffer.writeInt(actionRegLoad.getNxActionRegLoad().getDst().intValue()); outBuffer.writeLong(actionRegLoad.getNxActionRegLoad().getValue().longValue()); } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java index 48591a6c2d..d97ffb80bd 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; import io.netty.buffer.ByteBuf; @@ -31,9 +30,9 @@ public class RegMoveCodec extends AbstractActionCodec { ActionRegMove actionRegMove = (ActionRegMove) input.getActionChoice(); final int startIndex = outBuffer.writerIndex(); serializeHeader(EncodeConstants.EMPTY_LENGTH, SUBTYPE, outBuffer); - outBuffer.writeShort(actionRegMove.getNxActionRegMove().getNBits()); - outBuffer.writeShort(actionRegMove.getNxActionRegMove().getSrcOfs()); - outBuffer.writeShort(actionRegMove.getNxActionRegMove().getDstOfs()); + outBuffer.writeShort(actionRegMove.getNxActionRegMove().getNBits().toJava()); + outBuffer.writeShort(actionRegMove.getNxActionRegMove().getSrcOfs().toJava()); + outBuffer.writeShort(actionRegMove.getNxActionRegMove().getDstOfs().toJava()); writeNxmHeader(actionRegMove.getNxActionRegMove().getSrc(), outBuffer); writeNxmHeader(actionRegMove.getNxActionRegMove().getDst(), outBuffer); writePaddingAndSetLength(outBuffer, startIndex); @@ -55,6 +54,4 @@ public class RegMoveCodec extends AbstractActionCodec { actionBuilder.setActionChoice(actionRegMoveBuilder.build()); return actionBuilder.build(); } - - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodec.java index 43e117601f..2b22420a2c 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodec.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -25,11 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; +import org.opendaylight.yangtools.yang.common.Uint32; public abstract class AbstractExperimenterMatchCodec extends AbstractMatchCodec { protected static MatchEntrySerializerKey createSerializerKey( - short version, long expId, Class oxmField) { + short version, Uint32 expId, Class oxmField) { MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( version, ExperimenterClass.class, oxmField); key.setExperimenterId(expId); @@ -37,7 +39,7 @@ public abstract class AbstractExperimenterMatchCodec extends AbstractMatchCodec } protected static MatchEntryDeserializerKey createDeserializerKey( - short version, long expId, int fieldCode) { + short version, Uint32 expId, int fieldCode) { MatchEntryDeserializerKey key = new MatchEntryDeserializerKey( version, OxmMatchConstants.EXPERIMENTER_CLASS, fieldCode); key.setExperimenterId(expId); @@ -99,7 +101,7 @@ public abstract class AbstractExperimenterMatchCodec extends AbstractMatchCodec getNxmFieldCode(), hasMask, EncodeConstants.SIZE_OF_INT_IN_BYTES + (hasMask ? getValueLength() * 2 : getValueLength()), - getExperimenterId()); + getExperimenterId().longValue()); } @Override @@ -112,6 +114,6 @@ public abstract class AbstractExperimenterMatchCodec extends AbstractMatchCodec return OxmMatchConstants.EXPERIMENTER_CLASS; } - protected abstract long getExperimenterId(); + protected abstract @NonNull Uint32 getExperimenterId(); } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java index 527475ec9d..8b571edd8e 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -14,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public abstract class AbstractNshcCodec extends AbstractExperimenterMatchCodec { @@ -36,7 +36,7 @@ public abstract class AbstractNshcCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } @@ -44,5 +44,4 @@ public abstract class AbstractNshcCodec extends AbstractExperimenterMatchCodec { public int getValueLength() { return VALUE_LENGTH; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java index 0c24545a80..3f4acbb425 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java @@ -37,7 +37,7 @@ public class ArpOpCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); ArpOpCaseValue arpOpCase = ((ArpOpCaseValue) input.getMatchEntryValue()); - outBuffer.writeShort(arpOpCase.getArpOpValues().getValue()); + outBuffer.writeShort(arpOpCase.getArpOpValues().getValue().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java index 5fc6b16ece..0e4dd1b386 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java @@ -36,7 +36,7 @@ public class CtTpDstCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); CtTpDstCaseValue ctTpSrcCase = (CtTpDstCaseValue)input.getMatchEntryValue(); - outBuffer.writeShort(ctTpSrcCase.getCtTpDstValues().getCtTpDst()); + outBuffer.writeShort(ctTpSrcCase.getCtTpDstValues().getCtTpDst().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java index 7517a38097..3e710fb54c 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java @@ -36,7 +36,7 @@ public class CtTpSrcCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); CtTpSrcCaseValue ctTpSrcCase = (CtTpSrcCaseValue)input.getMatchEntryValue(); - outBuffer.writeShort(ctTpSrcCase.getCtTpSrcValues().getCtTpSrc()); + outBuffer.writeShort(ctTpSrcCase.getCtTpSrcValues().getCtTpSrc().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java index 4ed771218e..729d8d22db 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java @@ -41,7 +41,7 @@ public class CtZoneCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); CtZoneCaseValue ctZoneCase = (CtZoneCaseValue) input.getMatchEntryValue(); - outBuffer.writeShort(ctZoneCase.getCtZoneValues().getCtZone()); + outBuffer.writeShort(ctZoneCase.getCtZoneValues().getCtZone().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java index 38c5676b63..eb6d0dd615 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java @@ -37,7 +37,7 @@ public class EthTypeCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); EthTypeCaseValue value = (EthTypeCaseValue) input.getMatchEntryValue(); - outBuffer.writeShort(value.getEthTypeValues().getValue()); + outBuffer.writeShort(value.getEthTypeValues().getValue().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java index 19a2ab9939..c405cbfd22 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java @@ -50,7 +50,7 @@ public class IcmpTypeCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); IcmpTypeCaseValue icmpTypeValue = (IcmpTypeCaseValue) input.getMatchEntryValue(); - outBuffer.writeByte(icmpTypeValue.getIcmpTypeValues().getValue()); + outBuffer.writeByte(icmpTypeValue.getIcmpTypeValues().getValue().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java index 1ff96ffd2d..e5b9483e99 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java @@ -39,7 +39,7 @@ public class InPortCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); OfInPortCaseValue value = (OfInPortCaseValue) input.getMatchEntryValue(); - outBuffer.writeInt(value.getNxmOfInPortValues().getValue()); + outBuffer.writeInt(value.getNxmOfInPortValues().getValue().toJava()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java index e0fac69af4..719b70141c 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java @@ -21,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NshFlagsCodec extends AbstractExperimenterMatchCodec { @@ -61,7 +62,7 @@ public class NshFlagsCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } @@ -69,9 +70,9 @@ public class NshFlagsCodec extends AbstractExperimenterMatchCodec { protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) { NshFlagsCaseValue nshFlagsCaseValue = (NshFlagsCaseValue) value; NshFlagsValues nshFlagsValues = nshFlagsCaseValue.getNshFlagsValues(); - outBuffer.writeByte(nshFlagsValues.getNshFlags()); + outBuffer.writeByte(nshFlagsValues.getNshFlags().toJava()); if (hasMask) { - outBuffer.writeByte(nshFlagsValues.getMask()); + outBuffer.writeByte(nshFlagsValues.getMask().toJava()); } } } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java index 0d916dc7e9..2471846e18 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java @@ -21,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NshMdtypeCodec extends AbstractExperimenterMatchCodec { @@ -41,7 +42,7 @@ public class NshMdtypeCodec extends AbstractExperimenterMatchCodec { protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) { NshMdtypeCaseValue nshMdtypeCaseValue = (NshMdtypeCaseValue) value; NshMdtypeValues nshMdtypeValues = nshMdtypeCaseValue.getNshMdtypeValues(); - outBuffer.writeByte(nshMdtypeValues.getValue()); + outBuffer.writeByte(nshMdtypeValues.getValue().toJava()); } @Override @@ -57,7 +58,7 @@ public class NshMdtypeCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java index bcc3cced18..c21df1d996 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -21,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NshNpCodec extends AbstractExperimenterMatchCodec { @@ -41,7 +41,7 @@ public class NshNpCodec extends AbstractExperimenterMatchCodec { protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) { NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) value; NshNpValues nshNpValues = nshNpCaseValue.getNshNpValues(); - outBuffer.writeByte(nshNpValues.getValue()); + outBuffer.writeByte(nshNpValues.getValue().toJava()); } @Override @@ -57,7 +57,7 @@ public class NshNpCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodec.java index dfeb7a8295..749fa38a25 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -21,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NshTtlCodec extends AbstractExperimenterMatchCodec { @@ -41,9 +41,9 @@ public class NshTtlCodec extends AbstractExperimenterMatchCodec { protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) { NshTtlCaseValue nshTtlCaseValue = (NshTtlCaseValue) value; NshTtlValues nshTtlValues = nshTtlCaseValue.getNshTtlValues(); - outBuffer.writeByte(nshTtlValues.getNshTtl()); + outBuffer.writeByte(nshTtlValues.getNshTtl().toJava()); if (hasMask) { - outBuffer.writeByte(nshTtlValues.getMask()); + outBuffer.writeByte(nshTtlValues.getMask().toJava()); } } @@ -56,7 +56,7 @@ public class NshTtlCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java index 3673d2fb95..df047cc05e 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -21,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NsiCodec extends AbstractExperimenterMatchCodec { @@ -38,17 +38,17 @@ public class NsiCodec extends AbstractExperimenterMatchCodec { NXM_FIELD_CODE); @Override - protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) { + protected void serializeValue(final NxExpMatchEntryValue value, final boolean hasMask, final ByteBuf outBuffer) { NsiCaseValue nsiCaseValue = (NsiCaseValue) value; NsiValues nsiValues = nsiCaseValue.getNsiValues(); - outBuffer.writeByte(nsiValues.getNsi()); + outBuffer.writeByte(nsiValues.getNsi().toJava()); if (hasMask) { - outBuffer.writeByte(nsiValues.getMask()); + outBuffer.writeByte(nsiValues.getMask().toJava()); } } @Override - protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) { + protected NxExpMatchEntryValue deserializeValue(final ByteBuf message, final boolean hasMask) { Short value = message.readUnsignedByte(); Short mask = hasMask ? message.readUnsignedByte() : null; NsiValues nsiValues = new NsiValuesBuilder().setNsi(value).setMask(mask).build(); @@ -61,7 +61,7 @@ public class NsiCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java index 616a03ca74..ba7353cbf9 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -21,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NspCodec extends AbstractExperimenterMatchCodec { @@ -56,7 +56,7 @@ public class NspCodec extends AbstractExperimenterMatchCodec { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return NiciraConstants.NX_NSH_VENDOR_ID; } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java index c7619ff54f..3e91ba81c7 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java @@ -9,10 +9,10 @@ package org.opendaylight.openflowjava.nx.codec.match; import com.google.common.base.MoreObjects; import com.google.common.primitives.Ints; -import com.google.common.primitives.Longs; import java.math.BigInteger; import java.util.Objects; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Nxm header. @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; public class NxmHeader { // Full 4 or 8 byte header as big integer - private final BigInteger header; + private final Uint64 header; // Full 4 or 8 byte header as long private final long headerAsLong; // 4 byte class, field, length as long @@ -41,7 +41,7 @@ public class NxmHeader { * @param header the header as {@code BigInteger}. * @see NxmHeader#NxmHeader(long) */ - public NxmHeader(BigInteger header) { + public NxmHeader(Uint64 header) { this.headerAsLong = header.longValue(); if (isExperimenter(header)) { this.experimenterId = (int) this.headerAsLong; @@ -68,7 +68,7 @@ public class NxmHeader { * @param header the header as a {@code long}. */ public NxmHeader(long header) { - this(new BigInteger(1, Longs.toByteArray(header))); + this(Uint64.fromLongBits(header)); } /** @@ -104,10 +104,9 @@ public class NxmHeader { this.shortHeader = (long) oxmClass << 16 | nxmField << 9 | (hasMask ? 1 : 0) << 8 | length; this.experimenterId = experimenterId; if (isExperimenter()) { - this.header = BigInteger.valueOf(this.shortHeader) - .shiftLeft(32).add(BigInteger.valueOf(experimenterId)); + this.header = Uint64.fromLongBits((this.shortHeader << 32) + experimenterId); } else { - this.header = BigInteger.valueOf(this.shortHeader); + this.header = Uint64.valueOf(this.shortHeader); } this.headerAsLong = this.header.longValue(); } @@ -119,12 +118,12 @@ public class NxmHeader { } /** - * Returns the {@code BigInteger} representation of the header. + * Returns the {@code Uint64} representation of the header. * * @return the header. - * @see NxmHeader#NxmHeader(BigInteger) + * @see NxmHeader#NxmHeader(Uint64) */ - public BigInteger toBigInteger() { + public Uint64 toUint64() { return header; } @@ -162,8 +161,8 @@ public class NxmHeader { return oxmClass == EncodeConstants.EXPERIMENTER_VALUE; } - public static boolean isExperimenter(BigInteger bigInteger) { - return bigInteger.longValue() >>> 48 == EncodeConstants.EXPERIMENTER_VALUE; + public static boolean isExperimenter(Uint64 uint) { + return uint.longValue() >>> 48 == EncodeConstants.EXPERIMENTER_VALUE; } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java index da308c735b..4254304fa8 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -39,15 +38,15 @@ public class TcpDstCodec extends AbstractMatchCodec { EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); @Override - public void serialize(MatchEntry input, ByteBuf outBuffer) { + public void serialize(final MatchEntry input, final ByteBuf outBuffer) { serializeHeader(input, outBuffer); TcpDstCaseValue tcpDstCase = (TcpDstCaseValue) input.getMatchEntryValue(); - outBuffer.writeShort(tcpDstCase.getTcpDstValues().getPort().getValue()); - outBuffer.writeShort(tcpDstCase.getTcpDstValues().getMask()); + outBuffer.writeShort(tcpDstCase.getTcpDstValues().getPort().getValue().toJava()); + outBuffer.writeShort(tcpDstCase.getTcpDstValues().getMask().toJava()); } @Override - public MatchEntry deserialize(ByteBuf message) { + public MatchEntry deserialize(final ByteBuf message) { MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); matchEntryBuilder.setHasMask(true); int portNo = message.readUnsignedShort(); @@ -85,5 +84,4 @@ public class TcpDstCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm0Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java index eed1b71fcb..8914d71126 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -42,8 +41,8 @@ public class TcpSrcCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); TcpSrcCaseValue tcpSrcCase = (TcpSrcCaseValue) input.getMatchEntryValue(); - outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getPort().getValue()); - outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getMask()); + outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getPort().getValue().toJava()); + outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getMask().toJava()); } @Override @@ -85,5 +84,4 @@ public class TcpSrcCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm0Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java index e2eb5116b3..d84a12a89e 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java @@ -38,8 +38,7 @@ public class TunIdCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - BigInteger value = ((TunIdCaseValue) input.getMatchEntryValue()).getTunIdValues().getValue(); - outBuffer.writeLong(value.longValue()); + outBuffer.writeLong(((TunIdCaseValue) input.getMatchEntryValue()).getTunIdValues().getValue().longValue()); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java index 51ad42e18b..8174e18ee6 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -42,8 +41,8 @@ public class UdpDstCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); UdpDstCaseValue udpDstCase = (UdpDstCaseValue) input.getMatchEntryValue(); - outBuffer.writeShort(udpDstCase.getUdpDstValues().getPort().getValue()); - outBuffer.writeShort(udpDstCase.getUdpDstValues().getMask()); + outBuffer.writeShort(udpDstCase.getUdpDstValues().getPort().getValue().toJava()); + outBuffer.writeShort(udpDstCase.getUdpDstValues().getMask().toJava()); } @Override @@ -85,5 +84,4 @@ public class UdpDstCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm0Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java index 927a8d0f0a..21870f877d 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; import io.netty.buffer.ByteBuf; @@ -42,8 +41,8 @@ public class UdpSrcCodec extends AbstractMatchCodec { public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); UdpSrcCaseValue udpSrcCase = (UdpSrcCaseValue) input.getMatchEntryValue(); - outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getPort().getValue()); - outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getMask()); + outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getPort().getValue().toJava()); + outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getMask().toJava()); } @Override @@ -85,5 +84,4 @@ public class UdpSrcCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm0Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializerTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializerTest.java index efed7b7fc6..62f25d63bb 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializerTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializerTest.java @@ -25,6 +25,7 @@ import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class ActionDeserializerTest { @@ -46,7 +47,7 @@ public class ActionDeserializerTest { private static final short VERSION = 4; - private static final long EXPERIMENT_ID = NiciraConstants.NX_VENDOR_ID; + private static final Uint32 EXPERIMENT_ID = NiciraConstants.NX_VENDOR_ID; private static final byte SUBTYPE = 10; @Before @@ -54,8 +55,6 @@ public class ActionDeserializerTest { actionDeserializer = new ActionDeserializer(VERSION); buffer = ByteBufAllocator.DEFAULT.buffer(); providers = new LinkedList<>(); - - } /** @@ -93,7 +92,7 @@ public class ActionDeserializerTest { //size of length message.writeShort(13); //experimentId - message.writeInt((int)EXPERIMENT_ID); + message.writeInt(EXPERIMENT_ID.intValue()); //subtype message.writeShort(SUBTYPE); } diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2CodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2CodecTest.java index 88490fb8c4..a4f1d64e01 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2CodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2CodecTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; import static org.junit.Assert.assertEquals; @@ -25,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionOutputReg2; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionOutputReg2Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.output.reg2.grouping.NxActionOutputReg2Builder; +import org.opendaylight.yangtools.yang.common.Uint64; public class OutputReg2CodecTest { @@ -35,7 +35,7 @@ public class OutputReg2CodecTest { private static final int SRC = 2; private static final int MAX_LEN = 2; private static final long SRC_EXP = 0xFFFF000000000000L | SRC; - private static final BigInteger SRC_EXP_BIGINT = new BigInteger(1, Longs.toByteArray(SRC_EXP)); + private static final Uint64 SRC_EXP_BIGINT = Uint64.valueOf(new BigInteger(1, Longs.toByteArray(SRC_EXP))); private OutputReg2Codec outReg2Codec; private ByteBuf buffer; @@ -56,7 +56,7 @@ public class OutputReg2CodecTest { assertEquals(OFS_N_BITS, result.getNxActionOutputReg2().getNBits().shortValue()); assertEquals(MAX_LEN, result.getNxActionOutputReg2().getMaxLen().shortValue()); - assertEquals(BigInteger.valueOf(SRC), result.getNxActionOutputReg2().getSrc()); + assertEquals(Uint64.valueOf(SRC), result.getNxActionOutputReg2().getSrc()); assertFalse(buffer.isReadable()); } @@ -76,7 +76,7 @@ public class OutputReg2CodecTest { @Test public void serializeTest() { - Action action = createAction(BigInteger.valueOf(SRC)); + Action action = createAction(Uint64.valueOf(SRC)); outReg2Codec.serialize(action, buffer); //SerializeHeader part @@ -119,7 +119,7 @@ public class OutputReg2CodecTest { assertFalse(buffer.isReadable()); } - private Action createAction(BigInteger src) { + private Action createAction(final Uint64 src) { ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID); ActionBuilder actionBuilder = new ActionBuilder(); actionBuilder.setExperimenterId(experimenterId); @@ -136,7 +136,7 @@ public class OutputReg2CodecTest { return actionBuilder.build(); } - private void createBuffer(ByteBuf message, boolean withExpSrc) { + private void createBuffer(final ByteBuf message, final boolean withExpSrc) { message.writeShort(EncodeConstants.EXPERIMENTER_VALUE); message.writeShort(LENGTH); message.writeInt(NiciraConstants.NX_VENDOR_ID.intValue()); diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodecTest.java index 462f876372..eb9134c464 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodecTest.java @@ -24,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMove; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMoveBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.move.grouping.NxActionRegMoveBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; public class RegMoveCodecTest { private static final byte SUBTYPE = 6; @@ -32,9 +33,9 @@ public class RegMoveCodecTest { private static final int DST = 5; private static final long SRC_EXP = 0xFFFF000000000000L | SRC; private static final long DST_EXP = 0xFFFF000000000000L | DST; - private static final BigInteger SRC_EXP_BIGINT = new BigInteger(1, Longs.toByteArray(SRC_EXP)); - private static final BigInteger DST_EXP_BIGINT = new BigInteger(1, Longs.toByteArray(DST_EXP)); + private static final Uint64 SRC_EXP_BIGINT = Uint64.valueOf(new BigInteger(1, Longs.toByteArray(SRC_EXP))); + private static final Uint64 DST_EXP_BIGINT = Uint64.valueOf(new BigInteger(1, Longs.toByteArray(DST_EXP))); RegMoveCodec regMoveCodec; ByteBuf buffer; Action action; @@ -47,7 +48,7 @@ public class RegMoveCodecTest { @Test public void serializeTest() { - action = createAction(BigInteger.valueOf(SRC), BigInteger.valueOf(DST)); + action = createAction(Uint64.valueOf(SRC), Uint64.valueOf(DST)); regMoveCodec.serialize(action, buffer); @@ -67,7 +68,7 @@ public class RegMoveCodecTest { @Test public void serializeWithExperimenterSrcTest() { - action = createAction(SRC_EXP_BIGINT, BigInteger.valueOf(DST)); + action = createAction(SRC_EXP_BIGINT, Uint64.valueOf(DST)); regMoveCodec.serialize(action, buffer); @@ -154,7 +155,7 @@ public class RegMoveCodecTest { assertEquals(0, buffer.readableBytes()); } - private Action createAction(BigInteger src, BigInteger dst) { + private Action createAction(Uint64 src, Uint64 dst) { ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID); ActionBuilder actionBuilder = new ActionBuilder(); actionBuilder.setExperimenterId(experimenterId); diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodecTest.java index 5e5987be73..69a23487e8 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractExperimenterMatchCodecTest.java @@ -32,12 +32,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxExpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; +import org.opendaylight.yangtools.yang.common.Uint32; public class AbstractExperimenterMatchCodecTest { private static final int VALUE_LENGTH = 4; private static final int FIELD_CODE = 16; - private static final long EXPERIMENTER_ID = NiciraConstants.NX_NSH_VENDOR_ID; + private static final Uint32 EXPERIMENTER_ID = NiciraConstants.NX_NSH_VENDOR_ID; private ByteBuf buffer; private TestCodec testCodec; @@ -58,7 +59,7 @@ public class AbstractExperimenterMatchCodecTest { } @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return EXPERIMENTER_ID; } @@ -93,7 +94,7 @@ public class AbstractExperimenterMatchCodecTest { assertEquals(EncodeConstants.EXPERIMENTER_VALUE, buffer.readUnsignedShort()); assertEquals(FIELD_CODE << 1, buffer.readUnsignedByte()); assertEquals(EncodeConstants.SIZE_OF_INT_IN_BYTES + VALUE_LENGTH, buffer.readUnsignedByte()); - assertEquals(EXPERIMENTER_ID, buffer.readUnsignedInt()); + assertEquals(EXPERIMENTER_ID.longValue(), buffer.readUnsignedInt()); assertFalse(buffer.isReadable()); verify(testCodec).serializeValue(null, false, buffer); } @@ -107,7 +108,7 @@ public class AbstractExperimenterMatchCodecTest { assertEquals(EncodeConstants.EXPERIMENTER_VALUE, buffer.readUnsignedShort()); assertEquals(FIELD_CODE << 1 | 1, buffer.readUnsignedByte()); assertEquals(EncodeConstants.SIZE_OF_INT_IN_BYTES + (VALUE_LENGTH * 2), buffer.readUnsignedByte()); - assertEquals(EXPERIMENTER_ID, buffer.readUnsignedInt()); + assertEquals(EXPERIMENTER_ID.longValue(), buffer.readUnsignedInt()); assertFalse(buffer.isReadable()); verify(testCodec).serializeValue(null, true, buffer); } @@ -122,7 +123,7 @@ public class AbstractExperimenterMatchCodecTest { assertEquals(TestNxmField.class, matchEntry.getOxmMatchField()); assertEquals(false, matchEntry.isHasMask()); Experimenter experimenter = ((ExperimenterIdCase) matchEntry.getMatchEntryValue()).getExperimenter(); - assertEquals(EXPERIMENTER_ID, experimenter.getExperimenter().getValue().longValue()); + assertEquals(EXPERIMENTER_ID, experimenter.getExperimenter().getValue()); assertFalse(buffer.isReadable()); verify(testCodec).deserializeValue(buffer, false); } @@ -137,7 +138,7 @@ public class AbstractExperimenterMatchCodecTest { assertEquals(TestNxmField.class, matchEntry.getOxmMatchField()); assertEquals(true, matchEntry.isHasMask()); Experimenter experimenter = ((ExperimenterIdCase) matchEntry.getMatchEntryValue()).getExperimenter(); - assertEquals(EXPERIMENTER_ID, experimenter.getExperimenter().getValue().longValue()); + assertEquals(EXPERIMENTER_ID, experimenter.getExperimenter().getValue()); assertFalse(buffer.isReadable()); verify(testCodec).deserializeValue(buffer, true); } @@ -168,6 +169,6 @@ public class AbstractExperimenterMatchCodecTest { message.writeShort(OxmMatchConstants.EXPERIMENTER_CLASS); message.writeByte(fieldMask); message.writeByte(length); - message.writeInt((int) EXPERIMENTER_ID); + message.writeInt(EXPERIMENTER_ID.intValue()); } } \ No newline at end of file diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java index d38e06bf3c..9c8cd15295 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodecTest.java @@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshcCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class AbstractNshcCodecTest { @@ -74,7 +75,7 @@ public class AbstractNshcCodecTest { NxExpMatchEntryValue value = testCodec.deserializeValue(buffer, false); - assertEquals(NSHC_VALUE, ((NshcCaseValue) value).getNshc()); + assertEquals(Uint32.valueOf(NSHC_VALUE), ((NshcCaseValue) value).getNshc()); assertFalse(buffer.isReadable()); } @@ -84,17 +85,17 @@ public class AbstractNshcCodecTest { NxExpMatchEntryValue value = testCodec.deserializeValue(buffer, true); - assertEquals(NSHC_VALUE, ((NshcCaseValue) value).getNshc()); - assertEquals(NSHC_MASK, ((NshcCaseValue) value).getMask()); + assertEquals(Uint32.valueOf(NSHC_VALUE), ((NshcCaseValue) value).getNshc()); + assertEquals(Uint32.valueOf(NSHC_MASK), ((NshcCaseValue) value).getMask()); assertFalse(buffer.isReadable()); } - private NxExpMatchEntryValue createMatchEntryValue(Long value, Long mask) { + private NxExpMatchEntryValue createMatchEntryValue(final Long value, final Long mask) { return new NshcCaseValueBuilder().setNshc(value).setMask(mask).build(); } - private void writeBuffer(ByteBuf message, Long value, Long mask) { + private void writeBuffer(final ByteBuf message, final Long value, final Long mask) { message.writeInt(value.intValue()); if (mask != null) { message.writeInt(mask.intValue()); diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodecTest.java index d4a0ccce53..ca1fffc706 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodecTest.java @@ -20,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshFlagsCodecTest { @@ -62,7 +63,7 @@ public class NshFlagsCodecTest { NxExpMatchEntryValue value = nshFlagsCodec.deserializeValue(buffer, false); - assertEquals(FLAGS_VALUE, ((NshFlagsCaseValue) value).getNshFlagsValues().getNshFlags()); + assertEquals(Uint8.valueOf(FLAGS_VALUE), ((NshFlagsCaseValue) value).getNshFlagsValues().getNshFlags()); assertFalse(buffer.isReadable()); } @@ -72,8 +73,8 @@ public class NshFlagsCodecTest { NxExpMatchEntryValue value = nshFlagsCodec.deserializeValue(buffer, true); - assertEquals(FLAGS_VALUE, ((NshFlagsCaseValue) value).getNshFlagsValues().getNshFlags()); - assertEquals(FLAGS_MASK, ((NshFlagsCaseValue) value).getNshFlagsValues().getMask()); + assertEquals(Uint8.valueOf(FLAGS_VALUE), ((NshFlagsCaseValue) value).getNshFlagsValues().getNshFlags()); + assertEquals(Uint8.valueOf(FLAGS_MASK), ((NshFlagsCaseValue) value).getNshFlagsValues().getMask()); assertFalse(buffer.isReadable()); } diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java index 7f16045563..e09e4cf61c 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodecTest.java @@ -20,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshMdtypeCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshMdtypeCodecTest { @@ -50,7 +51,7 @@ public class NshMdtypeCodecTest { NxExpMatchEntryValue value = nshMdtypeCodec.deserializeValue(buffer, false); - assertEquals(MDTYPE_VALUE, ((NshMdtypeCaseValue) value).getNshMdtypeValues().getValue()); + assertEquals(Uint8.valueOf(MDTYPE_VALUE), ((NshMdtypeCaseValue) value).getNshMdtypeValues().getValue()); assertFalse(buffer.isReadable()); } diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java index b521771815..2ec179cbb5 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodecTest.java @@ -20,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshNpCodecTest { @@ -50,7 +51,7 @@ public class NshNpCodecTest { NxExpMatchEntryValue value = nshNpCodec.deserializeValue(buffer, false); - assertEquals(NP_VALUE, ((NshNpCaseValue) value).getNshNpValues().getValue()); + assertEquals(Uint8.valueOf(NP_VALUE), ((NshNpCaseValue) value).getNshNpValues().getValue()); assertFalse(buffer.isReadable()); } diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodecTest.java index af3f746bf9..c75e1f41e4 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NshTtlCodecTest.java @@ -20,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshTtlCodecTest { @@ -62,7 +63,7 @@ public class NshTtlCodecTest { NxExpMatchEntryValue value = nshTtlCodec.deserializeValue(buffer, false); - assertEquals(TTL_VALUE, ((NshTtlCaseValue) value).getNshTtlValues().getNshTtl()); + assertEquals(Uint8.valueOf(TTL_VALUE), ((NshTtlCaseValue) value).getNshTtlValues().getNshTtl()); assertFalse(buffer.isReadable()); } @@ -72,18 +73,18 @@ public class NshTtlCodecTest { NxExpMatchEntryValue value = nshTtlCodec.deserializeValue(buffer, true); - assertEquals(TTL_VALUE, ((NshTtlCaseValue) value).getNshTtlValues().getNshTtl()); - assertEquals(TTL_MASK, ((NshTtlCaseValue) value).getNshTtlValues().getMask()); + assertEquals(Uint8.valueOf(TTL_VALUE), ((NshTtlCaseValue) value).getNshTtlValues().getNshTtl()); + assertEquals(Uint8.valueOf(TTL_MASK), ((NshTtlCaseValue) value).getNshTtlValues().getMask()); assertFalse(buffer.isReadable()); } - private NxExpMatchEntryValue createMatchEntryValue(Short value, Short mask) { + private NxExpMatchEntryValue createMatchEntryValue(final Short value, final Short mask) { NshTtlValues nshTtlValues = new NshTtlValuesBuilder().setNshTtl(value).setMask(mask).build(); return new NshTtlCaseValueBuilder().setNshTtlValues(nshTtlValues).build(); } - private void writeBuffer(ByteBuf message, Short value, Short mask) { + private void writeBuffer(final ByteBuf message, final Short value, final Short mask) { message.writeByte(value.intValue()); if (mask != null) { message.writeByte(mask.intValue()); diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodecTest.java index 962a811c56..1c2b0e6610 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodecTest.java @@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NsiCodecTest { @@ -61,7 +62,7 @@ public class NsiCodecTest { NxExpMatchEntryValue value = nsiCodec.deserializeValue(buffer, false); - assertEquals(NSI_VALUE, ((NsiCaseValue) value).getNsiValues().getNsi()); + assertEquals(Uint8.valueOf(NSI_VALUE), ((NsiCaseValue) value).getNsiValues().getNsi()); assertFalse(buffer.isReadable()); } @@ -71,8 +72,8 @@ public class NsiCodecTest { NxExpMatchEntryValue value = nsiCodec.deserializeValue(buffer, true); - assertEquals(NSI_VALUE, ((NsiCaseValue) value).getNsiValues().getNsi()); - assertEquals(NSI_MASK, ((NsiCaseValue) value).getNsiValues().getMask()); + assertEquals(Uint8.valueOf(NSI_VALUE), ((NsiCaseValue) value).getNsiValues().getNsi()); + assertEquals(Uint8.valueOf(NSI_MASK), ((NsiCaseValue) value).getNsiValues().getMask()); assertFalse(buffer.isReadable()); } diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NspCodecTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NspCodecTest.java index b0b3b2308a..689b90b525 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NspCodecTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NspCodecTest.java @@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NspCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NspCodecTest { @@ -61,7 +62,7 @@ public class NspCodecTest { NxExpMatchEntryValue value = nspCodec.deserializeValue(buffer, false); - assertEquals(NSP_VALUE, ((NspCaseValue) value).getNspValues().getNsp()); + assertEquals(Uint32.valueOf(NSP_VALUE), ((NspCaseValue) value).getNspValues().getNsp()); assertFalse(buffer.isReadable()); } @@ -71,18 +72,18 @@ public class NspCodecTest { NxExpMatchEntryValue value = nspCodec.deserializeValue(buffer, true); - assertEquals(NSP_VALUE, ((NspCaseValue) value).getNspValues().getNsp()); - assertEquals(NSP_MASK, ((NspCaseValue) value).getNspValues().getMask()); + assertEquals(Uint32.valueOf(NSP_VALUE), ((NspCaseValue) value).getNspValues().getNsp()); + assertEquals(Uint32.valueOf(NSP_MASK), ((NspCaseValue) value).getNspValues().getMask()); assertFalse(buffer.isReadable()); } - private NxExpMatchEntryValue createMatchEntryValue(Long value, Long mask) { + private NxExpMatchEntryValue createMatchEntryValue(final Long value, final Long mask) { NspValues nspValues = new NspValuesBuilder().setNsp(value).setMask(mask).build(); return new NspCaseValueBuilder().setNspValues(nspValues).build(); } - private void writeBuffer(ByteBuf message, Long value, Long mask) { + private void writeBuffer(final ByteBuf message, final Long value, final Long mask) { message.writeInt(value.intValue()); if (mask != null) { message.writeInt(mask.intValue()); diff --git a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeaderTest.java b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeaderTest.java index 683cae9338..530dd867d9 100644 --- a/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeaderTest.java +++ b/extension/openflowjava-extension-nicira/src/test/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeaderTest.java @@ -11,14 +11,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.math.BigInteger; import org.junit.Test; +import org.opendaylight.yangtools.yang.common.Uint64; public class NxmHeaderTest { - private static final BigInteger NO_MASK_HEADER = new BigInteger("80000496", 16); - private static final BigInteger MASK_HEADER = new BigInteger("80000596", 16); - private static final BigInteger EXP_HEADER = new BigInteger("FFFFF4F300F2AB31", 16); + private static final Uint64 NO_MASK_HEADER = Uint64.valueOf("80000496", 16); + private static final Uint64 MASK_HEADER = Uint64.valueOf("80000596", 16); + private static final Uint64 EXP_HEADER = Uint64.valueOf("FFFFF4F300F2AB31", 16); @Test public void nxmHeaderNoMaskTest() { @@ -37,13 +37,13 @@ public class NxmHeaderTest { nxmHeaderFromBigInt.isHasMask(), nxmHeaderFromBigInt.getLength()); - assertEquals(NO_MASK_HEADER, nxmHeaderFromFields.toBigInteger()); + assertEquals(NO_MASK_HEADER, nxmHeaderFromFields.toUint64()); assertEquals(0x80000496L, nxmHeaderFromFields.toLong()); assertFalse(nxmHeaderFromFields.isExperimenter()); NxmHeader nxmHeaderFromLong = new NxmHeader(NO_MASK_HEADER.longValue()); - assertEquals(NO_MASK_HEADER, nxmHeaderFromLong.toBigInteger()); + assertEquals(NO_MASK_HEADER, nxmHeaderFromLong.toUint64()); assertEquals(0x80000496L, nxmHeaderFromLong.toLong()); assertFalse(nxmHeaderFromLong.isExperimenter()); @@ -71,13 +71,13 @@ public class NxmHeaderTest { nxmHeaderFromBigInt.isHasMask(), nxmHeaderFromBigInt.getLength()); - assertEquals(MASK_HEADER, nxmHeaderFromFields.toBigInteger()); + assertEquals(MASK_HEADER, nxmHeaderFromFields.toUint64()); assertEquals(0x80000596L, nxmHeaderFromFields.toLong()); assertFalse(nxmHeaderFromFields.isExperimenter()); NxmHeader nxmHeaderFromLong = new NxmHeader(MASK_HEADER.longValue()); - assertEquals(MASK_HEADER, nxmHeaderFromLong.toBigInteger()); + assertEquals(MASK_HEADER, nxmHeaderFromLong.toUint64()); assertEquals(0x80000596L, nxmHeaderFromLong.toLong()); assertFalse(nxmHeaderFromLong.isExperimenter()); @@ -106,14 +106,14 @@ public class NxmHeaderTest { nxmHeaderFromBigInt.getLength(), nxmHeaderFromBigInt.getExperimenterId()); - assertEquals(EXP_HEADER, nxmHeaderFromFields.toBigInteger()); + assertEquals(EXP_HEADER, nxmHeaderFromFields.toUint64()); assertEquals(0xFFFFF4F300F2AB31L, nxmHeaderFromFields.toLong()); assertTrue(nxmHeaderFromFields.isExperimenter()); assertEquals(0x00F2AB31L, nxmHeaderFromFields.getExperimenterId()); NxmHeader nxmHeaderFromLong = new NxmHeader(EXP_HEADER.longValue()); - assertEquals(EXP_HEADER, nxmHeaderFromLong.toBigInteger()); + assertEquals(EXP_HEADER, nxmHeaderFromLong.toUint64()); assertEquals(0xFFFFF4F300F2AB31L, nxmHeaderFromLong.toLong()); assertTrue(nxmHeaderFromLong.isExperimenter()); assertEquals(0x00F2AB31L, nxmHeaderFromLong.getExperimenterId()); diff --git a/extension/openflowplugin-extension-api/src/main/java/org/opendaylight/openflowplugin/extension/api/ExtensionConvertorData.java b/extension/openflowplugin-extension-api/src/main/java/org/opendaylight/openflowplugin/extension/api/ExtensionConvertorData.java index bccbf6153b..682616559b 100644 --- a/extension/openflowplugin-extension-api/src/main/java/org/opendaylight/openflowplugin/extension/api/ExtensionConvertorData.java +++ b/extension/openflowplugin-extension-api/src/main/java/org/opendaylight/openflowplugin/extension/api/ExtensionConvertorData.java @@ -8,12 +8,13 @@ package org.opendaylight.openflowplugin.extension.api; -import java.math.BigInteger; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class ExtensionConvertorData extends ConvertorData { - private Long xid; + private Uint32 xid; - private BigInteger datapathId; + private Uint64 datapathId; /** @@ -21,7 +22,7 @@ public class ExtensionConvertorData extends ConvertorData { * * @param version the version */ - public ExtensionConvertorData(short version) { + public ExtensionConvertorData(final short version) { super(version); } @@ -30,7 +31,7 @@ public class ExtensionConvertorData extends ConvertorData { * * @return the xid */ - public Long getXid() { + public Uint32 getXid() { return xid; } @@ -39,7 +40,7 @@ public class ExtensionConvertorData extends ConvertorData { * * @param xid the xid */ - public void setXid(Long xid) { + public void setXid(final Uint32 xid) { this.xid = xid; } @@ -48,7 +49,7 @@ public class ExtensionConvertorData extends ConvertorData { * * @return the datapath id */ - public BigInteger getDatapathId() { + public Uint64 getDatapathId() { return datapathId; } @@ -57,7 +58,7 @@ public class ExtensionConvertorData extends ConvertorData { * * @param datapathId the datapath id */ - public void setDatapathId(BigInteger datapathId) { + public void setDatapathId(final Uint64 datapathId) { this.datapathId = datapathId; } } diff --git a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java index a6987e107c..6fa2d28a0a 100644 --- a/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java +++ b/extension/openflowplugin-extension-eric/src/main/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertor.java @@ -37,6 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.er 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.general.extension.grouping.Extension; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Convert to/from SAL flow model to openflowjava model for Icmpv6NDOptionsTypeCase. @@ -60,7 +61,7 @@ public class Icmpv6NDOptionsTypeConvertor implements ConvertorToOFJava, if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - long value = matchGrouping.get().getEricOfIcmpv6NdReserved().getIcmpv6NdReserved(); + Uint32 value = matchGrouping.get().getEricOfIcmpv6NdReserved().getIcmpv6NdReserved(); Icmpv6NdReservedCaseValueBuilder icmpv6NdReservedCaseValueBuilder = new Icmpv6NdReservedCaseValueBuilder(); icmpv6NdReservedCaseValueBuilder.setIcmpv6NdReservedValues(new Icmpv6NdReservedValuesBuilder() .setIcmpv6NdReserved(value).build()); diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/NiciraExtensionProvider.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/NiciraExtensionProvider.java index 72f48d0ba6..c630d53f07 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/NiciraExtensionProvider.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/NiciraExtensionProvider.java @@ -297,6 +297,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcKey; import org.opendaylight.yangtools.concepts.ObjectRegistration; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -733,7 +734,8 @@ public class NiciraExtensionProvider implements AutoCloseable { ConvertorActionFromOFJava< org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action, ActionPath> actionConvertor) { - ActionSerializerKey key = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, actionCaseType, null); + ActionSerializerKey key = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, actionCaseType, + (Uint32) null); registrations.add(extensionConverterRegistrator.registerActionConvertor(key, actionConvertor)); } } diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverter.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverter.java index 073b56092e..b74217dfec 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverter.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/IpConverter.java @@ -8,10 +8,10 @@ package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor; import com.google.common.base.Splitter; -import com.google.common.collect.Lists; import java.util.List; import java.util.ListIterator; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yangtools.yang.common.Uint32; /** * IP conversion utilities. @@ -19,17 +19,15 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. * @author msunal */ public final class IpConverter { + private static final Splitter SPLITTER = Splitter.on('.').trimResults().omitEmptyStrings(); + private IpConverter() { } - public static long ipv4AddressToLong(Ipv4Address ipv4Address) { + public static long ipv4AddressToLong(final Ipv4Address ipv4Address) { long result = 0 ; - Iterable splitted = Splitter.on('.') - .trimResults() - .omitEmptyStrings() - .split(ipv4Address.getValue()); + List splittedAddress = SPLITTER.splitToList(ipv4Address.getValue()); - List splittedAddress = Lists.newArrayList(splitted.iterator()); int maxIndex = splittedAddress.size() - 1; ListIterator listIter = splittedAddress.listIterator(); while (listIter.hasNext()) { @@ -40,7 +38,11 @@ public final class IpConverter { return result & 0xFFFFFFFF; } - public static Ipv4Address longToIpv4Address(long ip) { + public static Ipv4Address longToIpv4Address(final Uint32 ip) { + return longToIpv4Address(ip.toJava()); + } + + public static Ipv4Address longToIpv4Address(final long ip) { long tmpIp = ip; StringBuilder sb = new StringBuilder(15); for (int i = 0; i < 4; i++) { diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertor.java index eef4bcd9f3..39bc1eb43c 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertor.java @@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionDecapNodesNodeTableFlowWriteActionsCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecap; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecapBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class DecapConvertor implements ConvertorActionToOFJava regSrcChoiceToHeaderBuilder = ImmutableMap.builder(); srcChoiceToNxmheader.forEach((srcChoice, header) -> { headerToSrcChoiceBuilder.put(header.toLong(), srcChoice); - headerToSrcChoiceBuilder.put(header.toBigInteger(), srcChoice); + headerToSrcChoiceBuilder.put(header.toUint64(), srcChoice); if (srcChoice instanceof SrcNxRegCase) { regSrcChoiceToHeaderBuilder.put(srcChoice, header); } else { @@ -271,7 +272,7 @@ public final class FieldChoiceResolver { ImmutableMap.Builder regDstChoiceToHeaderBuilder = ImmutableMap.builder(); dstChoiceToNxmheader.forEach((dstChoice, header) -> { dstToHeaderBuilder.put(header.toLong(), dstChoice); - dstToHeaderBuilder.put(header.toBigInteger(), dstChoice); + dstToHeaderBuilder.put(header.toUint64(), dstChoice); if (dstChoice instanceof DstNxRegCase) { regDstChoiceToHeaderBuilder.put(dstChoice, header); } else { @@ -290,6 +291,10 @@ public final class FieldChoiceResolver { * @param header the OXM/NXM header. * @return the destination choice. */ + static DstChoice resolveDstChoice(Uint32 header) { + return NXMHEADER_TO_DST_CHOICE.get(header.toJava()); + } + static DstChoice resolveDstChoice(Long header) { return NXMHEADER_TO_DST_CHOICE.get(header); } @@ -301,7 +306,7 @@ public final class FieldChoiceResolver { * @param header the OXM/NXM header. * @return the destination choice. */ - static DstChoice resolveDstChoice(BigInteger header) { + static DstChoice resolveDstChoice(Uint64 header) { return NXMHEADER_TO_DST_CHOICE.get(header); } @@ -316,6 +321,10 @@ public final class FieldChoiceResolver { return NXMHEADER_TO_SRC_CHOICE.get(header); } + static SrcChoice resolveSrcChoice(Uint32 header) { + return NXMHEADER_TO_SRC_CHOICE.get(header.toJava()); + } + /** * Resolves a source choice field from a {@code BigInteger} representation * of a NXM/OXM header. @@ -323,7 +332,7 @@ public final class FieldChoiceResolver { * @param header the OXM/NXM header. * @return the destination choice. */ - static SrcChoice resolveSrcChoice(BigInteger header) { + static SrcChoice resolveSrcChoice(Uint64 header) { return NXMHEADER_TO_SRC_CHOICE.get(header); } @@ -352,10 +361,10 @@ public final class FieldChoiceResolver { * @param dstChoice the destination choice field. * @return the OXM/NXM header as uint64 {@code BigInteger}. */ - static BigInteger resolveDstHeaderUint64(DstChoice dstChoice) { + static Uint64 resolveDstHeaderUint64(DstChoice dstChoice) { return dstChoice instanceof DstNxRegCase - ? REG_DST_CHOICE_TO_NXMHEADER.get(dstChoice).toBigInteger() - : DST_CHOICE_TYPE_TO_NXMHEADER.get(dstChoice.implementedInterface()).toBigInteger(); + ? REG_DST_CHOICE_TO_NXMHEADER.get(dstChoice).toUint64() + : DST_CHOICE_TYPE_TO_NXMHEADER.get(dstChoice.implementedInterface()).toUint64(); } /** @@ -383,10 +392,10 @@ public final class FieldChoiceResolver { * @param srcChoice the destination choice field. * @return the OXM/NXM header as uint64 {@code BigInteger}. */ - static BigInteger resolveSrcHeaderUint64(SrcChoice srcChoice) { + static Uint64 resolveSrcHeaderUint64(SrcChoice srcChoice) { return srcChoice instanceof SrcNxRegCase - ? REG_SRC_CHOICE_TO_NXMHEADER.get(srcChoice).toBigInteger() - : SRC_CHOICE_TYPE_TO_NXMHEADER.get(srcChoice.implementedInterface()).toBigInteger(); + ? REG_SRC_CHOICE_TO_NXMHEADER.get(srcChoice).toUint64() + : SRC_CHOICE_TYPE_TO_NXMHEADER.get(srcChoice.implementedInterface()).toUint64(); } /** diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertor.java index 83c7792326..6fe6ae2778 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertor.java @@ -30,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipathBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.DstBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class MultipathConvertor implements ConvertorActionToOFJava> start)); - if (value.bitLength() > end - start) { + final long valueBits = value.longValue(); + final long newValueBits = (valueBits & maskBits) >> start; + final int bitLength = bitLength(newValueBits); + if (bitLength > end - start) { // We cannot map a REG_LOAD2 to a single REG_LOAD if the mask // has multiple 1-bit segments (i.e. 0xFF00FF) throw new IllegalArgumentException("Value does not fit in the first 1-bit segment of the mask"); } + + value = Uint64.fromLongBits(newValueBits); } dstBuilder.setStart(start); @@ -265,18 +276,25 @@ public class RegLoad2Convertor implements return nxRegLoadBuilder.build(); } + private static int lowestSetBit(final long value) { + return LongMath.log2(Long.lowestOneBit(value), RoundingMode.UNNECESSARY); + } + + private static int bitLength(final long value) { + return 64 - Long.numberOfLeadingZeros(value); + } + // Convert value/bit range pair of the openfloplugin reg_load action to the // value/mask pair of the openflowjava reg_load2 action. - private static BigInteger[] resolveValueMask(BigInteger value, int start, int end) { - int bits = end - start + 1; - if (value.bitLength() > bits) { + private static Uint64[] resolveValueMask(Uint64 value, Uint16 start, Uint16 end) { + final int startInt = start.toJava(); + final int bits = end.toJava() - startInt + 1; + final long valueBits = value.longValue(); + if (bitLength(valueBits) > bits) { throw new IllegalArgumentException("Value does not fit the bit range"); } - BigInteger mask = BigInteger.ONE.shiftLeft(bits).subtract(BigInteger.ONE).shiftLeft(start); - value = value.shiftLeft(start); - - return new BigInteger[] {value, mask}; + final long maskBits = (1L << bits) - 1 << startInt; + return new Uint64[] {Uint64.fromLongBits(valueBits << startInt), Uint64.fromLongBits(maskBits)}; } - } diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertor.java index 519b387e43..5713919082 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertor.java @@ -29,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Convert to/from SAL flow model to openflowjava model for NxActionRegLoad action. @@ -53,7 +54,9 @@ public class RegLoadConvertor implements // We resolve the destination as a uint32 header, reg load action // does not support 8-byte experimenter headers. nxActionRegLoadBuilder.setDst(FieldChoiceResolver.resolveDstHeaderUint32(dst.getDstChoice())); - nxActionRegLoadBuilder.setOfsNbits(dst.getStart() << 6 | dst.getEnd() - dst.getStart()); + + final int start = dst.getStart().toJava(); + nxActionRegLoadBuilder.setOfsNbits(Uint16.valueOf(start << 6 | dst.getEnd().toJava() - start)); nxActionRegLoadBuilder.setValue(nxAction.getNxRegLoad().getValue()); actionRegLoadBuilder.setNxActionRegLoad(nxActionRegLoadBuilder.build()); return ActionUtil.createAction(actionRegLoadBuilder.build()); @@ -73,14 +76,15 @@ public class RegLoadConvertor implements return resolveAction(nxRegLoadBuilder.build(), path); } - private static int resolveStart(final int ofsNBints) { - return extractSub(ofsNBints, 10, 6); + private static Uint16 resolveStart(final Uint16 ofsNBints) { + return Uint16.valueOf(extractSub(ofsNBints.toJava(), 10, 6)); } - private static int resolveEnd(final int ofsNBints) { - int ofs = extractSub(ofsNBints, 10, 6); - int numBits = extractSub(ofsNBints, 6, 0); - return ofs + numBits; + private static Uint16 resolveEnd(final Uint16 ofsNBints) { + final int bits = ofsNBints.toJava(); + int ofs = extractSub(bits, 10, 6); + int numBits = extractSub(bits, 6, 0); + return Uint16.valueOf(ofs + numBits); } private static int extractSub(final int value, final int nrBits, final int offset) { diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertor.java index 0f5e510036..0e52f0f186 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertor.java @@ -59,7 +59,7 @@ public class RegMoveConvertor implements nxActionRegMove.setDstOfs(dst.getStart()); nxActionRegMove.setSrc(FieldChoiceResolver.resolveSrcHeaderUint64(src.getSrcChoice())); nxActionRegMove.setSrcOfs(src.getStart()); - nxActionRegMove.setNBits(dst.getEnd() - dst.getStart() + 1); + nxActionRegMove.setNBits(dst.getEnd().toJava() - dst.getStart().toJava() + 1); actionRegMoveBuilder.setNxActionRegMove(nxActionRegMove.build()); return ActionUtil.createAction(actionRegMoveBuilder.build()); } @@ -71,11 +71,11 @@ public class RegMoveConvertor implements DstBuilder dstBuilder = new DstBuilder(); dstBuilder.setDstChoice(FieldChoiceResolver.resolveDstChoice(actionRegMove.getDst())); dstBuilder.setStart(actionRegMove.getDstOfs()); - dstBuilder.setEnd(actionRegMove.getDstOfs() + actionRegMove.getNBits() - 1); + dstBuilder.setEnd(actionRegMove.getDstOfs().toJava() + actionRegMove.getNBits().toJava() - 1); SrcBuilder srcBuilder = new SrcBuilder(); srcBuilder.setSrcChoice(FieldChoiceResolver.resolveSrcChoice(actionRegMove.getSrc())); srcBuilder.setStart(actionRegMove.getSrcOfs()); - srcBuilder.setEnd(actionRegMove.getSrcOfs() + actionRegMove.getNBits() - 1); + srcBuilder.setEnd(actionRegMove.getSrcOfs().toJava() + actionRegMove.getNBits().toJava() - 1); NxRegMoveBuilder nxRegMoveBuilder = new NxRegMoveBuilder(); nxRegMoveBuilder.setDst(dstBuilder.build()); nxRegMoveBuilder.setSrc(srcBuilder.build()); diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpOpConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpOpConvertor.java index c31f6e6e41..7fdfdcac00 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpOpConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpOpConvertor.java @@ -35,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.arp.op.grouping.NxmOfArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.arp.op.grouping.NxmOfArpOpBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Convert to/from SAL flow model to openflowjava model for ArpOpCase. @@ -56,7 +57,7 @@ public class ArpOpConvertor implements ConvertorToOFJava, ConvertorF if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Integer value = matchGrouping.get().getNxmOfArpOp().getValue(); + Uint16 value = matchGrouping.get().getNxmOfArpOp().getValue(); ArpOpCaseValueBuilder arpOpCaseValueBuilder = new ArpOpCaseValueBuilder(); arpOpCaseValueBuilder.setArpOpValues(new ArpOpValuesBuilder() .setValue(value).build()); diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpSpaConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpSpaConvertor.java index 5dbafde1bc..04101b5ca3 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpSpaConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/ArpSpaConvertor.java @@ -46,15 +46,15 @@ import org.opendaylight.yangtools.yang.binding.Augmentation; public class ArpSpaConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @Override - public ExtensionAugment> convert(MatchEntry input, MatchPath path) { + public ExtensionAugment> convert(final MatchEntry input, final MatchPath path) { ArpSpaCaseValue arpSpaCaseValue = (ArpSpaCaseValue) input.getMatchEntryValue(); - Ipv4Address ipv4Address = IpConverter.longToIpv4Address(arpSpaCaseValue.getArpSpaValues().getValue()); + Ipv4Address ipv4Address = IpConverter.longToIpv4Address(arpSpaCaseValue.getArpSpaValues().getValue().toJava()); return resolveAugmentation(new NxmOfArpSpaBuilder().setIpv4Address(ipv4Address).build(), path, NxmOfArpSpaKey.class); } @Override - public MatchEntry convert(Extension extension) { + public MatchEntry convert(final Extension extension) { Optional matchGrouping = MatchUtil.ARP_SPA_RESOLVER.findExtension(extension); if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); @@ -67,8 +67,8 @@ public class ArpSpaConvertor implements ConvertorToOFJava, Convertor .match.rev140421.NxmOfArpSpa.class, Nxm0Class.class, arpSpaCaseValueBuilder.build()).build(); } - private static ExtensionAugment> resolveAugmentation(NxmOfArpSpa value, - MatchPath path, Class key) { + private static ExtensionAugment> resolveAugmentation(final NxmOfArpSpa value, + final MatchPath path, final Class key) { switch (path) { case FLOWS_STATISTICS_UPDATE_MATCH: return new ExtensionAugment<>(NxAugMatchNodesNodeTableFlow.class, diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertor.java index 951ebe972d..1febe9a100 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertor.java @@ -35,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.eth.type.grouping.NxmOfEthType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.eth.type.grouping.NxmOfEthTypeBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Convert to/from SAL flow model to openflowjava model for EthTypeCase. @@ -57,7 +58,7 @@ public class EthTypeConvertor implements ConvertorToOFJava, Converto if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Integer value = matchGrouping.get().getNxmOfEthType().getValue(); + Uint16 value = matchGrouping.get().getNxmOfEthType().getValue(); EthTypeCaseValueBuilder ethTypeCaseValueBuilder = new EthTypeCaseValueBuilder(); ethTypeCaseValueBuilder.setEthTypeValues(new EthTypeValuesBuilder() .setValue(value).build()); diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtil.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtil.java index 74f9eb343b..d6de0ff637 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtil.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtil.java @@ -71,6 +71,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcGrouping; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Match utilities. @@ -178,7 +179,7 @@ public final class MatchUtil { public static > MatchEntryBuilder createExperimenterMatchEntryBuilder( final Class matchField, - final long experimenterId, + final Uint32 experimenterId, final NxExpMatchEntryValue value) { ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder(); experimenterBuilder.setExperimenter(new ExperimenterId(experimenterId)); @@ -203,7 +204,15 @@ public final class MatchUtil { return result; } + public static Ipv4Address longToIpv4Address(final Uint32 value) { + return longToIpv4Address(value.toJava()); + } + public static Ipv4Address longToIpv4Address(final Long value) { + return longToIpv4Address(value.longValue()); + } + + public static Ipv4Address longToIpv4Address(final long value) { byte[] bytes = Longs.toByteArray(value); String[] strArray = new String[4]; for (int i = 4; i < bytes.length; i++) { diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertor.java index febcfb36f2..087a38ffc4 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertor.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.flags.grouping.NxmNxNshFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.flags.grouping.NxmNxNshFlagsBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshFlagsConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -64,12 +65,12 @@ public class NshFlagsConvertor implements ConvertorToOFJava, Convert if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Short flags = matchGrouping.get().getNxmNxNshFlags().getNshFlags(); - Short mask = matchGrouping.get().getNxmNxNshFlags().getMask(); + Uint8 flags = matchGrouping.get().getNxmNxNshFlags().getNshFlags(); + Uint8 mask = matchGrouping.get().getNxmNxNshFlags().getMask(); return buildMatchEntry(flags, mask); } - public static MatchEntry buildMatchEntry(Short flags, Short mask) { + public static MatchEntry buildMatchEntry(Uint8 flags, Uint8 mask) { NshFlagsValues nshFlagsValues = new NshFlagsValuesBuilder().setNshFlags(flags).setMask(mask).build(); NxExpMatchEntryValue value = new NshFlagsCaseValueBuilder().setNshFlagsValues(nshFlagsValues).build(); return MatchUtil.createExperimenterMatchEntryBuilder( diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertor.java index 949702e19d..a62ddd99df 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertor.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.mdtype.grouping.NxmNxNshMdtype; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.mdtype.grouping.NxmNxNshMdtypeBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshMdtypeConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -63,11 +64,11 @@ public class NshMdtypeConvertor implements ConvertorToOFJava, Conver if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Short value = matchGrouping.get().getNxmNxNshMdtype().getValue(); + Uint8 value = matchGrouping.get().getNxmNxNshMdtype().getValue(); return buildMatchEntry(value, null); } - public static MatchEntry buildMatchEntry(Short value, Short mask) { + public static MatchEntry buildMatchEntry(Uint8 value, Uint8 mask) { NshMdtypeValues nshMdtypeValues = new NshMdtypeValuesBuilder().setValue(value).build(); NxExpMatchEntryValue entryValue = new NshMdtypeCaseValueBuilder().setNshMdtypeValues(nshMdtypeValues).build(); return MatchUtil.createExperimenterMatchEntryBuilder( diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertor.java index c72c04b3fa..7d0a59272e 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertor.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.np.grouping.NxmNxNshNp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.np.grouping.NxmNxNshNpBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshNpConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -63,11 +64,11 @@ public class NshNpConvertor implements ConvertorToOFJava, ConvertorF if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Short value = matchGrouping.get().getNxmNxNshNp().getValue(); + Uint8 value = matchGrouping.get().getNxmNxNshNp().getValue(); return buildMatchEntry(value, null); } - public static MatchEntry buildMatchEntry(Short value, Short mask) { + public static MatchEntry buildMatchEntry(Uint8 value, Uint8 mask) { NshNpValues nshNpValues = new NshNpValuesBuilder().setValue(value).build(); NxExpMatchEntryValue entryValue = new NshNpCaseValueBuilder().setNshNpValues(nshNpValues).build(); return MatchUtil.createExperimenterMatchEntryBuilder( diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertor.java index f75757a5c0..276ade7e19 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertor.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.ttl.grouping.NxmNxNshTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.ttl.grouping.NxmNxNshTtlBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshTtlConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @Override @@ -61,11 +62,10 @@ public class NshTtlConvertor implements ConvertorToOFJava, Convertor if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Short flags = matchGrouping.get().getNxmNxNshTtl().getNshTtl(); - return buildMatchEntry(flags, null); + return buildMatchEntry(matchGrouping.get().getNxmNxNshTtl().getNshTtl(), null); } - public static MatchEntry buildMatchEntry(Short flags, Short mask) { + public static MatchEntry buildMatchEntry(Uint8 flags, Uint8 mask) { NshTtlValues nshTtlValues = new NshTtlValuesBuilder().setNshTtl(flags).setMask(mask).build(); NxExpMatchEntryValue value = new NshTtlCaseValueBuilder().setNshTtlValues(nshTtlValues).build(); return MatchUtil.createExperimenterMatchEntryBuilder( diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1Convertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1Convertor.java index ee47eb720f..ffb8ef47ae 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1Convertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1Convertor.java @@ -36,11 +36,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; public class Nshc1Convertor implements ConvertorToOFJava, ConvertorFromOFJava { @Override - public ExtensionAugment> convert(MatchEntry input, MatchPath path) { + public ExtensionAugment> convert(final MatchEntry input, final MatchPath path) { ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) input.getMatchEntryValue(); OfjAugNxExpMatch ofjAugNxExpMatch = experimenterIdCase.augmentation(OfjAugNxExpMatch.class); NshcCaseValue nshcCaseValue = (NshcCaseValue) ofjAugNxExpMatch.getNxExpMatchEntryValue(); @@ -52,18 +53,18 @@ public class Nshc1Convertor implements ConvertorToOFJava, ConvertorF } @Override - public MatchEntry convert(Extension extension) { + public MatchEntry convert(final Extension extension) { Optional matchGrouping = MatchUtil.NSC1_RESOLVER.findExtension(extension); if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Long value = matchGrouping.get().getNxmNxNshc1().getValue(); - Long mask = matchGrouping.get().getNxmNxNshc1().getMask(); + Uint32 value = matchGrouping.get().getNxmNxNshc1().getValue(); + Uint32 mask = matchGrouping.get().getNxmNxNshc1().getMask(); MatchEntry matchEntry = buildMatchEntry(value, mask); return matchEntry; } - public static MatchEntry buildMatchEntry(Long value, Long mask) { + public static MatchEntry buildMatchEntry(final Uint32 value, final Uint32 mask) { NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build(); return MatchUtil.createExperimenterMatchEntryBuilder( org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc1.class, @@ -72,8 +73,8 @@ public class Nshc1Convertor implements ConvertorToOFJava, ConvertorF } private static ExtensionAugment> resolveAugmentation( - NxmNxNshc1 value, - MatchPath path, Class key) { + final NxmNxNshc1 value, + final MatchPath path, final Class key) { switch (path) { case FLOWS_STATISTICS_UPDATE_MATCH: return new ExtensionAugment<>(NxAugMatchNodesNodeTableFlow.class, diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2Convertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2Convertor.java index fcba288232..af2bc41e8f 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2Convertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2Convertor.java @@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; public class Nshc2Convertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -57,13 +58,13 @@ public class Nshc2Convertor implements ConvertorToOFJava, ConvertorF if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Long value = matchGrouping.get().getNxmNxNshc2().getValue(); - Long mask = matchGrouping.get().getNxmNxNshc2().getMask(); + Uint32 value = matchGrouping.get().getNxmNxNshc2().getValue(); + Uint32 mask = matchGrouping.get().getNxmNxNshc2().getMask(); MatchEntry matchEntry = buildMatchEntry(value, mask); return matchEntry; } - public static MatchEntry buildMatchEntry(Long value, Long mask) { + public static MatchEntry buildMatchEntry(Uint32 value, Uint32 mask) { NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build(); return MatchUtil.createExperimenterMatchEntryBuilder( org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc2.class, diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3Convertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3Convertor.java index c697eb9f18..bb2e6ef29e 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3Convertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3Convertor.java @@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; public class Nshc3Convertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -57,13 +58,13 @@ public class Nshc3Convertor implements ConvertorToOFJava, ConvertorF if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Long value = matchGrouping.get().getNxmNxNshc3().getValue(); - Long mask = matchGrouping.get().getNxmNxNshc3().getMask(); + Uint32 value = matchGrouping.get().getNxmNxNshc3().getValue(); + Uint32 mask = matchGrouping.get().getNxmNxNshc3().getMask(); MatchEntry matchEntry = buildMatchEntry(value, mask); return matchEntry; } - public static MatchEntry buildMatchEntry(Long value, Long mask) { + public static MatchEntry buildMatchEntry(Uint32 value, Uint32 mask) { NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build(); return MatchUtil.createExperimenterMatchEntryBuilder( org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc3.class, diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4Convertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4Convertor.java index 2b61cfa1e5..251c7bba57 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4Convertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4Convertor.java @@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; public class Nshc4Convertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -57,13 +58,13 @@ public class Nshc4Convertor implements ConvertorToOFJava, ConvertorF if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Long value = matchGrouping.get().getNxmNxNshc4().getValue(); - Long mask = matchGrouping.get().getNxmNxNshc4().getMask(); + Uint32 value = matchGrouping.get().getNxmNxNshc4().getValue(); + Uint32 mask = matchGrouping.get().getNxmNxNshc4().getMask(); MatchEntry matchEntry = buildMatchEntry(value, mask); return matchEntry; } - public static MatchEntry buildMatchEntry(Long value, Long mask) { + public static MatchEntry buildMatchEntry(Uint32 value, Uint32 mask) { NshcCaseValue nshcCaseValue = new NshcCaseValueBuilder().setNshc(value).setMask(mask).build(); return MatchUtil.createExperimenterMatchEntryBuilder( org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc4.class, diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertor.java index b3bdceada3..e7c451f43a 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertor.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsi; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; public class NsiConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @Override @@ -58,12 +59,12 @@ public class NsiConvertor implements ConvertorToOFJava, ConvertorFro if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Short nsiValue = matchGrouping.get().getNxmNxNsi().getNsi(); + Uint8 nsiValue = matchGrouping.get().getNxmNxNsi().getNsi(); MatchEntry matchEntry = buildMatchEntry(nsiValue, null); return matchEntry; } - public static MatchEntry buildMatchEntry(Short nsi, Short mask) { + public static MatchEntry buildMatchEntry(Uint8 nsi, Uint8 mask) { NsiValues nsiValues = new NsiValuesBuilder().setNsi(nsi).setMask(mask).build(); NsiCaseValue nsiCaseValue = new NsiCaseValueBuilder().setNsiValues(nsiValues).build(); return MatchUtil.createExperimenterMatchEntryBuilder( diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertor.java index e612bfad5e..960e1a889f 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertor.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNsp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; public class NspConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -59,12 +60,12 @@ public class NspConvertor implements ConvertorToOFJava, ConvertorFro if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Long nspValue = matchGrouping.get().getNxmNxNsp().getValue(); + Uint32 nspValue = matchGrouping.get().getNxmNxNsp().getValue(); MatchEntry matchEntry = buildMatchEntry(nspValue, null); return matchEntry; } - public static MatchEntry buildMatchEntry(Long nsp, Long mask) { + public static MatchEntry buildMatchEntry(Uint32 nsp, Uint32 mask) { NspValues nspValues = new NspValuesBuilder().setNsp(nsp).setMask(mask).build(); NspCaseValue nspCaseValue = new NspCaseValueBuilder().setNspValues(nspValues).build(); return MatchUtil.createExperimenterMatchEntryBuilder( diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NxmInPortConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NxmInPortConvertor.java index 04d2006512..cadf567fe4 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NxmInPortConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NxmInPortConvertor.java @@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfInPortKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.in.port.grouping.OfInPortBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; public class NxmInPortConvertor implements ConvertorToOFJava, ConvertorFromOFJava { @@ -54,7 +55,7 @@ public class NxmInPortConvertor implements ConvertorToOFJava, if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - Integer value = matchGrouping.get().getOfInPort().getValue(); + Uint16 value = matchGrouping.get().getOfInPort().getValue(); OfInPortCaseValueBuilder inPortCaseValueBuilder = new OfInPortCaseValueBuilder(); inPortCaseValueBuilder.setNxmOfInPortValues( new NxmOfInPortValuesBuilder().setValue(value).build()); diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertor.java index 4f26d5c6a6..bd69efcfce 100644 --- a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertor.java +++ b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertor.java @@ -7,7 +7,6 @@ */ package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match; -import java.math.BigInteger; import java.util.Optional; import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava; import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava; @@ -36,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunIdBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Convert to/from SAL flow model to openflowjava model for TunIdCase. @@ -56,7 +56,7 @@ public class TunIdConvertor implements ConvertorToOFJava, ConvertorF if (!matchGrouping.isPresent()) { throw new CodecPreconditionException(extension); } - BigInteger value = matchGrouping.get().getNxmNxTunId().getValue(); + Uint64 value = matchGrouping.get().getNxmNxTunId().getValue(); TunIdCaseValueBuilder tunnelIdCaseBuilder = new TunIdCaseValueBuilder(); diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/MatchUtilTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/MatchUtilTest.java index 167592305f..ad80ede17d 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/MatchUtilTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/MatchUtilTest.java @@ -16,7 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. public class MatchUtilTest { private static final Ipv4Address IPV4_ADDRESS = new Ipv4Address("1.2.3.4"); - private static final Long IPV4_LONG = new Long(16909060L); + private static final Long IPV4_LONG = 16909060L; @Test public void testIpv4toLong() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertorTest.java index 80ded836ca..e55834ded6 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/DecapConvertorTest.java @@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionDecapNotifGroupDescStatsUpdatedCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionDecapNodesNodeTableFlowWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecap; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class DecapConvertorTest { @@ -38,7 +39,7 @@ public class DecapConvertorTest { @Mock private Action action; - private static final Long PACKET_TYPE = 0xFFFEL; + private static final Uint32 PACKET_TYPE = Uint32.valueOf(0xFFFEL); private DecapConvertor decapConvertor; diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/EncapConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/EncapConvertorTest.java index fac72741fd..e86eb64b4b 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/EncapConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/EncapConvertorTest.java @@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionEncapNotifGroupDescStatsUpdatedCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionEncapNodesNodeTableFlowWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.encap.grouping.NxEncap; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class EncapConvertorTest { @@ -38,7 +39,7 @@ public class EncapConvertorTest { @Mock private Action action; - private static final Long PACKET_TYPE = 0x1894FL; + private static final Uint32 PACKET_TYPE = Uint32.valueOf(0x1894FL); private EncapConvertor encapConvertor; diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FieldChoiceResolverTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FieldChoiceResolverTest.java index bbf9f4adf5..1b9b39ff57 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FieldChoiceResolverTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FieldChoiceResolverTest.java @@ -108,20 +108,20 @@ public class FieldChoiceResolverTest { public void testResolveChoiceToHeader() { if (srcChoiceOut != null) { if (header.isExperimenter()) { - Assert.assertEquals(header.toBigInteger(), FieldChoiceResolver.resolveSrcHeaderUint64(srcChoiceIn)); + Assert.assertEquals(header.toUint64(), FieldChoiceResolver.resolveSrcHeaderUint64(srcChoiceIn)); } else { Assert.assertEquals(header.toLong(), FieldChoiceResolver.resolveSrcHeaderUint32(srcChoiceIn).longValue()); - Assert.assertEquals(header.toBigInteger(), FieldChoiceResolver.resolveSrcHeaderUint64(srcChoiceIn)); + Assert.assertEquals(header.toUint64(), FieldChoiceResolver.resolveSrcHeaderUint64(srcChoiceIn)); } } if (dstChoiceOut != null) { if (header.isExperimenter()) { - Assert.assertEquals(header.toBigInteger(), FieldChoiceResolver.resolveDstHeaderUint64(dstChoiceIn)); + Assert.assertEquals(header.toUint64(), FieldChoiceResolver.resolveDstHeaderUint64(dstChoiceIn)); } else { Assert.assertEquals(header.toLong(), FieldChoiceResolver.resolveDstHeaderUint32(dstChoiceIn).longValue()); - Assert.assertEquals(header.toBigInteger(), FieldChoiceResolver.resolveDstHeaderUint64(dstChoiceIn)); + Assert.assertEquals(header.toUint64(), FieldChoiceResolver.resolveDstHeaderUint64(dstChoiceIn)); } } } @@ -130,11 +130,11 @@ public class FieldChoiceResolverTest { public void testResolveHeaderToChoice() { if (srcChoiceOut != null) { Assert.assertEquals(srcChoiceOut, FieldChoiceResolver.resolveSrcChoice(header.toLong())); - Assert.assertEquals(srcChoiceOut, FieldChoiceResolver.resolveSrcChoice(header.toBigInteger())); + Assert.assertEquals(srcChoiceOut, FieldChoiceResolver.resolveSrcChoice(header.toUint64())); } if (dstChoiceOut != null) { Assert.assertEquals(dstChoiceOut, FieldChoiceResolver.resolveDstChoice(header.toLong())); - Assert.assertEquals(dstChoiceOut, FieldChoiceResolver.resolveDstChoice(header.toBigInteger())); + Assert.assertEquals(dstChoiceOut, FieldChoiceResolver.resolveDstChoice(header.toUint64())); } } diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FinTimeoutConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FinTimeoutConvertorTest.java index da9f018704..940ec6277e 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FinTimeoutConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/FinTimeoutConvertorTest.java @@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.get.flow.statistics.output.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionFinTimeoutNotifDirectStatisticsUpdateWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionFinTimeoutNotifGroupDescStatsUpdatedCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionFinTimeoutNodesNodeTableFlowWriteActionsCase; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Test for {@link FinTimeoutConvertor}. @@ -48,13 +49,13 @@ public class FinTimeoutConvertorTest { .opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.fin.timeout.grouping .NxActionFinTimeout.class); when(actionsCase.getNxActionFinTimeout()).thenReturn(nxFinTimeout); - when(nxFinTimeout.getFinIdleTimeout()).thenReturn(1); - when(nxFinTimeout.getFinHardTimeout()).thenReturn(2); + when(nxFinTimeout.getFinIdleTimeout()).thenReturn(Uint16.valueOf(1)); + when(nxFinTimeout.getFinHardTimeout()).thenReturn(Uint16.valueOf(2)); final ActionFinTimeout actionFinTimeout = Mockito.mock(ActionFinTimeout.class); final NxActionFinTimeout nxActionFinTimeout = Mockito.mock(NxActionFinTimeout.class); - when(nxActionFinTimeout.getFinIdleTimeout()).thenReturn(3); - when(nxActionFinTimeout.getFinHardTimeout()).thenReturn(4); + when(nxActionFinTimeout.getFinIdleTimeout()).thenReturn(Uint16.valueOf(3)); + when(nxActionFinTimeout.getFinHardTimeout()).thenReturn(Uint16.valueOf(4)); when(actionFinTimeout.getNxActionFinTimeout()).thenReturn(nxActionFinTimeout); when(action.getActionChoice()).thenReturn(actionFinTimeout); diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertorTest.java index eddbd631db..b0f26b6936 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/MultipathConvertorTest.java @@ -33,6 +33,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionMultipathNodesNodeTableFlowWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipath; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,25 +60,27 @@ public class MultipathConvertorTest { when(bucketActionsCase.getNxMultipath()).thenReturn(nxMultipath); final Dst dst = Mockito.mock(Dst.class); - when(dst.getStart()).thenReturn(1); - when(dst.getEnd()).thenReturn(2); + when(dst.getStart()).thenReturn(Uint16.ONE); + when(dst.getEnd()).thenReturn(Uint16.valueOf(2)); final DstNxTunIdCase dstNxTunIdCase = new DstNxTunIdCaseBuilder().build(); when(dst.getDstChoice()).thenReturn(dstNxTunIdCase); when(nxMultipath.getFields()).thenReturn(OfjNxHashFields.NXHASHFIELDSETHSRC); - when(nxMultipath.getBasis()).thenReturn(2); + when(nxMultipath.getBasis()).thenReturn(Uint16.valueOf(2)); when(nxMultipath.getAlgorithm()).thenReturn(OfjNxMpAlgorithm.NXMPALGHASHTHRESHOLD); - when(nxMultipath.getMaxLink()).thenReturn(2); - when(nxMultipath.getArg()).thenReturn(2L); + when(nxMultipath.getMaxLink()).thenReturn(Uint16.valueOf(2)); + when(nxMultipath.getArg()).thenReturn(Uint32.valueOf(2)); when(nxMultipath.getDst()).thenReturn(dst); final ActionMultipath actionMultipath = Mockito.mock(ActionMultipath.class); final NxActionMultipath nxActionMultipath = Mockito.mock(NxActionMultipath.class); - when(nxActionMultipath.getDst()).thenReturn(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()); - when(nxActionMultipath.getBasis()).thenReturn(1); + when(nxActionMultipath.getDst()).thenReturn( + Uint32.valueOf(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong())); + when(nxActionMultipath.getBasis()).thenReturn(Uint16.ONE); when(nxActionMultipath.getAlgorithm()).thenReturn(OfjNxMpAlgorithm.NXMPALGHRW); - when(nxActionMultipath.getMaxLink()).thenReturn(2); - when(nxActionMultipath.getArg()).thenReturn(2L); + when(nxActionMultipath.getMaxLink()).thenReturn(Uint16.valueOf(2)); + when(nxActionMultipath.getArg()).thenReturn(Uint32.valueOf(2)); + when(nxActionMultipath.getOfsNbits()).thenReturn(Uint16.ZERO); when(actionMultipath.getNxActionMultipath()).thenReturn(nxActionMultipath); when(action.getActionChoice()).thenReturn(actionMultipath); @@ -88,11 +92,11 @@ public class MultipathConvertorTest { final ActionMultipath actionMultipath = (ActionMultipath) multipathConvertor.convert(bucketActionsCase).getActionChoice(); Assert.assertEquals(OfjNxHashFields.NXHASHFIELDSETHSRC, actionMultipath.getNxActionMultipath().getFields()); - Assert.assertEquals(Integer.valueOf(2), actionMultipath.getNxActionMultipath().getBasis()); + Assert.assertEquals(Uint16.valueOf(2), actionMultipath.getNxActionMultipath().getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHASHTHRESHOLD, actionMultipath.getNxActionMultipath().getAlgorithm()); - Assert.assertEquals(Integer.valueOf(2), actionMultipath.getNxActionMultipath().getMaxLink()); - Assert.assertEquals(Long.valueOf(2L), actionMultipath.getNxActionMultipath().getArg()); + Assert.assertEquals(Uint16.valueOf(2), actionMultipath.getNxActionMultipath().getMaxLink()); + Assert.assertEquals(Uint32.valueOf(2L), actionMultipath.getNxActionMultipath().getArg()); } @Test @@ -110,72 +114,72 @@ public class MultipathConvertorTest { final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5 = multipathConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.ONE, ((NxActionMultipathNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxMultipath() .getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHRW, ((NxActionMultipathNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxMultipath() .getAlgorithm()); - Assert.assertEquals(Long.valueOf(2L), + Assert.assertEquals(Uint32.valueOf(2L), ((NxActionMultipathNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxMultipath().getArg()); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxActionMultipathNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxMultipath() .getMaxLink()); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.ONE, ((NxActionMultipathNotifFlowsStatisticsUpdateWriteActionsCase) actionResult1).getNxMultipath() .getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHRW, ((NxActionMultipathNotifFlowsStatisticsUpdateWriteActionsCase) actionResult1).getNxMultipath() .getAlgorithm()); - Assert.assertEquals(Long.valueOf(2L), + Assert.assertEquals(Uint32.valueOf(2L), ((NxActionMultipathNotifFlowsStatisticsUpdateWriteActionsCase) actionResult1).getNxMultipath() .getArg()); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxActionMultipathNotifFlowsStatisticsUpdateWriteActionsCase) actionResult1).getNxMultipath() .getMaxLink()); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.ONE, ((NxActionMultipathNotifGroupDescStatsUpdatedCase) actionResult2).getNxMultipath().getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHRW, ((NxActionMultipathNotifGroupDescStatsUpdatedCase) actionResult2).getNxMultipath().getAlgorithm()); - Assert.assertEquals(Long.valueOf(2L), + Assert.assertEquals(Uint32.valueOf(2L), ((NxActionMultipathNotifGroupDescStatsUpdatedCase) actionResult2).getNxMultipath().getArg()); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxActionMultipathNotifGroupDescStatsUpdatedCase) actionResult2).getNxMultipath().getMaxLink()); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.ONE, ((NxActionMultipathNodesNodeTableFlowWriteActionsCase) actionResult3).getNxMultipath().getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHRW, ((NxActionMultipathNodesNodeTableFlowWriteActionsCase) actionResult3).getNxMultipath().getAlgorithm()); - Assert.assertEquals(Long.valueOf(2L), + Assert.assertEquals(Uint32.valueOf(2L), ((NxActionMultipathNodesNodeTableFlowWriteActionsCase) actionResult3).getNxMultipath().getArg()); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxActionMultipathNodesNodeTableFlowWriteActionsCase) actionResult3).getNxMultipath().getMaxLink()); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.ONE, ((NxActionMultipathNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxMultipath() .getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHRW, ((NxActionMultipathNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxMultipath() .getAlgorithm()); - Assert.assertEquals(Long.valueOf(2L), + Assert.assertEquals(Uint32.valueOf(2L), ((NxActionMultipathNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxMultipath() .getArg()); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxActionMultipathNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxMultipath() .getMaxLink()); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.ONE, ((NxActionMultipathNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxMultipath() .getBasis()); Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHRW, ((NxActionMultipathNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxMultipath() .getAlgorithm()); - Assert.assertEquals(Long.valueOf(2L), + Assert.assertEquals(Uint32.valueOf(2L), ((NxActionMultipathNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxMultipath() .getArg()); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxActionMultipathNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxMultipath() .getMaxLink()); } diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputReg2ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputReg2ConvertorTest.java index f2cbbb6c8d..bbee9636db 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputReg2ConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputReg2ConvertorTest.java @@ -34,12 +34,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder; import org.opendaylight.yangtools.yang.common.Empty; +import org.opendaylight.yangtools.yang.common.Uint16; @RunWith(MockitoJUnitRunner.class) public class OutputReg2ConvertorTest { - private static final int OFS_N_BITS = 1; - private static final int MAX_LEN = 2; + private static final Uint16 OFS_N_BITS = Uint16.ONE; + private static final Uint16 MAX_LEN = Uint16.valueOf(2); private static final SrcNxTunIdCase SRC_NX_TUN_ID_CASE = new SrcNxTunIdCaseBuilder() .setNxTunId(Empty.getInstance()).build(); @@ -66,7 +67,7 @@ public class OutputReg2ConvertorTest { final ActionOutputReg2 actionOutputReg2 = Mockito.mock(ActionOutputReg2.class); final NxActionOutputReg2 nxActionOutputReg2 = Mockito.mock(NxActionOutputReg2.class); when(nxActionOutputReg2.getSrc()).thenReturn( - NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toBigInteger()); + NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toUint64()); when(nxActionOutputReg2.getMaxLen()).thenReturn(MAX_LEN); when(nxActionOutputReg2.getNBits()).thenReturn(OFS_N_BITS); when(actionOutputReg2.getNxActionOutputReg2()).thenReturn(nxActionOutputReg2); @@ -79,9 +80,9 @@ public class OutputReg2ConvertorTest { public void testConvertSalToOf() { final ActionOutputReg2 actionOutputReg2 = (ActionOutputReg2) outputReg2Convertor.convert(actionsCase).getActionChoice(); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), actionOutputReg2.getNxActionOutputReg2().getNBits()); - Assert.assertEquals(Integer.valueOf(MAX_LEN), actionOutputReg2.getNxActionOutputReg2().getMaxLen()); - Assert.assertEquals(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toBigInteger(), + Assert.assertEquals(OFS_N_BITS, actionOutputReg2.getNxActionOutputReg2().getNBits()); + Assert.assertEquals(MAX_LEN, actionOutputReg2.getNxActionOutputReg2().getMaxLen()); + Assert.assertEquals(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toUint64(), actionOutputReg2.getNxActionOutputReg2().getSrc()); } @@ -100,60 +101,60 @@ public class OutputReg2ConvertorTest { final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5 = outputReg2Convertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS); - Assert.assertEquals(Integer.valueOf(MAX_LEN), + Assert.assertEquals(MAX_LEN, ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult) .getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), + Assert.assertEquals(OFS_N_BITS, ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult) .getNxOutputReg().getSrc().getOfsNbits()); Assert.assertEquals(SRC_NX_TUN_ID_CASE, ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult) .getNxOutputReg().getSrc().getSrcChoice()); - Assert.assertEquals(Integer.valueOf(MAX_LEN), + Assert.assertEquals(MAX_LEN, ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1) .getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), + Assert.assertEquals(OFS_N_BITS, ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1) .getNxOutputReg().getSrc().getOfsNbits()); Assert.assertEquals(SRC_NX_TUN_ID_CASE, ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1) .getNxOutputReg().getSrc().getSrcChoice()); - Assert.assertEquals(Integer.valueOf(MAX_LEN), + Assert.assertEquals(MAX_LEN, ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2) .getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), + Assert.assertEquals(OFS_N_BITS, ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2) .getNxOutputReg().getSrc().getOfsNbits()); Assert.assertEquals(SRC_NX_TUN_ID_CASE, ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2) .getNxOutputReg().getSrc().getSrcChoice()); - Assert.assertEquals(Integer.valueOf(MAX_LEN), + Assert.assertEquals(MAX_LEN, ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3) .getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), + Assert.assertEquals(OFS_N_BITS, ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3) .getNxOutputReg().getSrc().getOfsNbits()); Assert.assertEquals(SRC_NX_TUN_ID_CASE, ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3) .getNxOutputReg().getSrc().getSrcChoice()); - Assert.assertEquals(Integer.valueOf(MAX_LEN), + Assert.assertEquals(MAX_LEN, ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4) .getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), + Assert.assertEquals(OFS_N_BITS, ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4) .getNxOutputReg().getSrc().getOfsNbits()); Assert.assertEquals(SRC_NX_TUN_ID_CASE, ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4) .getNxOutputReg().getSrc().getSrcChoice()); - Assert.assertEquals(Integer.valueOf(MAX_LEN), + Assert.assertEquals(MAX_LEN, ((NxActionOutputRegNotifDirectStatisticsUpdateWriteActionsCase) actionResult5) .getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(OFS_N_BITS), + Assert.assertEquals(OFS_N_BITS, ((NxActionOutputRegNotifDirectStatisticsUpdateWriteActionsCase) actionResult5) .getNxOutputReg().getSrc().getOfsNbits()); Assert.assertEquals(SRC_NX_TUN_ID_CASE, diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputRegConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputRegConvertorTest.java index 15599e8b9f..80f0bab162 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputRegConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/OutputRegConvertorTest.java @@ -31,6 +31,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputReg; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,17 +57,18 @@ public class OutputRegConvertorTest { final NxOutputReg nxOutputReg = Mockito.mock(NxOutputReg.class); final Src src = Mockito.mock(Src.class); - when(src.getOfsNbits()).thenReturn(1); + when(src.getOfsNbits()).thenReturn(Uint16.valueOf(1)); when(nxOutputReg.getSrc()).thenReturn(src); when(nxOutputReg.getSrc().getSrcChoice()).thenReturn(new SrcNxTunIdCaseBuilder().build()); - when(nxOutputReg.getMaxLen()).thenReturn(2); + when(nxOutputReg.getMaxLen()).thenReturn(Uint16.valueOf(2)); when(actionsCase.getNxOutputReg()).thenReturn(nxOutputReg); final ActionOutputReg actionOutputReg = Mockito.mock(ActionOutputReg.class); final NxActionOutputReg nxActionOutputReg = Mockito.mock(NxActionOutputReg.class); - when(nxActionOutputReg.getSrc()).thenReturn(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()); - when(nxActionOutputReg.getMaxLen()).thenReturn(3); - when(nxActionOutputReg.getNBits()).thenReturn(4); + when(nxActionOutputReg.getSrc()).thenReturn( + Uint32.valueOf(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong())); + when(nxActionOutputReg.getMaxLen()).thenReturn(Uint16.valueOf(3)); + when(nxActionOutputReg.getNBits()).thenReturn(Uint16.valueOf(4)); when(actionOutputReg.getNxActionOutputReg()).thenReturn(nxActionOutputReg); when(action.getActionChoice()).thenReturn(actionOutputReg); @@ -76,8 +79,8 @@ public class OutputRegConvertorTest { public void testConvert() { final ActionOutputReg actionOutputReg = (ActionOutputReg) outputRegConvertor.convert(actionsCase).getActionChoice(); - Assert.assertEquals(Integer.valueOf(1), actionOutputReg.getNxActionOutputReg().getNBits()); - Assert.assertEquals(Integer.valueOf(2), actionOutputReg.getNxActionOutputReg().getMaxLen()); + Assert.assertEquals(Uint16.valueOf(1), actionOutputReg.getNxActionOutputReg().getNBits()); + Assert.assertEquals(Uint16.valueOf(2), actionOutputReg.getNxActionOutputReg().getMaxLen()); } @Test @@ -95,41 +98,41 @@ public class OutputRegConvertorTest { final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5 = outputRegConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS); - Assert.assertEquals(Integer.valueOf(3), + Assert.assertEquals(Uint16.valueOf(3), ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxOutputReg() .getMaxLen()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxOutputReg().getSrc() .getOfsNbits()); - Assert.assertEquals(Integer.valueOf(3), + Assert.assertEquals(Uint16.valueOf(3), ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1).getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(4), ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1) + Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1) .getNxOutputReg().getSrc().getOfsNbits()); - Assert.assertEquals(Integer.valueOf(3), + Assert.assertEquals(Uint16.valueOf(3), ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxOutputReg() .getMaxLen()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxOutputReg().getSrc() .getOfsNbits()); - Assert.assertEquals(Integer.valueOf(3), + Assert.assertEquals(Uint16.valueOf(3), ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3).getNxOutputReg().getMaxLen()); - Assert.assertEquals(Integer.valueOf(4), ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3) + Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3) .getNxOutputReg().getSrc().getOfsNbits()); - Assert.assertEquals(Integer.valueOf(3), + Assert.assertEquals(Uint16.valueOf(3), ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxOutputReg() .getMaxLen()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxOutputReg().getSrc() .getOfsNbits()); - Assert.assertEquals(Integer.valueOf(3), + Assert.assertEquals(Uint16.valueOf(3), ((NxActionOutputRegNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxOutputReg() .getMaxLen()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxOutputReg().getSrc() .getOfsNbits()); } diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2ConvertorTest.java index dccdc761f9..e598665185 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2ConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoad2ConvertorTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import junitparams.JUnitParamsRunner; @@ -41,6 +40,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegLoadNodesNodeTableFlowWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(JUnitParamsRunner.class) public class RegLoad2ConvertorTest { @@ -50,23 +52,23 @@ public class RegLoad2ConvertorTest { public static Iterable commonData() { return Arrays.asList(new Object[][] { - {0, 0, 0x01, 0x01, 0x01, null}, - {0, 7, 0xFF, 0xFF, 0xFF, null}, - {0, 3, 0x0F, 0x0F, 0x0F, null}, - {4, 7, 0x0F, 0xF0, 0xF0, null}, - {3, 5, 0x05, 0x28, 0x38, null} + {Uint16.valueOf(0), Uint16.valueOf(0), 0x01, 0x01, 0x01, null}, + {Uint16.valueOf(0), Uint16.valueOf(7), 0xFF, 0xFF, 0xFF, null}, + {Uint16.valueOf(0), Uint16.valueOf(3), 0x0F, 0x0F, 0x0F, null}, + {Uint16.valueOf(4), Uint16.valueOf(7), 0x0F, 0xF0, 0xF0, null}, + {Uint16.valueOf(3), Uint16.valueOf(5), 0x05, 0x28, 0x38, null} }); } public static Iterable salToOpenflowData() { return Arrays.asList(new Object[][] { // specified values do not fit in the bit range - {1, 5, 0xFF, null, null, IllegalArgumentException.class}, - {3, 5, 0x08, null, null, IllegalArgumentException.class}, + {Uint16.valueOf(1), Uint16.valueOf(5), 0xFF, null, null, IllegalArgumentException.class}, + {Uint16.valueOf(3), Uint16.valueOf(5), 0x08, null, null, IllegalArgumentException.class}, // out of range value and mask - {0, 16, 0x1FFFF, null, null, IllegalArgumentException.class}, + {Uint16.valueOf(0), Uint16.valueOf(16), 0x1FFFF, null, null, IllegalArgumentException.class}, // out of range mask - {0, 16, 0x1, null, null, IllegalArgumentException.class} + {Uint16.valueOf(0), Uint16.valueOf(16), 0x1, null, null, IllegalArgumentException.class} }); } @@ -75,15 +77,15 @@ public class RegLoad2ConvertorTest { // multiple 1-bit segment in mask {null, null, null, 0x05, 0x05, IllegalArgumentException.class}, {null, null, null, 0x28, 0x28, IllegalArgumentException.class}, - // no mask - {0, 7, 0x01, 0x01, null, null} + // no maskInteger + {Uint16.valueOf(0), Uint16.valueOf(7), 0x01, 0x01, null, null} }); } @Test @Parameters(method = "commonData, salToOpenflowData") - public void testConvertSalToOf(Integer rangeStart, - Integer rangeEnd, + public void testConvertSalToOf(Uint16 rangeStart, + Uint16 rangeEnd, Integer rangeValue, Integer value, Integer mask, @@ -97,7 +99,7 @@ public class RegLoad2ConvertorTest { when(dst.getStart()).thenReturn(rangeStart); when(dst.getEnd()).thenReturn(rangeEnd); NxRegLoad nxRegLoad = mock(NxRegLoad.class); - when(nxRegLoad.getValue()).thenReturn(BigInteger.valueOf(rangeValue)); + when(nxRegLoad.getValue()).thenReturn(Uint64.valueOf(rangeValue)); when(nxRegLoad.getDst()).thenReturn(dst); when(nxRegLoad.getDst().getDstChoice()).thenReturn(mock(DstNxNshFlagsCase.class)); NxActionRegLoadNodesNodeTableFlowApplyActionsCase actionsCase = @@ -119,8 +121,8 @@ public class RegLoad2ConvertorTest { @Test @Parameters(method = "commonData, openflowToSalData") - public void testConvertOfToSal(Integer rangeStart, - Integer rangeEnd, + public void testConvertOfToSal(Uint16 rangeStart, + Uint16 rangeEnd, Integer rangeValue, Integer value, Integer mask, @@ -132,7 +134,7 @@ public class RegLoad2ConvertorTest { NxActionRegLoad2 nxActionRegLoad2 = mock(NxActionRegLoad2.class); when(nxActionRegLoad2.getMatchEntry()).thenReturn(Collections.singletonList( - NshFlagsConvertor.buildMatchEntry(value.shortValue(), mask == null ? null : mask.shortValue()))); + NshFlagsConvertor.buildMatchEntry(Uint8.valueOf(value), mask == null ? null : Uint8.valueOf(mask)))); ActionRegLoad2 actionRegLoad2 = mock(ActionRegLoad2.class); when(actionRegLoad2.getNxActionRegLoad2()).thenReturn(nxActionRegLoad2); Action action = mock(Action.class); @@ -157,7 +159,7 @@ public class RegLoad2ConvertorTest { ((NxActionRegLoadNodesNodeTableFlowWriteActionsCase) actionResult).getNxRegLoad().getDst().getStart()); assertEquals(rangeEnd, ((NxActionRegLoadNodesNodeTableFlowWriteActionsCase) actionResult).getNxRegLoad().getDst().getEnd()); - assertEquals(BigInteger.valueOf(rangeValue), + assertEquals(Uint64.valueOf(rangeValue), ((NxActionRegLoadNodesNodeTableFlowWriteActionsCase) actionResult).getNxRegLoad().getValue()); assertEquals(rangeStart, @@ -166,7 +168,7 @@ public class RegLoad2ConvertorTest { assertEquals(rangeEnd, ((NxActionRegLoadNotifFlowsStatisticsUpdateApplyActionsCase) actionResult1).getNxRegLoad().getDst() .getEnd()); - assertEquals(BigInteger.valueOf(rangeValue), + assertEquals(Uint64.valueOf(rangeValue), ((NxActionRegLoadNotifFlowsStatisticsUpdateApplyActionsCase) actionResult1).getNxRegLoad().getValue()); assertEquals(rangeStart, @@ -175,14 +177,14 @@ public class RegLoad2ConvertorTest { assertEquals(rangeEnd, ((NxActionRegLoadNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegLoad().getDst() .getEnd()); - assertEquals(BigInteger.valueOf(rangeValue), + assertEquals(Uint64.valueOf(rangeValue), ((NxActionRegLoadNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegLoad().getValue()); assertEquals(rangeStart, ((NxActionRegLoadNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegLoad().getDst().getStart()); assertEquals(rangeEnd, ((NxActionRegLoadNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegLoad().getDst().getEnd()); - assertEquals(BigInteger.valueOf(rangeValue), + assertEquals(Uint64.valueOf(rangeValue), ((NxActionRegLoadNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegLoad().getValue()); assertEquals(rangeStart, @@ -191,7 +193,7 @@ public class RegLoad2ConvertorTest { assertEquals(rangeEnd, ((NxActionRegLoadNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegLoad().getDst() .getEnd()); - assertEquals(BigInteger.valueOf(rangeValue), + assertEquals(Uint64.valueOf(rangeValue), ((NxActionRegLoadNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegLoad().getValue()); assertEquals(rangeStart, @@ -200,7 +202,7 @@ public class RegLoad2ConvertorTest { assertEquals(rangeEnd, ((NxActionRegLoadNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegLoad().getDst() .getEnd()); - assertEquals(BigInteger.valueOf(rangeValue), + assertEquals(Uint64.valueOf(rangeValue), ((NxActionRegLoadNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegLoad().getValue()); } } \ No newline at end of file diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertorTest.java index ee5d121408..095b8f1244 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegLoadConvertorTest.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action import static org.mockito.Mockito.when; -import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -32,6 +31,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegLoadNodesNodeTableFlowWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,18 +58,19 @@ public class RegLoadConvertorTest { final NxRegLoad nxRegLoad = Mockito.mock(NxRegLoad.class); final Dst dst = Mockito.mock(Dst.class); - when(dst.getStart()).thenReturn(1); - when(dst.getEnd()).thenReturn(2); + when(dst.getStart()).thenReturn(Uint16.valueOf(1)); + when(dst.getEnd()).thenReturn(Uint16.valueOf(2)); when(nxRegLoad.getDst()).thenReturn(dst); - when(nxRegLoad.getValue()).thenReturn(BigInteger.valueOf(3L)); + when(nxRegLoad.getValue()).thenReturn(Uint64.valueOf(3)); when(nxRegLoad.getDst().getDstChoice()).thenReturn(new DstNxTunIdCaseBuilder().build()); when(actionsCase.getNxRegLoad()).thenReturn(nxRegLoad); final ActionRegLoad actionRegLoad = Mockito.mock(ActionRegLoad.class); final NxActionRegLoad nxActionRegLoad = Mockito.mock(NxActionRegLoad.class); - when(nxActionRegLoad.getDst()).thenReturn(NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong()); - when(nxActionRegLoad.getOfsNbits()).thenReturn(4); - when(nxActionRegLoad.getValue()).thenReturn(BigInteger.ONE); + when(nxActionRegLoad.getDst()).thenReturn( + Uint32.valueOf(NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong())); + when(nxActionRegLoad.getOfsNbits()).thenReturn(Uint16.valueOf(4)); + when(nxActionRegLoad.getValue()).thenReturn(Uint64.ONE); when(actionRegLoad.getNxActionRegLoad()).thenReturn(nxActionRegLoad); when(action.getActionChoice()).thenReturn(actionRegLoad); @@ -77,8 +80,8 @@ public class RegLoadConvertorTest { @Test public void testConvert() { final ActionRegLoad actionRegLoad = (ActionRegLoad)regLoadConvertor.convert(actionsCase).getActionChoice(); - Assert.assertEquals(Integer.valueOf(65), actionRegLoad.getNxActionRegLoad().getOfsNbits()); - Assert.assertEquals(BigInteger.valueOf(3), actionRegLoad.getNxActionRegLoad().getValue()); + Assert.assertEquals(Uint16.valueOf(65), actionRegLoad.getNxActionRegLoad().getOfsNbits()); + Assert.assertEquals(Uint64.valueOf(3), actionRegLoad.getNxActionRegLoad().getValue()); } @Test @@ -96,54 +99,54 @@ public class RegLoadConvertorTest { org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5 = regLoadConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegLoadNodesNodeTableFlowWriteActionsCase) actionResult).getNxRegLoad().getDst().getStart()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionRegLoadNodesNodeTableFlowWriteActionsCase) actionResult).getNxRegLoad().getDst().getEnd()); - Assert.assertEquals(BigInteger.ONE, + Assert.assertEquals(Uint64.ONE, ((NxActionRegLoadNodesNodeTableFlowWriteActionsCase) actionResult).getNxRegLoad().getValue()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegLoadNotifFlowsStatisticsUpdateApplyActionsCase) actionResult1).getNxRegLoad().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionRegLoadNotifFlowsStatisticsUpdateApplyActionsCase) actionResult1).getNxRegLoad().getDst() .getEnd()); - Assert.assertEquals(BigInteger.ONE, + Assert.assertEquals(Uint64.ONE, ((NxActionRegLoadNotifFlowsStatisticsUpdateApplyActionsCase) actionResult1).getNxRegLoad().getValue()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegLoadNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegLoad().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionRegLoadNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegLoad().getDst() .getEnd()); - Assert.assertEquals(BigInteger.ONE, + Assert.assertEquals(Uint64.ONE, ((NxActionRegLoadNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegLoad().getValue()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegLoadNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegLoad().getDst().getStart()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionRegLoadNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegLoad().getDst().getEnd()); - Assert.assertEquals(BigInteger.ONE, + Assert.assertEquals(Uint64.ONE, ((NxActionRegLoadNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegLoad().getValue()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegLoadNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegLoad().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionRegLoadNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegLoad().getDst() .getEnd()); - Assert.assertEquals(BigInteger.ONE, + Assert.assertEquals(Uint64.ONE, ((NxActionRegLoadNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegLoad().getValue()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegLoadNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegLoad().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(4), + Assert.assertEquals(Uint16.valueOf(4), ((NxActionRegLoadNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegLoad().getDst() .getEnd()); - Assert.assertEquals(BigInteger.ONE, + Assert.assertEquals(Uint64.ONE, ((NxActionRegLoadNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegLoad().getValue()); } } diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertorTest.java index 691b472275..ae281d1dce 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/RegMoveConvertorTest.java @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,20 +62,22 @@ public class RegMoveConvertorTest { when(actionsCase.getNxRegMove()).thenReturn(nxRegMove); when(nxRegMove.getSrc()).thenReturn(src); when(nxRegMove.getDst()).thenReturn(dst); - when(nxRegMove.getSrc().getStart()).thenReturn(1); - when(nxRegMove.getDst().getStart()).thenReturn(3); - when(nxRegMove.getDst().getEnd()).thenReturn(4); + when(nxRegMove.getSrc().getStart()).thenReturn(Uint16.valueOf(1)); + when(nxRegMove.getDst().getStart()).thenReturn(Uint16.valueOf(3)); + when(nxRegMove.getDst().getEnd()).thenReturn(Uint16.valueOf(4)); when(nxRegMove.getDst().getDstChoice()).thenReturn(new DstNxTunIdCaseBuilder().build()); when(nxRegMove.getSrc().getSrcChoice()).thenReturn(new SrcNxTunIdCaseBuilder().build()); final ActionRegMove actionRegMove = Mockito.mock(ActionRegMove.class); final NxActionRegMove nxActionRegMove = Mockito.mock(NxActionRegMove.class); when(nxActionRegMove.getSrc()).thenReturn( - NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toBigInteger()); + NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toUint64()); when(nxActionRegMove.getDst()).thenReturn( - NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toBigInteger()); + NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toUint64()); - when(nxActionRegMove.getNBits()).thenReturn(7); + when(nxActionRegMove.getDstOfs()).thenReturn(Uint16.ZERO); + when(nxActionRegMove.getSrcOfs()).thenReturn(Uint16.ZERO); + when(nxActionRegMove.getNBits()).thenReturn(Uint16.valueOf(7)); when(actionRegMove.getNxActionRegMove()).thenReturn(nxActionRegMove); when(action.getActionChoice()).thenReturn(actionRegMove); @@ -86,9 +89,9 @@ public class RegMoveConvertorTest { @Test public void testConvert() { final ActionRegMove actionRegMove = (ActionRegMove) regMoveConvertor.convert(actionsCase).getActionChoice(); - Assert.assertEquals(Integer.valueOf(3) ,actionRegMove.getNxActionRegMove().getDstOfs()); - Assert.assertEquals(Integer.valueOf(2) ,actionRegMove.getNxActionRegMove().getNBits()); - Assert.assertEquals(Integer.valueOf(1) ,actionRegMove.getNxActionRegMove().getSrcOfs()); + Assert.assertEquals(Uint16.valueOf(3), actionRegMove.getNxActionRegMove().getDstOfs()); + Assert.assertEquals(Uint16.valueOf(2), actionRegMove.getNxActionRegMove().getNBits()); + Assert.assertEquals(Uint16.valueOf(1), actionRegMove.getNxActionRegMove().getSrcOfs()); } @Test @@ -106,36 +109,36 @@ public class RegMoveConvertorTest { final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5 = regMoveConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxRegMove().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(6), + Assert.assertEquals(Uint16.valueOf(6), ((NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxRegMove().getDst() .getEnd()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegMoveNodesNodeTableFlowWriteActionsCase) actionResult1).getNxRegMove().getDst().getStart()); - Assert.assertEquals(Integer.valueOf(6), + Assert.assertEquals(Uint16.valueOf(6), ((NxActionRegMoveNodesNodeTableFlowWriteActionsCase) actionResult1).getNxRegMove().getDst().getEnd()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegMove().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(6), + Assert.assertEquals(Uint16.valueOf(6), ((NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxRegMove().getDst() .getEnd()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegMoveNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegMove().getDst().getStart()); - Assert.assertEquals(Integer.valueOf(6), + Assert.assertEquals(Uint16.valueOf(6), ((NxActionRegMoveNotifGroupDescStatsUpdatedCase) actionResult3).getNxRegMove().getDst().getEnd()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegMoveNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegMove().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(6), + Assert.assertEquals(Uint16.valueOf(6), ((NxActionRegMoveNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxRegMove().getDst() .getEnd()); - Assert.assertEquals(Integer.valueOf(0), + Assert.assertEquals(Uint16.ZERO, ((NxActionRegMoveNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegMove().getDst() .getStart()); - Assert.assertEquals(Integer.valueOf(6), + Assert.assertEquals(Uint16.valueOf(6), ((NxActionRegMoveNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxRegMove().getDst() .getEnd()); } diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/ResubmitConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/ResubmitConvertorTest.java index 27c647619a..29c2b92b78 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/ResubmitConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/action/ResubmitConvertorTest.java @@ -27,6 +27,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionResubmitNotifGroupDescStatsUpdatedCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionResubmitNodesNodeTableFlowWriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.resubmit.grouping.NxResubmit; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,13 +52,13 @@ public class ResubmitConvertorTest { public void setUp() { final NxResubmit nxResubmit = Mockito.mock(NxResubmit.class); when(actionsCase.getNxResubmit()).thenReturn(nxResubmit); - when(nxResubmit.getInPort()).thenReturn(1); - when(nxResubmit.getTable()).thenReturn((short) 2); + when(nxResubmit.getInPort()).thenReturn(Uint16.ONE); + when(nxResubmit.getTable()).thenReturn(Uint8.valueOf(2)); final ActionResubmit actionResubmit = Mockito.mock(ActionResubmit.class); final NxActionResubmit nxActionResubmit = Mockito.mock(NxActionResubmit.class); - when(nxActionResubmit.getInPort()).thenReturn(3); - when(nxActionResubmit.getTable()).thenReturn((short) 4); + when(nxActionResubmit.getInPort()).thenReturn(Uint16.valueOf(3)); + when(nxActionResubmit.getTable()).thenReturn(Uint8.valueOf(4)); when(actionResubmit.getNxActionResubmit()).thenReturn(nxActionResubmit); when(action.getActionChoice()).thenReturn(actionResubmit); diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertorTest.java index 889809a319..18869a4fcf 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshFlagsConvertorTest.java @@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.flags.grouping.NxmNxNshFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.flags.grouping.NxmNxNshFlagsBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class NshFlagsConvertorTest { @@ -41,8 +42,8 @@ public class NshFlagsConvertorTest { private Extension extension; private NshFlagsConvertor convertor; - private static final Short FLAGS_VALUE = (short) 0x7B; - private static final Short MASK_VALUE = (short) 0xFF; + private static final Uint8 FLAGS_VALUE = Uint8.valueOf(0x7B); + private static final Uint8 MASK_VALUE = Uint8.valueOf(0xFF); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java index fff6512b73..2758a6bd6f 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshMdtypeConvertorTest.java @@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.mdtype.grouping.NxmNxNshMdtype; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.mdtype.grouping.NxmNxNshMdtypeBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class NshMdtypeConvertorTest { @@ -42,7 +43,7 @@ public class NshMdtypeConvertorTest { private NshMdtypeConvertor convertor; - private static final Short MDTYPE_VALUE = (short) 0x7B; + private static final Uint8 MDTYPE_VALUE = Uint8.valueOf(0x7B); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java index b8028103f7..23ab67124b 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshNpConvertorTest.java @@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.np.grouping.NxmNxNshNp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.np.grouping.NxmNxNshNpBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class NshNpConvertorTest { @@ -42,7 +43,7 @@ public class NshNpConvertorTest { private NshNpConvertor convertor; - private static final Short NP_VALUE = (short) 0x7B; + private static final Uint8 NP_VALUE = Uint8.valueOf(0x7B); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertorTest.java index 650f1c1496..9d5a1b0e3d 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NshTtlConvertorTest.java @@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.ttl.grouping.NxmNxNshTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsh.ttl.grouping.NxmNxNshTtlBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class NshTtlConvertorTest { @@ -41,7 +42,7 @@ public class NshTtlConvertorTest { private Extension extension; private NshTtlConvertor convertor; - private static final Short TTL_VALUE = (short) 0x13; + private static final Uint8 TTL_VALUE = Uint8.valueOf(0x13); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java index 978408220b..92c26bcf6b 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link Nshc1Convertor}. @@ -44,8 +45,8 @@ public class Nshc1ConvertorTest { private Nshc1Convertor nshc1Convertor; - private static final Long NSHC1_VALUE = 0xFFFFFFFFL; - private static final Long MASK_VALUE = 0xFFFFFFFFL; + private static final Uint32 NSHC1_VALUE = Uint32.valueOf(0xFFFFFFFFL).intern(); + private static final Uint32 MASK_VALUE = Uint32.valueOf(0xFFFFFFFFL).intern(); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java index c58870ac43..7e21e12be4 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link Nshc2Convertor}. @@ -44,8 +45,8 @@ public class Nshc2ConvertorTest { private Nshc2Convertor nshc2Convertor; - private static final Long NSHC2_VALUE = 0xFFFFFFFFL; - private static final Long MASK_VALUE = 0xFFFFFFFFL; + private static final Uint32 NSHC2_VALUE = Uint32.valueOf(0xFFFFFFFFL).intern(); + private static final Uint32 MASK_VALUE = Uint32.valueOf(0xFFFFFFFFL).intern(); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java index d02cf7429d..302b3efc11 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link Nshc3Convertor}. @@ -44,8 +45,8 @@ public class Nshc3ConvertorTest { private Nshc3Convertor nshc3Convertor; - private static final Long NSHC3_VALUE = 0xFFFFFFFFL; - private static final Long MASK_VALUE = 0xFFFFFFFFL; + private static final Uint32 NSHC3_VALUE = Uint32.valueOf(0xFFFFFFFFL); + private static final Uint32 MASK_VALUE = Uint32.valueOf(0xFFFFFFFFL); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4ConvertorTest.java index e4aa7a90a5..e41472e047 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4ConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc4ConvertorTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4Builder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link Nshc4Convertor}. @@ -44,8 +45,8 @@ public class Nshc4ConvertorTest { private Nshc4Convertor nshc4Convertor; - private static final Long NSHC4_VALUE = 0xFFFFFFFFL; - private static final Long MASK_VALUE = 0xFFFFFFFFL; + private static final Uint32 NSHC4_VALUE = Uint32.valueOf(0xFFFFFFFFL); + private static final Uint32 MASK_VALUE = Uint32.valueOf(0xFFFFFFFFL); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertorTest.java index aafe317fb9..a2de8fcc11 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NsiConvertorTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsi; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link NsiConvertor}. @@ -44,7 +45,7 @@ public class NsiConvertorTest { private NsiConvertor nsiConvertor; - private static final Short NSI_VALUE = (short) 255; + private static final Uint8 NSI_VALUE = Uint8.MAX_VALUE; @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertorTest.java index c1f9e03a6b..93d954ee47 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/NspConvertorTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNsp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link NspConvertor}. @@ -44,7 +45,7 @@ public class NspConvertorTest { private NspConvertor nspConvertor; - private static final Long NSP_VALUE = 0xFFL; + private static final Uint32 NSP_VALUE = Uint32.valueOf(0xFFL); @Before public void setUp() { diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertorTest.java index 4e21914489..87938d2f8c 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TunIdConvertorTest.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match; import static org.mockito.Mockito.when; -import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -32,12 +31,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIdKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunIdBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test for {@link TunIdConvertor}. */ @RunWith(MockitoJUnitRunner.class) public class TunIdConvertorTest { + private static final Uint64 U64_TEN = Uint64.valueOf(10).intern(); + @Mock private Extension extension; @Mock @@ -48,7 +50,7 @@ public class TunIdConvertorTest { @Before public void setUp() { final NxmNxTunIdBuilder nxmNxTunIdBuilder = new NxmNxTunIdBuilder() - .setValue(BigInteger.ONE); + .setValue(Uint64.ONE); final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNodesNodeTableFlowBuilder(); nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxTunId(nxmNxTunIdBuilder.build()); @@ -63,14 +65,14 @@ public class TunIdConvertorTest { @Test public void testConvert() { final MatchEntry converted = tunIdConvertor.convert(extension); - Assert.assertEquals(BigInteger.ONE, ((TunIdCaseValue)converted.getMatchEntryValue()) + Assert.assertEquals(Uint64.ONE, ((TunIdCaseValue)converted.getMatchEntryValue()) .getTunIdValues().getValue()); } @Test public void testConvert1() { final TunIdValuesBuilder tunIdValuesBuilder = new TunIdValuesBuilder() - .setValue(BigInteger.TEN); + .setValue(U64_TEN); final TunIdCaseValueBuilder tunIdCaseValueBuilder = new TunIdCaseValueBuilder() .setTunIdValues(tunIdValuesBuilder.build()); @@ -80,26 +82,26 @@ public class TunIdConvertorTest { final ExtensionAugment> extensionAugment = tunIdConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH); - Assert.assertEquals(BigInteger.TEN, + Assert.assertEquals(U64_TEN, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxTunId().getValue()); Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIdKey.class); final ExtensionAugment> extensionAugment1 = tunIdConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH); - Assert.assertEquals(BigInteger.TEN, + Assert.assertEquals(U64_TEN, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxTunId() .getValue()); Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIdKey.class); final ExtensionAugment> extensionAugment2 = tunIdConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH); - Assert.assertEquals(BigInteger.TEN, + Assert.assertEquals(U64_TEN, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxTunId().getValue()); Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIdKey.class); final ExtensionAugment> extensionAugment3 = tunIdConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH); - Assert.assertEquals(BigInteger.TEN, + Assert.assertEquals(U64_TEN, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxTunId().getValue()); Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIdKey.class); } diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertorTest.java index 578cf9835b..857ea6b104 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertorTest.java @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.dst.grouping.NxmOfUdpDstBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Test for {@link UdpDstConvertor}. @@ -66,7 +67,7 @@ public class UdpDstConvertorTest { @Test public void testConvert() { final MatchEntry converted = udpDstConvertor.convert(extension); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.valueOf(1), ((UdpDstCaseValue) converted.getMatchEntryValue()).getUdpDstValues().getMask()); Assert.assertEquals(DEFAULT_PORT, ((UdpDstCaseValue) converted.getMatchEntryValue()).getUdpDstValues().getPort()); @@ -86,7 +87,7 @@ public class UdpDstConvertorTest { final ExtensionAugment> extensionAugment = udpDstConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfUdpDst().getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfUdpDst().getPort()); @@ -94,7 +95,7 @@ public class UdpDstConvertorTest { final ExtensionAugment> extensionAugment1 = udpDstConvertor .convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfUdpDst() .getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()) @@ -103,7 +104,7 @@ public class UdpDstConvertorTest { final ExtensionAugment> extensionAugment2 = udpDstConvertor .convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfUdpDst().getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfUdpDst().getPort()); @@ -111,7 +112,7 @@ public class UdpDstConvertorTest { final ExtensionAugment> extensionAugment3 = udpDstConvertor .convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfUdpDst().getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfUdpDst().getPort()); diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java index 9ece6e6d3d..cdc4526a00 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.src.grouping.NxmOfUdpSrcBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Test for {@link UdpSrcConvertor}. @@ -66,7 +67,7 @@ public class UdpSrcConvertorTest { @Test public void testConvert() { final MatchEntry converted = udpSrcConvertor.convert(extension); - Assert.assertEquals(Integer.valueOf(1), + Assert.assertEquals(Uint16.valueOf(1), ((UdpSrcCaseValue) converted.getMatchEntryValue()).getUdpSrcValues().getMask()); Assert.assertEquals(DEFAULT_PORT, ((UdpSrcCaseValue) converted.getMatchEntryValue()).getUdpSrcValues().getPort()); @@ -86,7 +87,7 @@ public class UdpSrcConvertorTest { final ExtensionAugment> extensionAugment = udpSrcConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfUdpSrc().getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfUdpSrc().getPort()); @@ -94,7 +95,7 @@ public class UdpSrcConvertorTest { final ExtensionAugment> extensionAugment1 = udpSrcConvertor .convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfUdpSrc() .getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()) @@ -103,7 +104,7 @@ public class UdpSrcConvertorTest { final ExtensionAugment> extensionAugment2 = udpSrcConvertor .convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfUdpSrc().getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfUdpSrc().getPort()); @@ -111,7 +112,7 @@ public class UdpSrcConvertorTest { final ExtensionAugment> extensionAugment3 = udpSrcConvertor .convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH); - Assert.assertEquals(Integer.valueOf(2), + Assert.assertEquals(Uint16.valueOf(2), ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfUdpSrc().getMask()); Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfUdpSrc().getPort()); diff --git a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/ByteBufUtils.java b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/ByteBufUtils.java index 3210305149..df534bb2ee 100644 --- a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/ByteBufUtils.java +++ b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/ByteBufUtils.java @@ -9,13 +9,14 @@ package org.opendaylight.openflowplugin.extension.onf; import com.google.common.base.Splitter; -import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import java.util.List; import org.junit.Assert; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Abstract class for common ByteBuf util methods. @@ -24,7 +25,7 @@ public abstract class ByteBufUtils { private static final Splitter HEXSTRING_SPLITTER = Splitter.onPattern("\\s+").omitEmptyStrings(); private static final byte[] XID = new byte[] { 0x01, 0x02, 0x03, 0x04 }; - private static final Long DEFAULT_XID = 0x01020304L; + private static final Uint32 DEFAULT_XID = Uint32.valueOf(0x01020304L); public static ByteBuf hexStringToByteBuf(final String hexSrc) { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); @@ -40,13 +41,12 @@ public abstract class ByteBufUtils { } public static void checkHeaderV13(OfHeader ofHeader) { - final Short version = EncodeConstants.OF13_VERSION_ID; - Assert.assertEquals("Wrong version", version, ofHeader.getVersion()); + Assert.assertEquals("Wrong version", Uint8.valueOf(EncodeConstants.OF13_VERSION_ID), ofHeader.getVersion()); Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid()); } private static byte[] hexStringToBytes(final String hexSrc) { - List byteChips = Lists.newArrayList(HEXSTRING_SPLITTER.split(hexSrc)); + List byteChips = HEXSTRING_SPLITTER.splitToList(hexSrc); byte[] result = new byte[byteChips.size()]; int index = 0; for (String chip : byteChips) { diff --git a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java index c50878c7f8..1ee9b7f6e7 100644 --- a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java +++ b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java @@ -19,6 +19,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.extension.api.ExtensionConvertorData; +import org.opendaylight.openflowplugin.extension.api.exception.ConversionException; import org.opendaylight.openflowplugin.extension.onf.BundleTestUtils; 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; @@ -59,7 +60,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.bundle.property.experimenter.BundlePropertyExperimenterData; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnf; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link org.opendaylight.openflowplugin.extension.onf.converter.BundleAddMessageConverter}. @@ -146,25 +149,26 @@ public class BundleAddMessageConverterTest { .types.port.rev130925.port.mod.port.PortBuilder() .setConfiguration(Mockito.mock(PortConfig.class)) .setAdvertisedFeatures(Mockito.mock(PortFeatures.class)) - .setPortNumber(Mockito.mock(PortNumberUni.class)) + .setPortNumber(new PortNumberUni(Uint32.ZERO)) .setHardwareAddress(Mockito.mock(MacAddress.class)) .build())) .build()).build()) .build(), BundlePortModCase.class); } - private void testConvert(final BundleInnerMessage message, final Class clazz) throws Exception { + private void testConvert(final BundleInnerMessage message, final Class clazz) + throws ConversionException { testConvert(message, clazz, false); } - private void testConvert(final boolean withProperty) throws Exception { + private void testConvert(final boolean withProperty) throws ConversionException { final BundleInnerMessage message = new BundleAddFlowCaseBuilder() .setAddFlowCaseData(new AddFlowCaseDataBuilder().build()).build(); testConvert(message, BundleFlowModCase.class, withProperty); } - private void testConvert(final BundleInnerMessage message, Class clazz, final boolean withProperty) - throws Exception { + private void testConvert(final BundleInnerMessage message, Class clazz, + final boolean withProperty) throws ConversionException { final BundleAddMessageSal original = createMessage(withProperty, message); final ExtensionConvertorData data = new ExtensionConvertorData(OFConstants.OFP_VERSION_1_3); data.setDatapathId(extractDatapathId(NODE_REF)); diff --git a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/OnfExperimenterErrorFactoryTest.java b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/OnfExperimenterErrorFactoryTest.java index 1cbc9d5ea7..e11c435e5e 100644 --- a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/OnfExperimenterErrorFactoryTest.java +++ b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/OnfExperimenterErrorFactoryTest.java @@ -38,7 +38,7 @@ public class OnfExperimenterErrorFactoryTest { Assert.assertEquals("Wrong type", EncodeConstants.EXPERIMENTER_VALUE, builtByFactory.getType().intValue()); Assert.assertEquals("Wrong type string", "EXPERIMENTER", builtByFactory.getTypeString()); Assert.assertEquals("Wrong experimenter ID", EncodeConstants.ONF_EXPERIMENTER_ID, - builtByFactory.augmentation(ExperimenterIdError.class).getExperimenter().getValue().intValue()); + builtByFactory.augmentation(ExperimenterIdError.class).getExperimenter().getValue()); Assert.assertNotNull("Data is null", builtByFactory.getData()); } diff --git a/features-aggregator/odl-openflowplugin-nsf-model/pom.xml b/features-aggregator/odl-openflowplugin-nsf-model/pom.xml index 40b1861ac0..7eeaf7e710 100644 --- a/features-aggregator/odl-openflowplugin-nsf-model/pom.xml +++ b/features-aggregator/odl-openflowplugin-nsf-model/pom.xml @@ -21,7 +21,7 @@ org.opendaylight.mdsal mdsal-artifacts - 4.0.6 + 5.0.2 import pom diff --git a/model/model-flow-base/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/flow/types/port/rev130925/PortNumberUniBuilder.java b/model/model-flow-base/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/flow/types/port/rev130925/PortNumberUniBuilder.java index 6eaa4b15b6..ee3953f774 100644 --- a/model/model-flow-base/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/flow/types/port/rev130925/PortNumberUniBuilder.java +++ b/model/model-flow-base/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/flow/types/port/rev130925/PortNumberUniBuilder.java @@ -1,5 +1,6 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925; +import org.opendaylight.yangtools.yang.common.Uint32; /** * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. @@ -12,11 +13,10 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925; */ public class PortNumberUniBuilder { - public static PortNumberUni getDefaultInstance(java.lang.String defaultValue) { + public static PortNumberUni getDefaultInstance(String defaultValue) { try { - long uint32 = Long.parseLong(defaultValue); - return new PortNumberUni(uint32); - } catch(NumberFormatException e){ + return new PortNumberUni(Uint32.valueOf(defaultValue)); + } catch (IllegalArgumentException e) { return new PortNumberUni(defaultValue); } } diff --git a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml index a549d9435f..e55d2b6e96 100644 --- a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml @@ -33,7 +33,7 @@ org.opendaylight.mdsal mdsal-artifacts - 4.0.6 + 5.0.2 import pom diff --git a/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 309189fd32..f1835d861f 100644 --- a/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -5,11 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.api.keys; 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.common.Uint32; /** * Key for an action serializer. @@ -21,7 +21,7 @@ public class ActionSerializerKey extends MessageTypeKey< implements ExperimenterSerializerKey { private final Class actionType; - private final Long experimenterId; + private final Uint32 experimenterId; /** * Constructor. @@ -30,13 +30,24 @@ public class ActionSerializerKey extends MessageTypeKey< * @param actionType type of action * @param experimenterId experimenter / vendor ID */ - public ActionSerializerKey(short msgVersion, Class actionType, - Long experimenterId) { + public ActionSerializerKey(final short msgVersion, final Class actionType, final Uint32 experimenterId) { super(msgVersion, Action.class); this.actionType = actionType; this.experimenterId = experimenterId; } + /** + * Constructor. + * + * @param msgVersion protocol wire version + * @param actionType type of action + * @param experimenterId experimenter / vendor ID + */ + @Deprecated(forRemoval = true) + public ActionSerializerKey(final short msgVersion, final Class actionType, final Long experimenterId) { + this(msgVersion, actionType, experimenterId == null ? (Uint32) null : Uint32.valueOf(experimenterId)); + } + @Override public int hashCode() { final int prime = 31; @@ -47,7 +58,7 @@ public class ActionSerializerKey extends MessageTypeKey< } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } diff --git a/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java b/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java index 7da6eb110c..e3397235ca 100644 --- a/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java +++ b/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Key for an experimenter action serializer. @@ -27,8 +28,22 @@ public final class ExperimenterActionSerializerKey extends ActionSerializerKey actionSubType) { + public ExperimenterActionSerializerKey(final short msgVersion, final Uint32 experimenterId, + final Class actionSubType) { + super(msgVersion, ExperimenterIdCase.class, experimenterId); + this.actionSubType = actionSubType; + } + + /** + * Constructor. + * + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param actionSubType vendor defined subtype + */ + @Deprecated(forRemoval = true) + public ExperimenterActionSerializerKey(final short msgVersion, final Long experimenterId, + final Class actionSubType) { super(msgVersion, ExperimenterIdCase.class, experimenterId); this.actionSubType = actionSubType; } @@ -42,7 +57,7 @@ public final class ExperimenterActionSerializerKey extends ActionSerializerKey oxmClass; private final Class oxmField; - private Long experimenterId; + + private Uint32 experimenterId; /** * Constructor. @@ -33,8 +34,7 @@ public final class MatchEntrySerializerKey oxmClass, - Class oxmField) { + public MatchEntrySerializerKey(final short msgVersion, final Class oxmClass, final Class oxmField) { super(msgVersion, MatchEntry.class); this.oxmClass = oxmClass; this.oxmField = oxmField; @@ -45,7 +45,7 @@ public final class MatchEntrySerializerKey(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 42L); Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, (Uint32) null); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, (Uint32) null); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOutCase.class, 42L); @@ -63,9 +64,9 @@ public class ActionSerializerKeyTest { key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); - key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, (Uint32) null); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, (Uint32) null); Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); } diff --git a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index abf181c856..73044d6f38 100644 --- a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -11,6 +11,7 @@ package org.opendaylight.openflowjava.protocol.api.keys; import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for MatchEntryDeserializerKey. @@ -38,12 +39,12 @@ public class MatchEntryDeserializerKeyTest { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); + key2.setExperimenterId(Uint32.valueOf(158L)); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - key1.setExperimenterId(158L); + key2.setExperimenterId(Uint32.valueOf(158L)); + key1.setExperimenterId(Uint32.valueOf(158L)); Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); } @@ -60,13 +61,11 @@ public class MatchEntryDeserializerKeyTest { MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - Long expId2 = 654321L; key1.setExperimenterId(null); - key2.setExperimenterId(expId2); + key2.setExperimenterId(Uint32.valueOf(654321L)); Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - Long expId1 = 123456L; - key1.setExperimenterId(expId1); + key1.setExperimenterId(Uint32.valueOf(123456L)); Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); } diff --git a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index cafbed0a19..3bb916b0de 100644 --- a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -15,6 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPh import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for MatchEntrySerializerKey. @@ -54,7 +55,7 @@ public class MatchEntrySerializerKeyTest { null, InPhyPort.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2.setExperimenterId(42L); + key2.setExperimenterId(Uint32.valueOf(42L)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } @@ -70,13 +71,13 @@ public class MatchEntrySerializerKeyTest { Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Long expId2 = 123456789L; + Uint32 expId2 = Uint32.valueOf(123456789L); key1.setExperimenterId(null); key2.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - Long expId1 = 987654331L; + Uint32 expId1 = Uint32.valueOf(987654331L); key1.setExperimenterId(expId1); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); diff --git a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index d1b2049d2e..b4464f6dc3 100644 --- a/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflowjava/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -13,6 +13,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for ExperimenterActionSerializerKey. @@ -35,7 +36,7 @@ public class ExperimenterActionSerializerKeyTest { key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, (Uint32) null, TestSubType.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java index 2f79241a18..92027bcb6f 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java @@ -37,7 +37,7 @@ public class OFDatagramPacketEncoder extends MessageToMessageEncoder { throws Exception { LOG.trace("Encoding"); try { - serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); + serializationFactory.messageToBuffer(wrapper.getMsg().getVersion().toJava(), out, wrapper.getMsg()); if (wrapper.getMsg() instanceof FlowModInput) { statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_SENT); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java index c84cafebfb..54385cd883 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java @@ -61,7 +61,7 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv @Override public int getPort() { - return config.getPort(); + return config.getPort().toJava(); } @Override @@ -71,7 +71,7 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv @Override public int getChannelOutboundQueueSize() { - return config.getChannelOutboundQueueSize(); + return config.getChannelOutboundQueueSize().toJava(); } @Override @@ -138,7 +138,7 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv @Override public long getSwitchIdleTimeout() { - return config.getSwitchIdleTimeout(); + return config.getSwitchIdleTimeout().toJava(); } @Override @@ -156,12 +156,12 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv return new ThreadConfiguration() { @Override public int getWorkerThreadCount() { - return threads.getWorkerThreads(); + return threads.getWorkerThreads().toJava(); } @Override public int getBossThreadCount() { - return threads.getBossThreads(); + return threads.getBossThreads().toJava(); } }; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java index 151d25c144..311fca4d47 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java @@ -276,7 +276,7 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter { protected ListenableFuture> sendToSwitchExpectRpcResultFuture(final I input, final Class responseClazz, final String failureInfo) { - final RpcResponseKey key = new RpcResponseKey(input.getXid(), responseClazz.getName()); + final RpcResponseKey key = new RpcResponseKey(input.getXid().toJava(), responseClazz.getName()); final ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(input, failureInfo, responseCache, key); return enqueueMessage(listener); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 017be60008..dc66be73d8 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -164,7 +164,7 @@ public class ConnectionAdapterImpl extends AbstractConnectionAdapterStatistics i } private static RpcResponseKey createRpcResponseKey(final OfHeader message) { - return new RpcResponseKey(message.getXid(), message.implementedInterface().getName()); + return new RpcResponseKey(message.getXid().toJava(), message.implementedInterface().getName()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java index d9aae5eeaf..0b4559eaec 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java @@ -126,7 +126,7 @@ final class StackedSegment { OutboundQueueEntry pairRequest(final OfHeader response) { // Explicitly 'long' to force unboxing before performing operations - final long xid = response.getXid(); + final long xid = response.getXid().toJava(); if (!xidInRange(xid)) { LOG.debug("Queue {} {}/{} ignoring XID {}", this, baseXid, entries.length, xid); return null; diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index 4cd8d88f36..f4689ce110 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -24,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 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; +import org.opendaylight.yangtools.yang.common.Uint32; /** * OF13SetFieldActionDeserializer. @@ -37,7 +38,7 @@ public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer @Override @SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") // FB doesn't recognize Objects.requireNonNull - public Action deserialize(ByteBuf input) { + public Action deserialize(final ByteBuf input) { Objects.requireNonNull(registry); final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping @@ -55,7 +56,7 @@ public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); + key.setExperimenterId(Uint32.valueOf(expId)); } OFDeserializer matchDeserializer = registry.getDeserializer(key); List entry = new ArrayList<>(); @@ -76,7 +77,7 @@ public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer } @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + public void injectDeserializerRegistry(final DeserializerRegistry deserializerRegistry) { this.registry = deserializerRegistry; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index f20e8778c3..9dfe025d6b 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -139,6 +139,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.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Translates MultipartReply messages. @@ -802,9 +803,9 @@ public class MultipartReplyMessageFactory implements OFDeserializer maxGroupsList = new ArrayList<>(); + List maxGroupsList = new ArrayList<>(); for (int i = 0; i < GROUP_TYPES; i++) { - maxGroupsList.add(rawMessage.readUnsignedInt()); + maxGroupsList.add(Uint32.valueOf(rawMessage.readUnsignedInt())); } featuresBuilder.setMaxGroups(maxGroupsList); List actionBitmaps = new ArrayList<>(); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java index 741cf6456e..676d8cca5a 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java @@ -26,7 +26,7 @@ public class OF10OutputActionSerializer extends AbstractActionSerializer { outBuffer.writeShort(((OutputActionCase) action.getActionChoice()) .getOutputAction().getPort().getValue().intValue()); outBuffer.writeShort(((OutputActionCase) action.getActionChoice()) - .getOutputAction().getMaxLength()); + .getOutputAction().getMaxLength().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index db90d39ab0..8ac14e84f2 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -23,7 +23,7 @@ public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeByte(((SetNwTosCase) action.getActionChoice()).getSetNwTosAction().getNwTos()); + outBuffer.writeByte(((SetNwTosCase) action.getActionChoice()).getSetNwTosAction().getNwTos().toJava()); outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index ba86edb027..1875d2251b 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -23,7 +23,7 @@ public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeByte(((SetVlanPcpCase) action.getActionChoice()).getSetVlanPcpAction().getVlanPcp()); + outBuffer.writeByte(((SetVlanPcpCase) action.getActionChoice()).getSetVlanPcpAction().getVlanPcp().toJava()); outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index 780d9a7ceb..8894ba1042 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -23,7 +23,7 @@ public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeShort(((SetVlanVidCase) action.getActionChoice()).getSetVlanVidAction().getVlanVid()); + outBuffer.writeShort(((SetVlanVidCase) action.getActionChoice()).getSetVlanVidAction().getVlanVid().toJava()); outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index 445b4f8cbe..06ace6c1d0 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -25,7 +25,7 @@ public class OF13OutputActionSerializer extends AbstractActionSerializer { super.serialize(action, outBuffer); outBuffer.writeInt(((OutputActionCase) action.getActionChoice()).getOutputAction() .getPort().getValue().intValue()); - outBuffer.writeShort(((OutputActionCase) action.getActionChoice()).getOutputAction().getMaxLength()); + outBuffer.writeShort(((OutputActionCase) action.getActionChoice()).getOutputAction().getMaxLength().toJava()); outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java index 219d7cc262..a5c996b0e6 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java @@ -24,7 +24,7 @@ public class OF13PopMplsActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeShort(((PopMplsCase) action.getActionChoice()) - .getPopMplsAction().getEthertype().getValue()); + .getPopMplsAction().getEthertype().getValue().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java index af65cb79f0..a67739cd38 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java @@ -24,7 +24,7 @@ public class OF13PushMplsActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeShort(((PushMplsCase) action.getActionChoice()) - .getPushMplsAction().getEthertype().getValue()); + .getPushMplsAction().getEthertype().getValue().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java index b301015e73..16182c4f8f 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java @@ -24,7 +24,7 @@ public class OF13PushPbbActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeShort(((PushPbbCase) action.getActionChoice()) - .getPushPbbAction().getEthertype().getValue()); + .getPushPbbAction().getEthertype().getValue().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java index a8f44cc7a5..02e43ed25b 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java @@ -25,7 +25,7 @@ public class OF13PushVlanActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeShort(((PushVlanCase) action.getActionChoice()) - .getPushVlanAction().getEthertype().getValue()); + .getPushVlanAction().getEthertype().getValue().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 2bf6432678..12a58982c9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -36,7 +36,7 @@ public class OF13SetFieldActionSerializer implements OFSerializer, @Override @SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") // FB doesn't recognize Objects.requireNonNull - public void serialize(Action action, ByteBuf outBuffer) { + public void serialize(final Action action, final ByteBuf outBuffer) { Objects.requireNonNull(registry); final int startIndex = outBuffer.writerIndex(); @@ -63,13 +63,13 @@ public class OF13SetFieldActionSerializer implements OFSerializer, } @Override - public void serializeHeader(Action input, ByteBuf outBuffer) { + public void serializeHeader(final Action input, final ByteBuf outBuffer) { outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); } @Override - public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { registry = serializerRegistry; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index 5cf4a7a779..e2adb38401 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -23,7 +23,7 @@ public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeByte(((SetMplsTtlCase) action.getActionChoice()).getSetMplsTtlAction().getMplsTtl()); + outBuffer.writeByte(((SetMplsTtlCase) action.getActionChoice()).getSetMplsTtlAction().getMplsTtl().toJava()); outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index 8256297068..2b5cbc06e7 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -23,7 +23,7 @@ public class OF13SetNwTtlActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeByte(((SetNwTtlCase) action.getActionChoice()).getSetNwTtlAction().getNwTtl()); + outBuffer.writeByte(((SetNwTtlCase) action.getActionChoice()).getSetNwTtlAction().getNwTtl().toJava()); outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java index 161422e6f0..9525e72d56 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java @@ -25,8 +25,8 @@ public class ErrorMessageFactory implements OFSerializer { @Override public void serialize(ErrorMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); - outBuffer.writeShort(message.getType()); - outBuffer.writeShort(message.getCode()); + outBuffer.writeShort(message.getType().toJava()); + outBuffer.writeShort(message.getCode().toJava()); byte[] data = message.getData(); if (data != null) { diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java index ee9e85aaf4..554a0170e0 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java @@ -38,7 +38,7 @@ public class ExperimenterInputMessageFactory implements OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( EncodeConstants.OF13_VERSION_ID, expId, message.getExpType().longValue())); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 01a1050ce1..abff263b20 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -49,16 +49,16 @@ public class FlowModInputMessageFactory implements OFSerializer, Serial outBuffer.writeLong(message.getCookieMask().longValue()); outBuffer.writeByte(message.getTableId().getValue().byteValue()); outBuffer.writeByte(message.getCommand().getIntValue()); - outBuffer.writeShort(message.getIdleTimeout()); - outBuffer.writeShort(message.getHardTimeout()); - outBuffer.writeShort(message.getPriority()); + outBuffer.writeShort(message.getIdleTimeout().toJava()); + outBuffer.writeShort(message.getHardTimeout().toJava()); + outBuffer.writeShort(message.getPriority().toJava()); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeInt(message.getOutPort().getValue().intValue()); outBuffer.writeInt(message.getOutGroup().intValue()); outBuffer.writeShort(createFlowModFlagsBitmask(message.getFlags())); outBuffer.writeZero(PADDING_IN_FLOW_MOD_MESSAGE); - registry.>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)) - .serialize(message.getMatch(), outBuffer); + registry.>getSerializer( + new MessageTypeKey<>(message.getVersion().toJava(), Match.class)) .serialize(message.getMatch(), outBuffer); ListSerializer.serializeList(message.getInstruction(), INSTRUCTION_KEY_MAKER, registry, outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer, index); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java index 6aed66d17f..597d84af81 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java @@ -42,17 +42,17 @@ public class FlowRemovedMessageFactory implements OFSerializer matchSerializer = registry.getSerializer( - new MessageTypeKey<>(message.getVersion(), Match.class)); + new MessageTypeKey<>(message.getVersion().toJava(), Match.class)); matchSerializer.serialize(message.getMatch(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer, index); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java index 3d9bc14fc7..86489d7f91 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java @@ -26,7 +26,7 @@ public class GetConfigReplyMessageFactory implements OFSerializer, MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand; MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark(); writeBandCommonFields(dscpRemarkBand, outBuffer); - outBuffer.writeByte(dscpRemarkBand.getPrecLevel()); + outBuffer.writeByte(dscpRemarkBand.getPrecLevel().toJava()); outBuffer.writeZero(PADDING_IN_METER_BAND_DSCP_REMARK); } else if (meterBand instanceof MeterBandExperimenterCase) { MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand; @@ -88,7 +88,7 @@ public class MeterModInputMessageFactory implements OFSerializer, ExperimenterIdMeterBand expIdMeterBand = experimenterBand.augmentation(ExperimenterIdMeterBand.class); if (expIdMeterBand != null) { - long expId = expIdMeterBand.getExperimenter().getValue(); + long expId = expIdMeterBand.getExperimenter().getValue().toJava(); Class meterBandSubType = expIdMeterBand.getSubType(); try { OFSerializer serializer = registry.getSerializer( diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java index b1522e8b9d..cac8fa9478 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java @@ -99,6 +99,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.multipart.reply.table.features._case.MultipartReplyTableFeatures; 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.TableFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Translates MultipartReply messages. @@ -233,7 +234,7 @@ public class MultipartReplyMessageFactory implements OFSerializer serializer = registry.getSerializer(ExperimenterSerializerKeyFactory .createMultipartRequestTFSerializerKey(EncodeConstants.OF13_VERSION_ID, expId)); serializer.serialize(property, output); @@ -350,7 +352,7 @@ public class MultipartReplyMessageFactory implements OFSerializer matchSerializer = registry.getSerializer( - new MessageTypeKey<>(message.getVersion(), Match.class)); + new MessageTypeKey<>(message.getVersion().toJava(), Match.class)); matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff); ListSerializer.serializeList(flowStats.getInstruction(), - TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff); + TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion().toJava()), registry, + flowStatsBuff); flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes()); outBuffer.writeBytes(flowStatsBuff); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index cdbd12d710..f2e9d58d84 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -262,7 +262,7 @@ public class MultipartRequestInputFactory implements OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( EncodeConstants.OF13_VERSION_ID, expId)); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index 57adef5ff6..d1809fb02f 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -44,13 +44,13 @@ public class OF10FlowModInputMessageFactory implements OFSerializer matchSerializer = registry.getSerializer(new MessageTypeKey<>( - message.getVersion(), MatchV10.class)); + message.getVersion().toJava(), MatchV10.class)); matchSerializer.serialize(message.getMatchV10(), outBuffer); outBuffer.writeLong(message.getCookie().longValue()); outBuffer.writeShort(message.getCommand().getIntValue()); outBuffer.writeShort(message.getIdleTimeout().intValue()); outBuffer.writeShort(message.getHardTimeout().intValue()); - outBuffer.writeShort(message.getPriority()); + outBuffer.writeShort(message.getPriority().toJava()); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getOutPort().getValue().intValue()); outBuffer.writeShort(createFlowModFlagsBitmask(message.getFlagsV10())); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java index 0d5219c9d3..f55d4cfb0e 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java @@ -43,17 +43,17 @@ public class OF10FlowRemovedMessageFactory implements OFSerializer matchSerializer = registry - .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class)); + .getSerializer(new MessageTypeKey<>(message.getVersion().toJava(), MatchV10.class)); matchSerializer.serialize(message.getMatchV10(), outBuffer); outBuffer.writeLong(message.getCookie().longValue()); - outBuffer.writeShort(message.getPriority()); + outBuffer.writeShort(message.getPriority().toJava()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeInt(message.getDurationSec().intValue()); outBuffer.writeInt(message.getDurationNsec().intValue()); - outBuffer.writeShort(message.getIdleTimeout()); + outBuffer.writeShort(message.getIdleTimeout().toJava()); outBuffer.writeZero(PADDING); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getPacketCount().longValue()); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java index 92905d55e8..13f2168de9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java @@ -27,7 +27,7 @@ public class OF10PacketInMessageFactory implements OFSerializer ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); - outBuffer.writeShort(message.getInPort()); + outBuffer.writeShort(message.getInPort().toJava()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java index 3a315b6cd5..9343a71b4c 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java @@ -154,7 +154,7 @@ public class OF10StatsReplyMessageFactory implements OFSerializer matchSerializer = registry - .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class)); + .getSerializer(new MessageTypeKey<>(message.getVersion().toJava(), MatchV10.class)); matchSerializer.serialize(flowStats.getMatchV10(), flowStatsBuff); flowStatsBuff.writeInt(flowStats.getDurationSec().intValue()); flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue()); - flowStatsBuff.writeShort(flowStats.getPriority()); - flowStatsBuff.writeShort(flowStats.getIdleTimeout()); - flowStatsBuff.writeShort(flowStats.getHardTimeout()); + flowStatsBuff.writeShort(flowStats.getPriority().toJava()); + flowStatsBuff.writeShort(flowStats.getIdleTimeout().toJava()); + flowStatsBuff.writeShort(flowStats.getHardTimeout().toJava()); flowStatsBuff.writeZero(FLOW_STATS_PADDING_2); flowStatsBuff.writeLong(flowStats.getCookie().longValue()); flowStatsBuff.writeLong(flowStats.getPacketCount().longValue()); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java index 49d5155bc0..36a8d7d47c 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java @@ -39,7 +39,7 @@ public class PacketInMessageFactory implements OFSerializer, Se outBuffer.writeByte(message.getTableId().getValue().byteValue()); outBuffer.writeLong(message.getCookie().longValue()); OFSerializer matchSerializer = registry.getSerializer( - new MessageTypeKey<>(message.getVersion(), Match.class)); + new MessageTypeKey<>(message.getVersion().toJava(), Match.class)); matchSerializer.serialize(message.getMatch(), outBuffer); outBuffer.writeZero(PADDING); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java index 274cae5183..ec4a5dd408 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java @@ -74,7 +74,7 @@ public class QueueGetConfigReplyMessageFactory implements OFSerializer { public void serialize(SetConfigInput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getFlags().getIntValue()); - outBuffer.writeShort(message.getMissSendLen()); + outBuffer.writeShort(message.getMissSendLen().toJava()); ByteBufUtils.updateOFHeaderLength(outBuffer); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java index 8fabaf7cad..fef8e5afa7 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java @@ -34,7 +34,7 @@ public class VendorInputMessageFactory implements OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( EncodeConstants.OF10_VERSION_ID, expId, message.getExpType().longValue())); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 18f4b2b654..fa15dbeba3 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -25,7 +25,7 @@ public class GoToTableInstructionSerializer extends AbstractInstructionSerialize outBuffer.writeShort(getType()); outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); outBuffer.writeByte(((GotoTableCase) instruction.getInstructionChoice()) - .getGotoTable().getTableId()); + .getGotoTable().getTableId().toJava()); outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java index 7bf498e668..d79b620f04 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java @@ -24,7 +24,7 @@ public class OxmArpOpSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); ArpOpCase entryValue = (ArpOpCase) entry.getMatchEntryValue(); - outBuffer.writeShort(entryValue.getArpOp().getOpCode()); + outBuffer.writeShort(entryValue.getArpOp().getOpCode().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java index 113b73e7ee..52b4993902 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java @@ -24,7 +24,7 @@ public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); Icmpv4CodeCase entryValue = (Icmpv4CodeCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIcmpv4Code().getIcmpv4Code()); + outBuffer.writeByte(entryValue.getIcmpv4Code().getIcmpv4Code().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java index a4c01a518e..03c0baf1a5 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java @@ -24,7 +24,7 @@ public class OxmIcmpv4TypeSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); Icmpv4TypeCase entryValue = (Icmpv4TypeCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIcmpv4Type().getIcmpv4Type()); + outBuffer.writeByte(entryValue.getIcmpv4Type().getIcmpv4Type().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java index 87e07c73b1..e3618f801a 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java @@ -24,7 +24,7 @@ public class OxmIcmpv6CodeSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); Icmpv6CodeCase entryValue = (Icmpv6CodeCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIcmpv6Code().getIcmpv6Code()); + outBuffer.writeByte(entryValue.getIcmpv6Code().getIcmpv6Code().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java index 4ae28755d6..53af421722 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java @@ -24,7 +24,7 @@ public class OxmIcmpv6TypeSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); Icmpv6TypeCase entryValue = (Icmpv6TypeCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIcmpv6Type().getIcmpv6Type()); + outBuffer.writeByte(entryValue.getIcmpv6Type().getIcmpv6Type().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java index 228ef31ac5..730ce0edf7 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java @@ -24,7 +24,7 @@ public class OxmIpDscpSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); IpDscpCase entryValue = (IpDscpCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIpDscp().getDscp().getValue()); + outBuffer.writeByte(entryValue.getIpDscp().getDscp().getValue().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java index 584f92d66d..15a189310c 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java @@ -24,7 +24,7 @@ public class OxmIpEcnSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); IpEcnCase entryValue = (IpEcnCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIpEcn().getEcn()); + outBuffer.writeByte(entryValue.getIpEcn().getEcn().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java index ef4f49372e..5dead166a1 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java @@ -24,7 +24,7 @@ public class OxmIpProtoSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); IpProtoCase entryValue = (IpProtoCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getIpProto().getProtocolNumber()); + outBuffer.writeByte(entryValue.getIpProto().getProtocolNumber().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java index f3e5a04fcb..c710af90e4 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java @@ -24,7 +24,7 @@ public class OxmMplsTcSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); MplsTcCase entryValue = (MplsTcCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getMplsTc().getTc()); + outBuffer.writeByte(entryValue.getMplsTc().getTc().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java index e67b3dc481..4e50eec014 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java @@ -24,7 +24,7 @@ public class OxmVlanPcpSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); VlanPcpCase entryValue = (VlanPcpCase) entry.getMatchEntryValue(); - outBuffer.writeByte(entryValue.getVlanPcp().getVlanPcp()); + outBuffer.writeByte(entryValue.getVlanPcp().getVlanPcp().toJava()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java index ea2761bd71..74579e9b84 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java @@ -25,7 +25,7 @@ public class OxmVlanVidSerializer extends AbstractOxmMatchEntrySerializer { public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); VlanVid vlanVid = ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid(); - int vlanVidValue = vlanVid.getVlanVid(); + int vlanVidValue = vlanVid.getVlanVid().toJava(); if (vlanVid.isCfiBit()) { short cfi = 1 << 12; // 13-th bit vlanVidValue = vlanVidValue | cfi; diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java index 926a30b3b2..61654423d1 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java @@ -12,6 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.match.AbstractOxmMatchEntrySerializer; 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.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16. @@ -19,18 +20,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc public abstract class AbstractOxmExperimenterMatchEntrySerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntry entry, ByteBuf outBuffer) { + public void serialize(final MatchEntry entry, final ByteBuf outBuffer) { serializeHeader(entry, outBuffer); } @Override - public void serializeHeader(MatchEntry entry, ByteBuf outBuffer) { + public void serializeHeader(final MatchEntry entry, final ByteBuf outBuffer) { outBuffer.writeShort(getOxmClassCode()); - writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), - getValueLength()); + writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), getValueLength()); } - protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { + protected static void writeOxmFieldAndLength(final ByteBuf out, final int fieldValue, final boolean hasMask, + final int lengthArg) { int fieldAndMask = fieldValue << 1; int length = lengthArg; if (hasMask) { @@ -44,7 +45,7 @@ public abstract class AbstractOxmExperimenterMatchEntrySerializer extends Abstra out.writeByte(length); } - protected ExperimenterIdCase serializeExperimenterId(MatchEntry matchEntry, ByteBuf out) { + protected ExperimenterIdCase serializeExperimenterId(final MatchEntry matchEntry, final ByteBuf out) { ExperimenterIdCase expCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue(); out.writeInt(expCase.getExperimenter().getExperimenter().getValue().intValue()); return expCase; @@ -53,5 +54,5 @@ public abstract class AbstractOxmExperimenterMatchEntrySerializer extends Abstra /** * Returns the Experimenter match entry ID. */ - protected abstract long getExperimenterId(); + protected abstract Uint32 getExperimenterId(); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java index ab61d0fbb2..e8685541a2 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java @@ -14,6 +14,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extension import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlags; 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.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16. @@ -21,11 +22,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc public class OnfOxmTcpFlagsSerializer extends AbstractOxmExperimenterMatchEntrySerializer { @Override - public void serialize(MatchEntry entry, ByteBuf outBuffer) { + public void serialize(final MatchEntry entry, final ByteBuf outBuffer) { super.serialize(entry, outBuffer); ExperimenterIdCase expCase = serializeExperimenterId(entry, outBuffer); TcpFlags tcpFlags = expCase.augmentation(TcpFlagsContainer.class).getTcpFlags(); - outBuffer.writeShort(tcpFlags.getFlags()); + outBuffer.writeShort(tcpFlags.getFlags().toJava()); if (entry.isHasMask()) { outBuffer.writeBytes(tcpFlags.getMask()); } @@ -35,7 +36,7 @@ public class OnfOxmTcpFlagsSerializer extends AbstractOxmExperimenterMatchEntryS * Returns the Experimenter match entry ID. */ @Override - protected long getExperimenterId() { + protected Uint32 getExperimenterId() { return EncodeConstants.ONF_EXPERIMENTER_ID; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index 558bb95872..0f888ae8ef 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -11,6 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSeriali import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Helper for registering serializers. @@ -28,7 +29,7 @@ public class ActionSerializerRegistryHelper { * @param version Openflow wire version * @param serializerRegistry registry to be filled with message serializers */ - public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + public ActionSerializerRegistryHelper(final short version, final SerializerRegistry serializerRegistry) { this.version = version; this.serializerRegistry = serializerRegistry; } @@ -39,9 +40,9 @@ public class ActionSerializerRegistryHelper { * @param actionType action type * @param serializer serializer instance */ - public void registerSerializer(Class actionType, - OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, - actionType, null), serializer); + public void registerSerializer(final Class actionType, + final OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, actionType, (Uint32) null), + serializer); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 4bad43db8d..a86f42ad83 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKe import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Factory for creating CodeKeyMaker instances. @@ -28,10 +29,10 @@ public final class CodeKeyMakerFactory { //not called } - public static CodeKeyMaker createMatchEntriesKeyMaker(short version) { + public static CodeKeyMaker createMatchEntriesKeyMaker(final short version) { return new AbstractCodeKeyMaker(version) { @Override - public MessageCodeKey make(ByteBuf input) { + public MessageCodeKey make(final ByteBuf input) { int oxmClass = input.getUnsignedShort(input.readerIndex()); int oxmField = input.getUnsignedByte(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; @@ -40,7 +41,7 @@ public final class CodeKeyMakerFactory { if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); + key.setExperimenterId(Uint32.valueOf(expId)); return key; } key.setExperimenterId(null); @@ -49,10 +50,10 @@ public final class CodeKeyMakerFactory { }; } - public static CodeKeyMaker createActionsKeyMaker(short version) { + public static CodeKeyMaker createActionsKeyMaker(final short version) { return new AbstractCodeKeyMaker(version) { @Override - public MessageCodeKey make(ByteBuf input) { + public MessageCodeKey make(final ByteBuf input) { int type = input.getUnsignedShort(input.readerIndex()); if (type == EncodeConstants.EXPERIMENTER_VALUE) { Long expId = input.getUnsignedInt(input.readerIndex() @@ -65,10 +66,10 @@ public final class CodeKeyMakerFactory { }; } - public static CodeKeyMaker createInstructionsKeyMaker(short version) { + public static CodeKeyMaker createInstructionsKeyMaker(final short version) { return new AbstractCodeKeyMaker(version) { @Override - public MessageCodeKey make(ByteBuf input) { + public MessageCodeKey make(final ByteBuf input) { int type = input.getUnsignedShort(input.readerIndex()); if (type == EncodeConstants.EXPERIMENTER_VALUE) { Long expId = input.getUnsignedInt(input.readerIndex() diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java index 332e1263de..f204910848 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java @@ -11,6 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegi import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Helper class for registering match entry deserializers. @@ -30,8 +31,8 @@ public class MatchEntryDeserializerRegistryHelper { * @param oxmClass oxm_class that will be used for match entry deserializer registration * @param deserializerRegistry registry to be filled with message deserializers */ - public MatchEntryDeserializerRegistryHelper(short version, int oxmClass, - DeserializerRegistry deserializerRegistry) { + public MatchEntryDeserializerRegistryHelper(final short version, final int oxmClass, + final DeserializerRegistry deserializerRegistry) { this.version = version; this.oxmClass = oxmClass; this.registry = deserializerRegistry; @@ -43,13 +44,13 @@ public class MatchEntryDeserializerRegistryHelper { * @param oxmField oxm_field value/code * @param deserializer deserializer instance */ - public void register(int oxmField, OFGeneralDeserializer deserializer) { + public void register(final int oxmField, final OFGeneralDeserializer deserializer) { MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField); key.setExperimenterId(null); registry.registerDeserializer(key, deserializer); } - public void registerExperimenter(int oxmField, long expId, OFGeneralDeserializer deserializer) { + public void registerExperimenter(final int oxmField, final Uint32 expId, final OFGeneralDeserializer deserializer) { MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, OxmMatchConstants.EXPERIMENTER_CLASS, oxmField); key.setExperimenterId(expId); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index 0408cfb34b..17c4265b49 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Helper class for registering match entry serializers. @@ -33,8 +34,8 @@ public class MatchEntrySerializerRegistryHelper { * @param generalClass class that will be used for match entry serializer registration * @param serializerRegistry registry to be filled with message serializers */ - public MatchEntrySerializerRegistryHelper(short version, Class generalClass, - SerializerRegistry serializerRegistry) { + public MatchEntrySerializerRegistryHelper(final short version, final Class generalClass, + final SerializerRegistry serializerRegistry) { this.version = version; this.generalClass = generalClass; this.serializerRegistry = serializerRegistry; @@ -47,7 +48,7 @@ public class MatchEntrySerializerRegistryHelper { * @param serializer the serializer instance */ public void registerSerializer( - Class specificClass, OFGeneralSerializer serializer) { + final Class specificClass, final OFGeneralSerializer serializer) { MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); key.setExperimenterId(null); serializerRegistry.registerSerializer(key, serializer); @@ -60,7 +61,7 @@ public class MatchEntrySerializerRegistryHelper { * @param serializer the serializer instance */ public void registerExperimenterSerializer( - Class specificClass, long expId, OFGeneralSerializer serializer) { + final Class specificClass, final Uint32 expId, final OFGeneralSerializer serializer) { MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( version, ExperimenterClass.class, specificClass); key.setExperimenterId(expId); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java index 4379dfbb96..a704dfdef7 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java @@ -36,21 +36,22 @@ public class OF10MatchSerializer implements OFSerializer { */ @Override public void serialize(final MatchV10 match, final ByteBuf outBuffer) { - outBuffer.writeInt(encodeWildcards(match.getWildcards(), match.getNwSrcMask(), match.getNwDstMask())); - outBuffer.writeShort(match.getInPort()); + outBuffer.writeInt(encodeWildcards(match.getWildcards(), match.getNwSrcMask().toJava(), + match.getNwDstMask().toJava())); + outBuffer.writeShort(match.getInPort().toJava()); outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(match.getDlSrc())); outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(match.getDlDst())); - outBuffer.writeShort(match.getDlVlan()); - outBuffer.writeByte(match.getDlVlanPcp()); + outBuffer.writeShort(match.getDlVlan().toJava()); + outBuffer.writeByte(match.getDlVlanPcp().toJava()); outBuffer.writeZero(PADDING_IN_MATCH); - outBuffer.writeShort(match.getDlType()); - outBuffer.writeByte(match.getNwTos()); - outBuffer.writeByte(match.getNwProto()); + outBuffer.writeShort(match.getDlType().toJava()); + outBuffer.writeByte(match.getNwTos().toJava()); + outBuffer.writeByte(match.getNwProto().toJava()); outBuffer.writeZero(PADDING_IN_MATCH_2); outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(match.getNwSrc())); outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(match.getNwDst())); - outBuffer.writeShort(match.getTpSrc()); - outBuffer.writeShort(match.getTpDst()); + outBuffer.writeShort(match.getTpSrc().toJava()); + outBuffer.writeShort(match.getTpDst().toJava()); } private static int encodeWildcards(final FlowWildcardsV10 wildcards, final short srcMask, final short dstMask) { diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index 8a24642031..21a18df9d3 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -37,7 +37,7 @@ public class OF13MatchSerializer implements OFSerializer, SerializerRegis private SerializerRegistry registry; @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { if (match == null) { LOG.debug("Match is null"); return; @@ -56,7 +56,7 @@ public class OF13MatchSerializer implements OFSerializer, SerializerRegis } } - private static void serializeType(Match match, ByteBuf out) { + private static void serializeType(final Match match, final ByteBuf out) { if (match.getType().isAssignableFrom(StandardMatchType.class)) { out.writeShort(STANDARD_MATCH_TYPE_CODE); } else if (match.getType().isAssignableFrom(OxmMatchType.class)) { @@ -70,7 +70,7 @@ public class OF13MatchSerializer implements OFSerializer, SerializerRegis * @param matchEntries list of match entries (oxm_fields) * @param out output ByteBuf */ - public void serializeMatchEntries(List matchEntries, ByteBuf out) { + public void serializeMatchEntries(final List matchEntries, final ByteBuf out) { if (matchEntries == null) { LOG.debug("Match entries are null"); return; @@ -91,7 +91,7 @@ public class OF13MatchSerializer implements OFSerializer, SerializerRegis } @Override - public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { this.registry = serializerRegistry; } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 8637dbdeff..569b54e6e9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Creates KeyMakers. @@ -37,10 +38,10 @@ public final class TypeKeyMakerFactory { * @param version openflow wire version that shall be used in lookup key * @return lookup key */ - public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { + public static TypeKeyMaker createMatchEntriesKeyMaker(final short version) { + return new AbstractTypeKeyMaker<>(version) { @Override - public MatchEntrySerializerKey make(MatchEntry entry) { + public MatchEntrySerializerKey make(final MatchEntry entry) { MatchEntrySerializerKey key; key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), entry.getOxmMatchField()); @@ -61,17 +62,17 @@ public final class TypeKeyMakerFactory { * @param version openflow wire version that shall be used in lookup key * @return lookup key */ - public static TypeKeyMaker createActionKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { + public static TypeKeyMaker createActionKeyMaker(final short version) { + return new AbstractTypeKeyMaker<>(version) { @Override - public MessageTypeKey make(Action entry) { + public MessageTypeKey make(final Action entry) { if (entry.getExperimenterId() != null) { return new ActionSerializerKey<>(getVersion(), (Class) entry.getActionChoice().implementedInterface(), entry.getExperimenterId().getValue()); } return new ActionSerializerKey<>(getVersion(), - (Class) entry.getActionChoice().implementedInterface(), null); + (Class) entry.getActionChoice().implementedInterface(), (Uint32) null); } }; } @@ -82,14 +83,14 @@ public final class TypeKeyMakerFactory { * @param version openflow wire version that shall be used in lookup key * @return lookup key */ - public static TypeKeyMaker createInstructionKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { + public static TypeKeyMaker createInstructionKeyMaker(final short version) { + return new AbstractTypeKeyMaker<>(version) { @Override - public MessageTypeKey make(Instruction entry) { + public MessageTypeKey make(final Instruction entry) { if (entry.getExperimenterId() != null) { return new InstructionSerializerKey<>(getVersion(), (Class) entry.getInstructionChoice().implementedInterface(), - entry.getExperimenterId().getValue()); + entry.getExperimenterId().getValue().toJava()); } return new InstructionSerializerKey<>(getVersion(), (Class) entry.getInstructionChoice().implementedInterface(), null); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java index 29b1e27f97..dab75a726b 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java @@ -30,6 +30,7 @@ import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test counters for encoding (at least DS_ENCODE_SUCCESS, DS_ENCODE_FAIL and DS_FLOW_MODS_SENT counters have to @@ -83,7 +84,7 @@ public class OFEncoderStatisticsTest { when(mockOut.readableBytes()).thenReturn(1); when(wrapper.getMsg()).thenReturn(mockMsg); - when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); int count = 4; for (int i = 0; i < count; i++) { @@ -105,7 +106,7 @@ public class OFEncoderStatisticsTest { } when(mockOut.readableBytes()).thenReturn(1); when(wrapper.getMsg()).thenReturn(mockFlowModInput); - when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); int count = 4; for (int i = 0; i < count; i++) { @@ -128,7 +129,7 @@ public class OFEncoderStatisticsTest { when(wrapper.getMsg()).thenReturn(mockMsg); when(wrapper.getListener()).thenReturn(listener); - when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); doThrow(new IllegalArgumentException()).when(mockSerializationFactory).messageToBuffer(anyShort(), any(ByteBuf.class), any(DataObject.class)); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java index 1ef3ac8439..fbbc7464dd 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java @@ -28,6 +28,7 @@ import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListen import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Unit tests for OFEncoder. @@ -63,7 +64,7 @@ public class OFEncoderTest { public void testEncodeSuccess() throws Exception { when(mockOut.readableBytes()).thenReturn(1); when(wrapper.getMsg()).thenReturn(mockMsg); - when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); @@ -78,7 +79,7 @@ public class OFEncoderTest { public void testEncodeSerializationException() throws Exception { when(wrapper.getMsg()).thenReturn(mockMsg); when(wrapper.getListener()).thenReturn(listener); - when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); doThrow(new IllegalArgumentException()).when(mockSerializationFactory).messageToBuffer(anyShort(), any(ByteBuf.class), any(DataObject.class)); @@ -95,7 +96,7 @@ public class OFEncoderTest { public void testEncodeSerializesNoBytes() throws Exception { when(mockOut.readableBytes()).thenReturn(0); when(wrapper.getMsg()).thenReturn(mockMsg); - when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java index 4c412d8a85..ed94311827 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import static org.mockito.Mockito.doReturn; + import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; @@ -27,6 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for ChannelOutboundQueue02. @@ -53,6 +57,14 @@ public class ChannelOutboundQueue02Test { @Before public void setUp() { MockitoAnnotations.initMocks(this); + mockXid(echoInput); + mockXid(barrierInput); + mockXid(echoReplyInput); + mockXid(experimenterInput); + } + + private static void mockXid(final OfHeader message) { + doReturn(Uint32.ZERO).when(message).getXid(); } /** diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java index d9beb94582..7d83f776d7 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import static org.mockito.Mockito.doReturn; + import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; @@ -42,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for ConnectionAdapterImp02l. @@ -84,6 +87,22 @@ public class ConnectionAdapterImp02lTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); + mockXid(barrierInput); + mockXid(echoInput); + mockXid(echoReplyInput); + mockXid(getConfigInput); + mockXid(getFeaturesInput); + mockXid(getQueueConfigInput); + mockXid(groupModInput); + mockXid(roleRequestInput); + mockXid(setConfigInput); + mockXid(tableModInput); + mockXid(getAsyncInput); + mockXid(setAsyncInput); + } + + private static void mockXid(final OfHeader message) { + doReturn(Uint32.ZERO).when(message).getXid(); } /** diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java index 0ff43eeeae..1398d404c1 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import static org.mockito.Mockito.doReturn; + import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; @@ -42,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for ConnectionAdapterImpl02. @@ -84,6 +87,22 @@ public class ConnectionAdapterImpl02Test { @Before public void setUp() { MockitoAnnotations.initMocks(this); + mockXid(barrierInput); + mockXid(echoInput); + mockXid(echoReplyInput); + mockXid(getConfigInput); + mockXid(getFeaturesInput); + mockXid(getQueueConfigInput); + mockXid(groupModInput); + mockXid(roleRequestInput); + mockXid(setConfigInput); + mockXid(tableModInput); + mockXid(getAsyncInput); + mockXid(setAsyncInput); + } + + private static void mockXid(final OfHeader message) { + doReturn(Uint32.ZERO).when(message).getXid(); } /** diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java index 6feb94a072..d07ef20b82 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java @@ -7,6 +7,7 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; import com.google.common.cache.Cache; @@ -47,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; @@ -58,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test counters in ConnectionAdapter (at least DS_ENTERED_OFJAVA, DS_FLOW_MODS_ENTERED and US_MESSAGE_PASS counters @@ -109,10 +112,27 @@ public class ConnectionAdapterImplStatisticsTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); + mockXid(barrierInput); + mockXid(echoInput); + mockXid(echoReplyInput); + mockXid(getConfigInput); + mockXid(getFeaturesInput); + mockXid(getQueueConfigInput); + mockXid(groupModInput); + mockXid(roleRequestInput); + mockXid(setConfigInput); + mockXid(tableModInput); + mockXid(getAsyncInput); + mockXid(setAsyncInput); + statCounters = StatisticsCounters.getInstance(); statCounters.startCounting(false, 0); } + private static void mockXid(final OfHeader message) { + doReturn(Uint32.ZERO).when(message).getXid(); + } + /** * Disconnect adapter. * Stop counting after each test. diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java index 5f6268e08f..a32bd28bb5 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.junit.Assert; @@ -49,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for FlowModInputMessageFactory. @@ -78,10 +78,9 @@ public class FlowModInputMessageFactoryTest { + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00"); FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb); BufferHelper.checkHeaderV13(deserializedMessage); - byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; - Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie()); - byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 }; - Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask()); + Assert.assertEquals("Wrong cookie", Uint64.valueOf("FF01040106000701", 16), deserializedMessage.getCookie()); + Assert.assertEquals("Wrong cookie mask", Uint64.valueOf("FF05000009300030", 16), + deserializedMessage.getCookieMask()); Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId()); Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand()); Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue()); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java index 7b18e148cf..a38e074c1e 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java @@ -54,7 +54,7 @@ public class FlowRemovedMessageFactoryTest { BufferHelper.checkHeaderV13(builtByFactory); Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L); - Assert.assertTrue(builtByFactory.getPriority() == 0x03); + Assert.assertTrue(builtByFactory.getPriority().toJava() == 0x03); Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue()); Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId()); Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue()); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 2ee9174702..1be2c7c12f 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -5,11 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -63,6 +61,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.multipart.reply.port.stats._case.MultipartReplyPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -162,15 +161,9 @@ public class MultipartReplyMessageFactoryTest { Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getByteCount()); - Assert.assertEquals("Wrong flowCount", - 8, - message.getFlowCount().intValue()); + Assert.assertEquals("Wrong packetCount", Uint64.valueOf("FF01010101010101", 16), message.getPacketCount()); + Assert.assertEquals("Wrong byteCount", Uint64.valueOf("0F01010101010101", 16), message.getByteCount()); + Assert.assertEquals("Wrong flowCount", 8, message.getFlowCount().intValue()); } /** @@ -196,11 +189,9 @@ public class MultipartReplyMessageFactoryTest { MultipartReplyTable message = messageCase.getMultipartReplyTable(); Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); - Assert.assertEquals("Wrong lookupCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong lookupCount", Uint64.valueOf("FF01010101010101", 16), message.getTableStats().get(0).getLookupCount()); - Assert.assertEquals("Wrong matchedCount", - new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong matchedCount", Uint64.valueOf("AF01010101010101", 16), message.getTableStats().get(0).getMatchedCount()); } @@ -236,41 +227,29 @@ public class MultipartReplyMessageFactoryTest { MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong rxPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong rxPackets", Uint64.valueOf("FF01010101010101", 16), message.getPortStats().get(0).getRxPackets()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", Uint64.valueOf("FF02020202020202", 16), message.getPortStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong rxBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxBytes", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxBytes()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong rxDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxDropped", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxDropped()); - Assert.assertEquals("Wrong txDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txDropped", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getTxDropped()); - Assert.assertEquals("Wrong rxErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxErrors", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxErrors()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getTxErrors()); - Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxFrameErr", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxFrameErr()); - Assert.assertEquals("Wrong rxOverErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxOverErr", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxOverErr()); - Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxCrcErr", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxCrcErr()); - Assert.assertEquals("Wrong collisions", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong collisions", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getCollisions()); Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue()); @@ -300,14 +279,11 @@ public class MultipartReplyMessageFactoryTest { MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", Uint64.valueOf("FF02030203020302", 16), message.getQueueStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", Uint64.valueOf("FF02020202020202", 16), message.getQueueStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", Uint64.valueOf("FF02030203020302", 16), message.getQueueStats().get(0).getTxErrors()); Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue()); @@ -356,48 +332,36 @@ public class MultipartReplyMessageFactoryTest { MultipartReplyGroup message = messageCase.getMultipartReplyGroup(); Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(0).getByteCount()); Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetCountBucket", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCountBucket", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCountBucket", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount()); - Assert.assertEquals("Wrong packetCountBucket_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetCountBucket_2", Uint64.valueOf("FF02020202020202", 16), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteCountBucket_2", Uint64.valueOf("FF02020202020202", 16), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount()); Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue()); - Assert.assertEquals("Wrong packetCount_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount_2", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(1).getPacketCount()); - Assert.assertEquals("Wrong byteCount_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount_2", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(1).getByteCount()); Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetCountBucket_1.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCountBucket_1.2", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket_1.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCountBucket_1.2", Uint64.valueOf("FF01010101010101", 16), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount()); - Assert.assertEquals("Wrong packetCountBucket_2.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetCountBucket_2.2", Uint64.valueOf("FF02020202020202", 16), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket_2.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteCountBucket_2.2", Uint64.valueOf("FF02020202020202", 16), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount()); } @@ -434,33 +398,25 @@ public class MultipartReplyMessageFactoryTest { message.getMeterStats().get(0).getMeterId().getValue().intValue()); Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getPacketInCount()); - Assert.assertEquals("Wrong byteInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getByteInCount()); Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", Uint64.valueOf("FF02020202020202", 16), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", Uint64.valueOf("FF02020202020202", 16), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", Uint64.valueOf("FF03030303030303", 16), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", Uint64.valueOf("FF03030303030303", 16), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); } @@ -511,66 +467,50 @@ public class MultipartReplyMessageFactoryTest { message.getMeterStats().get(0).getMeterId().getValue().intValue()); Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getPacketInCount()); - Assert.assertEquals("Wrong byteInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getByteInCount()); Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", Uint64.valueOf("FF02020202020202", 16), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", Uint64.valueOf("FF02020202020202", 16), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", Uint64.valueOf("FF03030303030303", 16), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", Uint64.valueOf("FF03030303030303", 16), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); Assert.assertEquals("Wrong meterId", 8, message.getMeterStats().get(1).getMeterId().getValue().intValue()); Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(1).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(1).getPacketInCount()); - Assert.assertEquals("Wrong byteInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(1).getByteInCount()); Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(1).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(1).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", Uint64.valueOf("FF01010101010101", 16), message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", Uint64.valueOf("FF02020202020202", 16), message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", Uint64.valueOf("FF02020202020202", 16), message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", Uint64.valueOf("FF03030303030303", 16), message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", Uint64.valueOf("FF03030303030303", 16), message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount()); } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java index f66d11d78e..9312437a90 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.junit.Assert; @@ -35,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for OF10FlowModInputMessageFactory. @@ -61,8 +61,7 @@ public class OF10FlowModInputMessageFactoryTest { FlowModInput deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV10(deserializedMessage); Assert.assertEquals("Wrong Match", createMatch(), deserializedMessage.getMatchV10()); - byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; - Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie()); + Assert.assertEquals("Wrong cookie", Uint64.valueOf("FF01040106000701", 16), deserializedMessage.getCookie()); Assert.assertEquals("Wrong command", FlowModCommand.forValue(0), deserializedMessage.getCommand()); Assert.assertEquals("Idle Timeout", 12, deserializedMessage.getIdleTimeout().intValue()); Assert.assertEquals("Wrong Hard Timeout", 16, deserializedMessage.getHardTimeout().intValue()); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 571df6a428..a16e281405 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -35,6 +34,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.multipart.reply.port.stats._case.MultipartReplyPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for OF10StatsReplyMessageFactory. @@ -135,14 +135,11 @@ public class OF10StatsReplyMessageFactoryTest { Assert.assertEquals("Wrong priority", 4, message.getFlowStats().get(0).getPriority().intValue()); Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue()); Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue()); - Assert.assertEquals("Wrong cookie", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + Assert.assertEquals("Wrong cookie", Uint64.valueOf("FF01020304050607", 16), message.getFlowStats().get(0).getCookie()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + Assert.assertEquals("Wrong packetCount", Uint64.valueOf("FF01020304050607", 16), message.getFlowStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + Assert.assertEquals("Wrong byteCount", Uint64.valueOf("FF00000000000020", 16), message.getFlowStats().get(0).getByteCount()); Action action1 = message.getFlowStats().get(0).getAction().get(0); Assert.assertTrue("Wrong action type", action1.getActionChoice() instanceof OutputActionCase); @@ -172,12 +169,8 @@ public class OF10StatsReplyMessageFactoryTest { Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); - Assert.assertEquals("Wrong packet-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getPacketCount()); - Assert.assertEquals("Wrong byte-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), - message.getByteCount()); + Assert.assertEquals("Wrong packet-count", Uint64.valueOf("FF01020304050607", 16), message.getPacketCount()); + Assert.assertEquals("Wrong byte-count", Uint64.valueOf("FF00000000000020", 16), message.getByteCount()); Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } @@ -208,11 +201,9 @@ public class OF10StatsReplyMessageFactoryTest { Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue()); Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue()); Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); - Assert.assertEquals("Wrong lookupCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong lookupCount", Uint64.valueOf("FF01010101010101", 16), message.getTableStats().get(0).getLookupCount()); - Assert.assertEquals("Wrong matchedCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), + Assert.assertEquals("Wrong matchedCount", Uint64.valueOf("FF01010101010100", 16), message.getTableStats().get(0).getMatchedCount()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } @@ -239,41 +230,29 @@ public class OF10StatsReplyMessageFactoryTest { MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong rxPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong rxPackets", Uint64.valueOf("FF01010101010101", 16), message.getPortStats().get(0).getRxPackets()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", Uint64.valueOf("FF02020202020202", 16), message.getPortStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong rxBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxBytes", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxBytes()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong rxDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxDropped", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxDropped()); - Assert.assertEquals("Wrong txDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txDropped", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getTxDropped()); - Assert.assertEquals("Wrong rxErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxErrors", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxErrors()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getTxErrors()); - Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxFrameErr", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxFrameErr()); - Assert.assertEquals("Wrong rxOverErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxOverErr", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxOverErr()); - Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxCrcErr", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getRxCrcErr()); - Assert.assertEquals("Wrong collisions", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong collisions", Uint64.valueOf("FF02030203020302", 16), message.getPortStats().get(0).getCollisions()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } @@ -298,16 +277,12 @@ public class OF10StatsReplyMessageFactoryTest { MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", Uint64.valueOf("FF02030203020302", 16), message.getQueueStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", Uint64.valueOf("FF02020202020202", 16), message.getQueueStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", Uint64.valueOf("FF02030203020302", 16), message.getQueueStats().get(0).getTxErrors()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } - } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java index f33b0fa53d..ed3ab075d7 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.junit.Assert.assertEquals; + import io.netty.buffer.ByteBuf; -import java.math.BigInteger; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; @@ -20,6 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerR import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for RoleRequestInputMessageFactory. @@ -43,10 +44,9 @@ public class RoleRequestInputMessageFactoryTest { ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 ff 01 01 01 01 01 01 01"); RoleRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV13(deserializedMessage); - Assert.assertEquals("Wrong role", ControllerRole.forValue(2), deserializedMessage.getRole()); - byte[] generationId = new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; - Assert.assertEquals("Wrong generation Id", new BigInteger(1, generationId), - deserializedMessage.getGenerationId()); + assertEquals("Wrong role", ControllerRole.forValue(2), deserializedMessage.getRole()); + assertEquals("Wrong generation Id", Uint64.valueOf("FF01010101010101", 16), + deserializedMessage.getGenerationId()); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java index 317f8e9221..9091dbcc15 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -5,11 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -26,6 +24,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.yangtools.yang.common.Uint64; /** * Unit tests for MultipartReplyFlow. @@ -109,12 +108,9 @@ public class MultipartReplyFlowTest { Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01}), flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong cookie", Uint64.valueOf("FF01010101010101", 16), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", Uint64.valueOf("EF01010101010101", 16), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", Uint64.valueOf("7F01010101010101", 16), flowStats1.getByteCount()); Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); flowStats1 = message.getFlowStats().get(1); Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); @@ -124,12 +120,9 @@ public class MultipartReplyFlowTest { Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01}), flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong cookie", Uint64.valueOf("FF01010101010101", 16), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", Uint64.valueOf("EF01010101010101", 16), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", Uint64.valueOf("7F01010101010101", 16), flowStats1.getByteCount()); Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java index b7c35a0ec8..bb50970f1f 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Expe import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; 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.yangtools.yang.common.Uint32; /** * Unit tests for OF13SetFieldActionSerializer. @@ -62,7 +63,7 @@ public class OF13SetFieldActionSerializerTest { ser.injectSerializerRegistry(registry); final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping .ActionBuilder actionBuilder = new ActionBuilder(); - long experimenterId = 12L; + final Uint32 experimenterId = Uint32.valueOf(12L); ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder(); ExperimenterBuilder expBuilder = new ExperimenterBuilder(); expBuilder.setExperimenter(new ExperimenterId(experimenterId)); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index dbf907370d..4afa2c364e 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -51,6 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for FlowModInputMessageFactory. @@ -77,6 +78,7 @@ public class FlowModInputMessageFactoryTest { /** * Testing of {@link FlowModInputMessageFactory} for correct translation from POJO. */ + @SuppressWarnings("null") @Test public void testFlowModInputMessageFactory() throws Exception { FlowModInputBuilder builder = new FlowModInputBuilder(); @@ -169,10 +171,10 @@ public class FlowModInputMessageFactoryTest { BufferHelper.checkHeaderV13(out,(byte) 14, 128); cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookie); - Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie)); + Assert.assertEquals("Wrong cookie", message.getCookie(), Uint64.valueOf("FF01040106000701", 16)); cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookieMask); - Assert.assertEquals("Wrong cookieMask", message.getCookieMask(), new BigInteger(1, cookieMask)); + Assert.assertEquals("Wrong cookieMask", message.getCookieMask(), Uint64.valueOf("FF05000009300030", 16)); Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte()); Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte()); Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort()); @@ -223,7 +225,7 @@ public class FlowModInputMessageFactoryTest { } @SuppressWarnings("checkstyle:AbbreviationAsWordInName") - private static FlowModFlags createFlowModFlagsFromBitmap(int input) { + private static FlowModFlags createFlowModFlagsFromBitmap(final int input) { final Boolean _oFPFFSENDFLOWREM = (input & 1 << 0) > 0; final Boolean _oFPFFCHECKOVERLAP = (input & 1 << 1) > 0; final Boolean _oFPFFRESETCOUNTS = (input & 1 << 2) > 0; diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java index fd683b826b..027506e32c 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java @@ -176,6 +176,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.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for MultipartReplyMessageFactory. @@ -650,11 +651,11 @@ public class MultipartReplyMessageFactoryTest { MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder(); feature.setTypes(new GroupTypes(true, false, true, false)); feature.setCapabilities(new GroupCapabilities(true, false, true, true)); - List maxGroups = new ArrayList<>(); - maxGroups.add(1L); - maxGroups.add(2L); - maxGroups.add(3L); - maxGroups.add(4L); + List maxGroups = new ArrayList<>(); + maxGroups.add(Uint32.valueOf(1)); + maxGroups.add(Uint32.valueOf(2)); + maxGroups.add(Uint32.valueOf(3)); + maxGroups.add(Uint32.valueOf(4)); feature.setMaxGroups(maxGroups); feature.setActionsBitmap(createActionType()); featureCase.setMultipartReplyGroupFeatures(feature.build()); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java index 6aa2508d85..9fd128262e 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for PacketInMessageFactory. @@ -105,7 +106,7 @@ public class PacketInMessageFactoryTest { serializedBuffer.readUnsignedByte()); cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; serializedBuffer.readBytes(cookie); - Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie)); + Assert.assertEquals("Wrong cookie", message.getCookie(), Uint64.valueOf(new BigInteger(1, cookie))); Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort()); serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java index d23e8e17cc..563bf3e84a 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java @@ -22,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for RoleReplyMessageFactory. @@ -57,6 +58,6 @@ public class RoleReplyMessageFactoryTest { serializedBuffer.skipBytes(PADDING); byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; serializedBuffer.readBytes(genId); - Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId)); + Assert.assertEquals("Wrong generation ID", message.getGenerationId(), Uint64.valueOf(new BigInteger(1, genId))); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java index b274179559..057e83c8c5 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java @@ -23,6 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for RoleRequestInputMessageFactory. @@ -69,6 +70,6 @@ public class RoleRequestInputMessageFactoryTest { out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE); byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(genId); - Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId)); + Assert.assertEquals("Wrong generation ID", message.getGenerationId(), Uint64.valueOf(new BigInteger(1, genId))); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java index a2da310d82..85955bc120 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.util; import io.netty.buffer.ByteBuf; @@ -18,6 +17,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Helper class for buffers. @@ -26,7 +27,7 @@ import org.opendaylight.yangtools.yang.binding.DataContainer; */ public abstract class BufferHelper { - public static final Long DEFAULT_XID = 0x01020304L; + public static final Uint32 DEFAULT_XID = Uint32.valueOf(0x01020304L); private static final byte[] XID = new byte[] { 0x01, 0x02, 0x03, 0x04 }; /** @@ -36,7 +37,7 @@ public abstract class BufferHelper { * @return ByteBuf filled with OpenFlow protocol message without first 4 * bytes */ - public static ByteBuf buildBuffer(byte[] payload) { + public static ByteBuf buildBuffer(final byte[] payload) { ByteBuf bb = UnpooledByteBufAllocator.DEFAULT.buffer(); bb.writeBytes(XID); bb.writeBytes(payload); @@ -50,7 +51,7 @@ public abstract class BufferHelper { * @return ByteBuf filled with OpenFlow protocol message without first 4 * bytes */ - public static ByteBuf buildBuffer(String payload) { + public static ByteBuf buildBuffer(final String payload) { return buildBuffer(ByteBufUtils.hexStringToBytes(payload)); } @@ -74,7 +75,7 @@ public abstract class BufferHelper { * @param msgType type of received message * @param length expected length of message in header */ - public static void checkHeaderV13(ByteBuf input, byte msgType, int length) { + public static void checkHeaderV13(final ByteBuf input, final byte msgType, final int length) { checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID); } @@ -83,8 +84,8 @@ public abstract class BufferHelper { * * @param ofHeader OpenFlow protocol header */ - public static void checkHeaderV13(OfHeader ofHeader) { - checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID); + public static void checkHeaderV13(final OfHeader ofHeader) { + checkHeader(ofHeader, Uint8.valueOf(EncodeConstants.OF13_VERSION_ID)); } /** @@ -94,7 +95,7 @@ public abstract class BufferHelper { * @param msgType type of received message * @param length expected length of message in header */ - public static void checkHeaderV10(ByteBuf input, byte msgType, int length) { + public static void checkHeaderV10(final ByteBuf input, final byte msgType, final int length) { checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID); } @@ -103,15 +104,15 @@ public abstract class BufferHelper { * * @param ofHeader OpenFlow protocol header */ - public static void checkHeaderV10(OfHeader ofHeader) { - checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID); + public static void checkHeaderV10(final OfHeader ofHeader) { + checkHeader(ofHeader, Uint8.valueOf(EncodeConstants.OF10_VERSION_ID)); } - private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) { + private static void checkHeader(final ByteBuf input, final byte msgType, final int length, final Short version) { Assert.assertEquals("Wrong version", version, Short.valueOf(input.readByte())); Assert.assertEquals("Wrong type", msgType, input.readByte()); Assert.assertEquals("Wrong length", length, input.readUnsignedShort()); - Assert.assertEquals("Wrong Xid", DEFAULT_XID, Long.valueOf(input.readUnsignedInt())); + Assert.assertEquals("Wrong Xid", DEFAULT_XID, Uint32.valueOf(input.readUnsignedInt())); } /** @@ -120,7 +121,7 @@ public abstract class BufferHelper { * @param ofHeader OpenFlow protocol header * @param version OpenFlow protocol version */ - public static void checkHeader(OfHeader ofHeader, Short version) { + public static void checkHeader(final OfHeader ofHeader, final Uint8 version) { Assert.assertEquals("Wrong version", version, ofHeader.getVersion()); Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid()); } @@ -131,11 +132,11 @@ public abstract class BufferHelper { * @param builder builder * @param version wire protocol number used */ - public static void setupHeader(Object builder, int version) throws NoSuchMethodException, SecurityException, - IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public static void setupHeader(final Object builder, final int version) throws NoSuchMethodException, + IllegalAccessException, InvocationTargetException { Method method = builder.getClass().getMethod("setVersion", Short.class); method.invoke(builder, (short) version); - Method m2 = builder.getClass().getMethod("setXid", Long.class); + Method m2 = builder.getClass().getMethod("setXid", Uint32.class); m2.invoke(builder, BufferHelper.DEFAULT_XID); } @@ -146,7 +147,7 @@ public abstract class BufferHelper { * @param bb data input buffer * @return message decoded pojo */ - public static E deserialize(OFDeserializer decoder, ByteBuf bb) { + public static E deserialize(final OFDeserializer decoder, final ByteBuf bb) { return decoder.deserialize(bb); } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java index 1950b036db..ad1eb9d8d8 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java @@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKe import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for CodeKeyMakerFactory. @@ -57,7 +58,7 @@ public class CodeKeyMakerFactoryTest { Assert.assertNotNull("Null key", codeKey); MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0); - comparationKey.setExperimenterId(1L); + comparationKey.setExperimenterId(Uint32.ONE); Assert.assertEquals("Wrong key", comparationKey, codeKey); Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java index fd1b709bb3..f3b814bad3 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.util; import io.netty.buffer.ByteBuf; @@ -16,13 +15,14 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Super class for common stuff of deserialization factories tests. */ public abstract class DefaultDeserializerFactoryTest { - private DeserializerRegistry registry; + private final DeserializerRegistry registry; protected OFDeserializer factory; protected MessageCodeKey messageCodeKey; @@ -44,7 +44,7 @@ public abstract class DefaultDeserializerFactoryTest { OFDeserializer serializer = registry.getDeserializer( new MessageCodeKey(version, messageCodeKey.getMsgType(), messageCodeKey.getClazz())); T builtByFactory = BufferHelper.deserialize(serializer, bb); - BufferHelper.checkHeader((OfHeader) builtByFactory, version); + BufferHelper.checkHeader((OfHeader) builtByFactory, Uint8.valueOf(version)); } } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index c5bf615938..3438179831 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.util; import org.junit.Assert; @@ -36,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc 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.yangtools.yang.common.Uint32; /** * Unit tests for TypeKeyMakerFactory. @@ -59,7 +59,7 @@ public class TypeKeyMakerFactoryTest { Assert.assertNotNull("Null key", key); Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OutputActionCase.class, null), key); + OutputActionCase.class, (Uint32) null), key); } /** @@ -167,7 +167,7 @@ public class TypeKeyMakerFactoryTest { Assert.assertNotNull("Null key", key); MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class); - comparationKey.setExperimenterId(42L); + comparationKey.setExperimenterId(Uint32.valueOf(42L)); Assert.assertEquals("Wrong key", comparationKey, key); } diff --git a/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java b/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java index 3b87325a8b..d5a94d778a 100644 --- a/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java +++ b/openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java @@ -5,12 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.it.integration; import com.google.common.util.concurrent.SettableFuture; import java.net.InetAddress; -import java.util.Arrays; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -136,9 +134,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan RpcResult rpcResult = adapter.getFeatures( featuresInput).get(2500, TimeUnit.MILLISECONDS); if (rpcResult.isSuccessful()) { - byte[] byteArray = rpcResult.getResult().getDatapathId() - .toByteArray(); - LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray)); + LOGGER.debug("DatapathId: {}", rpcResult.getResult().getDatapathId()); } else { RpcError rpcError = rpcResult.getErrors().iterator().next(); LOGGER.warn("rpcResult failed", rpcError.getCause()); diff --git a/openflowjava/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index a7c83ade56..4c85aa6dd9 100644 --- a/openflowjava/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/openflowjava/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -131,7 +131,7 @@ public abstract class ByteBufUtils { */ public static void writeOFHeader(final byte msgType, final E message, final ByteBuf out, final int length) { - out.writeByte(message.getVersion()); + out.writeByte(message.getVersion().toJava()); out.writeByte(msgType); out.writeShort(length); out.writeInt(message.getXid().intValue()); diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java index 92069150a4..07b43308f7 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java @@ -8,11 +8,14 @@ package org.opendaylight.openflowplugin.api; import com.google.common.collect.ImmutableList; -import java.math.BigInteger; import java.util.List; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; 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.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * OFP related constants. @@ -24,11 +27,11 @@ public final class OFConstants { } /** enum ofp_port_no, reserved port: process with normal L2/L3 switching. */ - public static final short OFPP_NORMAL = ((short)0xfffa); + public static final short OFPP_NORMAL = (short)0xfffa; /** enum ofp_port_no, reserved port: all physical ports except input port. */ - public static final short OFPP_ALL = ((short)0xfffc); + public static final short OFPP_ALL = (short)0xfffc; /** enum ofp_port_no, reserved port: local openflow port. */ - public static final short OFPP_LOCAL = ((short)0xfffe); + public static final short OFPP_LOCAL = (short)0xfffe; /** openflow protocol 1.0 - version identifier. */ public static final short OFP_VERSION_1_0 = 0x01; @@ -38,31 +41,31 @@ public final class OFConstants { public static final String OF_URI_PREFIX = "openflow:"; /** enum ofp_table: Table numbering, wildcard table used for table config, flow stats and flow deletes. */ - public static final Short OFPTT_ALL = 0xff; - public static final Long ANY = 0xffffffffL; + public static final Uint8 OFPTT_ALL = Uint8.MAX_VALUE; + public static final Uint32 ANY = Uint32.MAX_VALUE; /** Wildcard port used only for flow mod (delete) and flow stats requests. Selects * all flows regardless of output port (including flows with no output port).*/ - public static final Long OFPP_ANY = ANY; + public static final Uint32 OFPP_ANY = ANY; /** enum ofp_group: For OFPFC_DELETE* commands, require matching entries to include this as an * output group. A value of OFPG_ANY indicates no restriction. */ - public static final Long OFPG_ANY = ANY; + public static final Uint32 OFPG_ANY = ANY; /** enum ofp_group: Represents all groups for group delete commands. */ - public static final Long OFPG_ALL = 0xfffffffcL; + public static final Uint32 OFPG_ALL = Uint32.valueOf(0xfffffffcL).intern(); /** Refers to all queues configured at the specified port. */ - public static final Long OFPQ_ALL = ANY; + public static final Uint32 OFPQ_ALL = ANY; /** Represents all meters for stat requests commands. */ - public static final Long OFPM_ALL = ANY; + public static final Uint32 OFPM_ALL = ANY; /** Default cookie. */ - public static final BigInteger DEFAULT_COOKIE = BigInteger.ZERO; - public static final BigInteger DEFAULT_COOKIE_MASK = BigInteger.ZERO; + public static final Uint64 DEFAULT_COOKIE = Uint64.ZERO; + public static final Uint64 DEFAULT_COOKIE_MASK = Uint64.ZERO; public static final FlowCookie DEFAULT_FLOW_COOKIE = new FlowCookie(DEFAULT_COOKIE); - public static final Integer DEFAULT_FLOW_PRIORITY = 0x8000; + public static final Uint16 DEFAULT_FLOW_PRIORITY = Uint16.valueOf(0x8000).intern(); /** Empty flow match. */ public static final Match EMPTY_MATCH = new MatchBuilder().build(); /** indicates that no buffering should be applied and the whole packet is to be * sent to the controller. */ - public static final Long OFP_NO_BUFFER = 0xffffffffL; + public static final Uint32 OFP_NO_BUFFER = Uint32.valueOf(0xffffffffL).intern(); /** enum ofp_controller_max_len: indicates that no buffering should be applied and the whole packet is to be * sent to the controller. */ public static final Integer OFPCML_NO_BUFFER = 0xffff; diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java index b584655c1a..b28329f8b2 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceInfo.java @@ -5,15 +5,14 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.api.openflow.device; -import java.math.BigInteger; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint64; /** * API defining basic device information. @@ -42,7 +41,7 @@ public interface DeviceInfo extends XidSequencer { * Getter. * @return datapathId */ - BigInteger getDatapathId(); + Uint64 getDatapathId(); /** * Getter. diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/Xid.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/Xid.java index 74adb6cff9..e39f514887 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/Xid.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/Xid.java @@ -5,19 +5,20 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.api.openflow.device; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + +import org.opendaylight.yangtools.yang.common.Uint32; public final class Xid { - private final Long value; + private final Uint32 value; - public Xid(final Long value) { - this.value = Preconditions.checkNotNull(value); + public Xid(final Uint32 value) { + this.value = requireNonNull(value); } - public Long getValue() { + public Uint32 getValue() { return value; } diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/util/OpenflowVersion.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/util/OpenflowVersion.java index 99d7cc8d00..ca315493f0 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/util/OpenflowVersion.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/util/OpenflowVersion.java @@ -8,6 +8,11 @@ package org.opendaylight.openflowplugin.api.openflow.md.util; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import java.util.Arrays; +import org.opendaylight.yangtools.yang.common.Uint8; + /** * List of Openflow versions supported by the plugin. * Note: If you add a version here, @@ -20,6 +25,8 @@ public enum OpenflowVersion { OF13((short)0x04), UNSUPPORTED((short)0x00); + private static final ImmutableMap VERSIONS = Maps.uniqueIndex(Arrays.asList(values()), + ver -> Uint8.valueOf(ver.version)); private short version; @@ -27,6 +34,11 @@ public enum OpenflowVersion { this.version = version; } + public static OpenflowVersion get(final Uint8 version) { + final OpenflowVersion ver = VERSIONS.get(version); + return ver != null ? ver : UNSUPPORTED; + } + public static OpenflowVersion get(final Short version) { for (final OpenflowVersion ofv : OpenflowVersion.values()) { if (ofv.version == version) { diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowRegistryKey.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowRegistryKey.java index 7a3869a243..74eee663d6 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowRegistryKey.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowRegistryKey.java @@ -5,11 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.api.openflow.registry.flow; -import java.math.BigInteger; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Marker interface identifying flow stored in OFP local flow registry. @@ -21,7 +20,7 @@ public interface FlowRegistryKey { int getPriority(); - BigInteger getCookie(); + Uint64 getCookie(); Match getMatch(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java index 6162301f7c..bb522226ba 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java @@ -238,9 +238,9 @@ public class OpenFlowPluginProviderImpl implements // constructed threads when they are available. // Threads that have not been used for x seconds are terminated and removed from the cache. executorService = MoreExecutors.listeningDecorator(new ThreadPoolLoggingExecutor( - config.getThreadPoolMinThreads(), - config.getThreadPoolMaxThreads().getValue(), - config.getThreadPoolTimeout(), + config.getThreadPoolMinThreads().toJava(), + config.getThreadPoolMaxThreads().getValue().toJava(), + config.getThreadPoolTimeout().toJava(), TimeUnit.SECONDS, new SynchronousQueue<>(), POOL_NAME)); deviceManager = new DeviceManagerImpl( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/DeviceConnectionRateLimiter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/DeviceConnectionRateLimiter.java index 5d3862d557..aa1afb03fa 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/DeviceConnectionRateLimiter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/DeviceConnectionRateLimiter.java @@ -5,7 +5,6 @@ * terms of the 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.common; import com.google.common.util.concurrent.RateLimiter; @@ -13,13 +12,12 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; - public class DeviceConnectionRateLimiter { private final boolean doRateLimit; private final AtomicReference rateLimiter; public DeviceConnectionRateLimiter(final OpenflowProviderConfig config) { - int deviceConnectionRateLimitPerMin = config.getDeviceConnectionRateLimitPerMin(); + int deviceConnectionRateLimitPerMin = config.getDeviceConnectionRateLimitPerMin().toJava(); double rateLimiterSize; if (deviceConnectionRateLimitPerMin == 0) { doRateLimit = false; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java index a46b58d106..a1d0fdc087 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtil.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.impl.common; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -120,6 +119,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -271,7 +271,7 @@ public final class MultipartReplyTranslatorUtil { .reply.body.MultipartReplyPortStats translatePortStats( final MultipartReply msg, final OpenflowVersion ofVersion, - final BigInteger datapathId) { + final Uint64 datapathId) { MultipartReplyPortStatsBuilder message = new MultipartReplyPortStatsBuilder(); MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) msg.getMultipartReplyBody(); MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats(); @@ -494,7 +494,7 @@ public final class MultipartReplyTranslatorUtil { private static MultipartReplyQueueStats translateQueue(final MultipartReply msg, final OpenflowVersion ofVersion, - final BigInteger datapathId) { + final Uint64 datapathId) { MultipartReplyQueueStatsBuilder message = new MultipartReplyQueueStatsBuilder(); MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) msg.getMultipartReplyBody(); MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java index 61e04ac6f2..a7406aa058 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java @@ -13,6 +13,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; public class OpenFlowProviderConfigImpl implements OpenflowProviderConfig { private final ConfigurationService service; @@ -36,8 +38,8 @@ public class OpenFlowProviderConfigImpl implements OpenflowProviderConfig { } @Override - public Long getGlobalNotificationQuota() { - return service.getProperty(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString(), Long::valueOf); + public Uint32 getGlobalNotificationQuota() { + return service.getProperty(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString(), Uint32::valueOf); } @Override @@ -109,8 +111,8 @@ public class OpenFlowProviderConfigImpl implements OpenflowProviderConfig { } @Override - public Integer getThreadPoolMinThreads() { - return service.getProperty(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString(), Integer::valueOf); + public Uint16 getThreadPoolMinThreads() { + return service.getProperty(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString(), Uint16::valueOf); } @Override @@ -123,8 +125,8 @@ public class OpenFlowProviderConfigImpl implements OpenflowProviderConfig { } @Override - public Long getThreadPoolTimeout() { - return service.getProperty(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString(), Long::valueOf); + public Uint32 getThreadPoolTimeout() { + return service.getProperty(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString(), Uint32::valueOf); } @Override @@ -168,13 +170,13 @@ public class OpenFlowProviderConfigImpl implements OpenflowProviderConfig { @Override public > E augmentation( - java.lang.Class augmentationType) { + final java.lang.Class augmentationType) { return null; } @Override - public Integer getDeviceConnectionRateLimitPerMin() { + public Uint16 getDeviceConnectionRateLimitPerMin() { return service.getProperty(ConfigurationProperty.DEVICE_CONNECTION_RATE_LIMIT_PER_MIN.toString(), - Integer::valueOf); + Uint16::valueOf); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java index 03ad021192..d1d847d1fd 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java @@ -9,11 +9,9 @@ package org.opendaylight.openflowplugin.impl.connection; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Optional; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; @@ -31,6 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -124,11 +124,14 @@ public class ConnectionContextImpl implements ConnectionContext { private void disconnectDevice(final boolean propagate, final boolean forced) { final String device = nodeId != null ? nodeId.getValue() : getConnectionAdapter().getRemoteAddress().toString(); - final short auxiliaryId = Optional - .ofNullable(getFeatures()) - .flatMap(features -> Optional - .ofNullable(features.getAuxiliaryId())) - .orElse((short) 0); + + final Uint8 auxiliaryId; + if (featuresReply != null) { + final Uint8 id = featuresReply.getAuxiliaryId(); + auxiliaryId = id == null ? Uint8.ZERO : id; + } else { + auxiliaryId = Uint8.ZERO; + } if (connectionState == CONNECTION_STATE.RIP) { LOG.debug("Connection for device {} with auxiliary ID {} is already {}, so skipping closing.", @@ -163,7 +166,7 @@ public class ConnectionContextImpl implements ConnectionContext { private void propagateDeviceDisconnectedEvent() { if (deviceDisconnectedHandler != null) { - final BigInteger datapathId = featuresReply != null ? featuresReply.getDatapathId() : BigInteger.ZERO; + final Uint64 datapathId = featuresReply != null ? featuresReply.getDatapathId() : Uint64.ZERO; if (LOG.isDebugEnabled()) { LOG.debug("Propagating connection closed event: {}, datapathId:{}.", connectionAdapter.getRemoteAddress(), datapathId); @@ -184,7 +187,7 @@ public class ConnectionContextImpl implements ConnectionContext { @Override public void setOutboundQueueHandleRegistration( - OutboundQueueHandlerRegistration newRegistration) { + final OutboundQueueHandlerRegistration newRegistration) { this.outboundQueueHandlerRegistration = newRegistration; } @@ -249,12 +252,12 @@ public class ConnectionContextImpl implements ConnectionContext { } @Override - public void setHandshakeContext(HandshakeContext handshakeContext) { + public void setHandshakeContext(final HandshakeContext handshakeContext) { this.handshakeContext = handshakeContext; } @Override - public boolean equals(Object object) { + public boolean equals(final Object object) { if (this == object) { return true; } @@ -289,16 +292,16 @@ public class ConnectionContextImpl implements ConnectionContext { private final NodeId nodeId; private final KeyedInstanceIdentifier nodeII; - private final Short version; - private final BigInteger datapathId; + private final Uint8 version; + private final Uint64 datapathId; private final ServiceGroupIdentifier serviceGroupIdentifier; private OutboundQueue outboundQueueProvider; DeviceInfoImpl( final NodeId nodeId, final KeyedInstanceIdentifier nodeII, - final Short version, - final BigInteger datapathId, + final Uint8 version, + final Uint64 datapathId, final OutboundQueue outboundQueueProvider) { this.nodeId = nodeId; this.nodeII = nodeII; @@ -320,11 +323,11 @@ public class ConnectionContextImpl implements ConnectionContext { @Override public short getVersion() { - return version; + return version.toJava(); } @Override - public BigInteger getDatapathId() { + public Uint64 getDatapathId() { return datapathId; } @@ -334,7 +337,7 @@ public class ConnectionContextImpl implements ConnectionContext { } @Override - public boolean equals(Object object) { + public boolean equals(final Object object) { if (this == object) { return true; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java index 9188f6ae06..3507dd1edd 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java @@ -70,7 +70,7 @@ public class ConnectionManagerImpl implements ConnectionManager { connectionAdapter.setMessageListener(ofMessageListener); final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl( - connectionContext, config.getEchoReplyTimeout().getValue(), executorService); + connectionContext, config.getEchoReplyTimeout().getValue().toJava(), executorService); connectionAdapter.setSystemListener(systemListener); LOG.trace("connection ballet finished"); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImpl.java index c5c60efb75..0708eb14e9 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImpl.java @@ -31,6 +31,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,9 +70,11 @@ public class HandshakeManagerImpl implements HandshakeManager { * @param handshakeListener the HandshakeListener * @param useVersionBitmap should use negotiation bit map */ - public HandshakeManagerImpl(ConnectionAdapter connectionAdapter, Short highestVersion, List versionOrder, - ErrorHandler errorHandler, HandshakeListener handshakeListener, - boolean useVersionBitmap, DeviceConnectionRateLimiter deviceConnectionRateLimiter) { + public HandshakeManagerImpl(final ConnectionAdapter connectionAdapter, final Short highestVersion, + final List versionOrder, + final ErrorHandler errorHandler, final HandshakeListener handshakeListener, + final boolean useVersionBitmap, + final DeviceConnectionRateLimiter deviceConnectionRateLimiter) { this.highestVersion = highestVersion; this.versionOrder = versionOrder; this.connectionAdapter = connectionAdapter; @@ -82,7 +86,7 @@ public class HandshakeManagerImpl implements HandshakeManager { @Override @SuppressWarnings("checkstyle:IllegalCatch") - public synchronized void shake(HelloMessage receivedHello) { + public synchronized void shake(final HelloMessage receivedHello) { if (version != null) { // Some switches respond with a second HELLO acknowledging our HELLO @@ -105,9 +109,9 @@ public class HandshakeManagerImpl implements HandshakeManager { } // process the 2. and later hellos - Short remoteVersion = receivedHello.getVersion(); + Uint8 remoteVersion = receivedHello.getVersion(); List elements = receivedHello.getElements(); - setActiveXid(receivedHello.getXid()); + setActiveXid(receivedHello.getXid().toJava()); List remoteVersionBitmap = MessageFactory.digVersions(elements); LOG.debug("Hello message: version={}, xid={}, bitmap={}", remoteVersion, receivedHello.getXid(), remoteVersionBitmap); @@ -117,7 +121,7 @@ public class HandshakeManagerImpl implements HandshakeManager { handleVersionBitmapNegotiation(elements); } else { // versionBitmap missing at least on one side -> STEP-BY-STEP NEGOTIATION applying - handleStepByStepVersionNegotiation(remoteVersion); + handleStepByStepVersionNegotiation(remoteVersion.toJava()); } } catch (Exception ex) { errorHandler.handleException(ex); @@ -145,7 +149,7 @@ public class HandshakeManagerImpl implements HandshakeManager { ListenableFuture helloResult = sendHelloMessage(lastProposedVersion, nextHelloXid); Futures.addCallback(helloResult, new FutureCallback() { @Override - public void onSuccess(Void result) { + public void onSuccess(final Void result) { try { stepByStepVersionSubStep(remoteVersion); } catch (Exception e) { @@ -155,7 +159,7 @@ public class HandshakeManagerImpl implements HandshakeManager { } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { LOG.info("hello sending seriously failed [{}]", nextHelloXid); LOG.trace("detail of hello send problem", throwable); } @@ -165,7 +169,7 @@ public class HandshakeManagerImpl implements HandshakeManager { } } - private void stepByStepVersionSubStep(Short remoteVersion) { + private void stepByStepVersionSubStep(final Short remoteVersion) { if (remoteVersion >= lastProposedVersion) { postHandshake(lastProposedVersion, getNextXid()); LOG.trace("ret - OK - switch answered with lastProposedVersion"); @@ -188,7 +192,7 @@ public class HandshakeManagerImpl implements HandshakeManager { * @param remoteVersion remote version * @throws Exception exception */ - private void handleLowerVersionProposal(Short remoteVersion) { + private void handleLowerVersionProposal(final Short remoteVersion) { Short proposedVersion; // find the version from header version field proposedVersion = proposeNextVersion(remoteVersion); @@ -209,7 +213,7 @@ public class HandshakeManagerImpl implements HandshakeManager { * @param elements version elements * @throws Exception exception */ - private void handleVersionBitmapNegotiation(List elements) { + private void handleVersionBitmapNegotiation(final List elements) { final Short proposedVersion = proposeCommonBitmapVersion(elements); if (lastProposedVersion == null) { // first hello has not been sent yet @@ -217,13 +221,13 @@ public class HandshakeManagerImpl implements HandshakeManager { ListenableFuture helloDone = sendHelloMessage(proposedVersion, nexHelloXid); Futures.addCallback(helloDone, new FutureCallback() { @Override - public void onSuccess(Void result) { + public void onSuccess(final Void result) { LOG.trace("ret - DONE - versionBitmap"); postHandshake(proposedVersion, getNextXid()); } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { // NOOP } }, MoreExecutors.directExecutor()); @@ -239,7 +243,7 @@ public class HandshakeManagerImpl implements HandshakeManager { return activeXid; } - private void setActiveXid(Long xid) { + private void setActiveXid(final Long xid) { this.activeXid = xid; } @@ -248,7 +252,7 @@ public class HandshakeManagerImpl implements HandshakeManager { * * @param remoteVersion remove version */ - private void checkNegotiationStalling(Short remoteVersion) { + private void checkNegotiationStalling(final Short remoteVersion) { if (lastReceivedVersion != null && lastReceivedVersion.equals(remoteVersion)) { throw new IllegalStateException("version negotiation stalled: version = " + remoteVersion); } @@ -266,7 +270,7 @@ public class HandshakeManagerImpl implements HandshakeManager { * @param list bitmap list * @return proposed bitmap value */ - protected Short proposeCommonBitmapVersion(List list) { + protected Short proposeCommonBitmapVersion(final List list) { Short supportedHighestVersion = null; if (null != list && 0 != list.size()) { for (Elements element : list) { @@ -296,7 +300,7 @@ public class HandshakeManagerImpl implements HandshakeManager { * @param remoteVersion openflow version supported by remote entity * @return openflow version */ - protected short proposeNextVersion(short remoteVersion) { + protected short proposeNextVersion(final short remoteVersion) { Short proposal = null; for (short offer : versionOrder) { if (offer <= remoteVersion) { @@ -317,7 +321,7 @@ public class HandshakeManagerImpl implements HandshakeManager { * @param helloVersion initial hello version for openflow connection negotiation * @param helloXid transaction id */ - private ListenableFuture sendHelloMessage(Short helloVersion, final Long helloXid) { + private ListenableFuture sendHelloMessage(final Short helloVersion, final Long helloXid) { HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder); @@ -329,7 +333,7 @@ public class HandshakeManagerImpl implements HandshakeManager { Futures.addCallback(connectionAdapter.hello(helloInput), new FutureCallback>() { @Override - public void onSuccess(RpcResult result) { + public void onSuccess(final RpcResult result) { if (result.isSuccessful()) { LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress()); @@ -348,7 +352,7 @@ public class HandshakeManagerImpl implements HandshakeManager { } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage()); LOG.trace("DETAIL of sending of hello failure:", throwable); @@ -380,11 +384,13 @@ public class HandshakeManagerImpl implements HandshakeManager { Futures.addCallback(connectionAdapter.getFeatures(featuresBuilder.build()), new FutureCallback>() { @Override - public void onSuccess(RpcResult rpcFeatures) { + public void onSuccess(final RpcResult rpcFeatures) { LOG.trace("features are back"); if (rpcFeatures.isSuccessful()) { GetFeaturesOutput featureOutput = rpcFeatures.getResult(); - connectionAdapter.setDatapathId(featureOutput.getDatapathId()); + + final Uint64 dpId = featureOutput.getDatapathId(); + connectionAdapter.setDatapathId(dpId == null ? null : dpId.toJava()); if (!deviceConnectionRateLimiter.tryAquire()) { LOG.warn("Openflowplugin hit the device connection rate limit threshold. Denying" + " the connection from device {}", featureOutput.getDatapathId()); @@ -414,7 +420,7 @@ public class HandshakeManagerImpl implements HandshakeManager { } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { LOG.warn("getting feature failed seriously [{}, addr:{}]: {}", xid, connectionAdapter.getRemoteAddress(), throwable.getMessage()); LOG.trace("DETAIL of sending of hello failure:", throwable); @@ -429,7 +435,7 @@ public class HandshakeManagerImpl implements HandshakeManager { */ @VisibleForTesting @SuppressFBWarnings("IS2_INCONSISTENT_SYNC") // because shake() is synchronized - void setUseVersionBitmap(boolean useVersionBitmap) { + void setUseVersionBitmap(final boolean useVersionBitmap) { this.useVersionBitmap = useVersionBitmap; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java index 5aeefd1ab9..4ce5dca726 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java @@ -65,7 +65,7 @@ public class HandshakeListenerImpl implements HandshakeListener { } private FutureCallback> addBarrierCallback() { - return new FutureCallback>() { + return new FutureCallback<>() { @Override @SuppressWarnings("checkstyle:IllegalCatch") public void onSuccess(final RpcResult result) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java index 5084109fb1..7758173178 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java @@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.S import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +34,7 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe private static final Logger LOG = LoggerFactory.getLogger(SystemNotificationsListenerImpl.class); private static final Logger OF_EVENT_LOG = LoggerFactory.getLogger("OfEventLog"); - private static final Xid ECHO_XID = new Xid(0L); + private static final Xid ECHO_XID = new Xid(Uint32.ZERO); private final ConnectionContext connectionContext; @VisibleForTesting @@ -42,7 +43,7 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe private final ExecutorService executorService; public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext, - long echoReplyTimeout, + final long echoReplyTimeout, @Nonnull final ExecutorService executorService) { this.executorService = executorService; this.connectionContext = Preconditions.checkNotNull(connectionContext); @@ -113,7 +114,7 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe } } - private void logErrors(InetSocketAddress remoteAddress, RpcResult echoReplyValue) { + private void logErrors(final InetSocketAddress remoteAddress, final RpcResult echoReplyValue) { for (RpcError replyError : echoReplyValue.getErrors()) { Throwable cause = replyError.getCause(); if (LOG.isWarnEnabled()) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortDescMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortDescMultipartWriter.java index 23103b4c37..188c7942e2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortDescMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortDescMultipartWriter.java @@ -24,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +49,7 @@ public class PortDescMultipartWriter extends AbstractMultipartWriter { - long portNumber = OpenflowPortsUtil.getProtocolPortNumber( + Uint32 portNumber = OpenflowPortsUtil.getProtocolPortNumber( OpenflowVersion.get(features.getVersion()), stat.getPortNumber()); final NodeConnectorId id = InventoryDataServiceUtil diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java index 1fefc1fc34..d7ba87d282 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java @@ -22,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.N import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; public class PortStatsMultipartWriter extends AbstractMultipartWriter { @@ -44,11 +45,10 @@ public class PortStatsMultipartWriter extends AbstractMultipartWriter { final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion()); - final Long port = InventoryDataServiceUtil - .portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId()); + final Uint32 port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion, + stat.getNodeConnectorId()); - final NodeConnectorId id = InventoryDataServiceUtil - .nodeConnectorIdfromDatapathPortNo( + final NodeConnectorId id = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo( features.getDatapathId(), port, OpenflowVersion.get(features.getVersion())); @@ -60,7 +60,7 @@ public class PortStatsMultipartWriter extends AbstractMultipartWriter { @@ -49,7 +49,7 @@ public class QueueStatsMultipartWriter extends AbstractMultipartWriter { - final Long port = InventoryDataServiceUtil + final Uint32 port = InventoryDataServiceUtil .portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId()); final NodeConnectorId id = InventoryDataServiceUtil .nodeConnectorIdfromDatapathPortNo( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java index ae3e6e91c4..2d47d91dc4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java @@ -69,7 +69,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi private ExtensionConverterProvider extensionConverterProvider; private ScheduledThreadPoolExecutor spyPool; private ContextChainHolder contextChainHolder; - private QueuedNotificationManager queuedNotificationManager; + private final QueuedNotificationManager queuedNotificationManager; public DeviceManagerImpl(@Nonnull final OpenflowProviderConfig config, @Nonnull final DataBroker dataBroker, @@ -153,8 +153,8 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration = connectionContext.getConnectionAdapter().registerOutboundQueueHandler( outboundQueueProvider, - config.getBarrierCountLimit().getValue(), - TimeUnit.MILLISECONDS.toNanos(config.getBarrierIntervalTimeoutLimit().getValue())); + config.getBarrierCountLimit().getValue().toJava(), + TimeUnit.MILLISECONDS.toNanos(config.getBarrierIntervalTimeoutLimit().getValue().toJava())); connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration); @@ -192,7 +192,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi synchronized (updatePacketInRateLimitersLock) { final int deviceContextsSize = deviceContexts.size(); if (deviceContextsSize > 0) { - long freshNotificationLimit = config.getGlobalNotificationQuota() / deviceContextsSize; + long freshNotificationLimit = config.getGlobalNotificationQuota().toJava() / deviceContextsSize; if (freshNotificationLimit < 100) { freshNotificationLimit = 100; } @@ -227,7 +227,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi } @Override - public void setContextChainHolder(@Nonnull ContextChainHolder contextChainHolder) { + public void setContextChainHolder(@Nonnull final ContextChainHolder contextChainHolder) { this.contextChainHolder = contextChainHolder; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java index f8aa41a3c3..272b68f3d4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtil.java @@ -23,7 +23,7 @@ public final class SwitchFeaturesUtil { private static final Logger LOG = LoggerFactory.getLogger(SwitchFeaturesUtil.class); private static SwitchFeaturesUtil instance = new SwitchFeaturesUtil(); - private Map swFeaturesBuilders; + private final Map swFeaturesBuilders; private SwitchFeaturesUtil() { swFeaturesBuilders = new HashMap<>(); @@ -47,11 +47,11 @@ public final class SwitchFeaturesUtil { * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput} * @return switch features */ - public SwitchFeatures buildSwitchFeatures(GetFeaturesOutput features) { - if (swFeaturesBuilders.containsKey(features.getVersion())) { + public SwitchFeatures buildSwitchFeatures(final GetFeaturesOutput features) { + if (swFeaturesBuilders.containsKey(features.getVersion().toJava())) { LOG.debug("map contains version {}", features.getVersion()); try { - return swFeaturesBuilders.get(features.getVersion()).build(features); + return swFeaturesBuilders.get(features.getVersion().toJava()).build(features); } catch (NullPointerException e) { LOG.warn("error while building switch features: {}", e.getMessage()); LOG.debug("error while building switch features.. ", e); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java index 502b84e8ea..69b88f24a9 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java @@ -79,7 +79,7 @@ public class OF10DeviceInitializer extends AbstractDeviceInitializer { DeviceInitializationUtil.makeEmptyTables( deviceContext, deviceInfo, - deviceContext.getPrimaryConnectionContext().getFeatures().getTables()); + deviceContext.getPrimaryConnectionContext().getFeatures().getTables().toJava()); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializer.java index c954e0580e..0766a40df4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializer.java @@ -7,7 +7,6 @@ */ package org.opendaylight.openflowplugin.impl.device.initialization; -import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; @@ -81,13 +80,10 @@ public class OF13DeviceInitializer extends AbstractDeviceInitializer { return Futures.transform( switchFeaturesMandatory ? Futures.allAsList(futures) : Futures.successfulAsList(futures), - new Function>>, Void>() { - @Override - public Void apply(final List>> input) { - LOG.info("Static node {} successfully finished collecting", - deviceContext.getDeviceInfo()); - return null; - } + input1 -> { + LOG.info("Static node {} successfully finished collecting", + deviceContext.getDeviceInfo()); + return null; }, MoreExecutors.directExecutor()); }, MoreExecutors.directExecutor()); @@ -157,7 +153,7 @@ public class OF13DeviceInitializer extends AbstractDeviceInitializer { DeviceInitializationUtil.makeEmptyTables( deviceContext, deviceContext.getDeviceInfo(), - deviceContext.getPrimaryConnectionContext().getFeatures().getTables()); + deviceContext.getPrimaryConnectionContext().getFeatures().getTables().toJava()); } } } @@ -202,7 +198,7 @@ public class OF13DeviceInitializer extends AbstractDeviceInitializer { && translatedReply instanceof MeterFeatures) { final MeterFeatures meterFeatures = (MeterFeatures) translatedReply; - if (meterFeatures.getMaxMeter().getValue() > 0) { + if (meterFeatures.getMaxMeter().getValue().toJava() > 0) { deviceContext.getDeviceState().setMeterAvailable(true); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java index 24c076204e..11e21ce53c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java @@ -54,6 +54,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -149,9 +150,9 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker final DeviceInfo deviceInfo = connectionContext.getDeviceInfo(); final ContextChain contextChain = contextChainMap.get(deviceInfo); final FeaturesReply featuresReply = connectionContext.getFeatures(); - final Short auxiliaryId = featuresReply != null ? featuresReply.getAuxiliaryId() : null; + final Uint8 auxiliaryId = featuresReply != null ? featuresReply.getAuxiliaryId() : null; - if (auxiliaryId != null && auxiliaryId != 0) { + if (auxiliaryId != null && auxiliaryId.toJava() != 0) { if (contextChain == null) { LOG.warn("An auxiliary connection for device {}, but no primary connection. Refusing connection.", deviceInfo); @@ -280,7 +281,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker @Override @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") - public void ownershipChanged(EntityOwnershipChange entityOwnershipChange) { + public void ownershipChanged(final EntityOwnershipChange entityOwnershipChange) { if (entityOwnershipChange.getState().hasOwner()) { return; } @@ -306,13 +307,13 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker ListenableFuture future = deviceManager.removeDeviceFromOperationalDS(nodeInstanceIdentifier); Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(Object result) { + public void onSuccess(final Object result) { LOG.debug("Node removed from Oper DS, Node: {}", dpnId); OF_EVENT_LOG.debug("Node removed from Oper DS, Node: {}", dpnId); } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { LOG.error("Could not remove device {} from operational DS", dpnId, throwable); } }, MoreExecutors.directExecutor()); @@ -356,12 +357,11 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker LOG.debug("Context chain removed for node {}", deviceInfo); } - private FutureCallback reconciliationFrameworkCallback(@Nonnull DeviceInfo deviceInfo, - ContextChain contextChain, - ContextChainMastershipState mastershipState) { - return new FutureCallback() { + private FutureCallback reconciliationFrameworkCallback(@Nonnull final DeviceInfo deviceInfo, + final ContextChain contextChain, final ContextChainMastershipState mastershipState) { + return new FutureCallback<>() { @Override - public void onSuccess(ResultState result) { + public void onSuccess(final ResultState result) { if (ResultState.DONOTHING == result) { OF_EVENT_LOG.debug("Device {} connection is enabled by reconciliation framework", deviceInfo); LOG.info("Device {} connection is enabled by reconciliation framework.", deviceInfo); @@ -377,7 +377,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { OF_EVENT_LOG.debug("Reconciliation framework failure for device {} with error {}", deviceInfo, throwable.getMessage()); LOG.warn("Reconciliation framework failure."); @@ -386,7 +386,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker }; } - private String getDpnIdFromNodeName(String nodeName) { + private String getDpnIdFromNodeName(final String nodeName) { return nodeName.substring(nodeName.lastIndexOf(SEPARATOR) + 1); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java index f8500f8bcc..acd5e548e6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java @@ -159,8 +159,8 @@ public class ContextChainImpl implements ContextChain { } @Override - public boolean isMastered(@Nonnull ContextChainMastershipState mastershipState, - boolean inReconciliationFrameworkStep) { + public boolean isMastered(@Nonnull final ContextChainMastershipState mastershipState, + final boolean inReconciliationFrameworkStep) { switch (mastershipState) { case INITIAL_SUBMIT: LOG.debug("Device {}, initial submit OK.", deviceInfo); @@ -220,14 +220,14 @@ public class ContextChainImpl implements ContextChain { } @Override - public boolean addAuxiliaryConnection(@Nonnull ConnectionContext connectionContext) { - return connectionContext.getFeatures().getAuxiliaryId() != 0 + public boolean addAuxiliaryConnection(@Nonnull final ConnectionContext connectionContext) { + return connectionContext.getFeatures().getAuxiliaryId().toJava() != 0 && !ConnectionContext.CONNECTION_STATE.RIP.equals(primaryConnection.getConnectionState()) && auxiliaryConnections.add(connectionContext); } @Override - public boolean auxiliaryConnectionDropped(@Nonnull ConnectionContext connectionContext) { + public boolean auxiliaryConnectionDropped(@Nonnull final ConnectionContext connectionContext) { return auxiliaryConnections.remove(connectionContext); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java index 55b4594532..c14374373e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java @@ -63,6 +63,7 @@ import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.UdpSo import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.VlanPcpEntryDeserializer; import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.VlanVidEntryDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Util class for injecting new match entry deserializers into OpenflowJava. @@ -90,7 +91,7 @@ public final class MatchDeserializerInjector { deserializer); // Inject new match entry serializers here using injector created by createInjector method - final Function>>> injector = + final Function>>> injector = createInjector(deserializer, EncodeConstants.OF13_VERSION_ID); // Wrapped injector that uses OPENFLOW_BASIC_CLASS @@ -98,7 +99,7 @@ public final class MatchDeserializerInjector { injector.apply(OxmMatchConstants.OPENFLOW_BASIC_CLASS).apply(null); // Wrapped injector that uses EXPERIMENTER_CLASS - final Function>> experInjector = + final Function>> experInjector = injector.apply(OxmMatchConstants.EXPERIMENTER_CLASS); basicInjector.apply(OxmMatchConstants.ARP_OP).accept(new ArpOpEntryDeserializer()); @@ -157,7 +158,7 @@ public final class MatchDeserializerInjector { * @return injector */ @VisibleForTesting - static Function>>> createInjector( + static Function>>> createInjector( final MatchEntryDeserializerRegistry registry, final short version) { return oxmClass -> expId -> oxmField -> deserializer -> { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MatchDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MatchDeserializer.java index 093e701b2d..2fcf00cee3 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MatchDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MatchDeserializer.java @@ -23,6 +23,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtension 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; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +40,7 @@ public class MatchDeserializer implements OFDeserializer, HeaderDeseriali } @Override - public Match deserialize(ByteBuf inBuffer) { + public Match deserialize(final ByteBuf inBuffer) { if (inBuffer.readableBytes() <= 0) { return null; } @@ -67,14 +68,14 @@ public class MatchDeserializer implements OFDeserializer, HeaderDeseriali } @Override - public Match deserializeHeader(ByteBuf inBuffer) { + public Match deserializeHeader(final ByteBuf inBuffer) { final MatchBuilder builder = new MatchBuilder(); deserializeEntry(inBuffer, builder); return builder.build(); } @Override - public void deserializeEntry(ByteBuf inBuffer, MatchBuilder builder) { + public void deserializeEntry(final ByteBuf inBuffer, final MatchBuilder builder) { if (inBuffer.readableBytes() <= 0) { return; } @@ -90,7 +91,7 @@ public class MatchDeserializer implements OFDeserializer, HeaderDeseriali + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); + key.setExperimenterId(Uint32.valueOf(expId)); } final MatchEntryDeserializer entryDeserializer = entryRegistry.get(key); @@ -105,7 +106,8 @@ public class MatchDeserializer implements OFDeserializer, HeaderDeseriali } @Override - public void registerEntryDeserializer(MatchEntryDeserializerKey key, MatchEntryDeserializer deserializer) { + public void registerEntryDeserializer(final MatchEntryDeserializerKey key, + final MatchEntryDeserializer deserializer) { if (key == null || deserializer == null) { throw new IllegalArgumentException("MatchEntryDeserializerKey or Deserializer is null"); } @@ -119,7 +121,7 @@ public class MatchDeserializer implements OFDeserializer, HeaderDeseriali } @Override - public boolean unregisterEntryDeserializer(MatchEntryDeserializerKey key) { + public boolean unregisterEntryDeserializer(final MatchEntryDeserializerKey key) { if (key == null) { throw new IllegalArgumentException("MatchEntryDeserializerKey is null"); } @@ -128,7 +130,7 @@ public class MatchDeserializer implements OFDeserializer, HeaderDeseriali } @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + public void injectDeserializerRegistry(final DeserializerRegistry deserializerRegistry) { registry = deserializerRegistry; } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/PortMessageDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/PortMessageDeserializer.java index 0692e2851c..45a02f8eea 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/PortMessageDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/PortMessageDeserializer.java @@ -17,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.P import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni; +import org.opendaylight.yangtools.yang.common.Uint32; public class PortMessageDeserializer implements OFDeserializer { @@ -25,11 +26,11 @@ public class PortMessageDeserializer implements OFDeserializer { private static final byte PADDING_IN_PORT_MOD_MESSAGE_3 = 4; @Override - public PortMessage deserialize(ByteBuf message) { + public PortMessage deserialize(final ByteBuf message) { final PortMessageBuilder builder = new PortMessageBuilder() .setVersion((short) EncodeConstants.OF13_VERSION_ID) .setXid(message.readUnsignedInt()) - .setPortNumber(new PortNumberUni(message.readUnsignedInt())); + .setPortNumber(new PortNumberUni(Uint32.valueOf(message.readUnsignedInt()))); message.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1); builder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message)); @@ -41,33 +42,33 @@ public class PortMessageDeserializer implements OFDeserializer { return builder.build(); } - private static PortConfig readPortConfig(ByteBuf message) { + private static PortConfig readPortConfig(final ByteBuf message) { final long input = message.readUnsignedInt(); - final Boolean pcPortDown = ((input) & (1)) != 0; - final Boolean pcNRecv = ((input) & (1 << 2)) != 0; - final Boolean pcNFwd = ((input) & (1 << 5)) != 0; - final Boolean pcNPacketIn = ((input) & (1 << 6)) != 0; + final Boolean pcPortDown = (input & 1) != 0; + final Boolean pcNRecv = (input & 1 << 2) != 0; + final Boolean pcNFwd = (input & 1 << 5) != 0; + final Boolean pcNPacketIn = (input & 1 << 6) != 0; return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); } - private static PortFeatures readPortFeatures(ByteBuf message) { + private static PortFeatures readPortFeatures(final ByteBuf message) { final long input = message.readUnsignedInt(); - final Boolean pf10mbHd = ((input) & (1)) != 0; - final Boolean pf10mbFd = ((input) & (1 << 1)) != 0; - final Boolean pf100mbHd = ((input) & (1 << 2)) != 0; - final Boolean pf100mbFd = ((input) & (1 << 3)) != 0; - final Boolean pf1gbHd = ((input) & (1 << 4)) != 0; - final Boolean pf1gbFd = ((input) & (1 << 5)) != 0; - final Boolean pf10gbFd = ((input) & (1 << 6)) != 0; - final Boolean pf40gbFd = ((input) & (1 << 7)) != 0; - final Boolean pf100gbFd = ((input) & (1 << 8)) != 0; - final Boolean pf1tbFd = ((input) & (1 << 9)) != 0; - final Boolean pfOther = ((input) & (1 << 10)) != 0; - final Boolean pfCopper = ((input) & (1 << 11)) != 0; - final Boolean pfFiber = ((input) & (1 << 12)) != 0; - final Boolean pfAutoneg = ((input) & (1 << 13)) != 0; - final Boolean pfPause = ((input) & (1 << 14)) != 0; - final Boolean pfPauseAsym = ((input) & (1 << 15)) != 0; + final Boolean pf10mbHd = (input & 1) != 0; + final Boolean pf10mbFd = (input & 1 << 1) != 0; + final Boolean pf100mbHd = (input & 1 << 2) != 0; + final Boolean pf100mbFd = (input & 1 << 3) != 0; + final Boolean pf1gbHd = (input & 1 << 4) != 0; + final Boolean pf1gbFd = (input & 1 << 5) != 0; + final Boolean pf10gbFd = (input & 1 << 6) != 0; + final Boolean pf40gbFd = (input & 1 << 7) != 0; + final Boolean pf100gbFd = (input & 1 << 8) != 0; + final Boolean pf1tbFd = (input & 1 << 9) != 0; + final Boolean pfOther = (input & 1 << 10) != 0; + final Boolean pfCopper = (input & 1 << 11) != 0; + final Boolean pfFiber = (input & 1 << 12) != 0; + final Boolean pfAutoneg = (input & 1 << 13) != 0; + final Boolean pfPause = (input & 1 << 14) != 0; + final Boolean pfPauseAsym = (input & 1 << 15) != 0; return new PortFeatures( pfAutoneg, pfCopper, pfFiber, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java index 257f37471e..4fe339dd5f 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializer.java @@ -5,7 +5,6 @@ * terms of the 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.protocol.deserialization.multipart; import io.netty.buffer.ByteBuf; @@ -26,13 +25,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group 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.multipart.types.rev170112.multipart.reply.MultipartReplyBody; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartReplyGroupFeaturesDeserializer implements OFDeserializer { private static final int GROUP_TYPES = 4; @Override - public MultipartReplyBody deserialize(ByteBuf message) { + public MultipartReplyBody deserialize(final ByteBuf message) { final MultipartReplyGroupFeaturesBuilder builder = new MultipartReplyGroupFeaturesBuilder(); return builder @@ -40,23 +40,23 @@ public class MultipartReplyGroupFeaturesDeserializer implements OFDeserializer message.readUnsignedInt()) + .mapToObj(i -> Uint32.valueOf(message.readUnsignedInt())) .collect(Collectors.toList())) .setActions(IntStream .range(0, GROUP_TYPES) - .mapToObj(i -> message.readUnsignedInt()) + .mapToObj(i -> Uint32.valueOf(message.readUnsignedInt())) .collect(Collectors.toList())) .build(); } - private static List> readGroupCapabilities(ByteBuf message) { + private static List> readGroupCapabilities(final ByteBuf message) { final List> groupCapabilities = new ArrayList<>(); final long capabilitiesMask = message.readUnsignedInt(); - final boolean gcSelectWeight = ((capabilitiesMask) & (1 << 0)) != 0; - final boolean gcSelectLiveness = ((capabilitiesMask) & (1 << 1)) != 0; - final boolean gcChaining = ((capabilitiesMask) & (1 << 2)) != 0; - final boolean gcChainingChecks = ((capabilitiesMask) & (1 << 3)) != 0; + final boolean gcSelectWeight = (capabilitiesMask & 1 << 0) != 0; + final boolean gcSelectLiveness = (capabilitiesMask & 1 << 1) != 0; + final boolean gcChaining = (capabilitiesMask & 1 << 2) != 0; + final boolean gcChainingChecks = (capabilitiesMask & 1 << 3) != 0; if (gcSelectWeight) { groupCapabilities.add(SelectWeight.class); @@ -74,14 +74,14 @@ public class MultipartReplyGroupFeaturesDeserializer implements OFDeserializer> readGroupTypes(ByteBuf message) { + private static List> readGroupTypes(final ByteBuf message) { final List> groupTypes = new ArrayList<>(); final long typesMask = message.readUnsignedInt(); - final boolean gtAll = ((typesMask) & (1 << 0)) != 0; - final boolean gtSelect = ((typesMask) & (1 << 1)) != 0; - final boolean gtIndirect = ((typesMask) & (1 << 2)) != 0; - final boolean gtFF = ((typesMask) & (1 << 3)) != 0; + final boolean gtAll = (typesMask & 1 << 0) != 0; + final boolean gtSelect = (typesMask & 1 << 1) != 0; + final boolean gtIndirect = (typesMask & 1 << 2) != 0; + final boolean gtFF = (typesMask & 1 << 3) != 0; if (gtAll) { groupTypes.add(GroupAll.class); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortDescDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortDescDeserializer.java index c4d47f564c..1c9a81b937 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortDescDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortDescDeserializer.java @@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.m import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.PortsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartReplyPortDescDeserializer implements OFDeserializer { @@ -30,13 +31,13 @@ public class MultipartReplyPortDescDeserializer implements OFDeserializer items = new ArrayList<>(); while (message.readableBytes() > 0) { final PortsBuilder itemBuilder = new PortsBuilder(); - itemBuilder.setPortNumber(new PortNumberUni(message.readUnsignedInt())); + itemBuilder.setPortNumber(new PortNumberUni(Uint32.valueOf(message.readUnsignedInt()))); message.skipBytes(PADDING_IN_PORT_DESC_HEADER_01); itemBuilder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message)); message.skipBytes(PADDING_IN_PORT_DESC_HEADER_02); @@ -62,18 +63,18 @@ public class MultipartReplyPortDescDeserializer implements OFDeserializer items = new ArrayList<>(); @@ -107,14 +107,14 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer items = new ArrayList<>(); int tableFeaturesLength = length; int order = 0; @@ -278,7 +278,7 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer readMatchFields(ByteBuf message, int length) { + private List readMatchFields(final ByteBuf message, final int length) { final List matchFields = new ArrayList<>(); final int startIndex = message.readerIndex(); @@ -296,12 +296,12 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer readNextTableIds(ByteBuf message, int length) { - final List tableIds = new ArrayList<>(); + private static List readNextTableIds(final ByteBuf message, final int length) { + final List tableIds = new ArrayList<>(); int nextTableLength = length; while (nextTableLength > 0) { - tableIds.add(message.readUnsignedByte()); + tableIds.add(Uint8.valueOf(message.readUnsignedByte())); nextTableLength -= 1; } @@ -309,7 +309,7 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer readInstructions(ByteBuf message, int length) { + .Instruction> readInstructions(final ByteBuf message, final int length) { final List instructions = new ArrayList<>(); @@ -335,7 +335,7 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer readActions(ByteBuf message, int length) { + private List readActions(final ByteBuf message, final int length) { final List actions = new ArrayList<>(); final int startIndex = message.readerIndex(); int offset = 0; @@ -359,7 +359,7 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer deserialize(ByteBuf message) { + public Optional deserialize(final ByteBuf message) { int oxmClass = message.getUnsignedShort(message.readerIndex()); - int oxmField = message.getUnsignedByte(message.readerIndex() - + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - Long expId = null; + int oxmField = message.getUnsignedByte(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; + Uint32 expId = null; if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { - expId = message.getUnsignedInt(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES - + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + expId = Uint32.valueOf(message.getUnsignedInt(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES)); } final MatchEntryDeserializerKey key = diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java index 0b2b35be12..54e5cab1aa 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java @@ -5,7 +5,6 @@ * terms of the 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.protocol.serialization.actions; import com.google.common.base.MoreObjects; @@ -15,14 +14,16 @@ import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.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.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; public class OutputActionSerializer extends AbstractActionSerializer { @Override - public void serialize(OutputActionCase action, ByteBuf outBuffer) { + public void serialize(final OutputActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final OutputAction outputAction = action.getOutputAction(); - Long value = InventoryDataServiceUtil.portNumberfromNodeConnectorId( + Uint32 value = InventoryDataServiceUtil.portNumberfromNodeConnectorId( OpenflowVersion.OF13, outputAction.getOutputNodeConnector().getValue()); if (value == null) { @@ -30,7 +31,7 @@ public class OutputActionSerializer extends AbstractActionSerializer { @Override - public void serialize(PopMplsActionCase action, ByteBuf outBuffer) { + public void serialize(final PopMplsActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final PopMplsAction popMplsAction = action.getPopMplsAction(); - outBuffer.writeShort(popMplsAction.getEthernetType()); + outBuffer.writeShort(popMplsAction.getEthernetType().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java index 4ab4cab24a..5c11d1d172 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializer.java @@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti public class PushMplsActionSerializer extends AbstractActionSerializer { @Override - public void serialize(PushMplsActionCase action, ByteBuf outBuffer) { + public void serialize(final PushMplsActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final PushMplsAction pushMplsAction = action.getPushMplsAction(); - outBuffer.writeShort(pushMplsAction.getEthernetType()); + outBuffer.writeShort(pushMplsAction.getEthernetType().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java index 9432a8d5c4..7096d7fcd6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializer.java @@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti public class PushPbbActionSerializer extends AbstractActionSerializer { @Override - public void serialize(PushPbbActionCase action, ByteBuf outBuffer) { + public void serialize(final PushPbbActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final PushPbbAction pushPbbAction = action.getPushPbbAction(); - outBuffer.writeShort(pushPbbAction.getEthernetType()); + outBuffer.writeShort(pushPbbAction.getEthernetType().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java index 22e95e729c..30bf15d523 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializer.java @@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti public class PushVlanActionSerializer extends AbstractActionSerializer { @Override - public void serialize(PushVlanActionCase action, ByteBuf outBuffer) { + public void serialize(final PushVlanActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final PushVlanAction pushVlanAction = action.getPushVlanAction(); - outBuffer.writeShort(pushVlanAction.getEthernetType()); + outBuffer.writeShort(pushVlanAction.getEthernetType().toJava()); outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java index dff5193dce..b6b9f30f1d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializer.java @@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti public class SetMplsTtlActionSerializer extends AbstractActionSerializer { @Override - public void serialize(SetMplsTtlActionCase action, ByteBuf outBuffer) { + public void serialize(final SetMplsTtlActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final SetMplsTtlAction setMplsTtlAction = action.getSetMplsTtlAction(); - outBuffer.writeByte(setMplsTtlAction.getMplsTtl()); + outBuffer.writeByte(setMplsTtlAction.getMplsTtl().toJava()); outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java index 40a0c36619..d084b90c22 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializer.java @@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti public class SetNwTtlActionSerializer extends AbstractActionSerializer { @Override - public void serialize(SetNwTtlActionCase action, ByteBuf outBuffer) { + public void serialize(final SetNwTtlActionCase action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); final SetNwTtlAction setNwTtlAction = action.getSetNwTtlAction(); - outBuffer.writeByte(setNwTtlAction.getNwTtl()); + outBuffer.writeByte(setNwTtlAction.getNwTtl().toJava()); outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java index eed1ae0c27..f0d464ad1c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializer.java @@ -22,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class SetTpDstActionSerializer extends AbstractSetFieldActionSerializer { @Override - protected SetFieldCase buildAction(Action input) { + protected SetFieldCase buildAction(final Action input) { final SetTpDstAction setTpDstAction = ((SetTpDstActionCase) input).getSetTpDstAction(); final PortNumber port = setTpDstAction.getPort(); final SetFieldBuilder builder = new SetFieldBuilder(); @@ -31,13 +31,13 @@ public class SetTpDstActionSerializer extends AbstractSetFieldActionSerializer { switch (proto) { case ICMP: { builder.setIcmpv4Match(new Icmpv4MatchBuilder() - .setIcmpv4Code((short) (0xFF & port.getValue())) + .setIcmpv4Code((short) (0xFF & port.getValue().toJava())) .build()); break; } case ICMPV6: { builder.setIcmpv6Match(new Icmpv6MatchBuilder() - .setIcmpv6Code((short) (0xFF & port.getValue())) + .setIcmpv6Code((short) (0xFF & port.getValue().toJava())) .build()); break; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java index ea5a3a5030..cae8fe29ab 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializer.java @@ -22,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class SetTpSrcActionSerializer extends AbstractSetFieldActionSerializer { @Override - protected SetFieldCase buildAction(Action input) { + protected SetFieldCase buildAction(final Action input) { final SetTpSrcAction setTpSrcAction = ((SetTpSrcActionCase) input).getSetTpSrcAction(); final PortNumber port = setTpSrcAction.getPort(); final SetFieldBuilder builder = new SetFieldBuilder(); @@ -31,13 +31,13 @@ public class SetTpSrcActionSerializer extends AbstractSetFieldActionSerializer { switch (proto) { case ICMP: { builder.setIcmpv4Match(new Icmpv4MatchBuilder() - .setIcmpv4Type((short) (0xFF & port.getValue())) + .setIcmpv4Type((short) (0xFF & port.getValue().toJava())) .build()); break; } case ICMPV6: { builder.setIcmpv6Match(new Icmpv6MatchBuilder() - .setIcmpv6Type((short) (0xFF & port.getValue())) + .setIcmpv6Type((short) (0xFF & port.getValue().toJava())) .build()); break; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializer.java index 810459fab4..2575408d65 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializer.java @@ -15,9 +15,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru public class GoToTableInstructionSerializer extends AbstractInstructionSerializer { @Override - public void serialize(GoToTableCase input, ByteBuf outBuffer) { + public void serialize(final GoToTableCase input, final ByteBuf outBuffer) { super.serialize(input, outBuffer); - outBuffer.writeByte(input.getGoToTable().getTableId()); + outBuffer.writeByte(input.getGoToTable().getTableId().toJava()); outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializer.java index 70ffc9dc19..5b01a8b282 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializer.java @@ -5,11 +5,9 @@ * terms of the 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.protocol.serialization.instructions; import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase; @@ -18,14 +16,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer { @Override - public void serialize(WriteMetadataCase input, ByteBuf outBuffer) { + public void serialize(final WriteMetadataCase input, final ByteBuf outBuffer) { super.serialize(input, outBuffer); final WriteMetadata writeMetadata = input.getWriteMetadata(); outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); - outBuffer.writeBytes(ByteUtil - .convertBigIntegerToNBytes(writeMetadata.getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); - outBuffer.writeBytes(ByteUtil - .convertBigIntegerToNBytes(writeMetadata.getMetadataMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + // TODO: writeLong() should be faster + outBuffer.writeBytes(ByteUtil.uint64toBytes(writeMetadata.getMetadata())); + outBuffer.writeBytes(ByteUtil.uint64toBytes(writeMetadata.getMetadataMask())); } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializer.java index d490b2baa8..7766fe199f 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class ArpOpEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((ArpMatch) match.getLayer3Match()).getArpOp()); + outBuffer.writeShort(((ArpMatch) match.getLayer3Match()).getArpOp().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer3Match() != null && match.getLayer3Match() instanceof ArpMatch && ((ArpMatch) match.getLayer3Match()).getArpOp() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializer.java index d6c6cd04f9..f9d26208b0 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializer.java @@ -15,18 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class Icmpv4CodeEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getIcmpv4Match().getIcmpv4Code()); + outBuffer.writeByte(match.getIcmpv4Match().getIcmpv4Code().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIcmpv4Match() != null && match.getIcmpv4Match().getIcmpv4Code() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializer.java index 3190f7329a..e2a8f2fefb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializer.java @@ -16,18 +16,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class Icmpv4TypeEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getIcmpv4Match().getIcmpv4Type()); + outBuffer.writeByte(match.getIcmpv4Match().getIcmpv4Type().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIcmpv4Match() != null && match.getIcmpv4Match().getIcmpv4Type() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializer.java index e0a97b6851..ad5758c920 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializer.java @@ -15,18 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class Icmpv6CodeEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getIcmpv6Match().getIcmpv6Code()); + outBuffer.writeByte(match.getIcmpv6Match().getIcmpv6Code().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIcmpv6Match() != null && match.getIcmpv6Match().getIcmpv6Code() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializer.java index 38712b0489..053957bf71 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializer.java @@ -15,18 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class Icmpv6TypeEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getIcmpv6Match().getIcmpv6Type()); + outBuffer.writeByte(match.getIcmpv6Match().getIcmpv6Type().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIcmpv6Match() != null && match.getIcmpv6Match().getIcmpv6Type() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/InPortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/InPortEntrySerializer.java index 34f2ab62af..3da5a892ba 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/InPortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/InPortEntrySerializer.java @@ -13,13 +13,14 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; +import org.opendaylight.yangtools.yang.common.Uint32; public class InPortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - Long value = InventoryDataServiceUtil.portNumberfromNodeConnectorId( + Uint32 value = InventoryDataServiceUtil.portNumberfromNodeConnectorId( OpenflowVersion.OF13, match.getInPort().getValue()); if (value == null) { @@ -29,12 +30,12 @@ public class InPortEntrySerializer extends AbstractMatchEntrySerializer { } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getInPort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializer.java index 536f481a5e..872315f17f 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializer.java @@ -16,18 +16,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class IpDscpEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getIpMatch().getIpDscp().getValue()); + outBuffer.writeByte(match.getIpMatch().getIpDscp().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIpMatch() != null && match.getIpMatch().getIpDscp() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializer.java index 31544f928c..b1dc4262a6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializer.java @@ -15,18 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class IpEcnEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getIpMatch().getIpEcn()); + outBuffer.writeByte(match.getIpMatch().getIpEcn().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIpMatch() != null && match.getIpMatch().getIpEcn() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializer.java index cc479639f5..18c9b99e25 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializer.java @@ -15,19 +15,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class IpProtoEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); // TODO: What is getIpMatch().getIpProto()? Fix models probably - outBuffer.writeByte(match.getIpMatch().getIpProtocol()); + outBuffer.writeByte(match.getIpMatch().getIpProtocol().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getIpMatch() != null && match.getIpMatch().getIpProtocol() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializer.java index e895b13443..b4ca636972 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializer.java @@ -18,10 +18,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class Ipv6ExtHeaderEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); final Ipv6ExtHeader ipv6ExtHeader = ((Ipv6Match) match.getLayer3Match()).getIpv6ExtHeader(); - outBuffer.writeShort(ipv6ExtHeader.getIpv6Exthdr()); + outBuffer.writeShort(ipv6ExtHeader.getIpv6Exthdr().toJava()); if (getHasMask(match)) { writeMask(ByteUtil.unsignedShortToBytes( @@ -32,14 +32,14 @@ public class Ipv6ExtHeaderEntrySerializer extends AbstractMatchEntrySerializer { } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer3Match() != null && match.getLayer3Match() instanceof Ipv6Match && ((Ipv6Match) match.getLayer3Match()).getIpv6ExtHeader() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return ((Ipv6Match) match.getLayer3Match()).getIpv6ExtHeader().getIpv6ExthdrMask() != null; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializer.java index 1cff209903..1f024a89d1 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializer.java @@ -16,28 +16,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class MetadataEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeBytes(ByteUtil.convertBigIntegerToNBytes( - match.getMetadata().getMetadata(), - getValueLength())); + // TODO: writeLong() should be faster + outBuffer.writeBytes(ByteUtil.uint64toBytes(match.getMetadata().getMetadata())); if (getHasMask(match)) { - writeMask(ByteUtil.convertBigIntegerToNBytes( - match.getMetadata().getMetadataMask(), - getValueLength()), + // TODO: writeLong() should be faster + writeMask(ByteUtil.uint64toBytes(match.getMetadata().getMetadataMask()), outBuffer, getValueLength()); } } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getMetadata() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return match.getMetadata().getMetadataMask() != null; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializer.java index ac4871002e..715fb5135c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializer.java @@ -15,18 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class MplsBosEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeBoolean(match.getProtocolMatchFields().getMplsBos() != 0); + outBuffer.writeBoolean(match.getProtocolMatchFields().getMplsBos().toJava() != 0); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getProtocolMatchFields() != null && match.getProtocolMatchFields().getMplsBos() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializer.java index 9b04dc7da6..cac7e16a19 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializer.java @@ -15,18 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class MplsTcEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getProtocolMatchFields().getMplsTc()); + outBuffer.writeByte(match.getProtocolMatchFields().getMplsTc().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getProtocolMatchFields() != null && match.getProtocolMatchFields().getMplsTc() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializer.java index fb21ddb8a6..0b36f6cda3 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class SctpDestinationPortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((SctpMatch) match.getLayer4Match()).getSctpDestinationPort().getValue()); + outBuffer.writeShort(((SctpMatch) match.getLayer4Match()).getSctpDestinationPort().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer4Match() != null && match.getLayer4Match() instanceof SctpMatch && ((SctpMatch) match.getLayer4Match()).getSctpDestinationPort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializer.java index 6d57090c60..36b25d9675 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class SctpSourcePortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((SctpMatch) match.getLayer4Match()).getSctpSourcePort().getValue()); + outBuffer.writeShort(((SctpMatch) match.getLayer4Match()).getSctpSourcePort().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer4Match() != null && match.getLayer4Match() instanceof SctpMatch && ((SctpMatch) match.getLayer4Match()).getSctpSourcePort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializer.java index cda79f3574..312082709c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class TcpDestinationPortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((TcpMatch) match.getLayer4Match()).getTcpDestinationPort().getValue()); + outBuffer.writeShort(((TcpMatch) match.getLayer4Match()).getTcpDestinationPort().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer4Match() != null && match.getLayer4Match() instanceof TcpMatch && ((TcpMatch) match.getLayer4Match()).getTcpDestinationPort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializer.java index 419e8765ec..20cb370047 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializer.java @@ -17,9 +17,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class TcpFlagsEntrySerializer extends AbstractExperimenterMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(match.getTcpFlagsMatch().getTcpFlags()); + outBuffer.writeShort(match.getTcpFlagsMatch().getTcpFlags().toJava()); if (getHasMask(match)) { writeMask(ByteUtil.unsignedShortToBytes( @@ -30,18 +30,18 @@ public class TcpFlagsEntrySerializer extends AbstractExperimenterMatchEntrySeria } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getTcpFlagsMatch() != null && match.getTcpFlagsMatch().getTcpFlags() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return match.getTcpFlagsMatch().getTcpFlagsMask() != null; } @Override protected long getExperimenterId() { - return EncodeConstants.ONF_EXPERIMENTER_ID; + return EncodeConstants.ONF_EXPERIMENTER_ID.toJava(); } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializer.java index 7dedd65c28..2eb35a8d4b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class TcpSourcePortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((TcpMatch) match.getLayer4Match()).getTcpSourcePort().getValue()); + outBuffer.writeShort(((TcpMatch) match.getLayer4Match()).getTcpSourcePort().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer4Match() != null && match.getLayer4Match() instanceof TcpMatch && ((TcpMatch) match.getLayer4Match()).getTcpSourcePort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializer.java index afcb8f892c..a3c753aed6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializer.java @@ -16,25 +16,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class TunnelIdEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeBytes(ByteUtil.convertBigIntegerToNBytes(match.getTunnel().getTunnelId(), getValueLength())); - + // TODO: writeLong() should be faster + outBuffer.writeBytes(ByteUtil.uint64toBytes(match.getTunnel().getTunnelId())); if (getHasMask(match)) { - writeMask(ByteUtil.convertBigIntegerToNBytes( - match.getTunnel().getTunnelMask(), getValueLength()), - outBuffer, - getValueLength()); + writeMask(ByteUtil.uint64toBytes(match.getTunnel().getTunnelMask()), outBuffer, getValueLength()); } } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getTunnel() != null && match.getTunnel().getTunnelId() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return match.getTunnel().getTunnelMask() != null; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializer.java index 520491326e..627e9644d8 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class UdpDestinationPortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((UdpMatch) match.getLayer4Match()).getUdpDestinationPort().getValue()); + outBuffer.writeShort(((UdpMatch) match.getLayer4Match()).getUdpDestinationPort().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer4Match() != null && match.getLayer4Match() instanceof UdpMatch && ((UdpMatch) match.getLayer4Match()).getUdpDestinationPort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializer.java index ea9e651c2b..2f12572fbf 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializer.java @@ -16,20 +16,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class UdpSourcePortEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeShort(((UdpMatch) match.getLayer4Match()).getUdpSourcePort().getValue()); + outBuffer.writeShort(((UdpMatch) match.getLayer4Match()).getUdpSourcePort().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getLayer4Match() != null && match.getLayer4Match() instanceof UdpMatch && ((UdpMatch) match.getLayer4Match()).getUdpSourcePort() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializer.java index e3be094e2c..519438c79d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializer.java @@ -16,18 +16,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 public class VlanPcpEntrySerializer extends AbstractMatchEntrySerializer { @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); - outBuffer.writeByte(match.getVlanMatch().getVlanPcp().getValue()); + outBuffer.writeByte(match.getVlanMatch().getVlanPcp().getValue().toJava()); } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getVlanMatch() != null && match.getVlanMatch().getVlanPcp() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { return false; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializer.java index f34fd6ac2b..e053c12b35 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializer.java @@ -17,12 +17,12 @@ public class VlanVidEntrySerializer extends AbstractMatchEntrySerializer { private static final byte[] VLAN_VID_MASK = new byte[]{16, 0}; @Override - public void serialize(Match match, ByteBuf outBuffer) { + public void serialize(final Match match, final ByteBuf outBuffer) { super.serialize(match, outBuffer); final org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanId = match.getVlanMatch().getVlanId().getVlanId(); - int vlanVidValue = vlanId != null ? vlanId.getValue() : 0; + int vlanVidValue = vlanId != null ? vlanId.getValue().toJava() : 0; if (Boolean.TRUE.equals(match.getVlanMatch().getVlanId().isVlanIdPresent())) { short cfi = 1 << 12; @@ -37,15 +37,15 @@ public class VlanVidEntrySerializer extends AbstractMatchEntrySerializer { } @Override - public boolean matchTypeCheck(Match match) { + public boolean matchTypeCheck(final Match match) { return match.getVlanMatch() != null && match.getVlanMatch().getVlanId() != null; } @Override - protected boolean getHasMask(Match match) { + protected boolean getHasMask(final Match match) { final VlanId vlanId = match.getVlanMatch().getVlanId(); return Boolean.TRUE.equals(vlanId.isVlanIdPresent()) - && (vlanId.getVlanId() == null || vlanId.getVlanId().getValue() == 0); + && (vlanId.getVlanId() == null || vlanId.getVlanId().getValue().toJava() == 0); } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java index 0a86bc0e07..81ea0e38f6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java @@ -5,13 +5,11 @@ * terms of the 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.protocol.serialization.messages; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -57,6 +55,10 @@ 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.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.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Translates FlowMod messages. @@ -66,16 +68,18 @@ public class FlowMessageSerializer extends AbstractMessageSerializer>getSerializer( - new MessageTypeKey<>(message.getVersion(), Match.class)).serialize(message.getMatch(), outBuffer); + new MessageTypeKey<>(message.getVersion().toJava(), Match.class)).serialize(message.getMatch(), + outBuffer); } @@ -179,7 +184,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer protocol = Optional + final Optional protocol = Optional .ofNullable(message.getMatch()) .flatMap(m -> Optional.ofNullable(m.getIpMatch())) .flatMap(ipm -> Optional.ofNullable(ipm.getIpProtocol())); @@ -187,8 +192,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer Optional.ofNullable(is.getInstruction())) - .ifPresent(is -> is - .stream() + .ifPresent(is -> is.stream() .filter(Objects::nonNull) .sorted(OrderComparator.build()) .map(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types @@ -206,7 +210,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer updateInstruction(final Instruction instruction, final Short protocol) { + private static Optional updateInstruction(final Instruction instruction, final Uint8 protocol) { if (instruction instanceof ApplyActionsCase) { return Optional .ofNullable(((ApplyActionsCase) instruction).getApplyActions()) @@ -232,7 +236,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer Optional.ofNullable(is.getInstruction())) - .flatMap(is -> is - .stream() + .flatMap(is -> is.stream() .map(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types .rev131026.Instruction::getInstruction) .filter(ApplyActionsCase.class::isInstance) @@ -393,7 +396,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer { final int bucketIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - outBuffer.writeShort(MoreObjects.firstNonNull(bucket.getWeight(), 0)); + outBuffer.writeShort(MoreObjects.firstNonNull(bucket.getWeight(), Uint16.ZERO).toJava()); outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchPort(), OFConstants.OFPG_ANY) .intValue()); outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchGroup(), OFConstants.OFPG_ANY) @@ -99,7 +99,7 @@ public class GroupMessageSerializer extends AbstractMessageSerializer key = new ExperimenterIdSerializerKey<>( EncodeConstants.OF13_VERSION_ID, - band.getExperimenter(), + band.getExperimenter().toJava(), (Class) type.implementedInterface()); try { @@ -101,7 +101,7 @@ public class MeterMessageSerializer extends AbstractMessageSerializer byteBuf.writeByte(id.toJava())); } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java index de1e41c9b3..8e5834c9af 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializer.java @@ -19,7 +19,7 @@ public class NextTableTablePropertySerializer extends AbstractTablePropertySeria property .getTables() .getTableIds() - .forEach(byteBuf::writeByte); + .forEach(id -> byteBuf.writeByte(id.toJava())); } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java index 77e5ae3e48..144686130a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java @@ -41,6 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -112,7 +113,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { future.addCallback(new FutureCallback>() { @Override - public void onSuccess(Optional result) { + public void onSuccess(final Optional result) { result.ifPresent(flowCapableNode -> { flowCapableNode.nonnullTable().stream() .filter(Objects::nonNull) @@ -124,7 +125,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { LOG.debug("Failed to read {} path {}", logicalDatastoreType, path, throwable); } }, MoreExecutors.directExecutor()); @@ -181,11 +182,8 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { // We do not found flow in flow registry, that means it do not have any ID already assigned, so we need // to generate new alien flow ID here. - storeDescriptor( - flowRegistryKey, - FlowDescriptorFactory.create( - flowRegistryKey.getTableId(), - createAlienFlowId(flowRegistryKey.getTableId()))); + final Uint8 tableId = Uint8.valueOf(flowRegistryKey.getTableId()); + storeDescriptor(flowRegistryKey, FlowDescriptorFactory.create(tableId, createAlienFlowId(tableId))); } } @@ -231,7 +229,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { } @VisibleForTesting - static FlowId createAlienFlowId(final short tableId) { + static FlowId createAlienFlowId(final Uint8 tableId) { final String alienId = ALIEN_SYSTEM_FLOW_ID + tableId + '-' + UNACCOUNTED_FLOWS_COUNTER.incrementAndGet(); LOG.debug("Created alien flow id {} for table id {}", alienId, tableId); return new FlowId(alienId); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorFactory.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorFactory.java index 44a967e12e..c914c09a78 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorFactory.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorFactory.java @@ -5,15 +5,16 @@ * terms of the 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.registry.flow; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Objects; -import com.google.common.base.Preconditions; import javax.annotation.Nonnull; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey; +import org.opendaylight.yangtools.yang.common.Uint8; /** * This class serves as factory for creating @@ -26,10 +27,8 @@ public final class FlowDescriptorFactory { } @Nonnull - public static FlowDescriptor create(final short tableId, @Nonnull final FlowId flowId) { - return new FlowDescriptorDto( - new TableKey(tableId), - Preconditions.checkNotNull(flowId)); + public static FlowDescriptor create(final Uint8 tableId, @Nonnull final FlowId flowId) { + return new FlowDescriptorDto(new TableKey(tableId), requireNonNull(flowId)); } private static final class FlowDescriptorDto implements FlowDescriptor { @@ -43,7 +42,7 @@ public final class FlowDescriptorFactory { } @Override - public boolean equals(Object object) { + public boolean equals(final Object object) { if (this == object) { return true; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java index 64da79a9d7..c51cd61c8e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java @@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.registry.flow; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; -import java.math.BigInteger; import java.util.Objects; import javax.annotation.Nonnull; import org.opendaylight.openflowplugin.api.OFConstants; @@ -20,6 +19,9 @@ 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.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public final class FlowRegistryKeyFactory { @@ -30,24 +32,24 @@ public final class FlowRegistryKeyFactory { @Nonnull public static FlowRegistryKey create(final short version, @Nonnull final Flow flow) { //TODO: mandatory flow input values (or default values) should be specified via yang model - final short tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null"); - final int priority = MoreObjects.firstNonNull(flow.getPriority(), OFConstants.DEFAULT_FLOW_PRIORITY); - final BigInteger cookie = + final Uint8 tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null"); + final Uint16 priority = MoreObjects.firstNonNull(flow.getPriority(), OFConstants.DEFAULT_FLOW_PRIORITY); + final Uint64 cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue(); Match match = MatchNormalizationUtil .normalizeMatch(MoreObjects.firstNonNull(flow.getMatch(), OFConstants.EMPTY_MATCH), version); - return new FlowRegistryKeyDto(tableId, priority, cookie, match); + return new FlowRegistryKeyDto(tableId.toJava(), priority.toJava(), cookie, match); } private static final class FlowRegistryKeyDto implements FlowRegistryKey { private final short tableId; private final int priority; - private final BigInteger cookie; + private final Uint64 cookie; private final Match match; private FlowRegistryKeyDto(final short tableId, final int priority, - @Nonnull final BigInteger cookie, + @Nonnull final Uint64 cookie, @Nonnull final Match match) { this.tableId = tableId; this.priority = priority; @@ -162,7 +164,7 @@ public final class FlowRegistryKeyFactory { } @Override - public BigInteger getCookie() { + public Uint64 getCookie() { return cookie; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java index 7bebbd5fa3..a09e82c447 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java @@ -111,7 +111,7 @@ public class RoleContextImpl implements RoleContext { @Override public RequestContext createRequestContext() { - final AbstractRequestContext ret = new AbstractRequestContext(deviceInfo.reserveXidForDeviceMessage()) { + final AbstractRequestContext ret = new AbstractRequestContext<>(deviceInfo.reserveXidForDeviceMessage()) { @Override public void close() { requestContexts.remove(this); @@ -181,7 +181,7 @@ public class RoleContextImpl implements RoleContext { private final class MasterRoleCallback implements FutureCallback> { @Override - public void onSuccess(RpcResult setRoleOutputRpcResult) { + public void onSuccess(final RpcResult setRoleOutputRpcResult) { contextChainMastershipWatcher.onMasterRoleAcquired( deviceInfo, ContextChainMastershipState.MASTER_ON_DEVICE); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContext.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContext.java index be9304b421..ba5c569d2b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContext.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContext.java @@ -12,16 +12,22 @@ import com.google.common.util.concurrent.SettableFuture; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; public abstract class AbstractRequestContext implements RequestContext { private final SettableFuture> rpcResultFuture = SettableFuture.create(); private final Xid xid; private long waitTimeout; - protected AbstractRequestContext(final Long xid) { + protected AbstractRequestContext(final Uint32 xid) { this.xid = xid == null ? null : new Xid(xid); } + @Deprecated + protected AbstractRequestContext(final Long xid) { + this.xid = xid == null ? null : new Xid(Uint32.valueOf(xid)); + } + @Override public final ListenableFuture> getFuture() { return rpcResultFuture; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java index d00057213d..d329bf8c9a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.impl.rpc; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterators; import com.google.common.util.concurrent.Futures; @@ -38,6 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +65,7 @@ class RpcContextImpl implements RpcContext { @Nonnull final ExtensionConverterProvider extensionConverterProvider, @Nonnull final ConvertorExecutor convertorExecutor, @Nonnull final NotificationPublishService notificationPublishService, - boolean statisticsRpcEnabled) { + final boolean statisticsRpcEnabled) { this.deviceContext = deviceContext; this.deviceInfo = deviceContext.getDeviceInfo(); this.nodeInstanceIdentifier = deviceContext.getDeviceInfo().getNodeInstanceIdentifier(); @@ -137,12 +137,11 @@ class RpcContextImpl implements RpcContext { return null; } - return new AbstractRequestContext(xid) { + return new AbstractRequestContext<>(Uint32.valueOf(xid)) { @Override public void close() { tracker.release(); - final long xid = getXid().getValue(); - LOG.trace("Removed request context with xid {}", xid); + LOG.trace("Removed request context with xid {}", getXid().getValue()); messageSpy.spyMessage(RpcContextImpl.class, MessageSpy.StatisticsGroup.REQUEST_STACK_FREED); } }; @@ -177,12 +176,9 @@ class RpcContextImpl implements RpcContext { @Override public ListenableFuture closeServiceInstance() { - return Futures.transform(Futures.immediateFuture(null), new Function() { - @Override - public Void apply(final Void input) { - unregisterRPCs(); - return null; - } + return Futures.transform(Futures.immediateFuture(null), input -> { + unregisterRPCs(); + return null; }, MoreExecutors.directExecutor()); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java index 21a8e3073e..9736d4b8b4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java @@ -59,7 +59,7 @@ public class RpcManagerImpl implements RpcManager { * This method is only for testing. */ @VisibleForTesting - void addRecordToContexts(DeviceInfo deviceInfo, RpcContext rpcContexts) { + void addRecordToContexts(final DeviceInfo deviceInfo, final RpcContext rpcContexts) { if (!contexts.containsKey(deviceInfo)) { this.contexts.put(deviceInfo, rpcContexts); } @@ -69,7 +69,7 @@ public class RpcManagerImpl implements RpcManager { public RpcContext createContext(final @Nonnull DeviceContext deviceContext) { final RpcContextImpl rpcContext = new RpcContextImpl( rpcProviderRegistry, - config.getRpcRequestsQuota().getValue(), + config.getRpcRequestsQuota().getValue().toJava(), deviceContext, extensionConverterProvider, convertorExecutor, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartCollectorService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartCollectorService.java index cb4f1538b5..8318a7eea5 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartCollectorService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartCollectorService.java @@ -27,10 +27,11 @@ public abstract class AbstractMultipartCollectorService } @Override - protected FutureCallback createCallback(RequestContext> context, Class requestType) { + protected FutureCallback createCallback(final RequestContext> context, + final Class requestType) { final FutureCallback callback = super.createCallback(context, requestType); - return new FutureCallback() { + return new FutureCallback<>() { @Override public void onSuccess(final OfHeader result) { callback.onSuccess(result); @@ -43,7 +44,7 @@ public abstract class AbstractMultipartCollectorService DeviceInitializationUtil.makeEmptyTables( getTxFacade(), getDeviceInfo(), - getDeviceContext().getPrimaryConnectionContext().getFeatures().getTables()); + getDeviceContext().getPrimaryConnectionContext().getFeatures().getTables().toJava()); } callback.onFailure(throwable); @@ -53,7 +54,7 @@ public abstract class AbstractMultipartCollectorService @Override protected OfHeader buildRequest(final Xid xid, final MultipartType input) { - return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(), + return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue().toJava(), getVersion(), input, canUseSingleLayerSerialization()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java index af8e449564..68292c4555 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java @@ -12,7 +12,6 @@ import com.google.common.base.Verify; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import java.math.BigInteger; import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -33,6 +32,7 @@ import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +40,7 @@ public abstract class AbstractService { private static final Logger LOG = LoggerFactory.getLogger(AbstractService.class); private final short version; - private final BigInteger datapathId; + private final Uint64 datapathId; private final RequestContextStack requestContextStack; private final DeviceContext deviceContext; private final MessageSpy messageSpy; @@ -72,7 +72,7 @@ public abstract class AbstractService { return version; } - public BigInteger getDatapathId() { + public Uint64 getDatapathId() { return datapathId; } @@ -156,12 +156,12 @@ public abstract class AbstractService { final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider(); + // FIXME: reconcile uint32 vs. Long overflows + final Long queueXid = xid.getValue().toJava(); if (isComplete != null) { - outboundQueue.commitEntry(xid.getValue(), - request, - createCallback(requestContext, requestType), isComplete); + outboundQueue.commitEntry(queueXid, request, createCallback(requestContext, requestType), isComplete); } else { - outboundQueue.commitEntry(xid.getValue(), request, createCallback(requestContext, requestType)); + outboundQueue.commitEntry(queueXid, request, createCallback(requestContext, requestType)); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java index d9c5d01788..0a941797ea 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java @@ -31,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetR import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,7 +53,7 @@ public class RoleService extends AbstractSimpleService getGenerationIdFromDevice(final Short version) { + public ListenableFuture getGenerationIdFromDevice(final Short version) { LOG.info("getGenerationIdFromDevice called for device: {}", getDeviceInfo().getNodeId().getValue()); // send a dummy no-change role request to get the generation-id of the switch @@ -61,7 +62,7 @@ public class RoleService extends AbstractSimpleService finalFuture = SettableFuture.create(); + final SettableFuture finalFuture = SettableFuture.create(); final ListenableFuture> genIdListenableFuture = handleServiceCall(roleRequestInputBuilder); Futures.addCallback(genIdListenableFuture, new FutureCallback>() { @@ -97,7 +98,7 @@ public class RoleService extends AbstractSimpleService> submitRoleChange(final OfpRole ofpRole, final Short version, - final BigInteger generationId) { + final Uint64 generationId) { LOG.info("submitRoleChange called for device:{}, role:{}", getDeviceInfo().getNodeId(), ofpRole); final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder(); @@ -119,7 +120,7 @@ public class RoleService extends AbstractSimpleServicesuccess() .withResult(setRoleOutputBuilder.build()).build()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java index c8854c755a..943d61a556 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java @@ -126,17 +126,14 @@ public final class FlatBatchFlowAdapters { @VisibleForTesting static Function, RpcResult> convertBatchFlowResult(final int stepOffset) { - return new Function, RpcResult>() { - @Override - public RpcResult apply(final RpcResult input) { - List batchFailures = wrapBatchFlowFailuresForFlat(input, stepOffset); - ProcessFlatBatchOutputBuilder outputBuilder = - new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures); - return RpcResultBuilder.status(input.isSuccessful()) - .withRpcErrors(input.getErrors()) - .withResult(outputBuilder.build()) - .build(); - } + return input -> { + List batchFailures = wrapBatchFlowFailuresForFlat(input, stepOffset); + ProcessFlatBatchOutputBuilder outputBuilder = + new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures); + return RpcResultBuilder.status(input.isSuccessful()) + .withRpcErrors(input.getErrors()) + .withResult(outputBuilder.build()) + .build(); }; } @@ -146,7 +143,7 @@ public final class FlatBatchFlowAdapters { if (input.getResult().getBatchFailedFlowsOutput() != null) { for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) { final BatchFailure batchFailure = new BatchFailureBuilder() - .setBatchOrder(stepOffset + stepOutput.getBatchOrder()) + .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava()) .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() .setFlowId(stepOutput.getFlowId()) .build()) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java index bf38a2c499..90d4c6805a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java @@ -142,7 +142,7 @@ public final class FlatBatchGroupAdapters { if (input.getResult().getBatchFailedGroupsOutput() != null) { for (BatchFailedGroupsOutput stepOutput : input.getResult().getBatchFailedGroupsOutput()) { final BatchFailure batchFailure = new BatchFailureBuilder() - .setBatchOrder(stepOffset + stepOutput.getBatchOrder()) + .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava()) .setBatchItemIdChoice(new FlatBatchFailureGroupIdCaseBuilder() .setGroupId(stepOutput.getGroupId()) .build()) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java index cccdea3423..f679823eda 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java @@ -125,17 +125,14 @@ public final class FlatBatchMeterAdapters { @VisibleForTesting static Function, RpcResult> convertBatchMeterResult(final int stepOffset) { - return new Function, RpcResult>() { - @Override - public RpcResult apply(final RpcResult input) { - List batchFailures = wrapBatchMeterFailuresForFlat(input, stepOffset); - ProcessFlatBatchOutputBuilder outputBuilder = - new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures); - return RpcResultBuilder.status(input.isSuccessful()) - .withRpcErrors(input.getErrors()) - .withResult(outputBuilder.build()) - .build(); - } + return input -> { + List batchFailures = wrapBatchMeterFailuresForFlat(input, stepOffset); + ProcessFlatBatchOutputBuilder outputBuilder = + new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures); + return RpcResultBuilder.status(input.isSuccessful()) + .withRpcErrors(input.getErrors()) + .withResult(outputBuilder.build()) + .build(); }; } @@ -145,7 +142,7 @@ public final class FlatBatchMeterAdapters { if (input.getResult().getBatchFailedMetersOutput() != null) { for (BatchFailedMetersOutput stepOutput : input.getResult().getBatchFailedMetersOutput()) { final BatchFailure batchFailure = new BatchFailureBuilder() - .setBatchOrder(stepOffset + stepOutput.getBatchOrder()) + .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava()) .setBatchItemIdChoice(new FlatBatchFailureMeterIdCaseBuilder() .setMeterId(stepOutput.getMeterId()) .build()) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java index 01ccc72532..c9bbaf1b13 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerAggregateFlowMultipartService.java @@ -41,6 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFlowMultipartService { @@ -65,7 +67,7 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder(); final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder(); - final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL); + final Uint8 tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL); mprAggregateRequestBuilder.setTableId(tableId); long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue(); mprAggregateRequestBuilder.setOutPort(outputPortValue); @@ -86,7 +88,7 @@ public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFl mprAggregateRequestBuilder.setCookieMask( MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK)); } - long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY); + Uint32 outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY); mprAggregateRequestBuilder.setOutGroup(outGroup); } else { mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java index f4bc74b2a6..2ece276b2e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/multilayer/MultiLayerTableMultipartService.java @@ -13,7 +13,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -42,6 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,10 +52,10 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi private final VersionConvertorData data; private final ConvertorExecutor convertorExecutor; - public MultiLayerTableMultipartService(RequestContextStack requestContextStack, - DeviceContext deviceContext, - ConvertorExecutor convertorExecutor, - MultipartWriterProvider multipartWriterProvider) { + public MultiLayerTableMultipartService(final RequestContextStack requestContextStack, + final DeviceContext deviceContext, + final ConvertorExecutor convertorExecutor, + final MultipartWriterProvider multipartWriterProvider) { super(requestContextStack, deviceContext, multipartWriterProvider); this.convertorExecutor = convertorExecutor; data = new VersionConvertorData(getVersion()); @@ -78,7 +79,7 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi } @Override - public ListenableFuture> handleAndReply(UpdateTableInput input) { + public ListenableFuture> handleAndReply(final UpdateTableInput input) { final ListenableFuture>> multipartFuture = handleServiceCall(input); final SettableFuture> finalFuture = SettableFuture.create(); @@ -94,13 +95,13 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi finalFuture.set(RpcResultBuilder.failed() .withError(ErrorType.RPC, "Multipart reply list is empty.").build()); } else { - final Long xid = multipartReplies.get(0).getXid(); + final Uint32 xid = multipartReplies.get(0).getXid(); LOG.debug( "OnSuccess, rpc result successful," + " multipart response for rpc update-table with xid {} obtained.", xid); final UpdateTableOutputBuilder updateTableOutputBuilder = new UpdateTableOutputBuilder(); - updateTableOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(xid))); + updateTableOutputBuilder.setTransactionId(new TransactionId(Uint64.valueOf(xid))); finalFuture.set(RpcResultBuilder.success(updateTableOutputBuilder.build()).build()); try { storeStatistics(convertToSalTableFeatures(multipartReplies)); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImpl.java index 8a48d96378..c40079f34b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImpl.java @@ -11,7 +11,6 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import java.math.BigInteger; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext.CONNECTION_STATE; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; @@ -25,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalR import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleOutput; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +33,7 @@ public final class SalRoleServiceImpl extends AbstractSimpleService { LOG.debug("RoleChangeTask, GenerationIdFromDevice from device {} is {}", getDeviceInfo().getNodeId().getValue(), generationId); - final BigInteger nextGenerationId = getNextGenerationId(generationId); + final Uint64 nextGenerationId = getNextGenerationId(generationId); LOG.debug("nextGenerationId received from device:{} is {}", getDeviceInfo().getNodeId().getValue(), nextGenerationId); return roleService.submitRoleChange(role, getVersion(), nextGenerationId); }, MoreExecutors.directExecutor()); } - private static BigInteger getNextGenerationId(final BigInteger generationId) { + private static Uint64 getNextGenerationId(final Uint64 generationId) { if (generationId.compareTo(MAX_GENERATION_ID) < 0) { - return generationId.add(BigInteger.ONE); + return Uint64.valueOf(generationId.longValue() + 1); } else { - return BigInteger.ZERO; + return Uint64.ZERO; } } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java index ddf28f581a..fe4fbb99fd 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java @@ -13,7 +13,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; -import java.math.BigInteger; import java.util.List; import java.util.stream.Collectors; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -33,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multi import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,9 +40,9 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ private static final Logger LOG = LoggerFactory.getLogger(SingleLayerTableMultipartService.class); - public SingleLayerTableMultipartService(RequestContextStack requestContextStack, - DeviceContext deviceContext, - MultipartWriterProvider multipartWriterProvider) { + public SingleLayerTableMultipartService(final RequestContextStack requestContextStack, + final DeviceContext deviceContext, + final MultipartWriterProvider multipartWriterProvider) { super(requestContextStack, deviceContext, multipartWriterProvider); } @@ -59,7 +59,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ } @Override - public ListenableFuture> handleAndReply(UpdateTableInput input) { + public ListenableFuture> handleAndReply(final UpdateTableInput input) { final SettableFuture> finalFuture = SettableFuture.create(); Futures.addCallback(handleServiceCall(input), new FutureCallback>>() { @@ -76,7 +76,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ finalFuture.set(RpcResultBuilder .success(new UpdateTableOutputBuilder() .setTransactionId( - new TransactionId(BigInteger.valueOf(multipartReplies.get(0).getXid()))) + new TransactionId(Uint64.valueOf(multipartReplies.get(0).getXid()))) .build()) .build()); @@ -102,7 +102,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ } @Override - public void onFailure(Throwable throwable) { + public void onFailure(final Throwable throwable) { LOG.error("Failure multipart response for table features request", throwable); finalFuture.set(RpcResultBuilder.failed() .withError(ErrorType.RPC, "Future error", throwable).build()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtils.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtils.java index 37519bc0cf..61c4d76b92 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtils.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtils.java @@ -5,12 +5,12 @@ * terms of the 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.services.util; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public final class RequestInputUtils { @@ -18,9 +18,9 @@ public final class RequestInputUtils { throw new IllegalStateException("This class should not be instantiated."); } - public static MultipartRequestInputBuilder createMultipartHeader(MultipartType multipart, - Long xid, - Short version) { + public static MultipartRequestInputBuilder createMultipartHeader(final MultipartType multipart, + final Uint32 xid, + final Short version) { MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder(); mprInput.setType(multipart); mprInput.setVersion(version); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java index c007d571c3..0fb57f9a11 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java @@ -78,8 +78,8 @@ class StatisticsContextImpl implements StatisticsContext, De @Nonnull final MultipartWriterProvider statisticsWriterProvider, @Nonnull final ListeningExecutorService executorService, @Nonnull final OpenflowProviderConfig config, - boolean isStatisticsPollingOn, - boolean isUsingReconciliationFramework) { + final boolean isStatisticsPollingOn, + final boolean isUsingReconciliationFramework) { this.deviceContext = deviceContext; this.devState = Preconditions.checkNotNull(deviceContext.getDeviceState()); this.executorService = executorService; @@ -87,8 +87,8 @@ class StatisticsContextImpl implements StatisticsContext, De this.config = config; this.convertorExecutor = convertorExecutor; this.deviceInfo = deviceContext.getDeviceInfo(); - this.statisticsPollingInterval = config.getBasicTimerDelay().getValue(); - this.maximumPollingDelay = config.getMaximumTimerDelay().getValue(); + this.statisticsPollingInterval = config.getBasicTimerDelay().getValue().toJava(); + this.maximumPollingDelay = config.getMaximumTimerDelay().getValue().toJava(); this.statisticsWriterProvider = statisticsWriterProvider; this.isUsingReconciliationFramework = isUsingReconciliationFramework; @@ -116,7 +116,7 @@ class StatisticsContextImpl implements StatisticsContext, De @Override public RequestContext createRequestContext() { - final AbstractRequestContext ret = new AbstractRequestContext(deviceInfo.reserveXidForDeviceMessage()) { + final AbstractRequestContext ret = new AbstractRequestContext<>(deviceInfo.reserveXidForDeviceMessage()) { @Override public void close() { requestContexts.remove(this); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java index dab391f056..b99de55d07 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java @@ -43,8 +43,8 @@ public final class AggregateFlowsInTableService extends final TranslatorLibrary translatorLibrary; public static AggregateFlowsInTableService createWithOook(final RequestContextStack requestContextStack, - final DeviceContext deviceContext, - AtomicLong compatibilityXidSeed) { + final DeviceContext deviceContext, + final AtomicLong compatibilityXidSeed) { return new AggregateFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed, @@ -53,8 +53,8 @@ public final class AggregateFlowsInTableService extends public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, - AtomicLong compatibilityXidSeed, - TranslatorLibrary translatorLibrary) { + final AtomicLong compatibilityXidSeed, + final TranslatorLibrary translatorLibrary) { super(requestContextStack, deviceContext, compatibilityXidSeed); this.translatorLibrary = translatorLibrary; @@ -87,20 +87,21 @@ public final class AggregateFlowsInTableService extends } @Override - public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput buildTxCapableResult(TransactionId emulatedTxId) { + public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput buildTxCapableResult( + final TransactionId emulatedTxId) { return new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder().setTransactionId(emulatedTxId) .build(); } @Override - public AggregateFlowStatisticsUpdate transformToNotification(List result, - TransactionId emulatedTxId) { + public AggregateFlowStatisticsUpdate transformToNotification(final List result, + final TransactionId emulatedTxId) { final int mpSize = result.size(); Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize); MultipartReply mpReply = result.get(0); final TranslatorKey translatorKey = - new TranslatorKey(mpReply.getVersion(), MultipartReplyAggregateCase.class.getName()); + new TranslatorKey(mpReply.getVersion().toJava(), MultipartReplyAggregateCase.class.getName()); final MessageTranslator messageTranslator = translatorLibrary.lookupTranslator(translatorKey); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyService.java index e90d10ec0a..be20375a20 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyService.java @@ -53,7 +53,7 @@ public class StatisticsGatheringOnTheFlyService @Override protected OfHeader buildRequest(final Xid xid, final MultipartType input) { - return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(), + return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue().toJava(), getVersion(), input, canUseSingleLayerSerialization()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java index a0638491c7..99bd745b15 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java @@ -46,7 +46,7 @@ public class StatisticsGatheringService @Override protected OfHeader buildRequest(final Xid xid, final MultipartType input) { - return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(), + return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue().toJava(), getVersion(), input, canUseSingleLayerSerialization()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java index 6aa039669f..fff83bb8fe 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsService.java @@ -5,7 +5,6 @@ * terms of the 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.statistics.services.direct.multilayer; import java.util.ArrayList; @@ -51,7 +50,7 @@ public class FlowDirectStatisticsService extends AbstractFlowDirectStatisticsSer } @Override - protected GetFlowStatisticsOutput buildReply(List input, boolean success) { + protected GetFlowStatisticsOutput buildReply(final List input, final boolean success) { final List statsList = new ArrayList<>(); if (success) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java index 4a2385ae59..a093246be6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java @@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Remove import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,7 +30,7 @@ public class FlowRemovedTranslator implements MessageTranslator private final ConvertorExecutor convertorExecutor; private static final Logger LOG = LoggerFactory.getLogger(FlowRemovedTranslator.class); - public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) { + public FlowRemovedTranslator(final ConvertorExecutor convertorExecutor) { this.convertorExecutor = convertorExecutor; } @@ -39,7 +40,7 @@ public class FlowRemovedTranslator implements MessageTranslator @Override public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved - translate(FlowRemoved input, DeviceInfo deviceInfo, Object connectionDistinguisher) { + translate(final FlowRemoved input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) { FlowRemovedBuilder flowRemovedBld = new FlowRemovedBuilder() .setMatch(translateMatch(input, deviceInfo).build()) .setCookie(new FlowCookie(input.getCookie())) @@ -54,7 +55,7 @@ public class FlowRemovedTranslator implements MessageTranslator return flowRemovedBld.build(); } - protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) { + protected MatchBuilder translateMatch(final FlowRemoved flowRemoved, final DeviceInfo deviceInfo) { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion()); datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId()); @@ -72,11 +73,11 @@ public class FlowRemovedTranslator implements MessageTranslator * @param flowRemoved FLOW_REMOVED message. * @return SAL table ID. */ - protected Short translateTableId(FlowRemoved flowRemoved) { - return flowRemoved.getTableId().getValue().shortValue(); + protected Uint8 translateTableId(final FlowRemoved flowRemoved) { + return Uint8.valueOf(flowRemoved.getTableId().getValue()); } - private RemovedFlowReason translateReason(FlowRemoved removedFlow) { + private RemovedFlowReason translateReason(final FlowRemoved removedFlow) { LOG.debug("--Entering translateReason within FlowRemovedTranslator with reason: {}", removedFlow.getReason()); switch (removedFlow.getReason()) { case OFPRRIDLETIMEOUT: diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java index ad69683633..4bd8ab2328 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java @@ -5,7 +5,6 @@ * terms of the 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.translator; import java.util.Optional; @@ -14,18 +13,19 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorE 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; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions). */ public class FlowRemovedV10Translator extends FlowRemovedTranslator { - public FlowRemovedV10Translator(ConvertorExecutor convertorExecutor) { + public FlowRemovedV10Translator(final ConvertorExecutor convertorExecutor) { super(convertorExecutor); } @Override - protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) { + protected MatchBuilder translateMatch(final FlowRemoved flowRemoved, final DeviceInfo deviceInfo) { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion()); datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId()); @@ -44,7 +44,7 @@ public class FlowRemovedV10Translator extends FlowRemovedTranslator { * @return Zero. */ @Override - protected Short translateTableId(FlowRemoved flowRemoved) { - return (short) 0; + protected Uint8 translateTableId(final FlowRemoved flowRemoved) { + return Uint8.ZERO; } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java index 8e2ceac87a..6d32df52a3 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java @@ -8,7 +8,6 @@ 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; @@ -27,11 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Pa import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; +import org.opendaylight.yangtools.yang.common.Uint64; public class PacketReceivedTranslator implements MessageTranslator { private final ConvertorExecutor convertorExecutor; - public PacketReceivedTranslator(ConvertorExecutor convertorExecutor) { + public PacketReceivedTranslator(final ConvertorExecutor convertorExecutor) { this.convertorExecutor = convertorExecutor; } @@ -40,7 +40,7 @@ public class PacketReceivedTranslator implements MessageTranslator diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java index b1b6956f84..30ca988e4c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java @@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.P import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +59,7 @@ public class PortUpdateTranslator implements MessageTranslator Type of values. * @return {@code true} only if {@code value1} and {@code value2} are identical. */ - public static boolean equalsWithDefault(T value1, T value2, T def) { + public static boolean equalsWithDefault(final T value1, final T value2, final T def) { if (value1 == null) { return value2 == null || value2.equals(def); } else if (value2 == null) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java index efb6773530..6fc9cc3442 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java @@ -42,6 +42,7 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public final class FlowUtil { @@ -177,7 +178,7 @@ public final class FlowUtil { * @return instance identifier assembled for given node, table and flow */ public static FlowRef buildFlowPath(final InstanceIdentifier nodePath, - final short tableId, final FlowId flowId) { + final Uint8 tableId, final FlowId flowId) { final KeyedInstanceIdentifier flowPath = nodePath .augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(tableId)) @@ -202,7 +203,7 @@ public final class FlowUtil { private static class CumulatingFunction { private final List inputBatchFlows; - CumulatingFunction(List inputBatchFlows) { + CumulatingFunction(final List inputBatchFlows) { this.inputBatchFlows = inputBatchFlows; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/GroupUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/GroupUtil.java index 38ce623372..f7529ff9a1 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/GroupUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/GroupUtil.java @@ -40,6 +40,7 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Provides group util methods. @@ -129,8 +130,8 @@ public final class GroupUtil { * @param actionsSupported - list of supported actions * @return */ - public static List extractGroupActionsSupportBitmap(final List actionsSupported) { - List supportActionByGroups = new ArrayList<>(); + public static List extractGroupActionsSupportBitmap(final List actionsSupported) { + List supportActionByGroups = new ArrayList<>(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) { long supportActionBitmap = 0; @@ -150,7 +151,7 @@ public final class GroupUtil { supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? 1 << 25 : 0; supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? 1 << 26 : 0; supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? 1 << 27 : 0; - supportActionByGroups.add(supportActionBitmap); + supportActionByGroups.add(Uint32.valueOf(supportActionBitmap)); } return supportActionByGroups; } @@ -212,8 +213,8 @@ public final class GroupUtil { private final int sizeOfInputBatch; CumulatingFunction( - Iterable - inputBatchGroups, int sizeOfInputBatch) { + final Iterable + inputBatchGroups, final int sizeOfInputBatch) { this.inputBatchGroups = inputBatchGroups; this.sizeOfInputBatch = sizeOfInputBatch; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java index a71d580445..fae0666ba6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowplugin.impl.util; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import java.math.BigInteger; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -25,6 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Created by Tomas Slusny on 23.3.2016. @@ -41,11 +42,11 @@ public final class NodeConnectorRefToPortTranslator { * @return packet input converted to node connector reference */ @Nullable - public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) { + public static NodeConnectorRef toNodeConnectorRef(@Nonnull final PacketIn packetIn, final Uint64 dataPathId) { Preconditions.checkNotNull(packetIn); NodeConnectorRef ref = null; - Long port = getPortNoFromPacketIn(packetIn); + Uint32 port = getPortNoFromPacketIn(packetIn); if (port != null) { OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion()); @@ -64,10 +65,10 @@ public final class NodeConnectorRefToPortTranslator { */ @SuppressWarnings("unchecked") @Nullable - public static Long fromNodeConnectorRef(@Nonnull NodeConnectorRef nodeConnectorRef, short version) { + public static Uint32 fromNodeConnectorRef(@Nonnull final NodeConnectorRef nodeConnectorRef, final short version) { Preconditions.checkNotNull(nodeConnectorRef); - Long port = null; + Uint32 port = null; final InstanceIdentifier value = nodeConnectorRef.getValue(); if (value instanceof KeyedInstanceIdentifier) { @@ -85,14 +86,14 @@ public final class NodeConnectorRefToPortTranslator { @VisibleForTesting @Nullable - static Long getPortNoFromPacketIn(@Nonnull PacketIn packetIn) { + static Uint32 getPortNoFromPacketIn(@Nonnull final PacketIn packetIn) { Preconditions.checkNotNull(packetIn); - Long port = null; + Uint32 port = null; - if (packetIn.getVersion() == OFConstants.OFP_VERSION_1_0 && packetIn.getInPort() != null) { - port = packetIn.getInPort().longValue(); - } else if (packetIn.getVersion() == OFConstants.OFP_VERSION_1_3) { + if (packetIn.getVersion().toJava() == OFConstants.OFP_VERSION_1_0 && packetIn.getInPort() != null) { + port = Uint32.valueOf(packetIn.getInPort()); + } else if (packetIn.getVersion().toJava() == OFConstants.OFP_VERSION_1_3) { if (packetIn.getMatch() != null && packetIn.getMatch().getMatchEntry() != null) { List entries = packetIn.getMatch().getMatchEntry(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtil.java index bbd38b68f5..f93a9b5f18 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtil.java @@ -7,7 +7,6 @@ */ package org.opendaylight.openflowplugin.impl.util; -import java.math.BigInteger; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil; @@ -28,6 +27,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -131,8 +132,8 @@ public abstract class PortTranslatorUtil { return npc; } - public static NodeConnectorUpdated translatePort(final Short version, final BigInteger datapathId, - final Long portNumber, final PortGrouping port) { + public static NodeConnectorUpdated translatePort(final Short version, final Uint64 datapathId, + final Uint32 portNumber, final PortGrouping port) { OpenflowVersion ofVersion = OpenflowVersion.get(version); final NodeConnectorUpdatedBuilder builder = InventoryDataServiceUtil .nodeConnectorUpdatedBuilderFromDatapathIdPortNo(datapathId, port.getPortNo(), ofVersion); @@ -169,8 +170,8 @@ public abstract class PortTranslatorUtil { return builder.build(); } - public static NodeConnectorRemoved translatePortRemoved(final Short version, final BigInteger datapathId, - final Long portNumber, final PortGrouping port) { + public static NodeConnectorRemoved translatePortRemoved(final Short version, final Uint64 datapathId, + final Uint32 portNumber, final PortGrouping port) { OpenflowVersion ofVersion = OpenflowVersion.get(version); NodeConnectorRemovedBuilder builder = new NodeConnectorRemovedBuilder(); builder.setNodeConnectorRef( diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java index 33feef8875..abf719b245 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java @@ -36,6 +36,8 @@ import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationS import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService; import org.opendaylight.yangtools.concepts.ObjectRegistration; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class OpenFlowPluginProviderImplTest { @@ -81,12 +83,12 @@ public class OpenFlowPluginProviderImplTest { private static final int RPC_REQUESTS_QUOTA = 500; private static final long GLOBAL_NOTIFICATION_QUOTA = 131072; - private static final int THREAD_POOL_MIN_THREADS = 1; + private static final Uint16 THREAD_POOL_MIN_THREADS = Uint16.ONE; private static final int THREAD_POOL_MAX_THREADS = 32000; - private static final long THREAD_POOL_TIMEOUT = 60; + private static final Uint32 THREAD_POOL_TIMEOUT = Uint32.valueOf(60); private static final long BASIC_TIMER_DELAY = 1L; private static final boolean USE_SINGLE_LAYER_SERIALIZATION = false; - private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0; + private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO; @Before public void setUp() { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java index 3245b51b0f..926345c7fb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java @@ -29,6 +29,8 @@ import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationS import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class ConfigurationServiceFactoryImplTest { @@ -45,12 +47,12 @@ public class ConfigurationServiceFactoryImplTest { private static final boolean IS_STATISTICS_RPC_ENABLED = false; private static final boolean USE_SINGLE_LAYER_SERIALIZATION = true; private static final int RPC_REQUESTS_QUOTA = 2500; - private static final long GLOBAL_NOTIFICATION_QUOTA = 9000; - private static final int THREAD_POOL_MIN_THREADS = 3; + private static final Uint32 GLOBAL_NOTIFICATION_QUOTA = Uint32.valueOf(9000); + private static final Uint16 THREAD_POOL_MIN_THREADS = Uint16.valueOf(3); private static final int THREAD_POOL_MIN_THREADS_UPDATE = 4; private static final int THREAD_POOL_MAX_THREADS = 1000; - private static final long THREAD_POOL_TIMEOUT = 60; - private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0; + private static final Uint32 THREAD_POOL_TIMEOUT = Uint32.valueOf(60); + private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO; @Mock private OpenflowProviderConfig config; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImplTest.java index af7ff22016..31cb23327d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImplTest.java @@ -21,26 +21,28 @@ import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class OpenFlowProviderConfigImplTest { private static final Boolean IS_STATISTICS_POLLING_ON = true; - private static final Integer BARRIER_COUNT_LIMIT = 2000; - private static final Long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000L; - private static final Long ECHO_REPLY_TIMEOUT = 4000L; + private static final int BARRIER_COUNT_LIMIT = 2000; + private static final long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000L; + private static final long ECHO_REPLY_TIMEOUT = 4000L; private static final Boolean ENABLE_FLOW_REMOVED_NOTIFICATION = true; private static final Boolean SKIP_TABLE_FEATURES = true; - private static final Long BASIC_TIMER_DELAY = 2690L; - private static final Long MAXIMUM_TIMER_DELAY = 3679L; + private static final long BASIC_TIMER_DELAY = 2690L; + private static final long MAXIMUM_TIMER_DELAY = 3679L; private static final Boolean SWITCH_FEATURES_MANDATORY = false; private static final Boolean IS_STATISTICS_RPC_ENABLED = false; private static final Boolean USE_SINGLE_LAYER_SERIALIZATION = true; - private static final Integer RPC_REQUESTS_QUOTA = 2500; - private static final Long GLOBAL_NOTIFICATION_QUOTA = 9000L; - private static final Integer THREAD_POOL_MIN_THREADS = 3; - private static final Integer THREAD_POOL_MAX_THREADS = 1000; - private static final Long THREAD_POOL_TIMEOUT = 60L; - private static final Integer DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0; + private static final int RPC_REQUESTS_QUOTA = 2500; + private static final Uint32 GLOBAL_NOTIFICATION_QUOTA = Uint32.valueOf(9000); + private static final Uint16 THREAD_POOL_MIN_THREADS = Uint16.valueOf(3); + private static final int THREAD_POOL_MAX_THREADS = 1000; + private static final Uint32 THREAD_POOL_TIMEOUT = Uint32.valueOf(60); + private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO; @Mock private ConfigurationService configurationService; @@ -92,7 +94,7 @@ public class OpenFlowProviderConfigImplTest { @Test public void getRpcRequestsQuota() { - assertEquals(RPC_REQUESTS_QUOTA, openflowProviderConfig.getRpcRequestsQuota().getValue()); + assertEquals(RPC_REQUESTS_QUOTA, openflowProviderConfig.getRpcRequestsQuota().getValue().toJava()); } @Test @@ -118,17 +120,17 @@ public class OpenFlowProviderConfigImplTest { @Test public void getBarrierIntervalTimeoutLimit() { assertEquals(BARRIER_INTERVAL_TIMEOUT_LIMIT, openflowProviderConfig.getBarrierIntervalTimeoutLimit() - .getValue()); + .getValue().toJava()); } @Test public void getBarrierCountLimit() { - assertEquals(BARRIER_COUNT_LIMIT, openflowProviderConfig.getBarrierCountLimit().getValue()); + assertEquals(BARRIER_COUNT_LIMIT, openflowProviderConfig.getBarrierCountLimit().getValue().toJava()); } @Test public void getEchoReplyTimeout() { - assertEquals(ECHO_REPLY_TIMEOUT, openflowProviderConfig.getEchoReplyTimeout().getValue()); + assertEquals(ECHO_REPLY_TIMEOUT, openflowProviderConfig.getEchoReplyTimeout().getValue().toJava()); } @Test @@ -138,7 +140,7 @@ public class OpenFlowProviderConfigImplTest { @Test public void getThreadPoolMaxThreads() { - assertEquals(THREAD_POOL_MAX_THREADS, openflowProviderConfig.getThreadPoolMaxThreads().getValue()); + assertEquals(THREAD_POOL_MAX_THREADS, openflowProviderConfig.getThreadPoolMaxThreads().getValue().toJava()); } @Test @@ -158,12 +160,12 @@ public class OpenFlowProviderConfigImplTest { @Test public void getBasicTimerDelay() { - assertEquals(BASIC_TIMER_DELAY, openflowProviderConfig.getBasicTimerDelay().getValue()); + assertEquals(BASIC_TIMER_DELAY, openflowProviderConfig.getBasicTimerDelay().getValue().toJava()); } @Test public void getMaximumTimerDelay() { - assertEquals(MAXIMUM_TIMER_DELAY, openflowProviderConfig.getMaximumTimerDelay().getValue()); + assertEquals(MAXIMUM_TIMER_DELAY, openflowProviderConfig.getMaximumTimerDelay().getValue().toJava()); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/OutboundQueueProviderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/OutboundQueueProviderImplTest.java index 9549fc3c8c..cc07a61199 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/OutboundQueueProviderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/OutboundQueueProviderImplTest.java @@ -15,11 +15,12 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yangtools.yang.common.Uint32; public class OutboundQueueProviderImplTest extends TestCase { private static final Long DUMMY_ENTRY_NUMBER = 44L; - private static final Long DUMMY_XID = 55L; + private static final Uint32 DUMMY_XID = Uint32.valueOf(55L); private final OutboundQueueProviderImpl outboundQueueProvider = new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3); @@ -40,9 +41,9 @@ public class OutboundQueueProviderImplTest extends TestCase { @Test public void testCreateBarrierRequest() { - final BarrierInput barrierRequest = outboundQueueProvider.createBarrierRequest(DUMMY_XID); + final BarrierInput barrierRequest = outboundQueueProvider.createBarrierRequest(DUMMY_XID.toJava()); assertNotNull(barrierRequest); - assertEquals(OFConstants.OFP_VERSION_1_3, (short)barrierRequest.getVersion()); + assertEquals(OFConstants.OFP_VERSION_1_3, barrierRequest.getVersion().toJava()); assertEquals(DUMMY_XID, barrierRequest.getXid()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java index 74a64d59e6..2982270b0f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java @@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.connection.listener; import static org.mockito.ArgumentMatchers.any; -import java.math.BigInteger; import java.net.InetSocketAddress; import org.junit.After; import org.junit.Assert; @@ -34,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.FeaturesReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test for {@link HandshakeListenerImpl}. @@ -61,7 +61,7 @@ public class HandshakeListenerImplTest { .thenReturn(RpcResultBuilder.success(new BarrierOutputBuilder().build()).buildFuture()); connectionContextSpy = Mockito.spy(new ConnectionContextImpl(connectionAdapter)); Mockito.when(connectionContextSpy.getConnectionAdapter()).thenReturn(connectionAdapter); - Mockito.when(features.getDatapathId()).thenReturn(BigInteger.TEN); + Mockito.when(features.getDatapathId()).thenReturn(Uint64.valueOf(10)); handshakeListener = new HandshakeListenerImpl(connectionContextSpy, deviceConnectedHandler); handshakeListener.setHandshakeContext(handshakeContext); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java index 7c5054aece..2015859a11 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.S import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Testing basic bahavior of {@link SystemNotificationsListenerImpl}. @@ -68,19 +69,16 @@ public class SystemNotificationsListenerImplTest { connectionContextGolem = new ConnectionContextImpl(connectionAdapter); connectionContextGolem.changeStateToWorking(); connectionContextGolem.setNodeId(NODE_ID); + connectionContextGolem.setFeatures(features); connectionContext = Mockito.spy(connectionContextGolem); Mockito.when(connectionAdapter.getRemoteAddress()).thenReturn( InetSocketAddress.createUnresolved("unit-odl.example.org", 4242)); - Mockito.when(features.getAuxiliaryId()).thenReturn((short) 0); - - Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter); - Mockito.when(connectionContext.getFeatures()).thenReturn(features); + Mockito.when(features.getAuxiliaryId()).thenReturn(Uint8.ZERO); systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext, ECHO_REPLY_TIMEOUT, threadPool); - } @After @@ -200,11 +198,11 @@ public class SystemNotificationsListenerImplTest { private void verifyCommonInvocations() { verifyCommonInvocationsSubSet(); + Mockito.verify(connectionContext, Mockito.timeout(SAFE_TIMEOUT).atLeastOnce()).getFeatures(); Mockito.verify(connectionContext, Mockito.timeout(SAFE_TIMEOUT).atLeastOnce()).getConnectionAdapter(); } private void verifyCommonInvocationsSubSet() { Mockito.verify(connectionContext, Mockito.timeout(SAFE_TIMEOUT).atLeastOnce()).getConnectionState(); - Mockito.verify(connectionContext, Mockito.timeout(SAFE_TIMEOUT).atLeastOnce()).getFeatures(); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java index d4d20ccb1b..c8c5cc289d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java @@ -110,18 +110,20 @@ import org.opendaylight.yangtools.util.concurrent.NotificationManager; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @RunWith(MockitoJUnitRunner.class) public class DeviceContextImplTest { - private static final Logger LOG = LoggerFactory - .getLogger(DeviceContextImplTest.class); - private static final short DUMMY_AUXILIARY_ID = 33; - private static final BigInteger DUMMY_COOKIE = new BigInteger("33"); - private static final Long DUMMY_XID = 544L; + private static final Logger LOG = LoggerFactory.getLogger(DeviceContextImplTest.class); + private static final Uint8 DUMMY_AUXILIARY_ID = Uint8.valueOf(33); + private static final Uint64 DUMMY_COOKIE = Uint64.valueOf("33"); + private static final Uint32 DUMMY_XID = Uint32.valueOf(544L); private static final Long DUMMY_PORT_NUMBER = 159L; - private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("55"); + private static final Uint64 DUMMY_DATAPATH_ID = Uint64.valueOf("55"); private Xid xid; private Xid xidMulti; @@ -193,7 +195,7 @@ public class DeviceContextImplTest { .thenReturn(txChainFactory); Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent); Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId); - Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE); + Mockito.when(deviceInfo.getDatapathId()).thenReturn(Uint64.ONE); final SettableFuture> settableFuture = SettableFuture.create(); final SettableFuture> settableFutureMultiReply = SettableFuture.create(); Mockito.lenient().when(requestContext.getFuture()).thenReturn(settableFuture); @@ -218,7 +220,7 @@ public class DeviceContextImplTest { Mockito.lenient().when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); Mockito.lenient().when(featuresOutput.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); - Mockito.lenient().when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + Mockito.lenient().when(featuresOutput.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); Mockito.when(contextChainHolder.getContextChain(deviceInfo)).thenReturn(contextChain); Mockito.when(contextChain.isMastered(ContextChainMastershipState.CHECK, false)).thenReturn(true); @@ -263,8 +265,8 @@ public class DeviceContextImplTest { ((DeviceContextImpl) deviceContext).lazyTransactionManagerInitialization(); deviceContextSpy = Mockito.spy(deviceContext); - xid = new Xid(atomicLong.incrementAndGet()); - xidMulti = new Xid(atomicLong.incrementAndGet()); + xid = new Xid(Uint32.valueOf(atomicLong.incrementAndGet())); + xidMulti = new Xid(Uint32.valueOf(atomicLong.incrementAndGet())); lenient().doNothing().when(deviceContextSpy).writeToTransaction(any(), any(), any()); } @@ -419,9 +421,9 @@ public class DeviceContextImplTest { final GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class); lenient().when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); - lenient().when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + lenient().when(mockedPortStatusMessage.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); lenient().when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD); - lenient().when(mockedPortStatusMessage.getPortNo()).thenReturn(42L); + lenient().when(mockedPortStatusMessage.getPortNo()).thenReturn(Uint32.valueOf(42L)); deviceContextSpy.processPortStatusMessage(mockedPortStatusMessage); verify(messageSpy).spyMessage(any(), any()); } @@ -443,7 +445,7 @@ public class DeviceContextImplTest { // insert flow+flowId into local registry final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowRemovedMdsalBld.build()); - final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 0, new FlowId("ut-ofp:f456")); + final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(Uint8.ZERO, new FlowId("ut-ofp:f456")); deviceContext.getDeviceFlowRegistry().storeDescriptor(flowRegKey, flowDescriptor); // prepare empty input message diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java index 8c6ec8934f..8869734b1a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java @@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class OF10DeviceInitializerTest { @@ -93,7 +94,7 @@ public class OF10DeviceInitializerTest { when(deviceContext.getMessageSpy()).thenReturn(messageSpy); when(translatorLibrary.lookupTranslator(any())).thenReturn(messageTranslator); when(deviceContext.oook()).thenReturn(translatorLibrary); - when(requestContext.getXid()).thenReturn(new Xid(42L)); + when(requestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(42L))); when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success().buildFuture()); when(deviceContext.createRequestContext()).thenReturn(requestContext); when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java index 0f219b2006..4be4844140 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java @@ -48,6 +48,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.MultipartReplyDescCaseBuilder; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class OF13DeviceInitializerTest { @@ -97,7 +98,7 @@ public class OF13DeviceInitializerTest { when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); when(deviceContext.getMessageSpy()).thenReturn(messageSpy); when(deviceContext.oook()).thenReturn(translatorLibrary); - when(requestContext.getXid()).thenReturn(new Xid(42L)); + when(requestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(42L))); when(deviceContext.createRequestContext()).thenReturn(requestContext); when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/MultiMsgCollectorImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/MultiMsgCollectorImplTest.java index 3dd0c5ed44..1d9d5788d0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/MultiMsgCollectorImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/MultiMsgCollectorImplTest.java @@ -29,6 +29,7 @@ import org.opendaylight.openflowplugin.impl.connection.testutil.MsgGeneratorTest 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.MultipartReplyMessage; +import org.opendaylight.yangtools.yang.common.Uint32; /** * openflowplugin-api @@ -55,7 +56,7 @@ public class MultiMsgCollectorImplTest { ArgumentCaptor> mmCaptor; @Mock RequestContext> requestContext; - final Long xid = 1L; + final long xid = 1L; private final String hwTestValue = "test-value"; @@ -67,7 +68,7 @@ public class MultiMsgCollectorImplTest { public void setUp() { collector = new MultiMsgCollectorImpl<>(deviceProcessor, requestContext); cleanUpCheck = Runnables.doNothing(); - Mockito.when(requestContext.getXid()).thenReturn(new Xid(xid)); + Mockito.when(requestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(xid))); } @After @@ -89,7 +90,7 @@ public class MultiMsgCollectorImplTest { .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null); Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); final List multipartReplyList = mmCaptor.getValue(); Assert.assertEquals(1, multipartReplyList.size()); @@ -108,7 +109,7 @@ public class MultiMsgCollectorImplTest { .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null); Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); final List multipartReplyList = mmCaptor.getValue(); Assert.assertEquals(2, multipartReplyList.size()); @@ -140,14 +141,14 @@ public class MultiMsgCollectorImplTest { .setType(MultipartType.OFPMPPORTDESC).build(), false, null); Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); Mockito.reset(deviceProcessor); cleanUpCheck = () -> { Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions()) .processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); }; } @@ -166,14 +167,14 @@ public class MultiMsgCollectorImplTest { Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); Mockito.reset(deviceProcessor); cleanUpCheck = () -> { Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions()) .processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); }; } @@ -191,10 +192,10 @@ public class MultiMsgCollectorImplTest { .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null); Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture()); - Assert.assertEquals(xid, xidCaptor.getValue().getValue()); + Assert.assertEquals(xid, xidCaptor.getValue().getValue().toJava()); final List multipartReplyList = mmCaptor.getValue(); Assert.assertEquals(3, multipartReplyList.size()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java index 0645cf4b5f..7af2151f04 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java @@ -41,13 +41,14 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager import org.opendaylight.openflowplugin.impl.mastership.MastershipChangeServiceManagerImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class ContextChainHolderImplTest { private static final String ENTITY_TEST = "EntityTest"; private static final String OPENFLOW_TEST = "openflow:test"; - private static final Short AUXILIARY_ID = 0; + private static final Uint8 AUXILIARY_ID = Uint8.ZERO; @Mock private StatisticsManager statisticsManager; @Mock @@ -197,8 +198,7 @@ public class ContextChainHolderImplTest { registration.close(); Assert.assertTrue(contextChainHolder.deviceConnected(connectionContext) == ConnectionStatus.MAY_CONTINUE); - Short auxiliaryId1 = 1; - Mockito.when(featuresReply.getAuxiliaryId()).thenReturn(auxiliaryId1); + Mockito.when(featuresReply.getAuxiliaryId()).thenReturn(Uint8.ONE); Assert.assertTrue(contextChainHolder.deviceConnected(connectionContext) == ConnectionStatus.MAY_CONTINUE); Mockito.when(featuresReply.getAuxiliaryId()).thenReturn(AUXILIARY_ID); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteMetadataInstructionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteMetadataInstructionDeserializerTest.java index e8a03262dc..5fc8dfd323 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteMetadataInstructionDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteMetadataInstructionDeserializerTest.java @@ -37,18 +37,12 @@ public class WriteMetadataInstructionDeserializerTest extends AbstractInstructio assertEquals(WriteMetadataCase.class, instruction.implementedInterface()); assertArrayEquals( - ByteUtil - .convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES), - ByteUtil - .convertBigIntegerToNBytes(((WriteMetadataCase) instruction).getWriteMetadata() - .getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + ByteUtil.convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES), + ByteUtil.uint64toBytes(((WriteMetadataCase) instruction).getWriteMetadata().getMetadata())); assertArrayEquals( - ByteUtil - .convertBigIntegerToNBytes(metadataMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES), - ByteUtil - .convertBigIntegerToNBytes(((WriteMetadataCase) instruction).getWriteMetadata() - .getMetadataMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + ByteUtil.convertBigIntegerToNBytes(metadataMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES), + ByteUtil.uint64toBytes(((WriteMetadataCase) instruction).getWriteMetadata().getMetadataMask())); assertEquals(0, in.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java index a6423f89b4..ff4cb122e8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java @@ -15,6 +15,7 @@ import io.netty.buffer.UnpooledByteBufAllocator; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yangtools.yang.common.Uint32; public class EthernetTypeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest { @@ -26,7 +27,8 @@ public class EthernetTypeEntryDeserializerTest extends AbstractMatchEntryDeseria writeHeader(in, false); in.writeShort(ethType); - assertEquals(Long.valueOf(ethType), deserialize(in).getEthernetMatch().getEthernetType().getType().getValue()); + assertEquals(Uint32.valueOf(ethType), + deserialize(in).getEthernetMatch().getEthernetType().getType().getValue()); assertEquals(0, in.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java index bc45a91044..b460994303 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java @@ -12,30 +12,30 @@ import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.math.BigInteger; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata; +import org.opendaylight.yangtools.yang.common.Uint64; public class MetadataEntryDeserializerTest extends AbstractMatchEntryDeserializerTest { @Test public void deserializeEntry() { final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer(); - final BigInteger metadata = BigInteger.valueOf(20); - final BigInteger metadataMask = BigInteger.valueOf(30); + final Uint64 metadata = Uint64.valueOf(20); + final Uint64 metadataMask = Uint64.valueOf(30); writeHeader(in, false); - in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, getValueLength())); + in.writeBytes(ByteUtil.uint64toBytes(metadata)); assertEquals(metadata, deserialize(in).getMetadata().getMetadata()); assertEquals(0, in.readableBytes()); writeHeader(in, true); - in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, getValueLength())); - in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadataMask, getValueLength())); + in.writeBytes(ByteUtil.uint64toBytes(metadata)); + in.writeBytes(ByteUtil.uint64toBytes(metadataMask)); final Metadata desMetadata = deserialize(in).getMetadata(); assertEquals(metadata, desMetadata.getMetadata()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PacketTypeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PacketTypeEntryDeserializerTest.java index 27c2268c53..c9614bb000 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PacketTypeEntryDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PacketTypeEntryDeserializerTest.java @@ -16,13 +16,14 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; +import org.opendaylight.yangtools.yang.common.Uint32; public class PacketTypeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest { @Test public void deserializeEntryTest() { final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer(); - final Long packetType = 0x1894fL; + final Uint32 packetType = Uint32.valueOf(0x1894fL); writeHeader(in, false); in.writeInt(packetType.intValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java index d897510f30..8df61aaaa2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java @@ -26,7 +26,7 @@ public class TcpFlagsEntryDeserializerTest extends AbstractMatchEntryDeserialize final int tcpFlagsMask = 5; writeHeader(in, false); - in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID); + in.writeInt(EncodeConstants.ONF_EXPERIMENTER_ID.intValue()); in.writeShort(tcpFlags); TcpFlagsMatch match = deserialize(in).getTcpFlagsMatch(); @@ -34,7 +34,7 @@ public class TcpFlagsEntryDeserializerTest extends AbstractMatchEntryDeserialize assertEquals(0, in.readableBytes()); writeHeader(in, true); - in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID); + in.writeInt(EncodeConstants.ONF_EXPERIMENTER_ID.intValue()); in.writeShort(tcpFlags); in.writeShort(tcpFlagsMask); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java index f6ceff81a6..49c1e5fd05 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java @@ -34,7 +34,7 @@ public class TunnelIdEntryDeserializerTest extends AbstractMatchEntryDeserialize Tunnel match = deserialize(in).getTunnel(); assertArrayEquals( ByteUtil.convertBigIntegerToNBytes(tunnelId, EncodeConstants.SIZE_OF_LONG_IN_BYTES), - ByteUtil.convertBigIntegerToNBytes(match.getTunnelId(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + ByteUtil.uint64toBytes(match.getTunnelId())); assertEquals(0, in.readableBytes()); @@ -45,10 +45,10 @@ public class TunnelIdEntryDeserializerTest extends AbstractMatchEntryDeserialize match = deserialize(in).getTunnel(); assertArrayEquals( ByteUtil.convertBigIntegerToNBytes(tunnelId, EncodeConstants.SIZE_OF_LONG_IN_BYTES), - ByteUtil.convertBigIntegerToNBytes(match.getTunnelId(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + ByteUtil.uint64toBytes(match.getTunnelId())); assertArrayEquals( ByteUtil.convertBigIntegerToNBytes(tunnelIdMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES), - ByteUtil.convertBigIntegerToNBytes(match.getTunnelMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + ByteUtil.uint64toBytes(match.getTunnelMask())); assertEquals(0, in.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java index 416c4c37db..4d47dd6c4b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupFeaturesDeserializerTest.java @@ -26,10 +26,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupSelect; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartReplyGroupFeaturesDeserializerTest extends AbstractMultipartDeserializerTest { - private static final List MAX_GROUPS_LIST = Arrays.asList(1L, 2L, 3L, 4L); - private static final List ACTIONS_LIST = Arrays.asList(5L, 6L, 7L, 8L); + private static final List MAX_GROUPS_LIST = Arrays.asList(Uint32.valueOf(1), + Uint32.valueOf(2), Uint32.valueOf(3), Uint32.valueOf(4)); + private static final List ACTIONS_LIST = Arrays.asList(Uint32.valueOf(5), Uint32.valueOf(6), + Uint32.valueOf(7), Uint32.valueOf(8)); private static final List GROUP_TYPES_SUPPORTED = Arrays.asList( GroupTypes.GroupAll, @@ -60,11 +63,11 @@ public class MultipartReplyGroupFeaturesDeserializerTest extends AbstractMultipa buffer.writeInt(bitMaskGroups); buffer.writeInt(bitMaskCapabilities); - for (Long group: MAX_GROUPS_LIST) { + for (Uint32 group : MAX_GROUPS_LIST) { buffer.writeInt(group.intValue()); } - for (Long action: ACTIONS_LIST) { + for (Uint32 action: ACTIONS_LIST) { buffer.writeInt(action.intValue()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java index 1f4e60a534..438e85c741 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java @@ -16,6 +16,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.SetTpDstActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class SetTpDstActionSerializerTest extends AbstractSetFieldActionSerializerTest { @@ -31,7 +32,7 @@ public class SetTpDstActionSerializerTest extends AbstractSetFieldActionSerializ .build()) .build(); - assertAction(action, out -> assertEquals(Integer.valueOf(out.readUnsignedShort()), port.getValue())); + assertAction(action, out -> assertEquals(Uint16.valueOf(out.readUnsignedShort()), port.getValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java index 0c09fe5a85..56ea107427 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java @@ -16,6 +16,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.SetTpSrcActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class SetTpSrcActionSerializerTest extends AbstractSetFieldActionSerializerTest { @@ -31,7 +32,7 @@ public class SetTpSrcActionSerializerTest extends AbstractSetFieldActionSerializ .build()) .build(); - assertAction(action, out -> assertEquals(Integer.valueOf(out.readUnsignedShort()), port.getValue())); + assertAction(action, out -> assertEquals(Uint16.valueOf(out.readUnsignedShort()), port.getValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java index 933e29f393..6f1bf1a3a9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java @@ -67,6 +67,6 @@ public class TcpFlagsEntrySerializerTest extends AbstractExperimenterMatchEntryS @Override protected long getExperimenterId() { - return EncodeConstants.ONF_EXPERIMENTER_ID; + return EncodeConstants.ONF_EXPERIMENTER_ID.toJava(); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java index 4307d6db73..3bed18f781 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java @@ -30,6 +30,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.TablePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey; +import org.opendaylight.yangtools.yang.common.Uint8; public class MultipartRequestTableFeaturesSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5; @@ -40,7 +41,7 @@ public class MultipartRequestTableFeaturesSerializerTest extends AbstractSeriali private static final BigInteger METADATA_WRITE = BigInteger.TEN; private static final long MAX_ENTRIES = 12; private static final boolean IS_DEPRECATED_MASK = true; - private static final short NEXT_TABLE_ID = 43; + private static final Uint8 NEXT_TABLE_ID = Uint8.valueOf(43); private static final TableFeaturesPropType NEXT_TABLE_TYPE = TableFeaturesPropType.OFPTFPTNEXTTABLES; private static final NextTable NEXT_TABLE = new NextTableBuilder() @@ -94,7 +95,7 @@ public class MultipartRequestTableFeaturesSerializerTest extends AbstractSeriali assertEquals(NEXT_TABLE_TYPE.getIntValue(), out.readUnsignedShort()); final int propLength = out.readUnsignedShort(); final int paddingRemainder = propLength % EncodeConstants.PADDING; - assertEquals(NEXT_TABLE_ID, out.readUnsignedByte()); + assertEquals(NEXT_TABLE_ID.toJava(), out.readUnsignedByte()); if (paddingRemainder != 0) { out.skipBytes(EncodeConstants.PADDING - paddingRemainder); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializerTest.java index 5bfc3d7445..aeb101a77f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableMissTablePropertySerializerTest.java @@ -5,7 +5,6 @@ * terms of the 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.protocol.serialization.multipart.tablefeatures; import static org.junit.Assert.assertEquals; @@ -17,6 +16,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.NextTableMiss; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NextTableMissTablePropertySerializerTest extends AbstractTablePropertySerializerTest { @@ -25,7 +25,7 @@ public class NextTableMissTablePropertySerializerTest extends AbstractTablePrope final short tableId = 42; final NextTableMiss property = new NextTableMissBuilder() .setTablesMiss(new TablesMissBuilder() - .setTableIds(Collections.singletonList(tableId)) + .setTableIds(Collections.singletonList(Uint8.valueOf(tableId))) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializerTest.java index 076a589ff0..e9d97fa592 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/NextTableTablePropertySerializerTest.java @@ -17,6 +17,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.NextTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class NextTableTablePropertySerializerTest extends AbstractTablePropertySerializerTest { @@ -25,7 +26,7 @@ public class NextTableTablePropertySerializerTest extends AbstractTablePropertyS final short tableId = 42; final NextTable property = new NextTableBuilder() .setTables(new TablesBuilder() - .setTableIds(Collections.singletonList(tableId)) + .setTableIds(Collections.singletonList(Uint8.valueOf(tableId))) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java index 9cc4d36ef6..b661294a2f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java @@ -52,6 +52,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link DeviceFlowRegistryImpl}. @@ -60,7 +61,7 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; public class DeviceFlowRegistryImplTest { private static final String NODE_ID = "openflow:1"; private static final Pattern INDEX_PATTERN = Pattern.compile("^#UF\\$TABLE\\*1-([0-9]+)$"); - private static final Short DUMMY_TABLE_ID = 1; + private static final Uint8 DUMMY_TABLE_ID = Uint8.ONE; private DeviceFlowRegistryImpl deviceFlowRegistry; private FlowRegistryKey key; @@ -80,7 +81,7 @@ public class DeviceFlowRegistryImplTest { new DeviceFlowRegistryImpl(OFConstants.OFP_VERSION_1_3, dataBroker, nodeInstanceIdentifier); final FlowAndStatisticsMapList flowStats = TestFlowHelper.createFlowAndStatisticsMapListBuilder(1).build(); key = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, flowStats); - descriptor = FlowDescriptorFactory.create(key.getTableId(), new FlowId("ut:1")); + descriptor = FlowDescriptorFactory.create(Uint8.valueOf(key.getTableId()), new FlowId("ut:1")); Assert.assertEquals(0, deviceFlowRegistry.getAllFlowDescriptors().size()); deviceFlowRegistry.storeDescriptor(key, descriptor); @@ -176,7 +177,8 @@ public class DeviceFlowRegistryImplTest { @Test public void testStore() { //store the same key with different value - final FlowDescriptor descriptor2 = FlowDescriptorFactory.create(key.getTableId(), new FlowId("ut:2")); + final FlowDescriptor descriptor2 = FlowDescriptorFactory.create(Uint8.valueOf(key.getTableId()), + new FlowId("ut:2")); deviceFlowRegistry.storeDescriptor(key, descriptor2); Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size()); Assert.assertEquals("ut:2", deviceFlowRegistry.retrieveDescriptor(key).getFlowId().getValue()); @@ -244,7 +246,7 @@ public class DeviceFlowRegistryImplTest { Assert.assertEquals(1, counter.get()); } - private static Integer parseIndex(String alienFlowIdValue) { + private static Integer parseIndex(final String alienFlowIdValue) { final Matcher mach = INDEX_PATTERN.matcher(alienFlowIdValue); if (mach.find()) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorDtoTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorDtoTest.java index 45642087c1..6a901bcbcc 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorDtoTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowDescriptorDtoTest.java @@ -5,7 +5,6 @@ * terms of the 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.registry.flow; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -13,6 +12,7 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link FlowDescriptorFactory.FlowDescriptorDto}. @@ -21,15 +21,15 @@ public class FlowDescriptorDtoTest { @Test public void testCreate() { - final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 1, new FlowId("unit:1")); + final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(Uint8.ONE, new FlowId("unit:1")); Assert.assertNotNull(flowDescriptor); Assert.assertNotNull(flowDescriptor.getFlowId()); Assert.assertNotNull(flowDescriptor.getTableKey()); } @Test(expected = Exception.class) - @SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION") // that is the point of this test + @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "that is the point of this test") public void testCreateNegative1() { - FlowDescriptorFactory.create((short) 1, null); + FlowDescriptorFactory.create(Uint8.ONE, null); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java index 1d40449da2..8d7b542749 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java @@ -36,6 +36,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.f import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -91,7 +93,7 @@ public class FlowRegistryKeyFactoryTest { // different priority flowStatisticsMapListBld2 = new FlowAndStatisticsMapListBuilder(flowStatisticsMapList1); - flowStatisticsMapListBld2.setPriority(flowStatisticsMapListBld2.getPriority() + 1); + flowStatisticsMapListBld2.setPriority(flowStatisticsMapListBld2.getPriority().toJava() + 1); key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowStatisticsMapListBld2.build()); Assert.assertFalse(key1.equals(key2)); @@ -103,7 +105,7 @@ public class FlowRegistryKeyFactoryTest { // different tableId flowStatisticsMapListBld2 = new FlowAndStatisticsMapListBuilder(flowStatisticsMapList1); - flowStatisticsMapListBld2.setTableId((short) (flowStatisticsMapListBld2.getTableId() + 1)); + flowStatisticsMapListBld2.setTableId((short) (flowStatisticsMapListBld2.getTableId().toJava() + 1)); key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowStatisticsMapListBld2.build()); Assert.assertFalse(key1.equals(key2)); @@ -147,7 +149,7 @@ public class FlowRegistryKeyFactoryTest { .setTableId((short) 0); FlowBuilder fb1 = new FlowBuilder(flow1Builder.build()); - fb1.setTableId(null); + fb1.setTableId((Uint8) null); try { FlowRegistryKeyFactory.create(deviceInfo.getVersion(), fb1.build()); Assert.fail("hash creation should have failed because of NPE"); @@ -157,7 +159,7 @@ public class FlowRegistryKeyFactoryTest { } FlowBuilder fb2 = new FlowBuilder(flow1Builder.build()); - fb2.setPriority(null); + fb2.setPriority((Uint16) null); try { FlowRegistryKeyFactory.create(deviceInfo.getVersion(), fb2.build()); } catch (NullPointerException e) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContextTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContextTest.java index 11f893c10c..7522ae0d8b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContextTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/AbstractRequestContextTest.java @@ -5,7 +5,6 @@ * terms of the 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.rpc; import static org.junit.Assert.assertNotNull; @@ -15,6 +14,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class AbstractRequestContextTest { @@ -22,7 +22,7 @@ public class AbstractRequestContextTest { @Before public void setup() { - requestContext = new AbstractRequestContext(1L) { + requestContext = new AbstractRequestContext<>(Uint32.ONE) { @Override public void close() { // No-op diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallbackTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallbackTest.java index 0eca53826b..14952672a0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallbackTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallbackTest.java @@ -22,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; public class AbstractRequestCallbackTest { @@ -31,7 +32,7 @@ public class AbstractRequestCallbackTest { private static final EventIdentifier DUMMY_EVENT_IDENTIFIER = new EventIdentifier(DUMMY_EVENT_NAME, DUMMY_DEVICE_ID); private static final String DUMMY_EXCEPTION_DESCRIPTION = "dummy exception description"; - private static final Long DUMMY_XID = 100L; + private static final Uint32 DUMMY_XID = Uint32.valueOf(100L); private static final String DUMMY_MESSAGE_ILLEGAL_STATE_EXCEPTION = "dummy illegal state exception"; AbstractRequestContext dummyRequestContext; @@ -50,7 +51,7 @@ public class AbstractRequestCallbackTest { DUMMY_REQUEST_TYPE, new MessageIntelligenceAgencyImpl(), DUMMY_EVENT_IDENTIFIER) { @Override - public void onSuccess(Object object) { + public void onSuccess(final Object object) { } @@ -78,7 +79,7 @@ public class AbstractRequestCallbackTest { assertEquals(DUMMY_MESSAGE_ILLEGAL_STATE_EXCEPTION, rpcError.getMessage()); } - private RpcError provideRpcError(ListenableFuture futureResult) throws InterruptedException, + private RpcError provideRpcError(final ListenableFuture futureResult) throws InterruptedException, java.util.concurrent.ExecutionException { final Object result = futureResult.get(); assertTrue(result instanceof RpcResult); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/EchoServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/EchoServiceTest.java index cb380af69f..e0e22b4fa7 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/EchoServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/EchoServiceTest.java @@ -18,10 +18,11 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; public class EchoServiceTest extends ServiceMocking { - private static final Long DUMMY_XID_VALUE = 100L; + private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100); private static final byte[] DUMMY_DATA = "DUMMY DATA".getBytes(); EchoService echoService; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java index af573a6b7f..d6c77c7ad8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java @@ -69,6 +69,8 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; @RunWith(MockitoJUnitRunner.class) public class MultipartRequestOnTheFlyCallbackTest { @@ -76,7 +78,7 @@ public class MultipartRequestOnTheFlyCallbackTest { private static final String DUMMY_NODE_ID = "dummyNodeId"; private static final String DUMMY_EVENT_NAME = "dummy event name 1"; private static final String DUMMY_DEVICE_ID = "dummy device id 1"; - private static final Long DUMMY_XID = 55L; + private static final Uint32 DUMMY_XID = Uint32.valueOf(55L); private static final KeyedInstanceIdentifier NODE_PATH = KeyedInstanceIdentifier .create(Nodes.class) .child(Node.class, new NodeKey(new NodeId("uf-node:123"))); @@ -116,7 +118,7 @@ public class MultipartRequestOnTheFlyCallbackTest { when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection); when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_PATH); when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId); - when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); + when(mockedDeviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10)); when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); @@ -129,7 +131,7 @@ public class MultipartRequestOnTheFlyCallbackTest { final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.emptyList()); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - dummyRequestContext = new AbstractRequestContext>(DUMMY_XID) { + dummyRequestContext = new AbstractRequestContext<>(DUMMY_XID) { @Override public void close() { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java index 799ee3d433..2ebef15ced 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java @@ -12,7 +12,6 @@ import static org.mockito.Mockito.when; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import java.math.BigInteger; import org.junit.Before; import org.junit.runner.RunWith; import org.mockito.Matchers; @@ -49,12 +48,15 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public abstract class ServiceMocking { - protected static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444"); - protected static final Short DUMMY_VERSION = OFConstants.OFP_VERSION_1_3; - protected static final Long DUMMY_XID_VALUE = 2121L; + protected static final Uint64 DUMMY_DATAPATH_ID = Uint64.valueOf(444); + protected static final Uint8 DUMMY_VERSION = Uint8.valueOf(OFConstants.OFP_VERSION_1_3); + protected static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(2121L); protected static final Xid DUMMY_XID = new Xid(DUMMY_XID_VALUE); protected static final long DUMMY_EXPERIMENTER_ID = 42L; @@ -118,12 +120,12 @@ public abstract class ServiceMocking { lenient().when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II); when(mockedDeviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); - when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION); + when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION.toJava()); lenient().when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext); when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy); lenient().when(mockedDeviceContext.getDeviceFlowRegistry()) - .thenReturn(new DeviceFlowRegistryImpl(DUMMY_VERSION, dataBroker, DUMMY_NODE_II)); + .thenReturn(new DeviceFlowRegistryImpl(DUMMY_VERSION.toJava(), dataBroker, DUMMY_NODE_II)); lenient().when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); lenient().when(mockedDeviceContext.getMultiMsgCollector(Matchers.any())).thenReturn(multiMessageCollector); @@ -141,7 +143,7 @@ public abstract class ServiceMocking { when(mockedRequestContext.getFuture()).thenReturn(dummySuccessfulFuture); } - protected void mockSuccessfulFuture(T result) { + protected void mockSuccessfulFuture(final T result) { ListenableFuture> dummySuccessfulFuture = Futures.immediateFuture(RpcResultBuilder.success(result) .build()); when(mockedRequestContext.getFuture()).thenReturn(dummySuccessfulFuture); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/FlowCapableTransactionServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/FlowCapableTransactionServiceImplTest.java index e612add4ee..4f07efbaaa 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/FlowCapableTransactionServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/FlowCapableTransactionServiceImplTest.java @@ -5,7 +5,6 @@ * terms of the 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.services.sal; import static org.junit.Assert.assertEquals; @@ -20,13 +19,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link FlowCapableTransactionServiceImpl}. */ public class FlowCapableTransactionServiceImplTest extends ServiceMocking { - private static final Long DUMMY_XID_VALUE = 100L; + private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100); FlowCapableTransactionServiceImpl flowCapableTransactionService; @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/NodeConfigServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/NodeConfigServiceImplTest.java index fe39cfd7e9..1728d065f8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/NodeConfigServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/NodeConfigServiceImplTest.java @@ -19,13 +19,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.Set import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; public class NodeConfigServiceImplTest extends ServiceMocking { - private static final Long DUMMY_XID_VALUE = 150L; + private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(150); private static final SwitchConfigFlag DUMMY_FLAG = SwitchConfigFlag.FRAGNORMAL; private static final String DUMMY_FLAG_STR = "FRAGNORMAL"; - private static final Integer DUMMY_MISS_SEARCH_LENGTH = 3000; + private static final Uint16 DUMMY_MISS_SEARCH_LENGTH = Uint16.valueOf(3000); NodeConfigServiceImpl nodeConfigService; @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/PacketProcessingServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/PacketProcessingServiceImplTest.java index e8835d7695..5107449ce7 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/PacketProcessingServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/PacketProcessingServiceImplTest.java @@ -33,13 +33,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link PacketProcessingServiceImpl}. */ public class PacketProcessingServiceImplTest extends ServiceMocking { - private static final Long DUMMY_XID_VALUE = 100L; + private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100); public static final String ULTIMATE_PAYLOAD = "What do you get when you multiply six by nine?"; private PacketProcessingServiceImpl packetProcessingService; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImplTest.java index 76bcaf5cfe..71434991c5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalAsyncConfigServiceImplTest.java @@ -75,7 +75,7 @@ public class SalAsyncConfigServiceImplTest extends ServiceMocking { Assert.assertTrue(getAsyncResult.isDone()); Assert.assertTrue(getAsyncResult.get().isSuccessful()); verify(mockedRequestContextStack).createRequestContext(); - verify(mockedOutboundQueue).commitEntry(eq(ServiceMocking.DUMMY_XID_VALUE), + verify(mockedOutboundQueue).commitEntry(eq(ServiceMocking.DUMMY_XID_VALUE.toJava()), ArgumentMatchers.any(), ArgumentMatchers.any()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java index 3d56bf96bf..6b60dc7f2c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java @@ -30,13 +30,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link org.opendaylight.openflowplugin.impl.services.sal.SalExperimenterMessageServiceImpl}. */ public class SalExperimenterMessageServiceImplTest extends ServiceMocking { - private static final Long DUMMY_XID_VALUE = 100L; + private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100); private SalExperimenterMessageServiceImpl salExperimenterMessageService; @Mock private ExtensionConverterProvider extensionConverterProvider; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java index af67ef1b58..ed12ad36f4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java @@ -12,7 +12,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.common.util.concurrent.Futures; -import java.math.BigInteger; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import junit.framework.TestCase; @@ -68,11 +67,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class SalFlowServiceImplTest extends TestCase { - private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444"); + private static final Uint64 DUMMY_DATAPATH_ID = Uint64.valueOf(444); private static final String DUMMY_NODE_ID = "dummyNodeID"; private static final String DUMMY_FLOW_ID = "dummyFlowID"; private static final Short DUMMY_TABLE_ID = (short) 0; @@ -120,7 +122,7 @@ public class SalFlowServiceImplTest extends TestCase { when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy); when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry); - when(requestContext.getXid()).thenReturn(new Xid(84L)); + when(requestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(84L))); when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success().buildFuture()); when(mockedRequestContextStack.createRequestContext()).thenReturn(requestContext); @@ -130,8 +132,9 @@ public class SalFlowServiceImplTest extends TestCase { } private SalFlowServiceImpl mockSalFlowService(final short version) { - when(mockedFeatures.getVersion()).thenReturn(version); - when(mockedFeaturesOutput.getVersion()).thenReturn(version); + Uint8 ver = Uint8.valueOf(version); + when(mockedFeatures.getVersion()).thenReturn(ver); + when(mockedFeaturesOutput.getVersion()).thenReturn(ver); when(mockedDeviceInfo.getVersion()).thenReturn(version); final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); @@ -154,7 +157,7 @@ public class SalFlowServiceImplTest extends TestCase { addFlowFailCallback(OFConstants.OFP_VERSION_1_3); } - private void addFlowFailCallback(short version) throws InterruptedException, ExecutionException { + private void addFlowFailCallback(final short version) throws InterruptedException, ExecutionException { AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder() .setMatch(match) .setTableId((short)1) @@ -183,7 +186,7 @@ public class SalFlowServiceImplTest extends TestCase { removeFlowFailCallback(OFConstants.OFP_VERSION_1_3); } - private void removeFlowFailCallback(short version) throws InterruptedException, ExecutionException { + private void removeFlowFailCallback(final short version) throws InterruptedException, ExecutionException { RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder() .setTableId((short)1) .setMatch(match) @@ -207,8 +210,7 @@ public class SalFlowServiceImplTest extends TestCase { addFlow(OFConstants.OFP_VERSION_1_3); } - private void addFlow(short version) throws ExecutionException, - InterruptedException { + private void addFlow(final short version) throws ExecutionException, InterruptedException { AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder() .setMatch(match) .setTableId((short)1) @@ -231,7 +233,7 @@ public class SalFlowServiceImplTest extends TestCase { removeFlow(OFConstants.OFP_VERSION_1_3); } - private void removeFlow(short version) throws Exception { + private void removeFlow(final short version) throws Exception { RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder() .setMatch(match) .setTableId((short)1) @@ -253,7 +255,7 @@ public class SalFlowServiceImplTest extends TestCase { updateFlow(OFConstants.OFP_VERSION_1_3); } - private void updateFlow(short version) throws Exception { + private void updateFlow(final short version) throws Exception { UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class); UpdateFlowInput mockedUpdateFlowInput1 = mock(UpdateFlowInput.class); @@ -306,8 +308,8 @@ public class SalFlowServiceImplTest extends TestCase { .retrieveDescriptor(any(FlowRegistryKey.class))).thenReturn(mockedFlowDescriptor); } - private void verifyOutput(Future> rpcResultFuture) throws ExecutionException, - InterruptedException { + private static void verifyOutput(final Future> rpcResultFuture) + throws ExecutionException, InterruptedException { assertNotNull(rpcResultFuture); final RpcResult addFlowOutputRpcResult = rpcResultFuture.get(); assertNotNull(addFlowOutputRpcResult); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImplTest.java index ee020f7092..34d469848c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImplTest.java @@ -29,12 +29,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.Upda import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class SalPortServiceImplTest extends ServiceMocking { - private static final Long DUMMY_XID = 55L; - private static final Long DUMMY_PORT_NUMBER = 66L; + private static final Uint32 DUMMY_XID = Uint32.valueOf(55L); + private static final Uint32 DUMMY_PORT_NUMBER = Uint32.valueOf(66L); private static final String DUMMY_MAC_ADDRESS = "AA:BB:CC:DD:EE:FF"; SalPortServiceImpl salPortService; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java index e9b7557635..59827b7cff 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import com.google.common.util.concurrent.ListenableFuture; -import java.math.BigInteger; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.junit.Before; @@ -47,6 +46,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetR import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public class SalRoleServiceImplTest { @@ -80,7 +82,7 @@ public class SalRoleServiceImplTest { @Mock private OutboundQueue mockOutboundQueue; - private NodeId testNodeId = new NodeId(Uri.getDefaultInstance("openflow:1")); + private final NodeId testNodeId = new NodeId(Uri.getDefaultInstance("openflow:1")); private static long testXid = 100L; @@ -95,8 +97,8 @@ public class SalRoleServiceImplTest { public void setup() { MockitoAnnotations.initMocks(this); Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId); - Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); - short testVersion = 4; + Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10)); + Uint8 testVersion = Uint8.valueOf(4); Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion); Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState); Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo); @@ -106,7 +108,7 @@ public class SalRoleServiceImplTest { Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion); Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy); Mockito.when(mockRequestContextStack.createRequestContext()).thenReturn(mockRequestContext); - Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(testXid)); + Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(testXid))); Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue); Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()) .thenReturn(ConnectionContext.CONNECTION_STATE.WORKING); @@ -121,8 +123,8 @@ public class SalRoleServiceImplTest { @Test public void testSetRole() throws Exception { - RoleRequestOutput roleRequestOutput = (new RoleRequestOutputBuilder()) - .setXid(testXid).setGenerationId(BigInteger.valueOf(1)).build(); + RoleRequestOutput roleRequestOutput = new RoleRequestOutputBuilder() + .setXid(testXid).setGenerationId(Uint64.ONE).build(); ListenableFuture> futureOutput = RpcResultBuilder.success().withResult(roleRequestOutput).buildFuture(); @@ -144,7 +146,7 @@ public class SalRoleServiceImplTest { SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult(); assertNotNull(setRoleOutput); - assertEquals(BigInteger.valueOf(testXid), setRoleOutput.getTransactionId().getValue()); + assertEquals(Uint64.valueOf(testXid), setRoleOutput.getTransactionId().getValue()); } @@ -152,8 +154,8 @@ public class SalRoleServiceImplTest { public void testDuplicateRoles() throws Exception { // set role to slave - RoleRequestOutput roleRequestOutput = (new RoleRequestOutputBuilder()) - .setXid(testXid).setGenerationId(BigInteger.valueOf(1)).build(); + RoleRequestOutput roleRequestOutput = new RoleRequestOutputBuilder() + .setXid(testXid).setGenerationId(Uint64.ONE).build(); ListenableFuture> futureOutput = RpcResultBuilder.success().withResult(roleRequestOutput).buildFuture(); @@ -174,7 +176,7 @@ public class SalRoleServiceImplTest { SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult(); assertNotNull(setRoleOutput); - assertEquals(BigInteger.valueOf(testXid), setRoleOutput.getTransactionId().getValue()); + assertEquals(Uint64.valueOf(testXid), setRoleOutput.getTransactionId().getValue()); // make another role change with the same role - slave Future> future2 = salRoleService.setRole(setRoleInput); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java index 0830033a90..849d528e29 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java @@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.services.singlelayer; import static org.junit.Assert.assertEquals; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import org.junit.Test; @@ -25,10 +24,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint64; public class SingleLayerAggregateFlowMultipartServiceTest extends ServiceMocking { private static final short TABLE_ID = 42; - private static final BigInteger BYTE_COUNT = BigInteger.TEN; + private static final Uint64 BYTE_COUNT = Uint64.valueOf(10); private SingleLayerAggregateFlowMultipartService service; @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerPortServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerPortServiceTest.java index c4522bc74c..277b0f05d6 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerPortServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerPortServiceTest.java @@ -5,7 +5,6 @@ * terms of the 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.services.singlelayer; import static org.junit.Assert.assertEquals; @@ -18,15 +17,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.p import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput; +import org.opendaylight.yangtools.yang.common.Uint32; public class SingleLayerPortServiceTest extends ServiceMocking { - private static final long PORT_ID = 42; + private static final Uint32 PORT_ID = Uint32.valueOf(42); private SingleLayerPortService service; @Override protected void setup() { - service = new SingleLayerPortService<>(mockedRequestContextStack, - mockedDeviceContext, UpdatePortOutput.class); + service = new SingleLayerPortService<>(mockedRequestContextStack, mockedDeviceContext, UpdatePortOutput.class); } @Test @@ -40,6 +39,6 @@ public class SingleLayerPortServiceTest extends ServiceMocking { final PortMessage result = (PortMessage) ofHeader; - assertEquals(PORT_ID, result.getPortNumber().getUint32().longValue()); + assertEquals(PORT_ID, result.getPortNumber().getUint32()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtilsTest.java index 46404a133c..2784d22bd6 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/util/RequestInputUtilsTest.java @@ -15,19 +15,20 @@ import org.junit.Test; import org.opendaylight.openflowplugin.api.OFConstants; 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; +import org.opendaylight.yangtools.yang.common.Uint32; public class RequestInputUtilsTest { @Test public void createMultipartHeader() { - final Short version = OFConstants.OFP_VERSION_1_3; - final Long xid = 42L; + final short version = OFConstants.OFP_VERSION_1_3; + final Uint32 xid = Uint32.valueOf(42L); final MultipartType type = MultipartType.OFPMPDESC; final MultipartRequestInput input = RequestInputUtils .createMultipartHeader(type, xid, version) .build(); - assertEquals(version, input.getVersion()); + assertEquals(version, input.getVersion().toJava()); assertEquals(xid, input.getXid()); assertEquals(type, input.getType()); assertFalse(input.getFlags().isOFPMPFREQMORE()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java index 456742883e..482cc61172 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java @@ -13,7 +13,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.common.collect.Lists; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.junit.Before; @@ -53,31 +52,34 @@ 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.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public class MultipartReplyTranslatorTest { - private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("21"); - private static final Long DUMMY_XID = 1L; - 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; + private static final Uint64 DUMMY_DATAPATH_ID = Uint64.valueOf(21); + private static final Uint32 DUMMY_XID = Uint32.ONE; + private static final Uint64 DUMMY_BYTE_COUNT = Uint64.valueOf(31); + private static final Uint64 DUMMY_PACKET_COUNT = Uint64.valueOf(41); + private static final Uint32 DUMMY_FLOW_COUNT = Uint32.valueOf(51); private static final Long DUMMY_PORT_NO = 154L; - private static final BigInteger DUMMY_RX_BYTES = new BigInteger("155"); - private static final BigInteger DUMMY_TX_BYTES = new BigInteger("165"); - private static final BigInteger DUMMY_RX_PACKETS = new BigInteger("175"); - private static final BigInteger DUMMY_TX_PACKETS = new BigInteger("185"); - private static final BigInteger DUMMY_COLLISIONS = new BigInteger("195"); - private static final BigInteger DUMMY_RX_CRC_ERR = new BigInteger("205"); - private static final BigInteger DUMMY_RX_DROPPED = new BigInteger("215"); - private static final BigInteger DUMMY_RX_ERRORS = new BigInteger("225"); - private static final BigInteger DUMMY_RX_FRAME_ERR = new BigInteger("235"); - private static final BigInteger DUMMY_OVER_ERR = new BigInteger("245"); - private static final BigInteger DUMMY_TX_DROPPED = new BigInteger("255"); - private static final BigInteger DUMMY_TX_ERRORS = new BigInteger("265"); - private static final Long DUMMY_DURATION_SEC = 3453L; - private static final Long DUMMY_DURATION_NSEC = 3343L; + private static final Uint64 DUMMY_RX_BYTES = Uint64.valueOf(155); + private static final Uint64 DUMMY_TX_BYTES = Uint64.valueOf(165); + private static final Uint64 DUMMY_RX_PACKETS = Uint64.valueOf(175); + private static final Uint64 DUMMY_TX_PACKETS = Uint64.valueOf(185); + private static final Uint64 DUMMY_COLLISIONS = Uint64.valueOf(195); + private static final Uint64 DUMMY_RX_CRC_ERR = Uint64.valueOf(205); + private static final Uint64 DUMMY_RX_DROPPED = Uint64.valueOf(215); + private static final Uint64 DUMMY_RX_ERRORS = Uint64.valueOf(225); + private static final Uint64 DUMMY_RX_FRAME_ERR = Uint64.valueOf(235); + private static final Uint64 DUMMY_OVER_ERR = Uint64.valueOf(245); + private static final Uint64 DUMMY_TX_DROPPED = Uint64.valueOf(255); + private static final Uint64 DUMMY_TX_ERRORS = Uint64.valueOf(265); + private static final Uint32 DUMMY_DURATION_SEC = Uint32.valueOf(3453); + private static final Uint32 DUMMY_DURATION_NSEC = Uint32.valueOf(3343); private static final GroupId DUMMY_GROUP_ID = new GroupId(55L); - private static final Long DUMMY_REF_COUNT = 1234L; + private static final Uint32 DUMMY_REF_COUNT = Uint32.valueOf(1234); private static final GroupTypes DUMMY_GROUPS_TYPE = GroupTypes.GroupAll; private static final GroupType DUMMY_GROUP_TYPE = GroupType.OFPGTALL; private static final ConvertorManager CONVERTOR_MANAGER = ConvertorManagerFactory.createDefaultManager(); @@ -290,12 +292,12 @@ public class MultipartReplyTranslatorTest { return multipartReplyFlowCaseBuilder.build(); } - private MultipartReplyMessage prepareMocks(DeviceContext mockedDeviceContext, - MultipartReplyBody multipartReplyBody, + private MultipartReplyMessage prepareMocks(final DeviceContext mockedDeviceContext, + final MultipartReplyBody multipartReplyBody, final MultipartType multipartType) { ConnectionContext mockedConnectionContext = mock(ConnectionContext.class); FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class); - when(mockedFeaturesReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + when(mockedFeaturesReply.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); when(mockedFeaturesReply.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); DeviceInfo deviceInfo = mock(DeviceInfo.class); @@ -314,7 +316,7 @@ public class MultipartReplyTranslatorTest { return multipartReplyMessage; } - private DataContainer validateOutput(DataContainer dataObject) { + private DataContainer validateOutput(final DataContainer dataObject) { return dataObject; } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java index a6b3d8565d..8269dbe12d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java @@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.impl.statistics; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.math.BigInteger; import org.junit.Before; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; @@ -32,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint64; public class StatisticsContextImpMockInitiation { Boolean isTable = false; @@ -76,7 +76,7 @@ public class StatisticsContextImpMockInitiation { when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy); when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_ID); - when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); + when(mockedDeviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10)); when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java index 760f37b240..dc4c50a54b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java @@ -35,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,7 +85,7 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio public void testCreateRequestContext() { final RequestContext requestContext = statisticsContext.createRequestContext(); assertNotNull(requestContext); - assertEquals(TEST_XID, requestContext.getXid().getValue()); + assertEquals(Uint32.valueOf(TEST_XID), requestContext.getXid().getValue()); Assert.assertFalse(requestContext.getFuture().isDone()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java index fe4e0e0ee8..daa39ee38d 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java @@ -132,6 +132,8 @@ import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class StatisticsGatheringUtilsTest { @@ -180,10 +182,10 @@ public class StatisticsGatheringUtilsTest { when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionAdapter); when(deviceContext.isTransactionsEnabled()).thenReturn(Boolean.TRUE); when(connectionAdapter.getFeatures()).thenReturn(features); - when(features.getDatapathId()).thenReturn(BigInteger.ONE); - when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + when(features.getDatapathId()).thenReturn(Uint64.ONE); + when(features.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); - when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE); + when(deviceInfo.getDatapathId()).thenReturn(Uint64.ONE); when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodePath); when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID); provider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java index d5693a9335..d52ae0fe73 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java @@ -14,6 +14,7 @@ import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; public abstract class AbstractSingleStatsServiceTest extends AbstractStatsServiceTest { @@ -27,7 +28,7 @@ public abstract class AbstractSingleStatsServiceTest extends AbstractStatsServic @Override public void init() throws Exception { super.init(); - rqContext = new AbstractRequestContext(42L) { + rqContext = new AbstractRequestContext<>(Uint32.valueOf(42)) { @Override public void close() { //NOOP diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java index 66f59b0193..48ca4622e0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java @@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import static org.mockito.ArgumentMatchers.any; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import org.junit.Before; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -38,6 +37,8 @@ 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.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Created by mirehak on 7/23/15. @@ -71,7 +72,7 @@ public abstract class AbstractStatsServiceTest { public static final NodeId NODE_ID = new NodeId("unit-test-node:123"); protected final Answer answerVoidToCallback = invocation -> { - final FutureCallback callback = (FutureCallback) (invocation.getArguments()[2]); + final FutureCallback callback = (FutureCallback) invocation.getArguments()[2]; callback.onSuccess(null); return null; }; @@ -87,12 +88,12 @@ public abstract class AbstractStatsServiceTest { Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); Mockito.lenient().when(deviceInfo.getNodeId()).thenReturn(NODE_ID); Mockito.lenient().when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); - Mockito.lenient().when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); + Mockito.lenient().when(deviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10)); Mockito.lenient().when(connectionContext.getFeatures()).thenReturn(features); Mockito.lenient().when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider); - Mockito.lenient().when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); - Mockito.lenient().when(getFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L)); - Mockito.lenient().when(getFeaturesOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + Mockito.lenient().when(features.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); + Mockito.lenient().when(getFeaturesOutput.getDatapathId()).thenReturn(Uint64.valueOf(123L)); + Mockito.lenient().when(getFeaturesOutput.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); setUp(); } @@ -101,7 +102,7 @@ public abstract class AbstractStatsServiceTest { //NOOP } - protected static NodeRef createNodeRef(String nodeIdValue) { + protected static NodeRef createNodeRef(final String nodeIdValue) { InstanceIdentifier nodePath = InstanceIdentifier.create(Nodes.class) .child(Node.class, new NodeKey(new NodeId(nodeIdValue))); return new NodeRef(nodePath); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java index 9c68de8af6..24c097c927 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java @@ -5,7 +5,6 @@ * terms of the 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.statistics.services; import java.util.concurrent.Future; @@ -23,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.G import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods (failing). @@ -34,12 +34,13 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer private OpendaylightFlowStatisticsServiceImpl flowStatisticsService; + @Override public void setUp() { final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager); - AbstractRequestContext rqContext = new AbstractRequestContext(42L) { + AbstractRequestContext rqContext = new AbstractRequestContext<>(Uint32.valueOf(42)) { @Override public void close() { //NOOP diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java index d36d7a4a25..fab5bb07aa 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only not delegated method. @@ -54,13 +55,14 @@ public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsSer private OpendaylightFlowStatisticsServiceImpl flowStatisticsService; + @Override public void setUp() { final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager); - rqContextMp = new AbstractRequestContext>(42L) { + rqContextMp = new AbstractRequestContext<>(Uint32.valueOf(42L)) { @Override public void close() { //NOOP diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java index 6005d67f0e..30bde430f5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java @@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link OpendaylightFlowTableStatisticsServiceImpl}. @@ -48,6 +49,7 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing private OpendaylightFlowTableStatisticsServiceImpl flowTableStatisticsService; + @Override public void setUp() { flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext, new AtomicLong(), notificationPublishService); @@ -94,7 +96,7 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing @Test public void testBuildRequest() { - Xid xid = new Xid(42L); + Xid xid = new Xid(Uint32.valueOf(42L)); GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")); final OfHeader request = flowTableStatisticsService.buildRequest(xid, input.build()); @@ -103,7 +105,7 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing Assert.assertEquals(MultipartType.OFPMPTABLE, mpRequest.getType()); Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestTableCase); final MultipartRequestTableCase mpRequestBody = - (MultipartRequestTableCase) (mpRequest.getMultipartRequestBody()); + (MultipartRequestTableCase) mpRequest.getMultipartRequestBody(); Assert.assertNotNull(mpRequestBody.getMultipartRequestTable().getEmpty()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java index 848d03b06e..9d5792a508 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java @@ -55,6 +55,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.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link OpendaylightGroupStatisticsServiceImpl}. @@ -69,6 +70,7 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt private OpendaylightGroupStatisticsServiceImpl groupStatisticsService; + @Override public void setUp() { final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(rqContextStack, deviceContext, @@ -147,7 +149,7 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt false, false, false, false, false, false))) .setCapabilities(new GroupCapabilities(true, false, false, false)) .setTypes(new GroupTypes(true, false, false, false)) - .setMaxGroups(Collections.singletonList(5L)) + .setMaxGroups(Collections.singletonList(Uint32.valueOf(5L))) .build()) .build()) .build() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsServiceTest.java index 8cf5e207d1..e1cbf900ea 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsServiceTest.java @@ -17,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test of {@link PortStatsService}. @@ -25,6 +26,7 @@ public class PortStatsServiceTest extends AbstractStatsServiceTest { private PortStatsService portStatsService; + @Override public void setUp() { portStatsService = new PortStatsService(rqContextStack, deviceContext, new AtomicLong()); @@ -32,7 +34,7 @@ public class PortStatsServiceTest extends AbstractStatsServiceTest { @Test public void testBuildRequest() { - Xid xid = new Xid(42L); + Xid xid = new Xid(Uint32.valueOf(42L)); GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder() .setNodeConnectorId(new NodeConnectorId("junitProto:11:12")) .setNode(createNodeRef("junitProto:11")); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java index 062878b254..92423c7896 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java @@ -52,6 +52,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link AbstractCompatibleStatService}. @@ -81,7 +83,7 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest @Override public void setUp() { - rqContext = new AbstractRequestContext(42L) { + rqContext = new AbstractRequestContext<>(Uint32.valueOf(42)) { @Override public void close() { //NOOP @@ -93,7 +95,7 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest return null; }; - Mockito.lenient().when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + Mockito.lenient().when(featuresOutput.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); Mockito.when(rqContextStack.createRequestContext()).thenReturn(rqContext); Mockito.lenient().when(deviceContext.getDeviceState()).thenReturn(deviceState); Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyServiceTest.java index b31393d874..38f9efab3d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyServiceTest.java @@ -22,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link StatisticsGatheringOnTheFlyService}. @@ -53,11 +54,10 @@ public class StatisticsGatheringOnTheFlyServiceTest extends ServiceMocking { @Test public void testBuildRequest() { - final long xidValue = 21L; - Xid xid = new Xid(xidValue); + Xid xid = new Xid(Uint32.valueOf(21)); final OfHeader request = statisticsGatheringService.buildRequest(xid, MultipartType.OFPMPFLOW); - Assert.assertEquals(MultipartRequestInput.class, request.implementedInterface()); - Assert.assertEquals(xidValue, request.getXid().longValue()); Assert.assertNotNull(request); + Assert.assertEquals(MultipartRequestInput.class, request.implementedInterface()); + Assert.assertEquals(xid.getValue(), request.getXid()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringServiceTest.java index 8ba5942262..52f56452f8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringServiceTest.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.impl.services.ServiceMocking; 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; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link StatisticsGatheringService}. @@ -44,7 +45,7 @@ public class StatisticsGatheringServiceTest extends ServiceMocking { @Test public void testBuildRequest() { final long xidValue = 21L; - Xid xid = new Xid(xidValue); + Xid xid = new Xid(Uint32.valueOf(xidValue)); for (MultipartType mpType : MultipartType.values()) { final OfHeader request = statisticsGatheringService.buildRequest(xid, mpType); Assert.assertEquals(MultipartRequestInput.class, request.implementedInterface()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java index e793c8fd9d..86f70f3b3b 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java @@ -12,7 +12,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; -import java.math.BigInteger; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -47,12 +46,15 @@ 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.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public abstract class AbstractDirectStatisticsServiceTest { - protected static final Long PORT_NO = 1L; - protected static final BigInteger DATAPATH_ID = BigInteger.TEN; - protected static final short OF_VERSION = OFConstants.OFP_VERSION_1_3; + protected static final Uint32 PORT_NO = Uint32.ONE; + protected static final Uint64 DATAPATH_ID = Uint64.valueOf(10); + protected static final Uint8 OF_VERSION = Uint8.valueOf(OFConstants.OFP_VERSION_1_3); protected static final String NODE_ID = "openflow:10"; @Mock @@ -89,7 +91,7 @@ public abstract class AbstractDirectStatisticsServiceTest { protected ConvertorManager convertorManager; protected MultipartWriterProvider multipartWriterProvider; - protected static NodeRef createNodeRef(String nodeIdValue) { + protected static NodeRef createNodeRef(final String nodeIdValue) { InstanceIdentifier nodePath = InstanceIdentifier.create(Nodes.class) .child(Node.class, new NodeKey(new NodeId(nodeIdValue))); @@ -117,7 +119,7 @@ public abstract class AbstractDirectStatisticsServiceTest { when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier); lenient().when(deviceInfo.getNodeId()).thenReturn(new NodeId(NODE_ID)); - when(deviceInfo.getVersion()).thenReturn(OF_VERSION); + when(deviceInfo.getVersion()).thenReturn(OF_VERSION.toJava()); when(deviceInfo.getDatapathId()).thenReturn(DATAPATH_ID); lenient().when(getFeaturesOutput.getVersion()).thenReturn(OF_VERSION); lenient().when(getFeaturesOutput.getDatapathId()).thenReturn(DATAPATH_ID); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java index 3fced71de2..a0798eeb48 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java @@ -39,9 +39,11 @@ 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.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; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Short TABLE_NO = 1; + static final Uint8 TABLE_NO = Uint8.ONE; private FlowDirectStatisticsService service; @Override @@ -62,7 +64,7 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer when(input.getTableId()).thenReturn(TABLE_NO); final MultipartRequestFlowCase body = (MultipartRequestFlowCase) ((MultipartRequestInput) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42L)), input)) .getMultipartRequestBody(); final MultipartRequestFlow flow = body.getMultipartRequestFlow(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java index c50f80cf5d..204d1a2a2c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java @@ -34,9 +34,10 @@ 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.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; +import org.opendaylight.yangtools.yang.common.Uint32; public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Long GROUP_NO = 1L; + static final Uint32 GROUP_NO = Uint32.ONE; private GroupDirectStatisticsService service; @Override @@ -55,7 +56,7 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(input.getGroupId()).thenReturn(new GroupId(GROUP_NO)); final MultipartRequestGroupCase body = (MultipartRequestGroupCase) ((MultipartRequestInput) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42)), input)) .getMultipartRequestBody(); final MultipartRequestGroup group = body.getMultipartRequestGroup(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java index 6faddacb79..6b323f3a21 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java @@ -33,9 +33,10 @@ 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.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; +import org.opendaylight.yangtools.yang.common.Uint32; public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Long METER_NO = 1L; + static final Uint32 METER_NO = Uint32.valueOf(1); private MeterDirectStatisticsService service; @Override @@ -51,7 +52,7 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(input.getMeterId()).thenReturn(new MeterId(METER_NO)); final MultipartRequestMeterCase body = (MultipartRequestMeterCase) ((MultipartRequestInput) service - .buildRequest(new Xid(42L), input)).getMultipartRequestBody(); + .buildRequest(new Xid(Uint32.valueOf(42L)), input)).getMultipartRequestBody(); final MultipartRequestMeter meter = body.getMultipartRequestMeter(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java index 321be4b1e6..e702635e74 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -33,6 +32,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { private PortDirectStatisticsService service; @@ -53,7 +54,7 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat when(input.getNodeConnectorId()).thenReturn(nodeConnectorId); final MultipartRequestPortStatsCase body = (MultipartRequestPortStatsCase) ((MultipartRequestInput)service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42)), input)) .getMultipartRequestBody(); final MultipartRequestPortStats nodeConnector = body.getMultipartRequestPortStats(); @@ -75,17 +76,17 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat when(reply.getMultipartReplyBody()).thenReturn(nodeConnectorCase); when(nodeConnectorStat.getPortNo()).thenReturn(PORT_NO); - when(nodeConnectorStat.getTxBytes()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getCollisions()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxBytes()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxCrcErr()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxDropped()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxErrors()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxFrameErr()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxOverErr()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getRxPackets()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getTxDropped()).thenReturn(BigInteger.ONE); - when(nodeConnectorStat.getTxErrors()).thenReturn(BigInteger.ONE); + when(nodeConnectorStat.getTxBytes()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getCollisions()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxBytes()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxCrcErr()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxDropped()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxErrors()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxFrameErr()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxOverErr()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getRxPackets()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getTxDropped()).thenReturn(Uint64.ONE); + when(nodeConnectorStat.getTxErrors()).thenReturn(Uint64.ONE); final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true); assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java index 96df59863c..3af233d84e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.junit.Test; @@ -36,9 +35,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Long QUEUE_NO = 1L; + static final Uint32 QUEUE_NO = Uint32.ONE; private QueueDirectStatisticsService service; @Override @@ -58,7 +59,7 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(input.getNodeConnectorId()).thenReturn(new NodeConnectorId(NODE_ID + ":" + PORT_NO)); final MultipartRequestQueueCase body = (MultipartRequestQueueCase) ((MultipartRequestInput) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42)), input)) .getMultipartRequestBody(); final MultipartRequestQueue queue = body.getMultipartRequestQueue(); @@ -82,9 +83,11 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(queueStat.getPortNo()).thenReturn(PORT_NO); when(queueStat.getQueueId()).thenReturn(QUEUE_NO); - when(queueStat.getTxBytes()).thenReturn(BigInteger.ONE); - when(queueStat.getTxErrors()).thenReturn(BigInteger.ONE); - when(queueStat.getTxPackets()).thenReturn(BigInteger.ONE); + when(queueStat.getTxBytes()).thenReturn(Uint64.ONE); + when(queueStat.getTxErrors()).thenReturn(Uint64.ONE); + when(queueStat.getTxPackets()).thenReturn(Uint64.ONE); + when(queueStat.getDurationSec()).thenReturn(Uint32.ZERO); + when(queueStat.getDurationNsec()).thenReturn(Uint32.ZERO); final GetQueueStatisticsOutput output = service.buildReply(input, true); assertTrue(output.getQueueIdAndStatisticsMap().size() > 0); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java index d0eee124fc..23ab51a41d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java @@ -40,9 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Short TABLE_NO = 1; + static final Uint8 TABLE_NO = Uint8.ONE; private FlowDirectStatisticsService service; @Override @@ -63,7 +65,7 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer when(input.getTableId()).thenReturn(TABLE_NO); final MultipartRequestFlowStats body = (MultipartRequestFlowStats) ((MultipartRequest) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42L)), input)) .getMultipartRequestBody(); assertEquals(TABLE_NO, body.getFlowStats().getTableId()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java index f43224e5a6..dce3d3ea5e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java @@ -32,9 +32,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yangtools.yang.common.Uint32; public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Long GROUP_NO = 1L; + static final Uint32 GROUP_NO = Uint32.ONE; private GroupDirectStatisticsService service; @Override @@ -53,7 +54,7 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(input.getGroupId()).thenReturn(new GroupId(GROUP_NO)); final MultipartRequestGroupStats body = (MultipartRequestGroupStats) ((MultipartRequest) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42L)), input)) .getMultipartRequestBody(); assertEquals(GROUP_NO, body.getGroupId().getValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java index 0e85f37114..5ccb4d506f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java @@ -37,9 +37,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yangtools.yang.common.Uint32; public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Long METER_NO = 1L; + static final Uint32 METER_NO = Uint32.ONE; private MeterDirectStatisticsService service; @Override @@ -58,7 +59,7 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(input.getMeterId()).thenReturn(new MeterId(METER_NO)); final MultipartRequestMeterStats body = (MultipartRequestMeterStats) ((MultipartRequest) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42L)), input)) .getMultipartRequestBody(); assertEquals(METER_NO, body.getMeterId().getValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java index 22497a949a..932f659898 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java @@ -31,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.m import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { private PortDirectStatisticsService service; @@ -51,7 +52,7 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat when(input.getNodeConnectorId()).thenReturn(nodeConnectorId); final MultipartRequestPortStats body = (MultipartRequestPortStats) ((MultipartRequest)service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42L)), input)) .getMultipartRequestBody(); assertEquals(nodeConnectorId, body.getNodeConnectorId()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java index 5383a96ac3..bb50e72972 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java @@ -36,9 +36,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { - static final Long QUEUE_NO = 1L; + static final Uint32 QUEUE_NO = Uint32.ONE; private QueueDirectStatisticsService service; @Override @@ -58,7 +59,7 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(input.getNodeConnectorId()).thenReturn(nodeConnectorId); final MultipartRequestQueueStats body = (MultipartRequestQueueStats) ((MultipartRequest) service - .buildRequest(new Xid(42L), input)) + .buildRequest(new Xid(Uint32.valueOf(42L)), input)) .getMultipartRequestBody(); assertEquals(nodeConnectorId, body.getNodeConnectorId()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java index 4bf6d176de..12a8fc89fd 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java @@ -83,7 +83,7 @@ public class FlowRemovedTranslatorTest { assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue()); assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority()); - assertEquals((long)flowRemovedMessage.getTableId().getValue(), (long)flowRemoved.getTableId()); + assertEquals(flowRemovedMessage.getTableId().getValue().toJava(), flowRemoved.getTableId().toJava()); } @Test @@ -98,7 +98,7 @@ public class FlowRemovedTranslatorTest { } private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved - buildMessage(boolean isV10) { + buildMessage(final boolean isV10) { FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder() .setCookie(BigInteger.ONE) .setReason(FlowRemovedReason.OFPRRGROUPDELETE) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java index b0ae933a03..5ab9c03738 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java @@ -49,6 +49,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint64; @RunWith(MockitoJUnitRunner.class) public class PacketReceivedTranslatorTest { @@ -82,7 +83,7 @@ public class PacketReceivedTranslatorTest { final List phyPorts = Collections.singletonList(phyPort); convertorManager = ConvertorManagerFactory.createDefaultManager(); - Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); + Mockito.when(deviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10)); } @Test @@ -131,16 +132,14 @@ public class PacketReceivedTranslatorTest { PacketInMessageBuilder inputBld = new PacketInMessageBuilder() .setMatch(packetInMatchBld.build()) .setVersion(OFConstants.OFP_VERSION_1_3); - BigInteger dpid = BigInteger.TEN; - final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager); - final Match packetInMatch = packetReceivedTranslator.getPacketInMatch(inputBld.build(), dpid); + final Match packetInMatch = packetReceivedTranslator.getPacketInMatch(inputBld.build(), Uint64.valueOf(10)); Assert.assertNotNull(packetInMatch.getInPort()); Assert.assertEquals("openflow:10:" + PORT_NUM_VALUE, packetInMatch.getInPort().getValue()); } - private static MatchEntryBuilder assembleMatchEntryBld(long portNumValue) { + private static MatchEntryBuilder assembleMatchEntryBld(final long portNumValue) { MatchEntryBuilder matchEntryBuilder = prepareHeader(InPort.class, false); InPortBuilder inPortBld = new InPortBuilder().setPortNumber(new PortNumber(portNumValue)); InPortCaseBuilder caseBuilder = new InPortCaseBuilder(); @@ -149,7 +148,8 @@ public class PacketReceivedTranslatorTest { return matchEntryBuilder; } - private static MatchEntryBuilder prepareHeader(Class oxmMatchField, boolean hasMask) { + private static MatchEntryBuilder prepareHeader(final Class oxmMatchField, + final boolean hasMask) { MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(oxmMatchField); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java index e59364f3a6..f01fcebffd 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java @@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class DeviceInitializationUtilTest { @@ -50,7 +51,7 @@ public class DeviceInitializationUtilTest { .createNodeInstanceIdentifier(new NodeId("openflow:1")); private static final int PORT = 2017; private static final InetSocketAddress INET_SOCKET_ADDRESS = new InetSocketAddress("192.168.0.1", PORT); - private static final short TABLES = 25; + private static final Uint8 TABLES = Uint8.valueOf(25); @Mock private DataBroker dataBroker; @@ -74,7 +75,7 @@ public class DeviceInitializationUtilTest { when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(connectionAdapter.getRemoteAddress()).thenReturn(INET_SOCKET_ADDRESS); when(featuresReply.getTables()).thenReturn(TABLES); - when(featuresReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + when(featuresReply.getVersion()).thenReturn(Uint8.valueOf(OFConstants.OFP_VERSION_1_3)); when(featuresReply.getCapabilities()).thenReturn(new Capabilities(false, false, false, false, false, false, false)); when(connectionContext.getFeatures()).thenReturn(featuresReply); @@ -113,7 +114,7 @@ public class DeviceInitializationUtilTest { @Test public void getSwitchFeatures() { final SwitchFeatures switchFeatures = DeviceInitializationUtil.getSwitchFeatures(connectionContext); - assertEquals(TABLES, switchFeatures.getMaxTables().shortValue()); + assertEquals(TABLES, switchFeatures.getMaxTables()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java index 2c6a45b14b..244a1142c3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java @@ -35,12 +35,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class FlowUtilTest { public static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId"); public static final FlowId DUMMY_FLOW_ID = new FlowId("dummyFlowId"); public static final FlowId DUMMY_FLOW_ID_2 = new FlowId("dummyFlowId_2"); - public static final Short DUMMY_TABLE_ID = 1; + public static final Uint8 DUMMY_TABLE_ID = Uint8.ONE; @Test public void testBuildFlowPath() { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java index 7fde060327..9384121a97 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java @@ -36,6 +36,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link GroupUtil}. @@ -45,7 +46,7 @@ public class GroupUtilTest { private static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId"); private static final GroupId DUMMY_GROUP_ID = new GroupId(42L); private static final GroupId DUMMY_GROUP_ID_2 = new GroupId(43L); - private static final Long GROUP_ACTION_BITMAP = + private static final long GROUP_ACTION_BITMAP = 0b00000000000000000000000000000000000001111111111111001100000000001L; @Test @@ -218,11 +219,10 @@ public class GroupUtilTest { public void testExtractGroupActionsSupportBitmap() { ActionType actionSupported = new ActionType(true,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true); - final List groupActionsSupportBitmap = + final List groupActionsSupportBitmap = GroupUtil.extractGroupActionsSupportBitmap(Lists.newArrayList(actionSupported)); assertEquals(1, groupActionsSupportBitmap.size()); - final Long bitmap = groupActionsSupportBitmap.get(0); - assertEquals(GROUP_ACTION_BITMAP, bitmap); + assertEquals(GROUP_ACTION_BITMAP, groupActionsSupportBitmap.get(0).toJava()); } private RpcResult createBarrierFailureOutcome() { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java index c1a619c5e1..7c768174d9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java @@ -13,7 +13,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,6 +31,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorM import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply; import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.common.Uint64; @RunWith(MockitoJUnitRunner.class) public class MdSalRegistrationUtilsTest { @@ -56,8 +56,6 @@ public class MdSalRegistrationUtilsTest { @Mock private FeaturesReply mockedFeatures; @Mock - private BigInteger mockedDataPathId; - @Mock private ExtensionConverterProvider extensionConverterProvider; @Mock private NotificationPublishService notificationPublishService; @@ -69,7 +67,7 @@ public class MdSalRegistrationUtilsTest { convertorManager = ConvertorManagerFactory.createDefaultManager(); when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures); - when(mockedDeviceInfo.getDatapathId()).thenReturn(mockedDataPathId); + when(mockedDeviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(12345)); when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java index cd7920d2b7..a7c52f50d3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java @@ -26,17 +26,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; @RunWith(MockitoJUnitRunner.class) public class NodeConnectorRefToPortTranslatorTest extends TestCase { private static final String PACKET_DATA = "Test_Data"; - private static final Long PORT_NO = 5L; - private static final BigInteger DATA_PATH_ID = BigInteger.TEN; + private static final Uint32 PORT_NO = Uint32.valueOf(5L); + private static final Uint64 DATA_PATH_ID = Uint64.valueOf(10); private static final short OF_VERSION = OFConstants.OFP_VERSION_1_3; private static final Long TABLE_ID = 42L; - private static PacketIn createPacketIn(long portNo) { + private static PacketIn createPacketIn(final Uint32 portNo) { InPortBuilder inPortBuilder = new InPortBuilder() .setPortNumber(new PortNumber(portNo)); @@ -66,7 +68,7 @@ public class NodeConnectorRefToPortTranslatorTest extends TestCase { @Test public void testGetPortNoFromPacketIn() { PacketIn packetIn = createPacketIn(PORT_NO); - Long portNo = NodeConnectorRefToPortTranslator.getPortNoFromPacketIn(packetIn); + Uint32 portNo = NodeConnectorRefToPortTranslator.getPortNoFromPacketIn(packetIn); assertEquals(portNo, PORT_NO); } @@ -79,7 +81,7 @@ public class NodeConnectorRefToPortTranslatorTest extends TestCase { NodeConnectorRef ref = NodeConnectorRefToPortTranslator.toNodeConnectorRef(packetIn, DATA_PATH_ID); // Get port number from created NodeConnectorRef - Long refPort = NodeConnectorRefToPortTranslator.fromNodeConnectorRef(ref, OF_VERSION); + Uint32 refPort = NodeConnectorRefToPortTranslator.fromNodeConnectorRef(ref, OF_VERSION); // Check if we got the correct port number assertEquals(PORT_NO, refPort); @@ -88,6 +90,6 @@ public class NodeConnectorRefToPortTranslatorTest extends TestCase { assertEquals(ref, NodeConnectorRefToPortTranslator.toNodeConnectorRef(packetIn, DATA_PATH_ID)); // Check if 2 NodeConnectorRef created from same PacketIn but different datapaths do not have same value - assertNotSame(ref, NodeConnectorRefToPortTranslator.toNodeConnectorRef(packetIn, BigInteger.ONE)); + assertNotSame(ref, NodeConnectorRefToPortTranslator.toNodeConnectorRef(packetIn, Uint64.ONE)); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtilTest.java index 3a8e57c633..3bb435233e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtilTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.math.BigInteger; import org.junit.Test; 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; @@ -23,6 +22,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Created by Martin Bobak mbobak@cisco.com on 7/29/14. @@ -39,8 +40,8 @@ public class PortTranslatorUtilTest { private final boolean[] portCfgBools = {false, false, false, false}; private final boolean[] portCfgV10bools = {false, false, false, false, false, false, false}; private final boolean[] portStateBools = {false, false, false, false}; - private final Long currentSpeed = Long.decode("4294967295"); - private static final Long MAX_SPEED = Long.decode("4294967295"); + private final Uint32 currentSpeed = Uint32.valueOf(4294967295L); + private static final Uint32 MAX_SPEED = Uint32.valueOf(4294967295L); /** * Test method for @@ -101,8 +102,8 @@ public class PortTranslatorUtilTest { Short version = OpenflowVersion.OF10.getVersion(); - BigInteger dataPathId = BigInteger.ONE; - Long portNumber = 4294967295L; + Uint64 dataPathId = Uint64.ONE; + Uint32 portNumber = Uint32.valueOf(4294967295L); PortGrouping portGrouping = mockPortGrouping(); NodeConnectorUpdated nodeConnectorUpdated = PortTranslatorUtil @@ -133,7 +134,7 @@ public class PortTranslatorUtilTest { when(portGrouping.getMaxSpeed()).thenReturn(MAX_SPEED); when(portGrouping.getPeerFeatures()).thenReturn(getPortFeatures()); when(portGrouping.getPeerFeaturesV10()).thenReturn(getPortFeaturesV10()); - when(portGrouping.getPortNo()).thenReturn(Long.MAX_VALUE); + when(portGrouping.getPortNo()).thenReturn(Uint32.MAX_VALUE); when(portGrouping.getState()).thenReturn(getPortState()); when(portGrouping.getSupportedFeatures()).thenReturn(getPortFeatures()); when(portGrouping.getSupportedFeaturesV10()).thenReturn(getPortFeaturesV10()); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/ActionExtensionHelper.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/ActionExtensionHelper.java index 416b51b68d..daf8aa89fc 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/ActionExtensionHelper.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/ActionExtensionHelper.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.extension.api.path.ActionPath; import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yangtools.yang.common.Uint32; public final class ActionExtensionHelper { @@ -52,7 +53,7 @@ public final class ActionExtensionHelper { convertor = extensionConvertorProvider.getActionConverter(key); } else if (action.getActionChoice() != null) { ActionSerializerKey key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, - action.getActionChoice().implementedInterface(), null); + action.getActionChoice().implementedInterface(), (Uint32) null); convertor = extensionConvertorProvider.getActionConverter(key); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java index 04ed9659d0..46ff894ff8 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java @@ -93,8 +93,8 @@ public final class MatchExtensionHelper { * @return augmentation wrapper containing augmentation depending on matchPath */ @SuppressWarnings("unchecked") - public static > AugmentTuple processAllExtensions(Collection matchEntries, - OpenflowVersion ofVersion, MatchPath matchPath) { + public static > AugmentTuple processAllExtensions( + final Collection matchEntries, final OpenflowVersion ofVersion, final MatchPath matchPath) { List extensionsList = new ArrayList<>(); for (MatchEntry matchEntry : matchEntries) { @@ -163,7 +163,8 @@ public final class MatchExtensionHelper { * @param matchEntry match entry * @return an ExtensionListBuilder */ - private static ExtensionListBuilder processExtension(MatchEntry matchEntry, short ofVersion, MatchPath matchPath) { + private static ExtensionListBuilder processExtension(final MatchEntry matchEntry, final short ofVersion, + final MatchPath matchPath) { ExtensionListBuilder extListBld = null; // TODO: EXTENSION PROPOSAL (match, OFJava to MD-SAL) @@ -173,8 +174,7 @@ public final class MatchExtensionHelper { // If entry is experimenter, set experimenter ID to key if (matchEntry.getOxmClass().equals(ExperimenterClass.class)) { ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue(); - Long experimenterId = experimenterIdCase.getExperimenter().getExperimenter().getValue(); - key.setExperimenterId(experimenterId); + key.setExperimenterId(experimenterIdCase.getExperimenter().getExperimenter().getValue()); } if (null != OFSessionUtil.getExtensionConvertorProvider()) { diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java index 03709c33de..87ebf56005 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java @@ -8,7 +8,6 @@ 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; @@ -35,6 +34,7 @@ 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.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +63,7 @@ public class GroupConvertor extends Convertor salToOFBucketList(Buckets buckets, short version, int groupType, BigInteger datapathid) { + private List salToOFBucketList(final Buckets buckets, final short version, final int groupType, + final Uint64 datapathid) { final List bucketLists = new ArrayList<>(); final ActionConvertorData data = new ActionConvertorData(version); data.setDatapathId(datapathid); @@ -106,8 +107,8 @@ public class GroupConvertor extends Convertor { private static final Logger LOG = LoggerFactory.getLogger(PacketOutConvertor.class); private static final Set> TYPES = Collections.singleton(TransmitPacketInput.class); + private static final PortNumber CONTROLLER_PORT = new PortNumber(Uint32.valueOf(0xfffffffdL).intern()); /** * Create default empty meter mot input builder. @@ -62,7 +63,7 @@ public class PacketOutConvertor extends Convertor item = Arguments.checkInstanceOf(pathArgument, InstanceIdentifier.IdentifiableItem.class); NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class); - Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId( + Uint32 port = InventoryDataServiceUtil.portNumberfromNodeConnectorId( OpenflowVersion.get(ofVersion), key.getId()); return new PortNumber(port); } @@ -84,11 +85,11 @@ public class PacketOutConvertor extends Convertor inArgs = null; if (source.getIngress() != null) { @@ -99,7 +100,7 @@ public class PacketOutConvertor extends Convertor tableIds) { + final TableFeaturesPropType type, final List tableIds) { List nextTableIdsList = new ArrayList<>(); - for (Short tableId : tableIds) { + for (Uint8 tableId : tableIds) { NextTableIdsBuilder nextTableId = new NextTableIdsBuilder(); nextTableId.setTableId(tableId); nextTableIdsList.add(nextTableId.build()); @@ -637,8 +637,8 @@ public class TableFeaturesConvertor extends Convertor< } private static void setMatchEntry(final MatchEntryBuilder builder, - Class field, - final Boolean hasMask) { + final Class field, final Boolean hasMask) { if (field == TcpFlags.class) { builder.setOxmClass(ExperimenterClass.class); } else { @@ -655,8 +655,8 @@ public class TableFeaturesConvertor extends Convertor< @Override public List convert( - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, - VersionConvertorData data) { + final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, + final VersionConvertorData data) { List ofTableFeaturesList = new ArrayList<>(); TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertor.java index 9fc9129096..a80080aecd 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertor.java @@ -165,6 +165,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.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.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -499,7 +500,7 @@ public class TableFeaturesResponseConvertor return instructionList; } - private static List setNextTableFeatureProperty(final TableFeatureProperties properties) { + private static List setNextTableFeatureProperty(final TableFeatureProperties properties) { return properties.augmentation(NextTableRelatedTableFeatureProperty.class) .getNextTableIds().stream().map(NextTableIds::getTableId).collect(Collectors.toList()); } @@ -557,7 +558,7 @@ public class TableFeaturesResponseConvertor } @Override - public List convert(MultipartReplyTableFeatures source, VersionConvertorData data) { + public List convert(final MultipartReplyTableFeatures source, final VersionConvertorData data) { if (source == null || source.getTableFeatures() == null) { return Collections.emptyList(); } 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 index 46051852df..f40a4304b3 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -23,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti 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.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ public class OfToSalOutputActionCase extends ConvertorCase process(@Nonnull final OutputActionCase source, final ActionResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + final ConvertorExecutor convertorExecutor) { final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion()); OutputActionBuilder outputAction = new OutputActionBuilder(); @@ -50,8 +50,7 @@ public class OfToSalOutputActionCase extends ConvertorCase process(@Nonnull final SetNwTosCase source, final ActionResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + final ConvertorExecutor convertorExecutor) { return Optional.of(new SetNwTosActionCaseBuilder() .setSetNwTosAction(new SetNwTosActionBuilder() - .setTos((int) source.getSetNwTosAction().getNwTos()) + .setTos((int) source.getSetNwTosAction().getNwTos().toJava()) .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 index 0c937f3701..e96928af88 100644 --- 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 @@ -24,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 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.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +38,7 @@ public class SalToOfOutputActionCase extends ConvertorCase process(@Nonnull final OutputActionCase source, final ActionConvertorData data, - ConvertorExecutor convertorExecutor) { + final ConvertorExecutor convertorExecutor) { final OutputAction outputAction = source.getOutputAction(); final OutputActionBuilder outputBuilder = new OutputActionBuilder(); @@ -49,7 +50,7 @@ public class SalToOfOutputActionCase extends ConvertorCase process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data, - ConvertorExecutor convertorExecutor) { + final ConvertorExecutor convertorExecutor) { IPProtocols protocol = null; if (data.getIpProtocol() != null) { @@ -60,10 +60,10 @@ public class SalToOfSetTpDstActionCase extends ConvertorCase process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data, - ConvertorExecutor convertorExecutor) { + final ConvertorExecutor convertorExecutor) { IPProtocols protocol = null; if (data.getIpProtocol() != null) { @@ -60,11 +60,11 @@ public class SalToOfSetTpSrcActionCase extends ConvertorCase VALUE_MAP; - static { - Builder builder = ImmutableMap.builder(); - for (IPProtocols protocols : IPProtocols.values()) { - builder.put(protocols.protocol, protocols); - } - VALUE_MAP = builder.build(); - } + private static final ImmutableMap VALUE_MAP = Maps.uniqueIndex(Arrays.asList(values()), + proto -> proto.protocol); - IPProtocols(short value) { - this.protocol = value; + IPProtocols(final int value) { + this.protocol = Uint8.valueOf(value); } - public static IPProtocols fromProtocolNum(Short protocolNum) { + public static IPProtocols fromProtocolNum(final Uint8 protocolNum) { return VALUE_MAP.get(protocolNum); } } 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 index 54eb06a229..42cef2aa56 100644 --- 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 @@ -8,20 +8,20 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data; -import java.math.BigInteger; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Convertor data implementation containing Openflow version and datapath ID. */ public class VersionDatapathIdConvertorData extends VersionConvertorData { - private BigInteger datapathId; + private Uint64 datapathId; /** * Instantiates a new version datapath id convertor data. * * @param version the version */ - public VersionDatapathIdConvertorData(short version) { + public VersionDatapathIdConvertorData(final short version) { super(version); } @@ -30,7 +30,7 @@ public class VersionDatapathIdConvertorData extends VersionConvertorData { * * @return the datapath id */ - public BigInteger getDatapathId() { + public Uint64 getDatapathId() { return datapathId; } @@ -39,7 +39,7 @@ public class VersionDatapathIdConvertorData extends VersionConvertorData { * * @param datapathId the datapath id */ - public void setDatapathId(BigInteger datapathId) { + public void setDatapathId(final Uint64 datapathId) { this.datapathId = datapathId; } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/XidConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/XidConvertorData.java index b8035a2dea..f6f2fe4801 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/XidConvertorData.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/data/XidConvertorData.java @@ -8,18 +8,20 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data; +import org.opendaylight.yangtools.yang.common.Uint32; + /** * Convertor data used in containing Openflow version and XID. */ public class XidConvertorData extends VersionDatapathIdConvertorData { - private Long xid; + private Uint32 xid; /** * Instantiates a new Xid convertor data. * * @param version the version */ - public XidConvertorData(short version) { + public XidConvertorData(final short version) { super(version); } @@ -28,7 +30,7 @@ public class XidConvertorData extends VersionDatapathIdConvertorData { * * @return the xid */ - public Long getXid() { + public Uint32 getXid() { return xid; } @@ -37,7 +39,7 @@ public class XidConvertorData extends VersionDatapathIdConvertorData { * * @param xid the xid */ - public void setXid(Long xid) { + public void setXid(final Uint32 xid) { this.xid = xid; } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java index 8f8ebe4c9b..e6ecda79d6 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java @@ -12,7 +12,6 @@ import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Ordering; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -65,6 +64,9 @@ 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.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Converts the SAL Flow to OF Flow. It checks if there is a set-vlan-id (1.0) action made on OF1.3. @@ -84,17 +86,17 @@ public class FlowConvertor extends Convertor, Ve /** * Default idle timeout. */ - public static final Integer DEFAULT_IDLE_TIMEOUT = 0; + public static final Uint16 DEFAULT_IDLE_TIMEOUT = Uint16.ZERO; /** * Default hard timeout. */ - public static final Integer DEFAULT_HARD_TIMEOUT = 0; + public static final Uint16 DEFAULT_HARD_TIMEOUT = Uint16.ZERO; /** * Default priority. */ - public static final Integer DEFAULT_PRIORITY = Integer.parseInt("8000", 16); + public static final Uint16 DEFAULT_PRIORITY = Uint16.valueOf(0x8000); /** * flow flag: remove. @@ -137,13 +139,15 @@ public class FlowConvertor extends Convertor, Ve public static final List DEFAULT_MATCH_ENTRIES = ImmutableList.of(); // 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 TableId DEFAULT_TABLE_ID = new TableId(Uint32.ZERO); + private static final Uint32 DEFAULT_BUFFER_ID = OFConstants.OFP_NO_BUFFER; + private static final Uint32 OFPP_ANY = Uint32.MAX_VALUE; + private static final Uint32 DEFAULT_OUT_PORT = OFPP_ANY; + private static final Uint32 OFPG_ANY = Uint32.MAX_VALUE; + private static final Uint32 DEFAULT_OUT_GROUP = OFPG_ANY; + private static final Uint16 PUSH_VLAN = Uint16.valueOf(0x8100); + private static final Integer PUSH_TAG = PUSH_VLAN.toJava(); + private static final VlanCfi PUSH_CFI = new VlanCfi(1); private static final Ordering INSTRUCTION_ORDERING = Ordering.from(OrderComparator.build()); private static final VlanMatch VLAN_MATCH_FALSE; @@ -163,7 +167,7 @@ public class FlowConvertor extends Convertor, Ve RemoveFlowInput.class, UpdatedFlow.class); static { - final VlanId zeroVlan = new VlanId(0); + final VlanId zeroVlan = new VlanId(Uint16.ZERO); VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(); VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); vlanIdBuilder.setVlanIdPresent(false); @@ -181,7 +185,8 @@ public class FlowConvertor extends Convertor, Ve VLAN_MATCH_TRUE = vlanMatchBuilder2.build(); } - private FlowModInputBuilder toFlowModInput(Flow flow, VersionDatapathIdConvertorData versionConverterData) { + private FlowModInputBuilder toFlowModInput(final Flow flow, + final VersionDatapathIdConvertorData versionConverterData) { FlowModInputBuilder flowMod = new FlowModInputBuilder(); salToOFFlowCookie(flow, flowMod); @@ -214,7 +219,7 @@ public class FlowConvertor extends Convertor, Ve return flowMod; } - private static void salToOFFlowOutGroup(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowOutGroup(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getOutGroup() != null) { flowMod.setOutGroup(flow.getOutGroup()); } else { @@ -222,7 +227,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowOutPort(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowOutPort(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getOutPort() != null) { flowMod.setOutPort(new PortNumber(flow.getOutPort().longValue())); } else { @@ -230,7 +235,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowBufferId(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowBufferId(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getBufferId() != null) { flowMod.setBufferId(flow.getBufferId()); } else { @@ -238,7 +243,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowPriority(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowPriority(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getPriority() != null) { flowMod.setPriority(flow.getPriority()); } else { @@ -246,7 +251,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowHardTimeout(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowHardTimeout(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getHardTimeout() != null) { flowMod.setHardTimeout(flow.getHardTimeout()); } else { @@ -254,7 +259,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowIdleTimeout(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowIdleTimeout(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getIdleTimeout() != null) { flowMod.setIdleTimeout(flow.getIdleTimeout()); } else { @@ -262,7 +267,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowCommand(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowCommand(final Flow flow, final FlowModInputBuilder flowMod) { if (flow instanceof AddFlowInput || flow instanceof UpdatedFlow) { flowMod.setCommand(FlowModCommand.OFPFCADD); } else if (flow instanceof RemoveFlowInput) { @@ -274,7 +279,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowTableId(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowTableId(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getTableId() != null) { flowMod.setTableId(new TableId(flow.getTableId().longValue())); } else { @@ -282,7 +287,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowCookieMask(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowCookieMask(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getCookieMask() != null) { flowMod.setCookieMask(flow.getCookieMask().getValue()); } else { @@ -290,7 +295,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static void salToOFFlowCookie(Flow flow, FlowModInputBuilder flowMod) { + private static void salToOFFlowCookie(final Flow flow, final FlowModInputBuilder flowMod) { if (flow.getCookie() != null) { flowMod.setCookie(flow.getCookie().getValue()); } else { @@ -298,7 +303,7 @@ public class FlowConvertor extends Convertor, Ve } } - private List toInstructions(Flow flow, short version, BigInteger datapathid) { + private List toInstructions(final Flow flow, final short version, final Uint64 datapathid) { final List instructionsList = new ArrayList<>(); final ActionConvertorData data = new ActionConvertorData(version); data.setDatapathId(datapathid); @@ -321,7 +326,7 @@ public class FlowConvertor extends Convertor, Ve return instructionsList; } - private List getActions(short version, BigInteger datapathid, Flow flow) { + private List getActions(final short version, final Uint64 datapathid, final Flow flow) { Instructions instructions = flow.getInstructions(); List sortedInstructions = INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction()); @@ -350,7 +355,7 @@ public class FlowConvertor extends Convertor, Ve } // check if set vlanid action is present in the flow - private static boolean isSetVlanIdActionCasePresent(Flow flow) { + private static boolean isSetVlanIdActionCasePresent(final 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 && flow.getInstructions().getInstruction() != null) { @@ -387,8 +392,8 @@ public class FlowConvertor extends Convertor, Ve *     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 List handleSetVlanIdForOF13(Flow srcFlow, - VersionDatapathIdConvertorData versionDatapathIdConverterData) { + private List handleSetVlanIdForOF13(final Flow srcFlow, + final VersionDatapathIdConvertorData versionDatapathIdConverterData) { List list = new ArrayList<>(2); final Match srcMatch = Preconditions.checkNotNull(srcFlow.getMatch()); @@ -430,7 +435,7 @@ public class FlowConvertor extends Convertor, Ve } - private static Optional injectMatchToFlow(Flow sourceFlow, Match match) { + private static Optional injectMatchToFlow(final Flow sourceFlow, final Match match) { if (sourceFlow instanceof AddFlowInput) { return Optional.of(new AddFlowInputBuilder(sourceFlow).setMatch(match).build()); } else if (sourceFlow instanceof RemoveFlowInput) { @@ -442,7 +447,7 @@ public class FlowConvertor extends Convertor, Ve } } - private static Optional injectMatchAndAction(Flow sourceFlow, Match match) { + private static Optional injectMatchAndAction(final Flow sourceFlow, final Match match) { Instructions instructions = new InstructionsBuilder() .setInstruction(injectPushActionToInstruction(sourceFlow)) @@ -502,10 +507,10 @@ public class FlowConvertor extends Convertor, Ve PushVlanActionCaseBuilder pushVlanActionCaseBuilder = new PushVlanActionCaseBuilder(); PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder(); - pushVlanActionBuilder.setCfi(new VlanCfi(1)) + pushVlanActionBuilder.setCfi(PUSH_CFI) .setVlanId(setVlanIdActionCase.getSetVlanIdAction().getVlanId()) .setEthernetType(PUSH_VLAN) - .setTag(PUSH_VLAN); + .setTag(PUSH_TAG); pushVlanActionCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build()); PushVlanActionCase injectedAction = pushVlanActionCaseBuilder.build(); @@ -555,7 +560,7 @@ public class FlowConvertor extends Convertor, Ve } @Override - public List convert(Flow source, VersionDatapathIdConvertorData data) { + public List convert(final Flow source, final VersionDatapathIdConvertorData data) { if (data.getVersion() >= OFConstants.OFP_VERSION_1_3 && isSetVlanIdActionCasePresent(source)) { return handleSetVlanIdForOF13(source, data); } else { 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 index 817b81bee1..bd562a7c23 100644 --- 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 @@ -14,6 +14,9 @@ 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.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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Flow related utils. @@ -31,7 +34,7 @@ public final class FlowConvertorUtil { * @param actionList the action list * @return the list */ - public static List wrapActionList(List wrapActionList(final List actionList) { List actions = new ArrayList<>(); @@ -54,13 +57,14 @@ public final class FlowConvertorUtil { * @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(); + public static Uint8 getIpProtocolFromFlow(final Flow flow) { + final Match match = flow.getMatch(); + if (match != null) { + final IpMatch ipMatch = match.getIpMatch(); + if (ipMatch != null) { + return ipMatch.getIpProtocol(); + } } - - return ipProtocol; + return null; } } 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 index c8bc5b4269..5d100f5939 100644 --- 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 @@ -37,8 +37,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.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.match.types.rev131026.match.IpMatch; 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.common.Uint8; /** * Converts flow related statistics messages coming from openflow switch to MD-SAL messages. @@ -66,9 +68,9 @@ public class FlowStatsResponseConvertor extends Convertor, List< * @return OF10 actions as an instructions */ private Instructions wrapOF10ActionsToInstruction( - List actionsList, - final short version, final Short ipProtocol) { + final short version, final Uint8 ipProtocol) { ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(version); actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS); actionResponseConvertorData.setIpProtocol(ipProtocol); @@ -100,7 +102,8 @@ public class FlowStatsResponseConvertor extends Convertor, List< } @Override - public List convert(List source, FlowStatsResponseConvertorData data) { + public List convert(final List source, + final FlowStatsResponseConvertorData data) { final List result = new ArrayList<>(); for (FlowStats flowStats : source) { @@ -123,18 +126,19 @@ public class FlowStatsResponseConvertor extends Convertor, List< salFlowStatsBuilder.setPriority(flowStats.getPriority()); salFlowStatsBuilder.setTableId(flowStats.getTableId()); - Short ipProtocol = null; - if (flowStats.getMatchV10() != null) { final Optional matchBuilderOptional = getConvertorExecutor().convert( flowStats.getMatchV10(), data); + Uint8 ipProtocol = null; if (matchBuilderOptional.isPresent()) { - if (matchBuilderOptional.get().getIpMatch() != null) { - ipProtocol = matchBuilderOptional.get().getIpMatch().getIpProtocol(); + final MatchBuilder matchBuilder = matchBuilderOptional.get(); + final IpMatch ipMatch = matchBuilder.getIpMatch(); + if (ipMatch != null) { + ipProtocol = ipMatch.getIpProtocol(); } - salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build()); + salFlowStatsBuilder.setMatch(matchBuilder.build()); } if (flowStats.getAction() != null && flowStats.getAction().size() != 0) { 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 index 583b5a35c1..ae90e8a6db 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -14,7 +13,6 @@ 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; @@ -30,15 +28,9 @@ public class MeterCase extends ConvertorCase 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()); + final ConvertorExecutor convertorExecutor) { + return Optional.of(new InstructionBuilder().setInstructionChoice(new MeterCaseBuilder() + .setMeter(new MeterBuilder().setMeterId(source.getMeter().getMeterId().getValue()).build()).build()) + .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 index 1553efce68..708b33a934 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -31,14 +30,12 @@ public class WriteMetadataCase extends ConvertorCase process(final @Nonnull org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types .rev131026.instruction.instruction.WriteMetadataCase source, final ActionConvertorData data, - ConvertorExecutor convertorExecutor) { + final 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)); + writeMetadataBuilder.setMetadata(ByteUtil.uint64toBytes(writeMetadata.getMetadata())); + writeMetadataBuilder.setMetadataMask(ByteUtil.uint64toBytes(writeMetadata.getMetadataMask())); writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build()); InstructionBuilder instructionBuilder = new InstructionBuilder(); instructionBuilder.setInstructionChoice(writeMetadataCaseBuilder.build()); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java index abebc0d6e6..6901fe2583 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java @@ -5,7 +5,6 @@ * terms of the 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.ArrayList; @@ -128,6 +127,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc 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.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Utility class for converting a MD-SAL Flow into the OF flow mod. @@ -161,7 +163,7 @@ public class MatchConvertor extends Convertor, VersionCo private static final byte[] VLAN_VID_MASK = new byte[]{16, 0}; private static void layer3Match(final List matchEntryList, final Layer3Match layer3Match, - ConvertorExecutor converterExecutor, + final ConvertorExecutor converterExecutor, final ExtensionConverterProvider extensionConvertorProvider) { java.util.Optional> result = LAYER3_PROCESSOR.process(layer3Match, converterExecutor ); @@ -172,7 +174,7 @@ public class MatchConvertor extends Convertor, VersionCo } private static void layer4Match(final List matchEntryList, final Layer4Match layer4Match, - ConvertorExecutor converterExecutor, final ExtensionConverterProvider extensionConvertorProvider) { + final ConvertorExecutor converterExecutor, final ExtensionConverterProvider extensionConvertorProvider) { java.util.Optional> result = LAYER4_PROCESSOR.process(layer4Match, converterExecutor ); @@ -181,13 +183,13 @@ public class MatchConvertor extends Convertor, VersionCo } } - private static void inPortMatch(final List matchEntryList, NodeConnectorId inPort) { + private static void inPortMatch(final List matchEntryList, final NodeConnectorId inPort) { if (inPort == null) { return; } //TODO: currently this matchconverter is mapped to OF1.3 in MatchInjector. Will need to revisit during 1.4+ - final long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPort); + final Uint32 portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPort); MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); matchEntryBuilder.setHasMask(false); @@ -200,13 +202,14 @@ public class MatchConvertor extends Convertor, VersionCo matchEntryList.add(matchEntryBuilder.build()); } - private static void inPhyPortMatch(final List matchEntryList, NodeConnectorId inPhyPort) { + private static void inPhyPortMatch(final List matchEntryList, final NodeConnectorId inPhyPort) { if (inPhyPort == null) { return; } //TODO: currently this matchconverter is mapped to OF1.3 in MatchInjector. Will need to revisit during 1.4+ - final long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPhyPort); + final Uint32 portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, + inPhyPort); MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); matchEntryBuilder.setHasMask(false); @@ -233,12 +236,10 @@ public class MatchConvertor extends Convertor, VersionCo 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)); + metadataBuilder.setMetadata(ByteUtil.uint64toBytes(metadata.getMetadata())); if (hasmask) { - metadataBuilder.setMask(ByteUtil.convertBigIntegerToNBytes(metadata.getMetadataMask(), - OFConstants.SIZE_OF_LONG_IN_BYTES)); + metadataBuilder.setMask(ByteUtil.uint64toBytes(metadata.getMetadataMask())); } metadataCaseBuilder.setMetadata(metadataBuilder.build()); @@ -275,12 +276,10 @@ public class MatchConvertor extends Convertor, VersionCo boolean hasMask = tunnel.getTunnelMask() != null; if (hasMask) { - tunnelIdBuilder.setMask(ByteUtil.convertBigIntegerToNBytes(tunnel.getTunnelMask(), - OFConstants.SIZE_OF_LONG_IN_BYTES)); + tunnelIdBuilder.setMask(ByteUtil.uint64toBytes(tunnel.getTunnelMask())); } - tunnelIdBuilder.setTunnelId(ByteUtil.convertBigIntegerToNBytes(tunnel.getTunnelId(), - OFConstants.SIZE_OF_LONG_IN_BYTES)); + tunnelIdBuilder.setTunnelId(ByteUtil.uint64toBytes(tunnel.getTunnelId())); tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build()); MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); @@ -372,7 +371,7 @@ public class MatchConvertor extends Convertor, VersionCo matchEntryBuilder.setOxmMatchField(VlanVid.class); VlanVidBuilder vlanVidBuilder = new VlanVidBuilder(); boolean setCfiBit = false; - Integer vidEntryValue = 0; + Uint16 vidEntryValue = Uint16.ZERO; boolean hasmask = false; if (Boolean.TRUE.equals(vlanId.isVlanIdPresent())) { @@ -381,7 +380,7 @@ public class MatchConvertor extends Convertor, VersionCo vidEntryValue = vlanId.getVlanId().getValue(); } - hasmask = vidEntryValue == 0; + hasmask = vidEntryValue.toJava() == 0; if (hasmask) { vlanVidBuilder.setMask(VLAN_VID_MASK); } @@ -451,7 +450,7 @@ public class MatchConvertor extends Convertor, VersionCo } } - private static void tcpFlagsMatch(List matchEntryList, TcpFlagsMatch tcpFlagsMatch) { + private static void tcpFlagsMatch(final List matchEntryList, final TcpFlagsMatch tcpFlagsMatch) { ExperimenterIdCaseBuilder expIdCaseBuilder = new ExperimenterIdCaseBuilder(); if (tcpFlagsMatch != null) { MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); @@ -498,43 +497,37 @@ public class MatchConvertor extends Convertor, VersionCo return matchEntryBuilder.build(); } - private static MatchEntry toOfMplsTc(final Short mplsTc) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(MplsTc.class); - MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder(); - MplsTcBuilder mplsTcBuilder = new MplsTcBuilder(); - mplsTcBuilder.setTc(mplsTc); - mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build()); - matchEntryBuilder.setMatchEntryValue(mplsTcCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfMplsTc(final Uint8 mplsTc) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(MplsTc.class) + .setMatchEntryValue(new MplsTcCaseBuilder() + .setMplsTc(new MplsTcBuilder().setTc(mplsTc).build()) + .build()) + .build(); } - private static MatchEntry toOfMplsBos(final Short mplsBos) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(MplsBos.class); - MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder(); - MplsBosBuilder mplsBosBuilder = new MplsBosBuilder(); - mplsBosBuilder.setBos(mplsBos != 0); - mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build()); - matchEntryBuilder.setMatchEntryValue(mplsBosCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfMplsBos(final Uint8 mplsBos) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(MplsBos.class) + .setMatchEntryValue(new MplsBosCaseBuilder() + .setMplsBos(new MplsBosBuilder().setBos(mplsBos.toJava() != 0).build()) + .build()) + .build(); } - private static MatchEntry toOfMplsLabel(final Long mplsLabel) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(MplsLabel.class); - MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder(); - MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder(); - mplsLabelBuilder.setMplsLabel(mplsLabel); - mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build()); - matchEntryBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfMplsLabel(final Uint32 mplsLabel) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(MplsLabel.class) + .setMatchEntryValue(new MplsLabelCaseBuilder() + .setMplsLabel(new MplsLabelBuilder().setMplsLabel(mplsLabel).build()) + .build()) + .build(); } private static MatchEntry toOfEthernetType(final EthernetType ethernetType) { @@ -551,82 +544,67 @@ public class MatchConvertor extends Convertor, VersionCo return matchEntryBuilder.build(); } - private static MatchEntry toOfIcmpv4Type(final Short icmpv4Type) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(Icmpv4Type.class); - Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder(); - Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder(); - icmpv4TypeBuilder.setIcmpv4Type(icmpv4Type); - icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build()); - matchEntryBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfIcmpv4Type(final Uint8 icmpv4Type) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(Icmpv4Type.class) + .setMatchEntryValue(new Icmpv4TypeCaseBuilder() + .setIcmpv4Type(new Icmpv4TypeBuilder().setIcmpv4Type(icmpv4Type).build()) + .build()) + .build(); } - private static MatchEntry toOfIcmpv4Code(final Short icmpv4Code) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(Icmpv4Code.class); - Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder(); - Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder(); - icmpv4CodeBuilder.setIcmpv4Code(icmpv4Code); - icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build()); - matchEntryBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfIcmpv4Code(final Uint8 icmpv4Code) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(Icmpv4Code.class) + .setMatchEntryValue(new Icmpv4CodeCaseBuilder() + .setIcmpv4Code(new Icmpv4CodeBuilder().setIcmpv4Code(icmpv4Code).build()).build()) + .build(); } - private static MatchEntry toOfIcmpv6Type(final Short icmpv6Type) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(Icmpv6Type.class); - Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder(); - Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder(); - icmpv6TypeBuilder.setIcmpv6Type(icmpv6Type); - icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build()); - matchEntryBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfIcmpv6Type(final Uint8 icmpv6Type) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(Icmpv6Type.class) + .setMatchEntryValue(new Icmpv6TypeCaseBuilder() + .setIcmpv6Type(new Icmpv6TypeBuilder().setIcmpv6Type(icmpv6Type).build()) + .build()) + .build(); } - private static MatchEntry toOfIcmpv6Code(final Short icmpv6Code) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(Icmpv6Code.class); - Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder(); - Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder(); - icmpv6CodeBuilder.setIcmpv6Code(icmpv6Code); - icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build()); - matchEntryBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfIcmpv6Code(final Uint8 icmpv6Code) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(Icmpv6Code.class) + .setMatchEntryValue(new Icmpv6CodeCaseBuilder() + .setIcmpv6Code(new Icmpv6CodeBuilder().setIcmpv6Code(icmpv6Code).build()) + .build()) + .build(); } - private static MatchEntry toOfIpProto(final Short ipProtocol) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(IpProto.class); - IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder(); - IpProtoBuilder ipProtoBuilder = new IpProtoBuilder(); - ipProtoBuilder.setProtocolNumber(ipProtocol); - ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build()); - matchEntryBuilder.setMatchEntryValue(ipProtoCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfIpProto(final Uint8 ipProtocol) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(IpProto.class) + .setMatchEntryValue(new IpProtoCaseBuilder() + .setIpProto(new IpProtoBuilder().setProtocolNumber(ipProtocol).build()) + .build()) + .build(); } - private static MatchEntry toOfIpEcn(final Short ipEcn) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setOxmClass(OpenflowBasicClass.class); - matchEntryBuilder.setHasMask(false); - matchEntryBuilder.setOxmMatchField(IpEcn.class); - IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); - IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); - ipEcnBuilder.setEcn(ipEcn); - ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); - matchEntryBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); - return matchEntryBuilder.build(); + private static MatchEntry toOfIpEcn(final Uint8 ipEcn) { + return new MatchEntryBuilder() + .setOxmClass(OpenflowBasicClass.class) + .setHasMask(Boolean.FALSE) + .setOxmMatchField(IpEcn.class) + .setMatchEntryValue(new IpEcnCaseBuilder().setIpEcn(new IpEcnBuilder().setEcn(ipEcn).build()).build()) + .build(); } /** diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10Convertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10Convertor.java index 185cdc2d9b..ac3520a40f 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10Convertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10Convertor.java @@ -32,9 +32,12 @@ 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.Ipv4Match; 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.UdpMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; /** * The type Match converter v 10. @@ -65,7 +68,7 @@ public class MatchV10Convertor extends Convertor { public OfToSalEthTypeCase() { @@ -27,18 +26,16 @@ public class OfToSalEthTypeCase extends ConvertorCase process(@Nonnull EthTypeCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final EthTypeCase source, final MatchResponseConvertorData data, + final 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()); + matchBuilder.setEthernetMatch(data.getEthernetMatchBuilder() + .setEthernetType(new EthernetTypeBuilder() + .setType(new EtherType(Uint32.valueOf(ethTypeCase.getEthType().getValue()))) + .build()) + .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 index 06bdc43ea4..68b38a339b 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -18,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M 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; +import org.opendaylight.yangtools.yang.common.Uint8; public class OfToSalIcmpv4CodeCase extends ConvertorCase { public OfToSalIcmpv4CodeCase() { @@ -25,13 +25,13 @@ public class OfToSalIcmpv4CodeCase extends ConvertorCase process(@Nonnull Icmpv4CodeCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final Icmpv4CodeCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder(); Icmpv4Code icmpv4Code = source.getIcmpv4Code(); - Short v4code = icmpv4Code.getIcmpv4Code(); + Uint8 v4code = icmpv4Code.getIcmpv4Code(); if (v4code != null) { icmpv4MatchBuilder.setIcmpv4Code(v4code); 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 index 6692679e71..d50b61f441 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -18,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M 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; +import org.opendaylight.yangtools.yang.common.Uint8; public class OfToSalIcmpv4TypeCase extends ConvertorCase { public OfToSalIcmpv4TypeCase() { @@ -25,13 +25,13 @@ public class OfToSalIcmpv4TypeCase extends ConvertorCase process(@Nonnull Icmpv4TypeCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final Icmpv4TypeCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder(); Icmpv4Type icmpv4Type = source.getIcmpv4Type(); - Short type = icmpv4Type.getIcmpv4Type(); + Uint8 type = icmpv4Type.getIcmpv4Type(); if (type != null) { icmpv4MatchBuilder.setIcmpv4Type(type); 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 index cf0b349577..5d63beeb51 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -18,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M 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; +import org.opendaylight.yangtools.yang.common.Uint8; public class OfToSalIcmpv6CodeCase extends ConvertorCase { public OfToSalIcmpv6CodeCase() { @@ -25,13 +25,13 @@ public class OfToSalIcmpv6CodeCase extends ConvertorCase process(@Nonnull Icmpv6CodeCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final Icmpv6CodeCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final Icmpv6MatchBuilder icmpv6MatchBuilder = data.getIcmpv6MatchBuilder(); Icmpv6Code icmpv6Code = source.getIcmpv6Code(); - Short v6code = icmpv6Code.getIcmpv6Code(); + Uint8 v6code = icmpv6Code.getIcmpv6Code(); if (v6code != null) { icmpv6MatchBuilder.setIcmpv6Code(v6code); 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 index 38cc52e483..3a4e302fb9 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -18,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M 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; +import org.opendaylight.yangtools.yang.common.Uint8; public class OfToSalIcmpv6TypeCase extends ConvertorCase { public OfToSalIcmpv6TypeCase() { @@ -25,13 +25,13 @@ public class OfToSalIcmpv6TypeCase extends ConvertorCase process(@Nonnull Icmpv6TypeCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final Icmpv6TypeCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final Icmpv6MatchBuilder icmpv6MatchBuilder = data.getIcmpv6MatchBuilder(); Icmpv6Type icmpv6Type = source.getIcmpv6Type(); - Short v6type = icmpv6Type.getIcmpv6Type(); + Uint8 v6type = icmpv6Type.getIcmpv6Type(); if (v6type != null) { icmpv6MatchBuilder.setIcmpv6Type(v6type); 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 index 7b5dcc76d8..074fa8245e 100644 --- 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 @@ -5,10 +5,8 @@ * terms of the 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; @@ -20,6 +18,7 @@ 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; +import org.opendaylight.yangtools.yang.common.Uint64; public class OfToSalInPhyPortCase extends ConvertorCase { public OfToSalInPhyPortCase() { @@ -27,11 +26,11 @@ public class OfToSalInPhyPortCase extends ConvertorCase process(@Nonnull InPhyPortCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final InPhyPortCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion()); - final BigInteger datapathId = data.getDatapathId(); + final Uint64 datapathId = data.getDatapathId(); final PortNumber portNumber = source.getInPhyPort().getPortNumber(); 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 index 6947d509d3..4dc3967115 100644 --- 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 @@ -5,10 +5,8 @@ * terms of the 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; @@ -20,6 +18,7 @@ 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; +import org.opendaylight.yangtools.yang.common.Uint64; public class OfToSalInPortCase extends ConvertorCase { public OfToSalInPortCase() { @@ -27,11 +26,11 @@ public class OfToSalInPortCase extends ConvertorCase process(@Nonnull InPortCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final InPortCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion()); - final BigInteger datapathId = data.getDatapathId(); + final Uint64 datapathId = data.getDatapathId(); final PortNumber portNumber = source.getInPort().getPortNumber(); 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 index f7f909e569..a24e6e6aa6 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -18,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M 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; +import org.opendaylight.yangtools.yang.common.Uint8; public class OfToSalIpProtoCase extends ConvertorCase { public OfToSalIpProtoCase() { @@ -25,13 +25,13 @@ public class OfToSalIpProtoCase extends ConvertorCase process(@Nonnull IpProtoCase source, MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final IpProtoCase source, final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final IpMatchBuilder ipMatchBuilder = data.getIpMatchBuilder(); IpProto ipProto = source.getIpProto(); - Short protocolNumber = ipProto.getProtocolNumber(); + Uint8 protocolNumber = ipProto.getProtocolNumber(); if (protocolNumber != null) { ipMatchBuilder.setIpProtocol(protocolNumber); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPacketTypeCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPacketTypeCase.java index 77a6fec475..dafb031634 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPacketTypeCase.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/cases/OfToSalPacketTypeCase.java @@ -5,7 +5,6 @@ * terms of the 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; @@ -15,7 +14,6 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorE 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.PacketTypeMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PacketTypeCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.packet.type._case.PacketType; @@ -27,16 +25,16 @@ public class OfToSalPacketTypeCase extends ConvertorCase process(@Nonnull PacketTypeCase source, - MatchResponseConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional process(@Nonnull final PacketTypeCase source, + final MatchResponseConvertorData data, + final ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final PacketType packetType = source.getPacketType(); if (packetType != null) { - Long packetTypeValue = packetType.getPacketType(); - PacketTypeMatch packetTypeMatch = new PacketTypeMatchBuilder().setPacketType(packetTypeValue).build(); - matchBuilder.setPacketTypeMatch(packetTypeMatch); + matchBuilder.setPacketTypeMatch(new PacketTypeMatchBuilder() + .setPacketType(packetType.getPacketType()) + .build()); } return Optional.of(matchBuilder); 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 index c692a61662..e95283065d 100644 --- 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 @@ -52,8 +52,8 @@ public class SalToOfIpv6MatchCase extends ConvertorCase> process(@Nonnull Ipv6Match source, VersionConvertorData data, - ConvertorExecutor convertorExecutor) { + public Optional> process(@Nonnull final Ipv6Match source, final VersionConvertorData data, + final ConvertorExecutor convertorExecutor) { List result = new ArrayList<>(); if (source.getIpv6Source() != null) { @@ -172,7 +172,7 @@ public class SalToOfIpv6MatchCase extends ConvertorCase>> ActionUtil.ENC_FIELD_BIT_SIZE); } + public static Uint8 tosToDscp(final Uint8 tosValue) { + return Uint8.valueOf(tosValue.toJava() >>> ActionUtil.ENC_FIELD_BIT_SIZE); + } + /** * Converts DSCP to TOS value. * * @param dscpValue TypeOfService value * @return TOS value */ - public static Short dscpToTos(short dscpValue) { + public static Short dscpToTos(final short dscpValue) { return (short) (dscpValue << ActionUtil.ENC_FIELD_BIT_SIZE); } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtil.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtil.java index 62927716b9..d03d52ab89 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtil.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtil.java @@ -9,10 +9,14 @@ package org.opendaylight.openflowplugin.openflow.md.util; import com.google.common.base.Preconditions; import com.google.common.io.BaseEncoding; +import com.google.common.primitives.Longs; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.math.BigInteger; import java.util.Arrays; import javax.annotation.Nullable; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public final class ByteUtil { private ByteUtil() { @@ -70,6 +74,18 @@ public final class ByteUtil { return outputArray; } + /** + * Utility method to convert an Uint64 to an 8-byte array. + * + * @param uint Unsigned long, potentially null. + * @return byte array, or null if input was null. + */ + @Nullable + @SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") + public static byte[] uint64toBytes(@Nullable final Uint64 uint) { + return uint == null ? null : Longs.toByteArray(uint.longValue()); + } + /** * Converts a 4 byte array of unsigned bytes to unsigned int. * @@ -128,6 +144,26 @@ public final class ByteUtil { * @return bytes an array of 4 unsigned bytes */ public static byte[] unsignedIntToBytes(final Long unsignedInt) { + return unsignedIntToBytes(unsignedInt.longValue()); + } + + /** + * Converts unsigned integer to a 4 byte array of unsigned bytes. + * + * @param unsignedInt representing the unsigned integer + * @return bytes an array of 4 unsigned bytes + */ + public static byte[] unsignedIntToBytes(final Uint32 unsignedInt) { + return unsignedIntToBytes(unsignedInt.toJava()); + } + + /** + * Converts unsigned integer to a 4 byte array of unsigned bytes. + * + * @param unsignedInt representing the unsigned integer + * @return bytes an array of 4 unsigned bytes + */ + private static byte[] unsignedIntToBytes(final long unsignedInt) { byte[] bytes = new byte[4]; bytes[3] = (byte) (unsignedInt & 0xFF); bytes[2] = (byte) (unsignedInt >> 8 & 0xFF); @@ -143,6 +179,26 @@ public final class ByteUtil { * @return bytes an array of 3 unsigned bytes */ public static byte[] unsignedMediumToBytes(final Long unsignedInt) { + return unsignedMediumToBytes(unsignedInt.longValue()); + } + + /** + * Converts unsigned integer to a 3 byte array of unsigned bytes. + * + * @param unsignedInt representing the unsigned integer + * @return bytes an array of 3 unsigned bytes + */ + public static byte[] unsignedMediumToBytes(final Uint32 unsignedInt) { + return unsignedMediumToBytes(unsignedInt.toJava()); + } + + /** + * Converts unsigned integer to a 3 byte array of unsigned bytes. + * + * @param unsignedInt representing the unsigned integer + * @return bytes an array of 3 unsigned bytes + */ + private static byte[] unsignedMediumToBytes(final long unsignedInt) { byte[] bytes = new byte[3]; bytes[2] = (byte) (unsignedInt & 0xFF); bytes[1] = (byte) (unsignedInt >> 8 & 0xFF); @@ -157,6 +213,26 @@ public final class ByteUtil { * @return bytes an array of 2 unsigned bytes */ public static byte[] unsignedShortToBytes(final Integer unsignedShort) { + return unsignedShortToBytes(unsignedShort.intValue()); + } + + /** + * Converts unsigned short to a 2 byte array of unsigned bytes. + * + * @param unsignedShort representing the unsigned short + * @return bytes an array of 2 unsigned bytes + */ + public static byte[] unsignedShortToBytes(final Uint16 unsignedShort) { + return unsignedShortToBytes(unsignedShort.toJava()); + } + + /** + * Converts unsigned short to a 2 byte array of unsigned bytes. + * + * @param unsignedShort representing the unsigned short + * @return bytes an array of 2 unsigned bytes + */ + private static byte[] unsignedShortToBytes(final int unsignedShort) { byte[] bytes = new byte[2]; bytes[1] = (byte) (unsignedShort & 0xFF); bytes[0] = (byte) (unsignedShort >> 8 & 0xFF); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java index 6bd8eae90b..01dc7a34bd 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java @@ -29,6 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,35 +44,32 @@ public abstract class InventoryDataServiceUtil { */ private static final InstanceIdentifier NODES_IDENTIFIER = InstanceIdentifier.create(Nodes.class); - public static InstanceIdentifier identifierFromDatapathId(final BigInteger datapathId) { + public static InstanceIdentifier identifierFromDatapathId(final Uint64 datapathId) { NodeKey nodeKey = nodeKeyFromDatapathId(datapathId); return NODES_IDENTIFIER.child(Node.class, nodeKey); } - public static NodeKey nodeKeyFromDatapathId(final BigInteger datapathId) { + public static NodeKey nodeKeyFromDatapathId(final Uint64 datapathId) { return new NodeKey(nodeIdFromDatapathId(datapathId)); } - public static NodeUpdatedBuilder nodeUpdatedBuilderFromDataPathId(final BigInteger datapathId) { + public static NodeUpdatedBuilder nodeUpdatedBuilderFromDataPathId(final Uint64 datapathId) { NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); builder.setId(nodeIdFromDatapathId(datapathId)); builder.setNodeRef(nodeRefFromNodeKey(new NodeKey(builder.getId()))); return builder; } - public static NodeId nodeIdFromDatapathId(final BigInteger datapathId) { + public static NodeId nodeIdFromDatapathId(final Uint64 datapathId) { // FIXME: Convert to textual representation of datapathID String current = datapathId.toString(); return new NodeId(OFConstants.OF_URI_PREFIX + current); } - public static BigInteger dataPathIdFromNodeId(final NodeId nodeId) { - String dpids = nodeId.getValue().replace(OFConstants.OF_URI_PREFIX, ""); - BigInteger dpid = new BigInteger(dpids); - return dpid; + public static Uint64 dataPathIdFromNodeId(final NodeId nodeId) { + return Uint64.valueOf(nodeId.getValue().replace(OFConstants.OF_URI_PREFIX, "")); } - public static NodeRef nodeRefFromNodeKey(final NodeKey nodeKey) { return new NodeRef(nodeKeyToInstanceIdentifier(nodeKey)); } @@ -79,7 +78,7 @@ public abstract class InventoryDataServiceUtil { return NODES_IDENTIFIER.child(Node.class, nodeKey); } - public static NodeConnectorId nodeConnectorIdfromDatapathPortNo(final BigInteger datapathid, final Long portNo, + public static NodeConnectorId nodeConnectorIdfromDatapathPortNo(final Uint64 datapathid, final Uint32 portNo, final OpenflowVersion ofVersion) { String logicalName = OpenflowPortsUtil.getPortLogicalName(ofVersion, portNo); return new NodeConnectorId(OFConstants.OF_URI_PREFIX + datapathid + ":" + (logicalName == null @@ -87,12 +86,12 @@ public abstract class InventoryDataServiceUtil { } @Nullable - public static Long portNumberfromNodeConnectorId(final OpenflowVersion ofVersion, final NodeConnectorId ncId) { + public static Uint32 portNumberfromNodeConnectorId(final OpenflowVersion ofVersion, final NodeConnectorId ncId) { return portNumberfromNodeConnectorId(ofVersion, ncId.getValue()); } @Nullable - public static Long portNumberfromNodeConnectorId(final OpenflowVersion ofVersion, @Nonnull final String ncId) { + public static Uint32 portNumberfromNodeConnectorId(final OpenflowVersion ofVersion, @Nonnull final String ncId) { String portNoString = portNoStringfromNodeConnectorID(ncId); return OpenflowPortsUtil.getPortFromLogicalName(ofVersion, portNoString); } @@ -109,33 +108,33 @@ public abstract class InventoryDataServiceUtil { } - public static NodeConnectorRef nodeConnectorRefFromDatapathIdPortno(final BigInteger datapathId, final Long portNo, + public static NodeConnectorRef nodeConnectorRefFromDatapathIdPortno(final Uint64 datapathId, final Uint32 portNo, final OpenflowVersion ofVersion) { return new NodeConnectorRef(nodeConnectorInstanceIdentifierFromDatapathIdPortno(datapathId, portNo, ofVersion)); } - public static NodeConnectorRef nodeConnectorRefFromDatapathIdPortno(final BigInteger datapathId, final Long portNo, + public static NodeConnectorRef nodeConnectorRefFromDatapathIdPortno(final Uint64 datapathId, final Uint32 portNo, final OpenflowVersion ofVersion, final KeyedInstanceIdentifier nodePath) { return new NodeConnectorRef( nodeConnectorInstanceIdentifierFromDatapathIdPortno(datapathId, portNo, ofVersion, nodePath)); } public static InstanceIdentifier nodeConnectorInstanceIdentifierFromDatapathIdPortno( - final BigInteger datapathId, final Long portNo, final OpenflowVersion ofVersion) { + final Uint64 datapathId, final Uint32 portNo, final OpenflowVersion ofVersion) { NodeId nodeId = nodeIdFromDatapathId(datapathId); KeyedInstanceIdentifier nodePath = NODES_IDENTIFIER.child(Node.class, new NodeKey(nodeId)); return nodeConnectorInstanceIdentifierFromDatapathIdPortno(datapathId, portNo, ofVersion, nodePath); } public static InstanceIdentifier nodeConnectorInstanceIdentifierFromDatapathIdPortno( - final BigInteger datapathId, final Long portNo, final OpenflowVersion ofVersion, + final Uint64 datapathId, final Uint32 portNo, final OpenflowVersion ofVersion, final KeyedInstanceIdentifier nodePath) { NodeConnectorId nodeConnectorId = nodeConnectorIdfromDatapathPortNo(datapathId, portNo, ofVersion); return nodePath.child(NodeConnector.class, new NodeConnectorKey(nodeConnectorId)); } public static NodeConnectorUpdatedBuilder nodeConnectorUpdatedBuilderFromDatapathIdPortNo( - final BigInteger datapathId, final Long portNo, final OpenflowVersion ofVersion) { + final Uint64 datapathId, final Uint32 portNo, final OpenflowVersion ofVersion) { NodeConnectorUpdatedBuilder builder = new NodeConnectorUpdatedBuilder(); builder.setId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portNo, ofVersion)); builder.setNodeConnectorRef(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno( @@ -143,8 +142,8 @@ public abstract class InventoryDataServiceUtil { return builder; } - public static NodeConnectorBuilder nodeConnectorBuilderFromDatapathIdPortNo(final BigInteger datapathId, - final Long portNo, final OpenflowVersion ofVersion) { + public static NodeConnectorBuilder nodeConnectorBuilderFromDatapathIdPortNo(final Uint64 datapathId, + final Uint32 portNo, final OpenflowVersion ofVersion) { NodeConnectorBuilder builder = new NodeConnectorBuilder(); builder.setId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, portNo, ofVersion)); return builder; @@ -160,7 +159,7 @@ public abstract class InventoryDataServiceUtil { return Strings.padStart(dataPathId.toString(16), 16, '0'); } - public static BigInteger extractDatapathId(final NodeRef ref) { + public static Uint64 extractDatapathId(final NodeRef ref) { return InventoryDataServiceUtil.dataPathIdFromNodeId(ref.getValue().firstKeyOf(Node.class).getId()); } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtil.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtil.java index e5ca4f77c5..665b3ef4f3 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtil.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtil.java @@ -5,10 +5,10 @@ * terms of the 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.util; import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.Maps; import java.util.Objects; import javax.annotation.Nullable; import org.opendaylight.openflowjava.protocol.api.util.BinContent; @@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.P import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValuesV10; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,9 +33,13 @@ public final class OpenflowPortsUtil { } private static final Logger LOG = LoggerFactory.getLogger(OpenflowPortsUtil.class); - private static final ImmutableBiMap> VERSION_PORT_MAP; + + // TODO: deprecate this private static final ImmutableBiMap> VERSION_INVERSE_PORT_MAP; + private static final ImmutableBiMap> VERSION_PORT_MAP_UINT; + private static final ImmutableBiMap> VERSION_INVERSE_PORT_MAP_UINT; + private static boolean inportWarnignAlreadyFired = false; static { @@ -77,50 +82,73 @@ public final class OpenflowPortsUtil { BinContent.intToUnsignedLong(PortNumberValues.ANY.getIntValue())) // 0xffffffff .build(); - VERSION_PORT_MAP = new ImmutableBiMap.Builder>() - .put(OFConstants.OFP_VERSION_1_0, ofv10ports) - .put(OFConstants.OFP_VERSION_1_3, ofv13ports) - .build(); - VERSION_INVERSE_PORT_MAP = new ImmutableBiMap.Builder>() .put(OFConstants.OFP_VERSION_1_0, ofv10ports.inverse()) .put(OFConstants.OFP_VERSION_1_3, ofv13ports.inverse()) .build(); + + final ImmutableBiMap ofv10portsUint = ImmutableBiMap.copyOf(Maps.transformValues(ofv10ports, + l -> Uint32.valueOf(l).intern())); + final ImmutableBiMap ofv13portsUint = ImmutableBiMap.copyOf(Maps.transformValues(ofv13ports, + l -> Uint32.valueOf(l).intern())); + + VERSION_PORT_MAP_UINT = new ImmutableBiMap.Builder>() + .put(OFConstants.OFP_VERSION_1_0, ofv10portsUint) + .put(OFConstants.OFP_VERSION_1_3, ofv13portsUint) + .build(); + + VERSION_INVERSE_PORT_MAP_UINT = new ImmutableBiMap.Builder>() + .put(OFConstants.OFP_VERSION_1_0, ofv10portsUint.inverse()) + .put(OFConstants.OFP_VERSION_1_3, ofv13portsUint.inverse()) + .build(); } + // TODO: deprecate and migrate public static String getPortLogicalName(final short ofVersion, final Long portNumber) { return VERSION_INVERSE_PORT_MAP.get(ofVersion).get(portNumber); } + public static String getPortLogicalName(final short ofVersion, final Uint32 portNumber) { + return VERSION_INVERSE_PORT_MAP_UINT.get(ofVersion).get(portNumber); + } + + // TODO: deprecate and migrate public static String getPortLogicalName(final OpenflowVersion ofVersion, final Long portNumber) { return ofVersion.equals(OpenflowVersion.UNSUPPORTED) ? null : getPortLogicalName(ofVersion.getVersion(), portNumber); } + public static String getPortLogicalName(final OpenflowVersion ofVersion, final Uint32 portNumber) { + return ofVersion.equals(OpenflowVersion.UNSUPPORTED) + ? null + : getPortLogicalName(ofVersion.getVersion(), portNumber); + } + @Nullable - static Long getPortFromLogicalName(final OpenflowVersion ofVersion, final String logicalNameOrPort) { + static Uint32 getPortFromLogicalName(final OpenflowVersion ofVersion, final String logicalNameOrPort) { //The correct keyword defined in openflow specification in IN_PORT so we need to allow to use it //for legacy reasons we can't just simply drop the misspelled INPORT //TODO: Consider to remove 'INPORT' keyword - Long port; + Uint32 port; if (Objects.equals(logicalNameOrPort, "INPORT")) { if (!inportWarnignAlreadyFired) { LOG.warn("Using '{}' in port field is not recommended use 'IN_PORT' instead", logicalNameOrPort); inportWarnignAlreadyFired = true; } - port = VERSION_PORT_MAP.get(ofVersion.getVersion()).get(OutputPortValues.INPORT.getName()); + port = VERSION_PORT_MAP_UINT.get(ofVersion.getVersion()).get(OutputPortValues.INPORT.getName()); } else { - port = VERSION_PORT_MAP.get(ofVersion.getVersion()).get(logicalNameOrPort); + port = VERSION_PORT_MAP_UINT.get(ofVersion.getVersion()).get(logicalNameOrPort); } if (port == null) { try { - port = Long.decode(logicalNameOrPort); - } catch (final NumberFormatException ne) { + port = Uint32.valueOf(Long.decode(logicalNameOrPort)); + } catch (final IllegalArgumentException ne) { //ignore, sent null back. - if (logicalNameOrPort.contains(":")) { - port = Long.parseLong(logicalNameOrPort.substring(logicalNameOrPort.lastIndexOf(":") + 1)); + final int lastColon = logicalNameOrPort.lastIndexOf(':'); + if (lastColon != -1) { + port = Uint32.valueOf(logicalNameOrPort.substring(lastColon + 1)); } } } @@ -130,25 +158,35 @@ public final class OpenflowPortsUtil { public static PortNumberUni getProtocolAgnosticPort(final OpenflowVersion ofVersion, final Long portNumber) { final String reservedPortLogicalName = getPortLogicalName(ofVersion, portNumber); + return reservedPortLogicalName == null + ? new PortNumberUni(portNumber == null ? (Uint32) null : Uint32.valueOf(portNumber)) + : new PortNumberUni(reservedPortLogicalName); + } + + // TODO: deprecate and migrate + public static PortNumberUni getProtocolAgnosticPort(final OpenflowVersion ofVersion, final Uint32 portNumber) { + final String reservedPortLogicalName = getPortLogicalName(ofVersion, portNumber); + return reservedPortLogicalName == null ? new PortNumberUni(portNumber) : new PortNumberUni(reservedPortLogicalName); } - public static Long getProtocolPortNumber(final OpenflowVersion ofVersion, final PortNumberUni port) { + + public static Uint32 getProtocolPortNumber(final OpenflowVersion ofVersion, final PortNumberUni port) { final String portLogicalName = port.getString(); return portLogicalName != null - ? VERSION_PORT_MAP.get(ofVersion.getVersion()).get(portLogicalName) + ? VERSION_PORT_MAP_UINT.get(ofVersion.getVersion()).get(portLogicalName) : port.getUint32(); } - public static Long getMaxPortForVersion(final OpenflowVersion ofVersion) { + public static Uint32 getMaxPortForVersion(final OpenflowVersion ofVersion) { return getPortFromLogicalName(ofVersion, OutputPortValues.MAX.getName()); } - public static boolean isPortReserved(final OpenflowVersion ofVersion, final Long portNumber) { - return VERSION_INVERSE_PORT_MAP.get(ofVersion.getVersion()).containsKey(portNumber); + public static boolean isPortReserved(final OpenflowVersion ofVersion, final Uint32 portNumber) { + return VERSION_INVERSE_PORT_MAP_UINT.get(ofVersion.getVersion()).containsKey(portNumber); } /** @@ -158,13 +196,11 @@ public final class OpenflowPortsUtil { * @param portNumber port number * @return true if port number is valid for given protocol version */ - public static boolean checkPortValidity(final OpenflowVersion ofVersion, final Long portNumber) { + public static boolean checkPortValidity(final OpenflowVersion ofVersion, final Uint32 portNumber) { boolean portIsValid = true; if (portNumber == null) { portIsValid = false; - } else if (portNumber < 0) { - portIsValid = false; - } else if (portNumber > getMaxPortForVersion(ofVersion)) { + } else if (portNumber.compareTo(getMaxPortForVersion(ofVersion)) > 0) { if (!isPortReserved(ofVersion, portNumber)) { portIsValid = false; } @@ -195,7 +231,19 @@ public final class OpenflowPortsUtil { * @param portNumber port number * @return port number uri */ + // TODO: deprecate and migrate public static Uri getProtocolAgnosticPortUri(final short version, final long portNumber) { return new Uri(portNumberToString(getProtocolAgnosticPort(OpenflowVersion.get(version), portNumber))); } + + /** + * Converts port number to Uri. + * + * @param version openflow version + * @param portNumber port number + * @return port number uri + */ + public static Uri getProtocolAgnosticPortUri(final short version, final Uint32 portNumber) { + return new Uri(portNumberToString(getProtocolAgnosticPort(OpenflowVersion.get(version), portNumber))); + } } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java index 99f2afc2d6..4caf09709d 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -48,6 +47,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; 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.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class GroupConvertorTest { private ConvertorManager convertorManager; @@ -143,17 +144,17 @@ public class GroupConvertorTest { addGroupBuilder.setBuckets(buckets); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4); - data.setDatapathId(BigInteger.valueOf(1)); + data.setDatapathId(Uint64.ONE); final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data); assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand()); assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType()); - assertEquals(10L, (long) outAddGroupInput.getGroupId().getValue()); - assertEquals(10, (int) outAddGroupInput.getBucketsList().get(0).getWeight()); - assertEquals(20L, (long) outAddGroupInput.getBucketsList().get(0).getWatchPort().getValue()); - assertEquals((Long) 22L, outAddGroupInput.getBucketsList().get(0).getWatchGroup()); + assertEquals(10L, outAddGroupInput.getGroupId().getValue().toJava()); + assertEquals(10, outAddGroupInput.getBucketsList().get(0).getWeight().toJava()); + assertEquals(20L, outAddGroupInput.getBucketsList().get(0).getWatchPort().getValue().toJava()); + assertEquals(22L, outAddGroupInput.getBucketsList().get(0).getWatchGroup().toJava()); final List outActionList = outAddGroupInput.getBucketsList().get(0).getAction(); assertEquals(ImmutableList.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action @@ -166,9 +167,9 @@ public class GroupConvertorTest { .grouping.action.choice.group._case.GroupActionBuilder().setGroupId(5L).build()).build()) .build()), outActionList); - assertEquals((Integer) 50, outAddGroupInput.getBucketsList().get(1).getWeight()); - assertEquals((long) 60, (long) outAddGroupInput.getBucketsList().get(1).getWatchPort().getValue()); - assertEquals((Long) 70L, outAddGroupInput.getBucketsList().get(1).getWatchGroup()); + assertEquals(50, outAddGroupInput.getBucketsList().get(1).getWeight().toJava()); + assertEquals(60, outAddGroupInput.getBucketsList().get(1).getWatchPort().getValue().toJava()); + assertEquals(70L, outAddGroupInput.getBucketsList().get(1).getWatchGroup().toJava()); final List outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction(); assertEquals(ImmutableList.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action @@ -194,7 +195,7 @@ public class GroupConvertorTest { addGroupBuilder.setGroupType(GroupTypes.GroupAll); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4); - data.setDatapathId(BigInteger.valueOf(1)); + data.setDatapathId(Uint64.ONE); final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data); assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand()); @@ -255,7 +256,7 @@ public class GroupConvertorTest { addGroupBuilder.setBuckets(buckets); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4); - data.setDatapathId(BigInteger.valueOf(1)); + data.setDatapathId(Uint64.ONE); final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data); @@ -379,25 +380,25 @@ public class GroupConvertorTest { .build(); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4); - data.setDatapathId(BigInteger.valueOf(1)); + data.setDatapathId(Uint64.ONE); final GroupModInputBuilder outAddGroupInput = convert(input, data); final List bucketList = outAddGroupInput.getBucketsList(); - assertEquals(Long.valueOf(1), bucketList.get(0).getWatchGroup()); - assertEquals(Long.valueOf(3), bucketList.get(0).getWatchPort().getValue()); + assertEquals(Uint32.ONE, bucketList.get(0).getWatchGroup()); + assertEquals(Uint32.valueOf(3), bucketList.get(0).getWatchPort().getValue()); - assertEquals(Long.valueOf(1), bucketList.get(1).getWatchGroup()); - assertEquals(Long.valueOf(4), bucketList.get(1).getWatchPort().getValue()); + assertEquals(Uint32.ONE, bucketList.get(1).getWatchGroup()); + assertEquals(Uint32.valueOf(4), bucketList.get(1).getWatchPort().getValue()); - assertEquals(Long.valueOf(1), bucketList.get(2).getWatchGroup()); - assertEquals(Long.valueOf(5), bucketList.get(2).getWatchPort().getValue()); + assertEquals(Uint32.ONE, bucketList.get(2).getWatchGroup()); + assertEquals(Uint32.valueOf(5), bucketList.get(2).getWatchPort().getValue()); - assertEquals(Long.valueOf(1), bucketList.get(3).getWatchGroup()); - assertEquals(Long.valueOf(6), bucketList.get(3).getWatchPort().getValue()); + assertEquals(Uint32.ONE, bucketList.get(3).getWatchGroup()); + assertEquals(Uint32.valueOf(6), bucketList.get(3).getWatchPort().getValue()); - assertEquals(Long.valueOf(1), bucketList.get(4).getWatchGroup()); - assertEquals(Long.valueOf(2), bucketList.get(4).getWatchPort().getValue()); + assertEquals(Uint32.ONE, bucketList.get(4).getWatchGroup()); + assertEquals(Uint32.valueOf(2), bucketList.get(4).getWatchPort().getValue()); } @@ -482,7 +483,7 @@ public class GroupConvertorTest { addGroupBuilder.setBuckets(buckets); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4); - data.setDatapathId(BigInteger.valueOf(1)); + data.setDatapathId(Uint64.ONE); final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data); 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 index 48eb0f2be3..cfbc147b11 100644 --- 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 @@ -5,7 +5,6 @@ * terms of the 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; @@ -84,7 +83,7 @@ public class MeterConfigStatsResponseConvertorTest { assertEquals(PRESET_COUNT, meterConfigs.size()); int cnt = 0; for (MeterConfigStats meterConfigStats: meterConfigs) { - assertEquals(new Long(cnt), meterConfigStats.getMeterId().getValue()); + assertEquals(cnt, meterConfigStats.getMeterId().getValue().toJava()); assertTrue(meterConfigStats.getFlags().isMeterBurst()); assertFalse(meterConfigStats.getFlags().isMeterKbps()); assertTrue(meterConfigStats.getFlags().isMeterPktps()); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java index 2e1a17ce59..cfc09ce8d5 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java @@ -41,6 +41,8 @@ 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.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.mod.Bands; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class MeterConvertorTest { private ConvertorManager convertorManager; @@ -52,8 +54,8 @@ public class MeterConvertorTest { @Test public void testMeterModCommandConvertorwithAllParameters() { - long burstSize = 10L; - long dropRate = 20L; + final Uint32 burstSize = Uint32.valueOf(10L); + final Uint32 dropRate = Uint32.valueOf(20L); // / DROP Band MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder(); @@ -71,9 +73,9 @@ public class MeterConvertorTest { final MeterBandHeader meterBH = meterBandHeaderBuilder.build(); // DSCP Mark - final long dscpRemarkBurstSize = 11L; - final long dscpRemarkRate = 21L; - final short dscpPercLevel = 1; + final Uint32 dscpRemarkBurstSize = Uint32.valueOf(11L); + final Uint32 dscpRemarkRate = Uint32.valueOf(21L); + final Uint8 dscpPercLevel = Uint8.valueOf(1); MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder(); MeterBandType bandFlag1 = new MeterBandType(false, true, false); @@ -92,9 +94,9 @@ public class MeterConvertorTest { final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build(); // Experimental - final long expBurstSize = 12L; - final long expRate = 22L; - final long expExperimenter = 23L; + final Uint32 expBurstSize = Uint32.valueOf(12L); + final Uint32 expRate = Uint32.valueOf(22L); + final Uint32 expExperimenter = Uint32.valueOf(23L); MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder(); MeterBandType bandFlag2 = new MeterBandType(false, false, true); @@ -141,7 +143,7 @@ public class MeterConvertorTest { assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand()); assertTrue(outMeterModInput.getFlags().isOFPMFBURST()); - assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue()); + assertEquals(Uint32.valueOf(10L), outMeterModInput.getMeterId().getValue()); // BandInformation starts here: List bands = outMeterModInput.getBands(); @@ -150,8 +152,8 @@ public class MeterConvertorTest { if (meterBand instanceof MeterBandDropCase) { assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731 .MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType()); - assertEquals(burstSize, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize()); - assertEquals(dropRate, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate()); + assertEquals(burstSize, ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize()); + assertEquals(dropRate, ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate()); } if (meterBand instanceof MeterBandDscpRemarkCase) { @@ -159,11 +161,11 @@ public class MeterConvertorTest { .MeterBandType.OFPMBTDSCPREMARK, ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType()); assertEquals(dscpRemarkBurstSize, - (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize()); assertEquals(dscpRemarkRate, - (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate()); assertEquals(dscpPercLevel, - (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel()); } if (meterBand instanceof MeterBandExperimenterCase) { @@ -171,12 +173,12 @@ public class MeterConvertorTest { .MeterBandType.OFPMBTEXPERIMENTER, ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType()); assertEquals(expBurstSize, - (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize()); + ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize()); assertEquals(expRate, - (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate()); + ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate()); ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter() .augmentation(ExperimenterIdMeterBand.class); - assertEquals(expExperimenter, (long) expBand.getExperimenter().getValue()); + assertEquals(expExperimenter, expBand.getExperimenter().getValue()); } } } @@ -274,7 +276,7 @@ public class MeterConvertorTest { assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand()); assertFalse(outMeterModInput.getFlags().isOFPMFBURST()); assertTrue(outMeterModInput.getFlags().isOFPMFPKTPS()); - assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue()); + assertEquals(Uint32.valueOf(10L), outMeterModInput.getMeterId().getValue()); // BandInformation starts here: List bands = outMeterModInput.getBands(); @@ -283,8 +285,8 @@ public class MeterConvertorTest { if (meterBand instanceof MeterBandDropCase) { assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731 .MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType()); - assertEquals(burstSize, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize()); - assertEquals(dropRate, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate()); + assertEquals(burstSize, ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize().toJava()); + assertEquals(dropRate, ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate().toJava()); } if (meterBand instanceof MeterBandDscpRemarkCase) { @@ -292,11 +294,11 @@ public class MeterConvertorTest { .MeterBandType.OFPMBTDSCPREMARK, ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType()); assertEquals(dscpRemarkBurstSize, - (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize().toJava()); assertEquals(dscpRemarkRate, - (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate().toJava()); assertEquals(dscpPercLevel, - (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel().toJava()); } if (meterBand instanceof MeterBandExperimenterCase) { @@ -304,12 +306,12 @@ public class MeterConvertorTest { .MeterBandType.OFPMBTEXPERIMENTER, ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType()); assertEquals(expBurstSize, - (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize()); + ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize().toJava()); assertEquals(expRate, - (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate()); + ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate().toJava()); ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter() .augmentation(ExperimenterIdMeterBand.class); - assertEquals(expExperimenter, (long) expBand.getExperimenter().getValue()); + assertEquals(expExperimenter, expBand.getExperimenter().getValue().toJava()); } } } @@ -333,7 +335,7 @@ public class MeterConvertorTest { assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand()); assertTrue(outMeterModInput.getFlags().isOFPMFBURST()); - assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue()); + assertEquals(Uint32.valueOf(10L), outMeterModInput.getMeterId().getValue()); } @Test @@ -412,7 +414,7 @@ public class MeterConvertorTest { assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand()); assertTrue(outMeterModInput.getFlags().isOFPMFBURST()); - assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue()); + assertEquals(Uint32.valueOf(10L), outMeterModInput.getMeterId().getValue()); // BandInformation starts here: List bands = outMeterModInput.getBands(); @@ -422,38 +424,38 @@ public class MeterConvertorTest { assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731 .MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType()); - assertEquals((long) 20, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize()); - assertEquals((long) 10, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate()); + assertEquals(20, ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize()); + assertEquals(10, ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate()); } if (meterBand instanceof MeterBandDscpRemarkCase) { assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731 .MeterBandType.OFPMBTDSCPREMARK, ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType()); - assertEquals((long) 11, - (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize()); - assertEquals((long) 21, - (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate()); + assertEquals(11, + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize().toJava()); + assertEquals(21, + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate().toJava()); assertEquals((short) 1, - (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel()); + ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel().toJava()); } if (meterBand instanceof MeterBandExperimenterCase) { assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731 .MeterBandType.OFPMBTEXPERIMENTER, ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType()); - assertEquals((long) 12, - (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize()); - assertEquals((long) 22, - (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate()); + assertEquals(12, + ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize()); + assertEquals(22, + ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate()); ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter() .augmentation(ExperimenterIdMeterBand.class); - assertEquals((long) 23, (long) expBand.getExperimenter().getValue()); + assertEquals(23, expBand.getExperimenter().getValue()); } } } - private MeterModInputBuilder convert(Meter source, VersionConvertorData data) { + private MeterModInputBuilder convert(final Meter source, final VersionConvertorData data) { Optional outMeterModInputOptional = convertorManager.convert(source, data); return outMeterModInputOptional.orElse(MeterConvertor.defaultResult(data.getVersion())); } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java index ade28f7fe5..853f05df09 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java @@ -5,7 +5,6 @@ * terms of the 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; @@ -25,11 +24,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 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.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class MeterStatsResponseConvertorTest { private static final int PRESET_COUNT = 7; - private static List createMeterStatsLit() { @@ -73,24 +73,24 @@ public class MeterStatsResponseConvertorTest { int cnt = 0; for (MeterStats meterStats : meterStatsList) { assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918 - .MeterId((long) cnt)).getMeterId(), meterStats.key().getMeterId()); - assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue()); - assertEquals(new Long(1000 * cnt), meterStats.getDuration().getNanosecond().getValue()); - assertEquals(new Long(10 * cnt), meterStats.getDuration().getSecond().getValue()); + .MeterId(Uint32.valueOf(cnt))).getMeterId(), meterStats.key().getMeterId()); + assertEquals(Uint64.valueOf(cnt), meterStats.getByteInCount().getValue()); + assertEquals(Uint32.valueOf(1000 * cnt), meterStats.getDuration().getNanosecond().getValue()); + assertEquals(Uint32.valueOf(10 * cnt), meterStats.getDuration().getSecond().getValue()); - assertEquals(new Long(cnt), meterStats.getFlowCount().getValue()); - assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue()); + assertEquals(Uint32.valueOf(cnt), meterStats.getFlowCount().getValue()); + assertEquals(Uint64.valueOf(cnt), meterStats.getByteInCount().getValue()); assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().getBandStat().size()); int bandStatCount = 0; for (BandStat bandStat : meterStats.getMeterBandStats().getBandStat()) { - assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getByteBandCount().getValue()); - assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue()); + assertEquals(Uint64.valueOf(bandStatCount), bandStat.getByteBandCount().getValue()); + assertEquals(Uint64.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue()); bandStatCount++; } assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918 - .MeterId((long) cnt)).getMeterId(), meterStats.getMeterId()); - assertEquals(BigInteger.valueOf(cnt), meterStats.getPacketInCount().getValue()); + .MeterId(Uint32.valueOf(cnt))).getMeterId(), meterStats.getMeterId()); + assertEquals(Uint64.valueOf(cnt), meterStats.getPacketInCount().getValue()); cnt++; } } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java index cab39ef81f..7a78c11c20 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java @@ -44,6 +44,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Co import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Created by Jakub Toth jatoth@cisco.com on 9/23/14. @@ -98,7 +101,7 @@ public class PacketOutConvertorTest { Assert.assertEquals(OFConstants.OFP_NO_BUFFER, message.getBufferId()); Assert.assertEquals(new PortNumber(0xfffffffdL), message.getInPort()); - Assert.assertEquals(version, message.getVersion()); + Assert.assertEquals(Uint8.valueOf(version), message.getVersion()); Assert.assertEquals(xid, message.getXid()); Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData()); } @@ -164,8 +167,8 @@ public class PacketOutConvertorTest { for (int i = 0; i < datapathIdByte.length; i++) { datapathIdByte[i] = 1; } - BigInteger datapathId = new BigInteger(1, datapathIdByte); - Long xid = 0xfffffL; + Uint64 datapathId = Uint64.valueOf(new BigInteger(1, datapathIdByte)); + Uint32 xid = Uint32.valueOf(0xfffffL); XidConvertorData data = new XidConvertorData(version); data.setXid(xid); @@ -173,8 +176,8 @@ public class PacketOutConvertorTest { PacketOutInput message = convert(transmitPacketInput, data); Assert.assertEquals(transmitPacketInput.getBufferId(), message.getBufferId()); - Assert.assertEquals(Long.valueOf(inPort), message.getInPort().getValue()); - Assert.assertEquals(version, message.getVersion()); + Assert.assertEquals(Uint32.valueOf(inPort), message.getInPort().getValue()); + Assert.assertEquals(Uint8.valueOf(version), message.getVersion()); Assert.assertEquals(xid, message.getXid()); ActionConvertorData actionConvertorData = new ActionConvertorData(version); @@ -214,7 +217,7 @@ public class PacketOutConvertorTest { } private static PortNumber getPortNumber(final NodeConnectorKey nodeConKey, final Short ofVersion) { - Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(ofVersion), + Uint32 port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(ofVersion), nodeConKey.getId()); return new PortNumber(port); } @@ -244,7 +247,7 @@ public class PacketOutConvertorTest { return new NodeRef(path); } - private PacketOutInput convert(TransmitPacketInput transmitPacketInput, XidConvertorData data) { + private PacketOutInput convert(final TransmitPacketInput transmitPacketInput, final XidConvertorData data) { Optional messageOptional = convertorManager.convert(transmitPacketInput, data); return messageOptional.orElse(PacketOutConvertor.defaultResult(data.getVersion())); } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java index 5cb08e2a52..4b7c6ff1ce 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java @@ -29,6 +29,7 @@ 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.opendaylight.yangtools.yang.common.Uint32; public class PortConvertorTest { @@ -61,7 +62,7 @@ public class PortConvertorTest { PortBuilder portBld = new PortBuilder(); portBld.setAdvertisedFeatures(features); portBld.setConfiguration(config); - portBld.setPortNumber(new PortNumberUni(42L)); + portBld.setPortNumber(new PortNumberUni(Uint32.valueOf(42L))); portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS)); VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3); @@ -103,12 +104,12 @@ public class PortConvertorTest { flowCapableNodeConnectorBuilder.setAdvertisedFeatures(features); flowCapableNodeConnectorBuilder.setConfiguration(config); flowCapableNodeConnectorBuilder.setCurrentFeature(features); - flowCapableNodeConnectorBuilder.setCurrentSpeed(null); + flowCapableNodeConnectorBuilder.setCurrentSpeed((Uint32) null); flowCapableNodeConnectorBuilder.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS)); - flowCapableNodeConnectorBuilder.setMaximumSpeed(null); + flowCapableNodeConnectorBuilder.setMaximumSpeed((Uint32) null); flowCapableNodeConnectorBuilder.setName("foo"); flowCapableNodeConnectorBuilder.setPeerFeatures(features); - flowCapableNodeConnectorBuilder.setPortNumber(new PortNumberUni(42L)); + flowCapableNodeConnectorBuilder.setPortNumber(new PortNumberUni(Uint32.valueOf(42L))); flowCapableNodeConnectorBuilder.setState(state); flowCapableNodeConnectorBuilder.setSupported(features); @@ -120,9 +121,9 @@ public class PortConvertorTest { portsB.setAdvertisedFeatures(portf31); portsB.setConfig(config31); portsB.setCurrentFeatures(portf31); - portsB.setCurrSpeed(null); + portsB.setCurrSpeed((Uint32) null); portsB.setHwAddr(new MacAddress(DEFAULT_MAC_ADDRESS)); - portsB.setMaxSpeed(null); + portsB.setMaxSpeed((Uint32) null); portsB.setName("foo"); portsB.setPeerFeatures(portf31); portsB.setPortNo(42L); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java index 8d97e1e0b6..7e8be640a3 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -105,6 +104,8 @@ 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.WriteSetfield; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Unit tests for table features response conversions. @@ -165,8 +166,8 @@ public class TableFeaturesResponseConvertorTest { TableFeatures feature = list.get(0); Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue()); Assert.assertEquals("Wrong name", "Aloha", feature.getName()); - Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch()); - Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite()); + Assert.assertEquals("Wrong metadata match", Uint64.valueOf("0001020304050607", 16), feature.getMetadataMatch()); + Assert.assertEquals("Wrong metadata write", Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataWrite()); Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK()); Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue()); Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().getTableFeatureProperties().size()); @@ -180,10 +181,8 @@ public class TableFeaturesResponseConvertorTest { TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder(); featuresBuilder.setTableId((short) 5); featuresBuilder.setName("Aloha"); - byte[] metaMatch = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; - featuresBuilder.setMetadataMatch(metaMatch); - byte[] metaWrite = new byte[]{8, 9, 10, 11, 12, 13, 14, 15}; - featuresBuilder.setMetadataWrite(metaWrite); + featuresBuilder.setMetadataMatch(new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + featuresBuilder.setMetadataWrite(new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); featuresBuilder.setConfig(new TableConfig(false)); featuresBuilder.setMaxEntries(42L); @@ -299,10 +298,8 @@ public class TableFeaturesResponseConvertorTest { featuresBuilder = new TableFeaturesBuilder(); featuresBuilder.setTableId((short) 6); featuresBuilder.setName("Mahalo"); - byte[] metaMatch2 = new byte[]{8, 9, 10, 11, 12, 13, 14, 15}; - featuresBuilder.setMetadataMatch(metaMatch2); - byte[] metaWrite2 = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; - featuresBuilder.setMetadataWrite(metaWrite2); + featuresBuilder.setMetadataMatch(new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + featuresBuilder.setMetadataWrite(new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); featuresBuilder.setConfig(new TableConfig(false)); featuresBuilder.setMaxEntries(24L); @@ -554,8 +551,8 @@ public class TableFeaturesResponseConvertorTest { TableFeatures feature = list.get(0); Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue()); Assert.assertEquals("Wrong name", "Aloha", feature.getName()); - Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch()); - Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite()); + Assert.assertEquals("Wrong metadata match", Uint64.valueOf("0001020304050607", 16), feature.getMetadataMatch()); + Assert.assertEquals("Wrong metadata write",Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataWrite()); Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK()); Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue()); Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size()); @@ -566,7 +563,7 @@ public class TableFeaturesResponseConvertorTest { + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTable", property.getTableFeaturePropType().implementedInterface().getName()); NextTable propType = (NextTable) property.getTableFeaturePropType(); - List ids = propType.getTables().getTableIds(); + List ids = propType.getTables().getTableIds(); Assert.assertEquals("Wrong next table-id size", 2, ids.size()); Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue()); Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue()); @@ -619,8 +616,8 @@ public class TableFeaturesResponseConvertorTest { feature = list.get(1); Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue()); Assert.assertEquals("Wrong name", "Mahalo", feature.getName()); - Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch2), feature.getMetadataMatch()); - Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite()); + Assert.assertEquals("Wrong metadata match", Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataMatch()); + Assert.assertEquals("Wrong metadata write", Uint64.valueOf("0001020304050607", 16), feature.getMetadataWrite()); Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK()); Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue()); Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size()); @@ -854,7 +851,7 @@ public class TableFeaturesResponseConvertorTest { } - private List convert(MultipartReplyTableFeatures features) { + private List convert(final MultipartReplyTableFeatures features) { Optional> listOptional = convertorManager.convert(features, new VersionConvertorData(OFConstants.OFP_VERSION_1_3)); return listOptional.orElse(Collections.emptyList()); 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 index 9c9606d0f7..41fde8380f 100644 --- 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 @@ -7,7 +7,6 @@ */ 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; @@ -72,6 +71,9 @@ 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.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.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * test for {@link ActionConvertor}. @@ -97,7 +99,7 @@ public class ActionConvertorTest { dropActionData(); ActionConvertorData data = new ActionConvertorData((short) 0X4); - data.setDatapathId(BigInteger.ONE); + data.setDatapathId(Uint64.ONE); final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); Optional> actionsOptional = convertorManager.convert(salActions, data); @@ -666,7 +666,8 @@ public class ActionConvertorV13Test { ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue()); } - private static void checkEntryHeader(MatchEntry entry, Class field, boolean hasMask) { + private static void checkEntryHeader(final MatchEntry entry, final Class field, + final boolean hasMask) { Assert.assertEquals("Wrong oxm class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong oxm field", field, entry.getOxmMatchField()); Assert.assertEquals("Wrong hasMask", hasMask, entry.isHasMask()); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java index c4dc5c7c31..868fc81340 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java @@ -69,6 +69,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Unit tests for flow conversion. @@ -105,7 +109,7 @@ public class FlowConvertorTest { RemoveFlowInput flow = flowBuilder.build(); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - data.setDatapathId(new BigInteger("42")); + data.setDatapathId(Uint64.valueOf(42)); List flowMod = convert(flow, data); @@ -138,7 +142,7 @@ public class FlowConvertorTest { UpdatedFlow flow = flowBuilder.build(); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - data.setDatapathId(new BigInteger("42")); + data.setDatapathId(Uint64.valueOf(42)); List flowMod = convert(flow, data); @@ -214,7 +218,7 @@ public class FlowConvertorTest { AddFlowInput flow = flowBuilder.build(); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - data.setDatapathId(new BigInteger("42")); + data.setDatapathId(Uint64.valueOf(42)); List flowMod = convert(flow, data); Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue()); @@ -274,7 +278,7 @@ public class FlowConvertorTest { mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1))); VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - data.setDatapathId(BigInteger.ONE); + data.setDatapathId(Uint64.ONE); List flowModInputBuilders = convert(mockFlow, data); @@ -282,7 +286,7 @@ public class FlowConvertorTest { } - private List convert(Flow flow, VersionDatapathIdConvertorData data) { + private List convert(final Flow flow, final VersionDatapathIdConvertorData data) { Optional> flowModOptional = convertorManager.convert(flow, data); Assert.assertTrue("Flow convertor not found", flowModOptional.isPresent()); return flowModOptional.get(); @@ -302,7 +306,8 @@ public class FlowConvertorTest { } private static Instructions toApplyInstruction( - List actions) { + final List actions) { return new InstructionsBuilder().setInstruction(Collections.singletonList(new InstructionBuilder().setOrder(0) .setInstruction(new ApplyActionsCaseBuilder() .setApplyActions(new ApplyActionsBuilder().setAction(actions).build()).build()) @@ -358,17 +363,17 @@ public class FlowConvertorTest { } @Override - public Long getBufferId() { + public Uint32 getBufferId() { return null; } @Override - public BigInteger getOutPort() { + public Uint64 getOutPort() { return null; } @Override - public Long getOutGroup() { + public Uint32 getOutGroup() { return null; } @@ -398,17 +403,17 @@ public class FlowConvertorTest { } @Override - public Integer getPriority() { + public Uint16 getPriority() { return null; } @Override - public Integer getIdleTimeout() { + public Uint16 getIdleTimeout() { return null; } @Override - public Integer getHardTimeout() { + public Uint16 getHardTimeout() { return null; } @@ -418,7 +423,7 @@ public class FlowConvertorTest { } @Override - public Short getTableId() { + public Uint8 getTableId() { return null; } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Test.java index b4134962c6..461eae10cc 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Test.java @@ -5,7 +5,6 @@ * terms of the 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 static org.junit.Assert.assertEquals; @@ -41,6 +40,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 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.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Created by Martin Bobak mbobak@cisco.com on 8/30/14. @@ -106,7 +107,6 @@ public class MatchConvertorV10Test { Optional matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0)); MatchV10 matchV10 = matchV10Optional.get(); - final Integer zero = 0; assertEquals(ZERO_MAC, matchV10.getDlDst()); assertEquals(FF_MAC, matchV10.getDlSrc()); @@ -118,8 +118,8 @@ public class MatchConvertorV10Test { matchV10.getNwDst().getValue()); assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue()); assertEquals(0, matchV10.getNwTos().shortValue()); - assertEquals(zero, matchV10.getTpSrc()); - assertEquals(zero, matchV10.getTpDst()); + assertEquals(0, matchV10.getTpSrc().toJava()); + assertEquals(0, matchV10.getTpDst().toJava()); boolean wcTpSrc = true; boolean wcTpDst = true; @@ -149,13 +149,13 @@ public class MatchConvertorV10Test { matchV10.getNwDst().getValue()); assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue()); assertEquals(0, matchV10.getNwTos().shortValue()); - assertEquals(icmpType, matchV10.getTpSrc()); - assertEquals(zero, matchV10.getTpDst()); + assertEquals(55, matchV10.getTpSrc().toJava()); + assertEquals(0, matchV10.getTpDst().toJava()); assertEquals(wc, matchV10.getWildcards()); // Specify ICMP code only. Integer icmpCode = 31; - icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(null).setIcmpv4Code(icmpCode.shortValue()); + icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type((Uint8) null).setIcmpv4Code(icmpCode.shortValue()); wcTpSrc = true; wcTpDst = false; wc = new FlowWildcardsV10( @@ -175,8 +175,8 @@ public class MatchConvertorV10Test { matchV10.getNwDst().getValue()); assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue()); assertEquals(0, matchV10.getNwTos().shortValue()); - assertEquals(zero, matchV10.getTpSrc()); - assertEquals(icmpCode, matchV10.getTpDst()); + assertEquals(0, matchV10.getTpSrc().toJava()); + assertEquals(Uint16.valueOf(icmpCode), matchV10.getTpDst()); assertEquals(wc, matchV10.getWildcards()); // Specify both ICMP type and code. @@ -203,8 +203,8 @@ public class MatchConvertorV10Test { matchV10.getNwDst().getValue()); assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue()); assertEquals(0, matchV10.getNwTos().shortValue()); - assertEquals(icmpType, matchV10.getTpSrc()); - assertEquals(icmpCode, matchV10.getTpDst()); + assertEquals(Uint16.valueOf(icmpType), matchV10.getTpSrc()); + assertEquals(Uint16.valueOf(icmpCode), matchV10.getTpDst()); assertEquals(wc, matchV10.getWildcards()); } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java index f50b79f609..e31d4fa2d1 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -159,6 +158,7 @@ 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.vlan.vid._case.VlanVidBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit tests for match response conversions. @@ -184,7 +184,7 @@ public class MatchResponseConvertor2Test { public void testEmptyMatch() { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); convert(new MatchBuilder().build(), datapathIdConvertorData); } @@ -202,7 +202,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -531,7 +531,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -540,7 +540,7 @@ public class MatchResponseConvertor2Test { Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue()); Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue()); - Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }), + Assert.assertEquals("Wrong metadata", Uint64.valueOf("0001020304050607", 16), builtMatch.getMetadata().getMetadata()); Assert.assertEquals("Wrong packet type", 0x1894f, builtMatch.getPacketTypeMatch().getPacketType().longValue()); Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), @@ -573,7 +573,7 @@ public class MatchResponseConvertor2Test { Assert.assertEquals("Wrong mpls bos", 1, builtMatch.getProtocolMatchFields().getMplsBos().intValue()); Assert.assertEquals("Wrong mpls tc", 22, builtMatch.getProtocolMatchFields().getMplsTc().intValue()); Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue()); - Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}), + Assert.assertEquals("Wrong tunnel id", Uint64.valueOf("0102030405060708", 16), builtMatch.getTunnel().getTunnelId()); } @@ -693,16 +693,16 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build(); - Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}), + Assert.assertEquals("Wrong metadata", Uint64.valueOf("0001020304050607", 16), builtMatch.getMetadata().getMetadata()); - Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}), + Assert.assertEquals("Wrong metadata mask", Uint64.valueOf(1), builtMatch.getMetadata().getMetadataMask()); Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress()); @@ -719,7 +719,7 @@ public class MatchResponseConvertor2Test { Assert.assertEquals("Wrong ipv4 src address", "10.0.0.0/24", ipv4Match.getIpv4Source().getValue()); Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.0/20", ipv4Match.getIpv4Destination().getValue()); Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue()); - Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}), + Assert.assertEquals("Wrong tunnel id", Uint64.valueOf("0102030405060708", 16), builtMatch.getTunnel().getTunnelId()); } @@ -766,7 +766,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -824,7 +824,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -882,7 +882,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -941,7 +941,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -999,7 +999,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatch = convert(match, datapathIdConvertorData); @@ -1052,7 +1052,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder builtMatch = convert(builder.build(), datapathIdConvertorData); @@ -1098,7 +1098,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData); @@ -1198,7 +1198,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData); @@ -1242,7 +1242,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData); @@ -1322,7 +1322,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData); @@ -1400,7 +1400,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData); @@ -1463,7 +1463,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData); @@ -1521,7 +1521,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData); @@ -1579,7 +1579,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData); @@ -1638,7 +1638,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData); @@ -1697,7 +1697,7 @@ public class MatchResponseConvertor2Test { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData); @@ -1713,7 +1713,7 @@ public class MatchResponseConvertor2Test { } private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow - .MatchBuilder convert(Match match, VersionDatapathIdConvertorData data) { + .MatchBuilder convert(final Match match, final VersionDatapathIdConvertorData data) { final Optional salMatchOptional = convertorManager.convert(match, data); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertorTest.java index d039a29bf5..623f6d7056 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertorTest.java @@ -5,13 +5,11 @@ * terms of the 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -56,12 +54,13 @@ 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.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.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Unit test for {@link MatchConvertorImpl}. */ public class MatchResponseConvertorTest { - private static final BigInteger DPID = BigInteger.TEN; + private static final Uint64 DPID = Uint64.valueOf(10); private static final Long IN_PORT = 6L; private static final String URI_IN_PORT = "openflow:" + DPID + ":" + IN_PORT; @@ -336,15 +335,15 @@ public class MatchResponseConvertorTest { } } - private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) { + private MatchBuilder convert(final MatchV10 match, final VersionDatapathIdConvertorData data) { final Optional 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 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match match, + final VersionDatapathIdConvertorData data) { final Optional salMatchOptional = convertorManager.convert(match, data); return salMatchOptional.orElse(new MatchBuilder()); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertorTest.java index 0d012c3201..47a065f513 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchV10ResponseConvertorTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match; -import java.math.BigInteger; import java.util.Optional; import org.junit.Assert; import org.junit.Before; @@ -30,6 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Unit tests for v1.0 match conversion. @@ -74,7 +77,7 @@ public class MatchV10ResponseConvertorTest { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final Match salMatch = convert(match, datapathIdConvertorData).build(); @@ -127,7 +130,7 @@ public class MatchV10ResponseConvertorTest { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final Match salMatch = convert(match, datapathIdConvertorData).build(); @@ -152,7 +155,7 @@ public class MatchV10ResponseConvertorTest { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final Match salMatch = convert(match, datapathIdConvertorData).build(); @@ -180,7 +183,7 @@ public class MatchV10ResponseConvertorTest { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final Match salMatch = convert(match, datapathIdConvertorData).build(); @@ -204,7 +207,7 @@ public class MatchV10ResponseConvertorTest { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); - datapathIdConvertorData.setDatapathId(new BigInteger("42")); + datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); final Match salMatch = convert(match, datapathIdConvertorData).build(); } @@ -215,13 +218,13 @@ public class MatchV10ResponseConvertorTest { @Test public void testIcmpv4Match() { // NW_PROTO, TP_SRC, TP_DST are wildcarded. - Long dlType = 0x800L; + Uint32 dlType = Uint32.valueOf(0x800L); FlowWildcardsV10 wc = new FlowWildcardsV10( true, true, false, true, true, true, true, true, true, true); MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue()); MatchV10 match = builder.build(); - BigInteger dpid = BigInteger.valueOf(12345L); + Uint64 dpid = Uint64.valueOf(12345L); final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); datapathIdConvertorData.setDatapathId(dpid); @@ -265,8 +268,8 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify ICMPv4 protocol. - Short ipProto = 1; - match = builder.setNwProto(ipProto).build(); + Uint8 ipProto = Uint8.ONE; + match = builder.setNwProto(ipProto.shortValue()).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); IpMatch ipMatch = salMatch.getIpMatch(); @@ -314,7 +317,7 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify ICMPv4 type. - Short icmpType = 10; + Uint8 icmpType = Uint8.valueOf(10); match = builder.setTpSrc(icmpType.intValue()).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -369,8 +372,8 @@ public class MatchV10ResponseConvertorTest { null, icmpv4Match.getIcmpv4Code()); // Specify ICMPv4 code only. - Short icmpCode = 33; - match = builder.setTpSrc(null).setTpDst(icmpCode.intValue()).build(); + Uint8 icmpCode = Uint8.valueOf(33); + match = builder.setTpSrc((Uint16) null).setTpDst(icmpCode.intValue()).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); ipMatch = salMatch.getIpMatch(); @@ -396,8 +399,8 @@ public class MatchV10ResponseConvertorTest { icmpCode, icmpv4Match.getIcmpv4Code()); // Specify both ICMPv4 type and code. - icmpType = 0; - icmpCode = 8; + icmpType = Uint8.ZERO; + icmpCode = Uint8.valueOf(8); match = builder.setTpSrc(icmpType.intValue()).setTpDst(icmpCode.intValue()).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -431,13 +434,13 @@ public class MatchV10ResponseConvertorTest { public void testTcpMatch() { // TP_SRC, TP_DST are wildcarded. // NW_PROTO is not wildcarded but null. - Long dlType = 0x800L; + Uint32 dlType = Uint32.valueOf(0x800L); FlowWildcardsV10 wc = new FlowWildcardsV10( true, true, false, true, true, true, false, true, true, true); MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue()); MatchV10 match = builder.build(); - BigInteger dpid = BigInteger.valueOf(12345L); + Uint64 dpid = Uint64.valueOf(12345L); final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); datapathIdConvertorData.setDatapathId(dpid); @@ -459,7 +462,7 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify TCP protocol. - Short ipProto = 6; + Uint8 ipProto = Uint8.valueOf(6); match = builder.setNwProto(ipProto).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -508,7 +511,7 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify TCP source port. - Integer srcPort = 60000; + Uint16 srcPort = Uint16.valueOf(60000); match = builder.setTpSrc(srcPort).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -565,8 +568,8 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify TCP destination port only. - Integer dstPort = 6653; - match = builder.setTpSrc(null).setTpDst(dstPort).build(); + Uint16 dstPort = Uint16.valueOf(6653); + match = builder.setTpSrc((Uint16) null).setTpDst(dstPort).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); ipMatch = salMatch.getIpMatch(); @@ -593,8 +596,8 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify both source and destination port. - srcPort = 32767; - dstPort = 9999; + srcPort = Uint16.valueOf(32767); + dstPort = Uint16.valueOf(9999); match = builder.setTpSrc(srcPort).setTpDst(dstPort).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -629,13 +632,13 @@ public class MatchV10ResponseConvertorTest { public void testUdpMatch() { // TP_SRC, TP_DST are wildcarded. // NW_PROTO is not wildcarded but null. - Long dlType = 0x800L; + Uint32 dlType = Uint32.valueOf(0x800L); FlowWildcardsV10 wc = new FlowWildcardsV10( true, true, false, true, true, true, false, true, true, true); MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue()); MatchV10 match = builder.build(); - BigInteger dpid = BigInteger.valueOf(12345L); + Uint64 dpid = Uint64.valueOf(12345L); final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0); datapathIdConvertorData.setDatapathId(dpid); @@ -657,7 +660,7 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify UDP protocol. - Short ipProto = 17; + Uint8 ipProto = Uint8.valueOf(17); match = builder.setNwProto(ipProto).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -706,7 +709,7 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify UDP source port. - Integer srcPort = 60000; + Uint16 srcPort = Uint16.valueOf(60000); match = builder.setTpSrc(srcPort).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -763,8 +766,8 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify UDP destination port only. - Integer dstPort = 6653; - match = builder.setTpSrc(null).setTpDst(dstPort).build(); + Uint16 dstPort = Uint16.valueOf(6653); + match = builder.setTpSrc((Uint16) null).setTpDst(dstPort).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); ipMatch = salMatch.getIpMatch(); @@ -791,8 +794,8 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); // Specify both source and destination port. - srcPort = 32767; - dstPort = 9999; + srcPort = Uint16.valueOf(32767); + dstPort = Uint16.valueOf(9999); match = builder.setTpSrc(srcPort).setTpDst(dstPort).build(); salMatch = convert(match, datapathIdConvertorData).build(); etherMatch = salMatch.getEthernetMatch(); @@ -820,7 +823,7 @@ public class MatchV10ResponseConvertorTest { null, salMatch.getIcmpv4Match()); } - private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) { + private MatchBuilder convert(final MatchV10 match, final VersionDatapathIdConvertorData data) { final Optional salMatchOptional = convertorManager.convert(match, data); return salMatchOptional.orElse(new MatchBuilder()); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtilTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtilTest.java index bcd86cb3f7..7b4187a99b 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtilTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/ByteUtilTest.java @@ -8,11 +8,13 @@ package org.opendaylight.openflowplugin.openflow.md.util; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.junit.Test; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Created by Martin Bobak mbobak@cisco.com on 6/30/14. @@ -64,6 +66,12 @@ public class ByteUtilTest { assertEquals(8, bigIntAsBytes.length); } + @Test + public void testUint64toBytes() { + final Uint64 value = Uint64.valueOf("0102030405060708", 16); + assertArrayEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8}, ByteUtil.uint64toBytes(value)); + } + @Test public void testBytesToUnsignedInt() { long unsigned = ByteUtil.bytesToUnsignedInt(TEST_BYTES); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtilTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtilTest.java index 0a7fa37aa6..c737129efd 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtilTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtilTest.java @@ -23,13 +23,13 @@ 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.openflow.common.types.rev130731.PortNumberValuesV10; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; @RunWith(MockitoJUnitRunner.class) public class InventoryDataServiceUtilTest { - - - private static final long PORT_NO = PortNumberValuesV10.CONTROLLER.getIntValue(); - private static final BigInteger PATH_ID = BigInteger.TEN; + private static final Uint32 PORT_NO = Uint32.valueOf(PortNumberValuesV10.CONTROLLER.getIntValue()); + private static final Uint64 PATH_ID = Uint64.valueOf(10); /** * Test method for {@link InventoryDataServiceUtil#nodeUpdatedBuilderFromDataPathId(BigInteger datapathId)}. @@ -85,7 +85,7 @@ public class InventoryDataServiceUtilTest { @Test public void testNodeConnectorInstanceIdentifierFromDatapathIdPortno() { InstanceIdentifier nodeConnectorInstanceIdentifier = InventoryDataServiceUtil - .nodeConnectorInstanceIdentifierFromDatapathIdPortno(BigInteger.ONE, PORT_NO, OpenflowVersion.OF10); + .nodeConnectorInstanceIdentifierFromDatapathIdPortno(Uint64.ONE, PORT_NO, OpenflowVersion.OF10); assertNotNull(nodeConnectorInstanceIdentifier); } @@ -124,7 +124,7 @@ public class InventoryDataServiceUtilTest { long[] expectedDPIDs = new long[] { 1234L, -8236511293788841338L, -1L }; for (int i = 0; i < nodeIds.length; i++) { - BigInteger datapathId = InventoryDataServiceUtil.dataPathIdFromNodeId(nodeIds[i]); + Uint64 datapathId = InventoryDataServiceUtil.dataPathIdFromNodeId(nodeIds[i]); Assert.assertEquals(expectedDPIDs[i], datapathId.longValue()); } } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtilTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtilTest.java index 9600a1297f..8a1e907893 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtilTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtilTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Unit tests for OpenflowPortsUtil. @@ -81,8 +82,8 @@ public class OpenflowPortsUtilTest { //helper private static void matchGetPortfromLogicalName(final OpenflowVersion version, final String logicalName) { Assert.assertEquals("Controller reserve port not matching to logical-name for " + version, - mapVersionToPorts.get(version).get(logicalName), - OpenflowPortsUtil.getPortFromLogicalName(version, logicalName)); + mapVersionToPorts.get(version).get(logicalName).longValue(), + OpenflowPortsUtil.getPortFromLogicalName(version, logicalName).toJava()); } /** @@ -162,13 +163,12 @@ public class OpenflowPortsUtilTest { */ @Test public void testCheckPortValidity10() { - Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , -1L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , 0L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , 0xFF00L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , 0xFFF8L)); - Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , 0xFFF0L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , 0xFFFFL)); - Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , 0x1FFFFL)); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , Uint32.valueOf(0L))); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , Uint32.valueOf(0xFF00L))); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , Uint32.valueOf(0xFFF8L))); + Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , Uint32.valueOf(0xFFF0L))); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , Uint32.valueOf(0xFFFFL))); + Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF10 , Uint32.valueOf(0x1FFFFL))); } /** @@ -176,13 +176,11 @@ public class OpenflowPortsUtilTest { */ @Test public void testCheckPortValidity13() { - Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , -1L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , 0L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , 0xFFFFFF00L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , 0xFFFFFFF8L)); - Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , 0xFFFFFFF0L)); - Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , 0xFFFFFFFFL)); - Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , 0x1FFFFFFFFL)); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , Uint32.valueOf(0L))); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , Uint32.valueOf(0xFFFFFF00L))); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , Uint32.valueOf(0xFFFFFFF8L))); + Assert.assertFalse(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , Uint32.valueOf(0xFFFFFFF0L))); + Assert.assertTrue(OpenflowPortsUtil.checkPortValidity(OpenflowVersion.OF13 , Uint32.valueOf(0xFFFFFFFFL))); } /** @@ -192,7 +190,7 @@ public class OpenflowPortsUtilTest { public void testPortNumberToString() { PortNumberUni portNumber; - portNumber = new PortNumberUni(42L); + portNumber = new PortNumberUni(Uint32.valueOf(42L)); Assert.assertEquals("42", OpenflowPortsUtil.portNumberToString(portNumber)); portNumber = new PortNumberUni(OutputPortValues.FLOOD.toString()); diff --git a/parent/pom.xml b/parent/pom.xml index 89e3f2fbce..c0e7b3ef90 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.mdsal binding-parent - 4.0.6 + 5.0.2 diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowUtils.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowUtils.java index d799e8fe9b..03e600ca51 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowUtils.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowUtils.java @@ -38,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 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.EthernetMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; public final class FlowUtils { private FlowUtils() { @@ -47,7 +49,7 @@ public final class FlowUtils { /** * Returns a {@link FlowBuilder} forwarding all packets to controller port. */ - public static FlowBuilder createDirectMacToMacFlow(final Short tableId, final int priority, final MacAddress srcMac, + public static FlowBuilder createDirectMacToMacFlow(final Uint8 tableId, final int priority, final MacAddress srcMac, final MacAddress dstMac, final NodeConnectorRef dstPort) { FlowBuilder macToMacFlow = new FlowBuilder() .setTableId(tableId) @@ -72,7 +74,7 @@ public final class FlowUtils { .setOrder(0) .setAction(new OutputActionCaseBuilder() .setOutputAction(new OutputActionBuilder() - .setMaxLength(Integer.valueOf(0xffff)) + .setMaxLength(Uint16.MAX_VALUE) .setOutputNodeConnector(outputPort) .build()) .build()) @@ -111,11 +113,11 @@ public final class FlowUtils { /** * Returns a{@link FlowBuilder} forwarding all packets to controller port. */ - public static FlowBuilder createFwdAllToControllerFlow(final Short tableId, final int priority, + public static FlowBuilder createFwdAllToControllerFlow(final Uint8 tableId, final int priority, final FlowId flowId) { // Create output action -> send to controller OutputActionBuilder output = new OutputActionBuilder(); - output.setMaxLength(Integer.valueOf(0xffff)); + output.setMaxLength(Uint16.MAX_VALUE); Uri controllerPort = new Uri(OutputPortValues.CONTROLLER.toString()); output.setOutputNodeConnector(controllerPort); diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/InstanceIdentifierUtils.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/InstanceIdentifierUtils.java index 2acc10228b..e09ca98b1c 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/InstanceIdentifierUtils.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/InstanceIdentifierUtils.java @@ -20,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; public final class InstanceIdentifierUtils { @@ -76,7 +77,7 @@ public final class InstanceIdentifierUtils { * * @param tablePath the table path */ - public static Short getTableId(final InstanceIdentifier
tablePath) { + public static Uint8 getTableId(final InstanceIdentifier
tablePath) { return tablePath.firstKeyOf(Table.class).getId(); } diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandlerSimpleImpl.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandlerSimpleImpl.java index b8f72fdea3..4f6ffe53c8 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandlerSimpleImpl.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandlerSimpleImpl.java @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Pa import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -190,7 +191,7 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P */ InstanceIdentifier flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey); - Short tableId = InstanceIdentifierUtils.getTableId(tablePath); + Uint8 tableId = InstanceIdentifierUtils.getTableId(tablePath); FlowBuilder srcToDstFlow = FlowUtils.createDirectMacToMacFlow(tableId, DIRECT_FLOW_PRIORITY, srcMac, dstMac, destNodeConnector); srcToDstFlow.setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement()))); diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java index b88883f4d7..a539b54bc1 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java @@ -15,6 +15,7 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +26,7 @@ public class WakeupOnNode implements DataTreeChangeListener
{ @Override public void onDataTreeChanged(@Nonnull Collection> modifications) { - Short requiredTableId = 0; + Uint8 requiredTableId = Uint8.ZERO; // TODO add flow for (DataTreeModification
modification : modifications) { diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/NodeErrorListenerLoggingImpl.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/NodeErrorListenerLoggingImpl.java index 1b48eec380..bc8d27ac48 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/NodeErrorListenerLoggingImpl.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/NodeErrorListenerLoggingImpl.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.test; -import java.math.BigInteger; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.errors.rev131116.ErrorType; import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.BadActionErrorNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.BadInstructionErrorNotification; @@ -26,6 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev14041 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.SwitchConfigErrorNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.TableFeaturesErrorNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.TableModErrorNotification; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -128,7 +129,7 @@ public class NodeErrorListenerLoggingImpl implements NodeErrorListener { notification.getTransactionId().getValue())); } - private String toStr(ErrorType type, int code, BigInteger xid) { + private String toStr(ErrorType type, Uint16 code, Uint64 xid) { return "[Type=" + type + ", Code=" + code + ", Xid =" + xid + "]"; } } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java index 686e754016..5a47b1a491 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java @@ -68,6 +68,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.TableFeaturePropertiesKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint8; import org.osgi.framework.BundleContext; @SuppressWarnings("checkstyle:MethodName") @@ -245,7 +246,7 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr private TableFeaturePropertiesBuilder createNextTblFeatureProp() { TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder(); - List nextTblIds = Arrays.asList(new Short[]{2, 3}); + List nextTblIds = Arrays.asList(Uint8.valueOf(2), Uint8.valueOf(3)); NextTableBuilder nextTblBld = new NextTableBuilder(); nextTblBld.setTables(new TablesBuilder().setTableIds(nextTblIds).build()); @@ -260,7 +261,8 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr private TableFeaturePropertiesBuilder createNextTableMissTblFeatureProp() { TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder(); - List nextTblMissIds = Arrays.asList(new Short[]{23, 24, 25, 27, 28, 29, 30}); + List nextTblMissIds = Arrays.asList(Uint8.valueOf(23), Uint8.valueOf(24), Uint8.valueOf(25), + Uint8.valueOf(27), Uint8.valueOf(28), Uint8.valueOf(29), Uint8.valueOf(30)); NextTableMissBuilder nextTblMissBld = new NextTableMissBuilder(); nextTblMissBld.setTablesMiss(new TablesMissBuilder().setTableIds(nextTblMissIds).build()); -- 2.36.6