Add OnDemandShardState to report additional Shard state
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / AbstractDataListenerSupport.java
index a253b794db15871f69117f291be14ef4d1193a23..fde9ff3a46304701189b4ef053f88dace6ebe3dd 100644 (file)
@@ -9,21 +9,18 @@ package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
-import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EventListener;
-import java.util.Map.Entry;
 import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
 import org.opendaylight.controller.cluster.datastore.messages.ListenerRegistrationMessage;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class AbstractDataListenerSupport<L extends EventListener, R extends ListenerRegistrationMessage,
-        D extends DelayedListenerRegistration<L, R>, LR extends ListenerRegistration<L>>
-                extends LeaderLocalDelegateFactory<R, LR, Optional<DataTreeCandidate>> {
+abstract class AbstractDataListenerSupport<L extends EventListener, M extends ListenerRegistrationMessage,
+        D extends DelayedListenerRegistration<L, M>, R extends ListenerRegistration<L>>
+                extends LeaderLocalDelegateFactory<M, R> {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private final ArrayList<D> delayedListenerRegistrations = new ArrayList<>();
@@ -63,13 +60,12 @@ abstract class AbstractDataListenerSupport<L extends EventListener, R extends Li
     }
 
     @Override
-    void onMessage(R message, boolean isLeader, boolean hasLeader) {
+    void onMessage(M message, boolean isLeader, boolean hasLeader) {
         log.debug("{}: {} for {}, leader: {}", persistenceId(), logName(), message.getPath(), isLeader);
 
         final ListenerRegistration<L> registration;
-        if((hasLeader && message.isRegisterOnAllInstances()) || isLeader) {
-            final Entry<LR, Optional<DataTreeCandidate>> res = createDelegate(message);
-            registration = res.getKey();
+        if (hasLeader && message.isRegisterOnAllInstances() || isLeader) {
+            registration = createDelegate(message);
         } else {
             log.debug("{}: Shard is not the leader - delaying registration", persistenceId());
 
@@ -99,7 +95,7 @@ abstract class AbstractDataListenerSupport<L extends EventListener, R extends Li
         actors.add(actor);
     }
 
-    protected abstract D newDelayedListenerRegistration(R message);
+    protected abstract D newDelayedListenerRegistration(M message);
 
     protected abstract ActorRef newRegistrationActor(ListenerRegistration<L> registration);