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
*
* @author Robert Varga
*/
-public abstract class BackendInfoResolver<T extends BackendInfo> {
+public abstract class BackendInfoResolver<T extends BackendInfo> 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<? extends T> getBackendInfo(@Nonnull Long cookie);
+ public abstract @NonNull CompletionStage<? extends T> getBackendInfo(@NonNull Long cookie);
/**
* Request re-resolution of a particular backend identified by a cookie, indicating a particular information as
* @param staleInfo Stale backend information
* @return A {@link CompletionStage} resulting in information about the backend
*/
- @Nonnull
- public abstract CompletionStage<? extends T> refreshBackendInfo(@Nonnull Long cookie, @Nonnull T staleInfo);
+ public abstract @NonNull CompletionStage<? extends T> 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<Long> callback);
+
+ public abstract @NonNull String resolveCookieName(Long cookie);
+
+ @Override
+ public void close() {
+ }
}