summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-05-23 15:22:24 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-06-02 10:10:21 +0000
commitb475c0760ae397d2d485a37931f508820d88cce0 (patch)
treeebab26c53814449d6c897983d50291be51744c9c /v3po/v3po2vpp/src/main/java/io/fd/honeycomb
parentaa3a931cd81d3576dbac40825c3d7b920b7dc76a (diff)
HONEYCOMB-61: Detect VPP disconnect using keepalives
Change-Id: Ic664dbf452504d0fff97e8c766d735d9c5d95c72 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java16
1 files changed, 10 insertions, 6 deletions
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 ad181a701..8122fd245 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
@@ -21,6 +21,7 @@ import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
+import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.Version;
@@ -36,6 +37,11 @@ public final class VersionCustomizer
extends FutureJVppCustomizer
implements ChildReaderCustomizer<Version, VersionBuilder> {
+ /**
+ * Default timeout for executing version read
+ */
+ private static final int DEFAULT_TIMEOUT_IN_SECONDS = 30;
+
public VersionCustomizer(@Nonnull final FutureJVpp futureJVpp) {
super(futureJVpp);
}
@@ -54,13 +60,11 @@ public final class VersionCustomizer
@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Version> id, @Nonnull final VersionBuilder builder,
@Nonnull final ReadContext context) throws ReadFailedException {
+ // Execute with timeout
+ final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion());
+ final ShowVersionReply reply = TranslateUtils.getReply(showVersionFuture.toCompletableFuture(), id,
+ DEFAULT_TIMEOUT_IN_SECONDS);
- ShowVersionReply reply;
- try {
- reply = getFutureJVpp().showVersion(new ShowVersion()).toCompletableFuture().get();
- } catch (Exception e) {
- throw new ReadFailedException(id, e);
- }
builder.setBranch(TranslateUtils.toString(reply.version));
builder.setName(TranslateUtils.toString(reply.program));
builder.setBuildDate(TranslateUtils.toString(reply.buildDate));