X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FClientActorContext.java;h=cb36223c26f5c7a109a006ed7989dbdee70a21a6;hb=63bca3841f0187b5127f62fd04e4edcdce3a63c1;hp=26e68356d3f4404e7050bcbcc905542dc6eccb18;hpb=314d5b41ea6b464db939da95a33c872f594ccada;p=controller.git diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java index 26e68356d3..cb36223c26 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java @@ -13,18 +13,10 @@ import akka.actor.Scheduler; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Ticker; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nonnull; import javax.annotation.concurrent.ThreadSafe; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; -import org.opendaylight.controller.cluster.access.concepts.RequestException; -import org.opendaylight.controller.cluster.access.concepts.ResponseEnvelope; -import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.concepts.WritableIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import scala.concurrent.ExecutionContext; import scala.concurrent.duration.FiniteDuration; @@ -41,11 +33,8 @@ import scala.concurrent.duration.FiniteDuration; @Beta @ThreadSafe public class ClientActorContext extends AbstractClientActorContext implements Identifiable { - private static final Logger LOG = LoggerFactory.getLogger(ClientActorContext.class); - - private final Map queues = new ConcurrentHashMap<>(); - private final ClientIdentifier identifier; private final ExecutionContext executionContext; + private final ClientIdentifier identifier; private final Scheduler scheduler; // Hidden to avoid subclassing @@ -79,45 +68,15 @@ public class ClientActorContext extends AbstractClientActorContext implements Id * Execute a command in the context of the client actor. * * @param command Block of code which needs to be execute + * @param BackendInfo type */ - public void executeInActor(@Nonnull final InternalCommand command) { + public void executeInActor(@Nonnull final InternalCommand command) { self().tell(Preconditions.checkNotNull(command), ActorRef.noSender()); } - public Cancellable executeInActor(@Nonnull final InternalCommand command, final FiniteDuration delay) { + public Cancellable executeInActor(@Nonnull final InternalCommand command, + final FiniteDuration delay) { return scheduler.scheduleOnce(Preconditions.checkNotNull(delay), self(), Preconditions.checkNotNull(command), executionContext, ActorRef.noSender()); } - - SequencedQueue queueFor(final Long cookie) { - return queues.computeIfAbsent(cookie, t -> new SequencedQueue(t, ticker())); - } - - void removeQueue(final SequencedQueue queue) { - queues.remove(queue.getCookie(), queue); - } - - ClientActorBehavior completeRequest(final ClientActorBehavior current, final ResponseEnvelope response) { - final WritableIdentifier id = response.getMessage().getTarget(); - - // FIXME: this will need to be updated for other Request/Response types to extract cookie - Preconditions.checkArgument(id instanceof TransactionIdentifier); - final TransactionIdentifier txId = (TransactionIdentifier) id; - - final SequencedQueue queue = queues.get(txId.getHistoryId().getCookie()); - if (queue == null) { - LOG.info("{}: Ignoring unknown response {}", persistenceId(), response); - return current; - } else { - return queue.complete(current, response); - } - } - - void poison(final RequestException cause) { - for (SequencedQueue q : queues.values()) { - q.poison(cause); - } - - queues.clear(); - } }