BUG-5280: add AbstractClientConnection
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / BackendInfoResolver.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.access.client;
9
10 import akka.actor.ActorRef;
11 import java.util.concurrent.CompletionStage;
12 import javax.annotation.Nonnull;
13
14 /**
15  * Caching resolver which resolves a cookie to a leader {@link ActorRef}. This class needs to be specialized by the
16  * client. It is used by {@link ClientActorBehavior} for request dispatch. Results are cached until they are invalidated
17  * by either the client actor (when a message timeout is detected) and by the specific frontend (on explicit
18  * invalidation or when updated information becomes available).
19  *
20  * @author Robert Varga
21  */
22 public abstract class BackendInfoResolver<T extends BackendInfo> {
23     /**
24      * Request resolution of a particular backend identified by a cookie. This request can be satisfied from the cache.
25      *
26      * @param cookie Backend cookie
27      * @return A {@link CompletionStage} resulting in information about the backend
28      */
29     @Nonnull
30     public abstract CompletionStage<? extends T> getBackendInfo(@Nonnull Long cookie);
31
32     /**
33      * Request re-resolution of a particular backend identified by a cookie, indicating a particular information as
34      * being stale. If the implementation's cache holds the stale information, it should be purged.
35      *
36      * @param cookie Backend cookie
37      * @param staleInfo Stale backend information
38      * @return A {@link CompletionStage} resulting in information about the backend
39      */
40     @Nonnull
41     public abstract CompletionStage<? extends T> refreshBackendInfo(@Nonnull Long cookie, @Nonnull T staleInfo);
42 }