X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FActorContext.java;h=2f1949ec6a8b12c701e87d696b8777dedece947f;hb=98f72d6e38e62500bbad181acf522511d384565c;hp=ba4d4de6bfaeed985bf1e70c626c4a3bd365a0b1;hpb=2d16cfa0af7079ff969dcb81da6071ecacb3a5f6;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java index ba4d4de6bf..2f1949ec6a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java @@ -12,9 +12,14 @@ import akka.actor.ActorPath; import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; +import akka.actor.PoisonPill; import akka.util.Timeout; +import org.opendaylight.controller.cluster.datastore.Configuration; +import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException; +import org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Await; @@ -41,10 +46,14 @@ public class ActorContext { private final ActorSystem actorSystem; private final ActorRef shardManager; + private final Configuration configuration; - public ActorContext(ActorSystem actorSystem, ActorRef shardManager){ + private SchemaContext schemaContext = null; + + public ActorContext(ActorSystem actorSystem, ActorRef shardManager, Configuration configuration){ this.actorSystem = actorSystem; this.shardManager = shardManager; + this.configuration = configuration; } public ActorSystem getActorSystem() { @@ -81,7 +90,7 @@ public class ActorContext { return actorSystem.actorSelection(found.getPrimaryPath()); } - throw new RuntimeException("primary was not found"); + throw new PrimaryNotFoundException(); } /** @@ -99,7 +108,7 @@ public class ActorContext { try { return Await.result(future, AWAIT_DURATION); } catch (Exception e) { - throw new RuntimeException(e); + throw new TimeoutException(e); } } @@ -118,7 +127,7 @@ public class ActorContext { try { return Await.result(future, AWAIT_DURATION); } catch (Exception e) { - throw new RuntimeException(e); + throw new TimeoutException(e); } } @@ -131,7 +140,8 @@ public class ActorContext { * @param shardName * @param message * @param duration - * @throws java.lang.RuntimeException when a primary is not found or if the message to the remote shard fails or times out + * @throws org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException if the message to the remote shard times out + * @throws org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException if the primary shard is not found * * @return */ @@ -141,4 +151,8 @@ public class ActorContext { return executeRemoteOperation(primary, message, duration); } + public void shutdown() { + shardManager.tell(PoisonPill.getInstance(), null); + actorSystem.shutdown(); + } }