diff options
author | 2016-06-13 14:58:50 +0200 | |
---|---|---|
committer | 2016-06-15 10:32:09 +0000 | |
commit | cc306a6e41824f2de2fe9f3cd2f788c7e5c41cd5 (patch) | |
tree | 537b1ae2d6b17f003e2fec0dfddd9cbaf17ab4fa /v3po/v3po2vpp/src/main/java | |
parent | cb00de1bc91091060dfb688876b45b7dc740318e (diff) |
HONEYCOMB-91: initializer for L2 FIB tables
Change-Id: I7f133ea56fc3bb11e0f4b584839dabc0754a8d50
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java')
10 files changed, 147 insertions, 110 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/VppInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/VppInitializer.java index da943f530..4cb4a92e9 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/VppInitializer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/VppInitializer.java @@ -25,6 +25,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.L2FibTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.L2FibTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.l2.fib.table.L2FibEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomainsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder; @@ -58,22 +61,39 @@ public class VppInitializer extends AbstractDataTreeConverter<VppState, Vpp> { } private static final Function<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain, BridgeDomain> - CONVERT_BD = - new Function<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain, BridgeDomain>() { - @Nullable - @Override - public BridgeDomain apply( - @Nullable final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain input) { - final BridgeDomainBuilder builder = new BridgeDomainBuilder(); - builder.setLearn(input.isLearn()); - builder.setUnknownUnicastFlood(input.isUnknownUnicastFlood()); - builder.setArpTermination(input.isArpTermination()); - builder.setFlood(input.isFlood()); - builder.setForward(input.isForward()); - builder.setKey(new BridgeDomainKey(input.getKey().getName())); - // bdBuilder.setL2Fib(bd.getL2Fib()); // TODO we need state=>oper converter for L2Fib - builder.setName(input.getName()); - return builder.build(); - } - }; + CONVERT_BD = + new Function<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain, BridgeDomain>() { + @Nullable + @Override + public BridgeDomain apply( + @Nullable final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain input) { + final BridgeDomainBuilder builder = new BridgeDomainBuilder(); + builder.setLearn(input.isLearn()); + builder.setUnknownUnicastFlood(input.isUnknownUnicastFlood()); + builder.setArpTermination(input.isArpTermination()); + builder.setFlood(input.isFlood()); + builder.setForward(input.isForward()); + builder.setKey(new BridgeDomainKey(input.getKey().getName())); + builder.setName(input.getName()); + setL2FibTable(builder, input.getL2FibTable()); + return builder.build(); + } + }; + + private static void setL2FibTable(@Nonnull final BridgeDomainBuilder builder, + @Nullable final L2FibTable l2FibTable) { + if (l2FibTable == null) { + return; + } + final L2FibTableBuilder tableBuilder = new L2FibTableBuilder(); + tableBuilder.setL2FibEntry( + Lists.transform(l2FibTable.getL2FibEntry(), + oper -> { + final L2FibEntryBuilder config = new L2FibEntryBuilder(oper); + config.setBridgedVirtualInterface(null); + return config.build(); + })); + builder.setL2FibTable(tableBuilder.build()); + } + } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java index b3b05500a..463acc84e 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java @@ -61,7 +61,7 @@ final class InterconnectionWriteUtils { void setInterconnection(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex, final String ifcName, final Interconnection ic, final WriteContext writeContext) - throws WriteFailedException { + throws WriteFailedException { try { if (ic == null) { // TODO in case of update we should delete interconnection LOG.trace("Interconnection is not set. Skipping"); @@ -78,35 +78,36 @@ final class InterconnectionWriteUtils { throw new WriteFailedException(id, "Unable to handle Interconnection of type " + ic.getClass()); } } catch (VppBaseCallException e) { - LOG.warn("Failed to update bridge/xconnect based interconnection flags for: {}, interconnection: {}", ifcName, ic); + LOG.warn("Failed to update bridge/xconnect based interconnection flags for: {}, interconnection: {}", + ifcName, ic); throw new WriteFailedException(id, "Unable to handle Interconnection of type " + ic.getClass(), e); } } private void setBridgeBasedL2(final int swIfIndex, final String ifcName, final BridgeBased bb, final WriteContext writeContext) - throws VppBaseCallException { + throws VppBaseCallException { LOG.debug("Setting bridge based interconnection(bridge-domain={}) for interface: {}", bb.getBridgeDomain(), - ifcName); + ifcName); String bdName = bb.getBridgeDomain(); int bdId = bridgeDomainContext.getIndex(bdName, writeContext.getMappingContext()); checkArgument(bdId > 0, "Unable to set Interconnection for Interface: %s, bridge domain: %s does not exist", - ifcName, bdName); + ifcName, bdName); byte bvi = bb.isBridgedVirtualInterface() - ? (byte) 1 - : (byte) 0; + ? (byte) 1 + : (byte) 0; byte shg = 0; if (bb.getSplitHorizonGroup() != null) { shg = bb.getSplitHorizonGroup().byteValue(); } final CompletionStage<SwInterfaceSetL2BridgeReply> swInterfaceSetL2BridgeReplyCompletionStage = futureJvpp - .swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bvi, (byte) 1 /* enable */)); + .swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bvi, (byte) 1 /* enable */)); final SwInterfaceSetL2BridgeReply reply = - TranslateUtils.getReply(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture()); + TranslateUtils.getReply(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture()); LOG.debug("Bridge based interconnection updated successfully for: {}, interconnection: {}", ifcName, bb); } @@ -124,20 +125,20 @@ final class InterconnectionWriteUtils { private void setXconnectBasedL2(final int swIfIndex, final String ifcName, final XconnectBased ic, final WriteContext writeContext) - throws VppBaseCallException { + throws VppBaseCallException { String outSwIfName = ic.getXconnectOutgoingInterface(); LOG.debug("Setting xconnect based interconnection(outgoing ifc={}) for interface: {}", outSwIfName, ifcName); int outSwIfIndex = interfaceContext.getIndex(outSwIfName, writeContext.getMappingContext()); checkArgument(outSwIfIndex > 0, - "Unable to set Interconnection for Interface: %s, outgoing interface: %s does not exist", - ifcName, outSwIfIndex); + "Unable to set Interconnection for Interface: %s, outgoing interface: %s does not exist", + ifcName, outSwIfIndex); final CompletionStage<SwInterfaceSetL2XconnectReply> swInterfaceSetL2XconnectReplyCompletionStage = - futureJvpp - .swInterfaceSetL2Xconnect(getL2XConnectRequest(swIfIndex, outSwIfIndex, (byte) 1 /* enable */)); + futureJvpp + .swInterfaceSetL2Xconnect(getL2XConnectRequest(swIfIndex, outSwIfIndex, (byte) 1 /* enable */)); final SwInterfaceSetL2XconnectReply reply = - TranslateUtils.getReply(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture()); + TranslateUtils.getReply(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture()); LOG.debug("Xconnect based interconnection updated successfully for: {}, interconnection: {}", ifcName, ic); } 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, diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java index 371e39471..710a74be5 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java @@ -43,8 +43,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BridgeDomainCustomizer - extends FutureJVppCustomizer - implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey> { + extends FutureJVppCustomizer + implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey> { private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class); @@ -59,12 +59,12 @@ public class BridgeDomainCustomizer @Nonnull @Override public Optional<List<BridgeDomain>> extract(@Nonnull final InstanceIdentifier<BridgeDomain> currentId, - @Nonnull final DataObject parentData) { + @Nonnull final DataObject parentData) { return Optional.fromNullable(((BridgeDomains) parentData).getBridgeDomain()); } private BridgeDomainAddDelReply addOrUpdateBridgeDomain(final int bdId, @Nonnull final BridgeDomain bd) - throws VppBaseCallException { + throws VppBaseCallException { final BridgeDomainAddDelReply reply; final BridgeDomainAddDel request = new BridgeDomainAddDel(); request.bdId = bdId; @@ -84,7 +84,7 @@ public class BridgeDomainCustomizer public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final BridgeDomain dataBefore, @Nonnull final WriteContext ctx) - throws WriteFailedException.CreateFailedException { + throws WriteFailedException.CreateFailedException { LOG.debug("writeCurrentAttributes: id={}, current={}, ctx={}", id, dataBefore, ctx); final String bdName = dataBefore.getName(); @@ -93,7 +93,7 @@ public class BridgeDomainCustomizer // (maybe in context similar to artificial name) // Here we assign the next available ID from bdContext's perspective int index = 1; - while(bdContext.containsName(index, ctx.getMappingContext())) { + while (bdContext.containsName(index, ctx.getMappingContext())) { index++; } addOrUpdateBridgeDomain(index, dataBefore); @@ -106,41 +106,42 @@ public class BridgeDomainCustomizer private byte booleanToByte(@Nullable final Boolean aBoolean) { return aBoolean != null && aBoolean - ? (byte) 1 - : (byte) 0; + ? (byte) 1 + : (byte) 0; } @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final BridgeDomain dataBefore, - @Nonnull final WriteContext ctx) throws WriteFailedException.DeleteFailedException { + @Nonnull final WriteContext ctx) + throws WriteFailedException.DeleteFailedException { LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx); final String bdName = id.firstKeyOf(BridgeDomain.class).getName(); - int bdId = bdId = bdContext.getIndex(bdName, ctx.getMappingContext()); + int bdId = bdContext.getIndex(bdName, ctx.getMappingContext()); try { final BridgeDomainAddDel request = new BridgeDomainAddDel(); request.bdId = bdId; - final BridgeDomainAddDelReply reply = - TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture()); + TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture()); LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId); } catch (VppBaseCallException e) { LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId); - throw new WriteFailedException.DeleteFailedException(id,e); + throw new WriteFailedException.DeleteFailedException(id, e); } } @Override public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final BridgeDomain dataBefore, @Nonnull final BridgeDomain dataAfter, - @Nonnull final WriteContext ctx) throws WriteFailedException.UpdateFailedException { + @Nonnull final WriteContext ctx) + throws WriteFailedException.UpdateFailedException { LOG.debug("updateCurrentAttributes: id={}, dataBefore={}, dataAfter={}, ctx={}", id, dataBefore, dataAfter, - ctx); + ctx); final String bdName = checkNotNull(dataAfter.getName()); checkArgument(bdName.equals(dataBefore.getName()), - "BridgeDomain name changed. It should be deleted and then created."); + "BridgeDomain name changed. It should be deleted and then created."); try { addOrUpdateBridgeDomain(bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/L2FibEntryCustomizer.java index 712938190..b4a51b01a 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/L2FibEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/L2FibEntryCustomizer.java @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory; * VPP.<br> Equivalent of invoking {@code vppctl l2fib add/del} command. */ public class L2FibEntryCustomizer extends FutureJVppCustomizer - implements ListWriterCustomizer<L2FibEntry, L2FibEntryKey> { + implements ListWriterCustomizer<L2FibEntry, L2FibEntryKey> { private static final Logger LOG = LoggerFactory.getLogger(L2FibEntryCustomizer.class); @@ -75,7 +75,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry dataAfter, @Nonnull final WriteContext writeContext) - throws WriteFailedException.CreateFailedException { + throws WriteFailedException.CreateFailedException { try { LOG.debug("Creating L2 FIB entry: {} {}", id, dataAfter); l2FibAddDel(id, dataAfter, writeContext, true); @@ -91,13 +91,13 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer @Nonnull final L2FibEntry dataBefore, @Nonnull final L2FibEntry dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { throw new UnsupportedOperationException( - "L2 FIB entry update is not supported. It has to be deleted and then created."); + "L2 FIB entry update is not supported. It has to be deleted and then created."); } @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry dataBefore, @Nonnull final WriteContext writeContext) - throws WriteFailedException.DeleteFailedException { + throws WriteFailedException.DeleteFailedException { try { LOG.debug("Deleting L2 FIB entry: {} {}", id, dataBefore); l2FibAddDel(id, dataBefore, writeContext, false); @@ -122,7 +122,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer final L2FibAddDel l2FibRequest = createL2FibRequest(entry, bdId, swIfIndex, isAdd); LOG.debug("Sending l2FibAddDel request: {}", ReflectionToStringBuilder.toString(l2FibRequest)); final CompletionStage<L2FibAddDelReply> l2FibAddDelReplyCompletionStage = - getFutureJVpp().l2FibAddDel(l2FibRequest); + getFutureJVpp().l2FibAddDel(l2FibRequest); TranslateUtils.getReply(l2FibAddDelReplyCompletionStage.toCompletableFuture()); } @@ -145,6 +145,6 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer private static long macToLong(final String macAddress) { final byte[] mac = parseMac(macAddress); return Longs.fromBytes(mac[0], mac[1], mac[2], mac[3], - mac[4], mac[5], (byte) 0, (byte) 0); + mac[4], mac[5], (byte) 0, (byte) 0); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java index 4f0b0f741..1ef6fcec3 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java @@ -44,7 +44,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class BridgeDomainCustomizer extends FutureJVppCustomizer - implements ListReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> { + implements ListReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> { private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class); private final NamingContext bdContext; @@ -57,9 +57,9 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final BridgeDomainBuilder builder, @Nonnull final ReadContext context) - throws ReadFailedException { + throws ReadFailedException { LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: id={}, builderbuilder={}, context={}", - id, builder, context); + id, builder, context); final BridgeDomainKey key = id.firstKeyOf(id.getTargetType()); LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: key={}", key); @@ -123,7 +123,7 @@ public final class BridgeDomainCustomizer extends FutureJVppCustomizer throw new IllegalStateException("Bridge domain dump failed", e); // TODO ReadFailedException? } - if(reply == null || reply.bridgeDomainDetails == null) { + if (reply == null || reply.bridgeDomainDetails == null) { return Collections.emptyList(); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizer.java index f3393c26d..b7ff1e70d 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizer.java @@ -55,12 +55,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class L2FibEntryCustomizer extends FutureJVppCustomizer - implements ListReaderCustomizer<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder> { + implements ListReaderCustomizer<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder> { private static final Logger LOG = LoggerFactory.getLogger(L2FibEntryCustomizer.class); - Collector<L2FibTableEntry, ?, L2FibTableEntry> SINGLE_ITEM_COLLECTOR = - RWUtils.singleItemCollector(); + private static final Collector<L2FibTableEntry, ?, L2FibTableEntry> SINGLE_ITEM_COLLECTOR = + RWUtils.singleItemCollector(); private final NamingContext bdContext; private final NamingContext interfaceContext; @@ -75,7 +75,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntryBuilder builder, @Nonnull final ReadContext ctx) - throws ReadFailedException { + throws ReadFailedException { final L2FibEntryKey key = id.firstKeyOf(id.getTargetType()); final BridgeDomainKey bridgeDomainKey = id.firstKeyOf(BridgeDomain.class); @@ -85,12 +85,12 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer try { // TODO use cached l2FibTable final L2FibTableEntry entry = dumpL2Fibs(bdId).stream().filter(e -> key.getPhysAddress() - .equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2)))) - .collect(SINGLE_ITEM_COLLECTOR); + .equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2)))) + .collect(SINGLE_ITEM_COLLECTOR); builder.setAction(byteToBoolean(entry.filterMac) - ? L2FibFilter.class - : L2FibForward.class); + ? L2FibFilter.class + : L2FibForward.class); builder.setBridgedVirtualInterface(byteToBoolean(entry.bviMac)); if (entry.swIfIndex != -1) { @@ -110,7 +110,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer l2FibRequest.bdId = bdId; final CompletableFuture<L2FibTableEntryReplyDump> l2FibTableDumpCompletableFuture = - getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture(); + getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture(); final L2FibTableEntryReplyDump dump = TranslateUtils.getReply(l2FibTableDumpCompletableFuture); @@ -131,8 +131,8 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer LOG.debug("Reading L2 FIB for bridge domain {} (bdId={})", bridgeDomainKey, bdId); try { return dumpL2Fibs(bdId).stream() - .map(entry -> new L2FibEntryKey(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(entry.mac), 2))) - ).collect(Collectors.toList()); + .map(entry -> new L2FibEntryKey(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(entry.mac), 2))) + ).collect(Collectors.toList()); } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); } diff --git a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppHoneycombWriterModule.java b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppHoneycombWriterModule.java index fbd7cd597..6bf3da104 100644 --- a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppHoneycombWriterModule.java +++ b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppHoneycombWriterModule.java @@ -21,12 +21,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey; import org.opendaylight.yangtools.yang.binding.ChildOf; -public class VppHoneycombWriterModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractVppHoneycombWriterModule { - public VppHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { +public class VppHoneycombWriterModule extends + org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractVppHoneycombWriterModule { + public VppHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public VppHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.VppHoneycombWriterModule oldModule, java.lang.AutoCloseable oldInstance) { + public VppHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.VppHoneycombWriterModule oldModule, + java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @@ -39,7 +44,7 @@ public class VppHoneycombWriterModule extends org.opendaylight.yang.gen.v1.urn.h public java.lang.AutoCloseable createInstance() { final CompositeListWriter<BridgeDomain, BridgeDomainKey> bridgeDomainWriter = new CompositeListWriter<>( BridgeDomain.class, - RWUtils.singletonChildWriterList(l2FibTableWriter()), + RWUtils.singletonChildWriterList(l2FibTableWriter()), new BridgeDomainCustomizer(getVppJvppWriterDependency(), getBridgeDomainContextVppDependency())); final ChildWriter<BridgeDomains> bridgeDomainsWriter = new CompositeChildWriter<>( @@ -57,18 +62,18 @@ public class VppHoneycombWriterModule extends org.opendaylight.yang.gen.v1.urn.h } private ChildWriter l2FibTableWriter() { - final CompositeListWriter<L2FibEntry, L2FibEntryKey> l2FibEntryWriter = new CompositeListWriter<>(L2FibEntry.class, + final CompositeListWriter<L2FibEntry, L2FibEntryKey> l2FibEntryWriter = + new CompositeListWriter<>(L2FibEntry.class, new L2FibEntryCustomizer(getVppJvppWriterDependency(), - getBridgeDomainContextVppDependency(), getInterfaceContextVppDependency())); + getBridgeDomainContextVppDependency(), getInterfaceContextVppDependency())); final ChildWriter<L2FibTable> l2FibTableWriter = new CompositeChildWriter<>( - L2FibTable.class, - RWUtils.singletonChildWriterList(l2FibEntryWriter), - new ReflexiveChildWriterCustomizer<>()); + L2FibTable.class, + RWUtils.singletonChildWriterList(l2FibEntryWriter), + new ReflexiveChildWriterCustomizer<>()); return l2FibTableWriter; } - } diff --git a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppStateHoneycombReaderModule.java b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppStateHoneycombReaderModule.java index f56c824a6..abbde23ab 100644 --- a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppStateHoneycombReaderModule.java +++ b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/VppStateHoneycombReaderModule.java @@ -43,15 +43,20 @@ import org.openvpp.jvpp.future.FutureJVpp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class VppStateHoneycombReaderModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractVppStateHoneycombReaderModule { +public class VppStateHoneycombReaderModule extends + org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractVppStateHoneycombReaderModule { private static final Logger LOG = LoggerFactory.getLogger(VppStateHoneycombReaderModule.class); - public VppStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + public VppStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public VppStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.VppStateHoneycombReaderModule oldModule, java.lang.AutoCloseable oldInstance) { + public VppStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.VppStateHoneycombReaderModule oldModule, + java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @@ -72,20 +77,21 @@ public class VppStateHoneycombReaderModule extends org.opendaylight.yang.gen.v1. versionReader = new KeepaliveReaderWrapper<>(versionReader, getKeepaliveExecutorDependency().getExecutor(), ReadTimeoutException.class, 30, () -> reinitializeJVpp(reinitializationCounter)); - final CompositeListReader<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder> l2FibEntryReader = new CompositeListReader<>(L2FibEntry.class, + final CompositeListReader<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder> l2FibEntryReader = + new CompositeListReader<>(L2FibEntry.class, new L2FibEntryCustomizer(vppApi, - getBridgeDomainContextVppStateDependency(), getInterfaceContextVppStateDependency())); + getBridgeDomainContextVppStateDependency(), getInterfaceContextVppStateDependency())); final ChildReader<L2FibTable> l2FibTableReader = new CompositeChildReader<>( - L2FibTable.class, - RWUtils.singletonChildReaderList(l2FibEntryReader), - new ReflexiveChildReaderCustomizer<>(L2FibTableBuilder.class)); + L2FibTable.class, + RWUtils.singletonChildReaderList(l2FibEntryReader), + new ReflexiveChildReaderCustomizer<>(L2FibTableBuilder.class)); final CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader = new CompositeListReader<>(BridgeDomain.class, - RWUtils.singletonChildReaderList((ChildReader)l2FibTableReader), - new BridgeDomainCustomizer(vppApi, - getBridgeDomainContextVppStateDependency())); + RWUtils.singletonChildReaderList((ChildReader) l2FibTableReader), + new BridgeDomainCustomizer(vppApi, + getBridgeDomainContextVppStateDependency())); final ChildReader<BridgeDomains> bridgeDomainsReader = new CompositeChildReader<>( BridgeDomains.class, |