diff options
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate')
2 files changed, 23 insertions, 19 deletions
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 b60121a45..43be0d4ab 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 @@ -61,12 +61,13 @@ final class InterconnectionReadUtils { } @Nullable - Interconnection readInterconnection(@Nonnull final InstanceIdentifier<?> id, @Nonnull final String ifaceName, @Nonnull final ReadContext ctx) - throws ReadFailedException { + 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, id, ifaceName, - ifaceId, ctx.getModificationCache()); + ifaceId, ctx.getModificationCache()); LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface); final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id); @@ -78,7 +79,7 @@ final class InterconnectionReadUtils { // Set BVI if the bridgeDomainDetails.bviSwIfIndex == current sw if index final Optional<BridgeDomainDetails> bridgeDomainForInterface = - getBridgeDomainForInterface(dumpReply, bdForInterface.get().bdId); + getBridgeDomainForInterface(dumpReply, bdForInterface.get().bdId); // Since we already found an interface assigned to a bridge domain, the details for BD must be present checkState(bridgeDomainForInterface.isPresent()); if (bridgeDomainForInterface.get().bviSwIfIndex == ifaceId) { @@ -111,7 +112,8 @@ final class InterconnectionReadUtils { return reply.bridgeDomainDetails.stream().filter(a -> a.bdId == bdId).findFirst(); } - private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id) throws ReadFailedException { + 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?) @@ -120,10 +122,10 @@ final class InterconnectionReadUtils { request.bdId = -1; final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture = - futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture(); + futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture(); return TranslateUtils.getReply(bdCompletableFuture); } catch (VppBaseCallException e) { - throw new ReadFailedException(id,e); + throw new ReadFailedException(id, e); } } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java index 1db7b8a42..e2d3002d7 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java @@ -64,7 +64,7 @@ public final class InterfaceUtils { private static final int PHYSICAL_ADDRESS_LENGTH = 6; private static final Collector<SwInterfaceDetails, ?, SwInterfaceDetails> SINGLE_ITEM_COLLECTOR = - RWUtils.singleItemCollector(); + RWUtils.singleItemCollector(); private InterfaceUtils() { throw new UnsupportedOperationException("This utility class cannot be instantiated"); @@ -102,6 +102,7 @@ public final class InterfaceUtils { } // TODO rename and move to V3poUtils + /** * Reads first 6 bytes of supplied byte array and converts to string as Yang dictates <p> Replace later with * https://git.opendaylight.org/gerrit/#/c/34869/10/model/ietf/ietf-type- util/src/main/ @@ -118,13 +119,14 @@ public final class InterfaceUtils { public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, int startIndex) { Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes"); - final int endIndex = startIndex+PHYSICAL_ADDRESS_LENGTH; + final int endIndex = startIndex + PHYSICAL_ADDRESS_LENGTH; Preconditions.checkArgument(endIndex <= vppPhysAddress.length, - "Invalid physical address size (%s) for given startIndex (%d), expected >= %d", vppPhysAddress.length, startIndex, endIndex); + "Invalid physical address size (%s) for given startIndex (%d), expected >= %d", vppPhysAddress.length, + startIndex, endIndex); StringBuilder physAddr = new StringBuilder(); appendHexByte(physAddr, vppPhysAddress[startIndex]); - for (int i = startIndex+1; i < endIndex; i++) { + for (int i = startIndex + 1; i < endIndex; i++) { physAddr.append(":"); appendHexByte(physAddr, vppPhysAddress[i]); } @@ -159,21 +161,21 @@ public final class InterfaceUtils { * Queries VPP for interface description given interface key. * * @param futureJvpp VPP Java Future API - * @param id InstanceIdentifier, which is passed in ReadFailedException + * @param id InstanceIdentifier, which is passed in ReadFailedException * @param name interface name * @param index VPP index of the interface * @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not * available or outdated, another dump will be performed. * @return SwInterfaceDetails DTO or null if interface was not found * @throws IllegalArgumentException If interface cannot be found - * @throws ReadFailedException If read operation had failed + * @throws ReadFailedException If read operation had failed */ @Nonnull public static SwInterfaceDetails getVppInterfaceDetails(@Nonnull final FutureJVpp futureJvpp, @Nonnull final InstanceIdentifier<?> id, @Nonnull final String name, final int index, @Nonnull final ModificationCache ctx) - throws ReadFailedException { + throws ReadFailedException { requireNonNull(futureJvpp, "futureJvpp should not be null"); requireNonNull(name, "name should not be null"); requireNonNull(ctx, "ctx should not be null"); @@ -206,7 +208,7 @@ public final class InterfaceUtils { // Update the cache allInterfaces.clear(); allInterfaces - .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d))); + .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d))); if (allInterfaces.containsKey(index)) { return allInterfaces.get(index); @@ -220,7 +222,7 @@ public final class InterfaceUtils { // SwInterfaceDump's name filter does prefix match, so we need additional filtering: final SwInterfaceDetails iface = - ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(SINGLE_ITEM_COLLECTOR); + ifaces.swInterfaceDetails.stream().filter(d -> d.swIfIndex == index).collect(SINGLE_ITEM_COLLECTOR); allInterfaces.put(index, iface); // update the cache return iface; } @@ -253,9 +255,9 @@ public final class InterfaceUtils { } /** - * Check interface type. Uses interface details from VPP to determine. - * Uses {@link #getVppInterfaceDetails(FutureJVpp, InstanceIdentifier, String, int, ModificationCache)} internally - * so tries to utilize cache before asking VPP. + * Check interface type. Uses interface details from VPP to determine. Uses {@link + * #getVppInterfaceDetails(FutureJVpp, InstanceIdentifier, String, int, ModificationCache)} internally so tries to + * utilize cache before asking VPP. */ static boolean isInterfaceOfType(@Nonnull final FutureJVpp jvpp, @Nonnull final ModificationCache cache, |