blob: d05659bd09c347a616a6ae0e81dc31069cc9eca5 [file] [log] [blame]
Yuta HIGUCHId76830b2014-09-30 19:08:40 -07001package org.onlab.onos.store.device.impl;
2
3import java.util.Collection;
4import java.util.HashMap;
5import java.util.Map;
6
7import org.onlab.onos.cluster.NodeId;
8import org.onlab.onos.net.Device;
9import org.onlab.onos.net.DeviceId;
10import org.onlab.onos.store.Timestamp;
Yuta HIGUCHIc057c632014-10-06 18:38:14 -070011import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement;
Yuta HIGUCHId76830b2014-09-30 19:08:40 -070012
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
16public 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}