summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-08-16 08:09:19 +0200
committerJan Srnicek <jsrnicek@cisco.com>2017-08-16 08:09:19 +0200
commit3a7a67fe142749eb6b41f660d101f3fdffb8b3de (patch)
tree2e565e89ae1b0c39b7e328a5e5dab12a323585ce /v3po/v3po2vpp/src/main/java/io
parentc14b1fd0cee29fc2cd9d1ff395bdf2209f79bd48 (diff)
HC2VPP-22 - Interconnetion improvements
Change-Id: I0abb937df505663ecbae47f4c4a75681b3ff75be Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java34
1 files changed, 17 insertions, 17 deletions
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<BridgeDomainDetailsReplyDump,Void> 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<BridgeDomainDetailsReplyDump, Void>()
+ .acceptOnly(BridgeDomainDetailsReplyDump.class)
+ .withExecutor((id, params) -> {
+ final BridgeDomainDump request = new BridgeDomainDump();
+ request.bdId = -1;
+
+ final CompletableFuture<BridgeDomainDetailsReplyDump> 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<BridgeDomainSwIf> 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<BridgeDomainDetailsReplyDump> bdCompletableFuture =
- futureJVppCore.bridgeDomainDump(request).toCompletableFuture();
- return getReplyForRead(bdCompletableFuture, id);
-
- }
}