summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/main/java
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-09-23 16:39:09 +0200
committerJan Srnicek <jsrnicek@cisco.com>2016-09-23 16:41:57 +0200
commita7147d16c31d9028c6b5dc557264433de0f11c91 (patch)
tree15816600ab3dfa5eea706ef1b1910b2e13ae66d7 /lisp/lisp2vpp/src/main/java
parente7a0775b21c2ea6b7bb8efb63b5384df26e27fbb (diff)
HONEYCOMB-145 - Utility Class Refactoring
problematic mockito-all changed to mockito-core( https://github.com/mockito/mockito/issues/324) Translate Utils Splitted to multiple Trait Interfaces Ipv4Translator - Logic for translation of ipv4-based data Ipv6Translator - Logic for translation of ipv6-based data MacTranslator - Logic for translation of mac-based data AddressTranslator - Aggregation trait for Ipv4/Ipv6/Mac JvppReplyConsumer - Logic for extracting replies from jvpp calls ByteDataTranslator - any byte-based conversions Plus some existing utility classes changed to traits Change-Id: I342b625954223966802e65dca0fabf8456c89345 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/main/java')
-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
22 files changed, 166 insertions, 162 deletions
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());
}
}