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%2FClusterWrapperImpl.java;h=8910137ec4583272b55ead555b0ed12e11caa02c;hp=142aacde65c32f1050846810c8d33b1c9122be55;hb=5834673a28941e470173b5215f56cebdf0cfa2f0;hpb=0eb621d29daaf08979c356e2148e99c48458e169 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java index 142aacde65..8910137ec4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java @@ -12,18 +12,31 @@ import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.cluster.Cluster; import akka.cluster.ClusterEvent; +import com.google.common.base.Preconditions; public class ClusterWrapperImpl implements ClusterWrapper { private final Cluster cluster; private final String currentMemberName; public ClusterWrapperImpl(ActorSystem actorSystem){ + Preconditions.checkNotNull(actorSystem, "actorSystem should not be null"); + cluster = Cluster.get(actorSystem); + + Preconditions.checkState(cluster.getSelfRoles().size() > 0, + "No akka roles were specified\n" + + "One way to specify the member name is to pass a property on the command line like so\n" + + " -Dakka.cluster.roles.0=member-3\n" + + "member-3 here would be the name of the member" + ); + currentMemberName = (String) cluster.getSelfRoles().toArray()[0]; } public void subscribeToMemberEvents(ActorRef actorRef){ + Preconditions.checkNotNull(actorRef, "actorRef should not be null"); + cluster.subscribe(actorRef, ClusterEvent.initialStateAsEvents(), ClusterEvent.MemberEvent.class, ClusterEvent.UnreachableMember.class);