Fix bug CONTROLLER-1798. 86/66186/2
authorYIN Kangqian <yin.kangqian@zte.com.cn>
Mon, 4 Dec 2017 02:18:31 +0000 (10:18 +0800)
committerYIN Kangqian <yin.kangqian@zte.com.cn>
Tue, 5 Dec 2017 01:41:23 +0000 (09:41 +0800)
Updated peer address on shard in ShardManager#updateSchemaContext
for every existing peer memeber to avoid missing sending PeerAddressResolved
and PeerUp to shard while UpdateSchemaContext comes after MemberUp.

Change-Id: I0758e489a189f82180ca6885987ec99f1e5712c7
Signed-off-by: YIN Kangqian <yin.kangqian@zte.com.cn>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardPeerAddressResolver.java

index e3d3a60..430b3b7 100644 (file)
@@ -1137,6 +1137,17 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
             if (info.getActor() == null) {
                 LOG.debug("Creating Shard {}", info.getShardId());
                 info.setActor(newShardActor(info));
+                // Update peer address for every existing peer memeber to avoid missing sending
+                // PeerAddressResolved and PeerUp to this shard while UpdateSchemaContext comes after MemberUp.
+                String shardName = info.getShardName();
+                for (MemberName memberName : peerAddressResolver.getPeerMembers()) {
+                    String peerId = getShardIdentifier(memberName, shardName).toString() ;
+                    String peerAddress = peerAddressResolver.getShardActorAddress(shardName, memberName);
+                    info.updatePeerAddress(peerId, peerAddress, getSelf());
+                    info.peerUp(memberName, peerId, getSelf());
+                    LOG.debug("{}: updated peer {} on member {} with address {} on shard {} whose actor address is {}",
+                            persistenceId(), peerId, memberName, peerAddress, info.getShardId(), info.getActor());
+                }
             } else {
                 info.getActor().tell(message, getSelf());
             }
index a05548b..468d650 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
@@ -47,6 +48,10 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
         memberNameToAddress.remove(memberName);
     }
 
+    Set<MemberName> getPeerMembers() {
+        return this.memberNameToAddress.keySet();
+    }
+
     Address getPeerAddress(MemberName memberName) {
         return memberNameToAddress.get(memberName);
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.