DistributedMastershipStore: pupulate cache on startup
Change-Id: I64567a964c8beb63428d01f43df37968e4ac8be0
diff --git a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java b/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
index 10c116b..d3fcf3e 100644
--- a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
+++ b/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
@@ -4,6 +4,7 @@
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import com.hazelcast.core.IMap;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -53,9 +54,18 @@
masters = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader));
rawMasters.addEntryListener(new RemoteEventHandler<>(masters), true);
+ loadMasters();
+
log.info("Started");
}
+ private void loadMasters() {
+ for (byte[] keyBytes : rawMasters.keySet()) {
+ final DeviceId id = deserialize(keyBytes);
+ masters.refresh(id);
+ }
+ }
+
@Deactivate
public void deactivate() {
log.info("Stopped");