diff options
18 files changed, 155 insertions, 135 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java index 710bb8d1c..a7167c3ef 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java @@ -20,6 +20,8 @@ package io.fd.hc2vpp.lisp.translate.read; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext; import io.fd.hc2vpp.lisp.context.util.EidMappingContext; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams; @@ -31,8 +33,6 @@ import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; 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.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.vpp.jvpp.core.dto.LispAdjacenciesGet; import io.fd.vpp.jvpp.core.dto.LispAdjacenciesGetReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -70,6 +70,7 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer super(futureJvpp); dumpCacheManager = new DumpCacheManager.DumpCacheManagerBuilder<LispAdjacenciesGetReply, AdjacencyDumpParams>() .withExecutor(createExecutor()) + .acceptOnly(LispAdjacenciesGetReply.class) .build(); this.adjacenciesMappingContext = @@ -155,19 +156,32 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer }; } + private static final class AdjacencyDumpParams { + + private final int vni; + + AdjacencyDumpParams(final int vni) { + this.vni = vni; + } + + public int getVni() { + return this.vni; + } + } + private class EidPairProducer implements EidTranslator { private final EidMappingContext localMappingContext; private final EidMappingContext remoteMappingContext; - public EidPairProducer(final EidMappingContext localMappingContext, - final EidMappingContext remoteMappingContext) { + EidPairProducer(final EidMappingContext localMappingContext, + final EidMappingContext remoteMappingContext) { this.localMappingContext = checkNotNull(localMappingContext, "Local mapping context cannot be null"); this.remoteMappingContext = checkNotNull(remoteMappingContext, "Remote mapping context cannot be null"); } - public EidIdentificatorPair createPair(final LispAdjacency data, final int vni, - final MappingContext mappingContext) { + EidIdentificatorPair createPair(final LispAdjacency data, final int vni, + final MappingContext mappingContext) { return new EidIdentificatorPairBuilder() .setLocalEidId(new MappingId(localMappingContext.getId(getArrayAsEidLocal( MappingsDumpParams.EidType.valueOf(data.eidType), data.leid, vni), mappingContext))) @@ -176,17 +190,4 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer .build(); } } - - private static final class AdjacencyDumpParams { - - private final int vni; - - AdjacencyDumpParams(final int vni) { - this.vni = vni; - } - - public int getVni() { - return this.vni; - } - } } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizer.java index 1e6ce3ab0..726d5eda0 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/BridgeDomainSubtableCustomizer.java @@ -19,6 +19,8 @@ package io.fd.hc2vpp.lisp.translate.read; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.SubtableDumpParams; import io.fd.hc2vpp.lisp.translate.read.trait.SubtableReader; import io.fd.honeycomb.translate.read.ReadContext; @@ -26,8 +28,6 @@ import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -59,6 +59,7 @@ public class BridgeDomainSubtableCustomizer extends FutureJVppCustomizer impleme dumpManager = new DumpCacheManagerBuilder<LispEidTableMapDetailsReplyDump, SubtableDumpParams>() .withExecutor(createExecutor(futureJvppCore)) + .acceptOnly(LispEidTableMapDetailsReplyDump.class) .build(); this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null"); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java index c4bf0b865..0c6cc40d5 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/InterfaceCustomizer.java @@ -21,6 +21,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.LocatorDumpParams; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.LocatorDumpParams.LocatorDumpParamsBuilder; import io.fd.hc2vpp.lisp.translate.read.trait.LocatorReader; @@ -29,8 +31,6 @@ 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.util.read.cache.DumpCacheManager; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.core.dto.LispLocatorDetails; import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -67,6 +67,7 @@ public class InterfaceCustomizer this.dumpCacheManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorDetailsReplyDump, LocatorDumpParams>() .withExecutor(createLocatorDumpExecutor(futureJvpp)) + .acceptOnly(LispLocatorDetailsReplyDump.class) .build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java index eb078fe68..654d1fc3d 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java @@ -20,14 +20,14 @@ package io.fd.hc2vpp.lisp.translate.read; import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; 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.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder; -import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs; import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -51,6 +51,7 @@ public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer .withExecutor(((identifier, params) -> getReplyForRead( futureJVppCore.lispGetMapRequestItrRlocs(new LispGetMapRequestItrRlocs()).toCompletableFuture(), identifier))) + .acceptOnly(LispGetMapRequestItrRlocsReply.class) .build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java index 06d56c185..c6deb0209 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java @@ -24,6 +24,8 @@ import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDump import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.QuantityType; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.lisp.context.util.EidMappingContext; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams; import io.fd.hc2vpp.lisp.translate.read.trait.MappingReader; @@ -33,8 +35,6 @@ 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.util.read.cache.DumpCacheManager; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.core.dto.LispEidTableDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -78,6 +78,7 @@ public class LocalMappingCustomizer this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableDetailsReplyDump, MappingsDumpParams>() .withExecutor(createMappingDumpExecutor(futureJvpp)) + .acceptOnly(LispEidTableDetailsReplyDump.class) .build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java index 9b2ec5ac6..322022a7c 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java @@ -20,14 +20,14 @@ import static com.google.common.base.Preconditions.checkNotNull; import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.lisp.translate.read.trait.LocatorSetReader; 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.read.cache.DumpCacheManager; -import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails; import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -60,6 +60,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer this.locatorSetContext = checkNotNull(locatorSetContext, "Locator Set mapping context cannot be null"); this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorSetDetailsReplyDump, Void>() .withExecutor(createExecutor(futureJvpp)) + .acceptOnly(LispLocatorSetDetailsReplyDump.class) .build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java index cc73d7751..cf6ca8b83 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java @@ -19,14 +19,14 @@ package io.fd.hc2vpp.lisp.translate.read; import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.AddressTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; 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.util.read.cache.DumpCacheManager; -import io.fd.hc2vpp.common.translate.util.AddressTranslator; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails; import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.LispMapResolverDump; @@ -61,6 +61,7 @@ public class MapResolverCustomizer extends FutureJVppCustomizer .withExecutor((identifier, params) -> getReplyForRead( futureJvpp.lispMapResolverDump(new LispMapResolverDump()).toCompletableFuture(), identifier)) + .acceptOnly(LispMapResolverDetailsReplyDump.class) .build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java index 2a36a2576..3b00d2800 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java @@ -25,6 +25,10 @@ import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.l import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.translate.util.AddressTranslator; +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.lisp.context.util.EidMappingContext; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.LocatorDumpParams; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.LocatorDumpParams.LocatorDumpParamsBuilder; @@ -40,11 +44,7 @@ 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.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.common.translate.util.AddressTranslator; -import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.LispEidTableDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.LispLocatorDetails; @@ -105,16 +105,25 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableDetailsReplyDump, MappingsDumpParams>() .withExecutor(createMappingDumpExecutor(futureJvpp)) + .acceptOnly(LispEidTableDetailsReplyDump.class) .build(); // cache key needs to have locator set scope to not mix with cached data this.locatorsDumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorDetailsReplyDump, LocatorDumpParams>() .withExecutor(createLocatorDumpExecutor(futureJvpp)) - .withCacheKeyFactory(new IdentifierCacheKeyFactory(ImmutableSet.of(LocatorSet.class))) + .withCacheKeyFactory(new TypeAwareIdentifierCacheKeyFactory(LispLocatorDetailsReplyDump.class, + ImmutableSet.of(LocatorSet.class))) + .acceptOnly(LispLocatorDetailsReplyDump.class) .build(); } + //compensate ~0 as default value of ttl + private static long resolveTtl(final int ttlValue) { + return ttlValue == -1 + ? Integer.MAX_VALUE + : ttlValue; + } @Override public RemoteMappingBuilder getBuilder(InstanceIdentifier<RemoteMapping> id) { @@ -175,13 +184,6 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer resolveMappings(id, builder, details, ctx.getModificationCache(), ctx.getMappingContext()); } - //compensate ~0 as default value of ttl - private static long resolveTtl(final int ttlValue) { - return ttlValue == -1 - ? Integer.MAX_VALUE - : ttlValue; - } - @Override public List<RemoteMappingKey> getAllIds(InstanceIdentifier<RemoteMapping> id, ReadContext context) throws ReadFailedException { diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java index c0680a7c6..e38ae026b 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java @@ -20,13 +20,13 @@ import static com.google.common.base.Preconditions.checkState; import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; 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.util.read.cache.DumpCacheManager; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDump; @@ -60,6 +60,7 @@ public class VniTableCustomizer extends FutureJVppCustomizer this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableVniDetailsReplyDump, Void>() .withExecutor(((identifier, params) -> getReplyForRead( futureJvpp.lispEidTableVniDump(new LispEidTableVniDump()).toCompletableFuture(), identifier))) + .acceptOnly(LispEidTableVniDetailsReplyDump.class) .build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizer.java index 0a73dc3f2..b092cb485 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VrfSubtableCustomizer.java @@ -19,6 +19,7 @@ package io.fd.hc2vpp.lisp.translate.read; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; import io.fd.hc2vpp.lisp.translate.read.dump.executor.params.SubtableDumpParams; import io.fd.hc2vpp.lisp.translate.read.trait.SubtableReader; import io.fd.honeycomb.translate.read.ReadContext; @@ -26,7 +27,6 @@ import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -54,6 +54,7 @@ public class VrfSubtableCustomizer extends FutureJVppCustomizer super(futureJvpp); dumpManager = new DumpCacheManagerBuilder<LispEidTableMapDetailsReplyDump, SubtableDumpParams>() .withExecutor(createExecutor(futureJvpp)) + .acceptOnly(LispEidTableMapDetailsReplyDump.class) .build(); } diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java index 76c478594..497ed1c96 100644 --- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java +++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java @@ -64,11 +64,13 @@ public class NatReaderFactory implements ReaderFactory { this.mapEntryDumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>() .withExecutor(new MappingEntryCustomizer.MappingEntryDumpExecutor(jvppSnat)) + .acceptOnly(SnatStaticMappingDetailsReplyDump.class) .build(); this.addressRangeDumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatAddressDetailsReplyDump, Void>() .withExecutor(new ExternalIpPoolCustomizer.AddressRangeDumpExecutor(jvppSnat)) + .acceptOnly(SnatAddressDetailsReplyDump.class) .build(); } diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java index 87a70f707..641785281 100644 --- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java +++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java @@ -19,14 +19,14 @@ package io.fd.hc2vpp.nat.read.ifc; import com.google.inject.Inject; import com.google.inject.name.Named; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.impl.read.GenericInitReader; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump; import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDump; import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade; @@ -60,6 +60,7 @@ public final class IfcNatReaderFactory implements ReaderFactory { @Named("interface-context") final NamingContext ifcContext) { this.snatIfcDumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>() .withExecutor(new SnatInterfaceExecutor(jvppSnat)) + .acceptOnly(SnatInterfaceDetailsReplyDump.class) .build(); this.ifcContext = ifcContext; } diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java index b5c0dab53..d4078b0ab 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java @@ -20,13 +20,13 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.common.collect.Lists; +import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.impl.read.GenericReader; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetails; import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump; import org.junit.Test; @@ -60,6 +60,14 @@ public class InterfaceInboundNatCustomizerTest super(Inbound.class, NatBuilder.class); } + static <T extends ChildOf<Nat>> InstanceIdentifier<T> getId(Class<T> boundType) { + return InstanceIdentifier.create(InterfacesState.class) + .child(Interface.class, new InterfaceKey(IFC_NAME)) + .augmentation(NatInterfaceStateAugmentation.class) + .child(Nat.class) + .child(boundType); + } + @Override protected void setUp() throws Exception { id = getId(Inbound.class); @@ -68,17 +76,10 @@ public class InterfaceInboundNatCustomizerTest Mockito.doReturn(new SnatInterfaceDetailsReplyDump()).when(natExecutor).executeDump(id, null); dumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>() .withExecutor(natExecutor) + .acceptOnly(SnatInterfaceDetailsReplyDump.class) .build(); } - static <T extends ChildOf<Nat>> InstanceIdentifier<T> getId(Class<T> boundType) { - return InstanceIdentifier.create(InterfacesState.class) - .child(Interface.class, new InterfaceKey(IFC_NAME)) - .augmentation(NatInterfaceStateAugmentation.class) - .child(Nat.class) - .child(boundType); - } - @Test public void testNoPresence() throws Exception { assertFalse(getReader().read(id, ctx).isPresent()); diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java index 34f5b0949..30f0278cd 100644 --- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java +++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java @@ -21,13 +21,13 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.common.collect.Lists; +import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.impl.read.GenericReader; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetails; import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump; import org.junit.Test; @@ -63,6 +63,7 @@ public class InterfaceOutboundNatCustomizerTest Mockito.doReturn(new SnatInterfaceDetailsReplyDump()).when(abc).executeDump(id, null); dumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>() .withExecutor(abc) + .acceptOnly(SnatInterfaceDetailsReplyDump.class) .build(); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java index a71c0061e..43d82ec5e 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java @@ -19,19 +19,19 @@ package io.fd.hc2vpp.v3po.interfacesstate.ip; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; -import com.google.common.collect.ImmutableSet; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.interfacesstate.InterfaceCustomizer; +import io.fd.hc2vpp.v3po.interfacesstate.ip.dump.params.AddressDumpParams; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.Initialized; import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; import io.fd.honeycomb.translate.util.RWUtils; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.v3po.interfacesstate.InterfaceCustomizer; -import io.fd.hc2vpp.v3po.interfacesstate.ip.dump.params.AddressDumpParams; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.IpAddressDetails; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -72,10 +72,35 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer new DumpCacheManager.DumpCacheManagerBuilder<IpAddressDetailsReplyDump, AddressDumpParams>() .withExecutor(createExecutor(futureJVppCore)) // Key needs to contain interface ID to distinguish dumps between interfaces - .withCacheKeyFactory(new IdentifierCacheKeyFactory(ImmutableSet.of(Interface.class))) + .withCacheKeyFactory(new TypeAwareIdentifierCacheKeyFactory(IpAddressDetailsReplyDump.class, + ImmutableSet.of(Interface.class))) .build(); } + private static Subnet getSubnet(final Address address) { + final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.Subnet + subnet = address.getSubnet(); + + // Only prefix length supported + Preconditions.checkArgument( + subnet instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength); + + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLengthBuilder() + .setPrefixLength( + ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength) subnet) + .getPrefixLength()).build(); + } + + static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address> getCfgId( + final InstanceIdentifier<Address> id) { + return InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class)) + .augmentation(Interface1.class) + .child(Ipv4.class) + .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressKey( + id.firstKeyOf(Address.class).getIp())); + } + @Override @Nonnull public AddressBuilder getBuilder(@Nonnull InstanceIdentifier<Address> id) { @@ -140,27 +165,4 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer .setSubnet(getSubnet(readValue)) .build()); } - - private static Subnet getSubnet(final Address address) { - final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.Subnet - subnet = address.getSubnet(); - - // Only prefix length supported - Preconditions.checkArgument( - subnet instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength); - - return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLengthBuilder() - .setPrefixLength( - ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength) subnet) - .getPrefixLength()).build(); - } - - static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address> getCfgId( - final InstanceIdentifier<Address> id) { - return InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class)) - .augmentation(Interface1.class) - .child(Ipv4.class) - .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address.class, - new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressKey(id.firstKeyOf(Address.class).getIp())); - } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java index 3288e0c35..cb239dc9f 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java @@ -20,18 +20,18 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfacesstate.SubInterfaceCustomizer; import io.fd.hc2vpp.v3po.interfacesstate.ip.dump.params.AddressDumpParams; +import io.fd.hc2vpp.v3po.util.SubInterfaceUtils; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.Initialized; import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; import io.fd.honeycomb.translate.util.RWUtils; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.v3po.util.SubInterfaceUtils; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.IpAddressDetails; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -69,10 +69,16 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpAddressDetailsReplyDump, AddressDumpParams>() .withExecutor(createExecutor(futureJVppCore)) //same as with ipv4 addresses for interfaces, these must have cache scope of their parent sub-interface - .withCacheKeyFactory(new IdentifierCacheKeyFactory(ImmutableSet.of(SubInterface.class))) + .withCacheKeyFactory(new TypeAwareIdentifierCacheKeyFactory(IpAddressDetailsReplyDump.class, + ImmutableSet.of(SubInterface.class))) .build(); } + private static String getSubInterfaceName(@Nonnull final InstanceIdentifier<Address> id) { + return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), + Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier())); + } + @Override @Nonnull public AddressBuilder getBuilder(@Nonnull InstanceIdentifier<Address> id) { @@ -123,11 +129,6 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer ((Ipv4Builder) builder).setAddress(readData); } - private static String getSubInterfaceName(@Nonnull final InstanceIdentifier<Address> id) { - return SubInterfaceUtils.getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), - Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier())); - } - @Override public Initialized<Address> init( @Nonnull final InstanceIdentifier<Address> id, @Nonnull final Address readValue, diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java index bac21c88f..0ab64b21e 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java @@ -27,13 +27,13 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.Ipv4Translator; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.CacheKeyFactory; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.common.translate.util.Ipv4Translator; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.IpAddressDetails; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.IpAddressDump; @@ -76,6 +76,15 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, super(Address.class, Ipv4Builder.class); } + private static InstanceIdentifier<Address> getId(final String address, final String ifaceName) { + return InstanceIdentifier.builder(InterfacesState.class) + .child(Interface.class, new InterfaceKey(ifaceName)) + .augmentation(Interface2.class) + .child(Ipv4.class) + .child(Address.class, new AddressKey(new Ipv4AddressNoZone(new Ipv4Address(address)))) + .build(); + } + @Override public void setUp() { interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME); @@ -96,7 +105,8 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, .child(Address.class, new AddressKey(new Ipv4AddressNoZone("192.168.2.1"))); // to simulate complex key - cacheKeyFactory = new IdentifierCacheKeyFactory(ImmutableSet.of(Interface.class)); + cacheKeyFactory = new TypeAwareIdentifierCacheKeyFactory(IpAddressDetailsReplyDump.class, + ImmutableSet.of(Interface.class)); } @Override @@ -104,15 +114,6 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address, return new Ipv4AddressCustomizer(api, interfacesContext); } - private static InstanceIdentifier<Address> getId(final String address, final String ifaceName) { - return InstanceIdentifier.builder(InterfacesState.class) - .child(Interface.class, new InterfaceKey(ifaceName)) - .augmentation(Interface2.class) - .child(Ipv4.class) - .child(Address.class, new AddressKey(new Ipv4AddressNoZone(new Ipv4Address(address)))) - .build(); - } - @Test public void testReadCurrentAttributesFor2Ifcs() throws ReadFailedException { //changed to mock to not store first dumped data(otherwise that double thenReturn on line 118 is not gonna work) diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java index 4842f5de4..8c67735aa 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizerTest.java @@ -29,13 +29,13 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.Ipv4Translator; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.CacheKeyFactory; -import io.fd.honeycomb.translate.util.read.cache.IdentifierCacheKeyFactory; -import io.fd.hc2vpp.common.translate.util.Ipv4Translator; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.honeycomb.translate.util.read.cache.TypeAwareIdentifierCacheKeyFactory; import io.fd.vpp.jvpp.core.dto.IpAddressDetails; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import java.util.Arrays; @@ -76,19 +76,26 @@ public class SubInterfaceIpv4AddressCustomizerTest extends ListReaderCustomizerT .augmentation(SubinterfaceStateAugmentation.class) .child(SubInterfaces.class).child(SubInterface.class, new SubInterfaceKey(SUB_IF_ID)) .child(Ipv4.class); - private InstanceIdentifier<Address> ifaceOneAddressOneIdentifier; - private InstanceIdentifier<Address> ifaceTwoAddressOneIdentifier; - private CacheKeyFactory cacheKeyFactory; private static final Ipv4AddressNoZone IP1 = new Ipv4AddressNoZone("10.1.1.1"); private static final Ipv4AddressNoZone IP2 = new Ipv4AddressNoZone("10.1.1.2"); private static final short PREFIX_LENGTH = 16; - + private InstanceIdentifier<Address> ifaceOneAddressOneIdentifier; + private InstanceIdentifier<Address> ifaceTwoAddressOneIdentifier; + private CacheKeyFactory cacheKeyFactory; private NamingContext interfaceContext; public SubInterfaceIpv4AddressCustomizerTest() { super(Address.class, Ipv4Builder.class); } + private static InstanceIdentifier<Address> getId() { + return IP4_IID.child(Address.class); + } + + private static InstanceIdentifier<Address> getId(final Ipv4AddressNoZone ip) { + return IP4_IID.child(Address.class, new AddressKey(ip)); + } + @Override protected void setUp() throws Exception { interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME); @@ -109,7 +116,8 @@ public class SubInterfaceIpv4AddressCustomizerTest extends ListReaderCustomizerT .child(Address.class, new AddressKey(new Ipv4AddressNoZone("192.168.2.1"))); // to simulate complex key - cacheKeyFactory = new IdentifierCacheKeyFactory(ImmutableSet.of(SubInterface.class)); + cacheKeyFactory = new TypeAwareIdentifierCacheKeyFactory(IpAddressDetailsReplyDump.class, + ImmutableSet.of(SubInterface.class)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME); defineMapping(mappingContext, SUB_IF_NAME, SUB_IF_INDEX, IFC_CTX_NAME); @@ -121,14 +129,6 @@ public class SubInterfaceIpv4AddressCustomizerTest extends ListReaderCustomizerT return new SubInterfaceIpv4AddressCustomizer(api, interfaceContext); } - private static InstanceIdentifier<Address> getId() { - return IP4_IID.child(Address.class); - } - - private static InstanceIdentifier<Address> getId(final Ipv4AddressNoZone ip) { - return IP4_IID.child(Address.class, new AddressKey(ip)); - } - @Test public void testRead() throws ReadFailedException { final AddressBuilder builder = mock(AddressBuilder.class); |