Yuta HIGUCHI | d76830b | 2014-09-30 19:08:40 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.device.impl; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.HashMap; |
| 5 | import java.util.Map; |
| 6 | |
| 7 | import org.onlab.onos.cluster.NodeId; |
| 8 | import org.onlab.onos.net.Device; |
| 9 | import org.onlab.onos.net.DeviceId; |
| 10 | import org.onlab.onos.store.Timestamp; |
Yuta HIGUCHI | c057c63 | 2014-10-06 18:38:14 -0700 | [diff] [blame^] | 11 | import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement; |
Yuta HIGUCHI | d76830b | 2014-09-30 19:08:40 -0700 | [diff] [blame] | 12 | |
| 13 | // TODO DeviceID needs to be changed to something like (ProviderID, DeviceID) |
| 14 | // TODO: Handle Port as part of these messages, or separate messages for Ports? |
| 15 | |
| 16 | public class DeviceAntiEntropyAdvertisement |
| 17 | extends AntiEntropyAdvertisement<DeviceId> { |
| 18 | |
| 19 | |
| 20 | public DeviceAntiEntropyAdvertisement(NodeId sender, |
| 21 | Map<DeviceId, Timestamp> advertisement) { |
| 22 | super(sender, advertisement); |
| 23 | } |
| 24 | |
| 25 | // May need to add ProviderID, etc. |
| 26 | public static DeviceAntiEntropyAdvertisement create( |
| 27 | NodeId self, |
| 28 | Collection<VersionedValue<Device>> localValues) { |
| 29 | |
| 30 | Map<DeviceId, Timestamp> ads = new HashMap<>(localValues.size()); |
| 31 | for (VersionedValue<Device> e : localValues) { |
| 32 | ads.put(e.entity().id(), e.timestamp()); |
| 33 | } |
| 34 | return new DeviceAntiEntropyAdvertisement(self, ads); |
| 35 | } |
| 36 | |
| 37 | // For serializer |
| 38 | protected DeviceAntiEntropyAdvertisement() {} |
| 39 | } |