From 744551ed3b657da9f6c8d06bfed4dba4c9fc7700 Mon Sep 17 00:00:00 2001 From: Tibor Sirovatka Date: Mon, 30 May 2016 16:52:57 +0200 Subject: HONEYCOMB-67 Introduce exception handling into JVPP VppApiInvocationException replaced by VPP VPPBaseCallException(s) VppInvocationException - send request failed VppCallbackException - operation had failed (negative result) Change-Id: I897afead8d65ef1240e657116a0610850c62348f Signed-off-by: Tibor Sirovatka --- .../interfacesstate/InterconnectionReadUtils.java | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java index 886549ac3..f5c0e5972 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java @@ -29,6 +29,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.openvpp.jvpp.VppBaseCallException; import org.openvpp.jvpp.dto.BridgeDomainDetails; import org.openvpp.jvpp.dto.BridgeDomainDetailsReplyDump; import org.openvpp.jvpp.dto.BridgeDomainDump; @@ -59,15 +61,15 @@ final class InterconnectionReadUtils { } @Nullable - Interconnection readInterconnection(@Nonnull final String ifaceName, @Nonnull final ReadContext ctx) + Interconnection readInterconnection(@Nonnull final InstanceIdentifier id, @Nonnull final String ifaceName, @Nonnull final ReadContext ctx) throws ReadFailedException { final int ifaceId = interfaceContext.getIndex(ifaceName, ctx.getMappingContext()); - final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJvpp, ifaceName, + final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJvpp, id, ifaceName, ifaceId, ctx.getModificationCache()); LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface); - final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(); + final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id); final Optional bdForInterface = getBridgeDomainForInterface(ifaceId, dumpReply); if (bdForInterface.isPresent()) { final BridgeDomainSwIfDetails bdSwIfDetails = bdForInterface.get(); @@ -107,15 +109,19 @@ final class InterconnectionReadUtils { return reply.bridgeDomainDetails.stream().filter(a -> a.bdId == bdId).findFirst(); } - private BridgeDomainDetailsReplyDump getDumpReply() { - // We need to perform full bd dump, because there is no way - // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?) - // TODO cache dump result - final BridgeDomainDump request = new BridgeDomainDump(); - request.bdId = -1; - - final CompletableFuture bdCompletableFuture = - futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture(); - return TranslateUtils.getReply(bdCompletableFuture); + private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier id) throws ReadFailedException { + try { + // We need to perform full bd dump, because there is no way + // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?) + // TODO cache dump result + final BridgeDomainDump request = new BridgeDomainDump(); + request.bdId = -1; + + final CompletableFuture bdCompletableFuture = + futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture(); + return TranslateUtils.getReply(bdCompletableFuture); + } catch (VppBaseCallException e) { + throw new ReadFailedException(id,e); + } } } -- cgit 1.2.3-korg