summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/honeycomb-parent/pom.xml8
-rw-r--r--infra/cfg-init/pom.xml2
-rw-r--r--infra/data-impl/pom.xml2
-rw-r--r--infra/impl/pom.xml2
-rw-r--r--infra/it/it-test/pom.xml2
-rw-r--r--infra/notification/impl/pom.xml2
-rw-r--r--infra/translate-api/pom.xml2
-rw-r--r--infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/DataObjectUpdatesTest.java1
-rw-r--r--infra/translate-impl/pom.xml2
-rw-r--r--infra/translate-spi/pom.xml2
-rw-r--r--infra/translate-utils/pom.xml2
-rwxr-xr-xlisp/lisp2vpp/pom.xml2
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java12
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizer.java9
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java8
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java16
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java6
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java10
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java22
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java6
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java7
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java6
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java6
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java6
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java (renamed from lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java)81
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java14
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java10
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java10
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java16
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java11
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java16
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java11
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java33
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java12
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java47
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java44
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java8
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java14
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java8
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java8
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshEntryWriterCustomizer.java54
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java44
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizer.java102
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java55
-rw-r--r--v3po/v3po2vpp/pom.xml2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java4
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/AclWriter.java15
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java58
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java38
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java33
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java11
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java19
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java40
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceL2Customizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java48
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java32
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java32
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java62
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AbstractAceWriter.java22
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriter.java25
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4Writer.java28
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/IetfAClWriter.java39
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java9
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java17
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java (renamed from v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4WriteUtils.java)50
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv6Customizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java34
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidator.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizer.java10
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/EthernetCustomizer.java10
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java25
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java17
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java64
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java (renamed from v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceUtils.java)116
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2Customizer.java5
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizer.java6
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceAclCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java71
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java22
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java42
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java26
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java29
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java67
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4NeighbourCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4ReadUtils.java130
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java68
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java50
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java47
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/check/AddressDumpCheck.java16
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/params/AddressDumpParams.java28
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java37
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java25
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java27
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java26
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java38
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java38
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java24
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java26
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java20
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java29
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java17
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/DisabledInterfacesManagerTest.java3
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceTypeTestUtils.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java20
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java8
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java24
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslatorTest.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceUtilsTest.java)22
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java121
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java46
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java12
-rw-r--r--vpp-common/minimal-distribution/pom.xml2
-rw-r--r--vpp-common/vpp-translate-test/pom.xml2
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java2
-rw-r--r--vpp-common/vpp-translate-utils/pom.xml2
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AbstractInterfaceTypeCustomizer.java16
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AddressTranslator.java57
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslator.java79
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/FutureJVppCustomizer.java3
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv4Translator.java132
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv6Translator.java158
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumer.java95
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/MacTranslator.java109
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/NamingContext.java47
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TagRewriteOperation.java16
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TranslateUtils.java502
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/AddressTranslatorTest.java20
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java39
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv4TranslatorTest.java33
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv6TranslatorTest.java40
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumerTest.java60
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/MacTranslatorTest.java73
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java211
135 files changed, 2386 insertions, 2137 deletions
diff --git a/common/honeycomb-parent/pom.xml b/common/honeycomb-parent/pom.xml
index 4d6ca2fb0..5aa4fb3c4 100644
--- a/common/honeycomb-parent/pom.xml
+++ b/common/honeycomb-parent/pom.xml
@@ -146,9 +146,11 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
+ <!-- Dont use mockito-all, it has problematic dependency on harmcrest
+ More details here - https://github.com/mockito/mockito/issues/324-->
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
@@ -208,7 +210,9 @@
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<sourceDirectory>${project.basedir}</sourceDirectory>
<includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang</includes>
- <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/src/main/yang-gen-config\/,**\/src/main/yang-gen-sal\/,**\/src/main/xtend-gen\/,**\/src/main/yang\/</excludes>
+ <excludes>
+ **\/target\/,**\/bin\/,**\/target-ide\/,**\/src/main/yang-gen-config\/,**\/src/main/yang-gen-sal\/,**\/src/main/xtend-gen\/,**\/src/main/yang\/
+ </excludes>
<outputFile>${project.build.directory}/checkstyle-logging-result.xml</outputFile>
</configuration>
</execution>
diff --git a/infra/cfg-init/pom.xml b/infra/cfg-init/pom.xml
index c1fd353dc..1a0098dd0 100644
--- a/infra/cfg-init/pom.xml
+++ b/infra/cfg-init/pom.xml
@@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/data-impl/pom.xml b/infra/data-impl/pom.xml
index 341378192..8b4e29918 100644
--- a/infra/data-impl/pom.xml
+++ b/infra/data-impl/pom.xml
@@ -60,7 +60,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/impl/pom.xml b/infra/impl/pom.xml
index 0bbe23e6c..572a079bf 100644
--- a/infra/impl/pom.xml
+++ b/infra/impl/pom.xml
@@ -61,7 +61,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/it/it-test/pom.xml b/infra/it/it-test/pom.xml
index 9600de2e3..bd2f9c0d6 100644
--- a/infra/it/it-test/pom.xml
+++ b/infra/it/it-test/pom.xml
@@ -56,7 +56,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/infra/notification/impl/pom.xml b/infra/notification/impl/pom.xml
index 083cb98eb..f289f75d1 100644
--- a/infra/notification/impl/pom.xml
+++ b/infra/notification/impl/pom.xml
@@ -50,7 +50,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/translate-api/pom.xml b/infra/translate-api/pom.xml
index 88801f13c..594057284 100644
--- a/infra/translate-api/pom.xml
+++ b/infra/translate-api/pom.xml
@@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/DataObjectUpdatesTest.java b/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/DataObjectUpdatesTest.java
index 2c576eb6b..46ebb01ff 100644
--- a/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/DataObjectUpdatesTest.java
+++ b/infra/translate-api/src/test/java/io/fd/honeycomb/translate/write/registry/DataObjectUpdatesTest.java
@@ -20,6 +20,7 @@ import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
+
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
diff --git a/infra/translate-impl/pom.xml b/infra/translate-impl/pom.xml
index 99b3a9846..2a9280b87 100644
--- a/infra/translate-impl/pom.xml
+++ b/infra/translate-impl/pom.xml
@@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/translate-spi/pom.xml b/infra/translate-spi/pom.xml
index 18de9b1d4..8fb2cd1cb 100644
--- a/infra/translate-spi/pom.xml
+++ b/infra/translate-spi/pom.xml
@@ -50,7 +50,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/infra/translate-utils/pom.xml b/infra/translate-utils/pom.xml
index e1b14702a..d05f6b7ba 100644
--- a/infra/translate-utils/pom.xml
+++ b/infra/translate-utils/pom.xml
@@ -72,7 +72,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/lisp/lisp2vpp/pom.xml b/lisp/lisp2vpp/pom.xml
index b78ee8526..a3b49349c 100755
--- a/lisp/lisp2vpp/pom.xml
+++ b/lisp/lisp2vpp/pom.xml
@@ -86,7 +86,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java
index 0c2e2180f..153061ef5 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java
@@ -19,7 +19,7 @@ package io.fd.honeycomb.lisp.context.util;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Optional;
-import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.util.RWUtils;
import java.util.stream.Collector;
@@ -39,7 +39,7 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
/**
* Utility class allowing {@link MappingId} to {@link Eid} mapping
*/
-public class EidMappingContext {
+public class EidMappingContext implements EidTranslator {
private static final Collector<Mapping, ?, Mapping> SINGLE_ITEM_COLLECTOR = RWUtils.singleItemCollector();
@@ -75,7 +75,7 @@ public class EidMappingContext {
checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
return read.get().getMapping().stream()
- .filter(mapping -> EidConverter.compareEids(mapping.getEid(), eid))
+ .filter(mapping -> compareEids(mapping.getEid(), eid))
.collect(SINGLE_ITEM_COLLECTOR).getId();
}
@@ -104,7 +104,7 @@ public class EidMappingContext {
// that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object
// (x == y has the value true).
return read.get().getMapping().stream()
- .filter(mapping -> EidConverter.compareEids(mapping.getEid(), eid))
+ .filter(mapping -> compareEids(mapping.getEid(), eid))
.collect(SINGLE_ITEM_COLLECTOR).getId();
}
@@ -124,7 +124,7 @@ public class EidMappingContext {
checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
return read.isPresent()
- ? read.get().getMapping().stream().anyMatch(mapping -> EidConverter.compareEids(mapping.getEid(), eid))
+ ? read.get().getMapping().stream().anyMatch(mapping -> compareEids(mapping.getEid(), eid))
: false;
}
@@ -143,7 +143,7 @@ public class EidMappingContext {
checkArgument(read.isPresent(), "No mapping stored for eid: %s", eid);
return read.isPresent()
- ? read.get().getMapping().stream().anyMatch(mapping -> EidConverter.compareEids(mapping.getEid(), eid))
+ ? read.get().getMapping().stream().anyMatch(mapping -> compareEids(mapping.getEid(), eid))
: false;
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizer.java
index 90e0a491a..cf90be60e 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizer.java
@@ -20,8 +20,9 @@ package io.fd.honeycomb.lisp.translate.read;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
@@ -41,7 +42,7 @@ import org.slf4j.LoggerFactory;
* Customizer that handles reads of {@code LispState}
*/
public class LispStateCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<LispState, LispStateBuilder> {
+ implements ReaderCustomizer<LispState, LispStateBuilder>, JvppReplyConsumer, ByteDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(LispStateCustomizer.class);
@@ -60,12 +61,12 @@ public class LispStateCustomizer extends FutureJVppCustomizer
ShowLispStatusReply reply;
try {
- reply = TranslateUtils.getReply(getFutureJVpp().showLispStatus(new ShowLispStatus()).toCompletableFuture());
+ reply = getReply(getFutureJVpp().showLispStatus(new ShowLispStatus()).toCompletableFuture());
} catch (TimeoutException | VppBaseCallException e) {
throw new ReadFailedException(id, e);
}
- builder.setEnable(TranslateUtils.byteToBoolean(reply.featureStatus));
+ builder.setEnable(byteToBoolean(reply.featureStatus));
}
@Override
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
index 1262aaa9b..e16a2133e 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
@@ -22,17 +22,13 @@ import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsD
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.QuantityType;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.compareAddresses;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.getArrayAsEidLocal;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.getEidAsByteArray;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.getEidType;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.getPrefixLength;
import com.google.common.base.Optional;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
import io.fd.honeycomb.lisp.translate.read.dump.check.MappingsDumpCheck;
import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
@@ -66,7 +62,7 @@ import org.slf4j.LoggerFactory;
*/
public class LocalMappingCustomizer
extends FutureJVppCustomizer
- implements ListReaderCustomizer<LocalMapping, LocalMappingKey, LocalMappingBuilder> {
+ implements ListReaderCustomizer<LocalMapping, LocalMappingKey, LocalMappingBuilder>, EidTranslator {
private static final Logger LOG = LoggerFactory.getLogger(LocalMappingCustomizer.class);
private static final String KEY = LocalMappingCustomizer.class.getName();
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java
index 77d4e2f08..8df9dbf71 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java
@@ -25,11 +25,11 @@ import io.fd.honeycomb.lisp.translate.read.dump.executor.LocatorSetsDumpExecutor
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -48,7 +48,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LocatorSetCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<LocatorSet, LocatorSetKey, LocatorSetBuilder> {
+ implements ListReaderCustomizer<LocatorSet, LocatorSetKey, LocatorSetBuilder>, ByteDataTranslator {
//TODO - temporary as public because of hack in write customizer in *.write.LocatorSetCustomizer
public static final String LOCATOR_SETS_CACHE_ID = LocatorSetCustomizer.class.getName();
@@ -93,11 +93,11 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
LispLocatorSetDetailsReplyDump dump = dumpOptional.get();
java.util.Optional<LispLocatorSetDetails> details = dump.lispLocatorSetDetails.stream()
- .filter(n -> keyName.equals(TranslateUtils.toString(n.lsName)))
+ .filter(n -> keyName.equals(toString(n.lsName)))
.findFirst();
if (details.isPresent()) {
- final String name = TranslateUtils.toString(details.get().lsName);
+ final String name = toString(details.get().lsName);
builder.setName(name);
builder.setKey(new LocatorSetKey(name));
@@ -123,7 +123,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
return dumpOptional.get().lispLocatorSetDetails.stream()
.map(set -> {
- final String locatorSetName = TranslateUtils.toString(set.lsName);
+ final String locatorSetName = toString(set.lsName);
//creates mapping for existing locator-set(if it is'nt already existing one)
if (!locatorSetContext.containsIndex(locatorSetName, context.getMappingContext())) {
locatorSetContext.addName(set.lsIndex, locatorSetName, context.getMappingContext());
@@ -136,7 +136,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
return set;
})
- .map(set -> new LocatorSetKey(TranslateUtils.toString(set.lsName)))
+ .map(set -> new LocatorSetKey(toString(set.lsName)))
.collect(Collectors.toList());
} else {
LOG.warn("No data dumped for Locator Set {}", id);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java
index 9e98193d7..9c7146abb 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java
@@ -17,9 +17,6 @@
package io.fd.honeycomb.lisp.translate.read;
import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.arrayToIpAddress;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.byteToBoolean;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.reverseAddress;
import com.google.common.base.Optional;
import io.fd.honeycomb.lisp.translate.read.dump.check.MapResolverDumpCheck;
@@ -29,6 +26,7 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import java.util.Collections;
import java.util.List;
@@ -48,7 +46,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MapResolverCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<MapResolver, MapResolverKey, MapResolverBuilder> {
+ implements ListReaderCustomizer<MapResolver, MapResolverKey, MapResolverBuilder>, AddressTranslator {
private static final Logger LOG = LoggerFactory.getLogger(MapResolverCustomizer.class);
private static final String MAP_RESOLVERS_CACHE_ID = MapResolverCustomizer.class.getName();
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java
index effeb9674..54c2f3497 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java
@@ -17,13 +17,12 @@
package io.fd.honeycomb.lisp.translate.read;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.getReply;
-
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
@@ -42,7 +41,8 @@ import org.slf4j.LoggerFactory;
/**
* Customizer for reading {@link PitrCfg}<br> Currently unsupported in jvpp
*/
-public class PitrCfgCustomizer extends FutureJVppCustomizer implements ReaderCustomizer<PitrCfg, PitrCfgBuilder> {
+public class PitrCfgCustomizer extends FutureJVppCustomizer
+ implements ReaderCustomizer<PitrCfg, PitrCfgBuilder>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(PitrCfgCustomizer.class);
@@ -68,7 +68,7 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer implements ReaderCus
throw new ReadFailedException(id, e);
}
- builder.setLocatorSet(TranslateUtils.toString(reply.locatorSetName));
+ builder.setLocatorSet(toString(reply.locatorSetName));
LOG.debug("Reading status for Lisp Pitr node {} successfull", id);
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
index a34fedd7f..55b6cbadd 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
@@ -21,8 +21,6 @@ import static com.google.common.base.Preconditions.checkState;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.valueOf;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.compareAddresses;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.getArrayAsEidLocal;
import com.google.common.base.Optional;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
@@ -30,15 +28,14 @@ import io.fd.honeycomb.lisp.translate.read.dump.check.MappingsDumpCheck;
import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.QuantityType;
-import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -64,7 +61,8 @@ import org.slf4j.LoggerFactory;
* Customizer for reading {@code RemoteMapping}<br>
*/
public class RemoteMappingCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<RemoteMapping, RemoteMappingKey, RemoteMappingBuilder> {
+ implements ListReaderCustomizer<RemoteMapping, RemoteMappingKey, RemoteMappingBuilder>,
+ EidTranslator {
private static final Logger LOG = LoggerFactory.getLogger(RemoteMappingCustomizer.class);
private static final String KEY = RemoteMappingCustomizer.class.getName();
@@ -112,9 +110,9 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
final MappingsDumpParams dumpParams = new MappingsDumpParamsBuilder()
.setVni(Long.valueOf(vni).intValue())
.setEidSet(QuantityType.SPECIFIC)
- .setEidType(EidConverter.getEidType(eid))
- .setEid(EidConverter.getEidAsByteArray(eid))
- .setPrefixLength(EidConverter.getPrefixLength(eid))
+ .setEidType(getEidType(eid))
+ .setEid(getEidAsByteArray(eid))
+ .setPrefixLength(getPrefixLength(eid))
.setFilter(FilterType.REMOTE)
.build();
@@ -136,11 +134,11 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
.collect(
RWUtils.singleItemCollector());
- builder.setEid(EidConverter.getArrayAsEidRemote(valueOf(details.eidType), details.eid));
+ builder.setEid(getArrayAsEidRemote(valueOf(details.eidType), details.eid));
builder.setKey(new RemoteMappingKey(new MappingId(id.firstKeyOf(RemoteMapping.class).getId())));
builder.setTtl(resolveTtl(details.ttl));
builder.setAuthoritative(
- new RemoteMapping.Authoritative(TranslateUtils.byteToBoolean(details.authoritative)));
+ new RemoteMapping.Authoritative(byteToBoolean(details.authoritative)));
} else {
LOG.debug("No data dumped");
@@ -191,7 +189,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
.map(detail -> new RemoteMappingKey(
new MappingId(
remoteMappingContext.getId(
- EidConverter.getArrayAsEidRemote(
+ getArrayAsEidRemote(
valueOf(detail.eidType), detail.eid),
context.getMappingContext()))))
.collect(Collectors.toList());
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
index be6aa12e6..d621691ea 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
@@ -19,11 +19,11 @@ package io.fd.honeycomb.lisp.translate.read.dump.executor;
import static com.google.common.base.Preconditions.checkNotNull;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.openvpp.jvpp.VppBaseCallException;
@@ -36,7 +36,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* Executor for dumping of locators
*/
public class LocatorDumpExecutor extends AbstractDumpExecutor
- implements EntityDumpExecutor<LispLocatorDetailsReplyDump, LocatorDumpParams> {
+ implements EntityDumpExecutor<LispLocatorDetailsReplyDump, LocatorDumpParams>, JvppReplyConsumer {
public LocatorDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
@@ -53,7 +53,7 @@ public class LocatorDumpExecutor extends AbstractDumpExecutor
request.isIndexSet = (byte) 1;
try {
- return TranslateUtils.getReply(vppApi.lispLocatorDump(request).toCompletableFuture());
+ return getReply(vppApi.lispLocatorDump(request).toCompletableFuture());
} catch (TimeoutException e) {
throw DumpTimeoutException
.wrapTimeoutException("Locator dump ended in timeout with params" + params.toString(), e);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
index 1c9e01ead..648fac171 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
@@ -17,11 +17,11 @@
package io.fd.honeycomb.lisp.translate.read.dump.executor;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.openvpp.jvpp.VppBaseCallException;
@@ -31,7 +31,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
public class LocatorSetsDumpExecutor extends AbstractDumpExecutor
- implements EntityDumpExecutor<LispLocatorSetDetailsReplyDump, Void> {
+ implements EntityDumpExecutor<LispLocatorSetDetailsReplyDump, Void>, JvppReplyConsumer {
public LocatorSetsDumpExecutor(@Nonnull FutureJVppCore api) {
super(api);
@@ -45,8 +45,7 @@ public class LocatorSetsDumpExecutor extends AbstractDumpExecutor
request.filter = 1;
try {
- return TranslateUtils
- .getReply(vppApi.lispLocatorSetDump(request).toCompletableFuture());
+ return getReply(vppApi.lispLocatorSetDump(request).toCompletableFuture());
} catch (TimeoutException e) {
throw DumpTimeoutException.wrapTimeoutException("Locator sets dump ended in timeout", e);
} catch (VppBaseCallException e) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
index fe2ebbc16..bc0f99a6a 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
@@ -17,11 +17,11 @@
package io.fd.honeycomb.lisp.translate.read.dump.executor;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.openvpp.jvpp.VppBaseCallException;
@@ -31,7 +31,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
public class MapResolversDumpExecutor extends AbstractDumpExecutor
- implements EntityDumpExecutor<LispMapResolverDetailsReplyDump, Void> {
+ implements EntityDumpExecutor<LispMapResolverDetailsReplyDump, Void>, JvppReplyConsumer {
public MapResolversDumpExecutor(@Nonnull FutureJVppCore api) {
super(api);
@@ -40,7 +40,7 @@ public class MapResolversDumpExecutor extends AbstractDumpExecutor
@Override
public LispMapResolverDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException {
try {
- return TranslateUtils.getReply(vppApi.lispMapResolverDump(new LispMapResolverDump()).toCompletableFuture());
+ return getReply(vppApi.lispMapResolverDump(new LispMapResolverDump()).toCompletableFuture());
} catch (TimeoutException e) {
throw DumpTimeoutException
.wrapTimeoutException("Map resolver dump execution ended in timeout", e);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
index 86c9696b4..43042c61a 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
@@ -20,11 +20,11 @@ package io.fd.honeycomb.lisp.translate.read.dump.executor;
import static com.google.common.base.Preconditions.checkNotNull;
import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.openvpp.jvpp.VppBaseCallException;
@@ -37,7 +37,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* Common dump executor for both local and remote mappings
*/
public class MappingsDumpExecutor extends AbstractDumpExecutor
- implements EntityDumpExecutor<LispEidTableDetailsReplyDump, MappingsDumpParams> {
+ implements EntityDumpExecutor<LispEidTableDetailsReplyDump, MappingsDumpParams>, JvppReplyConsumer {
public MappingsDumpExecutor(@Nonnull FutureJVppCore vppApi) {
super(vppApi);
@@ -58,7 +58,7 @@ public class MappingsDumpExecutor extends AbstractDumpExecutor
request.filter = params.getFilter();
try {
- return TranslateUtils.getReply(vppApi.lispEidTableDump(request).toCompletableFuture());
+ return getReply(vppApi.lispEidTableDump(request).toCompletableFuture());
} catch (TimeoutException e) {
throw DumpTimeoutException
.wrapTimeoutException("Mappings dump execution timed out with params " + params.toString(), e);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
index 1e894d7a8..24325cc50 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
@@ -17,11 +17,11 @@
package io.fd.honeycomb.lisp.translate.read.dump.executor;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.openvpp.jvpp.VppBaseCallException;
@@ -31,7 +31,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
public class VniTableDumpExecutor extends AbstractDumpExecutor
- implements EntityDumpExecutor<LispEidTableMapDetailsReplyDump, Void> {
+ implements EntityDumpExecutor<LispEidTableMapDetailsReplyDump, Void>, JvppReplyConsumer {
public VniTableDumpExecutor(@Nonnull FutureJVppCore api) {
super(api);
@@ -40,7 +40,7 @@ public class VniTableDumpExecutor extends AbstractDumpExecutor
@Override
public LispEidTableMapDetailsReplyDump executeDump(Void params) throws DumpExecutionFailedException {
try {
- return TranslateUtils.getReply(vppApi.lispEidTableMapDump(new LispEidTableMapDump()).toCompletableFuture());
+ return getReply(vppApi.lispEidTableMapDump(new LispEidTableMapDump()).toCompletableFuture());
} catch (TimeoutException e) {
throw DumpTimeoutException.wrapTimeoutException("Eid table map dump ended in timeout", e);
} catch (VppBaseCallException e) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java
index b0ca7fc04..0a4319568 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidTranslator.java
@@ -22,7 +22,7 @@ import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsD
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
import java.util.Arrays;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
@@ -42,38 +42,35 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
/**
- * Helper class that converts {@code SimpleAddress} to eid format for vpp
+ * Trait providing converting logic for eid's
*/
-public final class EidConverter {
+public interface EidTranslator extends AddressTranslator {
- private EidConverter() {
- throw new UnsupportedOperationException("Cannot instantiate utility class " + EidConverter.class.getName());
- }
- public static byte getPrefixLength(LocalEid address) {
+ default byte getPrefixLength(LocalEid address) {
return resolverPrefixLength(address.getAddress());
}
- public static byte getPrefixLength(RemoteEid address) {
+ default byte getPrefixLength(RemoteEid address) {
return resolverPrefixLength(address.getAddress());
}
- public static byte getPrefixLength(
+ default byte getPrefixLength(
org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
return resolverPrefixLength(address.getAddress());
}
- public static byte getPrefixLength(
+ default byte getPrefixLength(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
return resolverPrefixLength(address.getAddress());
}
- public static byte getPrefixLength(
+ default byte getPrefixLength(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
return resolverPrefixLength(address.getAddress());
}
- private static byte resolverPrefixLength(Address address) {
+ static byte resolverPrefixLength(Address address) {
switch (resolveType(address)) {
case IPV4:
@@ -87,22 +84,22 @@ public final class EidConverter {
}
}
- public static Eid getArrayAsEidLocal(EidType type, byte[] address) {
+ default Eid getArrayAsEidLocal(EidType type, byte[] address) {
switch (type) {
case IPV4: {
return new EidBuilder().setAddress(
- new Ipv4Builder().setIpv4(TranslateUtils.arrayToIpv4AddressNoZoneReversed(address)).build())
+ new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address)).build())
.build();
}
case IPV6: {
return new EidBuilder().setAddress(
- new Ipv6Builder().setIpv6(TranslateUtils.arrayToIpv6AddressNoZoneReversed(address)).build())
+ new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address)).build())
.build();
}
case MAC: {
return new EidBuilder().setAddress(
- new MacBuilder().setMac(new MacAddress(TranslateUtils.byteArrayToMacSeparated(address)))
+ new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address)))
.build()).build();
}
default: {
@@ -111,28 +108,28 @@ public final class EidConverter {
}
}
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid getArrayAsEidRemote(
+ default org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid getArrayAsEidRemote(
EidType type, byte[] address) {
switch (type) {
case IPV4: {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
.setAddress(
- new Ipv4Builder().setIpv4(TranslateUtils.arrayToIpv4AddressNoZoneReversed(address))
+ new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address))
.build())
.build();
}
case IPV6: {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
.setAddress(
- new Ipv6Builder().setIpv6(TranslateUtils.arrayToIpv6AddressNoZoneReversed(address))
+ new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address))
.build())
.build();
}
case MAC: {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
.setAddress(
- new MacBuilder().setMac(new MacAddress(TranslateUtils.byteArrayToMacSeparated(address)))
+ new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address)))
.build()).build();
}
default: {
@@ -141,18 +138,18 @@ public final class EidConverter {
}
}
- public static String getArrayAsEidString(
+ default String getArrayAsEidString(
EidType type, byte[] address) {
switch (type) {
case IPV4: {
- return TranslateUtils.arrayToIpv4AddressNoZoneReversed(address).getValue();
+ return arrayToIpv4AddressNoZoneReversed(address).getValue();
}
case IPV6: {
- return TranslateUtils.arrayToIpv6AddressNoZoneReversed(address).getValue();
+ return arrayToIpv6AddressNoZoneReversed(address).getValue();
}
case MAC: {
//as wrong as it looks ,its right(second param is not end index,but count)
- return TranslateUtils.byteArrayToMacSeparated(Arrays.copyOfRange(address, 0, 6));
+ return byteArrayToMacSeparated(Arrays.copyOfRange(address, 0, 6));
}
default: {
throw new IllegalStateException("Unknown type detected");
@@ -161,14 +158,14 @@ public final class EidConverter {
}
- public static EidType getEidType(
+ default EidType getEidType(
org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
checkNotNull(address, "SimpleAddress cannot be null");
return resolveType(address.getAddress());
}
- public static EidType getEidType(
+ default EidType getEidType(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
checkNotNull(address, "SimpleAddress cannot be null");
@@ -176,7 +173,7 @@ public final class EidConverter {
}
- public static EidType getEidType(
+ default EidType getEidType(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
checkNotNull(address, "Address cannot be null");
@@ -184,19 +181,19 @@ public final class EidConverter {
}
- public static EidType getEidType(final LocalEid address) {
+ default EidType getEidType(final LocalEid address) {
checkNotNull(address, "Address cannot be null");
return resolveType(address.getAddress());
}
- public static EidType getEidType(final RemoteEid address) {
+ default EidType getEidType(final RemoteEid address) {
checkNotNull(address, "Address cannot be null");
return resolveType(address.getAddress());
}
- private static EidType resolveType(
+ static EidType resolveType(
Address address) {
if (address instanceof Ipv4) {
@@ -210,56 +207,54 @@ public final class EidConverter {
}
}
- public static byte[] getEidAsByteArray(
+ default byte[] getEidAsByteArray(
org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
}
- public static byte[] getEidAsByteArray(
+ default byte[] getEidAsByteArray(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
}
- public static byte[] getEidAsByteArray(
+ default byte[] getEidAsByteArray(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
}
- public static byte[] getEidAsByteArray(final LocalEid address) {
+ default byte[] getEidAsByteArray(final LocalEid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
}
- public static byte[] getEidAsByteArray(final RemoteEid address) {
+ default byte[] getEidAsByteArray(final RemoteEid address) {
checkNotNull(address, "Eid cannot be null");
return resolveByteArray(getEidType(address), address.getAddress());
}
- private static byte[] resolveByteArray(EidType type, Address address) {
+ default byte[] resolveByteArray(EidType type, Address address) {
switch (type) {
case IPV4:
- return TranslateUtils
- .ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(((Ipv4) address).getIpv4()));
+ return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(((Ipv4) address).getIpv4()));
case IPV6:
- return TranslateUtils
- .ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(((Ipv6) address).getIpv6()));
+ return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(((Ipv6) address).getIpv6()));
case MAC:
- return TranslateUtils.parseMac(((Mac) address).getMac().getValue());
+ return parseMac(((Mac) address).getMac().getValue());
default:
throw new IllegalArgumentException("Unsupported type");
}
}
- public static boolean compareEids(
+ default boolean compareEids(
LispAddress first,
LispAddress second) {
@@ -267,7 +262,7 @@ public final class EidConverter {
checkNotNull(second, "Second eid is null").getAddress());
}
- public static boolean compareAddresses(Address firstAddress, Address secondAddress) {
+ default boolean compareAddresses(Address firstAddress, Address secondAddress) {
checkNotNull(firstAddress, "First address is null");
checkNotNull(secondAddress, "Second address is null");
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
index 3eedf295d..dc0ea4062 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
@@ -20,12 +20,12 @@ package io.fd.honeycomb.lisp.translate.write;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
-import static io.fd.honeycomb.lisp.translate.util.EidConverter.*;
-import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.TimeoutException;
@@ -39,7 +39,9 @@ import org.openvpp.jvpp.core.dto.LispAddDelAdjacency;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Adjacency, AdjacencyKey> {
+public class AdjacencyCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Adjacency, AdjacencyKey>, ByteDataTranslator, EidTranslator,
+ JvppReplyConsumer {
public AdjacencyCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
super(futureJvpp);
@@ -89,7 +91,7 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWri
LispAddDelAdjacency request = new LispAddDelAdjacency();
- request.isAdd = TranslateUtils.booleanToByte(add);
+ request.isAdd = booleanToByte(add);
request.seid = getEidAsByteArray(data.getLocalEid());
request.seidLen = getPrefixLength(data.getLocalEid());
request.deid = getEidAsByteArray(data.getRemoteEid());
@@ -97,6 +99,6 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWri
request.eidType = (byte) localEidType.getValue();
request.vni = vni;
- TranslateUtils.getReply(getFutureJVpp().lispAddDelAdjacency(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispAddDelAdjacency(request).toCompletableFuture());
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
index c26bbf377..841298f4e 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
@@ -21,9 +21,10 @@ import static com.google.common.base.Preconditions.checkState;
import static java.nio.charset.StandardCharsets.UTF_8;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.io.UnsupportedEncodingException;
@@ -43,7 +44,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
*
* @see Interface
*/
-public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Interface, InterfaceKey> {
+public class InterfaceCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Interface, InterfaceKey>, ByteDataTranslator, JvppReplyConsumer {
private final NamingContext interfaceContext;
@@ -109,12 +111,12 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
throws VppBaseCallException, TimeoutException, UnsupportedEncodingException {
LispAddDelLocator request = new LispAddDelLocator();
- request.isAdd = TranslateUtils.booleanToByte(add);
+ request.isAdd = booleanToByte(add);
request.priority = data.getPriority().byteValue();
request.weight = data.getWeight().byteValue();
request.swIfIndex = interfaceIndex;
request.locatorSetName = locatorSetName.getBytes(UTF_8);
- TranslateUtils.getReply(getFutureJVpp().lispAddDelLocator(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispAddDelLocator(request).toCompletableFuture());
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
index 05c162d0c..040938c20 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
@@ -18,8 +18,9 @@ package io.fd.honeycomb.lisp.translate.write;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
@@ -36,7 +37,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
/**
* Handles updates of {@link Lisp} node. Takes care of LISP enable/disable
*/
-public class LispCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Lisp> {
+public class LispCustomizer extends FutureJVppCustomizer
+ implements WriterCustomizer<Lisp>, ByteDataTranslator, JvppReplyConsumer {
public LispCustomizer(final FutureJVppCore vppApi) {
super(vppApi);
@@ -84,12 +86,12 @@ public class LispCustomizer extends FutureJVppCustomizer implements WriterCustom
private void enableDisableLisp(final boolean enable) throws VppBaseCallException, TimeoutException {
final CompletionStage<LispEnableDisableReply> lispEnableDisableReplyCompletionStage =
getFutureJVpp().lispEnableDisable(getRequest(enable));
- TranslateUtils.getReply(lispEnableDisableReplyCompletionStage.toCompletableFuture());
+ getReply(lispEnableDisableReplyCompletionStage.toCompletableFuture());
}
private LispEnableDisable getRequest(final boolean enable) {
final LispEnableDisable lispEnableDisable = new LispEnableDisable();
- lispEnableDisable.isEn = TranslateUtils.booleanToByte(enable);
+ lispEnableDisable.isEn = booleanToByte(enable);
return lispEnableDisable;
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
index eec4b8269..cdd1906ed 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
@@ -23,10 +23,11 @@ import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsD
import static java.nio.charset.StandardCharsets.UTF_8;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
-import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.io.UnsupportedEncodingException;
@@ -46,7 +47,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* Customizer that writes changes for {@link LocalMapping}
*/
public class LocalMappingCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<LocalMapping, LocalMappingKey> {
+ implements ListWriterCustomizer<LocalMapping, LocalMappingKey>, ByteDataTranslator, EidTranslator,
+ JvppReplyConsumer {
private final EidMappingContext localMappingsContext;
@@ -118,9 +120,9 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer
LispAddDelLocalEid request = new LispAddDelLocalEid();
- request.isAdd = TranslateUtils.booleanToByte(add);
- request.eid = EidConverter.getEidAsByteArray(data.getEid());
- request.eidType = (byte) EidConverter.getEidType(data.getEid()).getValue();
+ request.isAdd = booleanToByte(add);
+ request.eid = getEidAsByteArray(data.getEid());
+ request.eidType = (byte) getEidType(data.getEid()).getValue();
request.locatorSetName = data.getLocatorSet().getBytes(UTF_8);
request.vni = vni;
@@ -131,7 +133,7 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer
request.prefixLen = (byte) 128;
}
- TranslateUtils.getReply(getFutureJVpp().lispAddDelLocalEid(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispAddDelLocalEid(request).toCompletableFuture());
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
index a53388125..8e2acbf9a 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
@@ -18,7 +18,6 @@ package io.fd.honeycomb.lisp.translate.write;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.getReply;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Optional;
@@ -30,9 +29,10 @@ import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.io.UnsupportedEncodingException;
@@ -55,7 +55,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* @see LocatorSet
*/
public class LocatorSetCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<LocatorSet, LocatorSetKey> {
+ implements ListWriterCustomizer<LocatorSet, LocatorSetKey>, ByteDataTranslator,
+ JvppReplyConsumer {
private final NamingContext locatorSetContext;
private final DumpCacheManager<LispLocatorSetDetailsReplyDump, Void> dumpManager;
@@ -140,7 +141,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
LispAddDelLocatorSet addDelSet = new LispAddDelLocatorSet();
- addDelSet.isAdd = TranslateUtils.booleanToByte(add);
+ addDelSet.isAdd = booleanToByte(add);
addDelSet.locatorSetName = name.getBytes(UTF_8);
@@ -158,7 +159,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
if (reply.isPresent()) {
return reply.get().lispLocatorSetDetails.stream()
- .filter(a -> name.equals(TranslateUtils.toString(a.lsName)))
+ .filter(a -> name.equals(toString(a.lsName)))
.collect(RWUtils.singleItemCollector())
.lsIndex;
} else {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java
index 02c9f4255..73b89c240 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java
@@ -19,8 +19,9 @@ package io.fd.honeycomb.lisp.translate.write;
import static com.google.common.base.Preconditions.checkNotNull;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.TimeoutException;
@@ -37,7 +38,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* Handles updates of {@link MapResolver} list
*/
public class MapResolverCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<MapResolver, MapResolverKey> {
+ implements ListWriterCustomizer<MapResolver, MapResolverKey>, AddressTranslator,
+ JvppReplyConsumer {
public MapResolverCustomizer(final FutureJVppCore vppApi) {
super(vppApi);
@@ -84,14 +86,14 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
TimeoutException {
LispAddDelMapResolver request = new LispAddDelMapResolver();
- request.isAdd = TranslateUtils.booleanToByte(add);
+ request.isAdd = booleanToByte(add);
- boolean ipv6 = TranslateUtils.isIpv6(data.getIpAddress());
+ boolean ipv6 = isIpv6(data.getIpAddress());
- request.isIpv6 = TranslateUtils.booleanToByte(ipv6);
- request.ipAddress = TranslateUtils.ipAddressToArray(ipv6, data.getIpAddress());
+ request.isIpv6 = booleanToByte(ipv6);
+ request.ipAddress = ipAddressToArray(ipv6, data.getIpAddress());
- TranslateUtils.getReply(getFutureJVpp().lispAddDelMapResolver(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispAddDelMapResolver(request).toCompletableFuture());
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
index ab3be2add..d146de3cd 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
@@ -20,11 +20,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeoutException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -36,7 +36,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
/**
* Customizer for {@code PitrCfg}
*/
-public class PitrCfgCustomizer extends FutureJVppCustomizer implements WriterCustomizer<PitrCfg> {
+public class PitrCfgCustomizer extends FutureJVppCustomizer
+ implements WriterCustomizer<PitrCfg>, JvppReplyConsumer, ByteDataTranslator {
public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
super(futureJvpp);
@@ -85,10 +86,10 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer implements WriterCus
throws VppBaseCallException, TimeoutException {
LispPitrSetLocatorSet request = new LispPitrSetLocatorSet();
- request.isAdd = TranslateUtils.booleanToByte(add);
+ request.isAdd = booleanToByte(add);
request.lsName = data.getLocatorSet().getBytes(UTF_8);
- TranslateUtils.getReply(getFutureJVpp().lispPitrSetLocatorSet(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispPitrSetLocatorSet(request).toCompletableFuture());
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
index e8e37969e..dae8cd89f 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
@@ -25,10 +25,11 @@ import static io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer.Locat
import com.google.common.base.Preconditions;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
-import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.io.ByteArrayOutputStream;
@@ -60,7 +61,8 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* Customizer for {@link RemoteMapping}
*/
public class RemoteMappingCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<RemoteMapping, RemoteMappingKey> {
+ implements ListWriterCustomizer<RemoteMapping, RemoteMappingKey>, EidTranslator,
+ AddressTranslator, JvppReplyConsumer {
private final EidMappingContext remoteMappingContext;
@@ -127,13 +129,13 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
LispAddDelRemoteMapping request = new LispAddDelRemoteMapping();
- request.isAdd = TranslateUtils.booleanToByte(add);
+ request.isAdd = booleanToByte(add);
request.vni = vni;
- request.eidType = (byte) EidConverter.getEidType(data.getEid()).getValue();
- request.eid = EidConverter.getEidAsByteArray(data.getEid());
+ request.eidType = (byte) getEidType(data.getEid()).getValue();
+ request.eid = getEidAsByteArray(data.getEid());
//this is not length of eid array,but prefix length(bad naming by vpp)
- request.eidLen = EidConverter.getPrefixLength(data.getEid());
+ request.eidLen = getPrefixLength(data.getEid());
if (LocatorListType.NEGATIVE
.equals(resolveType(data.getLocatorList()))) {
@@ -147,7 +149,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
request.rlocNum = Integer.valueOf(rlocs.getLocator().size()).byteValue();
}
- TranslateUtils.getReply(getFutureJVpp().lispAddDelRemoteMapping(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispAddDelRemoteMapping(request).toCompletableFuture());
}
private static LocatorListType resolveType(LocatorList locatorList) {
@@ -176,7 +178,8 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
return ((PositiveMapping) locatorList).getRlocs();
}
- private static byte[] locatorsToBinaryData(List<Locator> locators) throws IOException {
+ //cant be static because of use of default methods from traits
+ private byte[] locatorsToBinaryData(List<Locator> locators) throws IOException {
checkNotNull(locators, "Cannot convert null list");
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
@@ -189,8 +192,8 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
byte[] address;
//first byte says that its v4/v6
- isIpv4 = !TranslateUtils.isIpv6(locator.getAddress());
- out.writeByte(TranslateUtils.booleanToByte(isIpv4));
+ isIpv4 = !isIpv6(locator.getAddress());
+ out.writeByte(booleanToByte(isIpv4));
//then writes priority
out.write(locator.getPriority());
@@ -201,14 +204,14 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
if (isIpv4) {
//vpp in this case needs address as 16 byte array,regardless if it is ivp4 or ipv6
address = Arrays.copyOf(
- TranslateUtils
- .ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(locator.getAddress().getIpv4Address())),
+
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(locator.getAddress().getIpv4Address())),
16);
out.write(address);
} else {
- out.write(TranslateUtils
- .ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(locator.getAddress().getIpv6Address())));
+ out.write(
+ ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(locator.getAddress().getIpv6Address())));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
index ad1d41de9..de7cf2c1d 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
@@ -19,8 +19,9 @@ package io.fd.honeycomb.lisp.translate.write;
import static com.google.common.base.Preconditions.checkNotNull;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.TimeoutException;
@@ -28,8 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.openvpp.jvpp.core.dto.LispEidTableAddDelMap;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,7 +38,8 @@ import org.slf4j.LoggerFactory;
/**
* Customizer for {@code TableId}
*/
-public class VniTableCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<VniTable, VniTableKey> {
+public class VniTableCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<VniTable, VniTableKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
@@ -90,11 +92,11 @@ public class VniTableCustomizer extends FutureJVppCustomizer implements ListWrit
LispEidTableAddDelMap request = new LispEidTableAddDelMap();
- request.isAdd = TranslateUtils.booleanToByte(isAdd);
+ request.isAdd = booleanToByte(isAdd);
request.vni = vni;
request.dpTable = vrf;
request.isL2 = 0;
- TranslateUtils.getReply(getFutureJVpp().lispEidTableAddDelMap(request).toCompletableFuture());
+ getReply(getFutureJVpp().lispEidTableAddDelMap(request).toCompletableFuture());
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java
deleted file mode 100755
index 0f06d2984..000000000
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package io.fd.honeycomb.lisp.translate.util;
-
-import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
-import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
-import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-
-public class EidConverterTest {
-
- @Test
- public void testGetEidType() {
- assertEquals(IPV4, EidConverter
- .getEidType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
- .setAddress(
- new Ipv4Builder().setIpv4(
- new Ipv4Address("192.168.2.1"))
- .build())
- .build()));
-
- assertEquals(IPV6, EidConverter
- .getEidType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
- .setAddress(
- new Ipv6Builder().setIpv6(
- new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
- .build())
- .build()));
-
- assertEquals(MAC, EidConverter
- .getEidType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
- .setAddress(
- new MacBuilder().setMac(
- new MacAddress("aa:bb:cc:dd:ee:ff"))
- .build())
- .build()));
- }
-}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java
new file mode 100755
index 000000000..88ad10970
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java
@@ -0,0 +1,44 @@
+package io.fd.honeycomb.lisp.translate.util;
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+
+public class EidTranslatorTest implements EidTranslator {
+
+ @Test
+ public void testGetEidType() {
+ assertEquals(IPV4, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build()));
+
+ assertEquals(IPV6, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv6Builder().setIpv6(
+ new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
+ .build())
+ .build()));
+
+ assertEquals(MAC, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new MacBuilder().setMac(
+ new MacAddress("aa:bb:cc:dd:ee:ff"))
+ .build())
+ .build()));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
index 5f4fdcd97..409f27bbc 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
@@ -25,8 +25,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -48,7 +48,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelLocator;
import org.openvpp.jvpp.core.dto.LispAddDelLocatorReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class InterfaceCustomizerTest extends WriterCustomizerTest {
+public class InterfaceCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
@Captor
private ArgumentCaptor<LispAddDelLocator> intfCaptor;
@@ -119,7 +119,7 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest {
assertEquals(2, request.weight);
assertEquals(1, request.priority);
assertEquals(5, request.swIfIndex);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
@Test(expected = UnsupportedOperationException.class)
@@ -167,6 +167,6 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest {
assertEquals(2, request.weight);
assertEquals(1, request.priority);
assertEquals(5, request.swIfIndex);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
index c4bd65295..9887c6351 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -25,7 +25,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -52,7 +53,8 @@ import org.openvpp.jvpp.core.dto.LispAddDelLocalEidReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class LocalMappingCustomizerTest extends WriterCustomizerTest {
+public class LocalMappingCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator, Ipv4Translator {
+
@Captor
private ArgumentCaptor<LispAddDelLocalEid> mappingCaptor;
@@ -136,11 +138,11 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(0, request.eidType);
assertEquals(1, request.isAdd);
assertEquals(25, request.vni);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
@Test(expected = UnsupportedOperationException.class)
@@ -159,10 +161,10 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(0, request.eidType);
assertEquals(0, request.isAdd);
assertEquals(25, request.vni);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
index 0b2051b43..99818d52e 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -36,7 +36,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelMapResolver;
import org.openvpp.jvpp.core.dto.LispAddDelMapResolverReply;
-public class MapResolverCustomizerTest extends WriterCustomizerTest {
+public class MapResolverCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
private MapResolverCustomizer customizer;
@@ -74,7 +74,7 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest {
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(1, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
@@ -97,7 +97,7 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest {
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(0, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
index 9eca7cf67..dab387a62 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -52,7 +52,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelRemoteMapping;
import org.openvpp.jvpp.core.dto.LispAddDelRemoteMappingReply;
-public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
+public class RemoteMappingCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
@Captor
private ArgumentCaptor<LispAddDelRemoteMapping> mappingCaptor;
@@ -117,7 +117,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals(1, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(25, request.vni);
}
@@ -141,7 +141,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals(0, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(25, request.vni);
}
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshEntryWriterCustomizer.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshEntryWriterCustomizer.java
index d3c15ae88..51dd6e617 100755
--- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshEntryWriterCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshEntryWriterCustomizer.java
@@ -16,38 +16,32 @@
package io.fd.honeycomb.vppnsh.impl.config;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
+import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
-import javax.xml.bind.DatatypeConverter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ethernet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ipv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ipv6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.NextProtocol;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.NshMdType1Augment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.NshMdType1AugmentBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.entries.NshEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.entries.NshEntryKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.nsh.dto.*;
-import org.openvpp.jvpp.nsh.callback.*;
+import org.openvpp.jvpp.nsh.dto.NshAddDelEntry;
+import org.openvpp.jvpp.nsh.dto.NshAddDelEntryReply;
import org.openvpp.jvpp.nsh.future.FutureJVppNsh;
-import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,7 +49,7 @@ import org.slf4j.LoggerFactory;
* Writer customizer responsible for NshEntry create/delete.
*/
public class NshEntryWriterCustomizer extends FutureJVppNshCustomizer
- implements ListWriterCustomizer<NshEntry, NshEntryKey> {
+ implements ListWriterCustomizer<NshEntry, NshEntryKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(NshEntryWriterCustomizer.class);
private final NamingContext nshEntryContext;
@@ -69,11 +63,11 @@ public class NshEntryWriterCustomizer extends FutureJVppNshCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id,
@Nonnull final NshEntry dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("Creating nsh entry: iid={} dataAfter={}", id, dataAfter);
try {
final int newEntryIndex =
- nshAddDelEntry(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext());
+ nshAddDelEntry(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext());
// Add nsh entry name <-> vpp index mapping to the naming context:
nshEntryContext.addName(newEntryIndex, dataAfter.getName(), writeContext.getMappingContext());
@@ -97,7 +91,7 @@ public class NshEntryWriterCustomizer extends FutureJVppNshCustomizer
LOG.debug("Removing nsh entry: iid={} dataBefore={}", id, dataBefore);
final String entryName = dataBefore.getName();
checkState(nshEntryContext.containsIndex(entryName, writeContext.getMappingContext()),
- "Removing nsh entry {}, but index could not be found in the nsh entry context", entryName);
+ "Removing nsh entry {}, but index could not be found in the nsh entry context", entryName);
final int entryIndex = nshEntryContext.getIndex(entryName, writeContext.getMappingContext());
try {
@@ -112,13 +106,13 @@ public class NshEntryWriterCustomizer extends FutureJVppNshCustomizer
}
private int nshAddDelEntry(final boolean isAdd, @Nonnull final InstanceIdentifier<NshEntry> id,
- @Nonnull final NshEntry entry, final int entryId, final MappingContext ctx)
- throws VppBaseCallException, WriteTimeoutException {
+ @Nonnull final NshEntry entry, final int entryId, final MappingContext ctx)
+ throws VppBaseCallException, WriteTimeoutException {
final CompletionStage<NshAddDelEntryReply> createNshEntryReplyCompletionStage =
- getFutureJVppNsh().nshAddDelEntry(getNshAddDelEntryRequest(isAdd, entryId, entry, ctx));
+ getFutureJVppNsh().nshAddDelEntry(getNshAddDelEntryRequest(isAdd, entryId, entry, ctx));
final NshAddDelEntryReply reply =
- TranslateUtils.getReplyForWrite(createNshEntryReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(createNshEntryReplyCompletionStage.toCompletableFuture(), id);
return reply.entryIndex;
}
@@ -142,26 +136,26 @@ public class NshEntryWriterCustomizer extends FutureJVppNshCustomizer
request.verOC = (byte) entry.getVersion().shortValue();
request.length = (byte) entry.getLength().intValue();
- if (entry.getNextProtocol() == Ipv4.class)
+ if (entry.getNextProtocol() == Ipv4.class) {
request.nextProtocol = 1;
- else if (entry.getNextProtocol() == Ipv6.class)
+ } else if (entry.getNextProtocol() == Ipv6.class) {
request.nextProtocol = 2;
- else if (entry.getNextProtocol() == Ethernet.class)
+ } else if (entry.getNextProtocol() == Ethernet.class) {
request.nextProtocol = 3;
- else
+ } else {
request.nextProtocol = 0;
+ }
- if (entry.getMdType() == MdType1.class)
- {
+ if (entry.getMdType() == MdType1.class) {
request.mdType = 1;
getNshEntryMdType1Request(entry, request);
- }
- else if (entry.getMdType() == MdType1.class)
+ } else if (entry.getMdType() == MdType1.class) {
request.mdType = 2;
- else
+ } else {
request.mdType = 0;
+ }
- request.nspNsi = (entry.getNsp().intValue()<<8) | entry.getNsi();
+ request.nspNsi = (entry.getNsp().intValue() << 8) | entry.getNsi();
return request;
}
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java
index f2757bd64..c0e9b21c1 100755
--- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java
@@ -16,31 +16,28 @@
package io.fd.honeycomb.vppnsh.impl.config;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
+import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
-import javax.xml.bind.DatatypeConverter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.EncapType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VxlanGpe;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.maps.NshMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.maps.NshMapKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.nsh.dto.*;
-import org.openvpp.jvpp.nsh.callback.*;
+import org.openvpp.jvpp.nsh.dto.NshAddDelMap;
+import org.openvpp.jvpp.nsh.dto.NshAddDelMapReply;
import org.openvpp.jvpp.nsh.future.FutureJVppNsh;
-import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,15 +45,15 @@ import org.slf4j.LoggerFactory;
* Writer customizer responsible for NshMap create/delete.
*/
public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
- implements ListWriterCustomizer<NshMap, NshMapKey> {
+ implements ListWriterCustomizer<NshMap, NshMapKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(NshMapWriterCustomizer.class);
private final NamingContext nshMapContext;
private final NamingContext interfaceContext;
public NshMapWriterCustomizer(@Nonnull final FutureJVppNsh futureJVppNsh,
- @Nonnull final NamingContext nshMapContext,
- @Nonnull final NamingContext interfaceContext) {
+ @Nonnull final NamingContext nshMapContext,
+ @Nonnull final NamingContext interfaceContext) {
super(futureJVppNsh);
this.nshMapContext = checkNotNull(nshMapContext, "nshMapContext should not be null");
this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
@@ -65,11 +62,11 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id,
@Nonnull final NshMap dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("Creating nsh map: iid={} dataAfter={}", id, dataAfter);
try {
final int newMapIndex =
- nshAddDelMap(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext());
+ nshAddDelMap(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext());
// Add nsh map name <-> vpp index mapping to the naming context:
nshMapContext.addName(newMapIndex, dataAfter.getName(), writeContext.getMappingContext());
@@ -93,7 +90,7 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
LOG.debug("Removing nsh map: iid={} dataBefore={}", id, dataBefore);
final String mapName = dataBefore.getName();
checkState(nshMapContext.containsIndex(mapName, writeContext.getMappingContext()),
- "Removing nsh map {}, but index could not be found in the nsh map context", mapName);
+ "Removing nsh map {}, but index could not be found in the nsh map context", mapName);
final int mapIndex = nshMapContext.getIndex(mapName, writeContext.getMappingContext());
try {
@@ -108,25 +105,24 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
}
private int nshAddDelMap(final boolean isAdd, @Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMap map, final int mapId, final MappingContext ctx)
- throws VppBaseCallException, WriteTimeoutException {
+ @Nonnull final NshMap map, final int mapId, final MappingContext ctx)
+ throws VppBaseCallException, WriteTimeoutException {
final CompletionStage<NshAddDelMapReply> createNshMapReplyCompletionStage =
- getFutureJVppNsh().nshAddDelMap(getNshAddDelMapRequest(isAdd, mapId, map, ctx));
+ getFutureJVppNsh().nshAddDelMap(getNshAddDelMapRequest(isAdd, mapId, map, ctx));
- final NshAddDelMapReply reply =
- TranslateUtils.getReplyForWrite(createNshMapReplyCompletionStage.toCompletableFuture(), id);
+ final NshAddDelMapReply reply = getReplyForWrite(createNshMapReplyCompletionStage.toCompletableFuture(), id);
return reply.mapIndex;
}
private NshAddDelMap getNshAddDelMapRequest(final boolean isAdd, final int mapIndex,
- @Nonnull final NshMap map,
- @Nonnull final MappingContext ctx) {
+ @Nonnull final NshMap map,
+ @Nonnull final MappingContext ctx) {
final NshAddDelMap request = new NshAddDelMap();
request.isAdd = booleanToByte(isAdd);
- request.nspNsi = (map.getNsp().intValue()<<8) | map.getNsi();
- request.mappedNspNsi = (map.getMappedNsp().intValue()<<8) | map.getMappedNsi();
+ request.nspNsi = (map.getNsp().intValue() << 8) | map.getNsi();
+ request.mappedNspNsi = (map.getMappedNsp().intValue() << 8) | map.getMappedNsi();
if (map.getEncapType() == VxlanGpe.class) {
request.nextNode = 2;
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizer.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizer.java
index 53dff0b64..708d7364b 100755
--- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshEntryReaderCustomizer.java
@@ -18,30 +18,24 @@ package io.fd.honeycomb.vppnsh.impl.oper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
-
+import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ethernet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ipv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ipv6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.NextProtocol;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.NshMdType1StateAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.NshMdType1StateAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.MdType2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshEntriesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.entries.NshEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.entries.NshEntryBuilder;
@@ -50,12 +44,10 @@ import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.nsh.dto.NshEntryDump;
-import org.openvpp.jvpp.nsh.dto.NshAddDelEntry;
import org.openvpp.jvpp.nsh.dto.NshEntryDetails;
import org.openvpp.jvpp.nsh.dto.NshEntryDetailsReplyDump;
+import org.openvpp.jvpp.nsh.dto.NshEntryDump;
import org.openvpp.jvpp.nsh.future.FutureJVppNsh;
-import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,7 +55,7 @@ import org.slf4j.LoggerFactory;
* Reader customizer responsible for nsh entry read.<br> to VPP.
*/
public class NshEntryReaderCustomizer extends FutureJVppNshCustomizer
- implements ListReaderCustomizer<NshEntry, NshEntryKey, NshEntryBuilder> {
+ implements ListReaderCustomizer<NshEntry, NshEntryKey, NshEntryBuilder>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(NshEntryReaderCustomizer.class);
private final NamingContext nshEntryContext;
@@ -90,18 +82,18 @@ public class NshEntryReaderCustomizer extends FutureJVppNshCustomizer
private void setNshEntryMdType1Augment(@Nonnull final NshEntryBuilder builder,
@Nonnull NshEntryDetails nshEntryDetails) {
final NshMdType1StateAugmentBuilder augmentBuilder = new NshMdType1StateAugmentBuilder();
- augmentBuilder.setC1((long)nshEntryDetails.c1);
- augmentBuilder.setC2((long)nshEntryDetails.c2);
- augmentBuilder.setC3((long)nshEntryDetails.c3);
- augmentBuilder.setC4((long)nshEntryDetails.c4);
+ augmentBuilder.setC1((long) nshEntryDetails.c1);
+ augmentBuilder.setC2((long) nshEntryDetails.c2);
+ augmentBuilder.setC3((long) nshEntryDetails.c3);
+ augmentBuilder.setC4((long) nshEntryDetails.c4);
builder.addAugmentation(NshMdType1StateAugment.class, augmentBuilder.build());
}
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id,
- @Nonnull final NshEntryBuilder builder, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ @Nonnull final NshEntryBuilder builder, @Nonnull final ReadContext ctx)
+ throws ReadFailedException {
LOG.debug("Reading attributes for nsh entry: {}", id);
try {
final NshEntryKey key = id.firstKeyOf(NshEntry.class);
@@ -116,9 +108,9 @@ public class NshEntryReaderCustomizer extends FutureJVppNshCustomizer
request.entryIndex = nshEntryContext.getIndex(entryName, ctx.getMappingContext());
final CompletionStage<NshEntryDetailsReplyDump> nshEntryDetailsReplyDumpCompletionStage =
- getFutureJVppNsh().nshEntryDump(request);
+ getFutureJVppNsh().nshEntryDump(request);
final NshEntryDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(nshEntryDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(nshEntryDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
if (reply == null || reply.nshEntryDetails == null || reply.nshEntryDetails.isEmpty()) {
LOG.debug("Has no Nsh Entry {} in VPP. ", key.getName());
@@ -130,50 +122,48 @@ public class NshEntryReaderCustomizer extends FutureJVppNshCustomizer
final NshEntryDetails nshEntryDetails = reply.nshEntryDetails.get(0);
builder.setName(entryName);
builder.setKey(key);
- builder.setVersion( (short) nshEntryDetails.verOC );
- builder.setLength( (short) nshEntryDetails.length );
-
- switch(nshEntryDetails.nextProtocol) {
- case 1:
- builder.setNextProtocol(Ipv4.class);
- break;
- case 2:
- builder.setNextProtocol(Ipv6.class);
- break;
- case 3:
- builder.setNextProtocol(Ethernet.class);
- break;
- default:
- LOG.trace("Unsupported next protocol for nsh entry: {}", nshEntryDetails.nextProtocol);
- return;
+ builder.setVersion((short) nshEntryDetails.verOC);
+ builder.setLength((short) nshEntryDetails.length);
+
+ switch (nshEntryDetails.nextProtocol) {
+ case 1:
+ builder.setNextProtocol(Ipv4.class);
+ break;
+ case 2:
+ builder.setNextProtocol(Ipv6.class);
+ break;
+ case 3:
+ builder.setNextProtocol(Ethernet.class);
+ break;
+ default:
+ LOG.trace("Unsupported next protocol for nsh entry: {}", nshEntryDetails.nextProtocol);
+ return;
}
- switch(nshEntryDetails.mdType) {
- case 1:
- {
- builder.setMdType(MdType1.class);
- setNshEntryMdType1Augment(builder, nshEntryDetails);
- break;
- }
- case 2:
- {
- builder.setMdType(MdType1.class);
- break;
- }
- default:
- LOG.trace("Unsupported Mdtype for nsh entry: {}", nshEntryDetails.mdType);
- return;
+ switch (nshEntryDetails.mdType) {
+ case 1: {
+ builder.setMdType(MdType1.class);
+ setNshEntryMdType1Augment(builder, nshEntryDetails);
+ break;
+ }
+ case 2: {
+ builder.setMdType(MdType1.class);
+ break;
+ }
+ default:
+ LOG.trace("Unsupported Mdtype for nsh entry: {}", nshEntryDetails.mdType);
+ return;
}
- builder.setNsp( (long)((nshEntryDetails.nspNsi>>8) & 0xFFFFFF));
- builder.setNsi( (short)(nshEntryDetails.nspNsi & 0xFF ));
+ builder.setNsp((long) ((nshEntryDetails.nspNsi >> 8) & 0xFFFFFF));
+ builder.setNsi((short) (nshEntryDetails.nspNsi & 0xFF));
if (LOG.isTraceEnabled()) {
LOG.trace("Attributes for nsh entry {} successfully read: {}", id, builder.build());
}
} catch (VppBaseCallException e) {
LOG.warn("Failed to readCurrentAttributes for: {}", id);
- throw new ReadFailedException( id, e );
+ throw new ReadFailedException(id, e);
}
}
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java
index 7d6c64baf..4f3e6a1ef 100755
--- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java
@@ -21,23 +21,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
-
+import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ethernet;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Ipv6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.EncapType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VxlanGpe;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMapsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMapBuilder;
@@ -46,11 +40,10 @@ import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.nsh.dto.NshMapDump;
import org.openvpp.jvpp.nsh.dto.NshMapDetails;
import org.openvpp.jvpp.nsh.dto.NshMapDetailsReplyDump;
+import org.openvpp.jvpp.nsh.dto.NshMapDump;
import org.openvpp.jvpp.nsh.future.FutureJVppNsh;
-import io.fd.honeycomb.vppnsh.impl.util.FutureJVppNshCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,15 +51,15 @@ import org.slf4j.LoggerFactory;
* Reader customizer responsible for nsh map read.<br> to VPP.
*/
public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
- implements ListReaderCustomizer<NshMap, NshMapKey, NshMapBuilder> {
+ implements ListReaderCustomizer<NshMap, NshMapKey, NshMapBuilder>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(NshMapReaderCustomizer.class);
private final NamingContext nshMapContext;
private final NamingContext interfaceContext;
public NshMapReaderCustomizer(@Nonnull final FutureJVppNsh futureJVppNsh,
- @Nonnull final NamingContext nshMapContext,
- @Nonnull final NamingContext interfaceContext) {
+ @Nonnull final NamingContext nshMapContext,
+ @Nonnull final NamingContext interfaceContext) {
super(futureJVppNsh);
this.nshMapContext = checkNotNull(nshMapContext, "nshMapContext should not be null");
this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
@@ -87,8 +80,8 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMapBuilder builder, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ @Nonnull final NshMapBuilder builder, @Nonnull final ReadContext ctx)
+ throws ReadFailedException {
LOG.debug("Reading attributes for nsh map: {}", id);
try {
final NshMapKey key = id.firstKeyOf(NshMap.class);
@@ -103,9 +96,9 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
request.mapIndex = nshMapContext.getIndex(mapName, ctx.getMappingContext());
final CompletionStage<NshMapDetailsReplyDump> nshMapDetailsReplyDumpCompletionStage =
- getFutureJVppNsh().nshMapDump(request);
+ getFutureJVppNsh().nshMapDump(request);
final NshMapDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(nshMapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(nshMapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
if (reply == null || reply.nshMapDetails == null || reply.nshMapDetails.isEmpty()) {
LOG.debug("Has no Nsh Map {} in VPP. ", key.getName());
@@ -118,19 +111,19 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
builder.setName(mapName);
builder.setKey(key);
- builder.setNsp( (long)((nshMapDetails.nspNsi>>8) & 0xFFFFFF));
- builder.setNsi( (short)(nshMapDetails.nspNsi & 0xFF ));
+ builder.setNsp((long) ((nshMapDetails.nspNsi >> 8) & 0xFFFFFF));
+ builder.setNsi((short) (nshMapDetails.nspNsi & 0xFF));
- builder.setMappedNsp( (long)((nshMapDetails.mappedNspNsi>>8) & 0xFFFFFF));
- builder.setMappedNsi( (short)(nshMapDetails.mappedNspNsi & 0xFF ));
+ builder.setMappedNsp((long) ((nshMapDetails.mappedNspNsi >> 8) & 0xFFFFFF));
+ builder.setMappedNsi((short) (nshMapDetails.mappedNspNsi & 0xFF));
- switch(nshMapDetails.nextNode) {
- case 2:
- builder.setEncapType(VxlanGpe.class);
- break;
- default:
- LOG.trace("Unsupported encap type for nsh map: {}", nshMapDetails.nextNode);
- return;
+ switch (nshMapDetails.nextNode) {
+ case 2:
+ builder.setEncapType(VxlanGpe.class);
+ break;
+ default:
+ LOG.trace("Unsupported encap type for nsh map: {}", nshMapDetails.nextNode);
+ return;
}
checkState(interfaceContext.containsName(nshMapDetails.swIfIndex, ctx.getMappingContext()),
@@ -143,14 +136,14 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
}
} catch (VppBaseCallException e) {
LOG.warn("Failed to readCurrentAttributes for: {}", id);
- throw new ReadFailedException( id, e );
+ throw new ReadFailedException(id, e);
}
}
@Nonnull
@Override
public List<NshMapKey> getAllIds(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final ReadContext context) throws ReadFailedException {
+ @Nonnull final ReadContext context) throws ReadFailedException {
LOG.debug("Reading list of keys for nsh map: {}", id);
final NshMapDump request = new NshMapDump();
diff --git a/v3po/v3po2vpp/pom.xml b/v3po/v3po2vpp/pom.xml
index ba5cf0352..07210160c 100644
--- a/v3po/v3po2vpp/pom.xml
+++ b/v3po/v3po2vpp/pom.xml
@@ -98,7 +98,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java
index d78f33296..7ecf0c0f5 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/InterfacesInitializer.java
@@ -49,20 +49,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanVni;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.AclBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.EthernetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.GreBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.L2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.TapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUserBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.GreBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Acl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Ethernet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Gre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.L2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Tap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VhostUser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Vxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpe;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Gre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBased;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/AclWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/AclWriter.java
index a1bdf6aa9..ce4494757 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/AclWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/AclWriter.java
@@ -17,10 +17,10 @@
package io.fd.honeycomb.translate.v3po.interfaces;
import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import java.util.concurrent.CompletionStage;
@@ -36,13 +36,14 @@ import org.openvpp.jvpp.core.dto.InputAclSetInterface;
import org.openvpp.jvpp.core.dto.InputAclSetInterfaceReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-interface AclWriter {
+interface AclWriter extends ByteDataTranslator, JvppReplyConsumer {
default void inputAclSetInterface(@Nonnull final FutureJVppCore futureJVppCore, final boolean isAdd,
@Nonnull final InstanceIdentifier<?> id, @Nonnull final AclBaseAttributes acl,
- @Nonnegative final int ifIndex, @Nonnull final VppClassifierContextManager classifyTableContext,
+ @Nonnegative final int ifIndex,
+ @Nonnull final VppClassifierContextManager classifyTableContext,
@Nonnull final MappingContext mappingContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final InputAclSetInterface request = new InputAclSetInterface();
request.isAdd = booleanToByte(isAdd);
request.swIfIndex = ifIndex;
@@ -67,8 +68,8 @@ interface AclWriter {
}
final CompletionStage<InputAclSetInterfaceReply> inputAclSetInterfaceReplyCompletionStage =
- futureJVppCore.inputAclSetInterface(request);
+ futureJVppCore.inputAclSetInterface(request);
- TranslateUtils.getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java
index 1e3057d8c..04398f4b3 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java
@@ -20,8 +20,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.translate.v3po.util.AbstractInterfaceTypeCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -35,13 +35,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Gre;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.openvpp.jvpp.core.dto.GreAddDelTunnel;
import org.openvpp.jvpp.core.dto.GreAddDelTunnelReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
+public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implements JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(GreCustomizer.class);
private final NamingContext interfaceContext;
@@ -51,6 +51,17 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
this.interfaceContext = interfaceContext;
}
+ private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
+ final int outerFibId, final byte isIpv6) {
+ final GreAddDelTunnel greAddDelTunnel = new GreAddDelTunnel();
+ greAddDelTunnel.isAdd = isAdd;
+ greAddDelTunnel.srcAddress = srcAddr;
+ greAddDelTunnel.dstAddress = dstAddr;
+ greAddDelTunnel.outerFibId = outerFibId;
+ greAddDelTunnel.isIpv6 = isIpv6;
+ return greAddDelTunnel;
+ }
+
@Override
protected Class<? extends InterfaceType> getExpectedInterfaceType() {
return GreTunnel.class;
@@ -58,7 +69,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<Gre> id, @Nonnull final Gre dataAfter,
- @Nonnull final WriteContext writeContext)
+ @Nonnull final WriteContext writeContext)
throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
@@ -91,8 +102,10 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
}
private void createGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre,
- final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
- final byte isIpv6 = (byte) (isIpv6(gre) ? 1 : 0);
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
+ final byte isIpv6 = (byte) (isIpv6(gre)
+ ? 1
+ : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst()));
@@ -104,9 +117,9 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
dstAddress.getAddress(), outerFibId, isIpv6));
final GreAddDelTunnelReply reply =
- TranslateUtils.getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Gre tunnel set successfully for: {}, gre: {}", swIfName, gre);
- if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
+ if (interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
// VPP keeps gre tunnels present even after they are delete(reserving ID for next tunnel)
// This may cause inconsistencies in mapping context when configuring tunnels like this:
// 1. Add tunnel 2. Delete tunnel 3. Read interfaces (reserved mapping e.g. gre_tunnel0 -> 6
@@ -116,7 +129,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
// new name for that ID
final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
LOG.debug("Removing updated mapping of a gre tunnel, id: {}, former name: {}, new name: {}",
- reply.swIfIndex, formerName, swIfName);
+ reply.swIfIndex, formerName, swIfName);
interfaceContext.removeName(formerName, writeContext.getMappingContext());
}
// Add new interface to our interface context
@@ -126,22 +139,26 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
private boolean isIpv6(final Gre gre) {
if (gre.getSrc().getIpv4Address() == null) {
checkArgument(gre.getDst().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", gre.getSrc(),
- gre.getDst());
+ gre.getDst());
return true;
} else {
checkArgument(gre.getDst().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", gre.getSrc(),
- gre.getDst());
+ gre.getDst());
return false;
}
}
private String getAddressString(final IpAddress addr) {
- return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
+ return addr.getIpv4Address() == null
+ ? addr.getIpv6Address().getValue()
+ : addr.getIpv4Address().getValue();
}
private void deleteGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre,
- final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
- final byte isIpv6 = (byte) (isIpv6(gre) ? 1 : 0);
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
+ final byte isIpv6 = (byte) (isIpv6(gre)
+ ? 1
+ : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst()));
@@ -152,20 +169,9 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> {
getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(),
dstAddress.getAddress(), outerFibId, isIpv6));
- TranslateUtils.getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Gre tunnel deleted successfully for: {}, gre: {}", swIfName, gre);
// Remove interface from our interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
-
- private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
- final int outerFibId, final byte isIpv6) {
- final GreAddDelTunnel greAddDelTunnel = new GreAddDelTunnel();
- greAddDelTunnel.isAdd = isAdd;
- greAddDelTunnel.srcAddress = srcAddr;
- greAddDelTunnel.dstAddress = dstAddr;
- greAddDelTunnel.outerFibId = outerFibId;
- greAddDelTunnel.isIpv6 = isIpv6;
- return greAddDelTunnel;
- }
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java
index 64d262f23..e6b93dfee 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java
@@ -19,11 +19,11 @@ package io.fd.honeycomb.translate.v3po.interfaces;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection;
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
/**
* Utility class providing Interconnection CUD support.
*/
-final class InterconnectionWriteUtils {
+final class InterconnectionWriteUtils implements JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(InterconnectionWriteUtils.class);
@@ -61,7 +61,7 @@ final class InterconnectionWriteUtils {
void setInterconnection(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
final String ifcName, final Interconnection ic, final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
if (ic == null) { // TODO in case of update we should delete interconnection
LOG.trace("Interconnection is not set. Skipping");
@@ -77,14 +77,14 @@ final class InterconnectionWriteUtils {
}
} catch (VppBaseCallException e) {
LOG.warn("Failed to update bridge/xconnect based interconnection flags for: {}, interconnection: {}",
- ifcName, ic);
+ ifcName, ic);
throw new WriteFailedException(id, "Unable to handle Interconnection of type " + ic.getClass(), e);
}
}
void deleteInterconnection(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
final String ifcName, final Interconnection ic, final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
if (ic == null) { // TODO in case of update we should delete interconnection
LOG.trace("Interconnection is not set. Skipping");
@@ -98,7 +98,7 @@ final class InterconnectionWriteUtils {
}
} catch (VppBaseCallException e) {
LOG.warn("Failed to delete bridge/xconnect based interconnection flags for: {}, interconnection: {}",
- ifcName, ic);
+ ifcName, ic);
throw new WriteFailedException(id, "Unable to delete Interconnection of type " + ic.getClass(), e);
}
}
@@ -106,27 +106,27 @@ final class InterconnectionWriteUtils {
private void setBridgeBasedL2(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
final String ifcName, final BridgeBased bb,
final WriteContext writeContext, final byte enabled)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Setting bridge based interconnection(bridge-domain={}) for interface: {}", bb.getBridgeDomain(),
- ifcName);
+ ifcName);
String bdName = bb.getBridgeDomain();
int bdId = bridgeDomainContext.getIndex(bdName, writeContext.getMappingContext());
checkArgument(bdId > 0, "Unable to set Interconnection for Interface: %s, bridge domain: %s does not exist",
- ifcName, bdName);
+ ifcName, bdName);
byte bvi = bb.isBridgedVirtualInterface()
- ? (byte) 1
- : (byte) 0;
+ ? (byte) 1
+ : (byte) 0;
byte shg = 0;
if (bb.getSplitHorizonGroup() != null) {
shg = bb.getSplitHorizonGroup().byteValue();
}
final CompletionStage<SwInterfaceSetL2BridgeReply> swInterfaceSetL2BridgeReplyCompletionStage = futureJVppCore
- .swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bvi, enabled));
- TranslateUtils.getReplyForWrite(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture(), id);
+ .swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bvi, enabled));
+ getReplyForWrite(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Bridge based interconnection updated successfully for: {}, interconnection: {}", ifcName, bb);
}
@@ -145,19 +145,19 @@ final class InterconnectionWriteUtils {
private void setXconnectBasedL2(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
final String ifcName, final XconnectBased ic,
final WriteContext writeContext, final byte enabled)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
String outSwIfName = ic.getXconnectOutgoingInterface();
LOG.debug("Setting xconnect based interconnection(outgoing ifc={}) for interface: {}", outSwIfName, ifcName);
int outSwIfIndex = interfaceContext.getIndex(outSwIfName, writeContext.getMappingContext());
checkArgument(outSwIfIndex > 0,
- "Unable to set Interconnection for Interface: %s, outgoing interface: %s does not exist",
- ifcName, outSwIfIndex);
+ "Unable to set Interconnection for Interface: %s, outgoing interface: %s does not exist",
+ ifcName, outSwIfIndex);
final CompletionStage<SwInterfaceSetL2XconnectReply> swInterfaceSetL2XconnectReplyCompletionStage =
- futureJVppCore
- .swInterfaceSetL2Xconnect(getL2XConnectRequest(swIfIndex, outSwIfIndex, enabled));
- TranslateUtils.getReplyForWrite(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture(), id);
+ futureJVppCore
+ .swInterfaceSetL2Xconnect(getL2XConnectRequest(swIfIndex, outSwIfIndex, enabled));
+ getReplyForWrite(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Xconnect based interconnection updated successfully for: {}, interconnection: {}", ifcName, ic);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java
index be0c4af09..91861015c 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java
@@ -18,11 +18,11 @@ package io.fd.honeycomb.translate.v3po.interfaces;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -38,7 +38,8 @@ import org.slf4j.LoggerFactory;
/**
* Ietf interface write customizer that only caches interface objects for child writers
*/
-public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Interface, InterfaceKey> {
+public class InterfaceCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Interface, InterfaceKey>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceCustomizer.class);
private final NamingContext interfaceContext;
@@ -52,7 +53,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Interface> id,
@Nonnull final Interface dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
setInterface(id, dataAfter, writeContext);
@@ -67,7 +68,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
@Nonnull final Interface dataBefore,
@Nonnull final Interface dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
updateInterface(id, dataBefore, dataAfter, writeContext);
@@ -86,41 +87,45 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
private void setInterface(final InstanceIdentifier<Interface> id, final Interface swIf,
final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Setting interface: {} to: {}", id, swIf);
setInterfaceAttributes(id, swIf, swIf.getName(), writeContext);
}
private void setInterfaceAttributes(final InstanceIdentifier<Interface> id, final Interface swIf,
final String swIfName, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
setInterfaceFlags(id, swIfName, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()),
- swIf.isEnabled() ? (byte) 1 : (byte) 0);
+ swIf.isEnabled()
+ ? (byte) 1
+ : (byte) 0);
}
private void updateInterface(final InstanceIdentifier<Interface> id,
final Interface dataBefore,
final Interface dataAfter, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Updating interface:{} to: {}", id, dataAfter);
setInterfaceAttributes(id, dataAfter, dataAfter.getName(), writeContext);
}
private void setInterfaceFlags(final InstanceIdentifier<Interface> id, final String swIfName, final int swIfIndex,
final byte enabled)
- throws VppBaseCallException, WriteTimeoutException {
- final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags(
- getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */));
+ throws VppBaseCallException, WriteTimeoutException {
+ final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture =
+ getFutureJVpp().swInterfaceSetFlags(
+ getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */));
LOG.debug("Updating interface flags for: {}, index: {}, enabled: {}", swIfName, swIfIndex, enabled);
- TranslateUtils.getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id);
+ getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id);
LOG.debug("Interface flags updated successfully for: {}, index: {}, enabled: {}",
swIfName, swIfIndex, enabled);
}
- private SwInterfaceSetFlags getSwInterfaceSetFlagsInput(final int swIfIndex, final byte enabled, final byte deleted) {
+ private SwInterfaceSetFlags getSwInterfaceSetFlagsInput(final int swIfIndex, final byte enabled,
+ final byte deleted) {
final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags();
swInterfaceSetFlags.swIfIndex = swIfIndex;
swInterfaceSetFlags.adminUpDown = enabled;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java
index 18100e218..002cc4c77 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java
@@ -19,8 +19,8 @@ package io.fd.honeycomb.translate.v3po.interfaces;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.net.InetAddress;
@@ -31,14 +31,14 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ProxyArp;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.openvpp.jvpp.core.dto.ProxyArpAddDel;
import org.openvpp.jvpp.core.dto.ProxyArpAddDelReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCustomizer<ProxyArp> {
+public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCustomizer<ProxyArp>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ProxyArpCustomizer.class);
private final NamingContext interfaceContext;
@@ -49,7 +49,8 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu
}
@Override
- public void writeCurrentAttributes(@Nonnull InstanceIdentifier<ProxyArp> id, @Nonnull ProxyArp dataAfter, @Nonnull WriteContext writeContext) throws WriteFailedException {
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<ProxyArp> id, @Nonnull ProxyArp dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
@@ -93,7 +94,7 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu
dstAddress.getAddress(), vrfId));
final ProxyArpAddDelReply reply =
- TranslateUtils.getReplyForWrite(proxyArpAddDelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(proxyArpAddDelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Proxy ARP setting applied, with reply context:", reply.context);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java
index ebaad456b..b17cfc820 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java
@@ -16,15 +16,14 @@
package io.fd.honeycomb.translate.v3po.interfaces;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
-
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils;
import io.fd.honeycomb.translate.v3po.util.TagRewriteOperation;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -49,7 +48,8 @@ import org.slf4j.LoggerFactory;
* Writer Customizer responsible for vlan tag rewrite.<br> Sends {@code l2_interface_vlan_tag_rewrite} message to
* VPP.<br> Equivalent of invoking {@code vppctl set interface l2 tag-rewrite} command.
*/
-public class RewriteCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Rewrite> {
+public class RewriteCustomizer extends FutureJVppCustomizer
+ implements WriterCustomizer<Rewrite>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(RewriteCustomizer.class);
private final NamingContext interfaceContext;
@@ -80,14 +80,14 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements WriterCus
private void setTagRewrite(final InstanceIdentifier<Rewrite> id, final String ifname, final Rewrite rewrite,
final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final int swIfIndex = interfaceContext.getIndex(ifname, writeContext.getMappingContext());
LOG.debug("Setting tag rewrite for interface {}(id=): {}", ifname, swIfIndex, rewrite);
final CompletionStage<L2InterfaceVlanTagRewriteReply> replyCompletionStage =
getFutureJVpp().l2InterfaceVlanTagRewrite(getTagRewriteRequest(swIfIndex, rewrite));
- TranslateUtils.getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
LOG.debug("Tag rewrite for interface {}(id=) set successfully: {}", ifname, swIfIndex, rewrite);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java
index 51bf31d07..44fd8807c 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java
@@ -16,13 +16,13 @@
package io.fd.honeycomb.translate.v3po.interfaces;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -35,7 +35,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Routing> {
+public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Routing>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(RoutingCustomizer.class);
private final NamingContext interfaceContext;
@@ -48,7 +48,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Routing> id,
@Nonnull final Routing dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
final String ifName = id.firstKeyOf(Interface.class).getName();
try {
@@ -63,7 +63,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Routing> id,
@Nonnull final Routing dataBefore, @Nonnull final Routing dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
final String ifName = id.firstKeyOf(Interface.class).getName();
try {
@@ -86,13 +86,14 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus
LOG.debug("Setting routing for interface: {}, {}. Routing: {}", name, swIfc, rt);
int vrfId = (rt != null)
- ? rt.getVrfId().intValue()
- : 0;
+ ? rt.getVrfId().intValue()
+ : 0;
if (vrfId != 0) {
final CompletionStage<SwInterfaceSetTableReply> swInterfaceSetTableReplyCompletionStage =
- getFutureJVpp().swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, (byte) 0, /* isIpv6 */ vrfId));
- TranslateUtils.getReplyForWrite(swInterfaceSetTableReplyCompletionStage.toCompletableFuture(), id);
+ getFutureJVpp()
+ .swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, (byte) 0, /* isIpv6 */ vrfId));
+ getReplyForWrite(swInterfaceSetTableReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Routing set successfully for interface: {}, {}, routing: {}", name, swIfc, rt);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java
index 10dd60841..f2c1cc418 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java
@@ -19,17 +19,16 @@ package io.fd.honeycomb.translate.v3po.interfaces;
import static com.google.common.base.Preconditions.checkState;
import static io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils.getNumberOfTags;
import static io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.List;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -60,12 +59,13 @@ import org.slf4j.LoggerFactory;
* Equivalent of invoking {@code vppclt create subif} command.
*/
public class SubInterfaceCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<SubInterface, SubInterfaceKey> {
+ implements ListWriterCustomizer<SubInterface, SubInterfaceKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceCustomizer.class);
private final NamingContext interfaceContext;
- public SubInterfaceCustomizer(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext interfaceContext) {
+ public SubInterfaceCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext interfaceContext) {
super(futureJVppCore);
this.interfaceContext = Preconditions.checkNotNull(interfaceContext, "interfaceContext should not be null");
}
@@ -73,7 +73,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final SubInterface dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
final String superIfName = id.firstKeyOf(Interface.class).getName();
try {
createSubInterface(id, superIfName, dataAfter, writeContext);
@@ -89,15 +89,15 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
WriteTimeoutException {
final int superIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext());
final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage =
- getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex));
+ getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex));
final CreateSubifReply reply =
- TranslateUtils.getReplyForWrite(createSubifReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(createSubifReplyCompletionStage.toCompletableFuture(), id);
setInterfaceState(id, reply.swIfIndex, booleanToByte(subInterface.isEnabled()));
interfaceContext.addName(reply.swIfIndex,
- getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())),
- writeContext.getMappingContext());
+ getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())),
+ writeContext.getMappingContext());
LOG.debug("Sub interface created successfully for: {}, subInterface: {}", superIfName, subInterface);
}
@@ -124,7 +124,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
// TODO HONEYCOMB-183 match should be mandatory
final MatchType matchType = subInterface.getMatch().getMatchType();
request.exactMatch =
- booleanToByte(matchType instanceof VlanTagged && ((VlanTagged) matchType).isMatchExactTags());
+ booleanToByte(matchType instanceof VlanTagged && ((VlanTagged) matchType).isMatchExactTags());
request.defaultSub = booleanToByte(matchType instanceof Default);
if (numberOfTags > 0) {
@@ -167,41 +167,41 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final SubInterface dataBefore, @Nonnull final SubInterface dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
final String subIfaceName = getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
- Math.toIntExact(dataAfter.getIdentifier()));
+ Math.toIntExact(dataAfter.getIdentifier()));
try {
setInterfaceState(id, interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()),
- booleanToByte(dataAfter.isEnabled()));
+ booleanToByte(dataAfter.isEnabled()));
} catch (VppBaseCallException e) {
LOG.warn("Failed to update interface state for: interface if={}, enabled: {}",
- subIfaceName, booleanToByte(dataAfter.isEnabled()));
+ subIfaceName, booleanToByte(dataAfter.isEnabled()));
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
private void setInterfaceState(final InstanceIdentifier<SubInterface> id, final int swIfIndex, final byte enabled)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags();
swInterfaceSetFlags.swIfIndex = swIfIndex;
swInterfaceSetFlags.adminUpDown = enabled;
final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture =
- getFutureJVpp().swInterfaceSetFlags(swInterfaceSetFlags);
+ getFutureJVpp().swInterfaceSetFlags(swInterfaceSetFlags);
LOG.debug("Updating interface state for interface if={}, enabled: {}", swIfIndex, enabled);
SwInterfaceSetFlagsReply reply =
- TranslateUtils.getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id);
+ getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id);
LOG.debug("Interface state updated successfully for interface index: {}, enabled: {}, ctxId: {}",
- swIfIndex, enabled, reply.context);
+ swIfIndex, enabled, reply.context);
}
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final SubInterface dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException.DeleteFailedException {
throw new UnsupportedOperationException("Sub interface delete is not supported");
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceL2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceL2Customizer.java
index cfb78499a..8bccb7a99 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceL2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceL2Customizer.java
@@ -16,11 +16,11 @@
package io.fd.honeycomb.translate.v3po.interfaces;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java
index ba3c99ca8..3dec19803 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java
@@ -17,10 +17,11 @@
package io.fd.honeycomb.translate.v3po.interfaces;
import io.fd.honeycomb.translate.v3po.util.AbstractInterfaceTypeCustomizer;
-import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.v3po.util.MacTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
+import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
@@ -40,7 +41,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
+public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implements MacTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(TapCustomizer.class);
private final NamingContext interfaceContext;
@@ -57,8 +58,8 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataAfter,
- @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
try {
createTap(id, ifcName, dataAfter, writeContext);
@@ -71,7 +72,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Override
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataBefore,
@Nonnull final Tap dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
final int index;
@@ -92,7 +93,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
final int index;
@@ -114,31 +115,33 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapConnectReply> tapConnectFuture =
- getFutureJVpp().tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance()));
+ getFutureJVpp()
+ .tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance()));
final TapConnectReply reply =
- TranslateUtils.getReplyForWrite(tapConnectFuture.toCompletableFuture(), id);
+ getReplyForWrite(tapConnectFuture.toCompletableFuture(), id);
LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap);
// Add new interface to our interface context
interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
private void modifyTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, final Tap tap)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Modifying tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapModifyReply> vxlanAddDelTunnelReplyCompletionStage =
- getFutureJVpp().tapModify(getTapModifyRequest(tap.getTapName(), index, tap.getMac(), tap.getDeviceInstance()));
- TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getFutureJVpp()
+ .tapModify(getTapModifyRequest(tap.getTapName(), index, tap.getMac(), tap.getDeviceInstance()));
+ getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tap);
}
private void deleteTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index,
final Tap dataBefore,
final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore);
final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage =
- getFutureJVpp().tapDelete(getTapDeleteRequest(index));
- TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getFutureJVpp().tapDelete(getTapDeleteRequest(index));
+ getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore);
// Remove deleted interface from interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
@@ -148,15 +151,15 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
final TapConnect tapConnect = new TapConnect();
tapConnect.tapName = tapName.getBytes();
- if(mac == null) {
+ if (mac == null) {
tapConnect.useRandomMac = 1;
tapConnect.macAddress = new byte[6];
} else {
tapConnect.useRandomMac = 0;
- tapConnect.macAddress = TranslateUtils.parseMac(mac.getValue());
+ tapConnect.macAddress = parseMac(mac.getValue());
}
- if(deviceInstance == null) {
+ if (deviceInstance == null) {
tapConnect.renumber = 0;
} else {
tapConnect.renumber = 1;
@@ -166,20 +169,21 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
return tapConnect;
}
- private TapModify getTapModifyRequest(final String tapName, final int swIndex, final PhysAddress mac, final Long deviceInstance) {
+ private TapModify getTapModifyRequest(final String tapName, final int swIndex, final PhysAddress mac,
+ final Long deviceInstance) {
final TapModify tapConnect = new TapModify();
tapConnect.tapName = tapName.getBytes();
tapConnect.swIfIndex = swIndex;
- if(mac == null) {
+ if (mac == null) {
tapConnect.useRandomMac = 1;
tapConnect.macAddress = new byte[6];
} else {
tapConnect.useRandomMac = 0;
- tapConnect.macAddress = TranslateUtils.parseMac(mac.getValue());
+ tapConnect.macAddress = parseMac(mac.getValue());
}
- if(deviceInstance == null) {
+ if (deviceInstance == null) {
tapConnect.renumber = 0;
} else {
tapConnect.renumber = 1;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java
index d4e734da1..b66afb2b5 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java
@@ -18,10 +18,11 @@ package io.fd.honeycomb.translate.v3po.interfaces;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.v3po.util.AbstractInterfaceTypeCustomizer;
-import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
+import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
@@ -44,7 +45,8 @@ import org.slf4j.LoggerFactory;
/**
* Writer Customizer responsible for passing vhost user interface CRD operations to VPP
*/
-public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUser> {
+public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUser>
+ implements ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VhostUserCustomizer.class);
private final NamingContext interfaceContext;
@@ -61,7 +63,7 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<VhostUser> id,
- @Nonnull final VhostUser dataAfter, @Nonnull final WriteContext writeContext)
+ @Nonnull final VhostUser dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
@@ -74,13 +76,13 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
private void createVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName,
final VhostUser vhostUser, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Creating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<CreateVhostUserIfReply> createVhostUserIfReplyCompletionStage =
getFutureJVpp().createVhostUserIf(getCreateVhostUserIfRequest(vhostUser));
final CreateVhostUserIfReply reply =
- TranslateUtils.getReplyForWrite(createVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(createVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vhost user interface created successfully for: {}, vhostUser: {}", swIfName, vhostUser);
// Add new interface to our interface context
interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
@@ -88,7 +90,7 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
private CreateVhostUserIf getCreateVhostUserIfRequest(final VhostUser vhostUser) {
CreateVhostUserIf request = new CreateVhostUserIf();
- request.isServer = TranslateUtils.booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole()));
+ request.isServer = booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole()));
request.sockFilename = vhostUser.getSocket().getBytes();
// TODO HONEYCOMB-177 expose device instance attribute just like for TAP
request.renumber = 0;
@@ -114,19 +116,20 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
private void modifyVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName,
final VhostUser vhostUser, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<ModifyVhostUserIfReply> modifyVhostUserIfReplyCompletionStage =
getFutureJVpp()
- .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser, interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
+ .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser,
+ interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
- TranslateUtils.getReplyForWrite(modifyVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(modifyVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUser);
}
private ModifyVhostUserIf getModifyVhostUserIfRequest(final VhostUser vhostUser, final int swIfIndex) {
ModifyVhostUserIf request = new ModifyVhostUserIf();
- request.isServer = TranslateUtils.booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole()));
+ request.isServer = booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole()));
request.sockFilename = vhostUser.getSocket().getBytes();
// TODO HONEYCOMB-177
request.renumber = 0;
@@ -150,12 +153,13 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
private void deleteVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName,
final VhostUser vhostUser, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage =
- getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
+ getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(
+ interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
- TranslateUtils.getReplyForWrite(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser);
// Remove interface from our interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java
index 1513f7b15..d96ef3e34 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java
@@ -21,8 +21,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.util.AbstractInterfaceTypeCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -42,7 +42,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
+public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> implements JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VxlanCustomizer.class);
@@ -64,7 +64,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataAfter,
- @Nonnull final WriteContext writeContext)
+ @Nonnull final WriteContext writeContext)
throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
@@ -98,7 +98,9 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
private void createVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan,
final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
- final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
+ final byte isIpv6 = (byte) (isIpv6(vxlan)
+ ? 1
+ : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -111,7 +113,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6));
final VxlanAddDelTunnelReply reply =
- TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vxlan tunnel set successfully for: {}, vxlan: {}", swIfName, vxlan);
if (interfaceNamingContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
// VPP keeps vxlan tunnels present even after they are delete(reserving ID for next tunnel)
@@ -123,7 +125,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
// new name for that ID
final String formerName = interfaceNamingContext.getName(reply.swIfIndex, writeContext.getMappingContext());
LOG.debug("Removing updated mapping of a vxlan tunnel, id: {}, former name: {}, new name: {}",
- reply.swIfIndex, formerName, swIfName);
+ reply.swIfIndex, formerName, swIfName);
interfaceNamingContext.removeName(formerName, writeContext.getMappingContext());
}
@@ -142,22 +144,26 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
private boolean isIpv6(final Vxlan vxlan) {
if (vxlan.getSrc().getIpv4Address() == null) {
checkArgument(vxlan.getDst().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", vxlan.getSrc(),
- vxlan.getDst());
+ vxlan.getDst());
return true;
} else {
checkArgument(vxlan.getDst().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", vxlan.getSrc(),
- vxlan.getDst());
+ vxlan.getDst());
return false;
}
}
private String getAddressString(final IpAddress addr) {
- return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
+ return addr.getIpv4Address() == null
+ ? addr.getIpv6Address().getValue()
+ : addr.getIpv4Address().getValue();
}
private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan,
final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
- final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
+ final byte isIpv6 = (byte) (isIpv6(vxlan)
+ ? 1
+ : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -169,7 +175,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(),
dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6));
- TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext());
@@ -182,8 +188,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
}
private static VxlanAddDelTunnel getVxlanTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
- final int encapVrfId,
- final int decapNextIndex, final int vni, final byte isIpv6) {
+ final int encapVrfId,
+ final int decapNextIndex, final int vni, final byte isIpv6) {
final VxlanAddDelTunnel vxlanAddDelTunnel = new VxlanAddDelTunnel();
vxlanAddDelTunnel.isAdd = isAdd;
vxlanAddDelTunnel.srcAddress = srcAddr;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java
index 699c33d21..aeba262db 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java
@@ -21,11 +21,11 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.util.AbstractInterfaceTypeCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.net.InetAddress;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
@@ -42,7 +42,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe> {
+public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe> implements JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VxlanGpeCustomizer.class);
private final NamingContext interfaceNamingContext;
@@ -62,8 +62,9 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
}
@Override
- protected final void writeInterface(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataAfter,
- @Nonnull final WriteContext writeContext)
+ protected final void writeInterface(@Nonnull final InstanceIdentifier<VxlanGpe> id,
+ @Nonnull final VxlanGpe dataAfter,
+ @Nonnull final WriteContext writeContext)
throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
@@ -75,7 +76,8 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
}
@Override
- public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataBefore,
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id,
+ @Nonnull final VxlanGpe dataBefore,
@Nonnull final VxlanGpe dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException.UpdateFailedException {
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter,
@@ -83,7 +85,8 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
}
@Override
- public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataBefore,
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id,
+ @Nonnull final VxlanGpe dataBefore,
@Nonnull final WriteContext writeContext)
throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
@@ -97,8 +100,10 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
private void createVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName,
final VxlanGpe vxlanGpe, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
- final byte isIpv6 = (byte) (isIpv6(vxlanGpe) ? 1 : 0);
+ throws VppBaseCallException, WriteTimeoutException {
+ final byte isIpv6 = (byte) (isIpv6(vxlanGpe)
+ ? 1
+ : 0);
final InetAddress Local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal()));
final InetAddress Remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote()));
@@ -110,15 +115,15 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
LOG.debug("Setting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe);
final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage =
getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 1 /* is add */, Local.getAddress(),
- Remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
+ Remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
final VxlanGpeAddDelTunnelReply reply =
- TranslateUtils.getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("VxlanGpe tunnel set successfully for: {}, VxlanGpe: {}", swIfName, vxlanGpe);
if (interfaceNamingContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
final String formerName = interfaceNamingContext.getName(reply.swIfIndex, writeContext.getMappingContext());
LOG.debug("Removing updated mapping of a vxlan-gpe tunnel, id: {}, former name: {}, new name: {}",
- reply.swIfIndex, formerName, swIfName);
+ reply.swIfIndex, formerName, swIfName);
interfaceNamingContext.removeName(formerName, writeContext.getMappingContext());
}
@@ -135,24 +140,30 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
private boolean isIpv6(final VxlanGpe vxlanGpe) {
if (vxlanGpe.getLocal().getIpv4Address() == null) {
- checkArgument(vxlanGpe.getRemote().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", vxlanGpe.getLocal(),
- vxlanGpe.getRemote());
+ checkArgument(vxlanGpe.getRemote().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s",
+ vxlanGpe.getLocal(),
+ vxlanGpe.getRemote());
return true;
} else {
- checkArgument(vxlanGpe.getRemote().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", vxlanGpe.getLocal(),
- vxlanGpe.getRemote());
+ checkArgument(vxlanGpe.getRemote().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s",
+ vxlanGpe.getLocal(),
+ vxlanGpe.getRemote());
return false;
}
}
private String getAddressString(final IpAddress addr) {
- return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
+ return addr.getIpv4Address() == null
+ ? addr.getIpv6Address().getValue()
+ : addr.getIpv4Address().getValue();
}
private void deleteVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName,
final VxlanGpe vxlanGpe, final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
- final byte isIpv6 = (byte) (isIpv6(vxlanGpe) ? 1 : 0);
+ throws VppBaseCallException, WriteTimeoutException {
+ final byte isIpv6 = (byte) (isIpv6(vxlanGpe)
+ ? 1
+ : 0);
final InetAddress local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal()));
final InetAddress remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote()));
@@ -163,10 +174,11 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
LOG.debug("Deleting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe);
final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage =
- getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(),
- remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
+ getFutureJVpp()
+ .vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(),
+ remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
- TranslateUtils.getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext());
// Mark this interface as disabled to not include it in operational reads
@@ -177,9 +189,11 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext());
}
- private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final byte[] local, final byte[] remote,
- final int vni, final byte protocol, final int encapVrfId, final int decapVrfId,
- final byte isIpv6) {
+ private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final byte[] local,
+ final byte[] remote,
+ final int vni, final byte protocol,
+ final int encapVrfId, final int decapVrfId,
+ final byte isIpv6) {
final VxlanGpeAddDelTunnel VxlanGpeAddDelTunnel = new VxlanGpeAddDelTunnel();
VxlanGpeAddDelTunnel.isAdd = isAdd;
VxlanGpeAddDelTunnel.local = local;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AbstractAceWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AbstractAceWriter.java
index dc22a8740..eba7a1f85 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AbstractAceWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AbstractAceWriter.java
@@ -21,7 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import java.util.List;
import java.util.concurrent.CompletionStage;
@@ -48,7 +48,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
*
* @param <T> type of access control list entry
*/
-abstract class AbstractAceWriter<T extends AceType> implements AceWriter {
+abstract class AbstractAceWriter<T extends AceType> implements AceWriter, JvppReplyConsumer {
// TODO: HONEYCOMB-181 minimise memory used by classify tables (we create a lot of them to make ietf-acl model
// mapping more convenient):
@@ -60,7 +60,7 @@ abstract class AbstractAceWriter<T extends AceType> implements AceWriter {
static final int VLAN_TAG_LEN = 4;
private static final Collector<PacketHandling, ?, PacketHandling> SINGLE_ITEM_COLLECTOR =
- RWUtils.singleItemCollector();
+ RWUtils.singleItemCollector();
private final FutureJVppCore futureJVppCore;
@@ -107,9 +107,9 @@ abstract class AbstractAceWriter<T extends AceType> implements AceWriter {
@Override
public final void write(@Nonnull final InstanceIdentifier<?> id, @Nonnull final List<Ace> aces,
@Nonnull final InputAclSetInterface request, @Nonnegative final int vlanTags)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final PacketHandling action = aces.stream().map(ace -> ace.getActions().getPacketHandling()).distinct()
- .collect(SINGLE_ITEM_COLLECTOR);
+ .collect(SINGLE_ITEM_COLLECTOR);
checkArgument(vlanTags >= 0 && vlanTags <= 2, "Number of vlan tags %s is not in [0,2] range");
@@ -118,29 +118,29 @@ abstract class AbstractAceWriter<T extends AceType> implements AceWriter {
// Create table + session per entry
final ClassifyAddDelTable ctRequest =
- createClassifyTable(action, (T) ace.getMatches().getAceType(), nextTableIndex, vlanTags);
+ createClassifyTable(action, (T) ace.getMatches().getAceType(), nextTableIndex, vlanTags);
nextTableIndex = createClassifyTable(id, ctRequest);
createClassifySession(id,
- createClassifySession(action, (T) ace.getMatches().getAceType(), nextTableIndex, vlanTags));
+ createClassifySession(action, (T) ace.getMatches().getAceType(), nextTableIndex, vlanTags));
}
setClassifyTable(request, nextTableIndex);
}
private int createClassifyTable(@Nonnull final InstanceIdentifier<?> id,
@Nonnull final ClassifyAddDelTable request)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final CompletionStage<ClassifyAddDelTableReply> cs = futureJVppCore.classifyAddDelTable(request);
- final ClassifyAddDelTableReply reply = TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id);
+ final ClassifyAddDelTableReply reply = getReplyForWrite(cs.toCompletableFuture(), id);
return reply.newTableIndex;
}
private void createClassifySession(@Nonnull final InstanceIdentifier<?> id,
@Nonnull final ClassifyAddDelSession request)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final CompletionStage<ClassifyAddDelSessionReply> cs = futureJVppCore.classifyAddDelSession(request);
- TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id);
+ getReplyForWrite(cs.toCompletableFuture(), id);
}
protected ClassifyAddDelTable createClassifyTable(@Nonnull final PacketHandling action, final int nextTableIndex) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriter.java
index f6bb9c879..395058399 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceEthWriter.java
@@ -17,7 +17,7 @@
package io.fd.honeycomb.translate.v3po.interfaces.acl;
import com.google.common.annotations.VisibleForTesting;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.MacTranslator;
import java.util.List;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.PacketHandling;
@@ -29,7 +29,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class AceEthWriter extends AbstractAceWriter<AceEth> {
+final class AceEthWriter extends AbstractAceWriter<AceEth> implements MacTranslator {
@VisibleForTesting
static final int MATCH_N_VECTORS = 1;
@@ -54,10 +54,10 @@ final class AceEthWriter extends AbstractAceWriter<AceEth> {
if (aceEth.getDestinationMacAddressMask() != null) {
aceIsEmpty = false;
final String macAddress = aceEth.getDestinationMacAddressMask().getValue();
- final List<String> parts = TranslateUtils.COLON_SPLITTER.splitToList(macAddress);
+ final List<String> parts = COLON_SPLITTER.splitToList(macAddress);
int i = 0;
for (String part : parts) {
- request.mask[i++] = TranslateUtils.parseHexByte(part);
+ request.mask[i++] = parseHexByte(part);
}
} else if (aceEth.getDestinationMacAddress() != null) {
aceIsEmpty = false;
@@ -71,10 +71,10 @@ final class AceEthWriter extends AbstractAceWriter<AceEth> {
if (aceEth.getSourceMacAddressMask() != null) {
aceIsEmpty = false;
final String macAddress = aceEth.getSourceMacAddressMask().getValue();
- final List<String> parts = TranslateUtils.COLON_SPLITTER.splitToList(macAddress);
+ final List<String> parts = COLON_SPLITTER.splitToList(macAddress);
int i = 6;
for (String part : parts) {
- request.mask[i++] = TranslateUtils.parseHexByte(part);
+ request.mask[i++] = parseHexByte(part);
}
} else if (aceEth.getSourceMacAddress() != null) {
aceIsEmpty = false;
@@ -85,7 +85,7 @@ final class AceEthWriter extends AbstractAceWriter<AceEth> {
if (aceIsEmpty) {
throw new IllegalArgumentException(
- String.format("Ace %s does not define packet field match values", aceEth.toString()));
+ String.format("Ace %s does not define packet field match values", aceEth.toString()));
}
request.skipNVectors = 0;
@@ -108,26 +108,27 @@ final class AceEthWriter extends AbstractAceWriter<AceEth> {
if (aceEth.getDestinationMacAddress() != null) {
noMatch = false;
final String macAddress = aceEth.getDestinationMacAddress().getValue();
- final List<String> parts = TranslateUtils.COLON_SPLITTER.splitToList(macAddress);
+ final List<String> parts = COLON_SPLITTER.splitToList(macAddress);
int i = 0;
for (String part : parts) {
- request.match[i++] = TranslateUtils.parseHexByte(part);
+ request.match[i++] = parseHexByte(part);
}
}
if (aceEth.getSourceMacAddress() != null) {
noMatch = false;
final String macAddress = aceEth.getSourceMacAddress().getValue();
- final List<String> parts = TranslateUtils.COLON_SPLITTER.splitToList(macAddress);
+ final List<String> parts = COLON_SPLITTER.splitToList(macAddress);
int i = 6;
for (String part : parts) {
- request.match[i++] = TranslateUtils.parseHexByte(part);
+ request.match[i++] = parseHexByte(part);
}
}
if (noMatch) {
throw new IllegalArgumentException(
- String.format("Ace %s does not define neither source nor destination MAC address", aceEth.toString()));
+ String.format("Ace %s does not define neither source nor destination MAC address",
+ aceEth.toString()));
}
LOG.debug("ACE action={}, rule={} translated to session={}.", action, aceEth, request);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4Writer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4Writer.java
index cb232ed3e..b19c754e5 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4Writer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/AceIp4Writer.java
@@ -17,10 +17,10 @@
package io.fd.honeycomb.translate.v3po.interfaces.acl;
import static com.google.common.base.Preconditions.checkArgument;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.ipv4AddressNoZoneToArray;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.PacketHandling;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
@@ -33,7 +33,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class AceIp4Writer extends AbstractAceWriter<AceIp> {
+final class AceIp4Writer extends AbstractAceWriter<AceIp> implements Ipv4Translator {
@VisibleForTesting
static final int MATCH_N_VECTORS = 3; // number of 16B vectors
@@ -63,7 +63,8 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> {
return toByteMask(prefixLength);
}
- private static byte[] toMatchValue(final Ipv4Prefix ipv4Prefix) {
+ // static removed, cant use default from static content
+ private byte[] toMatchValue(final Ipv4Prefix ipv4Prefix) {
final String[] split = ipv4Prefix.getValue().split("/");
final byte[] addressBytes = ipv4AddressNoZoneToArray(split[0]);
final byte[] mask = toByteMask(Byte.valueOf(split[1]));
@@ -111,19 +112,19 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> {
if (ipVersion.getSourceIpv4Network() != null) {
aceIsEmpty = false;
System.arraycopy(toByteMask(ipVersion.getSourceIpv4Network()), 0, request.mask, baseOffset + SRC_IP_OFFSET,
- IP4_LEN);
+ IP4_LEN);
}
if (ipVersion.getDestinationIpv4Network() != null) {
aceIsEmpty = false;
System
- .arraycopy(toByteMask(ipVersion.getDestinationIpv4Network()), 0, request.mask,
- baseOffset + DST_IP_OFFSET, IP4_LEN);
+ .arraycopy(toByteMask(ipVersion.getDestinationIpv4Network()), 0, request.mask,
+ baseOffset + DST_IP_OFFSET, IP4_LEN);
}
if (aceIsEmpty) {
throw new IllegalArgumentException(
- String.format("Ace %s does not define packet field match values", aceIp.toString()));
+ String.format("Ace %s does not define packet field match values", aceIp.toString()));
}
LOG.debug("ACE action={}, rule={} translated to table={}.", action, aceIp, request);
@@ -147,7 +148,7 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> {
if (aceIp.getProtocol() != null) {
request.match[baseOffset + IP_VERSION_OFFSET] =
- (byte) (IP_VERSION_MASK & (aceIp.getProtocol().intValue() << 4));
+ (byte) (IP_VERSION_MASK & (aceIp.getProtocol().intValue() << 4));
}
if (aceIp.getDscp() != null) {
@@ -166,20 +167,21 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> {
if (ipVersion.getSourceIpv4Network() != null) {
noMatch = false;
System
- .arraycopy(toMatchValue(ipVersion.getSourceIpv4Network()), 0, request.match, baseOffset + SRC_IP_OFFSET,
- IP4_LEN);
+ .arraycopy(toMatchValue(ipVersion.getSourceIpv4Network()), 0, request.match,
+ baseOffset + SRC_IP_OFFSET,
+ IP4_LEN);
}
if (ipVersion.getDestinationIpv4Network() != null) {
noMatch = false;
System.arraycopy(toMatchValue(ipVersion.getDestinationIpv4Network()), 0, request.match,
- baseOffset + DST_IP_OFFSET,
- IP4_LEN);
+ baseOffset + DST_IP_OFFSET,
+ IP4_LEN);
}
if (noMatch) {
throw new IllegalArgumentException(
- String.format("Ace %s does not define packet field match values", aceIp.toString()));
+ String.format("Ace %s does not define packet field match values", aceIp.toString()));
}
LOG.debug("ACE action={}, rule={} translated to session={}.", action, aceIp, request);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/IetfAClWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/IetfAClWriter.java
index 3f75d6729..f337cebd0 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/IetfAClWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/IetfAClWriter.java
@@ -20,7 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -54,7 +54,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class IetfAClWriter {
+public final class IetfAClWriter implements JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(IetfAClWriter.class);
private final FutureJVppCore jvpp;
@@ -75,12 +75,12 @@ public final class IetfAClWriter {
// ietf-acl updates are handled first, so we use writeContext.readAfter
final Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>
- aclOptional = writeContext.readAfter(AclWriter.ACL_ID.child(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl.class,
- new AclKey(aclName, aclType)));
+ aclOptional = writeContext.readAfter(AclWriter.ACL_ID.child(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl.class,
+ new AclKey(aclName, aclType)));
checkArgument(aclOptional.isPresent(), "Acl lists not configured");
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl
- acl = aclOptional.get();
+ acl = aclOptional.get();
final AccessListEntries accessListEntries = acl.getAccessListEntries();
checkArgument(accessListEntries != null, "access list entries not configured");
@@ -89,13 +89,13 @@ public final class IetfAClWriter {
}
void deleteAcl(@Nonnull final InstanceIdentifier<?> id, final int swIfIndex)
- throws WriteTimeoutException, WriteFailedException.DeleteFailedException {
+ throws WriteTimeoutException, WriteFailedException.DeleteFailedException {
final ClassifyTableByInterface request = new ClassifyTableByInterface();
request.swIfIndex = swIfIndex;
try {
final CompletionStage<ClassifyTableByInterfaceReply> cs = jvpp.classifyTableByInterface(request);
- final ClassifyTableByInterfaceReply reply = TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id);
+ final ClassifyTableByInterfaceReply reply = getReplyForWrite(cs.toCompletableFuture(), id);
// We unassign and remove all ACL-related classify tables for given interface (we assume we are the only
// classify table manager)
@@ -112,7 +112,7 @@ public final class IetfAClWriter {
private void unassignClassifyTables(@Nonnull final InstanceIdentifier<?> id,
final ClassifyTableByInterfaceReply currentState)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final InputAclSetInterface request = new InputAclSetInterface();
request.isAdd = 0;
request.swIfIndex = currentState.swIfIndex;
@@ -120,12 +120,12 @@ public final class IetfAClWriter {
request.ip4TableIndex = currentState.ip4TableId;
request.ip6TableIndex = currentState.ip6TableId;
final CompletionStage<InputAclSetInterfaceReply> inputAclSetInterfaceReplyCompletionStage =
- jvpp.inputAclSetInterface(request);
- TranslateUtils.getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id);
+ jvpp.inputAclSetInterface(request);
+ getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id);
}
private void removeClassifyTable(@Nonnull final InstanceIdentifier<?> id, final int tableIndex)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
if (tableIndex == -1) {
return; // classify table id is absent
@@ -133,23 +133,23 @@ public final class IetfAClWriter {
final ClassifyAddDelTable request = new ClassifyAddDelTable();
request.tableIndex = tableIndex;
final CompletionStage<ClassifyAddDelTableReply> cs = jvpp.classifyAddDelTable(request);
- TranslateUtils.getReplyForWrite(cs.toCompletableFuture(), id);
+ getReplyForWrite(cs.toCompletableFuture(), id);
}
void write(@Nonnull final InstanceIdentifier<?> id, final int swIfIndex, @Nonnull final List<Acl> acls,
@Nonnull final WriteContext writeContext)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
write(id, swIfIndex, acls, writeContext, 0);
}
void write(@Nonnull final InstanceIdentifier<?> id, final int swIfIndex, @Nonnull final List<Acl> acls,
@Nonnull final WriteContext writeContext, @Nonnegative final int numberOfTags)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
// filter ACE entries and group by AceType
final Map<AclType, List<Ace>> acesByType = acls.stream()
- .flatMap(acl -> aclToAceStream(acl, writeContext))
- .collect(Collectors.groupingBy(AclType::fromAce));
+ .flatMap(acl -> aclToAceStream(acl, writeContext))
+ .collect(Collectors.groupingBy(AclType::fromAce));
final InputAclSetInterface request = new InputAclSetInterface();
request.isAdd = 1;
@@ -173,9 +173,8 @@ public final class IetfAClWriter {
}
final CompletionStage<InputAclSetInterfaceReply> inputAclSetInterfaceReplyCompletionStage =
- jvpp.inputAclSetInterface(request);
- TranslateUtils.getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id);
-
+ jvpp.inputAclSetInterface(request);
+ getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id);
}
private enum AclType {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java
index 574a42eb5..8ab5b6b62 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java
@@ -45,7 +45,8 @@ import org.slf4j.LoggerFactory;
/**
* Customizer for writing {@link Address}
*/
-public class Ipv4AddressCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Address, AddressKey> {
+public class Ipv4AddressCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Address, AddressKey>, Ipv4Writer {
private static final Logger LOG = LoggerFactory.getLogger(Ipv4AddressCustomizer.class);
private final NamingContext interfaceContext;
@@ -131,8 +132,8 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer implements ListW
final DottedQuad netmask = subnet.getNetmask();
checkNotNull(netmask, "netmask value should not be null");
- final byte subnetLength = Ipv4WriteUtils.getSubnetMaskLength(netmask.getValue());
- Ipv4WriteUtils.addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), subnetLength);
+ final byte subnetLength = getSubnetMaskLength(netmask.getValue());
+ addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), subnetLength);
} catch (VppBaseCallException e) {
LOG.warn("Failed to set Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}",
interfaceName, interfaceIndex, subnet, address);
@@ -148,7 +149,7 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer implements ListW
LOG.debug("Setting Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}",
interfaceName, interfaceIndex, subnet, address);
- Ipv4WriteUtils.addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(),
+ addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(),
subnet.getPrefixLength().byteValue());
LOG.debug("Subnet(prefix-length) set successfully for interface: {}(id={}). Subnet: {}, address: {}",
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java
index 72d8277fc..ab25970e7 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java
@@ -20,14 +20,16 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4;
@@ -45,7 +47,8 @@ import org.slf4j.LoggerFactory;
* Customizer for writing {@link Neighbor} for {@link Ipv4}.
*/
public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<Neighbor, NeighborKey> {
+ implements ListWriterCustomizer<Neighbor, NeighborKey>, ByteDataTranslator, AddressTranslator,
+ JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(Ipv4NeighbourCustomizer.class);
@@ -119,15 +122,15 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer
IpNeighborAddDel request = new IpNeighborAddDel();
- request.isAdd = TranslateUtils.booleanToByte(add);
+ request.isAdd = booleanToByte(add);
request.isIpv6 = 0;
request.isStatic = 1;
- request.dstAddress = TranslateUtils.ipv4AddressNoZoneToArray(data.getIp());
- request.macAddress = TranslateUtils.parseMac(data.getLinkLayerAddress().getValue());
+ request.dstAddress = ipv4AddressNoZoneToArray(data.getIp());
+ request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
request.swIfIndex = parentInterfaceIndex;
//TODO HONEYCOMB-182 if it is necessary for future use ,make adjustments to be able to set vrfid
//request.vrfId
- TranslateUtils.getReplyForWrite(getFutureJVpp().ipNeighborAddDel(request).toCompletableFuture(), id);
+ getReplyForWrite(getFutureJVpp().ipNeighborAddDel(request).toCompletableFuture(), id);
}
} \ No newline at end of file
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4WriteUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java
index 412030200..a950d45de 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4WriteUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java
@@ -19,7 +19,9 @@ package io.fd.honeycomb.translate.v3po.interfaces.ip;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnegative;
@@ -34,37 +36,33 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
/**
* Utility class providing Ipv4 CUD support.
*/
-// TODO HONEYCOMB-175 replace with interface with default methods or abstract class
-public final class Ipv4WriteUtils {
+public interface Ipv4Writer extends ByteDataTranslator, Ipv4Translator, JvppReplyConsumer {
- private static final int DOTTED_QUAD_MASK_LENGTH = 4;
- private static final int IPV4_ADDRESS_PART_BITS_COUNT = 8;
- private static final int NETMASK_PART_LIMIT = 256; // 2 power to 8
+ int DOTTED_QUAD_MASK_LENGTH = 4;
+ int IPV4_ADDRESS_PART_BITS_COUNT = 8;
+ int NETMASK_PART_LIMIT = 256; // 2 power to 8
- private Ipv4WriteUtils() {
- throw new UnsupportedOperationException("This utility class cannot be instantiated");
- }
-
- static void addDelAddress(@Nonnull final FutureJVppCore futureJVppCore, final boolean add, final InstanceIdentifier<?> id,
- @Nonnegative final int ifaceId,
- @Nonnull final Ipv4AddressNoZone address, @Nonnegative final byte prefixLength)
- throws VppBaseCallException, WriteTimeoutException {
+ default void addDelAddress(@Nonnull final FutureJVppCore futureJVppCore, final boolean add,
+ final InstanceIdentifier<?> id,
+ @Nonnegative final int ifaceId,
+ @Nonnull final Ipv4AddressNoZone address, @Nonnegative final byte prefixLength)
+ throws VppBaseCallException, WriteTimeoutException {
checkArgument(prefixLength > 0, "Invalid prefix length");
checkNotNull(address, "address should not be null");
- final byte[] addressBytes = TranslateUtils.ipv4AddressNoZoneToArray(address);
+ final byte[] addressBytes = ipv4AddressNoZoneToArray(address);
final CompletionStage<SwInterfaceAddDelAddressReply> swInterfaceAddDelAddressReplyCompletionStage =
- futureJVppCore.swInterfaceAddDelAddress(
- getSwInterfaceAddDelAddressRequest(ifaceId, TranslateUtils.booleanToByte(add) /* isAdd */,
- (byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, prefixLength, addressBytes));
+ futureJVppCore.swInterfaceAddDelAddress(
+ getSwInterfaceAddDelAddressRequest(ifaceId, booleanToByte(add) /* isAdd */,
+ (byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, prefixLength, addressBytes));
- TranslateUtils.getReplyForWrite(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture(), id);
}
- static SwInterfaceAddDelAddress getSwInterfaceAddDelAddressRequest(final int swIfc, final byte isAdd,
- final byte ipv6, final byte deleteAll,
- final byte length, final byte[] addr) {
+ default SwInterfaceAddDelAddress getSwInterfaceAddDelAddressRequest(final int swIfc, final byte isAdd,
+ final byte ipv6, final byte deleteAll,
+ final byte length, final byte[] addr) {
final SwInterfaceAddDelAddress swInterfaceAddDelAddress = new SwInterfaceAddDelAddress();
swInterfaceAddDelAddress.swIfIndex = swIfc;
swInterfaceAddDelAddress.isAdd = isAdd;
@@ -83,11 +81,11 @@ public final class Ipv4WriteUtils {
* @param mask the subnet mask in dot notation 255.255.255.255
* @return the prefix length as number of bits
*/
- public static byte getSubnetMaskLength(final String mask) {
+ default byte getSubnetMaskLength(final String mask) {
String[] maskParts = mask.split("\\.");
checkArgument(maskParts.length == DOTTED_QUAD_MASK_LENGTH,
- "Network mask %s is not in Quad Dotted Decimal notation!", mask);
+ "Network mask %s is not in Quad Dotted Decimal notation!", mask);
long maskAsNumber = 0;
for (int i = 0; i < DOTTED_QUAD_MASK_LENGTH; i++) {
@@ -100,11 +98,11 @@ public final class Ipv4WriteUtils {
String bits = Long.toBinaryString(maskAsNumber);
checkArgument(bits.length() == IPV4_ADDRESS_PART_BITS_COUNT * DOTTED_QUAD_MASK_LENGTH,
- "Incorrect network mask %s", mask);
+ "Incorrect network mask %s", mask);
final int leadingOnes = bits.indexOf('0');
checkArgument(leadingOnes != -1, "Broadcast address %s is not allowed!", mask);
checkArgument(bits.substring(leadingOnes).indexOf('1') == -1,
- "Non-contiguous network mask %s is not allowed!", mask);
+ "Non-contiguous network mask %s is not allowed!", mask);
return (byte) leadingOnes;
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv6Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv6Customizer.java
index 192906854..c04d14604 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv6Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv6Customizer.java
@@ -16,9 +16,9 @@
package io.fd.honeycomb.translate.v3po.interfaces.ip;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
-import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java
index e0fa46335..3fbb493af 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java
@@ -21,9 +21,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
* Write customizer for sub-interface {@link Address}
*/
public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<Address, AddressKey> {
+ implements ListWriterCustomizer<Address, AddressKey>, Ipv4Writer {
private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceIpv4AddressCustomizer.class);
private final NamingContext interfaceContext;
@@ -58,7 +58,7 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
@Override
public void writeCurrentAttributes(InstanceIdentifier<Address> id, Address dataAfter, WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
setAddress(true, id, dataAfter, writeContext);
}
@@ -66,12 +66,12 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
public void updateCurrentAttributes(InstanceIdentifier<Address> id, Address dataBefore, Address dataAfter,
WriteContext writeContext) throws WriteFailedException {
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter,
- new UnsupportedOperationException("Operation not supported"));
+ new UnsupportedOperationException("Operation not supported"));
}
@Override
public void deleteCurrentAttributes(InstanceIdentifier<Address> id, Address dataBefore, WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
setAddress(false, id, dataBefore, writeContext);
}
@@ -98,26 +98,26 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class);
final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class);
return SubInterfaceUtils
- .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue());
+ .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue());
}
private void setNetmaskSubnet(final boolean add, @Nonnull final InstanceIdentifier<Address> id,
@Nonnull final String subInterfaceName, final int subInterfaceIndex,
@Nonnull final Address address, @Nonnull final Netmask subnet)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Setting Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}",
- subInterfaceName, subInterfaceIndex, subnet, address);
+ subInterfaceName, subInterfaceIndex, subnet, address);
final DottedQuad netmask = subnet.getNetmask();
checkNotNull(netmask, "netmask value should not be null");
- final byte subnetLength = Ipv4WriteUtils.getSubnetMaskLength(netmask.getValue());
- Ipv4WriteUtils.addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), subnetLength);
+ final byte subnetLength = getSubnetMaskLength(netmask.getValue());
+ addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), subnetLength);
} catch (VppBaseCallException e) {
LOG.warn("Failed to set Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}",
- subInterfaceName, subInterfaceIndex, subnet, address);
+ subInterfaceName, subInterfaceIndex, subnet, address);
throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e);
}
}
@@ -125,19 +125,19 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
private void setPrefixLengthSubnet(final boolean add, @Nonnull final InstanceIdentifier<Address> id,
@Nonnull final String subInterfaceName, final int subInterfaceIndex,
@Nonnull final Address address, @Nonnull final PrefixLength subnet)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Setting Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}",
- subInterfaceName, subInterfaceIndex, subnet, address);
+ subInterfaceName, subInterfaceIndex, subnet, address);
- Ipv4WriteUtils.addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(),
- subnet.getPrefixLength().byteValue());
+ addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(),
+ subnet.getPrefixLength().byteValue());
LOG.debug("Subnet(prefix-length) set successfully for sub-interface: {}(id={}). Subnet: {}, address: {}",
- subInterfaceName, subInterfaceIndex, subnet, address);
+ subInterfaceName, subInterfaceIndex, subnet, address);
} catch (VppBaseCallException e) {
LOG.warn("Failed to set Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}",
- subInterfaceName, subInterfaceIndex, subnet, address);
+ subInterfaceName, subInterfaceIndex, subnet, address);
throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidator.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidator.java
index 361113858..a314eaf14 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidator.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidator.java
@@ -21,7 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
-import io.fd.honeycomb.translate.v3po.interfaces.ip.Ipv4WriteUtils;
+import io.fd.honeycomb.translate.v3po.interfaces.ip.Ipv4Writer;
import java.util.List;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address;
@@ -32,7 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
/**
* Validator for detecting if there is an attempt to assign multiple addresses from same subnet
*/
-public class SubnetValidator {
+public class SubnetValidator implements Ipv4Writer {
/**
* Checks whether data provided for writing are not in collision with already existing data
@@ -60,7 +60,7 @@ public class SubnetValidator {
.forConflictingData(conflictingPrefix, prefixLengthRegister.get(conflictingPrefix));
}
- private static Function<Address, Short> toPrefixLength() {
+ private Function<Address, Short> toPrefixLength() {
return (final Address address) -> {
final Subnet subnet = address.getSubnet();
@@ -69,7 +69,7 @@ public class SubnetValidator {
}
if (address.getSubnet() instanceof Netmask) {
- return (short) Ipv4WriteUtils.getSubnetMaskLength(
+ return (short) getSubnetMaskLength(
checkNotNull(((Netmask) subnet).getNetmask(), "No netmask defined for %s", subnet)
.getValue());
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizer.java
index 639b36651..04141ab12 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizer.java
@@ -20,11 +20,11 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
* Customizer for reading ACLs enabled on given interface.
*/
public class AclCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Acl, AclBuilder>, AclReader {
+ implements ReaderCustomizer<Acl, AclBuilder>, AclReader, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(AclCustomizer.class);
private final NamingContext interfaceContext;
@@ -80,8 +80,8 @@ public class AclCustomizer extends FutureJVppCustomizer
final ClassifyTableByInterface request = new ClassifyTableByInterface();
request.swIfIndex = interfaceContext.getIndex(interfaceKey.getName(), ctx.getMappingContext());
try {
- final ClassifyTableByInterfaceReply reply = TranslateUtils
- .getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id);
+ final ClassifyTableByInterfaceReply reply =
+ getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id);
builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext()));
builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext()));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/EthernetCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/EthernetCustomizer.java
index abded50a3..fda8befe5 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/EthernetCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/EthernetCustomizer.java
@@ -17,9 +17,9 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
public class EthernetCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Ethernet, EthernetBuilder> {
+ implements ReaderCustomizer<Ethernet, EthernetBuilder>, InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(EthernetCustomizer.class);
private NamingContext interfaceContext;
@@ -66,10 +66,10 @@ public class EthernetCustomizer extends FutureJVppCustomizer
@Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
- interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
+ final SwInterfaceDetails iface = getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache(), LOG);
- if(iface.linkMtu != 0) {
+ if (iface.linkMtu != 0) {
builder.setMtu((int) iface.linkMtu);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java
index 8b0a42068..fe672640a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java
@@ -17,14 +17,12 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
@@ -35,8 +33,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.GreTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Gre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.GreBuilder;
import org.opendaylight.yangtools.concepts.Builder;
@@ -51,7 +49,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GreCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Gre, GreBuilder> {
+ implements ReaderCustomizer<Gre, GreBuilder>, InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(GreCustomizer.class);
private NamingContext interfaceContext;
@@ -80,7 +78,7 @@ public class GreCustomizer extends FutureJVppCustomizer
try {
final InterfaceKey key = id.firstKeyOf(Interface.class);
final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, GreTunnel.class)) {
+ if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, GreTunnel.class, LOG)) {
return;
}
@@ -90,31 +88,32 @@ public class GreCustomizer extends FutureJVppCustomizer
request.swIfIndex = index;
final CompletionStage<GreTunnelDetailsReplyDump> swInterfaceGreDetailsReplyDumpCompletionStage =
- getFutureJVpp().greTunnelDump(request);
+ getFutureJVpp().greTunnelDump(request);
final GreTunnelDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(swInterfaceGreDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(swInterfaceGreDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
// VPP keeps gre tunnel interfaces even after they were deleted (optimization)
// However there ar no longer any gre tunnel specific fields assigned to it and this call
// returns nothing
if (reply == null || reply.greTunnelDetails == null || reply.greTunnelDetails.isEmpty()) {
LOG.debug(
- "Gre tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
+ "Gre tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
return;
}
checkState(reply.greTunnelDetails.size() == 1,
- "Unexpected number of returned gre tunnels: {} for tunnel: {}", reply.greTunnelDetails, key.getName());
+ "Unexpected number of returned gre tunnels: {} for tunnel: {}", reply.greTunnelDetails,
+ key.getName());
LOG.trace("Gre tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
final GreTunnelDetails swInterfaceGreDetails = reply.greTunnelDetails.get(0);
if (swInterfaceGreDetails.isIpv6 == 1) {
final Ipv6Address dstIpv6 =
- new Ipv6Address(parseAddress(swInterfaceGreDetails.dstAddress).getHostAddress());
+ new Ipv6Address(parseAddress(swInterfaceGreDetails.dstAddress).getHostAddress());
builder.setDst(new IpAddress(dstIpv6));
final Ipv6Address srcIpv6 =
- new Ipv6Address(parseAddress(swInterfaceGreDetails.srcAddress).getHostAddress());
+ new Ipv6Address(parseAddress(swInterfaceGreDetails.srcAddress).getHostAddress());
builder.setSrc(new IpAddress(srcIpv6));
} else {
final byte[] dstBytes = Arrays.copyOfRange(swInterfaceGreDetails.dstAddress, 0, 4);
@@ -128,7 +127,7 @@ public class GreCustomizer extends FutureJVppCustomizer
LOG.debug("Gre tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
} catch (VppBaseCallException e) {
LOG.warn("Failed to readCurrentAttributes for: {}", id, e);
- throw new ReadFailedException( id, e );
+ throw new ReadFailedException(id, e);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java
index 5dec9b426..acb7d855d 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java
@@ -22,7 +22,6 @@ import static java.util.Objects.requireNonNull;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
@@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory;
/**
* Utility class providing Interconnection read support.
*/
-final class InterconnectionReadUtils {
+final class InterconnectionReadUtils implements InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(InterconnectionReadUtils.class);
@@ -62,11 +61,11 @@ final class InterconnectionReadUtils {
@Nullable
Interconnection readInterconnection(@Nonnull final InstanceIdentifier<?> id, @Nonnull final String ifaceName,
@Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
final int ifaceId = interfaceContext.getIndex(ifaceName, ctx.getMappingContext());
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJVppCore, id, ifaceName,
- ifaceId, ctx.getModificationCache());
+ final SwInterfaceDetails iface = getVppInterfaceDetails(futureJVppCore, id, ifaceName,
+ ifaceId, ctx.getModificationCache(), LOG);
LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface);
final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id);
@@ -78,7 +77,7 @@ final class InterconnectionReadUtils {
// Set BVI if the bridgeDomainDetails.bviSwIfIndex == current sw if index
final Optional<BridgeDomainDetails> bridgeDomainForInterface =
- getBridgeDomainForInterface(dumpReply, bdForInterface.get().bdId);
+ getBridgeDomainForInterface(dumpReply, bdForInterface.get().bdId);
// Since we already found an interface assigned to a bridge domain, the details for BD must be present
checkState(bridgeDomainForInterface.isPresent());
if (bridgeDomainForInterface.get().bviSwIfIndex == ifaceId) {
@@ -112,7 +111,7 @@ final class InterconnectionReadUtils {
}
private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id)
- throws ReadFailedException {
+ throws ReadFailedException {
try {
// We need to perform full bd dump, because there is no way
// to ask VPP for BD details given interface id/name (TODO HONEYCOMB-190 add it to vpp.api?)
@@ -121,8 +120,8 @@ final class InterconnectionReadUtils {
request.bdId = -1;
final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
- futureJVppCore.bridgeDomainSwIfDump(request).toCompletableFuture();
- return TranslateUtils.getReplyForRead(bdCompletableFuture, id);
+ futureJVppCore.bridgeDomainSwIfDump(request).toCompletableFuture();
+ return getReplyForRead(bdCompletableFuture, id);
} catch (VppBaseCallException e) {
throw new ReadFailedException(id, e);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java
index d0baf003a..a85bfc09a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java
@@ -22,9 +22,9 @@ import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -54,12 +54,12 @@ import org.slf4j.LoggerFactory;
* Customizer for reading ietf-interfaces:interfaces-state/interface.
*/
public class InterfaceCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<Interface, InterfaceKey, InterfaceBuilder> {
+ implements ListReaderCustomizer<Interface, InterfaceKey, InterfaceBuilder>, ByteDataTranslator,
+ InterfaceDataTranslator {
- private static final Logger LOG = LoggerFactory.getLogger(InterfaceCustomizer.class);
public static final String DUMPED_IFCS_CONTEXT_KEY =
- InterfaceCustomizer.class.getName() + "dumpedInterfacesDuringGetAllIds";
-
+ InterfaceCustomizer.class.getName() + "dumpedInterfacesDuringGetAllIds";
+ private static final Logger LOG = LoggerFactory.getLogger(InterfaceCustomizer.class);
private final NamingContext interfaceNamingContext;
private final DisabledInterfacesManager interfaceDisableContext;
@@ -72,6 +72,19 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
}
@Nonnull
+ @SuppressWarnings("unchecked")
+ public static Map<Integer, SwInterfaceDetails> getCachedInterfaceDump(@Nonnull final ModificationCache ctx) {
+ return ctx.get(DUMPED_IFCS_CONTEXT_KEY) == null
+ ? new HashMap<>()
+ // allow customizers to update the cache
+ : (Map<Integer, SwInterfaceDetails>) ctx.get(DUMPED_IFCS_CONTEXT_KEY);
+ }
+
+ private static boolean isRegularInterface(final SwInterfaceDetails iface) {
+ return iface.subId == 0;
+ }
+
+ @Nonnull
@Override
public InterfaceBuilder getBuilder(@Nonnull InstanceIdentifier<Interface> id) {
return new InterfaceBuilder();
@@ -92,8 +105,8 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
}
// Pass cached details from getAllIds to getDetails to avoid additional dumps
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, ifaceName,
- index, ctx.getModificationCache());
+ final SwInterfaceDetails iface = getVppInterfaceDetails(getFutureJVpp(), id, ifaceName,
+ index, ctx.getModificationCache(), LOG);
LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface);
if (!isRegularInterface(iface)) {
@@ -102,33 +115,24 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
}
builder.setName(ifaceName);
- builder.setType(InterfaceUtils.getInterfaceType(new String(iface.interfaceName).intern()));
- builder.setIfIndex(InterfaceUtils.vppIfIndexToYang(iface.swIfIndex));
+ builder.setType(getInterfaceType(new String(iface.interfaceName).intern()));
+ builder.setIfIndex(vppIfIndexToYang(iface.swIfIndex));
builder.setAdminStatus(1 == iface.adminUpDown
- ? AdminStatus.Up
- : AdminStatus.Down);
+ ? AdminStatus.Up
+ : AdminStatus.Down);
builder.setOperStatus(1 == iface.linkUpDown
- ? OperStatus.Up
- : OperStatus.Down);
+ ? OperStatus.Up
+ : OperStatus.Down);
if (0 != iface.linkSpeed) {
- builder.setSpeed(InterfaceUtils.vppInterfaceSpeedToYang(iface.linkSpeed));
+ builder.setSpeed(vppInterfaceSpeedToYang(iface.linkSpeed));
}
if (iface.l2AddressLength == 6) {
- builder.setPhysAddress(new PhysAddress(InterfaceUtils.vppPhysAddrToYang(iface.l2Address)));
+ builder.setPhysAddress(new PhysAddress(vppPhysAddrToYang(iface.l2Address)));
}
LOG.trace("Base attributes read for interface: {} as: {}", ifaceName, builder);
}
@Nonnull
- @SuppressWarnings("unchecked")
- public static Map<Integer, SwInterfaceDetails> getCachedInterfaceDump(@Nonnull final ModificationCache ctx) {
- return ctx.get(DUMPED_IFCS_CONTEXT_KEY) == null
- ? new HashMap<>()
- // allow customizers to update the cache
- : (Map<Integer, SwInterfaceDetails>) ctx.get(DUMPED_IFCS_CONTEXT_KEY);
- }
-
- @Nonnull
@Override
public List<InterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<Interface> id,
@Nonnull final ReadContext context) throws ReadFailedException {
@@ -141,9 +145,9 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
request.nameFilterValid = 0;
final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
- getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
+ getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
final SwInterfaceDetailsReplyDump ifaces =
- TranslateUtils.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
+ getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
if (null == ifaces || null == ifaces.swInterfaceDetails) {
LOG.debug("No interfaces for :{} found in VPP", id);
@@ -152,7 +156,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
// Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
final MappingContext mappingCtx = context.getMappingContext();
final Set<Integer> interfacesIdxs = ifaces.swInterfaceDetails.stream()
@@ -164,7 +168,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
.map((elt) -> {
// Store interface name from VPP in context if not yet present
if (!interfaceNamingContext.containsName(elt.swIfIndex, mappingCtx)) {
- interfaceNamingContext.addName(elt.swIfIndex, TranslateUtils.toString(elt.interfaceName),
+ interfaceNamingContext.addName(elt.swIfIndex, toString(elt.interfaceName),
mappingCtx);
}
LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
@@ -199,10 +203,6 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
}
}
- private static boolean isRegularInterface(final SwInterfaceDetails iface) {
- return iface.subId == 0;
- }
-
@Override
public void merge(@Nonnull final org.opendaylight.yangtools.concepts.Builder<? extends DataObject> builder,
@Nonnull final List<Interface> readData) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java
index 499f21dea..986b92c24 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java
@@ -22,7 +22,8 @@ import static java.util.Objects.requireNonNull;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.math.BigInteger;
import java.util.Map;
import java.util.Objects;
@@ -34,11 +35,11 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.re
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Gauge64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.GreTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.GreTunnel;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.SwInterfaceDetails;
@@ -46,29 +47,23 @@ import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.core.dto.SwInterfaceDump;
import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public final class InterfaceUtils {
- private static final Logger LOG = LoggerFactory.getLogger(InterfaceUtils.class);
+public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyConsumer {
- private static final Gauge64 vppLinkSpeed0 = new Gauge64(BigInteger.ZERO);
- private static final Gauge64 vppLinkSpeed1 = new Gauge64(BigInteger.valueOf(10L * 1000000));
- private static final Gauge64 vppLinkSpeed2 = new Gauge64(BigInteger.valueOf(100L * 1000000));
- private static final Gauge64 vppLinkSpeed4 = new Gauge64(BigInteger.valueOf(1000L * 1000000));
- private static final Gauge64 vppLinkSpeed8 = new Gauge64(BigInteger.valueOf(10000L * 1000000));
- private static final Gauge64 vppLinkSpeed16 = new Gauge64(BigInteger.valueOf(40000L * 1000000));
- private static final Gauge64 vppLinkSpeed32 = new Gauge64(BigInteger.valueOf(100000L * 1000000));
+ Gauge64 vppLinkSpeed0 = new Gauge64(BigInteger.ZERO);
+ Gauge64 vppLinkSpeed1 = new Gauge64(BigInteger.valueOf(10L * 1000000));
+ Gauge64 vppLinkSpeed2 = new Gauge64(BigInteger.valueOf(100L * 1000000));
+ Gauge64 vppLinkSpeed4 = new Gauge64(BigInteger.valueOf(1000L * 1000000));
+ Gauge64 vppLinkSpeed8 = new Gauge64(BigInteger.valueOf(10000L * 1000000));
+ Gauge64 vppLinkSpeed16 = new Gauge64(BigInteger.valueOf(40000L * 1000000));
+ Gauge64 vppLinkSpeed32 = new Gauge64(BigInteger.valueOf(100000L * 1000000));
- private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
+ char[] HEX_CHARS = "0123456789abcdef".toCharArray();
- private static final int PHYSICAL_ADDRESS_LENGTH = 6;
+ int PHYSICAL_ADDRESS_LENGTH = 6;
- private static final Collector<SwInterfaceDetails, ?, SwInterfaceDetails> SINGLE_ITEM_COLLECTOR =
- RWUtils.singleItemCollector();
-
- private InterfaceUtils() {
- throw new UnsupportedOperationException("This utility class cannot be instantiated");
- }
+ Collector<SwInterfaceDetails, ?, SwInterfaceDetails> SINGLE_ITEM_COLLECTOR =
+ RWUtils.singleItemCollector();
/**
* Convert VPP's link speed bitmask to Yang type. 1 = 10M, 2 = 100M, 4 = 1G, 8 = 10G, 16 = 40G, 32 = 100G
@@ -76,7 +71,7 @@ public final class InterfaceUtils {
* @param vppLinkSpeed Link speed in bitmask format from VPP.
* @return Converted value from VPP link speed
*/
- public static Gauge64 vppInterfaceSpeedToYang(byte vppLinkSpeed) {
+ default Gauge64 vppInterfaceSpeedToYang(byte vppLinkSpeed) {
switch (vppLinkSpeed) {
case 1:
return vppLinkSpeed1;
@@ -95,7 +90,7 @@ public final class InterfaceUtils {
}
}
- private static final void appendHexByte(final StringBuilder sb, final byte b) {
+ default void appendHexByte(final StringBuilder sb, final byte b) {
final int v = b & 0xFF;
sb.append(HEX_CHARS[v >>> 4]);
sb.append(HEX_CHARS[v & 15]);
@@ -111,25 +106,25 @@ public final class InterfaceUtils {
* @throws NullPointerException if vppPhysAddress is null
* @throws IllegalArgumentException if vppPhysAddress.length < 6
*/
- public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress) {
+ default String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress) {
return vppPhysAddrToYang(vppPhysAddress, 0);
}
- public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, final int startIndex) {
+ default String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, final int startIndex) {
Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes");
final int endIndex = startIndex + PHYSICAL_ADDRESS_LENGTH;
checkArgument(endIndex <= vppPhysAddress.length,
- "Invalid physical address size (%s) for given startIndex (%s), expected >= %s", vppPhysAddress.length,
- startIndex, endIndex);
+ "Invalid physical address size (%s) for given startIndex (%s), expected >= %s", vppPhysAddress.length,
+ startIndex, endIndex);
return printHexBinary(vppPhysAddress, startIndex, endIndex);
}
- public static String printHexBinary(@Nonnull final byte[] bytes) {
+ default String printHexBinary(@Nonnull final byte[] bytes) {
Objects.requireNonNull(bytes, "bytes array should not be null");
return printHexBinary(bytes, 0, bytes.length);
}
- private static String printHexBinary(@Nonnull final byte[] bytes, final int startIndex, final int endIndex) {
+ default String printHexBinary(@Nonnull final byte[] bytes, final int startIndex, final int endIndex) {
StringBuilder str = new StringBuilder();
appendHexByte(str, bytes[startIndex]);
@@ -148,7 +143,7 @@ public final class InterfaceUtils {
* @param vppIfIndex the sw interface index VPP reported.
* @return VPP's interface index incremented by one
*/
- public static int vppIfIndexToYang(int vppIfIndex) {
+ default int vppIfIndexToYang(int vppIfIndex) {
return vppIfIndex + 1;
}
@@ -158,7 +153,7 @@ public final class InterfaceUtils {
* @param yangIfIndex if-index from ietf-interfaces.
* @return VPP's representation of the if-index
*/
- public static int yangIfIndexToVpp(int yangIfIndex) {
+ default int yangIfIndexToVpp(int yangIfIndex) {
checkArgument(yangIfIndex >= 1, "YANG if-index has invalid value %s", yangIfIndex);
return yangIfIndex - 1;
}
@@ -168,21 +163,22 @@ public final class InterfaceUtils {
* Queries VPP for interface description given interface key.
*
* @param futureJVppCore VPP Java Future API
- * @param id InstanceIdentifier, which is passed in ReadFailedException
- * @param name interface name
- * @param index VPP index of the interface
- * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not
- * available or outdated, another dump will be performed.
+ * @param id InstanceIdentifier, which is passed in ReadFailedException
+ * @param name interface name
+ * @param index VPP index of the interface
+ * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not
+ * available or outdated, another dump will be performed.
* @return SwInterfaceDetails DTO or null if interface was not found
* @throws IllegalArgumentException If interface cannot be found
* @throws ReadFailedException If read operation had failed
*/
@Nonnull
- public static SwInterfaceDetails getVppInterfaceDetails(@Nonnull final FutureJVppCore futureJVppCore,
- @Nonnull final InstanceIdentifier<?> id,
- @Nonnull final String name, final int index,
- @Nonnull final ModificationCache ctx)
- throws ReadFailedException {
+ default SwInterfaceDetails getVppInterfaceDetails(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final InstanceIdentifier<?> id,
+ @Nonnull final String name, final int index,
+ @Nonnull final ModificationCache ctx,
+ @Nonnull final Logger callerLogger)
+ throws ReadFailedException {
requireNonNull(futureJVppCore, "futureJVppCore should not be null");
requireNonNull(name, "name should not be null");
requireNonNull(ctx, "ctx should not be null");
@@ -201,21 +197,21 @@ public final class InterfaceUtils {
SwInterfaceDetailsReplyDump ifaces;
try {
CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJVppCore.swInterfaceDump(request);
- ifaces = TranslateUtils.getReplyForRead(requestFuture.toCompletableFuture(), id);
+ ifaces = getReplyForRead(requestFuture.toCompletableFuture(), id);
if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) {
request.nameFilterValid = 0;
- LOG.warn("VPP returned null instead of interface by key {} and its not cached", name);
- LOG.warn("Iterating through all the interfaces to find interface: {}", name);
+ callerLogger.warn("VPP returned null instead of interface by key {} and its not cached", name);
+ callerLogger.warn("Iterating through all the interfaces to find interface: {}", name);
// Or else just perform full dump and do inefficient filtering
requestFuture = futureJVppCore.swInterfaceDump(request);
- ifaces = TranslateUtils.getReplyForRead(requestFuture.toCompletableFuture(), id);
+ ifaces = getReplyForRead(requestFuture.toCompletableFuture(), id);
// Update the cache
allInterfaces.clear();
allInterfaces
- .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d)));
+ .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d)));
if (allInterfaces.containsKey(index)) {
return allInterfaces.get(index);
@@ -223,13 +219,13 @@ public final class InterfaceUtils {
throw new IllegalArgumentException("Unable to find interface " + name);
}
} catch (VppBaseCallException e) {
- LOG.warn("getVppInterfaceDetails for id :{} and name :{} failed with exception :", id, name, e);
+ callerLogger.warn("getVppInterfaceDetails for id :{} and name :{} failed with exception :", id, name, e);
throw new ReadFailedException(id, e);
}
// SwInterfaceDump's name filter does prefix match, so we need additional filtering:
final SwInterfaceDetails iface =
- ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(SINGLE_ITEM_COLLECTOR);
+ ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(SINGLE_ITEM_COLLECTOR);
allInterfaces.put(index, iface); // update the cache
return iface;
}
@@ -241,7 +237,7 @@ public final class InterfaceUtils {
* @return Interface type
*/
@Nonnull
- public static Class<? extends InterfaceType> getInterfaceType(@Nonnull final String interfaceName) {
+ default Class<? extends InterfaceType> getInterfaceType(@Nonnull final String interfaceName) {
if (interfaceName.startsWith("tap")) {
return Tap.class;
}
@@ -267,23 +263,25 @@ public final class InterfaceUtils {
/**
* Check interface type. Uses interface details from VPP to determine. Uses {@link
- * #getVppInterfaceDetails(FutureJVppCore, InstanceIdentifier, String, int, ModificationCache)} internally so tries to
- * utilize cache before asking VPP.
+ * #getVppInterfaceDetails(FutureJVppCore, InstanceIdentifier, String, int, ModificationCache, Logger)} internally so
+ * tries to utilize cache before asking VPP.
*/
- static boolean isInterfaceOfType(@Nonnull final FutureJVppCore jvpp,
- @Nonnull final ModificationCache cache,
- @Nonnull final InstanceIdentifier<?> id,
- final int index,
- @Nonnull final Class<? extends InterfaceType> ifcType) throws ReadFailedException {
+ default boolean isInterfaceOfType(@Nonnull final FutureJVppCore jvpp,
+ @Nonnull final ModificationCache cache,
+ @Nonnull final InstanceIdentifier<?> id,
+ final int index,
+ @Nonnull final Class<? extends InterfaceType> ifcType,
+ @Nonnull final Logger callerLogger)
+ throws ReadFailedException {
final String name = id.firstKeyOf(Interface.class).getName();
final SwInterfaceDetails vppInterfaceDetails =
- getVppInterfaceDetails(jvpp, id, name, index, cache);
+ getVppInterfaceDetails(jvpp, id, name, index, cache, callerLogger);
return isInterfaceOfType(ifcType, vppInterfaceDetails);
}
- static boolean isInterfaceOfType(final Class<? extends InterfaceType> ifcType,
- final SwInterfaceDetails cachedDetails) {
- return ifcType.equals(getInterfaceType(TranslateUtils.toString(cachedDetails.interfaceName)));
+ default boolean isInterfaceOfType(final Class<? extends InterfaceType> ifcType,
+ final SwInterfaceDetails cachedDetails) {
+ return ifcType.equals(getInterfaceType(toString(cachedDetails.interfaceName)));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2Customizer.java
index e8e50f6d6..1590746c7 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2Customizer.java
@@ -21,6 +21,7 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
@@ -33,10 +34,6 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-
-import static com.google.common.base.Preconditions.checkState;
-
/**
* Customizer for reading ietf-interfaces:interfaces-state/interface/iface_name/v3po:l2
*/
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizer.java
index 6ecaee63f..f84a3f792 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizer.java
@@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory;
* Customizer for reading vlan tag-rewrite configuration state form the VPP.
*/
public class RewriteCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Rewrite, RewriteBuilder> {
+ implements ReaderCustomizer<Rewrite, RewriteBuilder>, InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(RewriteCustomizer.class);
private final NamingContext interfaceContext;
@@ -86,8 +86,8 @@ public class RewriteCustomizer extends FutureJVppCustomizer
final String subInterfaceName = getSubInterfaceName(id);
LOG.debug("Reading attributes for sub interface: {}", subInterfaceName);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
- interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache());
+ final SwInterfaceDetails iface = getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
+ interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache(), LOG);
LOG.debug("VPP sub-interface details: {}", iface);
checkState(iface.subId != 0, "Interface returned by the VPP is not a sub-interface");
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceAclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceAclCustomizer.java
index cbc8c7ed1..8e7568d85 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceAclCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceAclCustomizer.java
@@ -21,11 +21,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory;
* Customizer for reading ACLs enabled on given sub-interface.
*/
public class SubInterfaceAclCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Acl, AclBuilder>, AclReader {
+ implements ReaderCustomizer<Acl, AclBuilder>, AclReader, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceAclCustomizer.class);
private final NamingContext interfaceContext;
@@ -82,13 +82,13 @@ public class SubInterfaceAclCustomizer extends FutureJVppCustomizer
final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class);
checkArgument(subInterfacekey != null, "No sub-interface key found");
final String subInterfaceName =
- getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue());
+ getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue());
final ClassifyTableByInterface request = new ClassifyTableByInterface();
request.swIfIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext());
try {
- final ClassifyTableByInterfaceReply reply = TranslateUtils
- .getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id);
+ final ClassifyTableByInterfaceReply reply =
+ getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id);
builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext()));
builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext()));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
index 167ae6a8c..3ba102fde 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
@@ -17,16 +17,15 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.byteToBoolean;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -72,11 +71,12 @@ import org.slf4j.LoggerFactory;
* Customizer for reading sub interfaces form the VPP.
*/
public class SubInterfaceCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<SubInterface, SubInterfaceKey, SubInterfaceBuilder> {
+ implements ListReaderCustomizer<SubInterface, SubInterfaceKey, SubInterfaceBuilder>, ByteDataTranslator,
+ InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceCustomizer.class);
- private NamingContext interfaceContext;
private static final Dot1qTag.VlanId ANY_VLAN_ID = new Dot1qTag.VlanId(Dot1qTag.VlanId.Enumeration.Any);
+ private NamingContext interfaceContext;
public SubInterfaceCustomizer(@Nonnull final FutureJVppCore jvpp,
@Nonnull final NamingContext interfaceContext) {
@@ -84,6 +84,28 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
this.interfaceContext = Preconditions.checkNotNull(interfaceContext, "interfaceContext should not be null");
}
+ private static String getSubInterfaceName(final InstanceIdentifier<SubInterface> id) {
+ return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
+ Math.toIntExact(id.firstKeyOf(id.getTargetType()).getIdentifier()));
+ }
+
+ private static Tag buildTag(final short index, final Class<? extends Dot1qTagVlanType> tagType,
+ final Dot1qTag.VlanId vlanId) {
+ TagBuilder tag = new TagBuilder();
+ tag.setIndex(index);
+ tag.setKey(new TagKey(index));
+ final Dot1qTagBuilder dtag = new Dot1qTagBuilder();
+ dtag.setTagType(tagType);
+ dtag.setVlanId(vlanId);
+ tag.setDot1qTag(dtag.build());
+ return tag.build();
+ }
+
+ private static Dot1qTag.VlanId buildVlanId(final short vlanId) {
+ // treat vlanId as unsigned value:
+ return new Dot1qTag.VlanId(new Dot1qVlanId(0xffff & vlanId));
+ }
+
@Nonnull
@Override
public List<SubInterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<SubInterface> id,
@@ -105,7 +127,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
final SwInterfaceDetailsReplyDump ifaces =
- TranslateUtils.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
+ getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
if (null == ifaces || null == ifaces.swInterfaceDetails) {
LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP");
@@ -113,8 +135,9 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
}
// Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- context.getModificationCache().put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
+ context.getModificationCache()
+ .put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
.filter(elt -> elt != null)
@@ -126,7 +149,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys);
return interfacesKeys;
} catch (VppBaseCallException e) {
- throw new ReadFailedException(id,e);
+ throw new ReadFailedException(id, e);
}
}
@@ -149,8 +172,8 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final String subInterfaceName = getSubInterfaceName(id);
LOG.debug("Reading attributes for sub interface: {}", subInterfaceName);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
- interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache());
+ final SwInterfaceDetails iface = getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
+ interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache(), LOG);
LOG.debug("VPP sub-interface details: {}", iface);
checkState(iface.subId != 0, "Interface returned by the VPP is not a sub-interface");
@@ -169,20 +192,15 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
builder.setOperStatus(1 == iface.linkUpDown
? SubInterfaceStatus.Up
: SubInterfaceStatus.Down);
- builder.setIfIndex(InterfaceUtils.vppIfIndexToYang(iface.swIfIndex));
+ builder.setIfIndex(vppIfIndexToYang(iface.swIfIndex));
if (iface.l2AddressLength == 6) {
- builder.setPhysAddress(new PhysAddress(InterfaceUtils.vppPhysAddrToYang(iface.l2Address)));
+ builder.setPhysAddress(new PhysAddress(vppPhysAddrToYang(iface.l2Address)));
}
if (0 != iface.linkSpeed) {
- builder.setSpeed(InterfaceUtils.vppInterfaceSpeedToYang(iface.linkSpeed));
+ builder.setSpeed(vppInterfaceSpeedToYang(iface.linkSpeed));
}
}
- private static String getSubInterfaceName(final InstanceIdentifier<SubInterface> id) {
- return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
- Math.toIntExact(id.firstKeyOf(id.getTargetType()).getIdentifier()));
- }
-
private Tags readTags(final SwInterfaceDetails iface) {
final TagsBuilder tags = new TagsBuilder();
final List<Tag> list = new ArrayList<>();
@@ -205,23 +223,6 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
return tags.build();
}
- private static Tag buildTag(final short index, final Class<? extends Dot1qTagVlanType> tagType,
- final Dot1qTag.VlanId vlanId) {
- TagBuilder tag = new TagBuilder();
- tag.setIndex(index);
- tag.setKey(new TagKey(index));
- final Dot1qTagBuilder dtag = new Dot1qTagBuilder();
- dtag.setTagType(tagType);
- dtag.setVlanId(vlanId);
- tag.setDot1qTag(dtag.build());
- return tag.build();
- }
-
- private static Dot1qTag.VlanId buildVlanId(final short vlanId) {
- // treat vlanId as unsigned value:
- return new Dot1qTag.VlanId(new Dot1qVlanId(0xffff & vlanId));
- }
-
private Match readMatch(final SwInterfaceDetails iface) {
final MatchBuilder match = new MatchBuilder();
if (iface.subDefault == 1) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
index debf0efee..37d85abca 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
@@ -19,8 +19,8 @@ package io.fd.honeycomb.translate.v3po.interfacesstate;
import static io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import javax.annotation.Nonnull;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java
index 5bf3435ce..37ba6bbd9 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java
@@ -16,14 +16,12 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -48,7 +46,7 @@ import org.slf4j.LoggerFactory;
public class TapCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Tap, TapBuilder> {
+ implements ReaderCustomizer<Tap, TapBuilder>, InterfaceDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(TapCustomizer.class);
public static final String DUMPED_TAPS_CONTEXT_KEY = TapCustomizer.class.getName() + "dumpedTapsDuringGetAllIds";
@@ -78,7 +76,7 @@ public class TapCustomizer extends FutureJVppCustomizer
final InterfaceKey key = id.firstKeyOf(Interface.class);
final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class, LOG)) {
return;
}
@@ -86,23 +84,23 @@ public class TapCustomizer extends FutureJVppCustomizer
@SuppressWarnings("unchecked")
Map<Integer, SwInterfaceTapDetails> mappedTaps =
- (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
+ (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
- if(mappedTaps == null) {
+ if (mappedTaps == null) {
// Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it
final SwInterfaceTapDump request = new SwInterfaceTapDump();
final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage =
- getFutureJVpp().swInterfaceTapDump(request);
+ getFutureJVpp().swInterfaceTapDump(request);
final SwInterfaceTapDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
- if(null == reply || null == reply.swInterfaceTapDetails) {
+ if (null == reply || null == reply.swInterfaceTapDetails) {
mappedTaps = Collections.emptyMap();
} else {
final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails;
// Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
mappedTaps = swInterfaceTapDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
}
ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
@@ -111,7 +109,7 @@ public class TapCustomizer extends FutureJVppCustomizer
final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index);
LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails);
- builder.setTapName(TranslateUtils.toString(swInterfaceTapDetails.devName));
+ builder.setTapName(toString(swInterfaceTapDetails.devName));
LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
} catch (VppBaseCallException e) {
LOG.warn("Failed to readCurrentAttributes for: {}", id, e);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java
index 96ae4fdf0..032b3c214 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java
@@ -16,14 +16,12 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
@@ -50,10 +48,11 @@ import org.slf4j.LoggerFactory;
public class VhostUserCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<VhostUser, VhostUserBuilder> {
+ implements ReaderCustomizer<VhostUser, VhostUserBuilder>, InterfaceDataTranslator, JvppReplyConsumer {
+ public static final String DUMPED_VHOST_USERS_CONTEXT_KEY =
+ VhostUserCustomizer.class.getName() + "dumpedVhostUsersDuringGetAllIds";
private static final Logger LOG = LoggerFactory.getLogger(VhostUserCustomizer.class);
- public static final String DUMPED_VHOST_USERS_CONTEXT_KEY = VhostUserCustomizer.class.getName() + "dumpedVhostUsersDuringGetAllIds";
private NamingContext interfaceContext;
public VhostUserCustomizer(@Nonnull final FutureJVppCore jvpp, @Nonnull final NamingContext interfaceContext) {
@@ -80,7 +79,8 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
final InterfaceKey key = id.firstKeyOf(Interface.class);
final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class,
+ LOG)) {
return;
}
@@ -88,23 +88,26 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
@SuppressWarnings("unchecked")
Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers =
- (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache().get(DUMPED_VHOST_USERS_CONTEXT_KEY);
+ (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache()
+ .get(DUMPED_VHOST_USERS_CONTEXT_KEY);
- if(mappedVhostUsers == null) {
+ if (mappedVhostUsers == null) {
// Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it
final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump();
- final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> swInterfaceVhostUserDetailsReplyDumpCompletionStage =
- getFutureJVpp().swInterfaceVhostUserDump(request);
+ final CompletionStage<SwInterfaceVhostUserDetailsReplyDump>
+ swInterfaceVhostUserDetailsReplyDumpCompletionStage =
+ getFutureJVpp().swInterfaceVhostUserDump(request);
final SwInterfaceVhostUserDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
- if(null == reply || null == reply.swInterfaceVhostUserDetails) {
+ if (null == reply || null == reply.swInterfaceVhostUserDetails) {
mappedVhostUsers = Collections.emptyMap();
} else {
- final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = reply.swInterfaceVhostUserDetails;
+ final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails =
+ reply.swInterfaceVhostUserDetails;
// Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
mappedVhostUsers = swInterfaceVhostUserDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
}
ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
@@ -112,12 +115,15 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
// Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping
final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index);
- LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceVhostUserDetails);
+ LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(),
+ swInterfaceVhostUserDetails);
- builder.setRole(swInterfaceVhostUserDetails.isServer == 1 ? VhostUserRole.Server : VhostUserRole.Client);
+ builder.setRole(swInterfaceVhostUserDetails.isServer == 1
+ ? VhostUserRole.Server
+ : VhostUserRole.Client);
builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features));
builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions);
- builder.setSocket(TranslateUtils.toString(swInterfaceVhostUserDetails.sockFilename));
+ builder.setSocket(toString(swInterfaceVhostUserDetails.sockFilename));
builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java
index b0a0496ce..2d01c3e39 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java
@@ -17,14 +17,13 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
@@ -52,7 +51,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class VxlanCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<Vxlan, VxlanBuilder> {
+ implements ReaderCustomizer<Vxlan, VxlanBuilder>, InterfaceDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VxlanCustomizer.class);
private final NamingContext interfaceContext;
@@ -81,7 +80,7 @@ public class VxlanCustomizer extends FutureJVppCustomizer
try {
final InterfaceKey key = id.firstKeyOf(Interface.class);
final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanTunnel.class)) {
+ if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanTunnel.class, LOG)) {
return;
}
@@ -91,31 +90,32 @@ public class VxlanCustomizer extends FutureJVppCustomizer
request.swIfIndex = index;
final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage =
- getFutureJVpp().vxlanTunnelDump(request);
+ getFutureJVpp().vxlanTunnelDump(request);
final VxlanTunnelDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
// VPP keeps vxlan tunnel interfaces even after they were deleted (optimization)
// However there ar no longer any vxlan tunnel specific fields assigned to it and this call
// returns nothing
if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) {
LOG.debug(
- "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
+ "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
return;
}
checkState(reply.vxlanTunnelDetails.size() == 1,
- "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, key.getName());
+ "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails,
+ key.getName());
LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0);
if (swInterfaceVxlanDetails.isIpv6 == 1) {
final Ipv6Address dstIpv6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress());
+ new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress());
builder.setDst(new IpAddress(dstIpv6));
final Ipv6Address srcIpv6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress());
+ new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress());
builder.setSrc(new IpAddress(srcIpv6));
} else {
final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4);
@@ -126,11 +126,11 @@ public class VxlanCustomizer extends FutureJVppCustomizer
builder.setSrc(new IpAddress(srcIpv4));
}
builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId);
- builder.setVni( new VxlanVni((long) swInterfaceVxlanDetails.vni));
+ builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni));
LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
} catch (VppBaseCallException e) {
LOG.warn("Failed to readCurrentAttributes for: {}", id);
- throw new ReadFailedException( id, e );
+ throw new ReadFailedException(id, e);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
index e6a9f85a2..deeba8ae0 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
@@ -17,14 +17,13 @@
package io.fd.honeycomb.translate.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
@@ -53,7 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class VxlanGpeCustomizer extends FutureJVppCustomizer
- implements ReaderCustomizer<VxlanGpe, VxlanGpeBuilder> {
+ implements ReaderCustomizer<VxlanGpe, VxlanGpeBuilder>, InterfaceDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VxlanGpeCustomizer.class);
private NamingContext interfaceContext;
@@ -82,7 +81,7 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer
try {
final InterfaceKey key = id.firstKeyOf(Interface.class);
final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanGpeTunnel.class)) {
+ if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanGpeTunnel.class, LOG)) {
return;
}
@@ -92,31 +91,33 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer
request.swIfIndex = index;
final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage =
- getFutureJVpp().vxlanGpeTunnelDump(request);
+ getFutureJVpp().vxlanGpeTunnelDump(request);
final VxlanGpeTunnelDetailsReplyDump reply =
- TranslateUtils.getReplyForRead(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
+ getReplyForRead(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture(),
+ id);
// VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization)
// However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call
// returns nothing
if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) {
LOG.debug(
- "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
+ "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
return;
}
checkState(reply.vxlanGpeTunnelDetails.size() == 1,
- "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, key.getName());
+ "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails,
+ key.getName());
LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0);
if (swInterfaceVxlanGpeDetails.isIpv6 == 1) {
final Ipv6Address remote6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress());
+ new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress());
builder.setRemote(new IpAddress(remote6));
final Ipv6Address local6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress());
+ new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress());
builder.setLocal(new IpAddress(local6));
} else {
final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4);
@@ -127,13 +128,13 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer
builder.setLocal(new IpAddress(local4));
}
builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni));
- builder.setNextProtocol(VxlanGpeNextProtocol.forValue(swInterfaceVxlanGpeDetails.protocol));
+ builder.setNextProtocol(VxlanGpeNextProtocol.forValue(swInterfaceVxlanGpeDetails.protocol));
builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId);
builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId);
LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
} catch (VppBaseCallException e) {
LOG.warn("Failed to readCurrentAttributes for: {}", id);
- throw new ReadFailedException( id, e );
+ throw new ReadFailedException(id, e);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
index f3605ca0f..e2df8e2cb 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
@@ -17,17 +17,18 @@
package io.fd.honeycomb.translate.v3po.interfacesstate.ip;
import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4ReadUtils.dumpAddresses;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4ReadUtils.findIpAddressDetailsByIp;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4ReadUtils.getAllIpv4AddressIds;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.AddressDumpExecutor;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.check.AddressDumpCheck;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.List;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -49,15 +50,22 @@ import org.slf4j.LoggerFactory;
* Read customizer for interface Ipv4 addresses.
*/
public class Ipv4AddressCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<Address, AddressKey, AddressBuilder> {
+ implements ListReaderCustomizer<Address, AddressKey, AddressBuilder>, Ipv4Reader {
private static final Logger LOG = LoggerFactory.getLogger(Ipv4AddressCustomizer.class);
+ private static final String CACHE_KEY = Ipv4AddressCustomizer.class.getName();
private final NamingContext interfaceContext;
+ private final DumpCacheManager<IpAddressDetailsReplyDump, AddressDumpParams> dumpManager;
- public Ipv4AddressCustomizer(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext interfaceContext) {
+ public Ipv4AddressCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext interfaceContext) {
super(futureJVppCore);
this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
+ this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpAddressDetailsReplyDump, AddressDumpParams>()
+ .withExecutor(new AddressDumpExecutor(futureJVppCore))
+ .withNonEmptyPredicate(new AddressDumpCheck())
+ .build();
}
@Override
@@ -69,38 +77,55 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Address> id, @Nonnull AddressBuilder builder,
@Nonnull ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("Reading attributes for interface address: {}", id);
final String interfaceName = id.firstKeyOf(Interface.class).getName();
final int interfaceIndex = interfaceContext.getIndex(interfaceName, ctx.getMappingContext());
- final Optional<IpAddressDetailsReplyDump> dumpOptional =
- dumpAddresses(getFutureJVpp(), id, interfaceName, interfaceIndex, ctx);
+ final Optional<IpAddressDetailsReplyDump> dumpOptional;
+ try {
+ dumpOptional =
+ dumpManager.getDump(CACHE_KEY, ctx.getModificationCache(),
+ new AddressDumpParams(interfaceIndex, false));
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
- final Optional<IpAddressDetails> ipAddressDetails =
- findIpAddressDetailsByIp(dumpOptional, id.firstKeyOf(Address.class).getIp());
+ if (dumpOptional.isPresent()) {
+ final Optional<IpAddressDetails> ipAddressDetails =
+ findIpAddressDetailsByIp(dumpOptional, id.firstKeyOf(Address.class).getIp());
- if (ipAddressDetails.isPresent()) {
- final IpAddressDetails detail = ipAddressDetails.get();
- builder.setIp(TranslateUtils.arrayToIpv4AddressNoZone(detail.ip))
- .setSubnet(new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
+ if (ipAddressDetails.isPresent()) {
+ final IpAddressDetails detail = ipAddressDetails.get();
+ builder.setIp(arrayToIpv4AddressNoZone(detail.ip))
+ .setSubnet(
+ new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
- if (LOG.isDebugEnabled()) {
- LOG.debug("Attributes for {} interface (id={}) address {} successfully read: {}",
- interfaceName, interfaceIndex, id, builder.build());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Attributes for {} interface (id={}) address {} successfully read: {}",
+ interfaceName, interfaceIndex, id, builder.build());
+ }
}
}
+
+
}
@Override
public List<AddressKey> getAllIds(@Nonnull InstanceIdentifier<Address> id, @Nonnull ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("Reading list of keys for interface addresses: {}", id);
final String interfaceName = id.firstKeyOf(Interface.class).getName();
final int interfaceIndex = interfaceContext.getIndex(interfaceName, ctx.getMappingContext());
- final Optional<IpAddressDetailsReplyDump> dumpOptional =
- dumpAddresses(getFutureJVpp(), id, interfaceName, interfaceIndex, ctx);
+ final Optional<IpAddressDetailsReplyDump> dumpOptional;
+ try {
+ dumpOptional =
+ dumpManager.getDump(CACHE_KEY, ctx.getModificationCache(),
+ new AddressDumpParams(interfaceIndex, false));
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
return getAllIpv4AddressIds(dumpOptional, AddressKey::new);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4NeighbourCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4NeighbourCustomizer.java
index 05b5ef47c..d95557e6d 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4NeighbourCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4NeighbourCustomizer.java
@@ -17,9 +17,9 @@
package io.fd.honeycomb.translate.v3po.interfacesstate.ip;
import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.read.ReadFailedException;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4Builder;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4ReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4ReadUtils.java
deleted file mode 100644
index c3c5616c9..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4ReadUtils.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.translate.v3po.interfacesstate.ip;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.v3po.util.ReadTimeoutException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
-import java.util.Collections;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.core.dto.IpAddressDetails;
-import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
-import org.openvpp.jvpp.core.dto.IpAddressDump;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility class providing Ipv4 read support.
- */
-final class Ipv4ReadUtils {
-
- static final String CACHE_KEY = Ipv4ReadUtils.class.getName();
- private static final Logger LOG = LoggerFactory.getLogger(Ipv4ReadUtils.class);
-
- private Ipv4ReadUtils() {
- throw new UnsupportedOperationException("This utility class cannot be instantiated");
- }
-
- // Many VPP APIs do not provide get operation for single item. Dump requests for all items are used instead.
- // To improve HC performance, caching dump requests is a common pattern.
- // TODO: HONEYCOMB-102 use more generic caching implementation, once provided
- static Optional<IpAddressDetailsReplyDump> dumpAddresses(@Nonnull final FutureJVppCore futureJVppCore,
- @Nonnull final InstanceIdentifier<?> id,
- @Nonnull final String interfaceName,
- final int interfaceIndex, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
-
- final String cacheKey = CACHE_KEY + interfaceName;
- Optional<IpAddressDetailsReplyDump> dumpFromCache = dumpAddressFromCache(cacheKey, ctx.getModificationCache());
-
- if (dumpFromCache.isPresent()) {
- return dumpFromCache;
- }
-
- Optional<IpAddressDetailsReplyDump> dumpFromOperational;
- try {
- dumpFromOperational = dumpAddressFromOperationalData(futureJVppCore, id, interfaceIndex);
- } catch (VppBaseCallException e) {
- throw new ReadFailedException(id, e);
- }
-
- if (dumpFromOperational.isPresent()) {
- ctx.getModificationCache().put(cacheKey, dumpFromOperational.get());
- }
-
- return dumpFromOperational;
- }
-
- private static Optional<IpAddressDetailsReplyDump> dumpAddressFromCache(@Nonnull final String cacheKey,
- @Nonnull final ModificationCache cache) {
- LOG.debug("Retrieving Ipv4 addresses from cache for {}", cacheKey);
- return Optional.fromNullable((IpAddressDetailsReplyDump) cache.get(cacheKey));
- }
-
- private static Optional<IpAddressDetailsReplyDump> dumpAddressFromOperationalData(
- @Nonnull final FutureJVppCore futureJVppCore, @Nonnull final InstanceIdentifier<?> id, final int interfaceIndex)
- throws VppBaseCallException, ReadTimeoutException {
- LOG.debug("Dumping Ipv4 addresses for interface id={}", interfaceIndex);
- final IpAddressDump dumpRequest = new IpAddressDump();
- dumpRequest.isIpv6 = 0;
- dumpRequest.swIfIndex = interfaceIndex;
- return Optional.fromNullable(
- TranslateUtils.getReplyForRead(futureJVppCore.ipAddressDump(dumpRequest).toCompletableFuture(), id));
- }
-
- @Nonnull static <T extends Identifier> List<T> getAllIpv4AddressIds(
- final Optional<IpAddressDetailsReplyDump> dumpOptional,
- @Nonnull final Function<Ipv4AddressNoZone, T> keyConstructor) {
- if (dumpOptional.isPresent() && dumpOptional.get().ipAddressDetails != null) {
- return dumpOptional.get().ipAddressDetails.stream()
- .map(detail -> keyConstructor.apply(TranslateUtils.arrayToIpv4AddressNoZone(detail.ip)))
- .collect(Collectors.toList());
- } else {
- return Collections.emptyList();
- }
- }
-
- static Optional<IpAddressDetails> findIpAddressDetailsByIp(
- final Optional<IpAddressDetailsReplyDump> dump,
- @Nonnull final Ipv4AddressNoZone ip) {
- checkNotNull(ip, "ip address should not be null");
-
- if (dump.isPresent() && dump.get().ipAddressDetails != null) {
- final List<IpAddressDetails> details = dump.get().ipAddressDetails;
-
- return Optional.of(details.stream()
- .filter(singleDetail -> ip.equals(TranslateUtils.arrayToIpv4AddressNoZone(singleDetail.ip)))
- .collect(RWUtils.singleItemCollector()));
- }
- return Optional.absent();
- }
-
-}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java
new file mode 100644
index 000000000..60447d974
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.v3po.interfacesstate.ip;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.openvpp.jvpp.core.dto.IpAddressDetails;
+import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
+
+/**
+ * Utility class providing Ipv4 read support.
+ */
+interface Ipv4Reader extends Ipv4Translator, JvppReplyConsumer {
+
+ @Nonnull
+ default <T extends Identifier> List<T> getAllIpv4AddressIds(
+ final Optional<IpAddressDetailsReplyDump> dumpOptional,
+ @Nonnull final Function<Ipv4AddressNoZone, T> keyConstructor) {
+ if (dumpOptional.isPresent() && dumpOptional.get().ipAddressDetails != null) {
+ return dumpOptional.get().ipAddressDetails.stream()
+ .map(detail -> keyConstructor.apply(arrayToIpv4AddressNoZone(detail.ip)))
+ .collect(Collectors.toList());
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ default Optional<IpAddressDetails> findIpAddressDetailsByIp(
+ final Optional<IpAddressDetailsReplyDump> dump,
+ @Nonnull final Ipv4AddressNoZone ip) {
+ checkNotNull(ip, "ip address should not be null");
+
+ if (dump.isPresent() && dump.get().ipAddressDetails != null) {
+ final List<IpAddressDetails> details = dump.get().ipAddressDetails;
+
+ return Optional.of(details.stream()
+ .filter(singleDetail -> ip.equals(arrayToIpv4AddressNoZone(singleDetail.ip)))
+ .collect(RWUtils.singleItemCollector()));
+ }
+ return Optional.absent();
+ }
+
+}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java
index e1f306140..bd96bfbb9 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java
@@ -17,18 +17,19 @@
package io.fd.honeycomb.translate.v3po.interfacesstate.ip;
import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4ReadUtils.dumpAddresses;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4ReadUtils.findIpAddressDetailsByIp;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4ReadUtils.getAllIpv4AddressIds;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.AddressDumpExecutor;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.check.AddressDumpCheck;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.SubInterfaceUtils;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.List;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -51,16 +52,22 @@ import org.slf4j.LoggerFactory;
* Read customizer for sub-interface Ipv4 addresses.
*/
public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<Address, AddressKey, AddressBuilder> {
+ implements ListReaderCustomizer<Address, AddressKey, AddressBuilder>, Ipv4Reader {
private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceIpv4AddressCustomizer.class);
+ private static final String CACHE_KEY = SubInterfaceIpv4AddressCustomizer.class.getName();
private final NamingContext interfaceContext;
+ private final DumpCacheManager<IpAddressDetailsReplyDump, AddressDumpParams> dumpManager;
public SubInterfaceIpv4AddressCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
@Nonnull final NamingContext interfaceContext) {
super(futureJVppCore);
this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
+ this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpAddressDetailsReplyDump, AddressDumpParams>()
+ .withExecutor(new AddressDumpExecutor(futureJVppCore))
+ .withNonEmptyPredicate(new AddressDumpCheck())
+ .build();
}
@Override
@@ -72,38 +79,49 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Address> id, @Nonnull AddressBuilder builder,
@Nonnull ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("Reading attributes for sub-interface address: {}", id);
final String subInterfaceName = getSubInterfaceName(id);
final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext());
- final Optional<IpAddressDetailsReplyDump> dumpOptional =
- dumpAddresses(getFutureJVpp(), id, subInterfaceName, subInterfaceIndex, ctx);
+ final Optional<IpAddressDetailsReplyDump> dumpOptional;
+ try {
+ dumpOptional = dumpManager
+ .getDump(CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(subInterfaceIndex, false));
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+
final Optional<IpAddressDetails> ipAddressDetails =
- findIpAddressDetailsByIp(dumpOptional, id.firstKeyOf(Address.class).getIp());
+ findIpAddressDetailsByIp(dumpOptional, id.firstKeyOf(Address.class).getIp());
if (ipAddressDetails.isPresent()) {
final IpAddressDetails detail = ipAddressDetails.get();
- builder.setIp(TranslateUtils.arrayToIpv4AddressNoZone(detail.ip))
- .setSubnet(new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
+ builder.setIp(arrayToIpv4AddressNoZone(detail.ip))
+ .setSubnet(new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
if (LOG.isDebugEnabled()) {
LOG.debug("Attributes for {} sub-interface (id={}) address {} successfully read: {}",
- subInterfaceName, subInterfaceIndex, id, builder.build());
+ subInterfaceName, subInterfaceIndex, id, builder.build());
}
}
}
@Override
public List<AddressKey> getAllIds(@Nonnull InstanceIdentifier<Address> id, @Nonnull ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("Reading list of keys for sub-interface addresses: {}", id);
final String subInterfaceName = getSubInterfaceName(id);
final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext());
- final Optional<IpAddressDetailsReplyDump> dumpOptional =
- dumpAddresses(getFutureJVpp(), id, subInterfaceName, subInterfaceIndex, ctx);
+ final Optional<IpAddressDetailsReplyDump> dumpOptional;
+ try {
+ dumpOptional = dumpManager
+ .getDump(CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(subInterfaceIndex, false));
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
return getAllIpv4AddressIds(dumpOptional, AddressKey::new);
}
@@ -115,6 +133,6 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
private static String getSubInterfaceName(@Nonnull final InstanceIdentifier<Address> id) {
return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
- Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier()));
+ Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier()));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java
new file mode 100644
index 000000000..a94e47c91
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java
@@ -0,0 +1,47 @@
+package io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump;
+
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
+import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.IpAddressDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+public class AddressDumpExecutor
+ implements EntityDumpExecutor<IpAddressDetailsReplyDump, AddressDumpParams>, ByteDataTranslator,
+ JvppReplyConsumer {
+
+ private FutureJVppCore vppApi;
+
+ public AddressDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
+ this.vppApi = checkNotNull(vppApi, "Vpp api refference cannot be null");
+ }
+
+ @Override
+ public IpAddressDetailsReplyDump executeDump(final AddressDumpParams params) throws DumpExecutionFailedException {
+ checkNotNull(params, "Address dump params cannot be null");
+
+ IpAddressDump dumpRequest = new IpAddressDump();
+ dumpRequest.isIpv6 = booleanToByte(params.isIpv6());
+ dumpRequest.swIfIndex = params.getInterfaceIndex();
+
+ try {
+ return getReply(vppApi.ipAddressDump(dumpRequest).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException
+ .wrapTimeoutException("Dumping or addresses ended in timeout[params : ]" + params, e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException.wrapFailedCallException("Dumping of addresses failed[params : ]" + params, e);
+ }
+ }
+}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/check/AddressDumpCheck.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/check/AddressDumpCheck.java
new file mode 100644
index 000000000..d6ab28db0
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/check/AddressDumpCheck.java
@@ -0,0 +1,16 @@
+package io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.check;
+
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.util.read.cache.exceptions.check.i.DumpEmptyException;
+import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
+
+public class AddressDumpCheck implements EntityDumpNonEmptyCheck<IpAddressDetailsReplyDump> {
+
+ @Override
+ public void assertNotEmpty(final IpAddressDetailsReplyDump data) throws DumpCheckFailedException {
+ if (data == null || data.ipAddressDetails == null) {
+ throw new DumpEmptyException("Invalid data dumped");
+ }
+ }
+}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/params/AddressDumpParams.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/params/AddressDumpParams.java
new file mode 100644
index 000000000..9b7591b58
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/params/AddressDumpParams.java
@@ -0,0 +1,28 @@
+package io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params;
+
+public class AddressDumpParams {
+
+ private final int interfaceIndex;
+ private final boolean isIpv6;
+
+ public AddressDumpParams(final int interfaceIndex, final boolean isIpv6) {
+ this.interfaceIndex = interfaceIndex;
+ this.isIpv6 = isIpv6;
+ }
+
+ public int getInterfaceIndex() {
+ return interfaceIndex;
+ }
+
+ public boolean isIpv6() {
+ return isIpv6;
+ }
+
+ @Override
+ public String toString() {
+ return "AddressDumpParams{" +
+ "interfaceIndex=" + interfaceIndex +
+ ", isIpv6=" + isIpv6 +
+ '}';
+ }
+}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
index 481a2eac9..974c4f876 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.translate.v3po.notification;
import com.google.common.base.Optional;
@@ -22,8 +23,8 @@ import com.google.inject.name.Named;
import io.fd.honeycomb.notification.ManagedNotificationProducer;
import io.fd.honeycomb.notification.NotificationCollector;
import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.CompletionStage;
@@ -51,7 +52,7 @@ import org.slf4j.LoggerFactory;
* received notification, it transforms it into its BA equivalent and pushes into HC's notification collector.
*/
@NotThreadSafe
-public final class InterfaceChangeNotificationProducer implements ManagedNotificationProducer {
+public final class InterfaceChangeNotificationProducer implements ManagedNotificationProducer, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceChangeNotificationProducer.class);
@@ -76,11 +77,11 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
enableDisableIfcNotifications(1);
LOG.debug("Interface notifications started successfully");
notificationListenerReg = jvpp.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback(
- swInterfaceSetFlagsNotification -> {
- LOG.trace("Interface notification received: {}", swInterfaceSetFlagsNotification);
- // TODO HONEYCOMB-166 this should be lazy
- collector.onNotification(transformNotification(swInterfaceSetFlagsNotification));
- }
+ swInterfaceSetFlagsNotification -> {
+ LOG.trace("Interface notification received: {}", swInterfaceSetFlagsNotification);
+ // TODO HONEYCOMB-166 this should be lazy
+ collector.onNotification(transformNotification(swInterfaceSetFlagsNotification));
+ }
);
}
@@ -89,10 +90,14 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
return new InterfaceDeletedBuilder().setName(getIfcName(swInterfaceSetFlagsNotification)).build();
} else {
return new InterfaceStateChangeBuilder()
- .setName(getIfcName(swInterfaceSetFlagsNotification))
- .setAdminStatus(swInterfaceSetFlagsNotification.adminUpDown == 1 ? InterfaceStatus.Up : InterfaceStatus.Down)
- .setOperStatus(swInterfaceSetFlagsNotification.linkUpDown == 1 ? InterfaceStatus.Up : InterfaceStatus.Down)
- .build();
+ .setName(getIfcName(swInterfaceSetFlagsNotification))
+ .setAdminStatus(swInterfaceSetFlagsNotification.adminUpDown == 1
+ ? InterfaceStatus.Up
+ : InterfaceStatus.Down)
+ .setOperStatus(swInterfaceSetFlagsNotification.linkUpDown == 1
+ ? InterfaceStatus.Up
+ : InterfaceStatus.Down)
+ .build();
}
}
@@ -107,8 +112,8 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
final Optional<String> optionalName =
interfaceContext.getNameIfPresent(swInterfaceSetFlagsNotification.swIfIndex, mappingContext);
return optionalName.isPresent()
- ? new InterfaceNameOrIndex(optionalName.get())
- : new InterfaceNameOrIndex((long) swInterfaceSetFlagsNotification.swIfIndex);
+ ? new InterfaceNameOrIndex(optionalName.get())
+ : new InterfaceNameOrIndex((long) swInterfaceSetFlagsNotification.swIfIndex);
}
@Override
@@ -132,9 +137,11 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
final CompletionStage<WantInterfaceEventsReply> wantInterfaceEventsReplyCompletionStage;
try {
wantInterfaceEventsReplyCompletionStage = jvpp.wantInterfaceEvents(wantInterfaceEvents);
- TranslateUtils.getReply(wantInterfaceEventsReplyCompletionStage.toCompletableFuture());
+ getReply(wantInterfaceEventsReplyCompletionStage.toCompletableFuture());
} catch (VppBaseCallException | TimeoutException e) {
- LOG.warn("Unable to {} interface notifications", enableDisable == 1 ? "enable" : "disable", e);
+ LOG.warn("Unable to {} interface notifications", enableDisable == 1
+ ? "enable"
+ : "disable", e);
throw new IllegalStateException("Unable to control interface notifications", e);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java
index 92eb396a8..4042dfac8 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java
@@ -16,13 +16,13 @@
package io.fd.honeycomb.translate.v3po.vpp;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
-
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.AddressTranslator;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -46,7 +46,8 @@ import org.slf4j.LoggerFactory;
* VPP.<br> Equivalent of invoking {@code vppctl set bridge-domain arp term} command.
*/
public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<ArpTerminationTableEntry, ArpTerminationTableEntryKey> {
+ implements ListWriterCustomizer<ArpTerminationTableEntry, ArpTerminationTableEntryKey>, ByteDataTranslator,
+ AddressTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ArpTerminationTableEntryCustomizer.class);
@@ -62,7 +63,7 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id,
@Nonnull final ArpTerminationTableEntry dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Creating ARP termination table entry: {} {}", id, dataAfter);
bdIpMacAddDel(id, dataAfter, writeContext, true);
@@ -79,14 +80,14 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
@Nonnull final ArpTerminationTableEntry dataAfter,
@Nonnull final WriteContext writeContext) throws WriteFailedException {
throw new UnsupportedOperationException(
- "ARP termination table entry update is not supported. It has to be deleted and then created.");
+ "ARP termination table entry update is not supported. It has to be deleted and then created.");
}
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id,
@Nonnull final ArpTerminationTableEntry dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Deleting ARP termination table entry entry: {} {}", id, dataBefore);
bdIpMacAddDel(id, dataBefore, writeContext, false);
@@ -100,23 +101,23 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
private void bdIpMacAddDel(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id,
@Nonnull final ArpTerminationTableEntry entry,
final WriteContext writeContext, boolean isAdd)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext());
final BdIpMacAddDel request = createRequest(entry, bdId, isAdd);
LOG.debug("Sending l2FibAddDel request: {}", request);
final CompletionStage<BdIpMacAddDelReply> replyCompletionStage =
- getFutureJVpp().bdIpMacAddDel(request);
+ getFutureJVpp().bdIpMacAddDel(request);
- TranslateUtils.getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
}
private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) {
final BdIpMacAddDel request = new BdIpMacAddDel();
request.bdId = bdId;
request.isAdd = booleanToByte(isAdd);
- request.macAddress = TranslateUtils.parseMac(entry.getPhysAddress().getValue());
+ request.macAddress = parseMac(entry.getPhysAddress().getValue());
final IpAddress ipAddress = entry.getIpAddress();
if (ipAddress.getIpv6Address() != null) {
@@ -124,7 +125,7 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
throw new UnsupportedOperationException("IPv6 address for ARP termination table is not supported yet");
}
- request.ipAddress = TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address()));
+ request.ipAddress = ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address()));
return request;
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java
index 83be3c62c..45d0e6460 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java
@@ -18,13 +18,13 @@ package io.fd.honeycomb.translate.v3po.vpp;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -41,8 +41,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BridgeDomainCustomizer
- extends FutureJVppCustomizer
- implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey> {
+ extends FutureJVppCustomizer
+ implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class);
@@ -51,14 +51,15 @@ public class BridgeDomainCustomizer
@GuardedBy("this")
private int bridgeDomainIndexCounter = 1;
- public BridgeDomainCustomizer(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext bdContext) {
+ public BridgeDomainCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext bdContext) {
super(futureJVppCore);
this.bdContext = Preconditions.checkNotNull(bdContext, "bdContext should not be null");
}
private BridgeDomainAddDelReply addOrUpdateBridgeDomain(@Nonnull final InstanceIdentifier<BridgeDomain> id,
final int bdId, @Nonnull final BridgeDomain bd)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final BridgeDomainAddDelReply reply;
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
@@ -69,7 +70,7 @@ public class BridgeDomainCustomizer
request.arpTerm = booleanToByte(bd.isArpTermination());
request.isAdd = ADD_OR_UPDATE_BD;
- reply = TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
+ reply = getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
LOG.debug("Bridge domain {} (id={}) add/update successful", bd.getName(), bdId);
return reply;
}
@@ -78,7 +79,7 @@ public class BridgeDomainCustomizer
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore,
@Nonnull final WriteContext ctx)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("writeCurrentAttributes: id={}, current={}, ctx={}", id, dataBefore, ctx);
final String bdName = dataBefore.getName();
@@ -113,7 +114,7 @@ public class BridgeDomainCustomizer
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore,
@Nonnull final WriteContext ctx)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx);
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
int bdId = bdContext.getIndex(bdName, ctx.getMappingContext());
@@ -122,7 +123,7 @@ public class BridgeDomainCustomizer
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
- TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
+ getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId);
} catch (VppBaseCallException e) {
LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId);
@@ -134,13 +135,13 @@ public class BridgeDomainCustomizer
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore, @Nonnull final BridgeDomain dataAfter,
@Nonnull final WriteContext ctx)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("updateCurrentAttributes: id={}, dataBefore={}, dataAfter={}, ctx={}", id, dataBefore, dataAfter,
- ctx);
+ ctx);
final String bdName = checkNotNull(dataAfter.getName());
checkArgument(bdName.equals(dataBefore.getName()),
- "BridgeDomain name changed. It should be deleted and then created.");
+ "BridgeDomain name changed. It should be deleted and then created.");
try {
addOrUpdateBridgeDomain(id, bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java
index d72d95493..29b4b939f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java
@@ -16,15 +16,14 @@
package io.fd.honeycomb.translate.v3po.vpp;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.parseMac;
-
import com.google.common.base.Preconditions;
import com.google.common.primitives.Longs;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.v3po.util.MacTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -47,7 +46,8 @@ import org.slf4j.LoggerFactory;
* VPP.<br> Equivalent of invoking {@code vppctl l2fib add/del} command.
*/
public class L2FibEntryCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<L2FibEntry, L2FibEntryKey> {
+ implements ListWriterCustomizer<L2FibEntry, L2FibEntryKey>, ByteDataTranslator, MacTranslator,
+ JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(L2FibEntryCustomizer.class);
@@ -64,7 +64,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id,
@Nonnull final L2FibEntry dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Creating L2 FIB entry: {} {}", id, dataAfter);
l2FibAddDel(id, dataAfter, writeContext, true);
@@ -80,13 +80,13 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
@Nonnull final L2FibEntry dataBefore, @Nonnull final L2FibEntry dataAfter,
@Nonnull final WriteContext writeContext) throws WriteFailedException {
throw new UnsupportedOperationException(
- "L2 FIB entry update is not supported. It has to be deleted and then created.");
+ "L2 FIB entry update is not supported. It has to be deleted and then created.");
}
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id,
@Nonnull final L2FibEntry dataBefore, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Deleting L2 FIB entry: {} {}", id, dataBefore);
l2FibAddDel(id, dataBefore, writeContext, false);
@@ -99,7 +99,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
private void l2FibAddDel(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry entry,
final WriteContext writeContext, boolean isAdd)
- throws VppBaseCallException, WriteTimeoutException {
+ throws VppBaseCallException, WriteTimeoutException {
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext());
@@ -112,9 +112,9 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
final L2FibAddDel l2FibRequest = createL2FibRequest(entry, bdId, swIfIndex, isAdd);
LOG.debug("Sending l2FibAddDel request: {}", l2FibRequest);
final CompletionStage<L2FibAddDelReply> l2FibAddDelReplyCompletionStage =
- getFutureJVpp().l2FibAddDel(l2FibRequest);
+ getFutureJVpp().l2FibAddDel(l2FibRequest);
- TranslateUtils.getReplyForWrite(l2FibAddDelReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(l2FibAddDelReplyCompletionStage.toCompletableFuture(), id);
}
private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) {
@@ -132,9 +132,9 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
// mac address is string of the form: 11:22:33:44:55:66
// but VPP expects long value in the format 11:22:33:44:55:66:XX:XX
- private static long macToLong(final String macAddress) {
+ private long macToLong(final String macAddress) {
final byte[] mac = parseMac(macAddress);
return Longs.fromBytes(mac[0], mac[1], mac[2], mac[3],
- mac[4], mac[5], (byte) 0, (byte) 0);
+ mac[4], mac[5], (byte) 0, (byte) 0);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java
index 558e6ba41..62f69d646 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java
@@ -19,7 +19,6 @@ package io.fd.honeycomb.translate.v3po.vppclassifier;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.printHexBinary;
import com.google.common.base.Optional;
import com.google.common.primitives.UnsignedInts;
@@ -27,8 +26,9 @@ import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -61,7 +61,8 @@ import org.slf4j.LoggerFactory;
* class table verbose} command.
*/
public class ClassifySessionReader extends FutureJVppCustomizer
- implements ListReaderCustomizer<ClassifySession, ClassifySessionKey, ClassifySessionBuilder>, VppNodeReader {
+ implements ListReaderCustomizer<ClassifySession, ClassifySessionKey, ClassifySessionBuilder>,
+ InterfaceDataTranslator, VppNodeReader, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ClassifySessionReader.class);
static final String CACHE_KEY = ClassifySessionReader.class.getName();
@@ -89,7 +90,7 @@ public class ClassifySessionReader extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<ClassifySession> id,
@Nonnull final ClassifySessionBuilder builder, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("Reading attributes for classify session: {}", id);
final ClassifySessionKey key = id.firstKeyOf(ClassifySession.class);
@@ -98,12 +99,13 @@ public class ClassifySessionReader extends FutureJVppCustomizer
final ClassifySessionDetailsReplyDump classifySessionDump = dumpClassifySessions(id, ctx);
final byte[] match = DatatypeConverter.parseHexBinary(key.getMatch().getValue().replace(":", ""));
final Optional<ClassifySessionDetails> classifySession =
- findClassifySessionDetailsByMatch(classifySessionDump, match);
+ findClassifySessionDetailsByMatch(classifySessionDump, match);
if (classifySession.isPresent()) {
final ClassifySessionDetails detail = classifySession.get();
builder.setHitNext(
- readVppNode(detail.tableId, detail.hitNextIndex, classifyTableContext, ctx.getMappingContext(), LOG).get());
+ readVppNode(detail.tableId, detail.hitNextIndex, classifyTableContext, ctx.getMappingContext(), LOG)
+ .get());
if (detail.opaqueIndex != ~0) {
// value is specified:
builder.setOpaqueIndex(readOpaqueIndex(detail.tableId, detail.opaqueIndex, ctx.getMappingContext()));
@@ -133,14 +135,14 @@ public class ClassifySessionReader extends FutureJVppCustomizer
@Nullable
private ClassifySessionDetailsReplyDump dumpClassifySessions(@Nonnull final InstanceIdentifier<?> id,
@Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
final ClassifyTableKey tableKey = id.firstKeyOf(ClassifyTable.class);
checkArgument(tableKey != null, "could not find ClassifyTable key in {}", id);
final String cacheKey = CACHE_KEY + tableKey;
ClassifySessionDetailsReplyDump classifySessionDump =
- (ClassifySessionDetailsReplyDump) ctx.getModificationCache().get(cacheKey);
+ (ClassifySessionDetailsReplyDump) ctx.getModificationCache().get(cacheKey);
if (classifySessionDump != null) {
LOG.debug("Classify sessions is present in cache: {}", cacheKey);
return classifySessionDump;
@@ -148,16 +150,16 @@ public class ClassifySessionReader extends FutureJVppCustomizer
final String tableName = tableKey.getName();
checkState(classifyTableContext.containsTable(tableName, ctx.getMappingContext()),
- "Reading classify sessions for table {}, but table index could not be found in the classify table context",
- tableName);
+ "Reading classify sessions for table {}, but table index could not be found in the classify table context",
+ tableName);
final int tableId = classifyTableContext.getTableIndex(tableName, ctx.getMappingContext());
LOG.debug("Dumping classify sessions for classify table id={}", tableId);
try {
final ClassifySessionDump dumpRequest = new ClassifySessionDump();
dumpRequest.tableId = tableId;
- classifySessionDump = TranslateUtils
- .getReplyForRead(getFutureJVpp().classifySessionDump(dumpRequest).toCompletableFuture(), id);
+ classifySessionDump =
+ getReplyForRead(getFutureJVpp().classifySessionDump(dumpRequest).toCompletableFuture(), id);
if (classifySessionDump != null) {
// update the cache:
@@ -171,19 +173,19 @@ public class ClassifySessionReader extends FutureJVppCustomizer
}
private static Optional<ClassifySessionDetails> findClassifySessionDetailsByMatch(
- @Nullable final ClassifySessionDetailsReplyDump classifySessionDump, @Nonnull final byte[] match) {
+ @Nullable final ClassifySessionDetailsReplyDump classifySessionDump, @Nonnull final byte[] match) {
if (classifySessionDump != null && classifySessionDump.classifySessionDetails != null) {
final List<ClassifySessionDetails> details = classifySessionDump.classifySessionDetails;
final List<ClassifySessionDetails> filteredSessions = details.stream()
- .filter(singleDetail -> Arrays.equals(singleDetail.match, match)).collect(Collectors.toList());
+ .filter(singleDetail -> Arrays.equals(singleDetail.match, match)).collect(Collectors.toList());
if (filteredSessions.isEmpty()) {
return Optional.absent();
} else if (filteredSessions.size() == 1) {
return Optional.of(filteredSessions.get(0));
} else {
throw new IllegalStateException(String.format(
- "Found %d classify sessions witch given match. Single session expected.",
- filteredSessions.size()));
+ "Found %d classify sessions witch given match. Single session expected.",
+ filteredSessions.size()));
}
}
return Optional.absent();
@@ -198,8 +200,8 @@ public class ClassifySessionReader extends FutureJVppCustomizer
final ClassifySessionDetailsReplyDump classifySessionDump = dumpClassifySessions(id, ctx);
if (classifySessionDump != null && classifySessionDump.classifySessionDetails != null) {
return classifySessionDump.classifySessionDetails.stream()
- .map(detail -> new ClassifySessionKey(new HexString(printHexBinary(detail.match))))
- .collect(Collectors.toList());
+ .map(detail -> new ClassifySessionKey(new HexString(printHexBinary(detail.match))))
+ .collect(Collectors.toList());
} else {
return Collections.emptyList();
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java
index d2029a368..e4870aecf 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java
@@ -19,12 +19,12 @@ package io.fd.honeycomb.translate.v3po.vppclassifier;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
@@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory;
* to VPP.<br> Equivalent to invoking {@code vppctl classify table} command.
*/
public class ClassifySessionWriter extends VppNodeWriter
- implements ListWriterCustomizer<ClassifySession, ClassifySessionKey> {
+ implements ListWriterCustomizer<ClassifySession, ClassifySessionKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ClassifySessionWriter.class);
private final VppClassifierContextManager classifyTableContext;
@@ -97,32 +97,32 @@ public class ClassifySessionWriter extends VppNodeWriter
private void classifyAddDelSession(final boolean isAdd, @Nonnull final InstanceIdentifier<ClassifySession> id,
@Nonnull final ClassifySession classifySession,
@Nonnull final WriteContext writeContext)
- throws VppBaseCallException, WriteFailedException {
+ throws VppBaseCallException, WriteFailedException {
final ClassifyTableKey tableKey = id.firstKeyOf(ClassifyTable.class);
checkArgument(tableKey != null, "could not find classify table key in {}", id);
final String tableName = tableKey.getName();
checkState(classifyTableContext.containsTable(tableName, writeContext.getMappingContext()),
- "Could not find classify table index for {} in the classify table context", tableName);
+ "Could not find classify table index for {} in the classify table context", tableName);
final int tableIndex = classifyTableContext.getTableIndex(tableName, writeContext.getMappingContext());
final ClassifyTable classifyTable =
- getClassifyTable(writeContext, id.firstIdentifierOf(ClassifyTable.class), isAdd);
+ getClassifyTable(writeContext, id.firstIdentifierOf(ClassifyTable.class), isAdd);
final int hitNextIndex = getNodeIndex(classifySession.getHitNext(), classifyTable, classifyTableContext,
- writeContext.getMappingContext(), id);
+ writeContext.getMappingContext(), id);
final int opaqueIndex =
- getOpaqueIndex(classifySession.getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id);
+ getOpaqueIndex(classifySession.getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id);
final CompletionStage<ClassifyAddDelSessionReply> createClassifyTableReplyCompletionStage = getFutureJVpp()
- .classifyAddDelSession(
- getClassifyAddDelSessionRequest(isAdd, classifySession, tableIndex, hitNextIndex, opaqueIndex));
+ .classifyAddDelSession(
+ getClassifyAddDelSessionRequest(isAdd, classifySession, tableIndex, hitNextIndex, opaqueIndex));
- TranslateUtils.getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id);
}
private ClassifyTable getClassifyTable(final WriteContext writeContext,
- @Nonnull final InstanceIdentifier<ClassifyTable> id,
- final boolean isAdd) {
+ @Nonnull final InstanceIdentifier<ClassifyTable> id,
+ final boolean isAdd) {
final Optional<ClassifyTable> classifyTable;
if (isAdd) {
classifyTable = writeContext.readAfter(id);
@@ -132,11 +132,11 @@ public class ClassifySessionWriter extends VppNodeWriter
return classifyTable.get();
}
- private static ClassifyAddDelSession getClassifyAddDelSessionRequest(final boolean isAdd,
- @Nonnull final ClassifySession classifySession,
- final int tableIndex,
- final int hitNextIndex,
- final int opaqueIndex) {
+ private ClassifyAddDelSession getClassifyAddDelSessionRequest(final boolean isAdd,
+ @Nonnull final ClassifySession classifySession,
+ final int tableIndex,
+ final int hitNextIndex,
+ final int opaqueIndex) {
ClassifyAddDelSession request = new ClassifyAddDelSession();
request.isAdd = booleanToByte(isAdd);
request.tableIndex = tableIndex;
@@ -152,7 +152,7 @@ public class ClassifySessionWriter extends VppNodeWriter
private int getOpaqueIndex(@Nullable final OpaqueIndex opaqueIndex, final ClassifyTable classifyTable,
final MappingContext ctx, final InstanceIdentifier<ClassifySession> id)
- throws VppBaseCallException, WriteFailedException {
+ throws VppBaseCallException, WriteFailedException {
if (opaqueIndex == null) {
return ~0; // value not specified
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java
index ad238d8bb..70af10eb7 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java
@@ -18,15 +18,16 @@ package io.fd.honeycomb.translate.v3po.vppclassifier;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.printHexBinary;
import com.google.common.base.Optional;
import com.google.common.primitives.UnsignedInts;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.v3po.util.MacTranslator;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -55,7 +56,9 @@ import org.slf4j.LoggerFactory;
* class table} command.
*/
public class ClassifyTableReader extends FutureJVppCustomizer
- implements ListReaderCustomizer<ClassifyTable, ClassifyTableKey, ClassifyTableBuilder>, VppNodeReader {
+ implements ListReaderCustomizer<ClassifyTable, ClassifyTableKey, ClassifyTableBuilder>, VppNodeReader,
+ MacTranslator,
+ InterfaceDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ClassifyTableReader.class);
private final VppClassifierContextManager classifyTableContext;
@@ -82,7 +85,7 @@ public class ClassifyTableReader extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<ClassifyTable> id,
@Nonnull final ClassifyTableBuilder builder, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("Reading attributes for classify table: {}", id);
final ClassifyTableKey key = id.firstKeyOf(ClassifyTable.class);
@@ -98,7 +101,7 @@ public class ClassifyTableReader extends FutureJVppCustomizer
try {
final ClassifyTableInfoReply reply =
- TranslateUtils.getReplyForRead(getFutureJVpp().classifyTableInfo(request).toCompletableFuture(), id);
+ getReplyForRead(getFutureJVpp().classifyTableInfo(request).toCompletableFuture(), id);
// mandatory values:
builder.setName(tableName);
@@ -108,14 +111,14 @@ public class ClassifyTableReader extends FutureJVppCustomizer
// optional value read from context
final Optional<String> tableBaseNode =
- classifyTableContext.getTableBaseNode(tableName, ctx.getMappingContext());
+ classifyTableContext.getTableBaseNode(tableName, ctx.getMappingContext());
if (tableBaseNode.isPresent()) {
builder.setClassifierNode(new VppNodeName(tableBaseNode.get()));
}
builder.setMissNext(
- readVppNode(reply.tableId, reply.missNextIndex, classifyTableContext, ctx.getMappingContext(), LOG)
- .get());
+ readVppNode(reply.tableId, reply.missNextIndex, classifyTableContext, ctx.getMappingContext(), LOG)
+ .get());
builder.setMask(new HexString(printHexBinary(reply.mask)));
builder.setActiveSessions(UnsignedInts.toLong(reply.activeSessions));
@@ -138,8 +141,9 @@ public class ClassifyTableReader extends FutureJVppCustomizer
@Nonnull final ReadContext context) throws ReadFailedException {
LOG.debug("Reading list of keys for classify tables: {}", id);
try {
- final ClassifyTableIdsReply classifyTableIdsReply = TranslateUtils
- .getReplyForRead(getFutureJVpp().classifyTableIds(new ClassifyTableIds()).toCompletableFuture(), id);
+ final ClassifyTableIdsReply classifyTableIdsReply =
+ getReplyForRead(getFutureJVpp().classifyTableIds(new ClassifyTableIds()).toCompletableFuture(),
+ id);
if (classifyTableIdsReply.ids != null) {
return Arrays.stream(classifyTableIdsReply.ids).mapToObj(i -> {
final String tableName = classifyTableContext.getTableName(i, context.getMappingContext());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java
index 3dc3cf7d1..6f4959c23 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriter.java
@@ -19,11 +19,11 @@ package io.fd.honeycomb.translate.v3po.vppclassifier;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
* VPP.<br> Equivalent to invoking {@code vppctl classify table} command.
*/
public class ClassifyTableWriter extends VppNodeWriter
- implements ListWriterCustomizer<ClassifyTable, ClassifyTableKey> {
+ implements ListWriterCustomizer<ClassifyTable, ClassifyTableKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(ClassifyTableWriter.class);
private final VppClassifierContextManager classifyTableContext;
@@ -58,14 +58,16 @@ public class ClassifyTableWriter extends VppNodeWriter
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<ClassifyTable> id,
@Nonnull final ClassifyTable dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ throws WriteFailedException {
LOG.debug("Creating classify table: iid={} dataAfter={}", id, dataAfter);
try {
final int newTableIndex =
- classifyAddDelTable(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext());
+ classifyAddDelTable(true, id, dataAfter, ~0 /* value not present */,
+ writeContext.getMappingContext());
// Add classify table name <-> vpp index mapping to the naming context:
- classifyTableContext.addTable(newTableIndex, dataAfter.getName(), dataAfter.getClassifierNode(), writeContext.getMappingContext());
+ classifyTableContext.addTable(newTableIndex, dataAfter.getName(), dataAfter.getClassifierNode(),
+ writeContext.getMappingContext());
LOG.debug("Successfully created classify table(id={]): iid={} dataAfter={}", newTableIndex, id, dataAfter);
} catch (VppBaseCallException e) {
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -86,7 +88,7 @@ public class ClassifyTableWriter extends VppNodeWriter
LOG.debug("Removing classify table: iid={} dataBefore={}", id, dataBefore);
final String tableName = dataBefore.getName();
checkState(classifyTableContext.containsTable(tableName, writeContext.getMappingContext()),
- "Removing classify table {}, but index could not be found in the classify table context", tableName);
+ "Removing classify table {}, but index could not be found in the classify table context", tableName);
final int tableIndex = classifyTableContext.getTableIndex(tableName, writeContext.getMappingContext());
try {
@@ -102,17 +104,17 @@ public class ClassifyTableWriter extends VppNodeWriter
private int classifyAddDelTable(final boolean isAdd, @Nonnull final InstanceIdentifier<ClassifyTable> id,
@Nonnull final ClassifyTable table, final int tableId, final MappingContext ctx)
- throws VppBaseCallException, WriteFailedException {
+ throws VppBaseCallException, WriteFailedException {
final int missNextIndex =
- getNodeIndex(table.getMissNext(), table, classifyTableContext, ctx, id);
+ getNodeIndex(table.getMissNext(), table, classifyTableContext, ctx, id);
final CompletionStage<ClassifyAddDelTableReply> createClassifyTableReplyCompletionStage =
- getFutureJVpp()
- .classifyAddDelTable(getClassifyAddDelTableRequest(isAdd, tableId, table, missNextIndex, ctx));
+ getFutureJVpp()
+ .classifyAddDelTable(getClassifyAddDelTableRequest(isAdd, tableId, table, missNextIndex, ctx));
final ClassifyAddDelTableReply reply =
- TranslateUtils.getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id);
+ getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id);
return reply.newTableIndex;
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java
index a4667bf4d..abc49cccb 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java
@@ -20,8 +20,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.ReadTimeoutException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
@@ -33,7 +33,7 @@ import org.openvpp.jvpp.core.dto.GetNextIndex;
import org.openvpp.jvpp.core.dto.GetNextIndexReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-abstract class VppNodeWriter extends FutureJVppCustomizer {
+abstract class VppNodeWriter extends FutureJVppCustomizer implements JvppReplyConsumer {
protected VppNodeWriter(@Nonnull final FutureJVppCore futureJvpp) {
super(futureJvpp);
@@ -42,35 +42,37 @@ abstract class VppNodeWriter extends FutureJVppCustomizer {
protected int getNodeIndex(@Nonnull final VppNode node, @Nonnull final ClassifyTable classifyTable,
@Nonnull final VppClassifierContextManager vppClassifierContextManager,
@Nonnull final MappingContext ctx, @Nonnull final InstanceIdentifier<?> id)
- throws VppBaseCallException, WriteFailedException {
+ throws VppBaseCallException, WriteFailedException {
if (node.getPacketHandlingAction() != null) {
return node.getPacketHandlingAction().getIntValue();
} else {
- return nodeNameToIndex(classifyTable, node.getVppNodeName().getValue(), vppClassifierContextManager, ctx, id);
+ return nodeNameToIndex(classifyTable, node.getVppNodeName().getValue(), vppClassifierContextManager, ctx,
+ id);
}
}
private int nodeNameToIndex(@Nonnull final ClassifyTable classifyTable, @Nonnull final String nextNodeName,
@Nonnull final VppClassifierContextManager vppClassifierContextManager,
@Nonnull final MappingContext ctx, @Nonnull final InstanceIdentifier<?> id)
- throws VppBaseCallException, WriteFailedException {
- checkArgument(classifyTable != null && classifyTable.getClassifierNode() != null, "to use relative node names, table classifier node needs to be provided");
+ throws VppBaseCallException, WriteFailedException {
+ checkArgument(classifyTable != null && classifyTable.getClassifierNode() != null,
+ "to use relative node names, table classifier node needs to be provided");
final GetNextIndex request = new GetNextIndex();
request.nodeName = classifyTable.getClassifierNode().getValue().getBytes();
request.nextName = nextNodeName.getBytes();
final CompletionStage<GetNextIndexReply> getNextIndexCompletionStage =
- getFutureJVpp().getNextIndex(request);
+ getFutureJVpp().getNextIndex(request);
final GetNextIndexReply reply;
try {
- reply = TranslateUtils.getReplyForRead(getNextIndexCompletionStage.toCompletableFuture(), id);
+ reply = getReplyForRead(getNextIndexCompletionStage.toCompletableFuture(), id);
// vpp does not provide relative node index to node name conversion (https://jira.fd.io/browse/VPP-219)
// as a workaround we need to add mapping to vpp-classfier-context
vppClassifierContextManager.addNodeName(classifyTable.getName(), reply.nextIndex, nextNodeName, ctx);
} catch (ReadTimeoutException e) {
throw new WriteFailedException(id, String.format("Failed to get node index for %s relative to %s",
- nextNodeName, classifyTable.getClassifierNode()), e);
+ nextNodeName, classifyTable.getClassifierNode()), e);
}
return reply.nextIndex;
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizer.java
index d254a7912..fcf0ff16a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizer.java
@@ -16,13 +16,12 @@
package io.fd.honeycomb.translate.v3po.vppstate;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.byteToBoolean;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.util.ArrayList;
@@ -44,12 +43,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class BridgeDomainCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> {
+ implements ListReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder>, ByteDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class);
private final NamingContext bdContext;
- public BridgeDomainCustomizer(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext bdContext) {
+ public BridgeDomainCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext bdContext) {
super(futureJVppCore);
this.bdContext = Preconditions.checkNotNull(bdContext, "bdContext should not be null");
}
@@ -57,9 +57,9 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomainBuilder builder, @Nonnull final ReadContext context)
- throws ReadFailedException {
+ throws ReadFailedException {
LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: id={}, builderbuilder={}, context={}",
- id, builder, context);
+ id, builder, context);
final BridgeDomainKey key = id.firstKeyOf(id.getTargetType());
LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: key={}", key);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java
index 2de19a1c1..e03b95f1a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java
@@ -16,19 +16,17 @@
package io.fd.honeycomb.translate.v3po.vppstate;
-import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.vppPhysAddrToYang;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.byteToBoolean;
-
import com.google.common.base.Preconditions;
import com.google.common.primitives.Longs;
import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.ReadTimeoutException;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -56,12 +54,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class L2FibEntryCustomizer extends FutureJVppCustomizer
- implements ListReaderCustomizer<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder> {
+ implements ListReaderCustomizer<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder>, ByteDataTranslator,
+ InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(L2FibEntryCustomizer.class);
private static final Collector<L2FibTableEntry, ?, L2FibTableEntry> SINGLE_ITEM_COLLECTOR =
- RWUtils.singleItemCollector();
+ RWUtils.singleItemCollector();
private final NamingContext bdContext;
private final NamingContext interfaceContext;
@@ -76,7 +75,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id,
@Nonnull final L2FibEntryBuilder builder, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ throws ReadFailedException {
final L2FibEntryKey key = id.firstKeyOf(id.getTargetType());
final BridgeDomainKey bridgeDomainKey = id.firstKeyOf(BridgeDomain.class);
@@ -86,12 +85,12 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
try {
// TODO HONEYCOMB-186 use cached l2FibTable
final L2FibTableEntry entry = dumpL2Fibs(id, bdId).stream().filter(e -> key.getPhysAddress()
- .equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2))))
- .collect(SINGLE_ITEM_COLLECTOR);
+ .equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2))))
+ .collect(SINGLE_ITEM_COLLECTOR);
builder.setAction(byteToBoolean(entry.filterMac)
- ? L2FibFilter.class
- : L2FibForward.class);
+ ? L2FibFilter.class
+ : L2FibForward.class);
builder.setBridgedVirtualInterface(byteToBoolean(entry.bviMac));
if (entry.swIfIndex != -1) {
@@ -107,14 +106,14 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
@Nonnull
private List<L2FibTableEntry> dumpL2Fibs(final InstanceIdentifier<L2FibEntry> id, final int bdId)
- throws VppBaseCallException, ReadTimeoutException {
+ throws VppBaseCallException, ReadTimeoutException {
final L2FibTableDump l2FibRequest = new L2FibTableDump();
l2FibRequest.bdId = bdId;
final CompletableFuture<L2FibTableEntryReplyDump> l2FibTableDumpCompletableFuture =
- getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture();
+ getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture();
- final L2FibTableEntryReplyDump dump = TranslateUtils.getReplyForRead(l2FibTableDumpCompletableFuture, id);
+ final L2FibTableEntryReplyDump dump = getReplyForRead(l2FibTableDumpCompletableFuture, id);
if (null == dump || null == dump.l2FibTableEntry) {
return Collections.emptyList();
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java
index eedf7642f..6c2b1833b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java
@@ -19,8 +19,9 @@ package io.fd.honeycomb.translate.v3po.vppstate;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;
@@ -35,8 +36,8 @@ import org.openvpp.jvpp.core.dto.ShowVersionReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
public final class VersionCustomizer
- extends FutureJVppCustomizer
- implements ReaderCustomizer<Version, VersionBuilder> {
+ extends FutureJVppCustomizer
+ implements ReaderCustomizer<Version, VersionBuilder>, ByteDataTranslator, JvppReplyConsumer {
public VersionCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
super(futureJVppCore);
@@ -59,12 +60,12 @@ public final class VersionCustomizer
try {
// Execute with timeout
final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion());
- final ShowVersionReply reply = TranslateUtils.getReplyForRead(showVersionFuture.toCompletableFuture(), id);
+ final ShowVersionReply reply = getReplyForRead(showVersionFuture.toCompletableFuture(), id);
- builder.setBranch(TranslateUtils.toString(reply.version));
- builder.setName(TranslateUtils.toString(reply.program));
- builder.setBuildDate(TranslateUtils.toString(reply.buildDate));
- builder.setBuildDirectory(TranslateUtils.toString(reply.buildDirectory));
+ builder.setBranch(toString(reply.version));
+ builder.setName(toString(reply.program));
+ builder.setBuildDate(toString(reply.buildDate));
+ builder.setBuildDirectory(toString(reply.buildDirectory));
} catch (VppBaseCallException e) {
throw new ReadFailedException(id, e);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/DisabledInterfacesManagerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/DisabledInterfacesManagerTest.java
index 7381533e5..52a7a5c2d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/DisabledInterfacesManagerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/DisabledInterfacesManagerTest.java
@@ -16,6 +16,9 @@
package io.fd.honeycomb.translate.v3po;
+
+
+
import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceTypeTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceTypeTestUtils.java
index 0dabe1468..9ff5b1b2d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceTypeTestUtils.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceTypeTestUtils.java
@@ -19,8 +19,8 @@ package io.fd.honeycomb.translate.v3po.interfaces;
import static org.mockito.Mockito.doReturn;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.write.WriteContext;
import org.mockito.Matchers;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
index 0c1d2d72f..a47f5b641 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
@@ -30,8 +30,8 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Test;
@@ -53,30 +53,30 @@ import org.openvpp.jvpp.core.dto.DeleteVhostUserIfReply;
import org.openvpp.jvpp.core.dto.ModifyVhostUserIf;
import org.openvpp.jvpp.core.dto.ModifyVhostUserIfReply;
-public class VhostUserCustomizerTest extends WriterCustomizerTest {
+public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
private VhostUserCustomizer customizer;
private static final int IFACE_ID = 1;
private static final String IFACE_NAME = "eth0";
private static final InstanceIdentifier<VhostUser> ID =
- InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
- .augmentation(VppInterfaceAugmentation.class).child(VhostUser.class);
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(VhostUser.class);
@Override
public void setUp() throws Exception {
InterfaceTypeTestUtils.setupWriteContext(writeContext,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class);
customizer = new VhostUserCustomizer(api, new NamingContext("generatedInterfaceName", "test-instance"));
}
private CreateVhostUserIf verifyCreateVhostUserIfWasInvoked(final VhostUser vhostUser)
- throws VppInvocationException {
+ throws VppInvocationException {
ArgumentCaptor<CreateVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(CreateVhostUserIf.class);
verify(api).createVhostUserIf(argumentCaptor.capture());
final CreateVhostUserIf actual = argumentCaptor.getValue();
assertEquals(0, actual.customDevInstance);
- assertEquals(TranslateUtils.booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole())), actual.isServer);
+ assertEquals(booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole())), actual.isServer);
assertEquals(0, actual.renumber);
assertEquals(0, actual.useCustomMac);
assertArrayEquals(vhostUser.getSocket().getBytes(), actual.sockFilename);
@@ -85,13 +85,13 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
}
private ModifyVhostUserIf verifyModifyVhostUserIfWasInvoked(final VhostUser vhostUser, final int swIfIndex)
- throws VppInvocationException {
+ throws VppInvocationException {
ArgumentCaptor<ModifyVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(ModifyVhostUserIf.class);
verify(api).modifyVhostUserIf(argumentCaptor.capture());
final ModifyVhostUserIf actual = argumentCaptor.getValue();
assertEquals(0, actual.customDevInstance);
- assertEquals(TranslateUtils.booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole())), actual.isServer);
+ assertEquals(booleanToByte(VhostUserRole.Server.equals(vhostUser.getRole())), actual.isServer);
assertEquals(0, actual.renumber);
assertEquals(swIfIndex, actual.swIfIndex);
assertArrayEquals(vhostUser.getSocket().getBytes(), actual.sockFilename);
@@ -122,7 +122,7 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
verifyCreateVhostUserIfWasInvoked(vhostUser);
verify(mappingContext).put(eq(ContextTestUtils.getMappingIid(IFACE_NAME, "test-instance")), eq(
- ContextTestUtils.getMapping(IFACE_NAME, 0).get()));
+ ContextTestUtils.getMapping(IFACE_NAME, 0).get()));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
index 745276473..416468300 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
@@ -24,8 +24,8 @@ import static org.mockito.Mockito.when;
import com.google.common.io.BaseEncoding;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import org.junit.Before;
@@ -45,7 +45,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.core.dto.IpNeighborAddDel;
import org.openvpp.jvpp.core.dto.IpNeighborAddDelReply;
-public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest {
+public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "parent";
@@ -85,7 +85,7 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest {
assertEquals(0, request.isIpv6);
assertEquals(1, request.isAdd);
assertEquals(1, request.isStatic);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.dstAddress).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.dstAddress).getValue());
assertEquals("aabbccee1122", BaseEncoding.base16().lowerCase().encode(request.macAddress));
assertEquals(5, request.swIfIndex);
}
@@ -111,7 +111,7 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest {
assertEquals(0, request.isIpv6);
assertEquals(0, request.isAdd);
assertEquals(1, request.isStatic);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.dstAddress).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.dstAddress).getValue());
assertEquals("aabbccee1122", BaseEncoding.base16().lowerCase().encode(request.macAddress));
assertEquals(5, request.swIfIndex);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
index acc407bd3..5c6f88abd 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
@@ -49,7 +49,7 @@ import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.core.dto.SwInterfaceDump;
public class InterfaceCustomizerTest extends
- ListReaderCustomizerTest<Interface, InterfaceKey, InterfaceBuilder> {
+ ListReaderCustomizerTest<Interface, InterfaceKey, InterfaceBuilder> implements InterfaceDataTranslator {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE0_NAME = "eth0";
@@ -96,23 +96,23 @@ public class InterfaceCustomizerTest extends
private void verifySwInterfaceDumpWasInvoked(final int nameFilterValid, final String ifaceName,
final int dumpIfcsInvocationCount)
- throws VppInvocationException {
+ throws VppInvocationException {
final SwInterfaceDump expected = new SwInterfaceDump();
- expected.nameFilterValid = (byte)nameFilterValid;
+ expected.nameFilterValid = (byte) nameFilterValid;
expected.nameFilter = ifaceName.getBytes();
verify(api, times(dumpIfcsInvocationCount)).swInterfaceDump(expected);
}
- private static void assertIfacesAreEqual(final Interface iface, final SwInterfaceDetails details) {
+ private void assertIfacesAreEqual(final Interface iface, final SwInterfaceDetails details) {
assertEquals(iface.getName(), new String(details.interfaceName));
- Assert.assertEquals(InterfaceUtils.yangIfIndexToVpp(iface.getIfIndex().intValue()), details.swIfIndex);
- assertEquals(iface.getPhysAddress().getValue(), InterfaceUtils.vppPhysAddrToYang(details.l2Address));
+ Assert.assertEquals(yangIfIndexToVpp(iface.getIfIndex().intValue()), details.swIfIndex);
+ assertEquals(iface.getPhysAddress().getValue(), vppPhysAddrToYang(details.l2Address));
}
@Test
public void testReadCurrentAttributes() throws Exception {
final InstanceIdentifier<Interface> id = InstanceIdentifier.create(InterfacesState.class)
- .child(Interface.class, new InterfaceKey(IFACE0_NAME));
+ .child(Interface.class, new InterfaceKey(IFACE0_NAME));
final InterfaceBuilder builder = getCustomizer().getBuilder(id);
final SwInterfaceDetails iface = new SwInterfaceDetails();
@@ -134,7 +134,7 @@ public class InterfaceCustomizerTest extends
public void testReadCurrentAttributesFailed() throws Exception {
final String ifaceName = IFACE0_NAME;
final InstanceIdentifier<Interface> id = InstanceIdentifier.create(InterfacesState.class)
- .child(Interface.class, new InterfaceKey(ifaceName));
+ .child(Interface.class, new InterfaceKey(ifaceName));
final InterfaceBuilder builder = getCustomizer().getBuilder(id);
whenSwInterfaceDumpThenReturn(Collections.emptyList());
@@ -152,7 +152,7 @@ public class InterfaceCustomizerTest extends
@Test
public void testReadSubInterface() throws Exception {
final InstanceIdentifier<Interface> id = InstanceIdentifier.create(InterfacesState.class)
- .child(Interface.class, new InterfaceKey(SUB_IFACE_NAME));
+ .child(Interface.class, new InterfaceKey(SUB_IFACE_NAME));
final InterfaceBuilder builder = mock(InterfaceBuilder.class);
final SwInterfaceDetails iface = new SwInterfaceDetails();
@@ -172,7 +172,7 @@ public class InterfaceCustomizerTest extends
@Test
public void testGetAllIds() throws Exception {
final InstanceIdentifier<Interface> id = InstanceIdentifier.create(InterfacesState.class)
- .child(Interface.class);
+ .child(Interface.class);
final SwInterfaceDetails swIf0 = new SwInterfaceDetails();
swIf0.swIfIndex = 0;
@@ -188,7 +188,7 @@ public class InterfaceCustomizerTest extends
whenSwInterfaceDumpThenReturn(Arrays.asList(swIf0, swIf1, swSubIf1));
final List<InterfaceKey> expectedIds = Arrays.asList(new InterfaceKey(IFACE0_NAME), new InterfaceKey(
- IFACE1_NAME));
+ IFACE1_NAME));
final List<InterfaceKey> actualIds = getCustomizer().getAllIds(id, ctx);
verifySwInterfaceDumpWasInvoked(0, "", 1);
@@ -200,7 +200,7 @@ public class InterfaceCustomizerTest extends
@Test
public void testGetAllIdsWithDisabled() throws Exception {
final InstanceIdentifier<Interface> id = InstanceIdentifier.create(InterfacesState.class)
- .child(Interface.class);
+ .child(Interface.class);
doReturn(true).when(interfaceDisableContext).isInterfaceDisabled(1, mappingContext);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceUtilsTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslatorTest.java
index c74e1ccfb..56567f282 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceUtilsTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslatorTest.java
@@ -25,31 +25,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
-public class InterfaceUtilsTest {
+public class InterfaceDataTranslatorTest implements InterfaceDataTranslator {
@Test
public void testVppPhysAddrToYang() throws Exception {
- assertEquals("01:02:03:04:05:06", InterfaceUtils.vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5, 6}));
- assertEquals("0a:0b:0c:0d:0e:0f", InterfaceUtils.vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0}));
+ assertEquals("01:02:03:04:05:06", vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5, 6}));
+ assertEquals("0a:0b:0c:0d:0e:0f", vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0}));
}
@Test(expected = NullPointerException.class)
public void testVppPhysAddrToYangFailNullArgument() throws Exception {
- InterfaceUtils.vppPhysAddrToYang(null);
+ vppPhysAddrToYang(null);
}
@Test(expected = IllegalArgumentException.class)
public void testVppPhysAddrToYangInvalidByteArrayLength() throws Exception {
- InterfaceUtils.vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5});
+ vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5});
}
@Test
public void testGetInterfaceType() {
- assertEquals(Tap.class, InterfaceUtils.getInterfaceType("tap0"));
- assertEquals(VxlanTunnel.class, InterfaceUtils.getInterfaceType("vxlan0"));
- assertEquals(VxlanGpeTunnel.class, InterfaceUtils.getInterfaceType("vxlan_gpe0"));
- assertEquals(VhostUser.class, InterfaceUtils.getInterfaceType("VirtualEthernet0/0/0"));
- assertEquals(EthernetCsmacd.class, InterfaceUtils.getInterfaceType("eth0.0"));
- assertEquals(EthernetCsmacd.class, InterfaceUtils.getInterfaceType("local0"));
+ assertEquals(Tap.class, getInterfaceType("tap0"));
+ assertEquals(VxlanTunnel.class, getInterfaceType("vxlan0"));
+ assertEquals(VxlanGpeTunnel.class, getInterfaceType("vxlan_gpe0"));
+ assertEquals(VhostUser.class, getInterfaceType("VirtualEthernet0/0/0"));
+ assertEquals(EthernetCsmacd.class, getInterfaceType("eth0.0"));
+ assertEquals(EthernetCsmacd.class, getInterfaceType("local0"));
}
} \ No newline at end of file
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
index be0ef14df..d351d2402 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
@@ -16,12 +16,11 @@
package io.fd.honeycomb.translate.v3po.interfacesstate.ip;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.reverseBytes;
-import static org.hamcrest.CoreMatchers.is;
+
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
@@ -29,13 +28,14 @@ import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
-import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matchers;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
@@ -54,13 +54,15 @@ import org.openvpp.jvpp.core.dto.IpAddressDetails;
import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
import org.openvpp.jvpp.core.dto.IpAddressDump;
-public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, AddressKey, AddressBuilder> {
+public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, AddressKey, AddressBuilder> implements
+ Ipv4Translator {
private static final String IFACE_NAME = "eth0";
private static final String IFACE_2_NAME = "eth1";
private static final int IFACE_ID = 1;
private static final int IFACE_2_ID = 2;
private static final String IFC_CTX_NAME = "ifc-test-instance";
+ public static final String CACHE_KEY = Ipv4AddressCustomizer.class.getName();
private NamingContext interfacesContext;
@@ -90,63 +92,44 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
}
@Test
- public void testReadCurrentAttributesFromCache() throws ReadFailedException {
- ModificationCache cache = new ModificationCache();
-
- IpAddressDetails detail1 = new IpAddressDetails();
- IpAddressDetails detail2 = new IpAddressDetails();
- IpAddressDetails detail3 = new IpAddressDetails();
-
- detail1.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
- detail2.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
- detail3.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.3"))));
-
- IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
- reply.ipAddressDetails = ImmutableList.of(detail1, detail2, detail3);
-
- cache.put(Ipv4ReadUtils.CACHE_KEY + IFACE_NAME, reply);
- when(ctx.getModificationCache()).thenReturn(cache);
-
- final AddressBuilder builder = new AddressBuilder();
- final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
-
- getCustomizer().readCurrentAttributes(id, builder, ctx);
-
- assertEquals("192.168.2.1", builder.getIp().getValue());
- }
-
- @Test
public void testReadCurrentAttributesFor2Ifcs() throws ReadFailedException {
- ModificationCache cache = new ModificationCache();
+ //changed to mock to not store first dumped data(otherwise that double thenReturn on line 118 is not gonna work)
+ ModificationCache cache = mock(ModificationCache.class);
IpAddressDetails detail1 = new IpAddressDetails();
IpAddressDetails detail2 = new IpAddressDetails();
detail1.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
detail2.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
reply.ipAddressDetails = ImmutableList.of(detail1);
IpAddressDetailsReplyDump reply2 = new IpAddressDetailsReplyDump();
reply2.ipAddressDetails = ImmutableList.of(detail2);
- when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future(reply)).thenReturn(future(reply2));
+ CompletableFuture<IpAddressDetailsReplyDump> future = new CompletableFuture<>();
+ future.complete(reply);
+ CompletableFuture<IpAddressDetailsReplyDump> future2 = new CompletableFuture<>();
+ future2.complete(reply2);
+
+ when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future).thenReturn(future2)
+ .thenReturn(future).thenReturn(future2);
+ when(api.ipAddressDump(Mockito.any(IpAddressDump.class))).thenReturn(future(reply)).thenReturn(future(reply2))
+ .thenReturn(future(reply)).thenReturn(future(reply2));
when(ctx.getModificationCache()).thenReturn(cache);
+
final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
final InstanceIdentifier<Address> id2 = getId("192.168.2.2", IFACE_2_NAME);
final List<AddressKey> ifc1Ids = getCustomizer().getAllIds(id, ctx);
assertThat(ifc1Ids.size(), is(1));
- assertThat(ifc1Ids, CoreMatchers.hasItem(new AddressKey(new Ipv4AddressNoZone("192.168.2.1"))));
+ assertThat(ifc1Ids, Matchers.hasItem(new AddressKey(new Ipv4AddressNoZone("192.168.2.1"))));
final List<AddressKey> ifc2Ids = getCustomizer().getAllIds(id2, ctx);
assertThat(ifc2Ids.size(), is(1));
- assertThat(ifc2Ids, CoreMatchers.hasItem(new AddressKey(new Ipv4AddressNoZone("192.168.2.2"))));
+ assertThat(ifc2Ids, Matchers.hasItem(new AddressKey(new Ipv4AddressNoZone("192.168.2.2"))));
AddressBuilder builder = new AddressBuilder();
getCustomizer().readCurrentAttributes(id, builder, ctx);
@@ -157,7 +140,7 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
}
@Test
- public void testReadCurrentAttributesFromOperationalData() throws ReadFailedException {
+ public void testReadCurrentAttributesSuccessfull() throws ReadFailedException {
ModificationCache cache = new ModificationCache();
IpAddressDetails detail1 = new IpAddressDetails();
@@ -165,11 +148,11 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
IpAddressDetails detail3 = new IpAddressDetails();
detail1.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
detail2.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
detail3.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.3"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.3"))));
IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
reply.ipAddressDetails = ImmutableList.of(detail1, detail2, detail3);
@@ -185,41 +168,7 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
}
@Test
- public void testGetAllIdsFromCache() throws ReadFailedException {
- ModificationCache cache = new ModificationCache();
-
- IpAddressDetails detail1 = new IpAddressDetails();
- IpAddressDetails detail2 = new IpAddressDetails();
- IpAddressDetails detail3 = new IpAddressDetails();
-
- detail1.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
- detail2.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
- detail3.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.3"))));
-
- IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
- reply.ipAddressDetails = ImmutableList.of(detail1, detail2, detail3);
-
- cache.put(Ipv4ReadUtils.CACHE_KEY + IFACE_NAME, reply);
- when(ctx.getModificationCache()).thenReturn(cache);
-
- final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
-
- List<Ipv4AddressNoZone> ids = getCustomizer().getAllIds(id, ctx).stream()
- .map(key -> key.getIp())
- .collect(Collectors.toList());
-
- verify(api, times(0)).ipAddressDump(Mockito.any(IpAddressDump.class));
- assertEquals(3, ids.size());
- assertEquals(true, "192.168.2.1".equals(ids.get(0).getValue()));
- assertEquals(true, "192.168.2.2".equals(ids.get(1).getValue()));
- assertEquals(true, "192.168.2.3".equals(ids.get(2).getValue()));
- }
-
- @Test
- public void testGetAllIdsFromOperationalData() throws ReadFailedException {
+ public void testGetAllIdsFromSuccessfull() throws ReadFailedException {
ModificationCache cache = new ModificationCache();
IpAddressDetails detail1 = new IpAddressDetails();
@@ -227,11 +176,11 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
IpAddressDetails detail3 = new IpAddressDetails();
detail1.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.1"))));
detail2.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.2"))));
detail3.ip = reverseBytes(
- TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.3"))));
+ ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(new Ipv4Address("192.168.2.3"))));
IpAddressDetailsReplyDump reply = new IpAddressDetailsReplyDump();
reply.ipAddressDetails = ImmutableList.of(detail1, detail2, detail3);
@@ -241,8 +190,8 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
final InstanceIdentifier<Address> id = getId("192.168.2.1", IFACE_NAME);
List<Ipv4AddressNoZone> ids = getCustomizer().getAllIds(id, ctx).stream()
- .map(key -> key.getIp())
- .collect(Collectors.toList());
+ .map(key -> key.getIp())
+ .collect(Collectors.toList());
assertEquals(3, ids.size());
assertEquals(true, "192.168.2.1".equals(ids.get(0).getValue()));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
index 6029f3faf..f41448bf0 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
@@ -16,7 +16,6 @@
package io.fd.honeycomb.translate.v3po.vpp;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
@@ -25,6 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
@@ -40,7 +40,7 @@ import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.BridgeDomainAddDel;
import org.openvpp.jvpp.core.dto.BridgeDomainAddDelReply;
-public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
+public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
private static final String BD_CTX_NAME = "bd-test-instance";
private static final byte ADD_OR_UPDATE_BD = (byte) 1;
@@ -53,7 +53,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
@Nullable
private static Boolean intToBoolean(final int value) {
- if (value == 0) {
+ if (value == 0) {
return Boolean.FALSE;
}
if (value == 1) {
@@ -63,7 +63,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
}
private static KeyedInstanceIdentifier<BridgeDomain, BridgeDomainKey> bdIdentifierForName(
- final String bdName) {
+ final String bdName) {
return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName));
}
@@ -79,17 +79,17 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
private BridgeDomain generateBridgeDomain(final String bdName, final int arpTerm, final int flood,
final int forward, final int learn, final int uuf) {
return new BridgeDomainBuilder()
- .setName(bdName)
- .setArpTermination(intToBoolean(arpTerm))
- .setFlood(intToBoolean(flood))
- .setForward(intToBoolean(forward))
- .setLearn(intToBoolean(learn))
- .setUnknownUnicastFlood(intToBoolean(uuf))
- .build();
+ .setName(bdName)
+ .setArpTermination(intToBoolean(arpTerm))
+ .setFlood(intToBoolean(flood))
+ .setForward(intToBoolean(forward))
+ .setLearn(intToBoolean(learn))
+ .setUnknownUnicastFlood(intToBoolean(uuf))
+ .build();
}
private void verifyBridgeDomainAddOrUpdateWasInvoked(final BridgeDomain bd, final int bdId)
- throws VppInvocationException {
+ throws VppInvocationException {
final BridgeDomainAddDel expected = new BridgeDomainAddDel();
expected.arpTerm = booleanToByte(bd.isArpTermination());
expected.flood = booleanToByte(bd.isFlood());
@@ -128,7 +128,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
verify(mappingContext).put(
- ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
+ ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
}
@Test
@@ -144,7 +144,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
verify(mappingContext).put(
- ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
+ ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
}
@Test
@@ -226,16 +226,16 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
final byte uufBefore = 0;
final BridgeDomain dataBefore =
- generateBridgeDomain(bdName, arpTermBefore, floodBefore, forwardBefore, learnBefore, uufBefore);
+ generateBridgeDomain(bdName, arpTermBefore, floodBefore, forwardBefore, learnBefore, uufBefore);
final BridgeDomain dataAfter =
- generateBridgeDomain(bdName, arpTermBefore ^ 1, floodBefore ^ 1, forwardBefore ^ 1, learnBefore ^ 1,
- uufBefore ^ 1);
+ generateBridgeDomain(bdName, arpTermBefore ^ 1, floodBefore ^ 1, forwardBefore ^ 1, learnBefore ^ 1,
+ uufBefore ^ 1);
whenBridgeDomainAddDelThenSuccess();
customizer
- .updateCurrentAttributes(bdIdentifierForName(bdName), dataBefore, dataAfter,
- writeContext);
+ .updateCurrentAttributes(bdIdentifierForName(bdName), dataBefore, dataAfter,
+ writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(dataAfter, bdId);
}
@@ -248,8 +248,8 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
try {
customizer
- .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter,
- writeContext);
+ .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter,
+ writeContext);
} catch (IllegalArgumentException e) {
verify(api, never()).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
return;
@@ -269,8 +269,8 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
try {
customizer
- .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter,
- writeContext);
+ .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter,
+ writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
verifyBridgeDomainAddOrUpdateWasInvoked(bdAfter, bdId);
return;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
index 728ba9306..174e27215 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
@@ -62,14 +62,14 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
customizer = new L2FibEntryCustomizer(
- api,
- new NamingContext("generatedBdName", BD_CTX_NAME),
- new NamingContext("generatedIfaceName", IFC_CTX_NAME));
+ api,
+ new NamingContext("generatedBdName", BD_CTX_NAME),
+ new NamingContext("generatedIfaceName", IFC_CTX_NAME));
}
private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final PhysAddress address) {
return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME))
- .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address));
+ .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address));
}
private void whenL2FibAddDelThenSuccess() {
@@ -105,7 +105,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
}
private void verifyL2FibAddDelWasInvoked(final L2FibAddDel expected) throws
- VppInvocationException {
+ VppInvocationException {
ArgumentCaptor<L2FibAddDel> argumentCaptor = ArgumentCaptor.forClass(L2FibAddDel.class);
verify(api).l2FibAddDel(argumentCaptor.capture());
final L2FibAddDel actual = argumentCaptor.getValue();
@@ -153,7 +153,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test(expected = UnsupportedOperationException.class)
public void testUpdate() throws Exception {
customizer.updateCurrentAttributes(InstanceIdentifier.create(L2FibEntry.class), mock(L2FibEntry.class),
- mock(L2FibEntry.class), writeContext);
+ mock(L2FibEntry.class), writeContext);
}
@Test
diff --git a/vpp-common/minimal-distribution/pom.xml b/vpp-common/minimal-distribution/pom.xml
index 17d8a22a7..12d11ec1a 100644
--- a/vpp-common/minimal-distribution/pom.xml
+++ b/vpp-common/minimal-distribution/pom.xml
@@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/vpp-common/vpp-translate-test/pom.xml b/vpp-common/vpp-translate-test/pom.xml
index 0fb5fb192..bef9a3014 100644
--- a/vpp-common/vpp-translate-test/pom.xml
+++ b/vpp-common/vpp-translate-test/pom.xml
@@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>compile</scope>
</dependency>
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java
index 4c6810925..3637ee2c8 100644
--- a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java
@@ -22,6 +22,8 @@ import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.vpp.test.util.FutureProducer;
import org.junit.Before;
import org.junit.Test;
diff --git a/vpp-common/vpp-translate-utils/pom.xml b/vpp-common/vpp-translate-utils/pom.xml
index e8c4d12e2..3b61f5cdf 100644
--- a/vpp-common/vpp-translate-utils/pom.xml
+++ b/vpp-common/vpp-translate-utils/pom.xml
@@ -78,7 +78,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AbstractInterfaceTypeCustomizer.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AbstractInterfaceTypeCustomizer.java
index dd66f7225..35eb1ad40 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AbstractInterfaceTypeCustomizer.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AbstractInterfaceTypeCustomizer.java
@@ -35,7 +35,7 @@ import org.openvpp.jvpp.core.future.FutureJVppCore;
* Validates the type of interface.
*/
public abstract class AbstractInterfaceTypeCustomizer<D extends DataObject>
- extends FutureJVppCustomizer implements WriterCustomizer<D> {
+ extends FutureJVppCustomizer implements WriterCustomizer<D> {
protected AbstractInterfaceTypeCustomizer(final FutureJVppCore futureJVppCore) {
super(futureJVppCore);
@@ -46,13 +46,13 @@ public abstract class AbstractInterfaceTypeCustomizer<D extends DataObject>
final InstanceIdentifier<Interface> ifcTypeFromIid = id.firstIdentifierOf(Interface.class);
checkArgument(ifcTypeFromIid != null, "Instance identifier does not contain {} type", Interface.class);
checkArgument(id.firstKeyOf(Interface.class) != null, "Instance identifier does not contain keyed {} type",
- Interface.class);
+ Interface.class);
final Optional<Interface> interfaceConfig = writeContext.readAfter(ifcTypeFromIid);
checkState(interfaceConfig.isPresent(),
- "Unable to get Interface configuration for an interface: %s currently being updated", ifcTypeFromIid);
+ "Unable to get Interface configuration for an interface: %s currently being updated", ifcTypeFromIid);
IllegalInterfaceTypeException
- .checkInterfaceType(interfaceConfig.get(), getExpectedInterfaceType());
+ .checkInterfaceType(interfaceConfig.get(), getExpectedInterfaceType());
}
protected abstract Class<? extends InterfaceType> getExpectedInterfaceType();
@@ -62,14 +62,14 @@ public abstract class AbstractInterfaceTypeCustomizer<D extends DataObject>
*/
@Override
public final void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataAfter,
- @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
checkProperInterfaceType(writeContext, id);
writeInterface(id, dataAfter, writeContext);
}
protected abstract void writeInterface(final InstanceIdentifier<D> id, final D dataAfter,
final WriteContext writeContext)
- throws WriteFailedException;
+ throws WriteFailedException;
// Validation for update and delete is not necessary
@@ -91,8 +91,8 @@ public abstract class AbstractInterfaceTypeCustomizer<D extends DataObject>
@Nonnull final Class<? extends InterfaceType> expectedType) {
if (ifc.getType() == null || !expectedType.equals(ifc.getType())) {
throw new IllegalInterfaceTypeException(String.format(
- "Unexpected interface type: %s for interface: %s. Expected interface is: %s", ifc.getType(),
- ifc.getName(), expectedType));
+ "Unexpected interface type: %s for interface: %s. Expected interface is: %s", ifc.getType(),
+ ifc.getName(), expectedType));
}
}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AddressTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AddressTranslator.java
new file mode 100644
index 000000000..d68331ca8
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/AddressTranslator.java
@@ -0,0 +1,57 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+
+/**
+ * Aggregation trait providing logic for converting address based data
+ */
+public interface AddressTranslator extends Ipv4Translator, Ipv6Translator, MacTranslator {
+
+ default byte[] ipAddressToArray(IpAddress address) {
+ checkNotNull(address, "Cannot resolve null adddress");
+
+ if (isIpv6(address)) {
+ return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address()));
+ } else {
+ return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address()));
+ }
+ }
+
+
+ /**
+ * Converts {@link IpAddress} to array representing {@link Ipv4Address} or {@link Ipv6Address}
+ */
+ default byte[] ipAddressToArray(boolean isIpv6, @Nonnull IpAddress address) {
+ checkNotNull(address, "Cannot convert null Address");
+
+ if (isIpv6) {
+ return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address()));
+ } else {
+ return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address()));
+ }
+ }
+
+ /**
+ * Converts array bytes to {@link IpAddress}
+ */
+ @Nonnull
+ default IpAddress arrayToIpAddress(boolean isIpv6, byte[] ip) {
+ if (isIpv6) {
+ return new IpAddress(arrayToIpv6AddressNoZone(ip));
+ } else {
+ return new IpAddress(arrayToIpv4AddressNoZone(ip));
+ }
+ }
+
+ default IpAddress reverseAddress(@Nonnull final IpAddress address) {
+ //arrayToIpAdddress internaly reverts order
+ return arrayToIpAddress(isIpv6(address), ipAddressToArray(address));
+ }
+}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslator.java
new file mode 100644
index 000000000..fedc3e5d2
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslator.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.v3po.util;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+/**
+ * Trait providing logic for working with binary-based data
+ */
+public interface ByteDataTranslator {
+
+ /**
+ * Returns 0 if argument is null or false, 1 otherwise.
+ *
+ * @param value Boolean value to be converted
+ * @return byte value equal to 0 or 1
+ */
+ default byte booleanToByte(@Nullable final Boolean value) {
+ return value != null && value
+ ? (byte) 1
+ : (byte) 0;
+ }
+
+ /**
+ * Returns Boolean.TRUE if argument is 0, Boolean.FALSE otherwise.
+ *
+ * @param value byte value to be converted
+ * @return Boolean value
+ * @throws IllegalArgumentException if argument is neither 0 nor 1
+ */
+ @Nonnull
+ default Boolean byteToBoolean(final byte value) {
+ if (value == 0) {
+ return Boolean.FALSE;
+ } else if (value == 1) {
+ return Boolean.TRUE;
+ }
+ throw new IllegalArgumentException(String.format("0 or 1 was expected but was %d", value));
+ }
+
+ /**
+ * Reverses bytes in the byte array
+ *
+ * @param bytes input array
+ * @return reversed array
+ */
+ default byte[] reverseBytes(final byte[] bytes) {
+ final byte[] reversed = new byte[bytes.length];
+ int i = 1;
+ for (byte aByte : bytes) {
+ reversed[bytes.length - i++] = aByte;
+ }
+
+ return reversed;
+ }
+
+ /**
+ * Return (interned) string from byte array while removing \u0000. Strings represented as fixed length byte[] from
+ * vpp contain \u0000.
+ */
+ default String toString(final byte[] cString) {
+ return new String(cString).replaceAll("\\u0000", "").intern();
+ }
+}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/FutureJVppCustomizer.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/FutureJVppCustomizer.java
index d0379e7d2..76e7b3316 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/FutureJVppCustomizer.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/FutureJVppCustomizer.java
@@ -18,9 +18,8 @@ package io.fd.honeycomb.translate.v3po.util;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-
import javax.annotation.Nonnull;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
/**
* Abstract utility to hold the vppApi reference.
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv4Translator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv4Translator.java
new file mode 100644
index 000000000..ebebf60dd
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv4Translator.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.v3po.util;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.net.InetAddresses;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+
+/**
+ * Trait providing logic for translation of ipv4-related data
+ */
+public interface Ipv4Translator extends ByteDataTranslator {
+
+ /**
+ * Creates address array from address part of {@link Ipv4Prefix}
+ */
+ default byte[] ipv4AddressPrefixToArray(@Nonnull final Ipv4Prefix ipv4Prefix) {
+ checkNotNull(ipv4Prefix, "Cannot convert null prefix");
+
+ byte[] retval = new byte[4];
+ String[] address = ipv4Prefix.getValue().substring(0, ipv4Prefix.getValue().indexOf('/')).split("\\.");
+
+ for (int d = 0; d < 4; d++) {
+ retval[d] = (byte) (Short.parseShort(address[d]) & 0xff);
+ }
+ return retval;
+ }
+
+ /**
+ * Extracts {@link Ipv4Prefix} prefix
+ */
+ default byte extractPrefix(Ipv4Prefix data) {
+ checkNotNull(data, "Cannot extract from null");
+
+ return Byte.valueOf(data.getValue().substring(data.getValue().indexOf('/') + 1));
+ }
+
+ /**
+ * Converts byte array to {@link Ipv4Prefix} with specified prefixLength
+ */
+ default Ipv4Prefix arrayToIpv4Prefix(final byte[] address, byte prefixLength) {
+ Ipv4AddressNoZone addressPart = arrayToIpv4AddressNoZone(address);
+
+ return new Ipv4Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength)));
+ }
+
+ /**
+ * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order.
+ *
+ * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No
+ * change in order.
+ */
+ @Nonnull
+ default Ipv4AddressNoZone arrayToIpv4AddressNoZone(@Nonnull byte[] ip) {
+ // VPP sends ipv4 in a 16 byte array
+ if (ip.length == 16) {
+ ip = Arrays.copyOfRange(ip, 0, 4);
+ }
+ try {
+ // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order
+ // compared to byte order it was submitted
+ return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("Unable to parse ipv4", e);
+ }
+ }
+
+ /**
+ * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order.
+ *
+ * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No
+ * change in order.
+ */
+ @Nonnull
+ default Ipv4AddressNoZone arrayToIpv4AddressNoZoneReversed(@Nonnull byte[] ip) {
+ // VPP sends ipv4 in a 16 byte array
+
+ if (ip.length == 16) {
+ ip = Arrays.copyOfRange(ip, 0, 4);
+ }
+
+ ip = reverseBytes(ip);
+
+ try {
+ // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order
+ // compared to byte order it was submitted
+ return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("Unable to parse ipv4", e);
+ }
+ }
+
+
+ /**
+ * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
+ * as the address.
+ *
+ * @return byte array with address bytes
+ */
+ default byte[] ipv4AddressNoZoneToArray(final Ipv4AddressNoZone ipv4Addr) {
+ return ipv4AddressNoZoneToArray(ipv4Addr.getValue());
+ }
+
+ default byte[] ipv4AddressNoZoneToArray(final String ipv4Addr) {
+ byte[] retval = new byte[4];
+ String[] dots = ipv4Addr.split("\\.");
+
+ for (int d = 0; d < 4; d++) {
+ retval[d] = (byte) (Short.parseShort(dots[d]) & 0xff);
+ }
+ return retval;
+ }
+}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv6Translator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv6Translator.java
new file mode 100644
index 000000000..6be7a5f24
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/Ipv6Translator.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.v3po.util;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import com.google.common.net.InetAddresses;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.apache.commons.lang3.StringUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+
+/**
+ * Trait providing logic for translation of ipv6-related data
+ */
+public interface Ipv6Translator extends ByteDataTranslator {
+
+ /**
+ * Transform Ipv6 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
+ * as the address.
+ *
+ * @return byte array with address bytes
+ */
+ default byte[] ipv6AddressNoZoneToArray(@Nonnull final Ipv6AddressNoZone ipv6Addr) {
+ byte[] retval = new byte[16];
+
+ //splits address and add ommited zeros for easier parsing
+ List<String> segments = Arrays.asList(ipv6Addr.getValue().split(":"))
+ .stream()
+ .map(segment -> StringUtils.repeat('0', 4 - segment.length()) + segment)
+ .collect(Collectors.toList());
+
+ byte index = 0;
+ for (String segment : segments) {
+
+ String firstPart = segment.substring(0, 2);
+ String secondPart = segment.substring(2);
+
+ //first part should be ommited
+ if ("00".equals(firstPart)) {
+ index++;
+ } else {
+ retval[index++] = ((byte) Short.parseShort(firstPart, 16));
+ }
+
+ retval[index++] = ((byte) Short.parseShort(secondPart, 16));
+ }
+
+ return retval;
+ }
+
+ /**
+ * Creates address array from address part of {@link Ipv6Prefix}
+ */
+ default byte[] ipv6AddressPrefixToArray(@Nonnull final Ipv6Prefix ipv4Prefix) {
+ checkNotNull(ipv4Prefix, "Cannot convert null prefix");
+
+ return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(
+ new Ipv6Address(ipv4Prefix.getValue().substring(0, ipv4Prefix.getValue().indexOf('/')))));
+ }
+
+ /**
+ * Extracts {@link Ipv6Prefix} prefix
+ */
+ default byte extractPrefix(Ipv6Prefix data) {
+ checkNotNull(data, "Cannot extract from null");
+
+ return Byte.valueOf(data.getValue().substring(data.getValue().indexOf('/') + 1));
+ }
+
+ /**
+ * Converts byte array to {@link Ipv6Prefix} with specified prefixLength
+ */
+ default Ipv6Prefix arrayToIpv6Prefix(final byte[] address, byte prefixLength) {
+ Ipv6AddressNoZone addressPart = arrayToIpv6AddressNoZone(address);
+
+ return new Ipv6Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength)));
+ }
+
+ /**
+ * Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in reversed order.
+ *
+ * @return Ipv46ddressNoZone containing string representation of IPv6 address constructed from submitted bytes. No
+ * change in order.
+ */
+ @Nonnull
+ default Ipv6AddressNoZone arrayToIpv6AddressNoZone(@Nonnull byte[] ip) {
+ checkArgument(ip.length == 16, "Illegal array length");
+
+ try {
+ return new Ipv6AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("Unable to parse ipv6", e);
+ }
+ }
+
+ /**
+ * Detects whether {@code IpAddress} is ipv6
+ */
+ default boolean isIpv6(IpAddress address) {
+ checkNotNull(address, "Address cannot be null");
+
+ checkState(!(address.getIpv4Address() == null && address.getIpv6Address() == null), "Invalid address");
+ return address.getIpv6Address() != null;
+ }
+
+ /**
+ * Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in natural order.
+ *
+ * @return Ipv46ddressNoZone containing string representation of IPv6 address constructed from submitted bytes. No
+ * change in order.
+ */
+ @Nonnull
+ default Ipv6AddressNoZone arrayToIpv6AddressNoZoneReversed(@Nonnull byte[] ip) {
+ checkArgument(ip.length == 16, "Illegal array length");
+
+ ip = reverseBytes(ip);
+
+ try {
+ return new Ipv6AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("Unable to parse ipv6", e);
+ }
+ }
+
+
+ /**
+ * Detects whether {@code IpPrefix} is ipv6
+ */
+ default boolean isIpv6(IpPrefix address) {
+ checkNotNull(address, "Address cannot be null");
+ checkState(!(address.getIpv4Prefix() == null && address.getIpv6Prefix() == null), "Invalid address");
+ return address.getIpv6Prefix() != null;
+ }
+}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumer.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumer.java
new file mode 100644
index 000000000..bf62ecd61
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumer.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.v3po.util;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.dto.JVppReply;
+
+/**
+ * Trait providing logic for consuming reply's to jvpp api calls
+ */
+public interface JvppReplyConsumer {
+
+ int DEFAULT_TIMEOUT_IN_SECONDS = 5;
+
+ default <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType)
+ throws VppBaseCallException, WriteTimeoutException {
+ return getReplyForWrite(future, replyType, DEFAULT_TIMEOUT_IN_SECONDS);
+ }
+
+ default <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType,
+ @Nonnegative final int timeoutInSeconds)
+ throws VppBaseCallException, WriteTimeoutException {
+ try {
+ return getReply(future, timeoutInSeconds);
+ } catch (TimeoutException e) {
+ throw new WriteTimeoutException(replyType, e);
+ }
+ }
+
+ default <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType)
+ throws VppBaseCallException, ReadTimeoutException {
+ return getReplyForRead(future, replyType, DEFAULT_TIMEOUT_IN_SECONDS);
+ }
+
+ default <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType,
+ @Nonnegative final int timeoutInSeconds)
+ throws VppBaseCallException, ReadTimeoutException {
+ try {
+ return getReply(future, timeoutInSeconds);
+ } catch (TimeoutException e) {
+ throw new ReadTimeoutException(replyType, e);
+ }
+ }
+
+ default <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future)
+ throws TimeoutException, VppBaseCallException {
+ return getReply(future, DEFAULT_TIMEOUT_IN_SECONDS);
+ }
+
+ default <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future,
+ @Nonnegative final int timeoutInSeconds)
+ throws TimeoutException, VppBaseCallException {
+ try {
+ checkArgument(timeoutInSeconds > 0, "Timeout cannot be < 0");
+ return future.get(timeoutInSeconds, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("Interrupted", e);
+ } catch (ExecutionException e) {
+ // Execution exception could generally contains any exception
+ // when using exceptions instead of return codes just rethrow it for processing on corresponding place
+ if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
+ throw (VppBaseCallException) (e.getCause());
+ }
+ throw new IllegalStateException(e);
+ }
+ }
+}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/MacTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/MacTranslator.java
new file mode 100644
index 000000000..f18a122f2
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/MacTranslator.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.v3po.util;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Splitter;
+import java.util.List;
+import java.util.function.BiConsumer;
+import javax.annotation.Nonnull;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
+
+/**
+ * Trait providing logic for translation of ipv4-related data
+ */
+public interface MacTranslator {
+
+ Splitter COLON_SPLITTER = Splitter.on(':');
+
+ /**
+ * Parse string represented mac address (using ":" as separator) into a byte array
+ */
+ @Nonnull
+ default byte[] parseMac(@Nonnull final String macAddress) {
+ final List<String> parts = COLON_SPLITTER.splitToList(macAddress);
+ checkArgument(parts.size() == 6, "Mac address is expected to have 6 parts but was: %s", macAddress);
+ return parseMacLikeString(parts);
+ }
+
+ default byte[] parseMacLikeString(final List<String> strings) {
+ return strings.stream().limit(6).map(this::parseHexByte).collect(
+ () -> new byte[strings.size()],
+ new BiConsumer<byte[], Byte>() {
+
+ private int i = -1;
+
+ @Override
+ public void accept(final byte[] bytes, final Byte aByte) {
+ bytes[++i] = aByte;
+ }
+ },
+ (bytes, bytes2) -> {
+ throw new UnsupportedOperationException("Parallel collect not supported");
+ });
+ }
+
+ /**
+ * Converts byte array to address string ,not separated with ":"
+ */
+ default String byteArrayToMacUnseparated(byte[] address) {
+ checkArgument(address.length == 6, "Illegal array length");
+ return Hex.encodeHexString(address);
+ }
+
+ /**
+ * Converts byte array to address string ,separated with ":"
+ */
+ default String byteArrayToMacSeparated(byte[] address) {
+ checkArgument(address.length == 6, "Illegal array length");
+
+ String unseparatedAddress = Hex.encodeHexString(address);
+ String separated = "";
+
+ for (int i = 0; i < unseparatedAddress.length(); i = i + 2) {
+ if (i == (unseparatedAddress.length() - 2)) {
+ separated = separated + unseparatedAddress.substring(0 + i, 2 + i);
+ } else {
+ separated = separated + unseparatedAddress.substring(0 + i, 2 + i) + ":";
+ }
+ }
+
+ return separated;
+ }
+
+ /**
+ * Converts MAC string to byte array
+ */
+ default byte[] macToByteArray(String mac) {
+ checkNotNull(mac, "MAC cannot be null");
+
+ mac = mac.replace(":", "");
+
+ try {
+ return Hex.decodeHex(mac.toCharArray());
+ } catch (DecoderException e) {
+ throw new IllegalArgumentException("Unable to convert mac", e);
+ }
+ }
+
+ default byte parseHexByte(final String aByte) {
+ return (byte) Integer.parseInt(aByte, 16);
+ }
+}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/NamingContext.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/NamingContext.java
index ead59a803..056a6df2c 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/NamingContext.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/NamingContext.java
@@ -39,32 +39,31 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
*/
public final class NamingContext implements AutoCloseable {
+ private static final Collector<Mapping, ?, Mapping> SINGLE_ITEM_COLLECTOR = RWUtils.singleItemCollector();
private final String artificialNamePrefix;
private final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContext, NamingContextKey>
- namingContextIid;
-
- private static final Collector<Mapping, ?, Mapping> SINGLE_ITEM_COLLECTOR = RWUtils.singleItemCollector();
+ namingContextIid;
/**
* Create new naming context
*
* @param artificialNamePrefix artificial name to be used for items without a name in VPP (or not provided)
- * @param instanceName name of this context instance. Will be used as list item identifier within context data tree
+ * @param instanceName name of this context instance. Will be used as list item identifier within context
+ * data tree
*/
public NamingContext(@Nonnull final String artificialNamePrefix, @Nonnull final String instanceName) {
this.artificialNamePrefix = artificialNamePrefix;
namingContextIid = InstanceIdentifier.create(Contexts.class).child(
- org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContext.class,
- new NamingContextKey(instanceName));
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContext.class,
+ new NamingContextKey(instanceName));
}
/**
* Retrieve name for mapping stored provided mappingContext instance. If not present, artificial name will be
* generated.
*
- * @param index index of a mapped item
+ * @param index index of a mapped item
* @param mappingContext mapping context providing context data for current transaction
- *
* @return name mapped to provided index
*/
@Nonnull
@@ -78,16 +77,15 @@ public final class NamingContext implements AutoCloseable {
checkState(read.isPresent(), "Mapping for index: %s is not present. But should be", index);
return read.get().getMapping().stream()
- .filter(mapping -> mapping.getIndex().equals(index))
- .collect(SINGLE_ITEM_COLLECTOR).getName();
+ .filter(mapping -> mapping.getIndex().equals(index))
+ .collect(SINGLE_ITEM_COLLECTOR).getName();
}
/**
* Retrieve name for mapping stored provided mappingContext instance. if present
*
- * @param index index of a mapped item
+ * @param index index of a mapped item
* @param mappingContext mapping context providing context data for current transaction
- *
* @return name mapped to provided index
*/
@Nonnull
@@ -97,33 +95,32 @@ public final class NamingContext implements AutoCloseable {
return read.isPresent()
? Optional.of(read.get().getMapping().stream()
- .filter(mapping -> mapping.getIndex().equals(index))
- .collect(SINGLE_ITEM_COLLECTOR)
- .getName())
+ .filter(mapping -> mapping.getIndex().equals(index))
+ .collect(SINGLE_ITEM_COLLECTOR)
+ .getName())
: Optional.absent();
}
/**
* Check whether mapping is present for index.
*
- * @param index index of a mapped item
+ * @param index index of a mapped item
* @param mappingContext mapping context providing context data for current transaction
- *
* @return true if present, false otherwise
*/
public synchronized boolean containsName(final int index, @Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
return read.isPresent()
- ? read.get().getMapping().stream().anyMatch(mapping -> mapping.getIndex().equals(index))
- : false;
+ ? read.get().getMapping().stream().anyMatch(mapping -> mapping.getIndex().equals(index))
+ : false;
}
/**
* Add mapping to current context
*
- * @param index index of a mapped item
- * @param name name of a mapped item
+ * @param index index of a mapped item
+ * @param name name of a mapped item
* @param mappingContext mapping context providing context data for current transaction
*/
public synchronized void addName(final int index, final String name, final MappingContext mappingContext) {
@@ -138,7 +135,7 @@ public final class NamingContext implements AutoCloseable {
/**
* Remove mapping from current context
*
- * @param name name of a mapped item
+ * @param name name of a mapped item
* @param mappingContext mapping context providing context data for current transaction
*/
public synchronized void removeName(final String name, final MappingContext mappingContext) {
@@ -148,9 +145,8 @@ public final class NamingContext implements AutoCloseable {
/**
* Returns index value associated with the given name.
*
- * @param name the name whose associated index value is to be returned
+ * @param name the name whose associated index value is to be returned
* @param mappingContext mapping context providing context data for current transaction
- *
* @return integer index value matching supplied name
* @throws IllegalArgumentException if name was not found
*/
@@ -164,9 +160,8 @@ public final class NamingContext implements AutoCloseable {
/**
* Check whether mapping is present for name.
*
- * @param name name of a mapped item
+ * @param name name of a mapped item
* @param mappingContext mapping context providing context data for current transaction
- *
* @return true if present, false otherwise
*/
public synchronized boolean containsIndex(final String name, final MappingContext mappingContext) {
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TagRewriteOperation.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TagRewriteOperation.java
index c403b7104..e7c07ed75 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TagRewriteOperation.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TagRewriteOperation.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.translate.v3po.util;
import com.google.common.base.Preconditions;
@@ -39,6 +40,11 @@ public enum TagRewriteOperation {
translate_2_to_2(2);
private static final int MAX_INDEX = 3;
+ private static TagRewriteOperation[][] translation = new TagRewriteOperation[][]{
+ {disabled, push_1, push_2},
+ {pop_1, translate_1_to_1, translate_1_to_2},
+ {pop_2, translate_2_to_1, translate_2_to_2}
+ };
private final int code;
private final byte popTags;
@@ -47,15 +53,10 @@ public enum TagRewriteOperation {
this.popTags = UnsignedBytes.checkedCast(popTags);
}
- private static TagRewriteOperation[][] translation = new TagRewriteOperation[][] {
- {disabled, push_1, push_2},
- {pop_1, translate_1_to_1, translate_1_to_2},
- {pop_2, translate_2_to_1, translate_2_to_2}
- };
-
/**
* Returns VPP tag rewrite operation for given number of tags to pop and tags to push.
- * @param toPop number of tags to pop (0..2)
+ *
+ * @param toPop number of tags to pop (0..2)
* @param toPush number of tags to push (0..2)
* @return vpp tag rewrite operation for given input parameters
*/
@@ -67,6 +68,7 @@ public enum TagRewriteOperation {
/**
* Returns VPP tag rewrite operation for given operation code.
+ *
* @param code VPP tag rewrite operation code
* @return vpp tag rewrite operation for given input parameter
*/
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TranslateUtils.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TranslateUtils.java
deleted file mode 100644
index c1f17ea6c..000000000
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/v3po/util/TranslateUtils.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.translate.v3po.util;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.base.Splitter;
-import com.google.common.net.InetAddresses;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.BiConsumer;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.dto.JVppReply;
-
-public final class TranslateUtils {
-
- public static final Splitter COLON_SPLITTER = Splitter.on(':');
- public static final int DEFAULT_TIMEOUT_IN_SECONDS = 5;
-
- private TranslateUtils() {
- }
-
- public static <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
- @Nonnull final InstanceIdentifier<?> replyType)
- throws VppBaseCallException, WriteTimeoutException {
- return getReplyForWrite(future, replyType, DEFAULT_TIMEOUT_IN_SECONDS);
- }
-
- public static <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
- @Nonnull final InstanceIdentifier<?> replyType,
- @Nonnegative final int timeoutInSeconds)
- throws VppBaseCallException, WriteTimeoutException {
- try {
- return getReply(future, timeoutInSeconds);
- } catch (TimeoutException e) {
- throw new WriteTimeoutException(replyType, e);
- }
- }
-
- public static <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
- @Nonnull final InstanceIdentifier<?> replyType)
- throws VppBaseCallException, ReadTimeoutException {
- return getReplyForRead(future, replyType, DEFAULT_TIMEOUT_IN_SECONDS);
- }
-
- public static <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
- @Nonnull final InstanceIdentifier<?> replyType,
- @Nonnegative final int timeoutInSeconds)
- throws VppBaseCallException, ReadTimeoutException {
- try {
- return getReply(future, timeoutInSeconds);
- } catch (TimeoutException e) {
- throw new ReadTimeoutException(replyType, e);
- }
- }
-
- public static <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future)
- throws TimeoutException, VppBaseCallException {
- return getReply(future, DEFAULT_TIMEOUT_IN_SECONDS);
- }
-
- public static <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future,
- @Nonnegative final int timeoutInSeconds)
- throws TimeoutException, VppBaseCallException {
- try {
- checkArgument(timeoutInSeconds > 0, "Timeout cannot be < 0");
- return future.get(timeoutInSeconds, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IllegalStateException("Interrupted", e);
- } catch (ExecutionException e) {
- // Execution exception could generally contains any exception
- // when using exceptions instead of return codes just rethrow it for processing on corresponding place
- if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
- throw (VppBaseCallException) (e.getCause());
- }
- throw new IllegalStateException(e);
- }
- }
-
- public static final byte[] ipAddressToArray(IpAddress address) {
- checkNotNull(address, "Cannot resolve null adddress");
-
- if (isIpv6(address)) {
- return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address()));
- } else {
- return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address()));
- }
- }
-
- /**
- * Creates address array from address part of {@link Ipv4Prefix}
- */
- public static byte[] ipv4AddressPrefixToArray(@Nonnull final Ipv4Prefix ipv4Prefix) {
- checkNotNull(ipv4Prefix, "Cannot convert null prefix");
-
- byte[] retval = new byte[4];
- String[] address = ipv4Prefix.getValue().substring(0, ipv4Prefix.getValue().indexOf('/')).split("\\.");
-
- for (int d = 0; d < 4; d++) {
- retval[d] = (byte) (Short.parseShort(address[d]) & 0xff);
- }
- return retval;
- }
-
- /**
- * Converts {@link IpAddress} to array representing {@link Ipv4Address} or {@link Ipv6Address}
- */
- public static byte[] ipAddressToArray(boolean isIpv6, @Nonnull IpAddress address) {
- checkNotNull(address, "Cannot convert null Address");
-
- if (isIpv6) {
- return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address()));
- } else {
- return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address()));
- }
- }
-
- /**
- * Converts array bytes to {@link IpAddress}
- */
- @Nonnull
- public static IpAddress arrayToIpAddress(boolean isIpv6, byte[] ip) {
- if (isIpv6) {
- return new IpAddress(arrayToIpv6AddressNoZone(ip));
- } else {
- return new IpAddress(arrayToIpv4AddressNoZone(ip));
- }
- }
-
- /**
- * Extracts {@link Ipv4Prefix} prefix
- */
- public static byte extractPrefix(Ipv4Prefix data) {
- checkNotNull(data, "Cannot extract from null");
-
- return Byte.valueOf(data.getValue().substring(data.getValue().indexOf('/') + 1));
- }
-
- /**
- * Converts byte array to {@link Ipv4Prefix} with specified prefixLength
- */
- public static Ipv4Prefix arrayToIpv4Prefix(final byte[] address, byte prefixLength) {
- Ipv4AddressNoZone addressPart = arrayToIpv4AddressNoZone(address);
-
- return new Ipv4Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength)));
- }
-
- /**
- * Transform Ipv6 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
- * as the address.
- *
- * @return byte array with address bytes
- */
- public static byte[] ipv6AddressNoZoneToArray(@Nonnull final Ipv6AddressNoZone ipv6Addr) {
- byte[] retval = new byte[16];
-
- //splits address and add ommited zeros for easier parsing
- List<String> segments = Arrays.asList(ipv6Addr.getValue().split(":"))
- .stream()
- .map(segment -> StringUtils.repeat('0', 4 - segment.length()) + segment)
- .collect(Collectors.toList());
-
- byte index = 0;
- for (String segment : segments) {
-
- String firstPart = segment.substring(0, 2);
- String secondPart = segment.substring(2);
-
- //first part should be ommited
- if ("00".equals(firstPart)) {
- index++;
- } else {
- retval[index++] = ((byte) Short.parseShort(firstPart, 16));
- }
-
- retval[index++] = ((byte) Short.parseShort(secondPart, 16));
- }
-
- return retval;
- }
-
- /**
- * Creates address array from address part of {@link Ipv6Prefix}
- */
- public static byte[] ipv6AddressPrefixToArray(@Nonnull final Ipv6Prefix ipv4Prefix) {
- checkNotNull(ipv4Prefix, "Cannot convert null prefix");
-
- return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(
- new Ipv6Address(ipv4Prefix.getValue().substring(0, ipv4Prefix.getValue().indexOf('/')))));
- }
-
- /**
- * Extracts {@link Ipv6Prefix} prefix
- */
- public static byte extractPrefix(Ipv6Prefix data) {
- checkNotNull(data, "Cannot extract from null");
-
- return Byte.valueOf(data.getValue().substring(data.getValue().indexOf('/') + 1));
- }
-
- /**
- * Converts byte array to {@link Ipv6Prefix} with specified prefixLength
- */
- public static Ipv6Prefix arrayToIpv6Prefix(final byte[] address, byte prefixLength) {
- Ipv6AddressNoZone addressPart = arrayToIpv6AddressNoZone(address);
-
- return new Ipv6Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength)));
- }
-
- /**
- * Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in reversed order.
- *
- * @return Ipv46ddressNoZone containing string representation of IPv6 address constructed from submitted bytes. No
- * change in order.
- */
- @Nonnull
- public static Ipv6AddressNoZone arrayToIpv6AddressNoZone(@Nonnull byte[] ip) {
- checkArgument(ip.length == 16, "Illegal array length");
-
- try {
- return new Ipv6AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Unable to parse ipv6", e);
- }
- }
-
-
- /**
- * Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in natural order.
- *
- * @return Ipv46ddressNoZone containing string representation of IPv6 address constructed from submitted bytes. No
- * change in order.
- */
- @Nonnull
- public static Ipv6AddressNoZone arrayToIpv6AddressNoZoneReversed(@Nonnull byte[] ip) {
- checkArgument(ip.length == 16, "Illegal array length");
-
- ip = reverseBytes(ip);
-
- try {
- return new Ipv6AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Unable to parse ipv6", e);
- }
- }
-
- /**
- * Converts byte array to address string ,not separated with ":"
- */
- public static String byteArrayToMacUnseparated(byte[] address) {
- checkArgument(address.length == 6, "Illegal array length");
- return Hex.encodeHexString(address);
- }
-
- /**
- * Converts byte array to address string ,separated with ":"
- */
- public static String byteArrayToMacSeparated(byte[] address) {
- checkArgument(address.length == 6, "Illegal array length");
-
- String unseparatedAddress = Hex.encodeHexString(address);
- String separated = "";
-
- for (int i = 0; i < unseparatedAddress.length(); i = i + 2) {
- if (i == (unseparatedAddress.length() - 2)) {
- separated = separated + unseparatedAddress.substring(0 + i, 2 + i);
- } else {
- separated = separated + unseparatedAddress.substring(0 + i, 2 + i) + ":";
- }
- }
-
- return separated;
- }
-
- /**
- * Converts MAC string to byte array
- */
- public static byte[] macToByteArray(String mac) {
- checkNotNull(mac, "MAC cannot be null");
-
- mac = mac.replace(":", "");
-
- try {
- return Hex.decodeHex(mac.toCharArray());
- } catch (DecoderException e) {
- throw new IllegalArgumentException("Unable to convert mac", e);
- }
- }
-
- /**
- * Detects whether {@code IpAddress} is ipv6
- */
- public static boolean isIpv6(IpAddress address) {
- checkNotNull(address, "Address cannot be null");
-
- checkState(!(address.getIpv4Address() == null && address.getIpv6Address() == null), "Invalid address");
- return address.getIpv6Address() != null;
- }
-
- /**
- * Detects whether {@code IpPrefix} is ipv6
- */
- public static boolean isIpv6(IpPrefix address) {
- checkNotNull(address, "Address cannot be null");
- checkState(!(address.getIpv4Prefix() == null && address.getIpv6Prefix() == null), "Invalid address");
- return address.getIpv6Prefix() != null;
- }
-
-
- /**
- * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
- * as the address.
- *
- * @return byte array with address bytes
- */
- public static byte[] ipv4AddressNoZoneToArray(final Ipv4AddressNoZone ipv4Addr) {
- return ipv4AddressNoZoneToArray(ipv4Addr.getValue());
- }
-
- public static byte[] ipv4AddressNoZoneToArray(final String ipv4Addr) {
- byte[] retval = new byte[4];
- String[] dots = ipv4Addr.split("\\.");
-
- for (int d = 0; d < 4; d++) {
- retval[d] = (byte) (Short.parseShort(dots[d]) & 0xff);
- }
- return retval;
- }
-
- /**
- * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order.
- *
- * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No
- * change in order.
- */
- @Nonnull
- public static Ipv4AddressNoZone arrayToIpv4AddressNoZone(@Nonnull byte[] ip) {
- // VPP sends ipv4 in a 16 byte array
- if (ip.length == 16) {
- ip = Arrays.copyOfRange(ip, 0, 4);
- }
- try {
- // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order
- // compared to byte order it was submitted
- return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Unable to parse ipv4", e);
- }
- }
-
- /**
- * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order.
- *
- * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No
- * change in order.
- */
- @Nonnull
- public static Ipv4AddressNoZone arrayToIpv4AddressNoZoneReversed(@Nonnull byte[] ip) {
- // VPP sends ipv4 in a 16 byte array
-
- if (ip.length == 16) {
- ip = Arrays.copyOfRange(ip, 0, 4);
- }
-
- ip = reverseBytes(ip);
-
- try {
- // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order
- // compared to byte order it was submitted
- return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip)));
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Unable to parse ipv4", e);
- }
- }
-
- /**
- * Return (interned) string from byte array while removing \u0000. Strings represented as fixed length byte[] from
- * vpp contain \u0000.
- */
- public static String toString(final byte[] cString) {
- return new String(cString).replaceAll("\\u0000", "").intern();
- }
-
- /**
- * Parse string represented mac address (using ":" as separator) into a byte array
- */
- @Nonnull
- public static byte[] parseMac(@Nonnull final String macAddress) {
- final List<String> parts = COLON_SPLITTER.splitToList(macAddress);
- checkArgument(parts.size() == 6, "Mac address is expected to have 6 parts but was: %s", macAddress);
- return parseMacLikeString(parts);
- }
-
- private static byte[] parseMacLikeString(final List<String> strings) {
- return strings.stream().limit(6).map(TranslateUtils::parseHexByte).collect(
- () -> new byte[strings.size()],
- new BiConsumer<byte[], Byte>() {
-
- private int i = -1;
-
- @Override
- public void accept(final byte[] bytes, final Byte aByte) {
- bytes[++i] = aByte;
- }
- },
- (bytes, bytes2) -> {
- throw new UnsupportedOperationException("Parallel collect not supported");
- });
- }
-
- public static byte parseHexByte(final String aByte) {
- return (byte) Integer.parseInt(aByte, 16);
- }
-
- /**
- * Returns 0 if argument is null or false, 1 otherwise.
- *
- * @param value Boolean value to be converted
- * @return byte value equal to 0 or 1
- */
- public static byte booleanToByte(@Nullable final Boolean value) {
- return value != null && value
- ? (byte) 1
- : (byte) 0;
- }
-
- /**
- * Returns Boolean.TRUE if argument is 0, Boolean.FALSE otherwise.
- *
- * @param value byte value to be converted
- * @return Boolean value
- * @throws IllegalArgumentException if argument is neither 0 nor 1
- */
- @Nonnull
- public static Boolean byteToBoolean(final byte value) {
- if (value == 0) {
- return Boolean.FALSE;
- } else if (value == 1) {
- return Boolean.TRUE;
- }
- throw new IllegalArgumentException(String.format("0 or 1 was expected but was %d", value));
- }
-
- /**
- * Reverses bytes in the byte array
- *
- * @param bytes input array
- * @return reversed array
- */
- public static byte[] reverseBytes(final byte[] bytes) {
- final byte[] reversed = new byte[bytes.length];
- int i = 1;
- for (byte aByte : bytes) {
- reversed[bytes.length - i++] = aByte;
- }
-
- return reversed;
- }
-
- public static IpAddress reverseAddress(@Nonnull final IpAddress address) {
- //arrayToIpAdddress internaly reverts order
- return arrayToIpAddress(isIpv6(address), ipAddressToArray(address));
- }
-}
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/AddressTranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/AddressTranslatorTest.java
new file mode 100644
index 000000000..92f58c933
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/AddressTranslatorTest.java
@@ -0,0 +1,20 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+
+public class AddressTranslatorTest implements AddressTranslator {
+
+ @Test
+ public void testRevertAddress() {
+ assertEquals("1.2.168.192",
+ reverseAddress(new IpAddress(new Ipv4Address("192.168.2.1"))).getIpv4Address().getValue());
+ assertEquals("3473:7003:2e8a::a385:b80d:120",
+ reverseAddress(new IpAddress(new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:7334"))).getIpv6Address()
+ .getValue());
+ }
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java
new file mode 100644
index 000000000..86ff5ff77
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java
@@ -0,0 +1,39 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Created by jsrnicek on 23.9.2016.
+ */
+public class ByteDataTranslatorTest implements ByteDataTranslator {
+
+ @Test
+ public void testBooleanToByte() {
+ assertEquals(0, booleanToByte(null));
+ assertEquals(0, booleanToByte(false));
+ assertEquals(1, booleanToByte(true));
+ }
+
+ @Test
+ public void testByteToBoolean() {
+ assertEquals(Boolean.FALSE, byteToBoolean((byte) 0));
+ assertEquals(Boolean.TRUE, byteToBoolean((byte) 1));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testByteToBooleanFailed() {
+ byteToBoolean((byte) 123);
+ }
+
+ @Test
+ public void testToString() {
+ final byte[] expected = "test".getBytes();
+ final byte[] cString = new byte[expected.length + 10];
+ System.arraycopy(expected, 0, cString, 0, expected.length);
+ final String jString = toString(cString);
+ assertArrayEquals(expected, jString.getBytes());
+ }
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv4TranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv4TranslatorTest.java
new file mode 100644
index 000000000..3b1dcd9b1
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv4TranslatorTest.java
@@ -0,0 +1,33 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+
+public class Ipv4TranslatorTest implements Ipv4Translator {
+
+ @Test
+ public void testIpv4NoZone() throws Exception {
+ final Ipv4AddressNoZone ipv4Addr = new Ipv4AddressNoZone("192.168.1.1");
+ byte[] bytes = ipv4AddressNoZoneToArray(ipv4Addr);
+ assertEquals((byte) 192, bytes[0]);
+ // Simulating the magic of VPP
+ bytes = reverseBytes(bytes);
+ final Ipv4AddressNoZone ipv4AddressNoZone = arrayToIpv4AddressNoZone(bytes);
+ assertEquals(ipv4Addr, ipv4AddressNoZone);
+ }
+
+ @Test
+ public void testIpv4AddressPrefixToArray() {
+ byte[] ip = ipv4AddressPrefixToArray(new Ipv4Prefix("192.168.2.1/24"));
+
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(ip).getValue());
+ }
+
+ @Test
+ public void testExtractPrefix() {
+ assertEquals(24, extractPrefix(new Ipv4Prefix("192.168.2.1/24")));
+ }
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv6TranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv6TranslatorTest.java
new file mode 100644
index 000000000..6f4d39c63
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/Ipv6TranslatorTest.java
@@ -0,0 +1,40 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+
+public class Ipv6TranslatorTest implements Ipv6Translator {
+
+ @Test
+ public void testIpv6NoZone() {
+ final Ipv6AddressNoZone ipv6Addr = new Ipv6AddressNoZone("3ffe:1900:4545:3:200:f8ff:fe21:67cf");
+ byte[] bytes = ipv6AddressNoZoneToArray(ipv6Addr);
+ assertEquals((byte) 63, bytes[0]);
+
+ bytes = reverseBytes(bytes);
+ final Ipv6AddressNoZone ivp6AddressNoZone = arrayToIpv6AddressNoZone(bytes);
+ assertEquals(ipv6Addr, ivp6AddressNoZone);
+ }
+
+ @Test
+ public void testIpv6AddressPrefixToArray() {
+ byte[] ip = ipv6AddressPrefixToArray(new Ipv6Prefix("3ffe:1900:4545:3:200:f8ff:fe21:67cf/48"));
+
+ assertEquals("cf67:21fe:fff8:2:300:4545:19:fe3f", arrayToIpv6AddressNoZone(ip).getValue());
+ }
+
+ @Test
+ public void testIpv4AddressPrefixToArray() {
+ byte[] ip = ipv6AddressPrefixToArray(new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/128"));
+
+ assertEquals("100::f012:b0a:b80d:120", arrayToIpv6AddressNoZone(ip).getValue());
+ }
+
+ @Test
+ public void testExtractPrefix() {
+ assertEquals(48, extractPrefix(new Ipv6Prefix("3ffe:1900:4545:3:200:f8ff:fe21:67cf/48")));
+ }
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumerTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumerTest.java
new file mode 100644
index 000000000..dbccef6e2
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/JvppReplyConsumerTest.java
@@ -0,0 +1,60 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.dto.JVppReply;
+
+public class JvppReplyConsumerTest implements JvppReplyConsumer {
+
+ private static class AnDataObject implements DataObject {
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return null;
+ }
+ }
+
+ @Test
+ public void testGetReplyForWriteTimeout() throws Exception {
+ final Future<JVppReply<?>> future = mock(Future.class);
+ when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class);
+ final InstanceIdentifier<AnDataObject>
+ replyType = InstanceIdentifier.create(AnDataObject.class);
+ try {
+ getReplyForWrite(future, replyType);
+ } catch (WriteTimeoutException e) {
+ assertTrue(e.getCause() instanceof TimeoutException);
+ assertEquals(replyType, e.getFailedId());
+ return;
+ }
+ fail("WriteTimeoutException was expected");
+ }
+
+ @Test
+ public void testGetReplyForReadTimeout() throws Exception {
+ final Future<JVppReply<?>> future = mock(Future.class);
+ final InstanceIdentifier<AnDataObject> replyType =
+ InstanceIdentifier.create(AnDataObject.class);
+ when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class);
+ try {
+ getReplyForRead(future, replyType);
+ } catch (ReadTimeoutException e) {
+ assertTrue(e.getCause() instanceof TimeoutException);
+ assertEquals(replyType, e.getFailedId());
+ return;
+ }
+ fail("ReadTimeoutException was expected");
+ }
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/MacTranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/MacTranslatorTest.java
new file mode 100644
index 000000000..60444204e
--- /dev/null
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/MacTranslatorTest.java
@@ -0,0 +1,73 @@
+package io.fd.honeycomb.translate.v3po.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MacTranslatorTest implements MacTranslator {
+
+ @Test
+ public void testParseMac() throws Exception {
+ byte[] bytes = parseMac("00:fF:7f:15:5e:A9");
+ assertMac(bytes);
+ }
+
+ private void assertMac(final byte[] bytes) {
+ assertEquals(6, bytes.length);
+ assertEquals((byte) 0, bytes[0]);
+ assertEquals((byte) 255, bytes[1]);
+ assertEquals((byte) 127, bytes[2]);
+ assertEquals((byte) 21, bytes[3]);
+ assertEquals((byte) 94, bytes[4]);
+ assertEquals((byte) 169, bytes[5]);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseMacLonger() throws Exception {
+ byte[] bytes = parseMac("00:fF:7f:15:5e:A9:88:77");
+ assertMac(bytes);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseMacShorter() throws Exception {
+ parseMac("00:fF:7f");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseRandomString() throws Exception {
+ parseMac("random{}}@$*&*!");
+ }
+
+ @Test(expected = NumberFormatException.class)
+ public void testParseMacNumberFormatEx() throws Exception {
+ parseMac("00:XX:7f:15:5e:77\"");
+ }
+
+ @Test
+ public void testByteArrayToMacUnseparated() {
+ byte[] address = parseMac("aa:bb:cc:dd:ee:ff");
+
+ String converted = byteArrayToMacUnseparated(address);
+
+ assertEquals("aabbccddeeff", converted);
+ }
+
+ @Test
+ public void testByteArrayToMacSeparated() {
+ byte[] address = parseMac("aa:bb:cc:dd:ee:ff");
+
+ String converted = byteArrayToMacSeparated(address);
+
+ assertEquals("aa:bb:cc:dd:ee:ff", converted);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testByteArrayToMacUnseparatedIllegal() {
+ byteArrayToMacUnseparated(new byte[]{54, 26, 87, 32, 14});
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testByteArrayToMacSeparatedIllegal() {
+ byteArrayToMacSeparated(new byte[]{54, 26, 87, 32, 14});
+ }
+} \ No newline at end of file
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java
deleted file mode 100644
index 3b7efbfc5..000000000
--- a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package io.fd.honeycomb.translate.v3po.util;
-
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.reverseAddress;
-import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.reverseBytes;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.dto.JVppReply;
-
-public class TranslateUtilsTest {
-
- private static class AnDataObject implements DataObject {
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return null;
- }
- }
-
- @Test
- public void testGetReplyForWriteTimeout() throws Exception {
- final Future<JVppReply<?>> future = mock(Future.class);
- when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class);
- final InstanceIdentifier<AnDataObject> replyType = InstanceIdentifier.create(AnDataObject.class);
- try {
- TranslateUtils.getReplyForWrite(future, replyType);
- } catch (WriteTimeoutException e) {
- assertTrue(e.getCause() instanceof TimeoutException);
- assertEquals(replyType, e.getFailedId());
- return;
- }
- fail("WriteTimeoutException was expected");
- }
-
- @Test
- public void testGetReplyForReadTimeout() throws Exception {
- final Future<JVppReply<?>> future = mock(Future.class);
- final InstanceIdentifier<AnDataObject> replyType = InstanceIdentifier.create(AnDataObject.class);
- when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class);
- try {
- TranslateUtils.getReplyForRead(future, replyType);
- } catch (ReadTimeoutException e) {
- assertTrue(e.getCause() instanceof TimeoutException);
- assertEquals(replyType, e.getFailedId());
- return;
- }
- fail("ReadTimeoutException was expected");
- }
-
- @Test
- public void testIpv4NoZone() throws Exception {
- final Ipv4AddressNoZone ipv4Addr = new Ipv4AddressNoZone("192.168.1.1");
- byte[] bytes = TranslateUtils.ipv4AddressNoZoneToArray(ipv4Addr);
- assertEquals((byte) 192, bytes[0]);
- // Simulating the magic of VPP
- bytes = reverseBytes(bytes);
- final Ipv4AddressNoZone ipv4AddressNoZone = TranslateUtils.arrayToIpv4AddressNoZone(bytes);
- assertEquals(ipv4Addr, ipv4AddressNoZone);
- }
-
- @Test
- public void testToString() {
- final byte[] expected = "test".getBytes();
- final byte[] cString = new byte[expected.length + 10];
- System.arraycopy(expected, 0, cString, 0, expected.length);
- final String jString = TranslateUtils.toString(cString);
- assertArrayEquals(expected, jString.getBytes());
- }
-
- @Test
- public void testParseMac() throws Exception {
- byte[] bytes = TranslateUtils.parseMac("00:fF:7f:15:5e:A9");
- assertMac(bytes);
- }
-
- private void assertMac(final byte[] bytes) {
- assertEquals(6, bytes.length);
- assertEquals((byte) 0, bytes[0]);
- assertEquals((byte) 255, bytes[1]);
- assertEquals((byte) 127, bytes[2]);
- assertEquals((byte) 21, bytes[3]);
- assertEquals((byte) 94, bytes[4]);
- assertEquals((byte) 169, bytes[5]);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParseMacLonger() throws Exception {
- byte[] bytes = TranslateUtils.parseMac("00:fF:7f:15:5e:A9:88:77");
- assertMac(bytes);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParseMacShorter() throws Exception {
- TranslateUtils.parseMac("00:fF:7f");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParseRandomString() throws Exception {
- TranslateUtils.parseMac("random{}}@$*&*!");
- }
-
- @Test(expected = NumberFormatException.class)
- public void testParseMacNumberFormatEx() throws Exception {
- TranslateUtils.parseMac("00:XX:7f:15:5e:77\"");
- }
-
- @Test
- public void testBooleanToByte() {
- assertEquals(0, TranslateUtils.booleanToByte(null));
- assertEquals(0, TranslateUtils.booleanToByte(false));
- assertEquals(1, TranslateUtils.booleanToByte(true));
- }
-
- @Test
- public void testByteToBoolean() {
- assertEquals(Boolean.FALSE, TranslateUtils.byteToBoolean((byte) 0));
- assertEquals(Boolean.TRUE, TranslateUtils.byteToBoolean((byte) 1));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testByteToBooleanFailed() {
- TranslateUtils.byteToBoolean((byte) 123);
- }
-
- @Test
- public void testIpv6NoZone() {
- final Ipv6AddressNoZone ipv6Addr = new Ipv6AddressNoZone("3ffe:1900:4545:3:200:f8ff:fe21:67cf");
- byte[] bytes = TranslateUtils.ipv6AddressNoZoneToArray(ipv6Addr);
- assertEquals((byte) 63, bytes[0]);
-
- bytes = reverseBytes(bytes);
- final Ipv6AddressNoZone ivp6AddressNoZone = TranslateUtils.arrayToIpv6AddressNoZone(bytes);
- assertEquals(ipv6Addr, ivp6AddressNoZone);
- }
-
- @Test
- public void testByteArrayToMacUnseparated() {
- byte[] address = TranslateUtils.parseMac("aa:bb:cc:dd:ee:ff");
-
- String converted = TranslateUtils.byteArrayToMacUnseparated(address);
-
- assertEquals("aabbccddeeff", converted);
- }
-
- @Test
- public void testByteArrayToMacSeparated() {
- byte[] address = TranslateUtils.parseMac("aa:bb:cc:dd:ee:ff");
-
- String converted = TranslateUtils.byteArrayToMacSeparated(address);
-
- assertEquals("aa:bb:cc:dd:ee:ff", converted);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testByteArrayToMacUnseparatedIllegal() {
- TranslateUtils.byteArrayToMacUnseparated(new byte[]{54, 26, 87, 32, 14});
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testByteArrayToMacSeparatedIllegal() {
- TranslateUtils.byteArrayToMacSeparated(new byte[]{54, 26, 87, 32, 14});
- }
-
- @Test
- public void testIpv4AddressPrefixToArray() {
- byte[] ip = TranslateUtils.ipv4AddressPrefixToArray(new Ipv4Prefix("192.168.2.1/24"));
-
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(ip).getValue());
- }
-
- @Test
- public void testIpv6AddressPrefixToArray() {
- byte[] ip = TranslateUtils.ipv6AddressPrefixToArray(new Ipv6Prefix("3ffe:1900:4545:3:200:f8ff:fe21:67cf/48"));
-
- assertEquals("cf67:21fe:fff8:2:300:4545:19:fe3f", TranslateUtils.arrayToIpv6AddressNoZone(ip).getValue());
- }
-
- @Test
- public void testExtractPrefix() {
- assertEquals(24, TranslateUtils.extractPrefix(new Ipv4Prefix("192.168.2.1/24")));
- assertEquals(48, TranslateUtils.extractPrefix(new Ipv6Prefix("3ffe:1900:4545:3:200:f8ff:fe21:67cf/48")));
- }
-
- @Test
- public void testRevertAddress() {
- assertEquals("1.2.168.192",
- reverseAddress(new IpAddress(new Ipv4Address("192.168.2.1"))).getIpv4Address().getValue());
- assertEquals("3473:7003:2e8a::a385:b80d:120",
- reverseAddress(new IpAddress(new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:7334"))).getIpv6Address()
- .getValue());
- }
-} \ No newline at end of file