diff options
author | 2016-09-02 13:45:01 +0200 | |
---|---|---|
committer | 2016-09-02 12:40:51 +0000 | |
commit | e562a8f1e0796a9699fc93e5b18de2c386b730f8 (patch) | |
tree | 7be63079381867a26da2b01ce01af3f79e642696 /lisp/lisp2vpp | |
parent | a8453be47c0a54069e3cd10615a80747dec45c28 (diff) |
HONEYCOMB-147 - Bad filtering while dumping local locator-sets
Cherrypicked from https://gerrit.fd.io/r/#/c/2607/2
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')
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))); } |