summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/main
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-09-02 13:45:01 +0200
committerJan Srnicek <jsrnicek@cisco.com>2016-09-02 13:53:13 +0200
commitcaba54834ef80017f2477b0c3355213a4ca57f33 (patch)
tree45b90282c10261fb4f48a2e2c789dacade2a456f /lisp/lisp2vpp/src/main
parent639833bee919ecfae2999857c09bf7d684f2c5b1 (diff)
HONEYCOMB-147 - Bad filtering while dumping local locator-sets
Fixed filtering while dumping only local locator-sets Added automatic learning of previously created locatr-sets(name to index mapping) Change-Id: I5d40c545e76a698ffdda9a092590280b0daca68a Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/main')
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java25
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java3
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java7
3 files changed, 29 insertions, 6 deletions
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 f8da94f1a..52b33815c 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
@@ -16,6 +16,7 @@
package io.fd.honeycomb.lisp.translate.read;
+import static com.google.common.base.Preconditions.checkNotNull;
import static io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor.NO_PARAMS;
import com.google.common.base.Optional;
@@ -25,12 +26,14 @@ 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.v3po.util.cache.DumpCacheManager;
import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSetsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetBuilder;
@@ -52,9 +55,12 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
private static final Logger LOG = LoggerFactory.getLogger(LocatorSetCustomizer.class);
private final DumpCacheManager<LispLocatorSetDetailsReplyDump, Void> dumpManager;
+ private final NamingContext locatorSetContext;
- public LocatorSetCustomizer(FutureJVppCore futureJvpp) {
+ public LocatorSetCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final NamingContext locatorSetContext) {
super(futureJvpp);
+ this.locatorSetContext = checkNotNull(locatorSetContext, "Locator Set mapping context cannot be null");
this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorSetDetailsReplyDump, Void>()
.withExecutor(new LocatorSetsDumpExecutor(futureJvpp))
.withNonEmptyPredicate(new LocatorSetsDumpCheck())
@@ -91,7 +97,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
.findFirst();
if (details.isPresent()) {
- final String name = TranslateUtils.toString(details.get().locatorSetName);
+ final String name = TranslateUtils.toString(details.get().locatorSetName);
builder.setName(name);
builder.setKey(new LocatorSetKey(name));
@@ -115,6 +121,21 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
if (dumpOptional.isPresent()) {
return dumpOptional.get().lispLocatorSetDetails.stream()
+ .map(set -> {
+
+ final String locatorSetName = TranslateUtils.toString(set.locatorSetName);
+ //creates mapping for existing locator-set(if it is'nt already existing one)
+ if (!locatorSetContext.containsIndex(locatorSetName, context.getMappingContext())) {
+ locatorSetContext.addName(set.locatorSetIndex, locatorSetName, context.getMappingContext());
+ }
+
+ LOG.trace("Locator Set with name: {}, VPP name: {} and index: {} found in VPP",
+ locatorSetContext.getName(set.locatorSetIndex, context.getMappingContext()),
+ locatorSetName,
+ set.locatorSetIndex);
+
+ return set;
+ })
.map(set -> new LocatorSetKey(TranslateUtils.toString(set.locatorSetName)))
.collect(Collectors.toList());
} else {
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 d074bae52..abafdc7a7 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
@@ -41,7 +41,8 @@ public class LocatorSetsDumpExecutor extends AbstractDumpExecutor
public LispLocatorSetDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException {
LispLocatorSetDump request = new LispLocatorSetDump();
- request.filter = 0;
+ //only local
+ request.filter = 1;
try {
return TranslateUtils
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
index 053f3d858..3d0801969 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
@@ -45,7 +45,7 @@ public class LocatorSetsReaderFactory extends AbstractLispReaderFactoryBase impl
final NamingContext locatorSetContext
) {
super(lispStateId, vppApi);
- this.interfaceContext=interfaceContext;
+ this.interfaceContext = interfaceContext;
this.locatorSetContext = locatorSetContext;
}
@@ -53,7 +53,7 @@ public class LocatorSetsReaderFactory extends AbstractLispReaderFactoryBase impl
@Nonnull final FutureJVppCore vppApi,
final NamingContext interfaceContext,
@Nonnull final NamingContext locatorSetContext) {
- return new LocatorSetsReaderFactory(lispStateId, vppApi, interfaceContext,locatorSetContext);
+ return new LocatorSetsReaderFactory(lispStateId, vppApi, interfaceContext, locatorSetContext);
}
@Override
@@ -63,7 +63,8 @@ public class LocatorSetsReaderFactory extends AbstractLispReaderFactoryBase impl
locatorSetsInstanceIdentifier.child(LocatorSet.class);
registry.addStructuralReader(locatorSetsInstanceIdentifier, LocatorSetsBuilder.class);
- registry.add(new GenericListReader<>(locatorSetInstanceIdentifier, new LocatorSetCustomizer(vppApi)));
+ registry.add(new GenericListReader<>(locatorSetInstanceIdentifier,
+ new LocatorSetCustomizer(vppApi, locatorSetContext)));
registry.add(new GenericListReader<>(locatorSetInstanceIdentifier.child(Interface.class),
new InterfaceCustomizer(vppApi, interfaceContext, locatorSetContext)));
}