Bug 1029: Remove dead code: samples/clustersession
[controller.git] / opendaylight / hosttracker_new / implementation / src / main / java / org / opendaylight / controller / hosttracker / internal / Device.java
index 50e77ec643298cef46c67d294b0c8242512db78f..8fcb988b6cd43a63530873c025a23d92cd2f067b 100755 (executable)
@@ -78,6 +78,8 @@ public class Device implements IDevice {
     protected final Short[] vlanIds;
     protected volatile String dhcpClientName;
 
+    private boolean staticHost;
+
     /**
      * These are the old attachment points for the device that were valid no
      * more than INACTIVITY_TIME ago.
@@ -179,7 +181,8 @@ public class Device implements IDevice {
      * @param newEntity
      *            the entity to add. newEntity must be have the same entity
      *            class as device
-     * @param if positive indicates the index in the entities array were the new
+     * @param insertionpoint
+     *        if positive indicates the index in the entities array were the new
      *        entity should be inserted. If negative we will compute the correct
      *        insertion point
      */
@@ -238,10 +241,11 @@ public class Device implements IDevice {
 
         TreeSet<Short> vals = new TreeSet<Short>();
         for (Entity e : entities) {
-            if (e.getVlan() == null)
+            if (e.getVlan() == null) {
                 vals.add((short) -1);
-            else
+            } else {
                 vals.add(e.getVlan());
+            }
         }
         return vals.toArray(new Short[vals.size()]);
     }
@@ -311,15 +315,16 @@ public class Device implements IDevice {
             return false;
 
         for (AttachmentPoint ap : apList) {
-            if (ap.getLastSeen() + AttachmentPoint.INACTIVITY_INTERVAL < System
-                    .currentTimeMillis())
-                expiredAPs.add(ap);
+            if (ap.getLastSeen() + AttachmentPoint.INACTIVITY_INTERVAL < System.currentTimeMillis()) {
+               expiredAPs.add(ap);
+            }
         }
         if (expiredAPs.size() > 0) {
             apList.removeAll(expiredAPs);
             return true;
-        } else
+        } else {
             return false;
+        }
     }
 
     /**
@@ -336,7 +341,6 @@ public class Device implements IDevice {
      */
     List<AttachmentPoint> getDuplicateAttachmentPoints(
             List<AttachmentPoint> oldAPList, Map<Long, AttachmentPoint> apMap) {
-        // ITopologyService topology = deviceManager.topology;
         List<AttachmentPoint> dupAPs = new ArrayList<AttachmentPoint>();
         long timeThreshold = System.currentTimeMillis()
                 - AttachmentPoint.INACTIVITY_INTERVAL;
@@ -345,17 +349,11 @@ public class Device implements IDevice {
             return dupAPs;
 
         for (AttachmentPoint ap : oldAPList) {
-            // XXX - Missing functionality
-            // long id = topology.getL2DomainId(ap.getSw());
             long id = 0;
             AttachmentPoint trueAP = apMap.get(id);
 
             if (trueAP == null)
                 continue;
-            // XXX - Missing functionality
-            // boolean c = (topology.isConsistent(trueAP.getSw(),
-            // trueAP.getPort(),
-            // ap.getSw(), ap.getPort()));
             boolean c = true;
             boolean active = (ap.getActiveSince() > trueAP.getActiveSince());
             boolean last = ap.getLastSeen() > timeThreshold;
@@ -408,7 +406,6 @@ public class Device implements IDevice {
      * any change to the list of attachment points for the device -- which
      * indicates a device move.
      *
-     * @param sw
      * @param port
      * @param lastSeen
      * @return
@@ -458,7 +455,6 @@ public class Device implements IDevice {
         }
 
         // XXX - Missing functionality
-        // long id = topology.getL2DomainId(sw);
         long id = 0;
         AttachmentPoint oldAP = apMap.get(id);
 
@@ -495,11 +491,6 @@ public class Device implements IDevice {
                 oldAPList.addAll(oldAPs);
             oldAPList.add(oldAP);
             this.oldAPs = oldAPList;
-            // XXX - Missing functionality
-            // if (!topology.isInSameBroadcastDomain(oldAP.getSw(),
-            // oldAP.getPort(),
-            // newAP.getSw(), newAP.getPort()))
-            // return true; // attachment point changed.
             return true;
         } else if (oldAPFlag) {
             // retain oldAP as is. Put the newAP in oldAPs for flagging
@@ -510,11 +501,6 @@ public class Device implements IDevice {
             // Add to oldAPList only if it was picked up from the oldAPList
             oldAPList.add(newAP);
             this.oldAPs = oldAPList;
-            // XXX - Missing functionality
-            // if (!topology.isInSameBroadcastDomain(oldAP.getSw(),
-            // oldAP.getPort(),
-            // newAP.getSw(), newAP.getPort()))
-            // return true; // attachment point changed.
             return true;
         }
         return false;
@@ -523,7 +509,6 @@ public class Device implements IDevice {
     /**
      * Delete (sw,port) from the list of list of attachment points and oldAPs.
      *
-     * @param sw
      * @param port
      * @return
      */
@@ -701,10 +686,12 @@ public class Device implements IDevice {
         TreeSet<Short> vals = new TreeSet<Short>();
         for (Entity e : entities) {
             if (e.getPort().equals(swp.getPort())) {
-                if (e.getVlan() == null)
+                if (e.getVlan() == null) {
                     vals.add(VLAN_UNTAGGED);
-                else
+                }
+                else  {
                     vals.add(e.getVlan());
+                }
             }
         }
         return vals.toArray(new Short[vals.size()]);
@@ -784,11 +771,16 @@ public class Device implements IDevice {
     public HostNodeConnector toHostNodeConnector() {
         Integer[] ipv4s = this.getIPv4Addresses();
         try {
+            Entity e = this.entities[this.entities.length-1];
+            NodeConnector n = null;
+            if(e!=null)
+                 n = e.getPort();
             InetAddress ip = InetAddress.getByName(ipv4s[ipv4s.length - 1]
                     .toString());
             byte[] macAddr = macLongToByte(this.getMACAddress());
-            HostNodeConnector nc = new HostNodeConnector(macAddr, ip, null,
+            HostNodeConnector nc = new HostNodeConnector(macAddr, ip, n,
                     (short) 0);
+            nc.setStaticHost(this.isStaticHost());
             return nc;
         } catch (Exception e) {
             return null;
@@ -803,6 +795,14 @@ public class Device implements IDevice {
         return macAddr;
     }
 
+    public boolean isStaticHost(){
+        return this.staticHost;
+    }
+
+    public void setStaticHost(boolean isStatic){
+        this.staticHost = isStatic;
+    }
+
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
@@ -818,7 +818,6 @@ public class Device implements IDevice {
             if (!isFirst)
                 builder.append(", ");
             isFirst = false;
-            // builder.append(IPv4.fromIPv4Address(ip));
             builder.append(ip);
         }
         builder.append("], APs=");