Class BackendInfoResolver<T extends BackendInfo>
- java.lang.Object
-
- org.opendaylight.controller.cluster.access.client.BackendInfoResolver<T>
-
- All Implemented Interfaces:
AutoCloseable
public abstract class BackendInfoResolver<T extends BackendInfo> extends Object implements AutoCloseable
Caching resolver which resolves a cookie to a leaderActorRef
. This class needs to be specialized by the client. It is used byClientActorBehavior
for request dispatch. Results are cached until they are invalidated by either the client actor (when a message timeout is detected) and by the specific frontend (on explicit invalidation or when updated information becomes available).If the completion stage returned by this interface's methods fails with a
RequestException
, it will be forwarded to all outstanding requests towards the leader. If it fails with aTimeoutException
, resolution process will be retried. If it fails with any other cause, it will we wrapped as aRuntimeRequestException
wrapping that cause.- Author:
- Robert Varga
-
-
Constructor Summary
Constructors Constructor Description BackendInfoResolver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
abstract @NonNull CompletionStage<? extends T>
getBackendInfo(@NonNull Long cookie)
Request resolution of a particular backend identified by a cookie.abstract @NonNull Registration
notifyWhenBackendInfoIsStale(Consumer<Long> callback)
Registers a callback to be notified when BackendInfo that may have been previously obtained is now stale and should be refreshed.abstract @NonNull CompletionStage<? extends T>
refreshBackendInfo(@NonNull Long cookie, @NonNull T staleInfo)
Request re-resolution of a particular backend identified by a cookie, indicating a particular information as being stale.abstract @NonNull String
resolveCookieName(Long cookie)
-
-
-
Method Detail
-
getBackendInfo
public abstract @NonNull CompletionStage<? extends T> getBackendInfo(@NonNull Long cookie)
Request resolution of a particular backend identified by a cookie. This request can be satisfied from the cache.- Parameters:
cookie
- Backend cookie- Returns:
- A
CompletionStage
resulting in information about the backend
-
refreshBackendInfo
public abstract @NonNull CompletionStage<? extends T> refreshBackendInfo(@NonNull Long cookie, @NonNull T staleInfo)
Request re-resolution of a particular backend identified by a cookie, indicating a particular information as being stale. If the implementation's cache holds the stale information, it should be purged.- Parameters:
cookie
- Backend cookiestaleInfo
- Stale backend information- Returns:
- A
CompletionStage
resulting in information about the backend
-
notifyWhenBackendInfoIsStale
public abstract @NonNull Registration notifyWhenBackendInfoIsStale(Consumer<Long> callback)
Registers a callback to be notified when BackendInfo that may have been previously obtained is now stale and should be refreshed.- Parameters:
callback
- the callback that takes the backend cookie whose BackendInfo is now stale.- Returns:
- a Registration
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-