Move host refresh related variable from SwitchManager to HostTracker 80/1480/1
authorMaurice Qureshi <maquresh@cisco.com>
Sun, 29 Sep 2013 01:00:29 +0000 (18:00 -0700)
committerMaurice Qureshi <maquresh@cisco.com>
Sun, 29 Sep 2013 01:00:29 +0000 (18:00 -0700)
Change-Id: I30921217c33dd33923cf51e8a24841c744b8b115
Signed-off-by: Maurice Qureshi <maquresh@cisco.com>
opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManager.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java

index 9f0cd893b09902a2781fb82480cee345413847b4..d7941f9cce19f90e9dc4494b5c074be3b90d4a82 100644 (file)
@@ -106,6 +106,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
     private String containerName = null;
     private ExecutorService executor;
     protected boolean stopping;
+    private static boolean hostRefresh = true;
+    private static int hostRetryCount = 5;
     private static class ARPPending {
         protected InetAddress hostIP;
         protected short sent_count;
@@ -933,7 +935,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
                     ARPPendingList.remove(entry.getKey());
                     continue;
                 }
-                if (arphost.getSent_count() < switchManager.getHostRetryCount()) {
+                if (arphost.getSent_count() < hostRetryCount) {
                     /*
                      * No reply has been received of first ARP Req, send the
                      * next one. Before sending the ARP, check if ARPHandler is
@@ -946,7 +948,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
                     hostFinder.find(arphost.getHostIP());
                     arphost.sent_count++;
                     logger.debug("ARP Sent from ARPPending List, IP: {}", arphost.getHostIP().getHostAddress());
-                } else if (arphost.getSent_count() >= switchManager.getHostRetryCount()) {
+                } else if (arphost.getSent_count() >= hostRetryCount) {
                     /*
                      * ARP requests have been sent without receiving a reply,
                      * remove this from the pending list
@@ -977,9 +979,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
             if ((clusterContainerService != null) && !clusterContainerService.amICoordinator()) {
                 return;
             }
-            if ((switchManager != null) && !switchManager.isHostRefreshEnabled()) {
+            if (!hostRefresh) {
                 /*
-                 * The host probe procedure was disabled by CLI
+                 * The host probe procedure is turned off
                  */
                 return;
             }
@@ -997,7 +999,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
 
                 short arp_cntdown = host.getArpSendCountDown();
                 arp_cntdown--;
-                if (arp_cntdown > switchManager.getHostRetryCount()) {
+                if (arp_cntdown > hostRetryCount) {
                     host.setArpSendCountDown(arp_cntdown);
                 } else if (arp_cntdown <= 0) {
                     /*
@@ -1006,7 +1008,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
                      */
                     removeKnownHost(entry.getKey());
                     notifyHostLearnedOrRemoved(host, false);
-                } else if (arp_cntdown <= switchManager.getHostRetryCount()) {
+                } else if (arp_cntdown <= hostRetryCount) {
                     /*
                      * Use the services of arphandler to check if host is still
                      * there
index 1af67719e19316407fb70f04066a2ffdc59ce4f3..f1b9585d023ab6b4d12cdd55a154cb495dc61d4d 100644 (file)
@@ -351,29 +351,19 @@ public interface ISwitchManager {
     public byte[] getNodeMAC(Node node);
 
     /**
-     * Return true if the host Refresh procedure (by sending ARP request probes
-     * to known hosts) is enabled. By default, the procedure is enabled. This can
-     * be overwritten by OSFI CLI "hostRefresh off".
-     *
-     * @return true if it is enabled; false if it's disabled.
-     */
-    public boolean isHostRefreshEnabled();
-
-    /**
-     * Return host refresh retry count
-     *
-     * @return host refresh retry count
+     * Create a Name/Tier/Bandwidth Property object based on given property name
+     * and value. Other property types are not supported yet.
+     *
+     * @param propName
+     *            Name of the Property specified by
+     *            {@link org.opendaylight.controller.sal.core.Property} and its
+     *            extended classes
+     * @param propValue
+     *            Value of the Property specified by
+     *            {@link org.opendaylight.controller.sal.core.Property} and its
+     *            extended classes
+     * @return {@link org.opendaylight.controller.sal.core.Property}
      */
-    public int getHostRetryCount();
-
-        /**
-         * Create a Name/Tier/Bandwidth Property object based on given property
-         * name and value. Other property types are not supported yet.
-         *
-     * @param propName Name of the Property specified by {@link org.opendaylight.controller.sal.core.Property} and its extended classes
-     * @param propValue Value of the Property specified by {@link org.opendaylight.controller.sal.core.Property} and its extended classes
-         * @return {@link org.opendaylight.controller.sal.core.Property}
-         */
     public Property createProperty(String propName, String propValue);
 
     /**
index 0581aa49ea574a214faf2c78acfbf9ecb449ceb1..5d0e364116dadd9c2972a6cdda4bc4bb98b0fe06 100644 (file)
@@ -106,8 +106,6 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
     private final Set<IInventoryListener> inventoryListeners = Collections
             .synchronizedSet(new HashSet<IInventoryListener>());
     private final Set<ISpanAware> spanAware = Collections.synchronizedSet(new HashSet<ISpanAware>());
-    private static boolean hostRefresh = true;
-    private int hostRetryCount = 5;
     private IClusterContainerServices clusterContainerService = null;
     private String containerName = null;
     private boolean isDefaultContainer = true;
@@ -1385,16 +1383,6 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
         return (macProperty == null) ? null : macProperty.getMacAddress();
     }
 
-    @Override
-    public boolean isHostRefreshEnabled() {
-        return hostRefresh;
-    }
-
-    @Override
-    public int getHostRetryCount() {
-        return hostRetryCount;
-    }
-
     @Override
     public NodeConnector getNodeConnector(Node node, String nodeConnectorName) {
         if (nodeConnectorNames == null) {
@@ -1850,8 +1838,6 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
         help.append("\t pencs <node id>        - Print enabled node connectors for a given node\n");
         help.append("\t pdm <node id>          - Print switch ports in device map\n");
         help.append("\t snt <node id> <tier>   - Set node tier number\n");
-        help.append("\t hostRefresh <on/off/?> - Enable/Disable/Query host refresh\n");
-        help.append("\t hostRetry <count>      - Set host retry count\n");
         return help.toString();
     }
 
@@ -1957,43 +1943,6 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
         setNodeProp(node, tier);
     }
 
-    public void _hostRefresh(CommandInterpreter ci) {
-        String mode = ci.nextArgument();
-        if (mode == null) {
-            ci.println("expecting on/off/?");
-            return;
-        }
-        if (mode.toLowerCase().equals("on")) {
-            hostRefresh = true;
-        } else if (mode.toLowerCase().equals("off")) {
-            hostRefresh = false;
-        } else if (mode.equals("?")) {
-            if (hostRefresh) {
-                ci.println("host refresh is ON");
-            } else {
-                ci.println("host refresh is OFF");
-            }
-        } else {
-            ci.println("expecting on/off/?");
-        }
-        return;
-    }
-
-    public void _hostRetry(CommandInterpreter ci) {
-        String retry = ci.nextArgument();
-        if (retry == null) {
-            ci.println("Please enter a valid number. Current retry count is "
-                    + hostRetryCount);
-            return;
-        }
-        try {
-            hostRetryCount = Integer.parseInt(retry);
-        } catch (Exception e) {
-            ci.println("Please enter a valid number");
-        }
-        return;
-    }
-
     @Override
     public byte[] getNodeMAC(Node node) {
         MacAddress mac = (MacAddress) this.getNodeProp(node,