summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io
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
commitffd80be44b795865b42edd60d587a577db54cae3 (patch)
tree3045587eb1974e91b916e5fb2b7bb479cc0e4808 /v3po/v3po2vpp/src/main/java/io
parentf1da426ffcd61fc4b498dfa4192c0cde19b552e2 (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')
-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));