From 3a7a67fe142749eb6b41f660d101f3fdffb8b3de Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Wed, 16 Aug 2017 08:09:19 +0200 Subject: HC2VPP-22 - Interconnetion improvements Change-Id: I0abb937df505663ecbae47f4c4a75681b3ff75be Signed-off-by: Jan Srnicek --- .../interfacesstate/InterconnectionReadUtils.java | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io/fd') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java index a25531303..4209f2a11 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java @@ -17,12 +17,14 @@ package io.fd.hc2vpp.v3po.interfacesstate; import static com.google.common.base.Preconditions.checkState; +import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; import static java.util.Objects.requireNonNull; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.vpp.jvpp.core.dto.BridgeDomainDetails; import io.fd.vpp.jvpp.core.dto.BridgeDomainDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.BridgeDomainDump; @@ -47,19 +49,30 @@ final class InterconnectionReadUtils implements InterfaceDataTranslator { private static final Logger LOG = LoggerFactory.getLogger(InterconnectionReadUtils.class); - private final FutureJVppCore futureJVppCore; private final NamingContext interfaceContext; private final NamingContext bridgeDomainContext; private final InterfaceCacheDumpManager dumpManager; + private final DumpCacheManager bdDumpManager; InterconnectionReadUtils(@Nonnull final FutureJVppCore futureJVppCore, @Nonnull final NamingContext interfaceContext, @Nonnull final NamingContext bridgeDomainContext, @Nonnull final InterfaceCacheDumpManager dumpManager) { - this.futureJVppCore = requireNonNull(futureJVppCore, "futureJVppCore should not be null"); + requireNonNull(futureJVppCore, "futureJVppCore should not be null"); this.interfaceContext = requireNonNull(interfaceContext, "interfaceContext should not be null"); this.bridgeDomainContext = requireNonNull(bridgeDomainContext, "bridgeDomainContext should not be null"); this.dumpManager = requireNonNull(dumpManager, "dumpManager should not be null"); + this.bdDumpManager = new DumpCacheManager.DumpCacheManagerBuilder() + .acceptOnly(BridgeDomainDetailsReplyDump.class) + .withExecutor((id, params) -> { + final BridgeDomainDump request = new BridgeDomainDump(); + request.bdId = -1; + + final CompletableFuture bdCompletableFuture = + futureJVppCore.bridgeDomainDump(request).toCompletableFuture(); + return getReplyForRead(bdCompletableFuture, id); + }) + .build(); } @Nullable @@ -71,7 +84,8 @@ final class InterconnectionReadUtils implements InterfaceDataTranslator { final SwInterfaceDetails iface = dumpManager.getInterfaceDetail(id, ctx, ifaceName); LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface); - final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id); + final BridgeDomainDetailsReplyDump dumpReply = bdDumpManager.getDump(id, ctx.getModificationCache(), NO_PARAMS) + .or(new BridgeDomainDetailsReplyDump()); for (final BridgeDomainDetails bd : dumpReply.bridgeDomainDetails) { final Optional bdIfAssignment = getBridgeDomainSwIf(ifaceId, bd); if (bdIfAssignment.isPresent()) { @@ -113,18 +127,4 @@ final class InterconnectionReadUtils implements InterfaceDataTranslator { int bdId) { return reply.bridgeDomainDetails.stream().filter(a -> a.bdId == bdId).findFirst(); } - - private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier id) - throws ReadFailedException { - // We need to perform full bd dump, because there is no way - // to ask VPP for BD details given interface id/name (TODO HC2VPP-22 add it to vpp.api?) - // TODO HC2VPP-22 cache dump result - final BridgeDomainDump request = new BridgeDomainDump(); - request.bdId = -1; - - final CompletableFuture bdCompletableFuture = - futureJVppCore.bridgeDomainDump(request).toCompletableFuture(); - return getReplyForRead(bdCompletableFuture, id); - - } } -- cgit 1.2.3-korg