populate DevicePorts on activate
Change-Id: If716b27fb13dcd64021cf56a0a49b76bc2258a5e
diff --git a/core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java b/core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
index 64ae3c8..6d132ad 100644
--- a/core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
+++ b/core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
@@ -95,6 +95,7 @@
rawDevicePorts.addEntryListener(new RemotePortEventHandler(devicePorts), includeValue);
loadDeviceCache();
+ loadDevicePortsCache();
log.info("Started");
}
@@ -122,13 +123,16 @@
}
private void loadDeviceCache() {
- log.info("{}:{}", rawDevices.size(), devices.size());
- if (rawDevices.size() != devices.size()) {
- for (Map.Entry<byte[], byte[]> e : rawDevices.entrySet()) {
- final DeviceId key = deserialize(e.getKey());
- final DefaultDevice val = deserialize(e.getValue());
- devices.put(key, Optional.of(val));
- }
+ for (byte[] keyBytes : rawDevices.keySet()) {
+ final DeviceId id = deserialize(keyBytes);
+ devices.refresh(id);
+ }
+ }
+
+ private void loadDevicePortsCache() {
+ for (byte[] keyBytes : rawDevicePorts.keySet()) {
+ final DeviceId id = deserialize(keyBytes);
+ devicePorts.refresh(id);
}
}