- private static final Logger LOG = LoggerFactory.getLogger(BackendInfoResolver.class);
- private final ConcurrentMap<Long, CompletableFuture<T>> backends = new ConcurrentHashMap<>();
-
- /**
- * Return the currently-resolved backend information, if available. This method is guaranteed not to block, but will
- * initiate resolution of the information if there is none.
- *
- * @param cookie Backend cookie
- * @return Backend information, if available
- */
- public final Optional<T> getFutureBackendInfo(final Long cookie) {
- final Future<T> f = lookupBackend(cookie);
- if (f.isDone()) {
- try {
- return Optional.of(f.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.debug("Resolution of {} failed", f, e);
- }
- }
-
- return Optional.empty();
- }
-