Yuta HIGUCHI

DistributedMastershipStore: pupulate cache on startup

Change-Id: I64567a964c8beb63428d01f43df37968e4ac8be0
......@@ -4,6 +4,7 @@ import com.google.common.base.Optional;
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 @@ public class DistributedMastershipStore
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");
......