ONOS-2926 Remove IP instead of host when the IP mapping is released

Change-Id: Ifea3366ce8a18ea068e615636b3069e769221c0e
diff --git a/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java b/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java
index d0b827c..26c6a84 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/host/impl/ECHostStore.java
@@ -27,6 +27,7 @@
 import static org.slf4j.LoggerFactory.getLogger;
 
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
@@ -197,6 +198,34 @@
     }
 
     @Override
+    public HostEvent removeIp(HostId hostId, IpAddress ipAddress) {
+        DefaultHost host = hosts.compute(hostId, (id, existingHost) -> {
+            if (existingHost != null) {
+                checkState(Objects.equals(hostId.mac(), existingHost.mac()),
+                        "Existing and new MAC addresses differ.");
+                checkState(Objects.equals(hostId.vlanId(), existingHost.vlan()),
+                        "Existing and new VLANs differ.");
+
+                Set<IpAddress> addresses = new HashSet<>(existingHost.ipAddresses());
+                if (addresses != null && addresses.contains(ipAddress)) {
+                    addresses.remove(ipAddress);
+                    return new DefaultHost(existingHost.providerId(),
+                            hostId,
+                            existingHost.mac(),
+                            existingHost.vlan(),
+                            existingHost.location(),
+                            ImmutableSet.copyOf(addresses),
+                            existingHost.annotations());
+                } else {
+                    return existingHost;
+                }
+            }
+            return null;
+        });
+        return host != null ? new HostEvent(HOST_UPDATED, host) : null;
+    }
+
+    @Override
     public int getHostCount() {
         return hosts.size();
     }