X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fnotifications%2FRoleChangeNotifier.java;h=bb4ad65f161f11bb57e5d263cdc17b41a2e0bc57;hb=a60f577d66eb510232b0e2ccca73d9e7a81af0c9;hp=598dfb1fe827fe8b03234003dc5d0bdf7c750223;hpb=b57b5bca2d4d04b0e317972b081271bf35c2c818;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifier.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifier.java index 598dfb1fe8..bb4ad65f16 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifier.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifier.java @@ -5,31 +5,31 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.notifications; import akka.actor.ActorPath; import akka.actor.ActorRef; import akka.actor.Props; import akka.serialization.Serialization; -import com.google.common.collect.Maps; +import java.util.HashMap; import java.util.Map; import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor; /** * The RoleChangeNotifier is responsible for receiving Raft role and leader state change messages and notifying * the listeners (within the same node), which are registered with it. - *

+ * + *

* The RoleChangeNotifier is instantiated by the Shard and injected into the RaftActor. */ public class RoleChangeNotifier extends AbstractUntypedActor implements AutoCloseable { private final String memberId; - private final Map registeredListeners = Maps.newHashMap(); + private final Map registeredListeners = new HashMap<>(); private RoleChangeNotification latestRoleChangeNotification = null; private LeaderStateChanged latestLeaderStateChanged; - public RoleChangeNotifier(String memberId) { + public RoleChangeNotifier(final String memberId) { this.memberId = memberId; } @@ -45,7 +45,7 @@ public class RoleChangeNotifier extends AbstractUntypedActor implements AutoClos } @Override - protected void handleReceive(Object message) throws Exception { + protected void handleReceive(final Object message) { if (message instanceof RegisterRoleChangeListener) { // register listeners for this shard @@ -63,7 +63,7 @@ public class RoleChangeNotifier extends AbstractUntypedActor implements AutoClos getSender().tell(new RegisterRoleChangeListenerReply(), getSelf()); - if(latestLeaderStateChanged != null) { + if (latestLeaderStateChanged != null) { getSender().tell(latestLeaderStateChanged, getSelf()); } @@ -92,11 +92,13 @@ public class RoleChangeNotifier extends AbstractUntypedActor implements AutoClos for (ActorRef listener: registeredListeners.values()) { listener.tell(latestLeaderStateChanged, getSelf()); } + } else { + unknownMessage(message); } } @Override - public void close() throws Exception { + public void close() { registeredListeners.clear(); } }