Merge "Add Select all checkbox to all datagrids, remove out port and out vlan columns...
authorAndrew Kim <andrekim@cisco.com>
Wed, 28 Aug 2013 04:57:36 +0000 (04:57 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 28 Aug 2013 04:57:36 +0000 (04:57 +0000)
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPEvent.java
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPReply.java
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPRequest.java
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterContainerServices.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterGlobalServices.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterServices.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterServicesCommon.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java

index fb92e8df854ce6cd464fd46ae494d976cf5c4e92..f676a79d4951043d22d45ea237f820ee0efc8476 100644 (file)
@@ -56,4 +56,21 @@ public abstract class ARPEvent implements Serializable{
     public InetAddress getTargetIP() {
         return tIP;
     }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ARPEvent [");
+        if (tIP != null) {
+            builder.append("tIP=")
+                    .append(tIP);
+        }
+        builder.append("]");
+        return builder.toString();
+    }
 }
index 4ca3e42c7c496a00f07503fd04df974ce243de3f..e4388c598fb0eec94a0bb6cdb8f070b4f328af2c 100644 (file)
@@ -13,6 +13,7 @@ import java.net.InetAddress;
 import java.util.Arrays;
 
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.utils.HexEncode;
 /*
  * ARP Reply event wrapper
  */
@@ -92,4 +93,36 @@ public class ARPReply extends ARPEvent {
     public NodeConnector getPort() {
         return port;
     }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ARPReply [");
+        if (port != null) {
+            builder.append("port=")
+                    .append(port)
+                    .append(", ");
+        }
+        if (tMac != null) {
+            builder.append("tMac=")
+                    .append(HexEncode.bytesToHexString(tMac))
+                    .append(", ");
+        }
+        if (sMac != null) {
+            builder.append("sMac=")
+                    .append(HexEncode.bytesToHexString(sMac))
+                    .append(", ");
+        }
+        if (sIP != null) {
+            builder.append("sIP=")
+                    .append(sIP);
+        }
+        builder.append("]");
+        return builder.toString();
+    }
 }
index 7f88a25e31c08388b57c9c1957a40da9a7311feb..39cd4f7131de5539a92ed5661b1806de59781b7a 100644 (file)
@@ -82,4 +82,26 @@ public class ARPRequest extends ARPEvent {
     public HostNodeConnector getHost() {
         return host;
     }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ARPRequest [");
+        if (subnet != null) {
+            builder.append("subnet=")
+                    .append(subnet)
+                    .append(", ");
+        }
+        if (host != null) {
+            builder.append("host=")
+                    .append(host);
+        }
+        builder.append("]");
+        return builder.toString();
+    }
 }
index f3b22c75d8102a76beeb78229e7faabb89e60bd5..627ab267399978950d66f7dd1625f25a2c405021 100644 (file)
@@ -76,7 +76,8 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     private ConcurrentMap<InetAddress, Short> countDownTimers;
     private Timer periodicTimer;
     private BlockingQueue<ARPCacheEvent> ARPCacheEvents = new LinkedBlockingQueue<ARPCacheEvent>();
-    Thread cacheEventHandler;
+    private Thread cacheEventHandler;
+    private boolean stopping = false;
     /*
      * A cluster allocated cache. Used for synchronizing ARP request/reply
      * events across all cluster controllers. To raise an event, we put() a specific
@@ -224,7 +225,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
             try {
                 requestor = new HostNodeConnector(sourceMAC, sourceIP, p, subnet.getVlan());
             } catch (ConstructionException e) {
-                log.debug("Received ARP packet with invalid MAC: {}", sourceMAC);
+                log.debug("Received ARP packet with invalid MAC: {}", HexEncode.bytesToHexString(sourceMAC));
                 return;
             }
             /*
@@ -268,7 +269,8 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                 && (NetUtils.isBroadcastMACAddr(targetMAC) || Arrays.equals(targetMAC, getControllerMAC()))) {
             if (connectionManager.isLocal(p.getNode())){
                 if (log.isTraceEnabled()){
-                    log.trace("Received local ARP req. for default gateway. Replying with controller MAC: {}", getControllerMAC());
+                    log.trace("Received local ARP req. for default gateway. Replying with controller MAC: {}",
+                            HexEncode.bytesToHexString(getControllerMAC()));
                 }
                 sendARPReply(p, getControllerMAC(), targetIP, pkt.getSenderHardwareAddress(), sourceIP);
             } else {
@@ -297,7 +299,6 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
             //Raise a bcast request event, all controllers need to send one
             log.trace("Sending a bcast ARP request for {}", targetIP);
             arpRequestReplyEvent.put(new ARPRequest(targetIP, subnet), false);
-
         } else {
             /*
              * Target host known (across the cluster), send ARP REPLY make sure that targetMAC
@@ -337,6 +338,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
      *  the targetIP as the target Network Address
      */
     protected void sendBcastARPRequest(InetAddress targetIP, Subnet subnet) {
+        log.trace("sendBcatARPRequest targetIP:{} subnet:{}", targetIP, subnet);
         Set<NodeConnector> nodeConnectors;
         if (subnet.isFlatLayer2()) {
             nodeConnectors = new HashSet<NodeConnector>();
@@ -348,11 +350,11 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         }
 
         for (NodeConnector p : nodeConnectors) {
-
             //fiter out any non-local or internal ports
             if (! connectionManager.isLocal(p.getNode()) || topologyManager.isInternal(p)) {
                 continue;
             }
+            log.trace("Sending toward nodeConnector:{}", p);
             ARP arp = new ARP();
             byte[] senderIP = subnet.getNetworkAddress().getAddress();
             byte[] targetIPByte = targetIP.getAddress();
@@ -393,7 +395,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
      * The sender MAC is the controller's MAC
      */
     protected void sendUcastARPRequest(HostNodeConnector host, Subnet subnet) {
-
+        log.trace("sendUcastARPRequest host:{} subnet:{}", host, subnet);
         NodeConnector outPort = host.getnodeConnector();
         if (outPort == null) {
             log.error("Failed sending UcastARP because cannot extract output port from Host: {}", host);
@@ -426,6 +428,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
         this.dataPacketService.transmitDataPacket(destPkt);
     }
 
+    @Override
     public void find(InetAddress networkAddress) {
         log.trace("Received find IP {}", networkAddress);
 
@@ -445,6 +448,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     /*
      * Probe the host by sending a unicast ARP Request to the host
      */
+    @Override
     public void probe(HostNodeConnector host) {
         log.trace("Received probe host {}", host);
 
@@ -562,6 +566,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
      *
      */
     void destroy() {
+        cacheEventHandler.interrupt();
     }
 
     /**
@@ -571,9 +576,9 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
      *
      */
     void start() {
+        stopping = false;
         startPeriodicTimer();
         cacheEventHandler.start();
-
     }
 
     /**
@@ -586,6 +591,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     }
 
     void stopping() {
+        stopping = true;
         cancelPeriodicTimer();
     }
 
@@ -666,15 +672,25 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     }
 
     private void generateAndSendReply(InetAddress sourceIP, byte[] sourceMAC) {
+        if (log.isTraceEnabled()) {
+            log.trace("generateAndSendReply called with params sourceIP:{} sourceMAC:{}", sourceIP,
+                      HexEncode.bytesToHexString(sourceMAC));
+        }
         Set<HostNodeConnector> hosts = arpRequestors.remove(sourceIP);
         if ((hosts == null) || hosts.isEmpty()) {
+            log.trace("Bailing out no requestors Hosts");
             return;
         }
         countDownTimers.remove(sourceIP);
         for (HostNodeConnector host : hosts) {
-            log.trace("Sending ARP Reply with src {}/{}, target {}/{}",
-                    new Object[] { sourceMAC, sourceIP, host.getDataLayerAddressBytes(), host.getNetworkAddress() });
-
+            if (log.isTraceEnabled()) {
+                log.trace("Sending ARP Reply with src {}/{}, target {}/{}",
+                          new Object[] {
+                              HexEncode.bytesToHexString(sourceMAC),
+                              sourceIP,
+                              HexEncode.bytesToHexString(host.getDataLayerAddressBytes()),
+                              host.getNetworkAddress() });
+            }
             if (connectionManager.isLocal(host.getnodeconnectorNode())){
                 sendARPReply(host.getnodeConnector(),
                         sourceMAC,
@@ -682,6 +698,12 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                         host.getDataLayerAddressBytes(),
                         host.getNetworkAddress());
             } else {
+                /*
+                 * In the remote event a requestor moved to another
+                 * controller it may turn out it now we need to send
+                 * the ARP reply from a different controller, this
+                 * cover the case
+                 */
                 arpRequestReplyEvent.put(
                         new ARPReply(
                             host.getnodeConnector(),
@@ -696,6 +718,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
 
     @Override
     public void entryUpdated(ARPEvent key, Boolean new_value, String cacheName, boolean originLocal) {
+        log.trace("Got and entryUpdated for cacheName {} key {} isNew {}", cacheName, key, new_value);
         enqueueARPCacheEvent(key, new_value);
     }
 
@@ -713,6 +736,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
             ARPCacheEvent cacheEvent = new ARPCacheEvent(event, new_value);
             if (!ARPCacheEvents.contains(cacheEvent)) {
                 this.ARPCacheEvents.add(cacheEvent);
+                log.trace("Enqueued {}", event);
             }
         } catch (Exception e) {
             log.debug("enqueueARPCacheEvent caught Interrupt Exception for event {}", event);
@@ -725,7 +749,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
     private class ARPCacheEventHandler implements Runnable {
         @Override
         public void run() {
-            while (true) {
+            while (!stopping) {
                 try {
                     ARPCacheEvent ev = ARPCacheEvents.take();
                     ARPEvent event = ev.getEvent();
@@ -733,20 +757,23 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA
                         ARPRequest req = (ARPRequest) event;
                         // If broadcast request
                         if (req.getHost() == null) {
+                            log.trace("Trigger and ARP Broadcast Request upon receipt of {}", req);
                             sendBcastARPRequest(req.getTargetIP(), req.getSubnet());
 
                         //If unicast and local, send reply
                         } else if (connectionManager.isLocal(req.getHost().getnodeconnectorNode())) {
+                            log.trace("ARPCacheEventHandler - sendUcatARPRequest upon receipt of {}", req);
                             sendUcastARPRequest(req.getHost(), req.getSubnet());
                         }
                     } else if (event instanceof ARPReply) {
                         ARPReply rep = (ARPReply) event;
                         // New reply received by controller, notify all awaiting requestors across the cluster
                         if (ev.isNewReply()) {
+                            log.trace("Trigger a generateAndSendReply in response to {}", rep);
                             generateAndSendReply(rep.getTargetIP(), rep.getTargetMac());
-
                         // Otherwise, a specific reply. If local, send out.
                         } else if (connectionManager.isLocal(rep.getPort().getNode())) {
+                            log.trace("ARPCacheEventHandler - sendUcatARPReply locally in response to {}", rep);
                             sendARPReply(rep.getPort(),
                                     rep.getSourceMac(),
                                     rep.getSourceIP(),
index 2f74ec39e4e0b559a2820ed0127c3fc750ba637d..fdf08bcbacdae07bc04fa362958864b1741fc5a4 100644 (file)
@@ -10,7 +10,7 @@
 /**
  * @file   IClusterContainerServices.java
  *
- * @brief  : Set of services and application will expect from the
+ * @brief  : Set of services an application will expect from the
  * clustering services provider. This interface is per-container and so
  * the container parameter is implicitely known
  *
@@ -21,9 +21,9 @@
 package org.opendaylight.controller.clustering.services;
 
 /**
- * Set of services and application will expect from the
- * clustering services provider. This interface is per-container and so
- * the container parameter is implicitly known
+ * Set of services an application will expect from the clustering services
+ * provider. This interface is per-container and so the container parameter is
+ * implicitly known
  *
  */
 public interface IClusterContainerServices extends IClusterServicesCommon {
index 61ad41529d286ae61e4360344f548e9a4461c3f4..58d8c0051b45e2efba4fd9fc587f0a28bc49a1be 100644 (file)
@@ -10,7 +10,7 @@
 /**
  * @file   IClusterGlobalServices.java
  *
- * @brief  : Set of services and application will expect from the
+ * @brief  : Set of services an application will expect from the
  * clustering services provider. This interface is supposed to have
  * Global scope
  *
@@ -21,9 +21,8 @@
 package org.opendaylight.controller.clustering.services;
 
 /**
- * Set of services and application will expect from the
- * clustering services provider. This interface is supposed to have
- * Global scope
+ * Set of services an application will expect from the clustering services
+ * provider. This interface is supposed to have Global scope
  *
  */
 public interface IClusterGlobalServices extends IClusterServicesCommon {
index 68960baa07a0d157b1c101fbdb6832208e54376c..a27b00eb1feb7d433cc8c46bed7ae84aa1baabc5 100644 (file)
@@ -10,7 +10,7 @@
 /**
  * @file   IClusterServices.java
  *
- * @brief  : Set of services and application will expect from the
+ * @brief  : Set of services an application will expect from the
  * clustering services provider
  *
  * Contract between the applications and the clustering service
@@ -33,7 +33,7 @@ import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 
 /**
- * Set of services and application will expect from the
+ * Set of services an application will expect from the
  * clustering services provider
  *
  */
index e292f73e540ee63aa07b7b28f9904c7d993ca28f..6850c64a0ed15774c3808773241659da7b75d7aa 100644 (file)
@@ -10,7 +10,7 @@
 /**
  * @file   IClusterServicesCommon.java
  *
- * @brief  : Set of services and application will expect from the
+ * @brief  : Set of services an application will expect from the
  * clustering services provider. This interface is going to be the
  * base for per-container and Global services and so the container
  * parameter is omitted but who uses knows about it
@@ -35,11 +35,12 @@ import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 
 /**
- * @deprecated for internal use
- * Set of services and application will expect from the
- * clustering services provider. This interface is going to be the
- * base for per-container and Global services and so the container
- * parameter is omitted but who uses knows about it
+ * This WILL NOT BE USED DIRECTLY, but VIA SUBCLASS
+ *
+ * Set of services and application will expect from the clustering services
+ * provider. This interface is going to be the base for per-container and Global
+ * services and so the container parameter is omitted but who uses knows about
+ * it
  *
  */
 public interface IClusterServicesCommon {
index eac854c10674f796fae64ec174aaef07aad4aed5..1b2128957e9352ffd93a0a0991abf91ec3a354ea 100644 (file)
@@ -232,6 +232,8 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
                     if (future != null) {
                         try {
                             host = future.get();
+                        } catch (InterruptedException ioe) {
+                            log.trace("Thread interrupted {}", ioe);
                         } catch (Exception e) {
                             log.error("", e);
                         }
index 7061954e80e199b2a52c49eeace78ad27b9d4518..283e756cd1b9edab8170158fb4152a6e20d365cc 100644 (file)
@@ -102,12 +102,15 @@ public class Activator implements BundleActivator {
                 this.bundlecontext = ctxt;
         }
 
+        @Override
         public void run () {
             try {
                 this.bundlecontext.getBundle(0).stop();
                 log.debug("shutdown handler thread called");
             } catch (BundleException e) {
                 log.debug("Bundle couldn't be stopped");
+            } catch (Exception e) {
+                log.debug("Unhandled exception");
             }
         }
     }