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 getReplyForWrite(@Nonnull Future<REP> future, @Nonnull final InstanceIdentifier<?> replyType, @Nonnegative final int timeoutInSeconds) throws VppBaseCallException, WriteTimeoutException { try { return getReply(future, timeoutInSeconds); } catch (TimeoutException e) { throw new WriteTimeoutException(replyType, e); } }
public static <REP extends JVppReply<?>> REP getReply(@Nonnull Future<REP> future, @Nonnegative final int timeoutInSeconds) throws TimeoutException, VppBaseCallException { try { checkArgument(timeoutInSeconds > 0, "Timeout cannot be < 0"); return future.get(timeoutInSeconds, TimeUnit.SECONDS); } 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); } }
private void enableDisableIfcNotifications(int enableDisable) { final WantInterfaceEvents wantInterfaceEvents = new WantInterfaceEvents(); wantInterfaceEvents.pid = 1; wantInterfaceEvents.enableDisable = enableDisable; final CompletionStage<WantInterfaceEventsReply> wantInterfaceEventsReplyCompletionStage; try { wantInterfaceEventsReplyCompletionStage = jvpp.wantInterfaceEvents(wantInterfaceEvents); TranslateUtils.getReply(wantInterfaceEventsReplyCompletionStage.toCompletableFuture()); } catch (VppBaseCallException | TimeoutException e) { LOG.warn("Unable to {} interface notifications", enableDisable == 1 ? "enable" : "disable", e); throw new IllegalStateException("Unable to control interface notifications", e); } }