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;
}
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());
+ }
+
}
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");
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);
}
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);
}
}
@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);
// 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) {
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?)
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);
}
}
}
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");
}
// 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/
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]);
}
* 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");
// 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);
// 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;
}
}
/**
- * 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,
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);
@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;
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();
// (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);
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);
* 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);
@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);
@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);
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());
}
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);
}
}
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;
@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);
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();
}
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;
@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);
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) {
l2FibRequest.bdId = bdId;
final CompletableFuture<L2FibTableEntryReplyDump> l2FibTableDumpCompletableFuture =
- getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture();
+ getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture();
final L2FibTableEntryReplyDump dump = TranslateUtils.getReply(l2FibTableDumpCompletableFuture);
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);
}
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);
}
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<>(
}
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;
}
-
}
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);
}
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,
private InstanceIdentifier<L2> getL2Id(final String name) {
return InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(name))
- .augmentation(
- VppInterfaceStateAugmentation.class).child(L2.class);
+ .augmentation(
+ VppInterfaceStateAugmentation.class).child(L2.class);
}
private void whenBridgeDomainSwIfDumpThenReturn(final List<BridgeDomainSwIfDetails> bdSwIfList,
final List<BridgeDomainDetails> bridgeDomainDetailses)
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
final BridgeDomainDetailsReplyDump reply = new BridgeDomainDetailsReplyDump();
reply.bridgeDomainSwIfDetails = bdSwIfList;
reply.bridgeDomainDetails = bridgeDomainDetailses;
final BridgeBasedBuilder bbBuilder = new BridgeBasedBuilder();
bbBuilder.setBridgeDomain(bdName);
bbBuilder.setSplitHorizonGroup((short) 1);
- if(bvi != null) {
+ if (bvi != null) {
bbBuilder.setBridgedVirtualInterface(bvi);
} else {
bbBuilder.setBridgedVirtualInterface(false); // false is default
return Optional.of(new MappingBuilder().setName(name).setIndex(index).build());
}
- public static KeyedInstanceIdentifier<Mapping, MappingKey> getMappingIid(final String name, final String namingContextName) {
+ public static KeyedInstanceIdentifier<Mapping, MappingKey> getMappingIid(final String name,
+ final String namingContextName) {
return InstanceIdentifier.create(Contexts.class).child(
- org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContext.class,
- new NamingContextKey(namingContextName)).child(Mappings.class).child(Mapping.class, new MappingKey(name));
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.NamingContext.class,
+ new NamingContextKey(namingContextName)).child(Mappings.class).child(Mapping.class, new MappingKey(name));
}
- public static void mockMapping(final MappingContext mappingContext, final String name, final int id, final String namingContextName) {
- final InstanceIdentifier<Mappings> mappingsIid = getMappingIid(name, namingContextName).firstIdentifierOf(Mappings.class);
+ public static void mockMapping(final MappingContext mappingContext, final String name, final int id,
+ final String namingContextName) {
+ final InstanceIdentifier<Mappings> mappingsIid =
+ getMappingIid(name, namingContextName).firstIdentifierOf(Mappings.class);
final Optional<Mapping> singleMapping = getMapping(name, id);
final Optional<Mappings> previousMappings = mappingContext.read(mappingsIid);
final MappingsBuilder mappingsBuilder;
- if(previousMappings != null && previousMappings.isPresent()) {
+ if (previousMappings != null && previousMappings.isPresent()) {
mappingsBuilder = new MappingsBuilder(previousMappings.get());
} else {
mappingsBuilder = new MappingsBuilder();
final List<Mapping> mappingList = mappingsBuilder.getMapping();
mappingList.add(singleMapping.get());
doReturn(Optional.of(mappingsBuilder.setMapping(mappingList).build()))
- .when(mappingContext).read(mappingsIid);
+ .when(mappingContext).read(mappingsIid);
doReturn(singleMapping).when(mappingContext).read(getMappingIid(name, namingContextName));
}
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.v3po.translate.v3po.vpp;
import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping;
private BridgeDomain generateBridgeDomain(final String bdName, final int arpTerm, final int flood,
final int forward, final int learn, final int uuf) {
return new BridgeDomainBuilder()
- .setName(bdName)
- .setArpTermination(BridgeDomainTestUtils.intToBoolean(arpTerm))
- .setFlood(BridgeDomainTestUtils.intToBoolean(flood))
- .setForward(BridgeDomainTestUtils.intToBoolean(forward))
- .setLearn(BridgeDomainTestUtils.intToBoolean(learn))
- .setUnknownUnicastFlood(BridgeDomainTestUtils.intToBoolean(uuf))
- .build();
+ .setName(bdName)
+ .setArpTermination(BridgeDomainTestUtils.intToBoolean(arpTerm))
+ .setFlood(BridgeDomainTestUtils.intToBoolean(flood))
+ .setForward(BridgeDomainTestUtils.intToBoolean(forward))
+ .setLearn(BridgeDomainTestUtils.intToBoolean(learn))
+ .setUnknownUnicastFlood(BridgeDomainTestUtils.intToBoolean(uuf))
+ .build();
}
private void verifyBridgeDomainAddOrUpdateWasInvoked(final BridgeDomain bd, final int bdId)
- throws VppInvocationException {
+ throws VppInvocationException {
final byte arpTerm = BridgeDomainTestUtils.booleanToByte(bd.isArpTermination());
final byte flood = BridgeDomainTestUtils.booleanToByte(bd.isFlood());
final byte forward = BridgeDomainTestUtils.booleanToByte(bd.isForward());
}
private void whenBridgeDomainAddDelThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<BridgeDomainAddDelReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<BridgeDomainAddDelReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
}
private void whenBridgeDomainAddDelThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
doReturn(TestHelperUtils.<BridgeDomainAddDelReply>createFutureException()).when(api)
- .bridgeDomainAddDel(any(BridgeDomainAddDel.class));
+ .bridgeDomainAddDel(any(BridgeDomainAddDel.class));
}
@Test
final String bdName = "bd1";
final BridgeDomain bd = generateBridgeDomain(bdName);
doReturn(Optional.absent()).when(mappingContext)
- .read(getMappingIid(bdName, "test-instance").firstIdentifierOf(Mappings.class));
+ .read(getMappingIid(bdName, "test-instance").firstIdentifierOf(Mappings.class));
whenBridgeDomainAddDelThenSuccess();
// Returning no Mappings for "test-instance" makes bdContext.containsName() return false
doReturn(Optional.absent()).when(mappingContext)
- .read(getMappingIid(bdName, "test-instance").firstIdentifierOf(Mappings.class));
+ .read(getMappingIid(bdName, "test-instance").firstIdentifierOf(Mappings.class));
whenBridgeDomainAddDelThenFailure();
final byte uufBefore = 0;
final BridgeDomain dataBefore =
- generateBridgeDomain(bdName, arpTermBefore, floodBefore, forwardBefore, learnBefore, uufBefore);
+ generateBridgeDomain(bdName, arpTermBefore, floodBefore, forwardBefore, learnBefore, uufBefore);
final BridgeDomain dataAfter =
- generateBridgeDomain(bdName, arpTermBefore ^ 1, floodBefore ^ 1, forwardBefore ^ 1, learnBefore ^ 1,
- uufBefore ^ 1);
+ generateBridgeDomain(bdName, arpTermBefore ^ 1, floodBefore ^ 1, forwardBefore ^ 1, learnBefore ^ 1,
+ uufBefore ^ 1);
whenBridgeDomainAddDelThenSuccess();
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), dataBefore, dataAfter, ctx);
-
+ .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), dataBefore, dataAfter, ctx);
verifyBridgeDomainAddOrUpdateWasInvoked(dataAfter, bdId);
}
try {
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter, ctx);
+ .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter, ctx);
} catch (IllegalArgumentException e) {
verify(api, never()).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
return;
public void testUpdateBridgeDomainFailed() throws Exception {
final int bdId = 1;
final String bdName = "bd1";
- final BridgeDomain bdBefore = generateBridgeDomain(bdName, 0, 1, 0 ,1, 0);
- final BridgeDomain bdAfter = generateBridgeDomain(bdName, 1, 1, 0 ,1, 0);
+ final BridgeDomain bdBefore = generateBridgeDomain(bdName, 0, 1, 0, 1, 0);
+ final BridgeDomain bdAfter = generateBridgeDomain(bdName, 1, 1, 0, 1, 0);
doReturn(getMapping(bdName, bdId)).when(mappingContext).read(getMappingIid(bdName, "test-instance"));
whenBridgeDomainAddDelThenFailure();
try {
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter, ctx);
- } catch (WriteFailedException.UpdateFailedException e) {
+ .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter, ctx);
+ } catch (WriteFailedException.UpdateFailedException e) {
verifyBridgeDomainAddOrUpdateWasInvoked(bdAfter, bdId);
return;
}
private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final PhysAddress address) {
return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME))
- .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address));
+ .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address));
}
private void whenL2FibAddDelThenSuccess() {
private void whenL2FibAddDelThenFailure() {
doReturn(TestHelperUtils.<L2InterfaceVlanTagRewriteReply>createFutureException()).when(api)
- .l2FibAddDel(any(L2FibAddDel.class));
+ .l2FibAddDel(any(L2FibAddDel.class));
}
private L2FibAddDel generateL2FibAddDelRequest(final long mac, final byte isAdd) {
}
private void verifyL2FibAddDelWasInvoked(final L2FibAddDel expected) throws
- VppInvocationException {
+ VppInvocationException {
ArgumentCaptor<L2FibAddDel> argumentCaptor = ArgumentCaptor.forClass(L2FibAddDel.class);
verify(api).l2FibAddDel(argumentCaptor.capture());
final L2FibAddDel actual = argumentCaptor.getValue();
@Test(expected = UnsupportedOperationException.class)
public void testUpdate() throws Exception {
customizer.updateCurrentAttributes(InstanceIdentifier.create(L2FibEntry.class), mock(L2FibEntry.class),
- mock(L2FibEntry.class), writeContext);
+ mock(L2FibEntry.class), writeContext);
}
@Test
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.v3po.translate.v3po.vppstate;
import static org.mockito.Mockito.mock;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainKey;
-public class BridgeDomainCustomizerTest extends ListReaderCustomizerTest<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> {
+public class BridgeDomainCustomizerTest
+ extends ListReaderCustomizerTest<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> {
private NamingContext bdContext;
private NamingContext interfacesContext;
private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final String bdName, final PhysAddress address) {
return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName))
- .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address));
+ .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address));
}
private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> l2FibTableEntryList)
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
final L2FibTableEntryReplyDump reply = new L2FibTableEntryReplyDump();
reply.l2FibTableEntry = l2FibTableEntryList;
bdContext = new NamingContext("generatedBdName", "bd-test-instance");
interfaceContext = new NamingContext("generatedIfaceName", "ifc-test-instance");
vppStateReader = VppStateTestUtils.getVppStateReader(api, bdContext);
- readerRegistry = new DelegatingReaderRegistry(Collections.<Reader<? extends DataObject>>singletonList(vppStateReader));
+ readerRegistry =
+ new DelegatingReaderRegistry(Collections.<Reader<? extends DataObject>>singletonList(vppStateReader));
}
private static Version getVersion() {
return new VersionBuilder()
- .setName("test")
- .setBuildDirectory("1")
- .setBranch("2")
- .setBuildDate("3")
- .build();
+ .setName("test")
+ .setBuildDirectory("1")
+ .setBranch("2")
+ .setBuildDate("3")
+ .build();
}
- private void whenShowVersionThenReturn(int retval, Version version) throws ExecutionException, InterruptedException, VppInvocationException {
+ private void whenShowVersionThenReturn(int retval, Version version)
+ throws ExecutionException, InterruptedException, VppInvocationException {
final CompletableFuture<ShowVersionReply> replyFuture = new CompletableFuture<>();
final ShowVersionReply reply = new ShowVersionReply();
reply.buildDate = version.getBuildDate().getBytes();
when(api.showVersion(any(ShowVersion.class))).thenReturn(replyFuture);
}
- private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> entryList) throws ExecutionException, InterruptedException, VppInvocationException {
+ private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> entryList)
+ throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<L2FibTableEntryReplyDump> replyCS = mock(CompletionStage.class);
final CompletableFuture<L2FibTableEntryReplyDump> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(replyCS);
}
- private void whenBridgeDomainDumpThenReturn(final List<BridgeDomainDetails> bdList) throws ExecutionException, InterruptedException, VppInvocationException {
+ private void whenBridgeDomainDumpThenReturn(final List<BridgeDomainDetails> bdList)
+ throws ExecutionException, InterruptedException, VppInvocationException {
final CompletionStage<BridgeDomainDetailsReplyDump> replyCS = mock(CompletionStage.class);
final CompletableFuture<BridgeDomainDetailsReplyDump> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
when(replyFuture.get()).thenReturn(reply);
doAnswer(invocation -> {
- BridgeDomainDump request = (BridgeDomainDump)invocation.getArguments()[0];
+ BridgeDomainDump request = (BridgeDomainDump) invocation.getArguments()[0];
if (request.bdId == -1) {
reply.bridgeDomainDetails = bdList;
} else {
whenBridgeDomainDumpThenReturn(bdList);
- final Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> dataObjects = readerRegistry.readAll(ctx);
+ final Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> dataObjects =
+ readerRegistry.readAll(ctx);
assertEquals(dataObjects.size(), 1);
- final VppState dataObject = (VppState)Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet())));
+ final VppState dataObject =
+ (VppState) Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet())));
assertEquals(version, dataObject.getVersion());
assertEquals(2, dataObject.getBridgeDomains().getBridgeDomain().size());
}
whenL2FibTableDumpThenReturn(Collections.singletonList(l2FibEntry));
// Deep child without a dedicated reader with specific l2fib key
- final InstanceIdentifier<? extends DataObject> idExisting = InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
- BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("01:02:03:04:05:06")));
+ final InstanceIdentifier<? extends DataObject> idExisting =
+ InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
+ BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class)
+ .child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("01:02:03:04:05:06")));
Optional<? extends DataObject> read =
readerRegistry.read(idExisting, ctx);
assertTrue(read.isPresent());
// non existing l2fib
- final InstanceIdentifier<? extends DataObject> idNonExisting = InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
- BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("FF:FF:FF:04:05:06")));
+ final InstanceIdentifier<? extends DataObject> idNonExisting =
+ InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
+ BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class)
+ .child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("FF:FF:FF:04:05:06")));
read = readerRegistry.read(idNonExisting, ctx);
assertFalse(read.isPresent());
}
assertTrue(read.isPresent());
assertEquals(readRoot.getBridgeDomains().getBridgeDomain().stream().filter(
- input -> input.getKey().getName().equals(bdName)).findFirst().get(),
+ input -> input.getKey().getName().equals(bdName)).findFirst().get(),
read.get());
}
@Nonnull final NamingContext bdContext) {
final ChildReader<Version> versionReader = new CompositeChildReader<>(
- Version.class, new VersionCustomizer(futureJVpp));
+ Version.class, new VersionCustomizer(futureJVpp));
final CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader =
- getBridgeDomainReader(futureJVpp, bdContext);
+ getBridgeDomainReader(futureJVpp, bdContext);
final ChildReader<BridgeDomains> bridgeDomainsReader = new CompositeChildReader<>(
- BridgeDomains.class,
- RWUtils.singletonChildReaderList(bridgeDomainReader),
- new ReflexiveChildReaderCustomizer<>(BridgeDomainsBuilder.class));
+ BridgeDomains.class,
+ RWUtils.singletonChildReaderList(bridgeDomainReader),
+ new ReflexiveChildReaderCustomizer<>(BridgeDomainsBuilder.class));
final List<ChildReader<? extends ChildOf<VppState>>> childVppReaders = new ArrayList<>();
childVppReaders.add(versionReader);
childVppReaders.add(bridgeDomainsReader);
return new CompositeRootReader<>(
- VppState.class,
- childVppReaders,
- RWUtils.<VppState>emptyAugReaderList(),
- new ReflexiveRootReaderCustomizer<>(VppStateBuilder.class));
+ VppState.class,
+ childVppReaders,
+ RWUtils.<VppState>emptyAugReaderList(),
+ new ReflexiveRootReaderCustomizer<>(VppStateBuilder.class));
}
static CompositeListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> getBridgeDomainReader(
- final @Nonnull FutureJVpp futureJVpp, @Nonnull final NamingContext bdContext) {
+ final @Nonnull FutureJVpp futureJVpp, @Nonnull final NamingContext bdContext) {
return new CompositeListReader<>(
- BridgeDomain.class,
- new BridgeDomainCustomizer(futureJVpp, bdContext));
+ BridgeDomain.class,
+ new BridgeDomainCustomizer(futureJVpp, bdContext));
}
}
public static final Splitter COLON_SPLITTER = Splitter.on(':');
- private TranslateUtils() {}
+ private TranslateUtils() {
+ }
public static <REP extends JVppReply<?>> REP getReply(Future<REP> future) throws VppBaseCallException {
try {
} catch (ExecutionException e) {
// Execution exception could generally contains any exception
// when using exceptions instead of return codes just rethrow it for processing on corresponding place
- if (e instanceof ExecutionException && ( e.getCause() instanceof VppBaseCallException)) {
+ if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
throw (VppBaseCallException) (e.getCause());
}
throw new IllegalStateException(e);
} catch (ExecutionException e) {
// Execution exception could generally contains any exception
// when using exceptions instead of return codes just rethrow it for processing on corresponding place
- if ( e.getCause() instanceof VppBaseCallException)
- throw (VppBaseCallException)(e.getCause());
+ if (e.getCause() instanceof VppBaseCallException) {
+ throw (VppBaseCallException) (e.getCause());
+ }
throw new IllegalStateException(e);
} catch (TimeoutException e) {
throw new ReadTimeoutException(replyType, e);
}
/**
- * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be
- * in the same order as the address.
+ * Transform Ipv4 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
+ * as the address.
*
* @return byte array with address bytes
*/
@Nonnull
public static Ipv4AddressNoZone arrayToIpv4AddressNoZone(@Nonnull byte[] ip) {
// VPP sends ipv4 in a 16 byte array
- if(ip.length == 16) {
+ if (ip.length == 16) {
ip = Arrays.copyOfRange(ip, 0, 4);
}
try {
}
/**
- * Return (interned) string from byte array while removing \u0000.
- * Strings represented as fixed length byte[] from vpp contain \u0000.
+ * Return (interned) string from byte array while removing \u0000. Strings represented as fixed length byte[] from
+ * vpp contain \u0000.
*/
public static String toString(final byte[] cString) {
return new String(cString).replaceAll("\\u0000", "").intern();
}
public static byte parseHexByte(final String aByte) {
- return (byte)Integer.parseInt(aByte, 16);
+ return (byte) Integer.parseInt(aByte, 16);
}
- /**
+ /**
* Returns 0 if argument is null or false, 1 otherwise.
+ *
* @param value Boolean value to be converted
* @return byte value equal to 0 or 1
*/
public static byte booleanToByte(@Nullable final Boolean value) {
- return value != null && value ? (byte) 1 : (byte) 0;
+ return value != null && value
+ ? (byte) 1
+ : (byte) 0;
}
/**
* Returns Boolean.TRUE if argument is 0, Boolean.FALSE otherwise.
+ *
* @param value byte value to be converted
* @return Boolean value
* @throws IllegalArgumentException if argument is neither 0 nor 1