Merge "Fixed validation bug of YANG import statement"
[controller.git] / opendaylight / hosttracker / src / main / java / org / opendaylight / controller / hosttracker / HostTracker.java
index dbcd0eede0ccb892a40dcbace85ab39ffdb22278..45f3cedacbd8e5f6a0f10575820e479464965bcb 100644 (file)
@@ -30,6 +30,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import org.apache.felix.dm.Component;
+import org.apache.taglibs.standard.lang.jstl.DivideOperator;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
@@ -158,7 +159,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         /* ARP Refresh Timer to go off every 5 seconds to implement ARP aging */
         arp_refresh_timer = new Timer();
         arp_refresh_timer.schedule(new ARPRefreshHandler(), 5000, 5000);
-        logger.info("startUp: Caches created, timers started");
+        logger.debug("startUp: Caches created, timers started");
     }
 
     @SuppressWarnings("deprecation")
@@ -168,7 +169,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                     .error("un-initialized clusterContainerService, can't create cache");
             return;
         }
-        logger.info("Creating Cache for HostTracker");
+        logger.debug("Creating Cache for HostTracker");
         try {
             this.clusterContainerService.createCache("hostTrackerAH", EnumSet
                     .of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
@@ -181,7 +182,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             logger
                     .error("Cache for HostTracker already exists, destroy and recreate");
         }
-        logger.info("Cache successfully created for HostTracker");
+        logger.debug("Cache successfully created for HostTracker");
     }
 
     @SuppressWarnings({ "unchecked", "deprecation" })
@@ -191,20 +192,20 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                     .error("un-initialized clusterContainerService, can't retrieve cache");
             return;
         }
-        logger.info("Retrieving cache for HostTrackerAH");
+        logger.debug("Retrieving cache for HostTrackerAH");
         hostsDB = (ConcurrentMap<InetAddress, HostNodeConnector>) this.clusterContainerService
                 .getCache("hostTrackerAH");
         if (hostsDB == null) {
             logger.error("Cache couldn't be retrieved for HostTracker");
         }
-        logger.info("Cache was successfully retrieved for HostTracker");
-        logger.info("Retrieving cache for HostTrackerIH");
+        logger.debug("Cache was successfully retrieved for HostTracker");
+        logger.debug("Retrieving cache for HostTrackerIH");
         inactiveStaticHosts = (ConcurrentMap<NodeConnector, HostNodeConnector>) this.clusterContainerService
                 .getCache("hostTrackerIH");
-        if (hostsDB == null) {
+        if (inactiveStaticHosts == null) {
             logger.error("Cache couldn't be retrieved for HostTrackerIH");
         }
-        logger.info("Cache was successfully retrieved for HostTrackerIH");
+        logger.debug("Cache was successfully retrieved for HostTrackerIH");
     }
 
     public void nonClusterObjectCreate() {
@@ -218,7 +219,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             logger.error("un-initialized clusterMger, can't destroy cache");
             return;
         }
-        logger.info("Destroying Cache for HostTracker");
+        logger.debug("Destroying Cache for HostTracker");
         this.clusterContainerService.destroyCache("hostTrackerAH");
         this.clusterContainerService.destroyCache("hostTrackerIH");
         nonClusterObjectCreate();
@@ -241,7 +242,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
 
     public void unsetArpHandler(IHostFinder hostFinder) {
         if (this.hostFinder == hostFinder) {
-            logger.info("Arp Handler Service removed!");
+            logger.debug("Arp Handler Service removed!");
             this.hostFinder = null;
         }
     }
@@ -252,7 +253,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
 
     public void unsetTopologyManager(ITopologyManager s) {
         if (this.topologyManager == s) {
-            logger.info("Topology Manager Service removed!");
+            logger.debug("Topology Manager Service removed!");
             this.topologyManager = null;
         }
     }
