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%2Fdatastore%2Futils%2FActorContext.java;h=c97e07db6d60c867c9f4c1687c9495ae9722a3c9;hp=ba4d4de6bfaeed985bf1e70c626c4a3bd365a0b1;hb=1af23ad8e572896323ed5d1c723d977a16eb7e6d;hpb=b2e6c299fad844633c8b40a2e180780f5774a4ae 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..c97e07db6d 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,7 +12,10 @@ 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.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.slf4j.Logger; @@ -81,7 +84,7 @@ public class ActorContext { return actorSystem.actorSelection(found.getPrimaryPath()); } - throw new RuntimeException("primary was not found"); + throw new PrimaryNotFoundException(); } /** @@ -99,7 +102,7 @@ public class ActorContext { try { return Await.result(future, AWAIT_DURATION); } catch (Exception e) { - throw new RuntimeException(e); + throw new TimeoutException(e); } } @@ -118,7 +121,7 @@ public class ActorContext { try { return Await.result(future, AWAIT_DURATION); } catch (Exception e) { - throw new RuntimeException(e); + throw new TimeoutException(e); } } @@ -131,7 +134,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 +145,8 @@ public class ActorContext { return executeRemoteOperation(primary, message, duration); } + public void shutdown() { + shardManager.tell(PoisonPill.getInstance(), null); + actorSystem.shutdown(); + } }