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=ee0a4796cac87e8cb79b004a36ad3748f8f52c68;hb=bfb38b42aa055a2478a5972f15ca4246dee796e9;hp=71e6b6491a4b2796e70d446b3bd0da11e9338a66;hpb=a46305fbc6bb7ec6883c21298d356a5e4fbbb015;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 71e6b6491a..ee0a4796ca 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 @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import java.util.concurrent.TimeUnit; import java.util.function.Function; +import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.datastore.ClusterWrapper; import org.opendaylight.controller.cluster.datastore.DataStoreVersions; import org.opendaylight.controller.cluster.datastore.DatastoreContext; @@ -207,7 +208,7 @@ public class ActorContext { return future.transform(new Mapper() { @Override - public PrimaryShardInfo checkedApply(Object response) throws Exception { + public PrimaryShardInfo checkedApply(Object response) throws UnknownMessageException { if(response instanceof RemotePrimaryShardFound) { LOG.debug("findPrimaryShardAsync received: {}", response); RemotePrimaryShardFound found = (RemotePrimaryShardFound)response; @@ -234,8 +235,8 @@ public class ActorContext { private PrimaryShardInfo onPrimaryShardFound(String shardName, String primaryActorPath, short primaryVersion, DataTree localShardDataTree) { ActorSelection actorSelection = actorSystem.actorSelection(primaryActorPath); - PrimaryShardInfo info = new PrimaryShardInfo(actorSelection, primaryVersion, - Optional.fromNullable(localShardDataTree)); + PrimaryShardInfo info = localShardDataTree == null ? new PrimaryShardInfo(actorSelection, primaryVersion) : + new PrimaryShardInfo(actorSelection, primaryVersion, localShardDataTree); primaryShardInfoCache.putSuccessful(shardName, info); return info; } @@ -391,27 +392,25 @@ public class ActorContext { return clusterWrapper; } - public String getCurrentMemberName(){ + public MemberName getCurrentMemberName(){ return clusterWrapper.getCurrentMemberName(); } /** * Send the message to each and every shard - * - * @param message */ - public void broadcast(final Function messageSupplier){ + public void broadcast(final Function messageSupplier, Class messageClass){ for(final String shardName : configuration.getAllShardNames()){ Future primaryFuture = findPrimaryShardAsync(shardName); primaryFuture.onComplete(new OnComplete() { @Override public void onComplete(Throwable failure, PrimaryShardInfo primaryShardInfo) { - Object message = messageSupplier.apply(primaryShardInfo.getPrimaryShardVersion()); if(failure != null) { LOG.warn("broadcast failed to send message {} to shard {}: {}", - message.getClass().getSimpleName(), shardName, failure); + messageClass.getSimpleName(), shardName, failure); } else { + Object message = messageSupplier.apply(primaryShardInfo.getPrimaryShardVersion()); primaryShardInfo.getPrimaryShardActor().tell(message, ActorRef.noSender()); } }