@@ -334,7 +335,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
          */
 
         if (hostFinder == null) {
-            logger.info("Exiting hostFind, null hostFinder");
+            logger.debug("Exiting hostFind, null hostFinder");
             return null;
         }
 
@@ -638,7 +639,6 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             if (switchNeedsTieringUpdate(dstNode, currentTier + 1)) {
                 Tier t = new Tier(currentTier + 1);
                 switchManager.setNodeProp(dstNode, t);
-                //logger.info("Updating Switch Tier "+ (currentTier+1) +" for "+String.format("%x", dstSw.getId()));
                 needsVisiting.add(dstNode);
             }
         }
@@ -683,7 +683,6 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             return true;
         else if (t.getValue() > tier)
             return true;
-        //logger.info(getContainerName()+" -> "+ "Switch "+String.format("%x", sw.getId())+ " is in better Tier "+sw.getTier()+" ... skipping "+tier);
         return false;
     }
 
@@ -719,7 +718,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             for (String switchName : hierarchy) {
                 buf.append(switchName + "/");
             }
-            logger.debug(getContainerName() + " -> " + buf.toString());
+            logger.debug("{} -> {}", getContainerName(), buf.toString());
             num++;
         }
     }
@@ -955,6 +954,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
     }
 
     private class ARPRefreshHandler extends TimerTask {
+        @SuppressWarnings("deprecation")
         public void run() {
             if ((clusterContainerService != null)
                     && !clusterContainerService.amICoordinator()) {
@@ -991,8 +991,6 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                     notifyHostLearnedOrRemoved(host, false);
                 } else if (arp_cntdown <= switchManager.getHostRetryCount()) {
                     /* Use the services of arphandler to check if host is still there */
-                    // logger.info("Probe for Host:{}", host);
-                    //logger.info("ARP Probing ("+arp_cntdown+") for "+host.toString());
                     logger.trace("ARP Probing ({}) for {}({})", new Object[] {
                             arp_cntdown,
                             host.getNetworkAddress().getHostAddress(),
@@ -1215,7 +1213,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                                     nc,
                     Short.valueOf(vlan));
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
             return new Status(StatusCode.BADREQUEST, "Invalid Address");
         }
     }
@@ -1227,7 +1225,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             address = InetAddress.getByName(networkAddress);
             return removeStaticHostReq(address);
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
             return new Status(StatusCode.BADREQUEST, "Invalid Address");
         }
     }
@@ -1235,7 +1233,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
     private void handleNodeConnectorStatusUp(NodeConnector nodeConnector) {
         ARPPending arphost;
 
-        logger.info("handleNodeConnectorStatusUp {}", nodeConnector);
+        logger.debug("handleNodeConnectorStatusUp {}", nodeConnector);
 
         for (int i = 0; i < failedARPReqList.size(); i++) {
             arphost = failedARPReqList.get(i);
@@ -1277,19 +1275,19 @@ public class HostTracker implements IfIptoHost, IfHostListener,
 
     void unsetClusterContainerService(IClusterContainerServices s) {
         if (this.clusterContainerService == s) {
-            logger.info("Cluster Service removed!");
+            logger.debug("Cluster Service removed!");
             this.clusterContainerService = null;
         }
     }
 
     void setSwitchManager(ISwitchManager s) {
-        logger.info("SwitchManager set");
+        logger.debug("SwitchManager set");
         this.switchManager = s;
     }
 
     void unsetSwitchManager(ISwitchManager s) {
         if (this.switchManager == s) {
-            logger.info("SwitchManager removed!");
+            logger.debug("SwitchManager removed!");
             this.switchManager = null;
         }
     }
@@ -1309,7 +1307,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         Dictionary<?, ?> props = c.getServiceProperties();
         if (props != null) {
             this.containerName = (String) props.get("containerName");
-            logger.debug("Running containerName:" + this.containerName);
+            logger.debug("Running containerName: {}", this.containerName);
         } else {
             // In the Global instance case the containerName is empty
             this.containerName = "";