summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImpl.java26
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImplTest.java11
2 files changed, 24 insertions, 13 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImpl.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImpl.java
index 0aee8e459..99a7a94ee 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImpl.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImpl.java
@@ -16,11 +16,11 @@
package io.fd.hc2vpp.v3po.read.cache;
-import static io.fd.hc2vpp.common.translate.util.JvppReplyConsumer.INSTANCE;
import static java.util.stream.Collectors.toMap;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.v3po.read.InterfaceDataTranslator;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -44,14 +44,14 @@ import org.slf4j.LoggerFactory;
/**
* Manager for dump data of interfaces/sub-interfaces
*/
-final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager {
+final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager, InterfaceDataTranslator {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceCacheDumpManagerImpl.class);
// byNameIndex must be cached, not held as reference here, to have it destroyed with cache after transaction
static final String BY_NAME_INDEX_KEY = InterfaceCacheDumpManagerImpl.class.getName() + "_byNameIndex";
private NamingContext namingContext;
- private final DumpCacheManager<SwInterfaceDetailsReplyDump, String> specificDumpManager;
+ private final DumpCacheManager<SwInterfaceDetailsReplyDump, Integer> specificDumpManager;
private final DumpCacheManager<SwInterfaceDetailsReplyDump, Void> fullDumpManager;
InterfaceCacheDumpManagerImpl(@Nonnull final FutureJVppCore jvpp,
@@ -59,7 +59,8 @@ final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager {
this.namingContext = namingContext;
specificDumpManager = specificInterfaceDumpManager(jvpp);
fullDumpManager = fullInterfaceDumpManager(jvpp,
- new StaticCacheKeyFactory(InterfaceCacheDumpManagerImpl.class.getName() + "_dump", SwInterfaceDetailsReplyDump.class));
+ new StaticCacheKeyFactory(InterfaceCacheDumpManagerImpl.class.getName() + "_dump",
+ SwInterfaceDetailsReplyDump.class));
}
@Override
@@ -95,8 +96,9 @@ final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager {
throws ReadFailedException {
LOG.debug("Interface {} not present in cached data, performing specific dump[{}]", interfaceName,
identifier);
+ int index = namingContext.getIndex(interfaceName, ctx.getMappingContext());
final SwInterfaceDetailsReplyDump reply =
- specificDumpManager.getDump(identifier, ctx.getModificationCache(), interfaceName)
+ specificDumpManager.getDump(identifier, ctx.getModificationCache(), index)
.orElse(new SwInterfaceDetailsReplyDump());
if (reply.swInterfaceDetails.isEmpty()) {
@@ -162,9 +164,9 @@ final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager {
.build();
}
- private static DumpCacheManager<SwInterfaceDetailsReplyDump, String> specificInterfaceDumpManager(
+ private static DumpCacheManager<SwInterfaceDetailsReplyDump, Integer> specificInterfaceDumpManager(
final FutureJVppCore jvpp) {
- return new DumpCacheManager.DumpCacheManagerBuilder<SwInterfaceDetailsReplyDump, String>()
+ return new DumpCacheManager.DumpCacheManagerBuilder<SwInterfaceDetailsReplyDump, Integer>()
.withExecutor(specificInterfaceDumpExecutor(jvpp))
.acceptOnly(SwInterfaceDetailsReplyDump.class)
.build();
@@ -185,14 +187,14 @@ final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager {
};
}
- private static EntityDumpExecutor<SwInterfaceDetailsReplyDump, String> specificInterfaceDumpExecutor(
+ private static EntityDumpExecutor<SwInterfaceDetailsReplyDump, Integer> specificInterfaceDumpExecutor(
final FutureJVppCore api) {
- return (identifier, ifaceName) -> {
+ return (identifier, swIfIndex) -> {
final SwInterfaceDump request = new SwInterfaceDump();
request.swIfIndex = new InterfaceIndex();
- request.swIfIndex.interfaceindex =~0;
- request.nameFilter = ifaceName.getBytes();
- request.nameFilterValid = 1;
+ request.swIfIndex.interfaceindex = swIfIndex;
+ request.nameFilter = "".getBytes();
+ request.nameFilterValid = 0;
final CompletableFuture<SwInterfaceDetailsReplyDump>
swInterfaceDetailsReplyDumpCompletableFuture = api.swInterfaceDump(request).toCompletableFuture();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImplTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImplTest.java
index 04b1d999e..4ee9d8ce3 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImplTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/cache/InterfaceCacheDumpManagerImplTest.java
@@ -88,6 +88,7 @@ public class InterfaceCacheDumpManagerImplTest implements NamingContextHelper, F
// this one is not in full dump
when(jvpp.swInterfaceDump(specificRequest(IFACE_3))).thenReturn(future(specificReplyThree()));
+ when(jvpp.swInterfaceDump(specificRequest(3))).thenReturn(future(specificReplyThree()));
defineMapping(mappingContext, IFACE_0, 0, "interface-context");
defineMapping(mappingContext, IFACE_1, 1, "interface-context");
defineMapping(mappingContext, IFACE_2, 2, "interface-context");
@@ -139,7 +140,7 @@ public class InterfaceCacheDumpManagerImplTest implements NamingContextHelper, F
final SwInterfaceDetails specificDetail = manager.getInterfaceDetail(identifierThree, ctx, IFACE_3);
assertEquals(detailThree(), specificDetail);
- verify(jvpp, times(1)).swInterfaceDump(specificRequest(IFACE_3));
+ verify(jvpp, times(1)).swInterfaceDump(specificRequest(3));
}
private SwInterfaceDetailsReplyDump fullReply() {
@@ -196,6 +197,14 @@ public class InterfaceCacheDumpManagerImplTest implements NamingContextHelper, F
specificRequest.nameFilter = ifaceName.getBytes();
return specificRequest;
}
+ private static SwInterfaceDump specificRequest(final int swIfIndex) {
+ final SwInterfaceDump specificRequest = new SwInterfaceDump();
+ specificRequest.swIfIndex = new InterfaceIndex();
+ specificRequest.swIfIndex.interfaceindex = swIfIndex;
+ specificRequest.nameFilterValid = 0;
+ specificRequest.nameFilter = "".getBytes();
+ return specificRequest;
+ }
private static SwInterfaceDump fullRequest() {
final SwInterfaceDump fullRequest = new SwInterfaceDump();