Yuta HIGUCHI

populate DevicePorts on activate

Change-Id: If716b27fb13dcd64021cf56a0a49b76bc2258a5e
...@@ -95,6 +95,7 @@ public class DistributedDeviceStore ...@@ -95,6 +95,7 @@ public class DistributedDeviceStore
95 rawDevicePorts.addEntryListener(new RemotePortEventHandler(devicePorts), includeValue); 95 rawDevicePorts.addEntryListener(new RemotePortEventHandler(devicePorts), includeValue);
96 96
97 loadDeviceCache(); 97 loadDeviceCache();
98 + loadDevicePortsCache();
98 99
99 log.info("Started"); 100 log.info("Started");
100 } 101 }
...@@ -122,14 +123,17 @@ public class DistributedDeviceStore ...@@ -122,14 +123,17 @@ public class DistributedDeviceStore
122 } 123 }
123 124
124 private void loadDeviceCache() { 125 private void loadDeviceCache() {
125 - log.info("{}:{}", rawDevices.size(), devices.size()); 126 + for (byte[] keyBytes : rawDevices.keySet()) {
126 - if (rawDevices.size() != devices.size()) { 127 + final DeviceId id = deserialize(keyBytes);
127 - for (Map.Entry<byte[], byte[]> e : rawDevices.entrySet()) { 128 + devices.refresh(id);
128 - final DeviceId key = deserialize(e.getKey());
129 - final DefaultDevice val = deserialize(e.getValue());
130 - devices.put(key, Optional.of(val));
131 } 129 }
132 } 130 }
131 +
132 + private void loadDevicePortsCache() {
133 + for (byte[] keyBytes : rawDevicePorts.keySet()) {
134 + final DeviceId id = deserialize(keyBytes);
135 + devicePorts.refresh(id);
136 + }
133 } 137 }
134 138
135 @Override 139 @Override
......