added HostProvider to SimpleHostManager
Change-Id: I13ff57fcd24ea7bd2c3f2544a3aad7d18ceda107
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java b/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
index ea68b53..a06a92e 100644
--- a/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
+++ b/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
@@ -20,6 +20,14 @@
private final Set<IPAddress> ips;
public DefaultHostDescription(MACAddress mac, VLANID vlan,
+ HostLocation loc) {
+ this.mac = mac;
+ this.vlan = vlan;
+ this.location = loc;
+ this.ips = new HashSet<IPAddress>();
+ }
+
+ public DefaultHostDescription(MACAddress mac, VLANID vlan,
HostLocation loc, Set<IPAddress> ips) {
this.mac = mac;
this.vlan = vlan;
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java
index 2f9eb29..b7fc5ae 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/host/impl/SimpleHostStore.java
@@ -76,20 +76,23 @@
HostDescription descr) {
DefaultHost updated;
HostEvent event;
- if (host.location().equals(descr.location())) {
- updated = new DefaultHost(providerId, host.id(),
- host.mac(),
- host.vlan(),
- host.location(),
- descr.ipAddresses());
- event = new HostEvent(HOST_UPDATED, updated);
- } else {
+ // Consider only actual location (not timestamp) change?
+ if (!(host.location().port().equals(descr.location().port()))) {
updated = new DefaultHost(providerId, host.id(),
host.mac(),
host.vlan(),
descr.location(),
host.ipAddresses());
event = new HostEvent(HOST_MOVED, updated);
+ } else if (!(host.ipAddresses().equals(descr.ipAddresses()))) {
+ updated = new DefaultHost(providerId, host.id(),
+ host.mac(),
+ host.vlan(),
+ descr.location(),
+ descr.ipAddresses());
+ event = new HostEvent(HOST_UPDATED, updated);
+ } else {
+ return null;
}
synchronized (this) {
hosts.put(host.id(), updated);