X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2Factors%2Fdds%2FDistributedDataStoreClientActor.java;h=69e0d5db502bd00382be8ff88ba2278e08a6d91d;hp=1e15fefd6f05c8189a84decaaeb3c015efab2029;hb=5cb0787412ab63a3aa5dcc044511e1ce569662cf;hpb=d0621d28e507d9f6c0b9445d197f90253d34725d diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientActor.java index 1e15fefd6f..69e0d5db50 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientActor.java @@ -7,63 +7,35 @@ */ package org.opendaylight.controller.cluster.databroker.actors.dds; -import akka.actor.ActorRef; import akka.actor.Props; -import akka.pattern.ExplicitAskSupport; -import akka.util.Timeout; -import com.google.common.base.Throwables; -import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; +import org.opendaylight.controller.cluster.access.client.AbstractClientActor; +import org.opendaylight.controller.cluster.access.client.ClientActorContext; import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendType; import org.opendaylight.controller.cluster.access.concepts.MemberName; -import org.opendaylight.controller.cluster.datastore.actors.client.AbstractClientActor; -import org.opendaylight.controller.cluster.datastore.actors.client.ClientActorBehavior; -import org.opendaylight.controller.cluster.datastore.actors.client.ClientActorContext; -import scala.Function1; -import scala.concurrent.Await; -import scala.concurrent.duration.Duration; -import scala.runtime.AbstractFunction1; +import org.opendaylight.controller.cluster.datastore.utils.ActorContext; /** * A {@link AbstractClientActor} which acts as the point of contact for DistributedDataStore. * * @author Robert Varga */ -public final class DistributedDataStoreClientActor extends AbstractClientActor { - // Unfortunately Akka's explicit ask pattern does not work with its Java API, as it fails to invoke passed message. - // In order to make this work for now, we tap directly into ExplicitAskSupport and use a Scala function instead - // of akka.japi.Function. - private static final ExplicitAskSupport ASK_SUPPORT = akka.pattern.extended.package$.MODULE$; - private static final Function1 GET_CLIENT_FACTORY = new AbstractFunction1() { - @Override - public Object apply(final ActorRef askSender) { - return new GetClientRequest(askSender); - } - }; - - private DistributedDataStoreClientActor(final FrontendIdentifier frontendId) { - super(frontendId); +public final class DistributedDataStoreClientActor extends AbstractDataStoreClientActor { + private DistributedDataStoreClientActor(final FrontendIdentifier frontendId, final ActorContext actorContext) { + super(frontendId, actorContext); } @Override - protected ClientActorBehavior initialBehavior(final ClientActorContext context) { - return new DistributedDataStoreClientBehavior(context); + AbstractDataStoreClientBehavior initialBehavior(final ClientActorContext context, final ActorContext actorContext) { + return new DistributedDataStoreClientBehavior(context, actorContext); } - public static Props props(final @Nonnull MemberName memberName, @Nonnull final String storeName) { - final String name = "DistributedDataStore:storeName='" + storeName + "'"; + public static Props props(@Nonnull final MemberName memberName, @Nonnull final String storeName, + final ActorContext ctx) { + final String name = "datastore-" + storeName; final FrontendIdentifier frontendId = FrontendIdentifier.create(memberName, FrontendType.forName(name)); - return Props.create(DistributedDataStoreClientActor.class, () -> new DistributedDataStoreClientActor(frontendId)); - } - - public static DistributedDataStoreClient getDistributedDataStoreClient(final @Nonnull ActorRef actor, - final long timeout, final TimeUnit unit) { - try { - return (DistributedDataStoreClient) Await.result(ASK_SUPPORT.ask(actor, GET_CLIENT_FACTORY, - Timeout.apply(timeout, unit)), Duration.Inf()); - } catch (Exception e) { - throw Throwables.propagate(e); - } + return Props.create(DistributedDataStoreClientActor.class, + () -> new DistributedDataStoreClientActor(frontendId, ctx)); } }