X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FBackendInfoResolver.java;h=5c5cda5bae0b8f7eb2e4bb02bd827e47c234c07b;hp=2e8ab4e103cc48636c87a8452b74a924ce6c3204;hb=HEAD;hpb=9409f87fa5f6ea0a37384a85bb4e66b974fdd9a7 diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java index 2e8ab4e103..5c5cda5bae 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java @@ -9,7 +9,9 @@ package org.opendaylight.controller.cluster.access.client; import akka.actor.ActorRef; import java.util.concurrent.CompletionStage; -import javax.annotation.Nonnull; +import java.util.function.Consumer; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.concepts.Registration; /** * Caching resolver which resolves a cookie to a leader {@link ActorRef}. This class needs to be specialized by the @@ -21,20 +23,19 @@ import javax.annotation.Nonnull; * If the completion stage returned by this interface's methods fails with a * {@link org.opendaylight.controller.cluster.access.concepts.RequestException}, it will be forwarded to all * outstanding requests towards the leader. If it fails with a {@link java.util.concurrent.TimeoutException}, - * resolution process will be retries. If it fails with any other cause, it will we wrapped as a + * resolution process will be retried. If it fails with any other cause, it will we wrapped as a * {@link org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException} wrapping that cause. * * @author Robert Varga */ -public abstract class BackendInfoResolver { +public abstract class BackendInfoResolver implements AutoCloseable { /** * Request resolution of a particular backend identified by a cookie. This request can be satisfied from the cache. * * @param cookie Backend cookie * @return A {@link CompletionStage} resulting in information about the backend */ - @Nonnull - public abstract CompletionStage getBackendInfo(@Nonnull Long cookie); + public abstract @NonNull CompletionStage getBackendInfo(@NonNull Long cookie); /** * Request re-resolution of a particular backend identified by a cookie, indicating a particular information as @@ -44,6 +45,21 @@ public abstract class BackendInfoResolver { * @param staleInfo Stale backend information * @return A {@link CompletionStage} resulting in information about the backend */ - @Nonnull - public abstract CompletionStage refreshBackendInfo(@Nonnull Long cookie, @Nonnull T staleInfo); + public abstract @NonNull CompletionStage refreshBackendInfo(@NonNull Long cookie, + @NonNull T staleInfo); + + /** + * Registers a callback to be notified when BackendInfo that may have been previously obtained is now stale and + * should be refreshed. + * + * @param callback the callback that takes the backend cookie whose BackendInfo is now stale. + * @return a Registration + */ + public abstract @NonNull Registration notifyWhenBackendInfoIsStale(Consumer callback); + + public abstract @NonNull String resolveCookieName(Long cookie); + + @Override + public void close() { + } }