@Override public void onTimeout(Interest interest) { String message = interest.getInterestLifetimeMilliseconds() + "ms timeout exceeded"; futureData.completeExceptionally(new TimeoutException(message)); } });
private void resend(Face face, Interest interest, OnData onData, OnTimeout onTimeout) throws IOException { LOGGER.log(Level.INFO, "Resending interest with {0}ms lifetime: {1}", new Object[]{interest.getInterestLifetimeMilliseconds(), interest.getName()}); face.expressInterest(interest, onData, timedOutInterest -> { try { retryInterest(face, timedOutInterest, onData, onTimeout); } catch (IOException e) { onTimeout.onTimeout(interest); } }); } }
private void retryInterest(Face face, Interest interest, OnData onData, OnTimeout onTimeout) throws IOException { double newLifetime = interest.getInterestLifetimeMilliseconds() * backoffFactor; if (newLifetime < cutoffLifetime) { interest.setInterestLifetimeMilliseconds(newLifetime); resend(face, interest, onData, onTimeout); } else { onTimeout.onTimeout(interest); } }