summaryrefslogtreecommitdiffstats
path: root/nsh
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
commit60d69218642cc976fa606fd8a38623d8c035dd86 (patch)
treea0ccb089d93198ff7c9974eaf3e39e44a1a1f06d /nsh
parent08cd3ae5fd61d60ec07996179146c956459c084f (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 'nsh')
-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
4 files changed, 114 insertions, 141 deletions
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();