HostTracker immediately ages out hosts on coordinator
[controller.git] / opendaylight / hosttracker / api / src / main / java / org / opendaylight / controller / hosttracker / hostAware / HostNodeConnector.java
index c83dc3d4089870cc020d0b6abf6fbd15e3637042..206124b93bf67a2fc995e960e36bc0bdae21942a 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -9,6 +8,7 @@
 
 package org.opendaylight.controller.hosttracker.hostAware;
 
+import java.io.Serializable;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -19,18 +19,15 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Host;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.packet.address.EthernetAddress;
 
-@XmlRootElement(name="host")
+@XmlRootElement(name = "host")
 @XmlAccessorType(XmlAccessType.NONE)
-public class HostNodeConnector extends Host {
+public class HostNodeConnector extends Host implements Serializable {
     private static final long serialVersionUID = 1L;
     @XmlElement
     private NodeConnector nodeConnector;
@@ -38,7 +35,7 @@ public class HostNodeConnector extends Host {
     private short vlan;
     @XmlElement
     private boolean staticHost;
-    private transient short arpSendCountDown;
+    private short arpSendCountDown;
 
     /**
      * Private constructor used for JAXB mapping
@@ -84,20 +81,6 @@ public class HostNodeConnector extends Host {
         return this.nodeConnector.getNode();
     }
 
-    /**
-     * @return the NodeId
-     */
-    public Long getnodeconnectornodeId() {
-        return (Long) this.nodeConnector.getNode().getID();
-    }
-
-    /**
-     * @return the port
-     */
-    public Short getnodeconnectorportId() {
-        return (Short) this.nodeConnector.getID();
-    }
-
     /**
      * @return the DataLayerAddress
      */
@@ -140,20 +123,36 @@ public class HostNodeConnector extends Host {
         return this;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((nodeConnector == null) ? 0 : nodeConnector.hashCode());
+        result = prime * result + (staticHost ? 1231 : 1237);
+        result = prime * result + vlan;
+        return result;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        HostNodeConnector other = (HostNodeConnector) obj;
+        if (nodeConnector == null) {
+            if (other.nodeConnector != null)
+                return false;
+        } else if (!nodeConnector.equals(other.nodeConnector))
+            return false;
+        if (staticHost != other.staticHost)
+            return false;
+        if (vlan != other.vlan)
+            return false;
+        return true;
     }
 
     public boolean equalsByIP(InetAddress networkAddress) {
@@ -173,13 +172,10 @@ public class HostNodeConnector extends Host {
         return !Arrays.equals(emptyArray, macaddr);
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
-        return "HostNodeConnector[" + ReflectionToStringBuilder.toString(this)
-                + "]";
+        return "HostNodeConnector [nodeConnector=" + nodeConnector + ", vlan="
+                + vlan + ", staticHost=" + staticHost + "]";
     }
 
     public boolean isV4Host() {