Yuta HIGUCHI

DistributedMastershipStore: pupulate cache on startup

Change-Id: I64567a964c8beb63428d01f43df37968e4ac8be0
...@@ -4,6 +4,7 @@ import com.google.common.base.Optional; ...@@ -4,6 +4,7 @@ import com.google.common.base.Optional;
4 import com.google.common.cache.LoadingCache; 4 import com.google.common.cache.LoadingCache;
5 import com.google.common.collect.ImmutableSet; 5 import com.google.common.collect.ImmutableSet;
6 import com.hazelcast.core.IMap; 6 import com.hazelcast.core.IMap;
7 +
7 import org.apache.felix.scr.annotations.Activate; 8 import org.apache.felix.scr.annotations.Activate;
8 import org.apache.felix.scr.annotations.Component; 9 import org.apache.felix.scr.annotations.Component;
9 import org.apache.felix.scr.annotations.Deactivate; 10 import org.apache.felix.scr.annotations.Deactivate;
...@@ -53,9 +54,18 @@ public class DistributedMastershipStore ...@@ -53,9 +54,18 @@ public class DistributedMastershipStore
53 masters = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader)); 54 masters = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader));
54 rawMasters.addEntryListener(new RemoteEventHandler<>(masters), true); 55 rawMasters.addEntryListener(new RemoteEventHandler<>(masters), true);
55 56
57 + loadMasters();
58 +
56 log.info("Started"); 59 log.info("Started");
57 } 60 }
58 61
62 + private void loadMasters() {
63 + for (byte[] keyBytes : rawMasters.keySet()) {
64 + final DeviceId id = deserialize(keyBytes);
65 + masters.refresh(id);
66 + }
67 + }
68 +
59 @Deactivate 69 @Deactivate
60 public void deactivate() { 70 public void deactivate() {
61 log.info("Stopped"); 71 log.info("Stopped");
......