Fix for ONOS-5032 and ONOS-5034

Change-Id: Ib964252dd05754ce7069a7a82ccb1d1c29bfa978
diff --git a/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java b/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
index b4449ae..a359862 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
@@ -48,6 +48,7 @@
 import org.onosproject.store.service.MapEventListener;
 import org.onosproject.store.service.Serializer;
 import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.WallClockTimestamp;
 import org.slf4j.Logger;
 
 import java.util.Collection;
@@ -87,7 +88,8 @@
     @Activate
     public void activate() {
         KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
-                .register(KryoNamespaces.API);
+                .register(KryoNamespaces.API)
+                .register(WallClockTimestamp.class);
 
         hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder()
                 .withName("onos-hosts")
@@ -122,7 +124,9 @@
         if (!Objects.equals(existingHost.providerId(), providerId) ||
                 !Objects.equals(existingHost.mac(), hostDescription.hwAddress()) ||
                 !Objects.equals(existingHost.vlan(), hostDescription.vlan()) ||
-                !Objects.equals(existingHost.location(), hostDescription.location())) {
+                !Objects.equals(existingHost.location(), hostDescription.location()) ||
+                hostDescription.timestamp() == null ||
+                hostDescription.timestamp().isNewerThan(existingHost.timestamp())) {
             return true;
         }
 
@@ -173,13 +177,13 @@
                            } else {
                                annotations = hostDescription.annotations();
                            }
-
                            return new DefaultHost(providerId,
                                                   hostId,
                                                   hostDescription.hwAddress(),
                                                   hostDescription.vlan(),
                                                   location,
                                                   addresses,
+                                                  hostDescription.timestamp(),
                                                   annotations);
                        });
         return null;
@@ -302,3 +306,4 @@
         }
     }
 }
+