summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java16
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java23
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java30
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java19
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java15
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java43
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java32
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java33
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java31
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java22
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/AddressCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java6
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java5
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/notification/InterfaceChangeNotificationProducer.java4
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java20
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/L2FibEntryCustomizer.java10
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizer.java10
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java15
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java8
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java7
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/test/InterfaceTestUtils.java25
-rw-r--r--v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/AbstractInterfaceTypeCustomizer.java4
-rw-r--r--v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java56
-rw-r--r--v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/WriteTimeoutException.java33
-rw-r--r--v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java51
33 files changed, 350 insertions, 186 deletions
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java
index a924c7646..10a664fcf 100644
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java
+++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java
@@ -31,11 +31,11 @@ public class WriteFailedException extends TranslationException {
private final InstanceIdentifier<?> failedId;
/**
- * Constructs an WriteFailedException given data id and exception cause.
+ * Constructs an WriteFailedException given data id, exception detail message and exception cause.
*
* @param failedId instance identifier of the data object that could not be read
* @param cause the cause of read failure
- * @param message
+ * @param message the exception detail message
*/
public WriteFailedException(@Nonnull final InstanceIdentifier<?> failedId,
@Nonnull final String message,
@@ -56,6 +56,18 @@ public class WriteFailedException extends TranslationException {
}
/**
+ * Constructs an WriteFailedException given data id and exception cause.
+ *
+ * @param failedId instance identifier of the data object that could not be read
+ * @param cause the cause of read failure
+ */
+ public WriteFailedException(@Nonnull final InstanceIdentifier<?> failedId,
+ @Nonnull final Throwable cause) {
+ super(cause);
+ this.failedId = checkNotNull(failedId, "failedId should not be null");
+ }
+
+ /**
* Returns id of the data object that could not be written.
*
* @return data object instance identifier
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 b5720a427..8c550aaf5 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
@@ -21,6 +21,7 @@ import static java.util.Objects.requireNonNull;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
@@ -65,9 +66,9 @@ final class InterconnectionWriteUtils {
if (ic == null) { // TODO in case of update we should delete interconnection
LOG.trace("Interconnection is not set. Skipping");
} else if (ic instanceof XconnectBased) {
- setXconnectBasedL2(swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 1 /*enable*/);
+ setXconnectBasedL2(id, swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 1 /*enable*/);
} else if (ic instanceof BridgeBased) {
- setBridgeBasedL2(swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 1 /*enable*/);
+ setBridgeBasedL2(id, swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 1 /*enable*/);
} else {
// FIXME how does choice extensibility work
// FIXME it is not even possible to create a dedicated customizer for Interconnection, since it's not a DataObject
@@ -90,9 +91,9 @@ final class InterconnectionWriteUtils {
if (ic == null) { // TODO in case of update we should delete interconnection
LOG.trace("Interconnection is not set. Skipping");
} else if (ic instanceof XconnectBased) {
- setXconnectBasedL2(swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 0 /*disable*/);
+ setXconnectBasedL2(id, swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 0 /*disable*/);
} else if (ic instanceof BridgeBased) {
- setBridgeBasedL2(swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 0 /*disable*/);
+ setBridgeBasedL2(id, swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 0 /*disable*/);
} else {
LOG.error("Unable to delete Interconnection of type {}", ic.getClass());
throw new WriteFailedException(id, "Unable to delete Interconnection of type " + ic.getClass());
@@ -104,9 +105,10 @@ final class InterconnectionWriteUtils {
}
}
- private void setBridgeBasedL2(final int swIfIndex, final String ifcName, final BridgeBased bb,
+ private void setBridgeBasedL2(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
+ final String ifcName, final BridgeBased bb,
final WriteContext writeContext, final byte enabled)
- throws VppBaseCallException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Setting bridge based interconnection(bridge-domain={}) for interface: {}", bb.getBridgeDomain(),
ifcName);
@@ -126,7 +128,7 @@ final class InterconnectionWriteUtils {
final CompletionStage<SwInterfaceSetL2BridgeReply> swInterfaceSetL2BridgeReplyCompletionStage = futureJvpp
.swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bvi, enabled));
- TranslateUtils.getReply(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Bridge based interconnection updated successfully for: {}, interconnection: {}", ifcName, bb);
}
@@ -142,9 +144,10 @@ final class InterconnectionWriteUtils {
return swInterfaceSetL2Bridge;
}
- private void setXconnectBasedL2(final int swIfIndex, final String ifcName, final XconnectBased ic,
+ private void setXconnectBasedL2(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
+ final String ifcName, final XconnectBased ic,
final WriteContext writeContext, final byte enabled)
- throws VppBaseCallException {
+ throws VppBaseCallException, WriteTimeoutException {
String outSwIfName = ic.getXconnectOutgoingInterface();
LOG.debug("Setting xconnect based interconnection(outgoing ifc={}) for interface: {}", outSwIfName, ifcName);
@@ -156,7 +159,7 @@ final class InterconnectionWriteUtils {
final CompletionStage<SwInterfaceSetL2XconnectReply> swInterfaceSetL2XconnectReplyCompletionStage =
futureJvpp
.swInterfaceSetL2Xconnect(getL2XConnectRequest(swIfIndex, outSwIfIndex, enabled));
- TranslateUtils.getReply(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture(), id);
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/interfaces/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
index 9f96bb75e..de07bdcc1 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
@@ -21,6 +21,7 @@ import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.List;
@@ -70,7 +71,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
@Nonnull final Interface dataBefore,
@Nonnull final Interface dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.UpdateFailedException {
+ throws WriteFailedException {
try {
updateInterface(id, dataBefore, dataAfter, writeContext);
@@ -98,35 +99,38 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
private void setInterface(final InstanceIdentifier<Interface> id, final Interface swIf,
final WriteContext writeContext)
- throws VppBaseCallException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Setting interface: {} to: {}", id, swIf);
- setInterfaceAttributes(swIf, swIf.getName(), writeContext);
+ setInterfaceAttributes(id, swIf, swIf.getName(), writeContext);
}
- private void setInterfaceAttributes(final Interface swIf, final String swIfName, final WriteContext writeContext)
- throws VppBaseCallException {
+ private void setInterfaceAttributes(final InstanceIdentifier<Interface> id, final Interface swIf,
+ final String swIfName, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
- setInterfaceFlags(swIfName, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()),
+ setInterfaceFlags(id, swIfName, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()),
swIf.isEnabled() ? (byte) 1 : (byte) 0);
}
private void updateInterface(final InstanceIdentifier<Interface> id,
final Interface dataBefore,
- final Interface dataAfter, final WriteContext writeContext) throws VppBaseCallException {
+ final Interface dataAfter, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Updating interface:{} to: {}", id, dataAfter);
- setInterfaceAttributes(dataAfter, dataAfter.getName(), writeContext);
+ setInterfaceAttributes(id, dataAfter, dataAfter.getName(), writeContext);
}
- private void setInterfaceFlags(final String swIfName, final int swIfIndex, final byte enabled)
- throws VppBaseCallException {
+ private void setInterfaceFlags(final InstanceIdentifier<Interface> id, final String swIfName, final int swIfIndex,
+ final byte enabled)
+ throws VppBaseCallException, WriteTimeoutException {
final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags(
getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */));
LOG.debug("Updating interface flags for: {}, index: {}, enabled: {}", swIfName, swIfIndex, enabled);
- SwInterfaceSetFlagsReply reply = TranslateUtils.getReply(swInterfaceSetFlagsReplyFuture.toCompletableFuture());
- LOG.debug("Interface flags updated successfully for: {}, index: {}, enabled: {}, ctxId: {}",
- swIfName, swIfIndex, enabled, reply.context);
+ TranslateUtils.getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id);
+ LOG.debug("Interface flags updated successfully for: {}, index: {}, enabled: {}",
+ swIfName, swIfIndex, enabled);
}
private SwInterfaceSetFlags getSwInterfaceSetFlagsInput(final int swIfIndex, final byte enabled, final byte deleted) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java
index eec941c1d..9fa57830a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java
@@ -26,6 +26,7 @@ import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.TagRewriteOperation;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.List;
@@ -73,10 +74,10 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
@Override
public void writeCurrentAttributes(final InstanceIdentifier<Rewrite> id, final Rewrite dataAfter,
final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
final String subifName = getSubInterfaceName(id);
try {
- setTagRewrite(subifName, dataAfter, writeContext);
+ setTagRewrite(id, subifName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to write interface {}(id=): {}", subifName, writeContext, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -88,16 +89,16 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
Math.toIntExact(id.firstKeyOf(SubInterface.class).getIdentifier()));
}
- private void setTagRewrite(final String ifname, final Rewrite rewrite, final WriteContext writeContext)
- throws VppBaseCallException {
+ private void setTagRewrite(final InstanceIdentifier<Rewrite> id, final String ifname, final Rewrite rewrite,
+ final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
final int swIfIndex = interfaceContext.getIndex(ifname, writeContext.getMappingContext());
LOG.debug("Setting tag rewrite for interface {}(id=): {}", ifname, swIfIndex, rewrite);
final CompletionStage<L2InterfaceVlanTagRewriteReply> replyCompletionStage =
getFutureJVpp().l2InterfaceVlanTagRewrite(getTagRewriteRequest(swIfIndex, rewrite));
- final L2InterfaceVlanTagRewriteReply reply =
- TranslateUtils.getReply(replyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(replyCompletionStage.toCompletableFuture(), id);
LOG.debug("Tag rewrite for interface {}(id=) set successfully: {}", ifname, swIfIndex, rewrite);
}
@@ -139,7 +140,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
throws WriteFailedException {
final String subifName = getSubInterfaceName(id);
try {
- setTagRewrite(subifName, dataAfter, writeContext);
+ setTagRewrite(id, subifName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to update interface {}(id=): {}", subifName, writeContext, dataAfter);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -149,12 +150,12 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Rewrite> id,
@Nonnull final Rewrite dataBefore, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
final String subifName = getSubInterfaceName(id);
try {
LOG.debug("Disabling tag rewrite for interface {}", subifName);
final Rewrite rewrite = new RewriteBuilder().build(); // rewrite without push and pops will cause delete
- setTagRewrite(subifName, rewrite, writeContext);
+ setTagRewrite(id, subifName, rewrite, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to delete interface {}(id=): {}", subifName, writeContext, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
index 0621fc2e3..9d41afd0c 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
@@ -21,6 +21,7 @@ import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -58,11 +59,11 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Routing> id,
@Nonnull final Routing dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
final String ifName = id.firstKeyOf(Interface.class).getName();
try {
- setRouting(ifName, dataAfter, writeContext);
+ setRouting(id, ifName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to set routing for interface: {}, {}, vxlan: {}", ifName, writeContext, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -73,12 +74,12 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Routing> id,
@Nonnull final Routing dataBefore, @Nonnull final Routing dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.UpdateFailedException {
+ throws WriteFailedException {
final String ifName = id.firstKeyOf(Interface.class).getName();
try {
// TODO handle updates properly
- setRouting(ifName, dataAfter, writeContext);
+ setRouting(id, ifName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to update routing for interface: {}, {}, vxlan: {}", ifName, writeContext, dataAfter);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -91,7 +92,8 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
// TODO implement delete
}
- private void setRouting(final String name, final Routing rt, final WriteContext writeContext) throws VppBaseCallException {
+ private void setRouting(final InstanceIdentifier<Routing> id, final String name, final Routing rt,
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext());
LOG.debug("Setting routing for interface: {}, {}. Routing: {}", name, swIfc, rt);
@@ -102,8 +104,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
if (vrfId != 0) {
final CompletionStage<SwInterfaceSetTableReply> swInterfaceSetTableReplyCompletionStage =
getFutureJVpp().swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, (byte) 0, /* isIpv6 */ vrfId));
- final SwInterfaceSetTableReply reply =
- TranslateUtils.getReply(swInterfaceSetTableReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(swInterfaceSetTableReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Routing set successfully for interface: {}, {}, routing: {}", name, swIfc, rt);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
index 3b3f6f629..c6d19475a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
@@ -26,6 +26,7 @@ import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.List;
@@ -63,7 +64,7 @@ import org.slf4j.LoggerFactory;
* Equivalent of invoking {@code vppclt create subif} command.
*/
public class SubInterfaceCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<SubInterface, SubInterfaceKey> {
+ implements ListWriterCustomizer<SubInterface, SubInterfaceKey> {
private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceCustomizer.class);
private final NamingContext interfaceContext;
@@ -76,7 +77,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
@Nonnull
@Override
public Optional<List<SubInterface>> extract(@Nonnull final InstanceIdentifier<SubInterface> currentId,
- @Nonnull final DataObject parentData) {
+ @Nonnull final DataObject parentData) {
return Optional.fromNullable(((SubInterfaces) parentData).getSubInterface());
}
@@ -84,26 +85,28 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final SubInterface dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
+ final String superIfName = id.firstKeyOf(Interface.class).getName();
try {
- createSubInterface(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
+ createSubInterface(id, superIfName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
- LOG.warn("Failed to create sub interface for: {}, subInterface: {}", id.firstKeyOf(Interface.class).getName(), dataAfter);
+ LOG.warn("Failed to create sub interface for: {}, subInterface: {}", superIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
- private void createSubInterface(@Nonnull final String superIfName,
+ private void createSubInterface(final InstanceIdentifier<SubInterface> id, @Nonnull final String superIfName,
@Nonnull final SubInterface subInterface,
- final WriteContext writeContext) throws VppBaseCallException {
+ final WriteContext writeContext) throws VppBaseCallException,
+ WriteTimeoutException {
final int superIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext());
final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage =
getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex));
final CreateSubifReply reply =
- TranslateUtils.getReply(createSubifReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(createSubifReplyCompletionStage.toCompletableFuture(), id);
- setInterfaceState(reply.swIfIndex, booleanToByte(subInterface.isEnabled()));
+ setInterfaceState(id, reply.swIfIndex, booleanToByte(subInterface.isEnabled()));
interfaceContext.addName(reply.swIfIndex,
getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())),
writeContext.getMappingContext());
@@ -132,7 +135,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final MatchType matchType = subInterface.getMatch().getMatchType(); // todo match should be mandatory
request.exactMatch =
- booleanToByte(matchType instanceof VlanTagged && ((VlanTagged) matchType).isMatchExactTags());
+ booleanToByte(matchType instanceof VlanTagged && ((VlanTagged) matchType).isMatchExactTags());
request.defaultSub = booleanToByte(matchType instanceof Default);
if (numberOfTags > 0) {
@@ -187,34 +190,36 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final SubInterface dataBefore, @Nonnull final SubInterface dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.UpdateFailedException {
+ throws WriteFailedException {
if (Objects.equals(dataBefore.isEnabled(), dataAfter.isEnabled())) {
LOG.debug("No state update will be performed. Ignoring config");
return; // TODO shouldn't we throw exception here (if there will be dedicated L2 customizer)?
}
final String subIfaceName = getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
- Math.toIntExact(dataAfter.getIdentifier()));
+ Math.toIntExact(dataAfter.getIdentifier()));
try {
- setInterfaceState(interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()),
- booleanToByte(dataAfter.isEnabled()));
+ setInterfaceState(id, interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()),
+ booleanToByte(dataAfter.isEnabled()));
} catch (VppBaseCallException e) {
LOG.warn("Failed to update interface state for: interface if={}, enabled: {}",
- subIfaceName, booleanToByte(dataAfter.isEnabled()));
+ subIfaceName, booleanToByte(dataAfter.isEnabled()));
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
- private void setInterfaceState(final int swIfIndex, final byte enabled) throws VppBaseCallException {
+ private void setInterfaceState(final InstanceIdentifier<SubInterface> id, final int swIfIndex, final byte enabled)
+ throws VppBaseCallException, WriteTimeoutException {
final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags();
swInterfaceSetFlags.swIfIndex = swIfIndex;
swInterfaceSetFlags.adminUpDown = enabled;
final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture =
- getFutureJVpp().swInterfaceSetFlags(swInterfaceSetFlags);
+ getFutureJVpp().swInterfaceSetFlags(swInterfaceSetFlags);
LOG.debug("Updating interface state for interface if={}, enabled: {}", swIfIndex, enabled);
- SwInterfaceSetFlagsReply reply = TranslateUtils.getReply(swInterfaceSetFlagsReplyFuture.toCompletableFuture());
+ SwInterfaceSetFlagsReply reply =
+ TranslateUtils.getReplyForWrite(swInterfaceSetFlagsReplyFuture.toCompletableFuture(), id);
LOG.debug("Interface state updated successfully for interface index: {}, enabled: {}, ctxId: {}",
swIfIndex, enabled, reply.context);
}
@@ -223,7 +228,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final SubInterface dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException.DeleteFailedException {
throw new UnsupportedOperationException("Sub interface delete is not supported");
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
index e26ed4534..d0e5179e2 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
@@ -20,6 +20,7 @@ import com.google.common.base.Optional;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
@@ -63,10 +64,10 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
try {
- createTap(ifcName, dataAfter, writeContext);
+ createTap(id, ifcName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to set tap interface: {}, tap: {}", ifcName, dataAfter, e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -76,7 +77,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Override
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataBefore,
@Nonnull final Tap dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.UpdateFailedException {
+ throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
final int index;
@@ -87,7 +88,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
}
try {
- modifyTap(ifcName, index, dataAfter);
+ modifyTap(id, ifcName, index, dataAfter);
} catch (VppBaseCallException e) {
LOG.warn("Failed to set tap interface: {}, tap: {}", ifcName, dataAfter, e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
@@ -97,7 +98,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
final String ifcName = id.firstKeyOf(Interface.class).getName();
final int index;
@@ -108,41 +109,42 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
}
try {
- deleteTap(ifcName, index, dataBefore, writeContext);
+ deleteTap(id, ifcName, index, dataBefore, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to delete tap interface: {}, tap: {}", ifcName, dataBefore.getTapName(), e);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createTap(final String swIfName, final Tap tap, final WriteContext writeContext) throws VppBaseCallException {
+ private void createTap(final InstanceIdentifier<Tap> id, final String swIfName, final Tap tap,
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapConnectReply> tapConnectFuture =
getFutureJVpp().tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance()));
final TapConnectReply reply =
- TranslateUtils.getReply(tapConnectFuture.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(tapConnectFuture.toCompletableFuture(), id);
LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap);
// Add new interface to our interface context
interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
- private void modifyTap(final String swIfName, final int index, final Tap tap) throws VppBaseCallException {
+ private void modifyTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, final Tap tap)
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Modifying tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapModifyReply> vxlanAddDelTunnelReplyCompletionStage =
getFutureJVpp().tapModify(getTapModifyRequest(tap.getTapName(), index, tap.getMac(), tap.getDeviceInstance()));
- final TapModifyReply reply =
- TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tap);
}
- private void deleteTap(final String swIfName, final int index, final Tap dataBefore,
+ private void deleteTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index,
+ final Tap dataBefore,
final WriteContext writeContext)
- throws VppBaseCallException {
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore);
final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage =
getFutureJVpp().tapDelete(getTapDeleteRequest(index));
- final TapDeleteReply reply =
- TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore);
// Remove deleted interface from interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
index ae25354fc..60df2cf37 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
@@ -21,6 +21,7 @@ import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
@@ -67,23 +68,25 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- createVhostUserIf(swIfName, dataAfter, writeContext);
+ createVhostUserIf(id, swIfName, dataAfter, writeContext);
} catch (VppBaseCallException | IllegalInterfaceTypeException e) {
LOG.debug("Failed to create vhost user interface: {}, vhostUser: {}", swIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
- private void createVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException {
+ private void createVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName,
+ final VhostUser vhostUser, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Creating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<CreateVhostUserIfReply> createVhostUserIfReplyCompletionStage =
getFutureJVpp().createVhostUserIf(getCreateVhostUserIfRequest(vhostUser));
final CreateVhostUserIfReply reply =
- TranslateUtils.getReply(createVhostUserIfReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(createVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vhost user interface created successfully for: {}, vhostUser: {}", swIfName, vhostUser);
// Add new interface to our interface context
interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
@@ -104,24 +107,25 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser dataBefore, @Nonnull final VhostUser dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.UpdateFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- modifyVhostUserIf(swIfName, dataAfter, writeContext);
+ modifyVhostUserIf(id, swIfName, dataAfter, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to update vhost user interface: {}, vhostUser: {}", swIfName, dataAfter);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
- private void modifyVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException {
+ private void modifyVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName,
+ final VhostUser vhostUser, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<ModifyVhostUserIfReply> modifyVhostUserIfReplyCompletionStage =
getFutureJVpp()
.modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser, interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
- final ModifyVhostUserIfReply reply =
- TranslateUtils.getReply(modifyVhostUserIfReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(modifyVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUser);
}
@@ -138,23 +142,24 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser dataBefore, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- deleteVhostUserIf(swIfName, dataBefore, writeContext);
+ deleteVhostUserIf(id, swIfName, dataBefore, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to delete vhost user interface: {}, vhostUser: {}", swIfName, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void deleteVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException {
+ private void deleteVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName,
+ final VhostUser vhostUser, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage =
getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
- final DeleteVhostUserIfReply reply =
- TranslateUtils.getReply(deleteVhostUserIfReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser);
// Remove interface from our interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
index 77489eca2..382348012 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
@@ -16,13 +16,19 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.base.Optional;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
+import java.net.InetAddress;
+import java.util.concurrent.CompletionStage;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -38,12 +44,6 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import java.net.InetAddress;
-import java.util.concurrent.CompletionStage;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
// TODO extract common code from all Interface type specific writer customizers into a superclass
public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@@ -70,10 +70,10 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- createVxlanTunnel(swIfName, dataAfter, writeContext);
+ createVxlanTunnel(id, swIfName, dataAfter, writeContext);
} catch (VppBaseCallException | IllegalInterfaceTypeException e) {
LOG.debug("Failed to set vxlan tunnel for interface: {}, vxlan: {}", swIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -91,17 +91,18 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- deleteVxlanTunnel(swIfName, dataBefore, writeContext);
+ deleteVxlanTunnel(id, swIfName, dataBefore, writeContext);
} catch (VppBaseCallException e) {
LOG.debug("Failed to delete vxlan tunnel for interface: {}, vxlan: {}", swIfName, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppBaseCallException {
+ private void createVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan,
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -115,7 +116,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6));
final VxlanAddDelTunnelReply reply =
- TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vxlan tunnel set successfully for: {}, vxlan: {}", swIfName, vxlan);
if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
// VPP keeps vxlan tunnels present even after they are delete(reserving ID for next tunnel)
@@ -150,7 +151,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
}
- private void deleteVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppBaseCallException {
+ private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan,
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -163,8 +165,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(),
dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6));
- final VxlanAddDelTunnelReply reply =
- TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
// Remove interface from our interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java
index 0a6746807..9b7e4bdbd 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java
@@ -23,6 +23,7 @@ import com.google.common.net.InetAddresses;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.net.InetAddress;
@@ -69,10 +70,10 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
@Override
protected final void writeInterface(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataAfter,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- createVxlanGpeTunnel(swIfName, dataAfter, writeContext);
+ createVxlanGpeTunnel(id, swIfName, dataAfter, writeContext);
} catch (VppBaseCallException | IllegalInterfaceTypeException e) {
LOG.warn("Failed to set VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
@@ -90,17 +91,19 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataBefore,
@Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- deleteVxlanGpeTunnel(swIfName, dataBefore, writeContext);
+ deleteVxlanGpeTunnel(id, swIfName, dataBefore, writeContext);
} catch (VppBaseCallException e) {
LOG.warn("Failed to delete VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createVxlanGpeTunnel(final String swIfName, final VxlanGpe VxlanGpe, final WriteContext writeContext) throws VppBaseCallException {
+ private void createVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName,
+ final VxlanGpe VxlanGpe, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
final byte isIpv6 = (byte) (isIpv6(VxlanGpe) ? 1 : 0);
final InetAddress Local = InetAddresses.forString(getAddressString(VxlanGpe.getLocal()));
final InetAddress Remote = InetAddresses.forString(getAddressString(VxlanGpe.getRemote()));
@@ -116,7 +119,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
Remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
final VxlanGpeAddDelTunnelReply reply =
- TranslateUtils.getReply(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("VxlanGpe tunnel set successfully for: {}, VxlanGpe: {}", swIfName, VxlanGpe);
if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
@@ -144,7 +147,9 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
}
- private void deleteVxlanGpeTunnel(final String swIfName, final VxlanGpe VxlanGpe, final WriteContext writeContext) throws VppBaseCallException {
+ private void deleteVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName,
+ final VxlanGpe VxlanGpe, final WriteContext writeContext)
+ throws VppBaseCallException, WriteTimeoutException {
final byte isIpv6 = (byte) (isIpv6(VxlanGpe) ? 1 : 0);
final InetAddress local = InetAddresses.forString(getAddressString(VxlanGpe.getLocal()));
final InetAddress remote = InetAddresses.forString(getAddressString(VxlanGpe.getRemote()));
@@ -159,8 +164,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(),
remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
- final VxlanGpeAddDelTunnelReply reply =
- TranslateUtils.getReply(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("VxlanGpe tunnel deleted successfully for: {}, VxlanGpe: {}", swIfName, VxlanGpe);
// Remove interface from our interface context
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/AddressCustomizer.java
index 0b62bc027..65055744b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/AddressCustomizer.java
@@ -182,7 +182,7 @@ public class AddressCustomizer extends FutureJVppCustomizer implements ListWrite
getSwInterfaceAddDelAddressRequest(swIfc, TranslateUtils.booleanToByte(add) /* isAdd */,
(byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, plen.byteValue(), addr));
- TranslateUtils.getReply(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Subnet(prefix-length) set successfully for interface: {}, {}, Subnet: {}, Address: {}", name,
swIfc, subnet, address);
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 43be0d4ab..4bd542b0c 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
@@ -123,7 +123,7 @@ final class InterconnectionReadUtils {
final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture();
- return TranslateUtils.getReply(bdCompletableFuture);
+ return TranslateUtils.getReplyForRead(bdCompletableFuture, id);
} catch (VppBaseCallException e) {
throw new ReadFailedException(id, e);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
index 943016aac..832b29c13 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
@@ -128,7 +128,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
final SwInterfaceDetailsReplyDump ifaces =
- TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
+ TranslateUtils.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
if (null == ifaces || null == ifaces.swInterfaceDetails) {
LOG.debug("No interfaces for :{} found in VPP", id);
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 01a315a77..4d1f5dd5d 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
@@ -191,10 +191,10 @@ public final class InterfaceUtils {
return allInterfaces.get(index);
}
- SwInterfaceDetailsReplyDump ifaces = null;
+ SwInterfaceDetailsReplyDump ifaces;
try {
CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJvpp.swInterfaceDump(request);
- ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
+ ifaces = TranslateUtils.getReplyForRead(requestFuture.toCompletableFuture(), id);
if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) {
request.nameFilterValid = 0;
@@ -203,7 +203,7 @@ public final class InterfaceUtils {
// Or else just perform full dump and do inefficient filtering
requestFuture = futureJvpp.swInterfaceDump(request);
- ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
+ ifaces = TranslateUtils.getReplyForRead(requestFuture.toCompletableFuture(), id);
// Update the cache
allInterfaces.clear();
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
index 998b188d0..911937c31 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
@@ -107,7 +107,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
final SwInterfaceDetailsReplyDump ifaces =
- TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
+ TranslateUtils.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id);
if (null == ifaces || null == ifaces.swInterfaceDetails) {
LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP");
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
index f4d4a7ad2..3f79e5517 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
@@ -94,7 +94,7 @@ public class TapCustomizer extends FutureJVppCustomizer
final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage =
getFutureJVpp().swInterfaceTapDump(request);
final SwInterfaceTapDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForRead(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
if(null == reply || null == reply.swInterfaceTapDetails) {
mappedTaps = Collections.emptyMap();
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
index 65f08fee2..23e1a6efd 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
@@ -96,7 +96,7 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> swInterfaceVhostUserDetailsReplyDumpCompletionStage =
getFutureJVpp().swInterfaceVhostUserDump(request);
final SwInterfaceVhostUserDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForRead(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
if(null == reply || null == reply.swInterfaceVhostUserDetails) {
mappedVhostUsers = Collections.emptyMap();
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
index c1068d0ea..3d82820a4 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
@@ -93,7 +93,7 @@ public class VxlanCustomizer extends FutureJVppCustomizer
final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage =
getFutureJVpp().vxlanTunnelDump(request);
final VxlanTunnelDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForRead(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
// VPP keeps vxlan tunnel interfaces even after they were deleted (optimization)
// However there ar no longer any vxlan tunnel specific fields assigned to it and this call
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
index c5c04e113..de05dc4bc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
@@ -94,7 +94,7 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer
final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage =
getFutureJVpp().vxlanGpeTunnelDump(request);
final VxlanGpeTunnelDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForRead(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture(), id);
// VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization)
// However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
index 6c8bb9447..641516136 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
@@ -25,6 +25,7 @@ import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.v3po.translate.util.RWUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.v3po.translate.v3po.util.ReadTimeoutException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import java.util.Collections;
import java.util.List;
@@ -154,13 +155,13 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer
private Optional<IpAddressDetailsReplyDump> dumpAddressFromOperationalData(final InstanceIdentifier<Address> id,
final MappingContext mappingContext)
- throws VppBaseCallException {
+ throws VppBaseCallException, ReadTimeoutException {
LOG.debug("Dumping from operational data...");
final IpAddressDump dumpRequest = new IpAddressDump();
dumpRequest.isIpv6 = 0;
dumpRequest.swIfIndex = interfaceContext.getIndex(id.firstKeyOf(Interface.class).getName(), mappingContext);
return Optional.fromNullable(
- TranslateUtils.getReply(getFutureJVpp().ipAddressDump(dumpRequest).toCompletableFuture()));
+ TranslateUtils.getReplyForRead(getFutureJVpp().ipAddressDump(dumpRequest).toCompletableFuture(), id));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/notification/InterfaceChangeNotificationProducer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/notification/InterfaceChangeNotificationProducer.java
index f3689d7e2..8ca63c105 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/notification/InterfaceChangeNotificationProducer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/notification/InterfaceChangeNotificationProducer.java
@@ -24,6 +24,7 @@ import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.CompletionStage;
+import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
@@ -35,7 +36,6 @@ 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.InterfaceStatus;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.dto.SwInterfaceSetFlagsNotification;
import org.openvpp.jvpp.dto.WantInterfaceEvents;
import org.openvpp.jvpp.dto.WantInterfaceEventsReply;
@@ -126,7 +126,7 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
try {
wantInterfaceEventsReplyCompletionStage = jvpp.wantInterfaceEvents(wantInterfaceEvents);
TranslateUtils.getReply(wantInterfaceEventsReplyCompletionStage.toCompletableFuture());
- } catch (VppBaseCallException e) {
+ } catch (VppBaseCallException | TimeoutException e) {
LOG.warn("Unable to {} interface notifications", enableDisable == 1 ? "enable" : "disable", e);
throw new IllegalStateException("Unable to control interface notifications", e);
}
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 3bc7ba175..22344baa6 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
@@ -26,6 +26,7 @@ import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.List;
@@ -63,8 +64,9 @@ public class BridgeDomainCustomizer
return Optional.fromNullable(((BridgeDomains) parentData).getBridgeDomain());
}
- private BridgeDomainAddDelReply addOrUpdateBridgeDomain(final int bdId, @Nonnull final BridgeDomain bd)
- throws VppBaseCallException {
+ private BridgeDomainAddDelReply addOrUpdateBridgeDomain(@Nonnull final InstanceIdentifier<BridgeDomain> id,
+ final int bdId, @Nonnull final BridgeDomain bd)
+ throws VppBaseCallException, WriteTimeoutException {
final BridgeDomainAddDelReply reply;
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
@@ -75,7 +77,7 @@ public class BridgeDomainCustomizer
request.arpTerm = booleanToByte(bd.isArpTermination());
request.isAdd = ADD_OR_UPDATE_BD;
- reply = TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture());
+ reply = TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
LOG.debug("Bridge domain {} (id={}) add/update successful", bd.getName(), bdId);
return reply;
}
@@ -84,7 +86,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 {
LOG.debug("writeCurrentAttributes: id={}, current={}, ctx={}", id, dataBefore, ctx);
final String bdName = dataBefore.getName();
@@ -101,7 +103,7 @@ public class BridgeDomainCustomizer
index++;
}
}
- addOrUpdateBridgeDomain(index, dataBefore);
+ addOrUpdateBridgeDomain(id, index, dataBefore);
bdContext.addName(index, bdName, ctx.getMappingContext());
} catch (VppBaseCallException e) {
LOG.warn("Failed to create bridge domain", e);
@@ -113,7 +115,7 @@ public class BridgeDomainCustomizer
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore,
@Nonnull final WriteContext ctx)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx);
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
int bdId = bdContext.getIndex(bdName, ctx.getMappingContext());
@@ -122,7 +124,7 @@ public class BridgeDomainCustomizer
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
- TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture());
+ TranslateUtils.getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id);
LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId);
} catch (VppBaseCallException e) {
LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId);
@@ -134,7 +136,7 @@ public class BridgeDomainCustomizer
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomain dataBefore, @Nonnull final BridgeDomain dataAfter,
@Nonnull final WriteContext ctx)
- throws WriteFailedException.UpdateFailedException {
+ throws WriteFailedException {
LOG.debug("updateCurrentAttributes: id={}, dataBefore={}, dataAfter={}, ctx={}", id, dataBefore, dataAfter,
ctx);
@@ -143,7 +145,7 @@ public class BridgeDomainCustomizer
"BridgeDomain name changed. It should be deleted and then created.");
try {
- addOrUpdateBridgeDomain(bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter);
+ addOrUpdateBridgeDomain(id, bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter);
} catch (VppBaseCallException e) {
LOG.warn("Failed to create bridge domain", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
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 b4a51b01a..3655a48f1 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
@@ -26,6 +26,7 @@ import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.v3po.translate.v3po.util.WriteTimeoutException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.List;
@@ -75,7 +76,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 {
try {
LOG.debug("Creating L2 FIB entry: {} {}", id, dataAfter);
l2FibAddDel(id, dataAfter, writeContext, true);
@@ -97,7 +98,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id,
@Nonnull final L2FibEntry dataBefore, @Nonnull final WriteContext writeContext)
- throws WriteFailedException.DeleteFailedException {
+ throws WriteFailedException {
try {
LOG.debug("Deleting L2 FIB entry: {} {}", id, dataBefore);
l2FibAddDel(id, dataBefore, writeContext, false);
@@ -109,7 +110,8 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
}
private void l2FibAddDel(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry entry,
- final WriteContext writeContext, boolean isAdd) throws VppBaseCallException {
+ final WriteContext writeContext, boolean isAdd)
+ throws VppBaseCallException, WriteTimeoutException {
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext());
@@ -124,7 +126,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer
final CompletionStage<L2FibAddDelReply> l2FibAddDelReplyCompletionStage =
getFutureJVpp().l2FibAddDel(l2FibRequest);
- TranslateUtils.getReply(l2FibAddDelReplyCompletionStage.toCompletableFuture());
+ TranslateUtils.getReplyForWrite(l2FibAddDelReplyCompletionStage.toCompletableFuture(), id);
}
private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) {
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 b7ff1e70d..93cc9e448 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
@@ -27,6 +27,7 @@ import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.v3po.translate.util.RWUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.v3po.translate.v3po.util.ReadTimeoutException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import java.util.Collections;
import java.util.List;
@@ -84,7 +85,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
try {
// TODO use cached l2FibTable
- final L2FibTableEntry entry = dumpL2Fibs(bdId).stream().filter(e -> key.getPhysAddress()
+ final L2FibTableEntry entry = dumpL2Fibs(id, bdId).stream().filter(e -> key.getPhysAddress()
.equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2))))
.collect(SINGLE_ITEM_COLLECTOR);
@@ -105,14 +106,15 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
}
@Nonnull
- private List<L2FibTableEntry> dumpL2Fibs(final int bdId) throws VppBaseCallException {
+ private List<L2FibTableEntry> dumpL2Fibs(final InstanceIdentifier<L2FibEntry> id, final int bdId)
+ throws VppBaseCallException, ReadTimeoutException {
final L2FibTableDump l2FibRequest = new L2FibTableDump();
l2FibRequest.bdId = bdId;
final CompletableFuture<L2FibTableEntryReplyDump> l2FibTableDumpCompletableFuture =
getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture();
- final L2FibTableEntryReplyDump dump = TranslateUtils.getReply(l2FibTableDumpCompletableFuture);
+ final L2FibTableEntryReplyDump dump = TranslateUtils.getReplyForRead(l2FibTableDumpCompletableFuture, id);
if (null == dump || null == dump.l2FibTableEntry) {
return Collections.emptyList();
@@ -130,7 +132,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
LOG.debug("Reading L2 FIB for bridge domain {} (bdId={})", bridgeDomainKey, bdId);
try {
- return dumpL2Fibs(bdId).stream()
+ return dumpL2Fibs(id, bdId).stream()
.map(entry -> new L2FibEntryKey(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(entry.mac), 2)))
).collect(Collectors.toList());
} catch (VppBaseCallException e) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
index 2673e8e3d..83a8995f7 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
@@ -64,7 +64,7 @@ public final class VersionCustomizer
try {
// Execute with timeout
final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion());
- final ShowVersionReply reply = TranslateUtils.getReply(showVersionFuture.toCompletableFuture(), id,
+ final ShowVersionReply reply = TranslateUtils.getReplyForRead(showVersionFuture.toCompletableFuture(), id,
DEFAULT_TIMEOUT_IN_SECONDS);
builder.setBranch(TranslateUtils.toString(reply.version));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
index 82952ec35..959d6eb4a 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -43,6 +44,8 @@ import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -96,12 +99,12 @@ public class VhostUserCustomizerTest {
}
private void whenCreateVhostUserIfThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
final CompletionStage<CreateVhostUserIfReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<CreateVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final CreateVhostUserIfReply reply = new CreateVhostUserIfReply();
- when(replyFuture.get()).thenReturn(reply);
+ when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
when(api.createVhostUserIf(any(CreateVhostUserIf.class))).thenReturn(replyCS);
}
@@ -115,12 +118,12 @@ public class VhostUserCustomizerTest {
}
private void whenModifyVhostUserIfThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
final CompletionStage<ModifyVhostUserIfReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<ModifyVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final ModifyVhostUserIfReply reply = new ModifyVhostUserIfReply();
- when(replyFuture.get()).thenReturn(reply);
+ when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
when(api.modifyVhostUserIf(any(ModifyVhostUserIf.class))).thenReturn(replyCS);
}
@@ -134,12 +137,12 @@ public class VhostUserCustomizerTest {
}
private void whenDeleteVhostUserIfThenSuccess()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
final CompletionStage<DeleteVhostUserIfReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<DeleteVhostUserIfReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final DeleteVhostUserIfReply reply = new DeleteVhostUserIfReply();
- when(replyFuture.get()).thenReturn(reply);
+ when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
when(api.deleteVhostUserIf(any(DeleteVhostUserIf.class))).thenReturn(replyCS);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
index afe26beff..1d00e2f11 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -43,6 +44,8 @@ import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -100,12 +103,13 @@ public class VxlanCustomizerTest {
.augmentation(VppInterfaceAugmentation.class).child(Vxlan.class);
}
- private void whenVxlanAddDelTunnelThenSuccess() throws ExecutionException, InterruptedException, VppInvocationException {
+ private void whenVxlanAddDelTunnelThenSuccess()
+ throws ExecutionException, InterruptedException, VppInvocationException, TimeoutException {
final CompletionStage<VxlanAddDelTunnelReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<VxlanAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final VxlanAddDelTunnelReply reply = new VxlanAddDelTunnelReply();
- when(replyFuture.get()).thenReturn(reply);
+ when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
when(api.vxlanAddDelTunnel(any(VxlanAddDelTunnel.class))).thenReturn(replyCS);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
index a4fa2f188..12424999f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -43,6 +44,8 @@ import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -102,12 +105,12 @@ public class VxlanGpeCustomizerTest {
}
private void whenVxlanGpeAddDelTunnelThenSuccess()
- throws ExecutionException, InterruptedException, VppBaseCallException {
+ throws ExecutionException, InterruptedException, VppBaseCallException, TimeoutException {
final CompletionStage<VxlanGpeAddDelTunnelReply> replyCS = mock(CompletionStage.class);
final CompletableFuture<VxlanGpeAddDelTunnelReply> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final VxlanGpeAddDelTunnelReply reply = new VxlanGpeAddDelTunnelReply();
- when(replyFuture.get()).thenReturn(reply);
+ when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
when(api.vxlanGpeAddDelTunnel(any(VxlanGpeAddDelTunnel.class))).thenReturn(replyCS);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/test/InterfaceTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/test/InterfaceTestUtils.java
index c88cefa9e..f72aaa571 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/test/InterfaceTestUtils.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/test/InterfaceTestUtils.java
@@ -16,20 +16,23 @@
package io.fd.honeycomb.v3po.translate.v3po.test;
-import org.openvpp.jvpp.VppBaseCallException;
-import org.openvpp.jvpp.dto.SwInterfaceDetails;
-import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
-import org.openvpp.jvpp.dto.SwInterfaceDump;
-import org.openvpp.jvpp.future.FutureJVpp;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.dto.SwInterfaceDetails;
+import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
+import org.openvpp.jvpp.dto.SwInterfaceDump;
+import org.openvpp.jvpp.future.FutureJVpp;
public final class InterfaceTestUtils {
private InterfaceTestUtils() {
@@ -37,13 +40,13 @@ public final class InterfaceTestUtils {
}
public static void whenSwInterfaceDumpThenReturn(final FutureJVpp api, final List<SwInterfaceDetails> interfaceList)
- throws ExecutionException, InterruptedException, VppBaseCallException {
+ throws ExecutionException, InterruptedException, VppBaseCallException, TimeoutException {
final CompletionStage<SwInterfaceDetailsReplyDump> replyCS = mock(CompletionStage.class);
final CompletableFuture<SwInterfaceDetailsReplyDump> replyFuture = mock(CompletableFuture.class);
when(replyCS.toCompletableFuture()).thenReturn(replyFuture);
final SwInterfaceDetailsReplyDump reply = new SwInterfaceDetailsReplyDump();
reply.swInterfaceDetails = interfaceList;
- when(replyFuture.get()).thenReturn(reply);
+ when(replyFuture.get(anyLong(), eq(TimeUnit.SECONDS))).thenReturn(reply);
when(api.swInterfaceDump(any(SwInterfaceDump.class))).thenReturn(replyCS);
}
}
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/AbstractInterfaceTypeCustomizer.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/AbstractInterfaceTypeCustomizer.java
index e1a5bf2bc..fd08472d7 100644
--- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/AbstractInterfaceTypeCustomizer.java
+++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/AbstractInterfaceTypeCustomizer.java
@@ -65,14 +65,14 @@ public abstract class AbstractInterfaceTypeCustomizer<D extends DataObject>
*/
@Override
public final void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataAfter,
- @Nonnull final WriteContext writeContext) throws WriteFailedException.CreateFailedException {
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
checkProperInterfaceType(writeContext, id);
writeInterface(id, dataAfter, writeContext);
}
protected abstract void writeInterface(final InstanceIdentifier<D> id, final D dataAfter,
final WriteContext writeContext)
- throws WriteFailedException.CreateFailedException;
+ throws WriteFailedException;
// Validation for update and delete is not necessary
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
index d44bf8fd5..1a6a50133 100644
--- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
+++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
@@ -39,30 +39,53 @@ import org.openvpp.jvpp.dto.JVppReply;
public final class TranslateUtils {
public static final Splitter COLON_SPLITTER = Splitter.on(':');
+ public static final int DEFAULT_TIMEOUT_IN_SECONDS = 5;
private TranslateUtils() {
}
- public static <REP extends JVppReply<?>> REP getReply(Future<REP> future) throws VppBaseCallException {
+ public static <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType)
+ throws VppBaseCallException, WriteTimeoutException {
+ return getReplyForWrite(future, replyType, DEFAULT_TIMEOUT_IN_SECONDS);
+ }
+
+ public static <REP extends JVppReply<?>> REP getReplyForWrite(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType,
+ @Nonnegative final int timeoutInSeconds)
+ throws VppBaseCallException, WriteTimeoutException {
try {
- return future.get();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IllegalStateException("Interrupted", 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 instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
- throw (VppBaseCallException) (e.getCause());
- }
- throw new IllegalStateException(e);
+ return getReply(future, timeoutInSeconds);
+ } catch (TimeoutException e) {
+ throw new WriteTimeoutException(replyType, e);
}
}
+ public static <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType)
+ throws VppBaseCallException, ReadTimeoutException {
+ return getReplyForRead(future, replyType, DEFAULT_TIMEOUT_IN_SECONDS);
+ }
+
+ public static <REP extends JVppReply<?>> REP getReplyForRead(@Nonnull Future<REP> future,
+ @Nonnull final InstanceIdentifier<?> replyType,
+ @Nonnegative final int timeoutInSeconds)
+ throws VppBaseCallException, ReadTimeoutException {
+ try {
+ return getReply(future, timeoutInSeconds);
+ } catch (TimeoutException e) {
+ throw new ReadTimeoutException(replyType, e);
+ }
+ }
+
+ public static <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future)
+ throws TimeoutException, VppBaseCallException {
+ return getReply(future, DEFAULT_TIMEOUT_IN_SECONDS);
+ }
+
public static <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future,
- @Nonnull final InstanceIdentifier<?> replyType,
@Nonnegative final int timeoutInSeconds)
- throws ReadTimeoutException, VppBaseCallException {
+ throws TimeoutException, VppBaseCallException {
try {
checkArgument(timeoutInSeconds > 0, "Timeout cannot be < 0");
return future.get(timeoutInSeconds, TimeUnit.SECONDS);
@@ -72,12 +95,10 @@ public final class TranslateUtils {
} 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) {
+ if (e instanceof ExecutionException && (e.getCause() instanceof VppBaseCallException)) {
throw (VppBaseCallException) (e.getCause());
}
throw new IllegalStateException(e);
- } catch (TimeoutException e) {
- throw new ReadTimeoutException(replyType, e);
}
}
@@ -188,6 +209,7 @@ public final class TranslateUtils {
/**
* Reverses bytes in the byte array
+ *
* @param bytes input array
* @return reversed array
*/
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/WriteTimeoutException.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/WriteTimeoutException.java
new file mode 100644
index 000000000..9516459b2
--- /dev/null
+++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/WriteTimeoutException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.v3po.translate.v3po.util;
+
+import com.google.common.annotations.Beta;
+import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Thrown when write method invocation times out.
+ */
+@Beta
+public class WriteTimeoutException extends WriteFailedException {
+
+ public WriteTimeoutException(final InstanceIdentifier<?> id, final Throwable cause) {
+ super(id, cause);
+ }
+
+}
diff --git a/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java b/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java
index 89e7d9d89..334887430 100644
--- a/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java
+++ b/v3po/vpp-translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtilsTest.java
@@ -3,12 +3,62 @@ package io.fd.honeycomb.v3po.translate.v3po.util;
import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.reverseBytes;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.dto.JVppReply;
public class TranslateUtilsTest {
+ private static class AnDataObject implements DataObject {
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return null;
+ }
+ }
+
+ @Test
+ public void testGetReplyForWriteTimeout() throws Exception {
+ final Future<JVppReply<?>> future = mock(Future.class);
+ when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class);
+ final InstanceIdentifier<AnDataObject> replyType = InstanceIdentifier.create(AnDataObject.class);
+ try {
+ TranslateUtils.getReplyForWrite(future, replyType);
+ } catch (WriteTimeoutException e) {
+ assertTrue(e.getCause() instanceof TimeoutException);
+ assertEquals(replyType, e.getFailedId());
+ return;
+ }
+ fail("WriteTimeoutException was expected");
+ }
+
+ @Test
+ public void testGetReplyForReadTimeout() throws Exception {
+ final Future<JVppReply<?>> future = mock(Future.class);
+ final InstanceIdentifier<AnDataObject> replyType = InstanceIdentifier.create(AnDataObject.class);
+ when(future.get(anyLong(), eq(TimeUnit.SECONDS))).thenThrow(TimeoutException.class);
+ try {
+ TranslateUtils.getReplyForRead(future, replyType);
+ } catch (ReadTimeoutException e) {
+ assertTrue(e.getCause() instanceof TimeoutException);
+ assertEquals(replyType, e.getFailedId());
+ return;
+ }
+ fail("ReadTimeoutException was expected");
+ }
+
@Test
public void testIpv4NoZone() throws Exception {
final Ipv4AddressNoZone ipv4Addr = new Ipv4AddressNoZone("192.168.1.1");
@@ -83,4 +133,5 @@ public class TranslateUtilsTest {
public void testByteToBooleanFailed() {
TranslateUtils.byteToBoolean((byte) 123);
}
+
} \ No newline at end of file