Added notion of a general Store abstraction and wired it up in ClusterStore.
diff --git a/core/net/src/main/java/org/onlab/onos/cluster/impl/ClusterManager.java b/core/net/src/main/java/org/onlab/onos/cluster/impl/ClusterManager.java
index aa21283..d0cc949 100644
--- a/core/net/src/main/java/org/onlab/onos/cluster/impl/ClusterManager.java
+++ b/core/net/src/main/java/org/onlab/onos/cluster/impl/ClusterManager.java
@@ -11,6 +11,7 @@
import org.onlab.onos.cluster.ClusterEventListener;
import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.ClusterStore;
+import org.onlab.onos.cluster.ClusterStoreDelegate;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.event.AbstractListenerRegistry;
@@ -32,6 +33,8 @@
public static final String INSTANCE_ID_NULL = "Instance ID cannot be null";
private final Logger log = getLogger(getClass());
+ private ClusterStoreDelegate delegate = new InternalStoreDelegate();
+
protected final AbstractListenerRegistry<ClusterEvent, ClusterEventListener>
listenerRegistry = new AbstractListenerRegistry<>();
@@ -43,6 +46,7 @@
@Activate
public void activate() {
+ store.setDelegate(delegate);
eventDispatcher.addSink(ClusterEvent.class, listenerRegistry);
log.info("Started");
}
@@ -90,4 +94,13 @@
public void removeListener(ClusterEventListener listener) {
listenerRegistry.removeListener(listener);
}
+
+ // Store delegate to re-post events emitted from the store.
+ private class InternalStoreDelegate implements ClusterStoreDelegate {
+ @Override
+ public void notify(ClusterEvent event) {
+ checkNotNull(event, "Event cannot be null");
+ eventDispatcher.post(event);
+ }
+ }
}