summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-07-11 12:20:06 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-07-18 10:33:31 +0000
commitd4d78fa86e8b36cef4f24449512aabe8687b42cc (patch)
tree66192f5c6ad37d69c37658c7cf7bb74306b4b14c /lisp
parentdabd8f1b137c311935c984bed8c79931c79640cc (diff)
HC2VPP-185 - create artificial mapping if not contained in mapping
Change-Id: Ide0dd4581452cbff935df500c73d50afbbecdcbf Signed-off-by: Jan Srnicek <jsrnicek@cisco.com> (cherry picked from commit 96813eec73e2992c89c013b03f9c1265f91027b6)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java
index 9cb489940..25983b1a3 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java
@@ -22,8 +22,10 @@ import com.google.common.base.Optional;
import io.fd.hc2vpp.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.util.RWUtils;
+
import java.util.stream.Collector;
import javax.annotation.Nonnull;
+
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.Contexts;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.EidMappingContextKey;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.Mappings;
@@ -72,7 +74,13 @@ public class EidMappingContext implements EidTranslator {
@Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
- if (!read.isPresent()) {
+ // create artificial mapping if no mapping present or does not contain key
+ // !read.isPresent() - no mappings are present,
+ // for example after restart and clean of persistence
+ // !containsId() - can happen with case described above after first mapping is
+ // created or if trying to find mapping for some eid that was created by vpp as
+ // byproduct of other call, or while trying to find mapping for default data
+ if (!read.isPresent() || !containsId(remoteEid, mappingContext)) {
final MappingId artificialMappingId = getMappingId(remoteEid.toString(), artificialPrefix);
addEid(artificialMappingId, remoteEid, mappingContext);
return artificialMappingId;
@@ -102,7 +110,13 @@ public class EidMappingContext implements EidTranslator {
@Nonnull final MappingContext mappingContext) {
final Optional<Mappings> read = mappingContext.read(namingContextIid.child(Mappings.class));
- if (!read.isPresent()) {
+ // create artificial mapping if no mapping present or does not contain key
+ // !read.isPresent() - no mappings are present,
+ // for example after restart and clean of persistence
+ // !containsId() - can happen with case described above after first mapping is
+ // created or if trying to find mapping for some eid that was created by vpp as
+ // byproduct of other call, or while trying to find mapping for default data
+ if (!read.isPresent() || !containsId(eid, mappingContext)) {
final MappingId artificialMappingId = getMappingId(eid.toString(), artificialPrefix);
addEid(artificialMappingId, eid, mappingContext);
return artificialMappingId;